TD3D9GraphicsDriver missing Graphics method?

BlitzMax Forums/BlitzMax Programming/TD3D9GraphicsDriver missing Graphics method?

therevills(Posted 2011) [#1]
Hi All,

In dxgraphics.mod\d3d7graphics.bmx the class TD3D7GraphicsDriver has a method Graphics which returns TD3D7Graphics, but in dxgraphics.mod\d3d9graphics.bmx the class TD3D9GraphicsDriver doesn't have this method....

Is this correct?

How can I get the TD3D9Graphics using the DirectX9 driver?

Thanks!


kfprimm(Posted 2011) [#2]
I don't believe there is a way. The driver architecture doesn't really mandate that the current TGraphics object, at least on the driver implementation side.

Why do you need to get the TD3D9Graphics object specifically? Perhaps there is an alternate way?

In any case, instead of using Graphics you could just use CreateGraphics, cast the object to TD3D9Graphics and store the object, and then call SetGraphics.


therevills(Posted 2011) [#3]
I'm trying to update Grey Alien Framework v1.11 to use DirectX 9 and within GAF there is a method called GetActiveWindowSafe which returns the window handle, currently it is doing this:

Local my_driver:TD3D7GraphicsDriver = D3D7GraphicsDriver()
Local my_graphics:TD3D7Graphics = my_driver.Graphics()
return my_graphics


And I was trying to do this:
Local my_driver:TD3D9GraphicsDriver = D3D9GraphicsDriver()
Local my_graphics:TD3D9Graphics = my_driver.Graphics()
return my_graphics


But of course it fails since TD3D9GraphicsDriver doesnt have the method Graphics().

I've talked the Jake (Grey Alien) and he tells me that this does work on his version of BlitzMax. He is using 1.41, which I have download but the method is not in there either so we think that Jake must have added it himself to the d3d9graphics.bmx module.


kfprimm(Posted 2011) [#4]
I have scanned over the module source and I don't see any approach to grabbing the graphics object.

Hmm. I don't own the framework so I'm guessing here.

I assume GetActiveWindowSafe is supposed to return the HWND of the graphics object and was written because GetActiveWindow was considered not definite enough. The documentation says it'll return the active window attached to the threads messaging queue and since there should only be one, this should always work. I don't know though, the framework has seen quite a lot of action so perhaps he ran into an issue with it somewhere along the way.

However, you could try FindWindow as a suitable replacement.
Local hwnd = FindWindow("BBDX9Device Window Class", Null)

That ought to work as it should be declared in PUB.Win32.

Once you have the HWND, you could just make your own TD3D9Graphics object and return that.

Last edited 2011


therevills(Posted 2011) [#5]
Thanks kfprimm.

I think Jake got his code from this thread:
http://www.blitzbasic.com/Community/posts.php?topic=80290#902594

And Jake's comment for GetActiveWindowSafe is this:
'GetActiveWindow() 'This old method is sometimes unreliable! (e.g. if another window gets focused when this one is being created.)
'Use new more reliable method.



Grey Alien(Posted 2011) [#6]
I still don't have a reliable way to get the window on Macs or in OpenGL.