gluDisk Texture mapping problem


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:

  1. function used to draw the primitives

  2. the function used to load textures

  3. generate a display list for the disk primitive

Thank you in advance for any help given.



In-game screenshot:

texture bmp:

void HeadsUpDisplay::draw()
glAlphaFunc(GL_GEQUAL, 0.0f);

glCallList(box); // Draw The Box

} // 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,
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


glNewList(box, GL_COMPILE); // New Compiled box Display List

glTranslatef(-270, -98,0);

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);

glEndList(); // Done Building The box List

} // End BuildLists()

If you insist on using gluDisc then you have to make sure that the speedometer uses the entire textures width and height, there is no other way.

Unless that is of cause you decide to use a single quad instead of a disc (like that speed boost thingy) and alpha blending, in this case it will look a lot better.

I think gluDisk maps the texture coordinates in a doesnt gluDisk map coordinates like a polor coordinate system? but your texure looks like it’s mapped out in cartesian space, so why not just draw a simple quad with your texture and use alpha blending to get rid off transparent space?