Hi there,
I hope someone can help with a problem I’m having. First of all, in my assignment I have to create a simple 2D game. So far, I’ve been able to draw a line using Bresenham’s algorith, and I have it rotating around the x-axis to make it like a radar beam.
Now, I have added a texture from a bitmap. See elow.
void drawUFO()
{
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, Texture[0]);
glBegin(GL_QUADS);
glTexCoord2f(0,0); glVertex3f(-300,0,0);
glTexCoord2f(1,0); glVertex3f(-250,0,0);
glTexCoord2f(1,-1); glVertex3f(-250,-50,0);
glTexCoord2f(0,-1); glVertex3f(-300,-50,0);
glEnd();
glFlush();
glDisable(GL_TEXTURE_2D);
glutPostRedisplay();
}
Now, I need to make this texture move across the screen. I assume I need to use something like glTranslatef. I’ve tried variations of things like below, but either the screen just flashes, or nothing is displayed.
void drawUFO()
{
int xCoor=-150;
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, Texture[0]);
glTranslatef(xCoor, 0,0);
glBegin(GL_QUADS);
glTexCoord2f(0,0); glVertex3f(-300,0,0);
glTexCoord2f(1,0); glVertex3f(-250,0,0);
glTexCoord2f(1,-1); glVertex3f(-250,-50,0);
glTexCoord2f(0,-1); glVertex3f(-300,-50,0);
glEnd();
glFlush();
glDisable(GL_TEXTURE_2D);
xCoor++;
glutSwapBuffers();
glutPostRedisplay();
}
It’s quite possible that the problems lies in other areas of my code…