Yes, I´m newbie
I´ve been working with NeHe´s Tutorials and mixing them with others (perhaps bad idea)
Anyway, I finaly managed to have the infamous spining cube… and textured!!!
Next step; the HUD, my fist attempt was to build a simple white rectangle, but a grey one appeared And when I press “F” (to change the texture of the cube from Nearest to Linear to MipMapping) the grey rectangle changes to a darker one
- Nearest -> grey rectangle
- Linear -> dark grey rectangle
- MipMap -> dark grey rectangle
Here´s some code:
glGenTextures(3,&texture[0]);
// Create Nearest Filtered Texture
glBindTexture(GL_TEXTURE_2D, texture[0]);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);
// Create Linear Filtered Texture
glBindTexture(GL_TEXTURE_2D, texture[1]);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);
// Create MipMapped Texture
glBindTexture(GL_TEXTURE_2D, texture[2]);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);
gluBuild2DMipmaps(GL_TEXTURE_2D,3,TextureImage[0]->sizeX,TextureImage[0]->sizeY,GL_RGB,GL_UNSIGNED_BYTE, TextureImage[0]->data);
//That is part of the code that creates the
// textures
int DrawGLScene(GLvoid)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(0.0f,0.0f,z);
glRotatef(xrot,1.0f,0.0f,0.0f);
glRotatef(yrot,0.0f,1.0f,0.0f);
glRotatef(zrot,0.0f,0.0f,1.0f);
glBindTexture(GL_TEXTURE_2D, texture[filter]);
//When you press F “filter” cycles trough
//[0,1,2] ;the textures from above
glBegin(GL_QUADS);
//The six faces of the cube with normals
//and texture coordinates
glEnd();
//*********
//** HUD **
//*********
glLoadIdentity();
glDisable(GL_DEPTH_TEST);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glDisable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING);
gluOrtho2D (0, 10, 10,0 );
glColor3f(1.0f,1.0f,1.0f);
glBegin(GL_QUADS);
glVertex2f(0.0f,0.0f);
glVertex2f(0.0f,5.0f);
glVertex2f(10.0f,5.0f);
glVertex2f(10.0f,0.0f);
glEnd();
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
return true;
}
Hope this is some stupid newbie mistake.
Thanks anyway
?