Hello,
I am currently working on a HUD for a racing game. I have a speedometer texture that I am mapping to a gluDisk() primitive and the problem I am having is that the extra white space from the texture is getting mapped to the disk (see link below).
I want to know of a way to just map the useful part of my texture to the primitive. Below is the code used to:
-
function used to draw the primitives
-
the function used to load textures
-
generate a display list for the disk primitive
Thank you in advance for any help given.
Tensaijin
Links
In-game screenshot: http://public.csusm.edu/TensaiMations/EV_prob_1.jpg
texture bmp: http://public.csusm.edu/TensaiMations/spd_odometer.bmp
void HeadsUpDisplay::draw()
{
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GEQUAL, 0.0f);
glEnable2D();
LoadTex(spd_odometer);
glCallList(circle);
LoadTex(spd_boost_gauge);
glCallList(box); // Draw The Box
glDisable2D();
} // End draw()
void HeadsUpDisplay::LoadTex(SDL_Surface* tex)
{
glBindTexture(GL_TEXTURE_2D, texture);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); // scale linearly when image bigger than texture
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST); // scale linearly + mipmap when image smalled than texture
glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE_ALPHA, tex->w, tex->h, 0,
GL_BGR_EXT, GL_UNSIGNED_BYTE, tex->pixels);
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, tex->w, tex->h, GL_BGR_EXT,
GL_UNSIGNED_BYTE, tex->pixels);
} // End LoadTex()
GLvoid HeadsUpDisplay::BuildLists() // Build Box Display List
{
box = glGenLists(2); // Build a List
circle = box + 1;
glNewList(circle, GL_COMPILE); // New Compiled box Display List
glTranslatef(624, -98,0);
gluQuadricTexture(quad, GL_TRUE);
gluDisk(quad, 0, 100, 100, 1); // Draw a disk
glEndList();
glNewList(box, GL_COMPILE); // New Compiled box Display List
glTranslatef(-270, -98,0);
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f); glVertex2d(0, 0);
glTexCoord2f(0.0f, 1.0f); glVertex2d(228,0);
glTexCoord2f(1.0f, 1.0f); glVertex2d(228, 63);
glTexCoord2f(1.0f, 0.0f); glVertex2d(0, 63);
glEnd();
glEndList(); // Done Building The box List
} // End BuildLists()