• Advertisement

Archived

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

Okay, why ?

This topic is 5881 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

First I initalize my teture:
glEnable(GL_TEXTURE_2D);
	bitmapData = LoadBitmapFile("test.bmp", &bitmapInfoHeader);
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture);
glTexImage2D(GL_TEXTURE_2D,0,GL_RGB,bitmapInfoHeader.biWidth, bitmapInfoHeader.biHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, bitmapData);
 
Then I draw my thing:
glLoadIdentity();
			glTranslatef(x, y, z);
			glRotatef(r, 0.0f, 1.0f, 0.0f);


			glBegin(GL_QUADS);
				glColor3f(1.0f,1.0f,1.0f);
				glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 0.0f);
				glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f,-1.0f, 0.0f);
				glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f,-1.0f, 0.0f);
				glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 0.0f);
			glEnd();
 
And what the f-ck? No texture there!

Share this post


Link to post
Share on other sites
Advertisement
Try drawing the square like this:

glTexCoord2f(1, 1); glVertex2f(1.0f, 1.0f);
glTexCoord2f(0, 1); glVertex2f(-1.0f, 1.0f);
glTexCoord2f(0, 0); glVertex2f(-1.0f, -1.0f);
glTexCoord2f(1, 0); glVertex2f(1.0f, -1.0f);

Share this post


Link to post
Share on other sites
Are you sure your texture''s dimensions are powers of 2?
Are you sure the file loads properly?

Share this post


Link to post
Share on other sites
>>bitmapData = LoadBitmapFile("test.bmp", &bitmapInfoHeader);
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture);
glTexImage2D(GL_TEXTURE_2D,0,GL_RGB,bitmapInfoHeader.biWidth, bitmapInfoHeader.biHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, bitmapData);<<

youre missing about 4 lines check other ppls code eg wheres the filtering method + texture wrap

Share this post


Link to post
Share on other sites
they have to be called somewhere or else youll end up with a white texture (which is prolly what the poster is experiencing)

Share this post


Link to post
Share on other sites
Yes, they do need to be called at some point, but not neccesarily at the same time as glTexImage2D().

Share this post


Link to post
Share on other sites

  • Advertisement