Please test this graphics code

BlitzMax Forums/BlitzMax Programming/Please test this graphics code

Please could you test this graphics code. I need to know if it shows the line that says "The mode did not open correctly! There is a difference between the reported OpenGL depth and GraphicsDepth(), maybe a way to indicate errors in 15/16bit mode, but in 24/32-bit it wouldn't work".

For this to work, your graphics card has to NOT support stencil buffers in 16-bit fullscreen. Most cards probably don't support stencils in 16-bit unless in window mode. If your card does support stencil buffers in 16-bit, please change the CreateGraphics() to some combination of buffers and color depth that your card does not support.

Let me know your findings, thanks. If this works consistently across the board, it's a way to tell if certain buffers fail to open in 16-bit screens.

SetGraphicsDriver GLGraphicsDriver()
gra:TGraphics=CreateGraphics(640,480,16,60,GRAPHICS_BACKBUFFER|GRAPHICS_ALPHABUFFER|GRAPHICS_STENCILBUFFER)
gra2:TGLGraphics=TGLGraphics(gra)
Local wid,hig,dep,htz,flg:Int=0
gra2.GetSettings(wid,hig,dep,htz,flg)
Print "CreateGraphics has these settings: "+wid+" "+hig+" "+dep+" "+htz+" "+Bin$(flg)

enablepolledinput()
WaitKey
Try
	SetGraphics gra
Catch a$
	CloseGraphics(gra)
	Print "My error report: "+a$
	Print "I couldn't open the fullscreen display, trying a window"
	gra=CreateGraphics(640,480,0,0,GRAPHICS_BACKBUFFER|GRAPHICS_ALPHABUFFER|GRAPHICS_STENCILBUFFER|GRAPHICS_DEPTHBUFFER|GRAPHICS_ACCUMBUFFER)
	If gra
		Print "It worked, the window opened, hallelujah!"
	Else
		Print "The window didn't even open, yet alone the context!"
		End
	EndIf
	WaitKey
	Try
		SetGraphics gra
		Print "It worked, the display context opened, hallelujah!"
		GLDrawText("The window display is open!",50,50)
		Flip 1
		WaitKey
	Catch a$
		Print "Error: "+a$
		Print "I couldn't open a windowed display either, oh darn!"
		WaitKey
		End
	EndTry
	CloseGraphics(gra)
	End
EndTry
Local a:Int[1]
a[0]=0
glGetIntegerv(GL_RED_BITS,a)
Print "Color red bits: "+a[0]
If a[0]=8 And GraphicsDepth()<24 Then Print "The mode did not open correctly! There is a difference between the reported OpenGL depth and GraphicsDepth(), maybe a way to indicate errors in 15/16bit mode, but in 24/32-bit it wouldn't work"
a[0]=0
glGetIntegerv(GL_GREEN_BITS,a)
Print "Color green bits: "+a[0]
a[0]=0
glGetIntegerv(GL_BLUE_BITS,a)
Print "Color  blue bits: "+a[0]
a[0]=0
glGetIntegerv(GL_ALPHA_BITS,a)
Print "Color alpha bits: "+a[0]
a[0]=0
glGetIntegerv(GL_DEPTH_BITS,a)
Print "Depth bits: "+a[0]
a[0]=0
glGetIntegerv(GL_STENCIL_BITS,a)
Print "Stencil bits: "+a[0]
a[0]=0
glGetIntegerv(GL_ACCUM_RED_BITS,a)
Print "Accum red bits: "+a[0]
a[0]=0
glGetIntegerv(GL_ACCUM_GREEN_BITS,a)
Print "Accum green bits: "+a[0]
a[0]=0
glGetIntegerv(GL_ACCUM_BLUE_BITS,a)
Print "Accum blue bits: "+a[0]
a[0]=0
glGetIntegerv(GL_ACCUM_ALPHA_BITS,a)
Print "Accum alpha bits: "+a[0]
a[0]=0
glGetBooleanv(GL_DOUBLEBUFFER,a)
Print "Double buffering supported?: "+a[0]
a[0]=0
glGetBooleanv(GL_STEREO,a)
Print "Stereo left/right buffers supported?: "+a[0]
a[0]=0
glGetIntegerv(GL_AUX_BUFFERS,a)
Print "Auxiliary buffers available?: "+a[0]
a[0]=0
glGetIntegerv(GL_MAX_PIXEL_MAP_TABLE,a)
Print "Maximum pixel-remap table size: "+a[0]
a[0]=0
glGetIntegerv(GL_MAX_TEXTURE_SIZE,a)
Print "Maximum texture size: "+a[0]+"x"+a[0]
Print "GraphicsWidth(): "+GraphicsWidth()
Print "GraphicsHeight(): "+GraphicsHeight()
Print "GraphicsDepth(): "+GraphicsDepth()
Print "GraphicsHertz(): "+GraphicsHertz()
Print "GraphicsFlags(): "+Bin$(GraphicsFlags())
Local b:String
If GraphicsFlags() & GRAPHICS_BACKBUFFER=GRAPHICS_BACKBUFFER Then b:+"BACK + "
If GraphicsFlags() & GRAPHICS_ALPHABUFFER=GRAPHICS_ALPHABUFFER Then b:+"ALPHA + "
If GraphicsFlags() & GRAPHICS_STENCILBUFFER=GRAPHICS_STENCILBUFFER Then b:+"STENCIL + "
If GraphicsFlags() & GRAPHICS_DEPTHBUFFER=GRAPHICS_DEPTHBUFFER Then b:+"DEPTH + "
If GraphicsFlags() & GRAPHICS_ACCUMBUFFER=GRAPHICS_ACCUMBUFFER Then b:+"ACCUM"
Print "Buffers *requested*: "+b

