Importing code, Oddmod2 , D3D11Max2DDriver()

BlitzMax Forums/BlitzMax Programming/Importing code, Oddmod2 , D3D11Max2DDriver()

Richard Betson(Posted 2013) [#1]
Hi,

I use Oddmod2 and D3D11Max2DDriver() and they work great. Although when I import code into my main source I get errors (Identifier not found) on the rotation commands such as:

Oddmod2: SetScreenRotation(0), SetScreenFocus(0,0)
D3D11Max2DDriver(): SetScreenRotationD3D11(0). SetScreenFocusD3D11(0,0)

Commands like Drawimage(), SetScale() and alike work fine, just the above commands fail.

Is there a fix or workaround for this issue?

- Edit -

Just to be clear the drivers import OK. This relates to importing code I've written into my main source. ;)

Thanks,


col(Posted 2013) [#2]
Hmm.

Have you tried deleting all of the .i, .a and .bmx files in the affected .mod folders ( including your own one ) and rebuilding the modules?


Richard Betson(Posted 2013) [#3]
Well.

I am just importing source code and not a mod. I use import so that I have no conflicts in vars and alike.

This stems from an issue (I thought I fixed) where DX 10/11 systems were flat out crashing if I imported my say window/GUI code (not a mod) in to my main game source code and within the window/GUI code added "import Oddmod2/ D3D11Max2DDriver()" so that the above commands would compile with no errors. This caused all sorts of problems on DX 10/11 systems even if I removed your driver and the rotation commands (not at fault I'm sure) and just used Oddmod.

But it got me thinking why doesn't the SetRotation() commands work if I import the graphics drivers into my main source code as the DrawImage() command does.

Basically code wise it would look like:

My main game source or the root code:
Import SRS.D3D11Max2D
Import ODD.D3D9Odd2D
Import "window.bmx"

run games stuff



The window.bmx code:
SetScreenRotation(0)
SetScreenFocus(0,0)
SetScreenRotationD3D11(0)
SetScreenFocusD3D11(0,0)
DrawImage()
SetScale()
SetViewport()


Normally I would slip in the Import SRS.D3D11Max2D/ODD.D3D9Odd2D right into the window.bmx code and this would let the commands for rotation compile with no errors, but when I do it blows up on DX 10/11 systems but not DX 9 based systems.

I hope this explains what I up against... It's been a long day. :)

- Rich -


col(Posted 2013) [#4]
Really strange. I don't know what to suggest. It sounds like the functions end up out of scope for some reason.

Are you using the Framework command at all?
Or is it possible that you have cyclic imports? ie "A.bmx" imports "B.bmx" which import "A.bmx"?


Richard Betson(Posted 2013) [#5]
Hi,

Strange indeed. I'm not cyclically importing code or using framework (should I use framework). Even stranger is that I am using "Import Oddmod2/ D3D11Max2DDriver()" in my map engine code which I import into my main game code source with no ill effects.

The only difference between my window.bmx code and my map engine code is the use of SetViewport() and SetRotation() commands. My gut feeling is that the issue might be related to SetViewport()


col(Posted 2013) [#6]

(should I use framework)


Not really, no. If you did then you'd only need more Import commands :)

The only thing I can think of to is to try to replicate the same Import pattern but using empty files to see what happens, and see if the functions go out of scope and hopefully narrow it down from there.


Richard Betson(Posted 2013) [#7]
Hi Dave,

I've put together a little test app simulating the way I'm doing all of the above. I'm running it by my DX10/11 beta testers to see if crashes. If it does I'll post it here and let you (and all) take a look at it.

- Rich -


col(Posted 2013) [#8]
In your 'window.bmx" source code file, if you're going to use SetRotation() etc in that file then you will need to have

Import SRS.D3D11Max2D
Import ODD.D3D9Odd2D


in there too for the extra functions to be available.

However you say that it blows up when you do, and this is what really needs to be fixed, what happens in said explosion?


Richard Betson(Posted 2013) [#9]
Hi Dave,

When it blows up it does the following. On DX9 video card systems it will run fine but on DX10/11 video card based systems it will error with an "Unhandled Exception Error:Attempt to access a field or method using a null object" running with a DX9, OpenGL or your driver. The error is linked to the rotation commands as I recall and removing them fixed the problem as well as removing the imported drivers.

I'm in the process of isolating the problem now but not having a DX10/11 video card is making it tough to find. I'm going to borrow a a friends DX10 laptop and see what I can find out.

But I have never had an issue like this with BlitzMAX where a compiled app runs great on DX9 video cards and won't run on DX10/11 video cards even with a DX9 driver. Kind of a weird problem.


Russell(Posted 2013) [#10]
Perhaps a silly question, but how do I download the srs.mod/dx11max2dDriver.mod from github? If I right-click "save file as..." it downloads as a *file* instead of a folder called srs.mod or d3d11graphics.mod or what have you. Viewed in Wordpad, the downloaded *.mod file(s) looks like XML!

Anyway, is this available as a zipped archive like the good 'ol days? (Or even svn, which, although not a perfect solution, at least I know how to use). Or does github require some kind of client?

Never mind. I discovered the 'zip' button, which conveniently zips the whole shabang for ya! Hey, I'm kind diggin this whole git thing! (Although only from an end-user standpoint. Developer side might be a royal pain, however...)

Thanks!

p.s. Found this concerning downloading zips from github. Could be useful for github newbies like me:

to simply download a repository as a ZIP file: add the extra path '/zipball/master/' to the end of the repository URL and wallah it gives you a zip of the whole lot.


In other words, if you add that to the end of your srs.mod url in your signature then users will get the 'download file' requester automagically containing the whole deal! Cool!

Russell


col(Posted 2013) [#11]

In other words, if you add that to the end of your srs.mod url in your signature then users will get the 'download file' requester automagically containing the whole deal!



Nice one! Learn something new every day.

Sounds like a good idea although I'm not sure I like the idea that it appends some parts of a checksum into the zipped filename, only because it changes the filename... ahh nevermind as it appends -master if you dl from github directly anyway. Oh well, I'm sure everyone knows that the final folder structure within 'Max is supposed to be mod/srs.mod/...

Have fun :-)