Results 1 to 4 of 4

Thread: Pixel color format

  1. #1
    Junior Member Newbie
    Join Date
    May 2001
    Location
    Huntsville, AL, USA
    Posts
    2

    Pixel color format

    I'm attempting to use the glDrawPixels function to view some data in color at particular pixel locations. I'm able to accomplish this ok in a gray scale environment. I'm including the approach I used for that situation. Any comments (or examples to point me to) on how to see the color RGB values displayed would be appreciated. Please be specific as I'm a beginner with openGl.

    Here's a snippet of my current implementation:

    float *TheTempData;

    int BufferSize = window_width*window_height;
    TheTempData = new float[BufferSize];

    for( row = 0; row < window_height; row++)
    {
    rowoffset = row*width;

    for( col = 0; col < widow_width; col++)
    {
    int index = rowOffset + col;

    float temp = call to a function that returns a floating point value for temperature from a floating point 2-D array.

    float grey_temp = (temp - minTemp) / (maxTemp - minTemp); // max/minTemp are floats

    grey_temp = MAX(grey_temp, 0.0);
    grey_temp = MIN(grey_temp, 1.0);
    TheTempData[index] = grey_temp;
    }
    }

    To draw the pixels:

    glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
    glPushMatrix();

    glDrawPixels(window_width, window_height, GL_LUMINANCE, GL_FLOAT, TheTempData);

    I just want to display the same data in color, and if possible, avoid reading in the database (that the temperature values are extracted from) in a different data type (e.g. unsigned long as opposed to the current float type).

    Thanks for the help!

  2. #2
    Guest

    Re: Pixel color format

    If you just want to display it in shades of one color can you try to replace GL_LUMINANCE with GL_RED, GL_BLUE or GL_GREEN.

  3. #3
    Junior Member Newbie
    Join Date
    May 2001
    Location
    Huntsville, AL, USA
    Posts
    2

    Re: Pixel color format

    Originally posted by nvidia_linux:
    If you just want to display it in shades of one color can you try to replace GL_LUMINANCE with GL_RED, GL_BLUE or GL_GREEN.
    I actually would like to use the GL_RGB format with the appropriate data type. I'm not sure how to send the data into an array so that the RGB values would be deciphered by the glDrawPixels function. With the current implementation, I have a float array (TheTempData) that sends a float value. How do I convert the float value such that a Red Green and Blue color could be associated with it and be interpreted within glDrawPixels? Is this even possible? Thanks!

  4. #4
    Guest

    Re: Pixel color format

    I guess you just have to make your arrays 3 times bigger and replace GL_LUMINANCE with GL_RGB. Each floating point is between 0..1 in the order red, green and blue.

Similar Threads

  1. Get the pixel / color format of the draw buffer?
    By taifunbrowser in forum OpenGL: Windows
    Replies: 4
    Last Post: 07-05-2009, 11:08 AM
  2. Pixel Format vs. Display Format
    By Nakoruru in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 08-16-2002, 05:17 AM
  3. How to convert GL_RGB pixel data format (image) to GL_RGBA format
    By Coloro.cl in forum OpenGL: Basic Coding
    Replies: 8
    Last Post: 02-13-2002, 06:01 AM
  4. Pixel Format
    By Rong Yao in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 06-26-2001, 05:30 AM
  5. pixel format
    By tah in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 10-30-2000, 07:55 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean