Part of the Khronos Group

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: glTexImage2D Question

  1. #1
    Junior Member Regular Contributor
    Join Date
    Sep 2005

    Question glTexImage2D Question

    I work on a legacy Solaris system running Solaris 10. The application reads in various data files and produces many 2D plots of the data. They have numerous symbols that can be used on the plots. These bitmaps were created using Solaris's Icon Editor software and saved as XBM files. I have #included these files as they #define the width, height, and bits array for each icon.

    Currently, the software is ignoring the icon choice and manually drawing an 'X', '+', or 'filled square' on the plots for each data point using GL_LINES or GL_POLYGON inside glBegin and glEnd. I tried replacing this code with glRasterPos2f calls followed by glBitmap calls. This is horrendously slow and obviously not the way I want to go.

    I have read where using glTexImage2D would be a possible method to try so I can get all the possible symbol icons to work. Unfortunately, my plot is never guarenteed to be 2^m x 2^n in size. It can be whatever size they user wants. The only versions of OpenGL I can find for Solaris are 1.2, 1.3, and 1.5. When I first tried to update to 1.5, nothing on the plots worked. So instead of looking into this problem, I rolled back to 1.3 and will look into the 1.5 issues a little later (if it can wait).

    Where do I need to start looking at to try and use glTexImage2D? I will need to be able to tell the texture that I need a square centered around this point, a triangle centered around this point, and so on. Currently, 1000s to 10,000s of points will be drawn at one time, so I am thinking creating a texture containing all 1000+ icons will be more efficient than drawing each one "manually" but I am confused where I need to begin to start looking into this.

    Thanks for any help you have!

  2. #2
    Super Moderator OpenGL Guru
    Join Date
    Feb 2000
    Montreal, Canada
    You have to make sure your texture's dimensions are power of 2. You can scale them down or up with gluScaleImage or use gluBuild2DMipmaps which will do scale to nearest power of 2 and also generate the mipmaps for you. You also have to respect the max texture dimensions supported by your hardware.

    "I will need to be able to tell the texture that I need a square centered around this point, a triangle centered around this point, and so on"
    You should look for "billboarding" and I'm sure you'll get many hits.

    "texture containing all 1000+ icons"
    That's called a texture atlas and you can get some tips from here.
    an open source GLU replacement library. Much more modern than GLU.
    float matrix[16], inverse_matrix[16];
    glhTranslatef2(matrix, 0.0, 0.0, 5.0);
    glhRotateAboutXf2(matrix, angleInRadians);
    glhScalef2(matrix, 1.0, 1.0, -1.0);
    glhQuickInvertMatrixf2(matrix, inverse_matrix);
    glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
    glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

Tags for this Thread

Posting Permissions

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