I don't understand why my texture("texture.bmp"), is not showing on the screen. Please help me.
The whole drawing function:
///HERE EVERYTHING IS BEING RENDERED
void Main::display(){
int startTime = GetTickCount();
///BACKGROUND COLOR
glClearColor(0.3f, 0.3f, 2.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
///LOAD THE IDENTITY MATRIX FOR THE DRAWING
glLoadIdentity();
///SO EVERYTHING HAS THE CORRECT SIZE
glTranslatef(0.0f, 0.0f, -5.0f);
///CAMERA MOVEMENT
glTranslatef(cameraX, 0.0f, 0.0f);
///THE SUN
glBegin(GL_QUADS);
glColor3f(1.0f,1.0f,0.0f);
glVertex2f(-3.0f, 2.0f); // The bottom left corner
glVertex2f(-3.0f, 2.5f); // The top left corner
glVertex2f(-2.5f, 2.5f); // The top right corner
glVertex2f(-2.5f, 2.0f); // The bottom right corner
glEnd();
///THE GROUND
glBegin(GL_QUADS);
glColor3f(0.5f,2.0f,0.5f);
glVertex2f(-20.0f,-4.0f);
glVertex2f(-20.0f,-1.0f);
glVertex2f(130.0f,-1.0f);
glVertex2f(130.0f,-4.0f);
glColor3f(0.0f,1.0f,0.0f);
for(float i = 0.0f ; i < 100.0f ; i += 5.0f){
glVertex2f(i,-1.0f);
glVertex2f(i,ranFloat[static_cast<int>(i-4.0f)]);
glVertex2f(i+1.0f,ranFloat[static_cast<int>(i-4.0f)]);
glVertex2f(i+1.0f,-1.0f);
}
glEnd();
///THE GRASS
glBegin(GL_QUADS);
glColor3f(0.0f,0.5f,0.0f);
glVertex2f(-20.0f,-1.2f);
glVertex2f(-20.0f,-1.0f);
glVertex2f(130.0f,-1.0f);
glVertex2f(130.0f,-1.2f);
glEnd();
///THE PLAYER
glTranslatef(playerX,playerY,0.0f);
glBegin(GL_QUADS);
glColor3f(1.0f,0.0f,0.0f);
glVertex2f(-3.0f,-1.0f);
glVertex2f(-3.0f,0.0f);
glVertex2f(-2.8f,0.0f);
glVertex2f(-2.8f,-1.0f);
glEnd();
///TEXTUREEEEEEEEEEEEEEEEEEEEEE
glBindTexture(GL_TEXTURE_2D,texture);
glEnable(GL_TEXTURE_2D);
int X = 0;
int Y = 0;
int Width = 1;
int Height = 1;
glBegin(GL_QUADS);
glTexCoord2f(0, 0); glVertex3f(X, Y, 0);
glTexCoord2f(0, 1); glVertex3f(X + Width, Y, 0);
glTexCoord2f(1, 1); glVertex3f(X + Width, Y + Height, 0);
glTexCoord2f(1, 0); glVertex3f(X, Y + Height, 0);
glEnd();
glDisable(GL_TEXTURE_2D);
///CLOUDS
glBegin(GL_QUADS);
glColor3f(1.0f,1.0f,1.0f);
for(float i = 0.0f ; i < 100.0f ; i += 5.0f){
glVertex2f(i,3.0f);
glVertex2f(i,4.0f);
glVertex2f(i+4.0f,3.0f);
glVertex2f(i+4.0f,4.0f);
}
glEnd();
if(Input::flying){
Input::returnFly(0.007f);
}
elapsedMS = GetTickCount() - startTime; // Time since start of loop
//std::cout << "FPS: " << elapsedMS << std::endl;
///THE ACTUAL MOVEMENT
playerY += playerFly;//*elapsedMS;
playerX += cameraSpeed*-1;//*elapsedMS;
cameraX += cameraSpeed;//*elapsedMS;
///SWAP THE BUFFERS FOR SMOOTH RENDERING
glutSwapBuffers();
}
The rest of my code has nothing to do with the texture loading. The loading is not the problem, because I didn't get any errors.