• Advertisement

Archived

This topic is now archived and is closed to further replies.

Texture problems

This topic is 5293 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

*Sigh* I''ve been using textures in OpenGL for years now but they are allways unreliable and unpredictable. Usually I can fiddle with them enough that they work, but in the simple case I cannot get them to work proporly. Its a simple thing I''m doing, every frame I put new image info into the texture then apply it to a quad the size of the screen (aka. project it up onto the screen). This allows for easy resizing of the screen etc. Problem is its not working, I''m left with a white polygon every time no matter the input. The texture is created as follows:
		glEnable(GL_TEXTURE_2D);
		glGenTextures(1, &texid);
		glBindTexture(GL_TEXTURE_2D, texid);
		glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
		glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);

And then the image data is put into it and its applied to the square (on every frame, the preceeding code was only done once at the beginning):
	glEnable(GL_TEXTURE_2D);
	glBindTexture(GL_TEXTURE_2D, texid);	
	glTexImage2D(GL_TEXTURE_2D, 0, 3, 100, 100, 0, GL_RGB, GL_UNSIGNED_BYTE, screen);
	glColor4f(1.0f,1.0f,1.0f,1.0f);
	glBegin(GL_QUADS);
	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();
Thanks, ~SPH

Share this post


Link to post
Share on other sites
Advertisement

  • Advertisement