I'm just starting with opengl. This is my first project, in fact.
I want to map some texture to a quadrilateral in the background and want to draw a sphere using gluSphere in the front and I want to animate this. So, I map the texture first, then draw the sphere in the display function and then call glutPostRedisplay. It does show the texture and the sphere correctly when display is first called. But, as soon as glutPostRedisplay is called, the texture disappears and only the sphere is drawn. I have given my code below. I apologize for using any bad opengl practices.
<code>void display()
{
glClear(GL_COLOR_BUFFER_BIT);
drawTex();
glPushMatrix();
glTranslatef(SIZE/2, SIZE/2, 0);
glutSolidSphere(15.0, 20, 20);
glPopMatrix();
glutSwapBuffers();
glutPostRedisplay();
}
void LoadTextureRAW( const char * filename, int wrap )
{
GLuint texture;
int width, height;
unsigned char * data;
FILE * file;

What is 1 doing there? That's not a value you obtained from GL is it?
Use glGenTexture to obtain the ID.

Alfonse Reinheart

12-04-2011, 11:57 AM

Technically, that's perfectly legal (pre-GL 3.1 core). One of the stupider bits of old-school GL objects is that they are required to allow the user to basically pick a GLuint number and use it as an object name. The driver has to play along and create an object for it. You don't have to use glGen* to generate them.