🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Newbie problem with bitmaps...

Started by
2 comments, last by KappaMic 24 years ago
I''ve loaded two bitmap, i want the second bitmap to be the background and i want to rotate the first bitmap. Where''s the problem??? how can i "select" which is the bitmap to manipulate at a certain point of my code?? I don''t want to rotate the second bitmap !!!!!!!!!!!!!!!!!!!!!!!!!!!! Here''s my code ("ripped" from a tutorial) procedure DrawGLScene(); begin glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT); glLoadIdentity(); glTranslatef(0.0,0.0,-5.0); //which bitmap ?????? glRotatef(xrot,1.0,0.0,0.0); //which bitmap ?????? glRotatef(yrot,0.0,1.0,0.0); //which bitmap ?????? glRotatef(zrot,0.0,0.0,1.0); //which bitmap ?????? glBindTexture(GL_TEXTURE_2D, texture[0]); //here i select the bitmap to be rotated glBegin(GL_QUADS); glNormal3f(-1.0, 0.0, 0.0); glTexCoord2f(0.0, 0.0); glVertex3f(-1.0, -1.0, -1.0); glTexCoord2f(1.0, 0.0); glVertex3f(-1.0, -1.0, 1.0); glTexCoord2f(1.0, 1.0); glVertex3f(-1.0, 1.0, 1.0); glTexCoord2f(0.0, 1.0); glVertex3f(-1.0, 1.0, -1.0); glEnd(); xrot := xrot + 0.5; yrot := yrot + 2.7; zrot := zrot + 0.3; glBindTexture(GL_TEXTURE_2D, texture[1]); //this is the background!!! glBegin(GL_QUADS); glNormal3f(-2.0, 0.0, 0.0); glTexCoord2f(0.0, 0.0); glVertex3f(-2.0, -2.0, -2.0); glTexCoord2f(2.0, 0.0); glVertex3f(-2.0, -2.0, 2.0); glTexCoord2f(1.0, 2.0); glVertex3f(-2.0, 2.0, 2.0); glTexCoord2f(0.0, 2.0); glVertex3f(-2.0, 2.0, -2.0); glEnd(); end; Many thanks!!!!!!!!!!!
Advertisement
Draw your background before you translate and rotate (after glLoadIdentity). OpenGL is a very procedural language. Everything is done immediately and forever. If you rotate, then everything that will be done afterward will be rotated.

EL
----------------------------------------"Inash neteia haeg joa kavari quilm..." SD4
Try this! (so you use Delphi?)

procedure DrawGLScene();

begin
glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(0.0,0.0,-5.0); //

glRotatef(xrot,1.0,0.0,0.0); //These are just
glRotatef(yrot,0.0,1.0,0.0); //for the whole
glRotatef(zrot,0.0,0.0,1.0); //rotation of the scene

glPushMatrix();

glBindTexture(GL_TEXTURE_2D, texture[0]);

glBegin(GL_QUADS);
glNormal3f(-1.0, 0.0, 0.0);
glTexCoord2f(0.0, 0.0); glVertex3f(-1.0, -1.0, -1.0);
glTexCoord2f(1.0, 0.0); glVertex3f(-1.0, -1.0, 1.0);
glTexCoord2f(1.0, 1.0); glVertex3f(-1.0, 1.0, 1.0);
glTexCoord2f(0.0, 1.0); glVertex3f(-1.0, 1.0, -1.0);
glEnd();

xrot := xrot + 0.5;
yrot := yrot + 2.7;
zrot := zrot + 0.3;

glPopMatrix();

glPushMatrix();

glBindTexture(GL_TEXTURE_2D, texture[1]); //this is the background!!!

glBegin(GL_QUADS);
glNormal3f(-2.0, 0.0, 0.0);
glTexCoord2f(0.0, 0.0); glVertex3f(-2.0, -2.0, -2.0);
glTexCoord2f(2.0, 0.0); glVertex3f(-2.0, -2.0, 2.0);
glTexCoord2f(1.0, 2.0); glVertex3f(-2.0, 2.0, 2.0);
glTexCoord2f(0.0, 2.0); glVertex3f(-2.0, 2.0, -2.0);
glEnd();

glPopMatrix();

end;


Everytime you use a new ''object'' You have to use the glPush..PopMatrix-thing!
So you can manipulate these objects and the others are not affected!

Hope this helps!

bye
Gunhed
Sorry made a mistake!!!

new code:

procedure DrawGLScene();

begin
glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(0.0,0.0,-5.0); //

glRotatef(xrot,1.0,0.0,0.0); //These are just
glRotatef(yrot,0.0,1.0,0.0); //for the whole
glRotatef(zrot,0.0,0.0,1.0); //rotation of the scene

glPushMatrix();

glRotatef(xrot2,1.0,0.0,0.0); //These are just
glRotatef(yrot2,0.0,1.0,0.0); //for the whole
glRotatef(zrot2,0.0,0.0,1.0); //rotation of the scene

glBindTexture(GL_TEXTURE_2D, texture[0]);

glBegin(GL_QUADS);
glNormal3f(-1.0, 0.0, 0.0);
glTexCoord2f(0.0, 0.0); glVertex3f(-1.0, -1.0, -1.0);
glTexCoord2f(1.0, 0.0); glVertex3f(-1.0, -1.0, 1.0);
glTexCoord2f(1.0, 1.0); glVertex3f(-1.0, 1.0, 1.0);
glTexCoord2f(0.0, 1.0); glVertex3f(-1.0, 1.0, -1.0);
glEnd();

xrot2 := xrot2 + 0.5;
yrot2 := yrot2 + 2.7;
zrot2 := zrot2 + 0.3;

glPopMatrix();

glPushMatrix();

glBindTexture(GL_TEXTURE_2D, texture[1]); //this is the background!!!

glBegin(GL_QUADS);
glNormal3f(-2.0, 0.0, 0.0);
glTexCoord2f(0.0, 0.0); glVertex3f(-2.0, -2.0, -2.0);
glTexCoord2f(2.0, 0.0); glVertex3f(-2.0, -2.0, 2.0);
glTexCoord2f(1.0, 2.0); glVertex3f(-2.0, 2.0, 2.0);
glTexCoord2f(0.0, 2.0); glVertex3f(-2.0, 2.0, -2.0);
glEnd();

glPopMatrix();

end;

Everytime you use a new ''object'' You have to use the glPush..PopMatrix-thing!
So you can manipulate these objects and the others are not affected!

Hope this helps!

bye
Gunhed

This topic is closed to new replies.

Advertisement