GLDrawText("The full screen display is open!",50,50)
Flip 1
WaitKey
Print "The full screen mode opened successfully!"
CloseGraphics(gra)
End


CreateGraphics has these settings: 640 480 16 60 00000000000000000000000000010110
Color red bits: 5
Color green bits: 6
Color blue bits: 5
Color alpha bits: 0
Depth bits: 24
Stencil bits: 0
Accum red bits: 16
Accum green bits: 16
Accum blue bits: 16
Accum alpha bits: 16
Double buffering supported?: 1
Stereo left/right buffers supported?: 0
Auxiliary buffers available?: 4
Maximum pixel-remap table size: 65536
Maximum texture size: 4096x4096
GraphicsWidth(): 640
GraphicsHeight(): 480
GraphicsDepth(): 16
GraphicsHertz(): 60
GraphicsFlags(): 00000000000000000000000000010110
Buffers *requested*: BACK + ALPHA + STENCIL +
The full screen mode opened successfully!


Nvidia GT6600 OC

Umm.. okay, so your card supports all the buffers in 16-bit fullscreen, right?

Same as JoeRetro here

Building untitled1
Compiling:untitled1.bmx
flat assembler version 1.64
4 passes, 18140 bytes.
Linking:untitled1.debug.exe
Executing:untitled1.debug.exe
CreateGraphics has these settings: 640 480 16 60 00000000000000000000000000010110
Color red bits: 5
Color green bits: 6
Color blue bits: 5
Color alpha bits: 0
Depth bits: 24
Stencil bits: 0
Accum red bits: 16
Accum green bits: 16
Accum blue bits: 16
Accum alpha bits: 16
Double buffering supported?: 1
Stereo left/right buffers supported?: 0
Auxiliary buffers available?: 4
Maximum pixel-remap table size: 65536
Maximum texture size: 4096x4096
GraphicsWidth(): 640
GraphicsHeight(): 480
GraphicsDepth(): 16
GraphicsHertz(): 60
GraphicsFlags(): 00000000000000000000000000010110
Buffers *requested*: BACK + ALPHA + STENCIL +
The full screen mode opened successfully!

Process complete

Athlon64 3500+ GeForce 6600GT

CreateGraphics has these settings: 640 480 16 60 00000000000000000000000000010110
Color red bits: 8
The mode did not open correctly! There is a difference between the reported OpenGL depth and GraphicsDepth(), maybe a way to indicate errors in 15/16bit mode, but in 24/32-bit it wouldn't work
Color green bits: 8
Color blue bits: 8
Color alpha bits: 8
Depth bits: 24
Stencil bits: 8
Accum red bits: 0
Accum green bits: 0
Accum blue bits: 0
Accum alpha bits: 0
Double buffering supported?: 1
Stereo left/right buffers supported?: 0
Auxiliary buffers available?: 0
Maximum pixel-remap table size: 65536
Maximum texture size: 2048x2048
GraphicsWidth(): 640
GraphicsHeight(): 480
GraphicsDepth(): 16
GraphicsHertz(): 60
GraphicsFlags(): 00000000000000000000000000010110
Buffers *requested*: BACK + ALPHA + STENCIL +
The full screen mode opened successfully!

When I first start it, it will jusdt show me an 640x480 black screen. About half the time it will also show the the windows taskbar at the bottom (only the left half of it, since the desktop resolution is higher than the screen that is open). After pressing a key it shows the 'full screen display is open' text, on a corrupted background (appears to be randomly colored bars and such, like a memory dump)

video adapter: ATI Radeon 9600 Pro

same as xlsior, including problems.

Nvidia 6600GTx2 SLi

The gfx problems are not an issue, it's because I didn't do a clearscreen, you're seeing the junk in the backbuffer uncleared is all. And yes you're supposed to see nothing until you press a key.

But thanks for testing it.

What I'm confused about from your results is that you asked for a 16-bit display with buffers, OpenGL reports it as a 32-bit screen, which is supposed to indicate that the display did not open properly, and yet you say you could see the text saying the screen is open.

Darn. More stupid unreliability.