I’m trying to make a simple textured rectangular in OpenGL using SOIL and GLUT.
This is my Display function (executed in main by glutDisplayFunc(Display)):
void Display () { GLuint tex_2d; glMatrixMode (GL_MODELVIEW); glLoadIdentity (); glClear (GL_COLOR_BUFFER_BIT); glClearColor (1.0,1.0,1.0,1.0); gluLookAt (eyex,eyey,eyez,centerx,centery,centerz,0,1,0); glEnable(GL_TEXTURE_2D); tex_2d = SOIL_load_OGL_texture ( 'img.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 ); if( 0 == tex_2d ) { printf( 'SOIL loading error: '%s'\n', SOIL_last_result() ); exit(1); } glBindTexture(GL_TEXTURE_2D, tex_2d); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR); glColor3f (0.0,0.0,0.0); glBegin(GL_POLYGON); glTexCoord2f(0.0f, 0.0f); glVertex2f(0.0f, 0.0f); glTexCoord2f(1.0f, 0.0f); glVertex2f(1.0f, 0.0f); glTexCoord2f(1.0f, 1.0f); glVertex2f(1.0f, 1.0f); glTexCoord2f(0.0f, 1.0f); glVertex2f(0.0f, 1.0f); glEnd(); glDisable(GL_TEXTURE_2D); glFlush (); glutSwapBuffers(); }
With this is see only a black rectangular without any texture. I’m trying to do something with this for a few hours. Please help, thanks in advance.
Could it be that you set the color to black just before you draw the rectangle? The line
Try white instead…