1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
Gluint texture[100];
int LoadGLTextures(int ID)
{
texture[ID] = SOIL_load_OGL_texture("game_textures/buy_screen/egg_fef.bmp", SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, SOIL_FLAG_INVERT_Y);
glBindTexture(GL_TEXTURE_2D, texture[ID]);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
return true;
}
void drawTexture(int id, float x, float y, float z, float scale)
{
LoadGLTextures(id);
glBindTexture(GL_TEXTURE_2D, texture[id]);
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f); glVertex3f(-scale+x, -scale+y, z);
glTexCoord2f(1.0f, 0.0f); glVertex3f( scale+x, -scale+y, z);
glTexCoord2f(1.0f, 1.0f); glVertex3f( scale+x, scale+y, z);
glTexCoord2f(0.0f, 1.0f); glVertex3f(-scale+x, scale+y, z);
glEnd();
}
//......
//in the draw function
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glColor3d(light,light,light);
drawTexture(48, -.86, 1.44, -2.9995, .64);
//bluh bluh, other code
glutSetWindow(1);
resize(600,600);
glutPostRedisplay();
glutSwapBuffers(); //352, 234
|