SOIL and SDL_opengl
Iv been working to use SOIL in my opengl program, everything seems ok until i load an image. Befor i simple test program would draw line in opengl and it all worked just fine.
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_LINES);
glColor4f(1,1,1,1);
glVertex2f(100,100);
glVertex2f(200,100);
glEnd()
SDL_GL_SWAPBUFFERS();
I saw this gl line just fine, but after i use my texture manager to load the image into my texture list i can no longer see the line, as if the image loading stopped my glcontext from updating or something. Im very new to opengl so please excuse me if this is elementary stuff. I know the line code is being run as it dropped in some cout tests in it. Is there something that SOIL does that i need to be aware of?
Quote:Original post by schragnasher
Iv been working to use SOIL in my opengl program, everything seems ok until i load an image. Befor i simple test program would draw line in opengl and it all worked just fine.
I'm not sure, but SOIL may enable texturing behind your back, or you may have done it. Be sure to call glDisable(GL_TEXTURE_2D) before trying to draw the line.
Quote:I know the line code is being run as it dropped in some cout tests in it.
It's never to early to start using a debugger! [smile]
well that seems to have worked, but i was under the impression i wanted to enable texture2d as im using GL for 2d? Disabling TEXTURE_3D seems to make this work out as well. What is the right setup for a 2d game?
Quote:Original post by schragnasher
well that seems to have worked, but i was under the impression i wanted to enable texture2d as im using GL for 2d? Disabling TEXTURE_3D seems to make this work out as well. What is the right setup for a 2d game?
The right setup for any game is to enable what you want, and disable what you don't want. It seems that SOIL is doing some enabling that you didn't, and it is sticking around when it comes time for you to do your drawing. So, when you draw your line, OpenGL is expecting it to be textured, since SOIL told it that texturing was happening. Since you didn't supply texture coordinates (glTexCoord*), default ones were supplied which could have caused any color to show up on the line, depending on the texture.
Disabling texturing told OpenGL "Hey, OpenGL, I was using some texture capabilities [to load a texture], but I'm not any more, so treat this next stuff as untextured!" Do your business, and then enable texturing when you need it later.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement