Results 1 to 4 of 4

Thread: do i have any problem on glDrawPixels()?

  1. #1
    Junior Member Newbie
    Join Date
    Aug 2004
    Location
    shanghai,PRC
    Posts
    16

    do i have any problem on glDrawPixels()?

    I have setup an array of 400*400 in the memory.Each element of the array is a voxel(each voxel contains three unsigned int,representing the red, green, and blue color respectively)
    Then, I want to display the array in an opengl window that has been constructed.However, after I called the function glDrawPixel(400,400,GL_RGB,GL_UNSIGNED INT,pImage),nothing was displayed.What would be the problem?Can anyone help me?Thanks
    //the default position of raster is (0,0);
    glDrawPixels(400,400,GL_RGB,GL_UNSIGNED INT,m_Image.pImage);
    //Is there any problem? how i need to set the glOrhho()?and how about the glViewport()?
    I want to display the picture in an opengl window that has been constructed.

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    2,978

    Re: do i have any problem on glDrawPixels()?

    Do you use the whole range of an unsigned int in your image? OpenGL maps integer color values so that the maximum representable value maps to maximum intensity. For unsigned ints, that means the entire color range is from 0 (black) to ~4.2 billion (white, or maximum intensity).

  3. #3
    Junior Member Newbie
    Join Date
    Aug 2004
    Location
    shanghai,PRC
    Posts
    16

    Re: do i have any problem on glDrawPixels()?

    If the problem lies in the wrong use of the unsigned int, I guess the values I set to the elements will approximately equal to zero when changed to the range of [0.0,1.0].Then, when I change the background of the window to white,a black image would display on the "white canvus".But in fact, nothing happened.
    Am I right? I am not sure.Thanks.

  4. #4
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    2,978

    Re: do i have any problem on glDrawPixels()?

    Yes, you are correct that you should get a black image if you only use a small fraction of the full range. For example, if you use unsigned integers, but only use colors in the range [0, 255] (an unsigned byte), when converted to the range [0, 1], you effectively get the range [0, ~0.0000006]. So a white clear color should give you a white background with a black square where the image goes.

    Is the raster position correct then? If you set it explicitly, make sure it's valid. If you don't set it anywhere, the default is the lower left corner and it a valid position, so no need to worry about it then.

    If the raster position is not a problem, you have to provide more details about what you're doing. There's nothing wrong with the calls to glDrawPixels as you posted them, assuming the parameters passed matches the actual image.

Similar Threads

  1. glDrawPixels problem
    By imported_xargon in forum OpenGL: Basic Coding
    Replies: 10
    Last Post: 02-14-2006, 01:02 PM
  2. Problem with glDrawPixels
    By yaro_dup1 in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 04-16-2003, 11:55 AM
  3. glDrawPixels Problem
    By mop in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 01-09-2003, 06:27 PM
  4. glDrawPixels problem
    By Menne in forum OpenGL: Advanced Coding
    Replies: 3
    Last Post: 02-02-2002, 03:55 AM
  5. problem with glDrawPixels
    By Nicola Mosca in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 01-25-2001, 01:32 AM

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