Errors with GLGraphicsDriver

BlitzMax Forums/BlitzMax Programming/Errors with GLGraphicsDriver

MrCredo(Posted 2008) [#1]
What is wrong with this code?
I get Unhandled Memory Exception Error

SetGraphicsDriver GLGraphicsDriver()
Local g:TGraphics=CreateGraphics(1024,768,32,60,GRAPHICS_BACKBUFFER|GRAPHICS_ALPHABUFFER)
SetGraphics(g)

'Graphics(1024,768,32)
Local img:TImage=LoadImage("images/move.png")

time=MilliSecs()
For i=1 To 100000
	DrawImage(img, 0,0)
Next
time=MilliSecs()-time

Flip()
Delay(1000)
Print(time)



JazzieB(Posted 2008) [#2]
Is that image where it's supposed to be? Check it actually loads by seeing if img is Null after loading.


JazzieB(Posted 2008) [#3]
Actually, the GLMax2DDriver works just fine.


CASO(Posted 2008) [#4]
Just curious, where do you find the flags like "GRAPHICS_BACKBUFFER"?

EDIT: Opps, sometimes you ask a stupid question and find the answer a few moments later.


MrCredo(Posted 2008) [#5]
>>>Is that image where it's supposed to be? Check it actually loads by seeing if img is Null after loading.

I added this line after LoadImage:

If img=Null Then End

when i start my program with debug - i get this error: Unhandles Exception: Attempt to access field or method of Null object.

AND DrawImage is selected in editor!!!

If i disable first 3 lines and anable Graphics (=DirectX) - this program run without errors...


GfK(Posted 2008) [#6]
Actually, the GLMax2DDriver works just fine.
No it doesn't. It doesn't work at all on some Intel GMA chipsets, where other GL stuff runs perfectly.


Dreamora(Posted 2008) [#7]
The GLMax2D Driver actually even works on Intel GMA as Max2D is written in a way that allows it to run on MS OGL 1.1 Emulation!

The problem here is that GLGraphicsDriver is used, not GLMax2D, this means that you can not use any Max2D commands at all. That simple it is.
You can only use pure opengl


Brucey(Posted 2008) [#8]
Dream's right. You need to specify the correct Max2D driver.
The way the drivers works inside BlitzMax is a bit confusing (try writing a new one and you'll see what I mean!).
By default each driver you Import sets itself as the graphics driver. If you need one different to the last one that was set, you set the driver you need.
If you intend using Max2D commands, always set the Max2D driver you need (be it GL or D3D).


GfK(Posted 2008) [#9]
The GLMax2D Driver actually even works on Intel GMA
I have one. I guarantee it does not work.
The problem here is that GLGraphicsDriver is used, not GLMax2D, this means that you can not use any Max2D commands at all. That simple it is.
You can only use pure opengl
Well, that's no good.


MrCredo(Posted 2008) [#10]
>>>If you intend using Max2D commands, always set the Max2D driver you need

And how can i do this?

I think SetGraphicsDriver GLGraphicsDriver() was right?


Jim Teeuwen(Posted 2008) [#11]
There is apparently a difference between "GLGraphicsDriver()" and "GLMax2DDriver()".

So Use: SetGraphicsDriver( GLMax2DDriver() );

As far as my tests have shown (which are not very thourough), this allows the use of both raw OpenGL commands as well as using Max2D commands.


MrCredo(Posted 2008) [#12]
a thanks - this works


Dreamora(Posted 2008) [#13]
You can use raw OpenGL commands with the GLMax2DDriver, BUT don't mess with the stack or it will bomb out.