PDA

View Full Version : OpenGL doesn't render my texture



estate8143
12-30-2012, 10:21 AM
Hi,

my code doesn't cause OpenGL to render my texture:



//This is in the load routine:
qglBindTexture( GL_TEXTURE_2D, texture );
qglTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
qglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILT ER,GL_LINEAR);
qglTexImage2D(GL_TEXTURE_2D, 0, 3, tileWidth, tileHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, data);



//This is in the render loop:
qglEnable(GL_DEPTH_TEST);
qglDepthFunc(GL_LEQUAL);

qglClearColor( 0.0f, 0.0f, 0.0f, 0.0f) ;
qglClear(GL_COLOR_BUFFER_BIT);
qglClear(GL_DEPTH_BUFFER_BIT) ;
qglMatrixMode(GL_MODELVIEW) ;
qglLoadIdentity();

qglEnable( GL_TEXTURE_2D );
GL_Color(0.2f, 0.2f, 1.0f, 1);

qglBindTexture( GL_TEXTURE_2D, texture);

qglBegin(GL_QUADS);
qglTexCoord2f(1.0f,0.0f);
qglVertex3f( 1.0f*scaleSkybox,-1.0f*scaleSkybox, scaleSkybox);
qglTexCoord2f(1.0f,1.0f);
qglVertex3f( 1.0f*scaleSkybox,1.0f*scaleSkybox, scaleSkybox);
qglTexCoord2f(0.0f,1.0f);
qglVertex3f(-1.0f*scaleSkybox, 1.0f*scaleSkybox, scaleSkybox);
qglTexCoord2f(0.0f,0.0f);
qglVertex3f( -1.0f*scaleSkybox, -1.0f*scaleSkybox, scaleSkybox);
qglEnd();

qglDisable(GL_TEXTURE_2D);


The only result is the tinted square, like I specified with GL_Color()

I tried a lot, but this refuses to work.
There is no OpenGL error, and the texture data is loaded properly.

I should also mention, that this code is written in C for the Darkplaces Engine to replace the skybox with an animated one.

Edit: Also, I get a vaild number for texture, as loaded.