Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: gluDisk Texture mapping problem

  1. #1
    Junior Member Newbie
    Join Date
    Nov 2006
    Posts
    1

    gluDisk Texture mapping problem

    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:

    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.

    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_FILTE R,GL_LINEAR); // scale linearly when image bigger than texture
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTE R,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()

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Feb 2006
    Location
    Sweden
    Posts
    748

    Re: gluDisk Texture mapping problem

    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.

  3. #3
    Junior Member Newbie
    Join Date
    Jul 2006
    Posts
    11

    Re: gluDisk Texture mapping problem

    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?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •