Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Is 'glDrawPixels' a valid call list command?

  1. #1
    Member Newbie
    Join Date
    Jul 2001
    Location
    boston, ma, usa
    Posts
    30

    Is 'glDrawPixels' a valid call list command?

    When a new list is created, will the 'glDrawPixels' be stored in it?

    Thank you.

  2. #2
    Senior Member Frequent Contributor
    Join Date
    Feb 2000
    Location
    France
    Posts
    880

    Re: Is 'glDrawPixels' a valid call list command?

    Yes, it is legal to call glDrawPixels from within a display list.

    You can actually also call glReadPixels when compiling a display list but the catch is that this call would be executed immediately instead of being compiled. Here are a few functions that are executed immediately but not compiled into the display list:

    glIsList, glGenLists, glDeleteLists, glFeedbackBuffer, glSelectBuffer, glRenderMode, glReadPixels, glPixelStore, glFlush, glFinish, glIsEnabled

    As you can see, glDrawPixels is not in there (I took that from MSDN).

    Regards.

    Eric

  3. #3
    Member Newbie
    Join Date
    Jul 2001
    Location
    boston, ma, usa
    Posts
    30

    Re: Is 'glDrawPixels' a valid call list command?

    Thank you.

    In fact, what I need to do is to keep the depth buffer and restore it later. The following is my code, but it dosen't work:

    //keep the old depth buffer
    glGetIntegerv(GL_VIEWPORT, viewport);

    m_width = viewport[2];
    m_height = viewport[3];
    if (m_DepthBuffer == NULL)
    m_DepthBuffer = new GLfloat[viewport[2]*viewport[3]];
    glReadPixels(0, 0, m_width, m_height, GL_DEPTH_COMPONENT, GL_FLOAT, m_DepthBuffer);

    m_nClipList = glGenLists(1);
    glNewList(m_nClipList, GL_COMPILE);

    GLfloat r, g, b;
    myGdiToGlColor(m_Color, r, g, b);
    glColor3f(r, g, b);


    glClear(GL_DEPTH_BUFFER_BIT);
    glEnable(GL_DEPTH_TEST);
    //...perform some operations that may change the depth buffer


    //restore the depth buffer
    glDepthMask(GL_TRUE);
    //glClear(GL_DEPTH_BUFFER_BIT);
    glRasterPos2i(0, 0);
    glDrawPixels(m_width, m_height, GL_DEPTH_COMPONENT, GL_FLOAT, m_DepthBuffer);

  4. #4
    Senior Member OpenGL Pro
    Join Date
    Jun 2000
    Location
    Shreveport, LA, USA
    Posts
    1,502

    Re: Is 'glDrawPixels' a valid call list command?

    Remember that the raster position is transformed just like any other vertex. So be sure your projection and modelview matrices are properly configured before setting the raster postion.

  5. #5
    Senior Member Frequent Contributor
    Join Date
    Feb 2000
    Location
    France
    Posts
    880

    Re: Is 'glDrawPixels' a valid call list command?

    Do you actually have to use glRasterPos ? I wouldn't have bothered if I had written this piece of code... Is there any reason why you should use it ?

    Now, I can see a potential problem in your code (but it probably does not explain what you are experiencing): if the window is resized and you forget to destroy m_DepthBuffer, its dimensions won't be correct anymore... Say you are running in a 320x200 window. On the first pass, m_DepthBuffer is NULL and is allocated for 320x200. Now someone resizes to 640x480. If you do not destroy m_DepthBuffer and set it to NULL, on the next pass, it won't be reallocated and OpenGL will try to store 640x480 pixels in an array that can contain only 320x200...

    Now, when you say "it doesn't work", what do you exactly mean ? (i.e. what are the symptoms ?).

    Regards.

    Eric

  6. #6
    Member Newbie
    Join Date
    Jul 2001
    Location
    boston, ma, usa
    Posts
    30

    Re: Is 'glDrawPixels' a valid call list command?

    I guarantee that it is not a problem about 'm_DepthBuffer'. It must be problem of the raster position. What really confused me is what the coordination of depth buffer is.
    Is it the same as color buffer? More frankly,
    how will you do when you need to keep the depth buffer for laterly use?

  7. #7
    Senior Member OpenGL Pro
    Join Date
    Jun 2000
    Location
    Shreveport, LA, USA
    Posts
    1,502

    Re: Is 'glDrawPixels' a valid call list command?

    You are correct Eric, the raster need not be set since it defaults to (0,0,0,1). However you do have to explicitly set it if it has been changed. But still, even if you were using the default position, wouldn't you still need to ensure the projection and modelview matrices were proper? Or is the raster position only transformed when explicitly set with glRasterPos, i.e does the default position get transformed too? I've written similiar code and always explicitly set the raster position to (0,0,0,1), if nothing else, it does make the code more readable I think.

    [This message has been edited by DFrey (edited 07-30-2001).]

  8. #8
    Senior Member Frequent Contributor
    Join Date
    Feb 2000
    Location
    France
    Posts
    880

    Re: Is 'glDrawPixels' a valid call list command?

    Originally posted by jxruan:
    More frankly,
    how will you do when you need to keep the depth buffer for laterly use?
    There is actually a thread in the Advanced section about this topic:
    http://www.opengl.org/discussion_boa...ML/003633.html

    Regards.

    Eric


    [This message has been edited by Eric (edited 07-30-2001).]

  9. #9
    Senior Member Frequent Contributor
    Join Date
    Feb 2000
    Location
    France
    Posts
    880

    Re: Is 'glDrawPixels' a valid call list command?

    DFrey,

    I understand what you mean: it must definitely be clearer to add it (and I am sure it does not cost a lot of CPU cycles !).

    Actually, I have never tried to understand what the glRasterPos command does... I have just read its man page to have a better idea.

    I think I never looked into it because I thought its use would slow down the rendering... Is it a misconception or is it something that was true on older cards ? (or is it still true ?!?).

    Regards.

    Eric

  10. #10
    Member Newbie
    Join Date
    Jul 2001
    Location
    boston, ma, usa
    Posts
    30

    Re: Is 'glDrawPixels' a valid call list command?

    "it doesn't work" means the depth buffer wasn't restored although the 'm_DepthBuffer' contain the correct data of 'old depth buffer'. This is true even when I let all values in 'm_DepthBuffer' equal to 1.0f, which may work the same as "glClear(GL_DEPTH_BUFFER_BIT)".

Page 1 of 2 12 LastLast

Similar Threads

  1. testing nv command list
    By Antonio in forum OpenGL: Advanced Coding
    Replies: 4
    Last Post: 06-18-2016, 10:26 AM
  2. using command glDrawPixels(), but no display...
    By reader1 in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 04-16-2015, 10:45 PM
  3. Replies: 1
    Last Post: 08-27-2012, 04:00 AM
  4. Sorting List & Counting Valid Entries
    By welford in forum OpenCL
    Replies: 2
    Last Post: 06-06-2011, 07:09 AM
  5. Is the following function call valid?
    By Lvl80retpaladin in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 03-08-2010, 05:14 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