Skip to main content
gamedev.net
🔒 Locked

Okay, why ?

Started by Moogle 7 replies 450+ views
Original Post
Moogle
Moogle
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!
-=Moogle=-
BlackHwk4
BlackHwk4
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);
Omaha
Omaha
Are you sure your texture''s dimensions are powers of 2?
Are you sure the file loads properly?
zedzeek
zedzeek
>>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
Omaha
Omaha
You don''t need to specify those at load time.
zedzeek
zedzeek
they have to be called somewhere or else youll end up with a white texture (which is prolly what the poster is experiencing)
Omaha
Omaha
Yes, they do need to be called at some point, but not neccesarily at the same time as glTexImage2D().
Moogle
Moogle
Oh I found out.
I added thoose min and mag filter things...
-=Moogle=-
Moogle
Moogle
Oh I found out.
I added thoose min and mag filter things... thanks
-=Moogle=-

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.