Hey folks.
I am trying to do a `test` to see if the display that is opened really has a double buffer. I can query OpenGL with glGetIntegerv() and it can say yes, but I also want to use a `graphics test` which proves whether separate backbuffer and frontbuffer are present. I am doing the test with an open display with words on it so I can SEE whether it is actually double buffered or not, but I am trying to get my test to comply with what is obvously true.
The test I am trying to do is as follows, but it doesn't seem to work right in all cases. It works in full-screen mode, with either single or double buffered displays. But in window mode it doesn't report correctly. I *should* be getting pixel values coming back from glReadPixels() but instead I get 0's. This appears to happen despite the fact that I can insert breaks which let me SEE that it actually does have a backbuffer, you can't see what's being drawn until it flips, etc.... and yet when I do the second set of DrawRect's to erase the backbuffer, it erases the front buffer, even though it is double-buffered! I have tried adding glDrawBuffer(GL_BACK) and all that, doesn't fix it.
Any ideas why this is not working in window mode, or how to test successfully in window mode?
(sorry about visual confusion from all the comments)
I thought maybe I need to put another glFinish() after Flip() to make sure it has finished copying the back to the front before I do the test?
Any other possibilities? Is there something I'm not seeing?
I know that you can never know whether your display will hardware-flip, copy, or whether the backbuffer will contain the previous frame, black, trash data, or a totally new backbuffer after the flip. Still doesn't seem to matter. Why does this code work fullscreen but not windowed?
It is mainly when I open a double-buffered window that it says there is no double buffering.
I am trying to do a `test` to see if the display that is opened really has a double buffer. I can query OpenGL with glGetIntegerv() and it can say yes, but I also want to use a `graphics test` which proves whether separate backbuffer and frontbuffer are present. I am doing the test with an open display with words on it so I can SEE whether it is actually double buffered or not, but I am trying to get my test to comply with what is obvously true.
The test I am trying to do is as follows, but it doesn't seem to work right in all cases. It works in full-screen mode, with either single or double buffered displays. But in window mode it doesn't report correctly. I *should* be getting pixel values coming back from glReadPixels() but instead I get 0's. This appears to happen despite the fact that I can insert breaks which let me SEE that it actually does have a backbuffer, you can't see what's being drawn until it flips, etc.... and yet when I do the second set of DrawRect's to erase the backbuffer, it erases the front buffer, even though it is double-buffered! I have tried adding glDrawBuffer(GL_BACK) and all that, doesn't fix it.
Any ideas why this is not working in window mode, or how to test successfully in window mode?
(sorry about visual confusion from all the comments)
Local TestColor:Int=$FF Local TestColor2:Int=$FFFFFF00 'We draw to the backbuffer and flip it rather than draw to the front 'because on some systems it wont let you draw to the front glDrawBuffer(GL_BACK) 'Draw to backbuffer Cls 'Erase backbuffer so when we flip it looks ok SetColor TestColor,TestColor,TestColor DrawRect 0,0,2,2 'Put color on the backbuffer. If it appears on the 'front buffer later there is no doublebuffer. (Make sure the whole 'corner pixel is covered on all systems) DrawRect 0,MyHeight-2,2,2 'Some platforms, in window mode, have 0,0 'topleft, others bottomleft. Unless you use GLGraphicsDriver() and set 'up your own OpenGL display you can't be sure, so check 2 pixels glFlush() glFinish() 'Make sure it draws it, needed for single-buffered displays ' particularly Flip 1 'Flip the display, back becomes front if there is one. If there 'is a backbuffer it should now be blank, unless the flip is done by 'copying the backbuffer to the front, in which case they are now 'identical and the back has to be cleared SetColor $0,$0,$0 'Make it ready to do a mini cls - necessary in case 'the backbuffer was copied to front or if the back has trash data on it, 'the backbuffer HAS to have black on it 'Works in full-screen single/double, maybe works in windowed singlebuffered, 'doesn't work in windowed doublebuffered (this code erases the pixels!) DrawRect 0,0,2,2 'Clear the first pixel. This also clears the front 'buffer in single-buffered mode - our test DrawRect 0,MyHeight-2,2,2 'Clear the second pixel. These are NEEDED to 'handle copy/blit type Flip as in window mode glFlush() glFinish() 'Make sure it is drawn before we test - it may erase the 'front buffer glReadBuffer(GL_FRONT) 'Read from the front buffer (this will be the 'backbuffer in single buffered mode) Local pix2,pix3:Int=0 glReadPixels(1,MyHeight-1,1,1,GL_RGB,GL_UNSIGNED_BYTE,Varptr(pix2)) 'Check first pixel glReadPixels(1,1,1,1,GL_RGB,GL_UNSIGNED_BYTE,Varptr(pix3)) 'Check 'second pixel Print Hex$(pix2)+" "+Hex$(pix3)+" "+Hex$(TestColor2) 'what? enablepolledinput();WaitKey 'temporary If (pix2=TestColor2) And (pix3=TestColor2) 'Pixel color is correct, 'our test agrees ...if this was true then we now know there is a doublebuffered display.
I thought maybe I need to put another glFinish() after Flip() to make sure it has finished copying the back to the front before I do the test?
Any other possibilities? Is there something I'm not seeing?
I know that you can never know whether your display will hardware-flip, copy, or whether the backbuffer will contain the previous frame, black, trash data, or a totally new backbuffer after the flip. Still doesn't seem to matter. Why does this code work fullscreen but not windowed?
It is mainly when I open a double-buffered window that it says there is no double buffering.