Tycho Brahe
|
|
« on: February 26, 2010, 02:53:14 PM » |
|
Hi guys, I've been trying to use soil to get images loaded into my project and I've run into a problem. When I try to load an image using SOIL_load_OGL_texture, the function fails and doesnt return a proper GLuint texture reference. What I'm doing is this: easy_texture = SOIL_load_OGL_texture("tex.png",SOIL_LOAD_AUTO,SOIL_CREATE_NEW_ID,SOIL_FLAG_MIPMAPS|SOIL_FLAG_INVERT_Y|SOIL_FLAG_NTSC_SAFE_RGB|SOIL_FLAG_COMPRESS_TO_DXT); From this I get a reference of 0, which the soil reference tells me means that its failed. I've tried using variations on it, but it still hasn't worked, has anyone got any advice on how to get it to load correctly? or alternatively, some sample code which works which should load the image as a texture... Thanks in advance! Adam
|
|
|
Logged
|
|
|
|
Aquin
|
|
« Reply #1 on: February 26, 2010, 02:57:54 PM » |
|
Are you sure about the filename path to your image?
You might think "yeah it's right here totally fine." BUT
Are you sure about the 'working directory' settings for your project? I'd check both of these things first, because it looks like the file isn't being found from your error.
|
|
|
Logged
|
I'd write a devlog about my current game, but I'm too busy making it.
|
|
|
Tycho Brahe
|
|
« Reply #2 on: February 26, 2010, 03:05:31 PM » |
|
I'm pretty sure it is, this is assumming that SOIL uses the directory that the excutable is in as the working directory. I've also tried it with a absolute path to the file as well, with no joy their either, so I'm not sure thats it.
|
|
|
Logged
|
|
|
|
Glaiel-Gamer
Guest
|
|
« Reply #3 on: February 26, 2010, 03:06:38 PM » |
|
did you create an opengl context?
|
|
|
Logged
|
|
|
|
Tycho Brahe
|
|
« Reply #4 on: February 26, 2010, 03:18:59 PM » |
|
I've got opengl working and this is the only thing in it that isint working in it. I can render to the context and even draw a texture, even though it hasn't been loaded yet.
|
|
|
Logged
|
|
|
|
Zaphos
Guest
|
|
« Reply #5 on: February 26, 2010, 05:34:40 PM » |
|
Does your code initialize opengl *before* trying to load the texture?
|
|
|
Logged
|
|
|
|
Sos
|
|
« Reply #6 on: February 26, 2010, 10:11:48 PM » |
|
easy_texture = SOIL_load_OGL_texture("tex.png",4,0,SOIL_FLAG_POWER_OF_TWO|SOIL_FLAG_MIPMAPS|SOIL_FLAG_INVERT_Y);
Try now. you probably lack dxt support
|
|
|
Logged
|
|
|
|
Tycho Brahe
|
|
« Reply #7 on: February 27, 2010, 09:47:31 AM » |
|
still not working. Are there any functions which need to be called before using soil? I know that DevIL needed to be initialised before it would work and I'm wondering if its the same with SOIL
[EDIT] Actually, this does work! but only with a .bmp file, not with PNG files. I'm now trying to work out why...
|
|
« Last Edit: February 27, 2010, 10:20:17 AM by 14113 »
|
Logged
|
|
|
|
skyy
|
|
« Reply #8 on: February 27, 2010, 10:30:18 AM » |
|
Went through one of my old projects just to find out how I loaded PNG files using SOIL, heh. Here we go: _ID = 0;
_ID = SOIL_load_OGL_texture( filename.c_str(), SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, SOIL_FLAG_MULTIPLY_ALPHA ); // loads the actual texture in as opengl texture
if( !_ID ) // error loading file { std::cout << "Texture " << filename.c_str() << " not loaded. " << std::endl; return false; }
Meh... Straight paste from old project but yeah, that's the way I did it. Don't know does it help at all but hopefully it does.
|
|
|
Logged
|
|
|
|
Tycho Brahe
|
|
« Reply #9 on: February 27, 2010, 10:57:53 AM » |
|
damn, even that doesnt work. The SOIL functions only seem to work for me with BMP images. Its possible that I'm creating my png textures improperly, I not sure though... [EDIT] SOLVED IT!! I downloaded an example .png image (from here http://entropymine.com/jason/testbed/pngtrans/) and tried to load that and it worked. I need to look at how its saved to make sure my textures can be loaded (they cant at the moment)
|
|
« Last Edit: February 27, 2010, 11:07:55 AM by 14113 »
|
Logged
|
|
|
|
Zaphos
Guest
|
|
« Reply #10 on: February 27, 2010, 11:07:38 AM » |
|
IIRC SOIL is just a layer on top of stb_image, which isn't designed to handle all image files (the idea being, as a developer you can create ones that are nice for it to handle), though it has handled the png files I've created. So, it could be that it just doesn't like something about the way you're generating pngs ...
|
|
|
Logged
|
|
|
|
Tycho Brahe
|
|
« Reply #11 on: February 27, 2010, 11:08:33 AM » |
|
Thanks all, as I said in the edit I've solved it! Thanks to all!
|
|
|
Logged
|
|
|
|
skyy
|
|
« Reply #12 on: February 27, 2010, 11:17:44 AM » |
|
I gotta say, it's always a great moment when something starts working after you've smashed your head on the wall for ages about it
|
|
|
Logged
|
|
|
|
Tycho Brahe
|
|
« Reply #13 on: February 27, 2010, 11:49:00 AM » |
|
Yeah, its working...but I've realised its not loading the alpha values correctly so its not semi-transparent...DAMN!
|
|
|
Logged
|
|
|
|
Tycho Brahe
|
|
« Reply #14 on: February 27, 2010, 12:08:57 PM » |
|
again, my fault, I'd forgotten to enable GL_BLEND
idiot me...
|
|
|
Logged
|
|
|
|
Glaiel-Gamer
Guest
|
|
« Reply #15 on: February 27, 2010, 02:50:14 PM » |
|
again, my fault, I'd forgotten to enable GL_BLEND
idiot me...
don't you just love those errors It took me like 2 days to find out the reason my texture loading code wasn't working was cause I forgot to enable GL_TEXTURE_2D that happens EVERY TIME I write a graphics engine too. You'd think I'd learn by now.
|
|
|
Logged
|
|
|
|
Sos
|
|
« Reply #16 on: February 27, 2010, 06:40:25 PM » |
|
haha! I have like 30 lines of GL init code for copy pasting to do that for me. You shpuld get some too.
|
|
|
Logged
|
|
|
|
|