B+ OpenGL Driver Mode Mangles GL States

BlitzPlus Forums/BlitzPlus Programming/B+ OpenGL Driver Mode Mangles GL States

Parlance(Posted 2003) [#1]
Has anyone else had this problem when using Peter Scheutz's GLDirect userlib with B+? It seems that certain commands like drawimage reset quite a few GL states, most of which I have been able to pin down and reset manually, however there seems to be one that I cannot find. After a call to drawimage subsequent calls to glcolor4f (or any similar function) ignores the alpha channel and keeps it at 1.0. Mark if you're reading this I'd appreciate (and maybe some other people too) a little info on exactly which states which blitz commands modify.


Difference(Posted 2003) [#2]
I would not recommend using the Blitz OpenGL mode togther with OpenGL Direct.
I think Native mode would be the best choice. Are you not getting two render contexts otherwise?

But I'm curious: are you letting Blitz initialize OpenGl and how do you flip?

glPushAttrib, glPopAttrib might solve it for you though.

I think you should consider what Mark does to the OpenGL states as part of the "inner workings" of Blitz, and therefore undocumented for now.


Parlance(Posted 2003) [#3]
I'm initializing OpenGL with GLDirect but it would appear that they are sharing the same rendering context somehow. DrawImage coordinates are transformed through the projection matrix and scaled even too! I'm aware of glPushAttrib and glPopAttrib however I'm leary (sp?) of popping a whole set of states back at once because of the performance hit of multiple rendering state changes. As for flipping the backbuffer I'm simply using SwapBuffers(hMainDC) although when switched to the internal B+ Flip command it all works exactly the same (perfectly). I'm not using the B+ native driver with GL because it is extremely slow. In several test on several machines not only did it bring my fps down to about 3, but the openGL graphics were quite corrupted. Even if that wasn't the case however I would still be negating the aforementioned extended functionality of B+ internal graphics commands used in tandem with OpenGL commands. I'm looking forward to hearing from mark about this.


Difference(Posted 2003) [#4]
I made a small test, and in B+ 1.34 it is possible to skip the ogld initialization altogether, and use SetGfxDriver 2 instead.

Then use Flip instead of SwapBuffers(hMainDC )

If you add

wglGetCurrentDC%():"wglGetCurrentDC" ; goes in OpenGL32.decls

and

GetPixelFormat%(hDC%):"GetPixelFormat" ; goes in GDI32.decls

you can use this function to get a description of the pixelformat Blitz gives you:

Function ogld_DescribeCurrentPixelFormat.ogld_PixelFormat()

	Local lPixelFormat%	
	Local hDc
	
	hDc=wglGetCurrentDC()
	
	If hDc=0 Then Return


	lpPixelFormat=CreateBank(40)	

	lPixelFormat= GetPixelFormat(hDc)

	DescribePixelFormat hDC, lPixelFormat, BankSize(lpPixelFormat), lpPixelFormat
	
	pf.ogld_PixelFormat=New ogld_PixelFormat
	ogld_PF_BankToType lpPixelFormat,pf.ogld_PixelFormat
	
	FreeBank lpPixelFormat

	; return pixel format type
	Return pf
End Function 


Call it like this:

pf.ogld_PixelFormat= ogld_DescribeCurrentPixelFormat()

DebugLog "You got: " + "Color: " + pf\ColorBits + " Depth: " + pf\DepthBits + " Alpha: " + pf\AlphaBits + " Stencil: " + pf\StencilBits