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