Some modules for ya.

Community Forums/Showcase/Some modules for ya.

TartanTangerine (was Indiepath)(Posted 2005) [#1]
I thought I'd share these with the community, you can probably find these somewhere on the BMax forum but I thought I'd save you the trouble.

What do we have?

Indiepath.ProjMatrix : Lets you play with the projection matrix : works with DirectX and OpenGL (this is your best friend)

Indiepath.AnimImageFast : Accelerated Single Surface Animated Image drawing : DirectX and OpenGL - This function is at least 45% faster than the inbuilt command and requires less video memory.

Indiepath.bMapText : Accelerated Single Surface Bitmap text drawing : DirectX and OpenGL - shed loads faster than using the inbuilt stuff.

Heres the files : http://indiepath.com/tim/indiepath.mod.rar

Here's an example (.exe and example included in archive)
Strict
Framework BRL.D3D7Max2D

Import Indiepath.AnimImageFast
Import Indiepath.ProjMatrix
Import Indiepath.bMapText
Framework BRL.D3D7Max2D

SetGraphicsDriver D3D7Max2DDriver()

' Set the Graphics to whatever you want, the matrix will deal with the scale and position.

Graphics 640,480,0,60
'Graphics 800,600,0,60
'Graphics 1024,768,0,60

'SetMatrix(BaseWidth,BaseHeight,BaseDepth)
SetMatrix(800,600,2)

SetClsColor(80,80,80)
Cls

'bMapText.Create(bitmapname:string,flags)
Local text1:bMapText = bMapText.Create("fatbot",FILTEREDIMAGE|MIPMAPPEDIMAGE)

' TAnimImage(url:object,cell_width,cell_height,Start_frame,NumberFrames,Flags)
Local blob:TAnimImage = TAnimImage.Load("blocks.png", 32, 32, 0, 16, FILTEREDIMAGE)

For Local b=0 To 15
	' This Draw Command is 45% faster than the existing command.
	'Draw(x,y,width,height,frame)
	blob.Draw(5 + (b * 40), 200, 30, 30, b)
Next

SetScale(0.4,0.4)

' DrawbMapText(text:string,x,y,center,right)
text1.DrawbMapText("Indiepath Ltd",400,280,True,False)

SetScale(0.35,0.35)
SetColor(255,255,155)
text1.DrawbMapText("Hit ESC to Exit",400,330,True,False)

Flip

WaitKey()



Robert Cummings(Posted 2005) [#2]
Thanks Tim, I'll take a close look at these. Very sexy...

The 45% faster boost - is that because it's single surface or is it the TnL stuff?


Don999(Posted 2005) [#3]
opengl works
directx says: DX7ImageFrame Lock failed


TartanTangerine (was Indiepath)(Posted 2005) [#4]
Rob, it's single surface using the normal HAL renderer. The normal AnimImage command creates a new surface and texture for each frame, this is both expensive in terms of memory and switching surfaces everytime you draw to screen.

Don999, You need to have version 1.10 of Bmax as a minimum to compile the stuff.. Where does the error come from? which module?

{EDIT} When v1.12 is released I may have to rework some of this as I suspect there have been some big changes


TeaVirus(Posted 2005) [#5]
Very nice! Thanks!!


Grey Alien(Posted 2005) [#6]
Very generous although some of them could come obsolete soon!


Hotcakes(Posted 2005) [#7]
Tim;s fixes have been posted around the place for a while, it'll be interesting to see if any of them have made it to the official mods. Altho, if you look at the modserver, the brl.random module has floyd's name on it, which suggests they took his better random generator. Tim's name is no where to be found, so maybe they overlooked these ones. Time will tell (not much time now!)

@Don999: As Tim said you need v1.10 for the DX stuff... however, if you upgrade to v1.10 now you can't syncmods, because the modserver is locked for the upgrade. So you will have to wait until v1.12 is released. And then it could be a case of none of this code works anymore ;]


xlsior(Posted 2005) [#8]
I get the same error, with 1.10 with latest syncmods:

Unhandled Exception: DX7ImageFrame Lock failed

Did you make any custom changes to the BRL DX7 module as well, by any chance?

when running the sample source, both the text1.DrawbMapText and the blob.Draw commands trigger the error.

Remarking those three lines out and the error goes away, but of course nothing really happens anymore either at that point. Any idea what's causing this?

I would really be interested in getting that resolved, since these are incredibly useful additions to BMax.


TartanTangerine (was Indiepath)(Posted 2005) [#9]
I am using standard Bmax commands. No "under the hood" stuff here guys.


xlsior(Posted 2005) [#10]
Hm, Weird... I copied the 'indiepath.mod' folder under the blitzmax/mod directory, would I need to do anything else for the sample to run?

*update*

I just switched to SetGraphicsDriver GLMax2DDriver(), and it -does- compile and run. However, it has some kind of problem as well:



(Just the text, the squares look OK on the screen. they just look bad in this screenshot due to JPG compression artifacts)
The pre-compiled sample .EXE works fine though, and shows the text without corruption.

I tried both regular and debug mode -- With OpenGL both modes look the same, in DirectX mode the release mode will immediately quit without error, in debug mode it will throw the error message mentioned above.
The Matrix-projection portion does seem to work though.


TartanTangerine (was Indiepath)(Posted 2005) [#11]
Cool. I'll check it out - later.. It seems to be a UV issue.


xlsior(Posted 2005) [#12]
the same code now fails to compile altogether using the Blitzmax 1.12 version:

C:/Code/BlitzMax/mod/indiepath.mod/animimagefast.mod/animimagefast.release.win32.a(animimagefast.bmx.release.win32.o.b)(code+0x37e): undefined reference to `bbGCEnter'
C:/Code/BlitzMax/mod/indiepath.mod/animimagefast.mod/animimagefast.release.win32.a(animimagefast.bmx.release.win32.o.b)(code+0x3bb): undefined reference to `bbGCFlush'
C:/Code/BlitzMax/mod/indiepath.mod/animimagefast.mod/animimagefast.release.win32.a(animimagefast.bmx.release.win32.o.b)(code+0x3cb): undefined reference to `bbGCLeave'
C:/Code/BlitzMax/mod/indiepath.mod/bmaptext.mod/bmaptext.release.win32.a(bmaptext.bmx.release.win32.o.b)(code+0x217): undefined reference to `bbGCEnter'
C:/Code/BlitzMax/mod/indiepath.mod/bmaptext.mod/bmaptext.release.win32.a(bmaptext.bmx.release.win32.o.b)(code+0x232): undefined reference to `bbGCFlush'
C:/Code/BlitzMax/mod/indiepath.mod/bmaptext.mod/bmaptext.release.win32.a(bmaptext.bmx.release.win32.o.b)(code+0x242): undefined reference to `bbGCLeave'
Build Error: Failed to link d:/indiepath/lil_demo.exe



TartanTangerine (was Indiepath)(Posted 2005) [#13]
Are you suprised? BMax will fail on any instance of Flushmem().

I'll repost these at some point today.


Hotcakes(Posted 2005) [#14]
So none of these made it into official modules? Shame.


TartanTangerine (was Indiepath)(Posted 2005) [#15]
Okay, updated and re-compiled. All modules work correctly with OpenGL and DirectX, even the Projection Matrix Mod!

Just download from the link above and install as normal.


xlsior(Posted 2005) [#16]
Very nice!

Now works correctly under both DX and OpenGL on my system.


xlsior(Posted 2005) [#17]
A tip for others playing around with these modules: It appears that the projection matrix behaves slightly different in OpenGL than in DirectX:

In DirectX mode, SetViewport needs the virtual resolution, while in OpenGL mode SetViewport requires the actual resolution. That means that if your application runs in both graphic modes, you'll have to apply some extra logic around any calls to SetViewPort, or one of the two will not behave as expected.

(Also -- the commands don't get highlighted in the IDE?)


xlsior(Posted 2005) [#18]
It looks like the latest syncmods broke your module again:

Building lil_demo
Compiling:lil_demo.bmx
flat assembler version 1.64
3 passes, 1813 bytes.
Linking:lil_demo.exe
C:/Code/BlitzMax/mod/indiepath.mod/animimagefast.mod/animimagefast.release.win32.a(animimagefast.bmx.release.win32.o.b)(code+0x36e): undefined reference to `brl_d3d7max2d_TDX7ImageFrame'
C:/Code/BlitzMax/mod/indiepath.mod/bmaptext.mod/bmaptext.release.win32.a(bmaptext.bmx.release.win32.o.b)(code+0x7bd): undefined reference to `brl_d3d7max2d_TDX7ImageFrame'
Build Error: Failed to link D:/indiepath2/lil_demo.exe
Process complete




TartanTangerine (was Indiepath)(Posted 2005) [#19]
Don't sync mods then :D I haven't.

I'll fix this when.......

1) Indiegamebusiness.com has been launched
2) igLoader has been lauched as a commercial product
3) Seasonal games are launched on cloverleaf and portals.
4) I get a spare moment.


TartanTangerine (was Indiepath)(Posted 2005) [#20]
Fixed, uploaded new file.


xlsior(Posted 2005) [#21]
Oooooh.

A-Star Pathfinding and DeltaTime module as well, I see?

Any documentation on any of these?


TartanTangerine (was Indiepath)(Posted 2005) [#22]
ah, I did not mean to include the A* stuff :D

Delta Time :-




Robert Cummings(Posted 2005) [#23]
You'll be including your games next. So thats where I find makeGame() - in 1.15!


TartanTangerine (was Indiepath)(Posted 2005) [#24]
Lol, na the commands are :

MakeNewSkin();
CreateMoneyFromOldRope();


xlsior(Posted 2005) [#25]
ah, I did not mean to include the A* stuff :D


Don't you hate it when that happens? :-)


chriscrawford100(Posted 2006) [#26]
Is the module still available? The link at the start of this the thread is broken at the moment. In any case Indie I tracked down another thread with your posting of the basic matrix code and got it working in my project. Fantastic!!! I had pretty much resigned myself to only supporting one resolution rather than go through the pain of doing things the really ugly "take screen res into account for every calculation" way. Thanks a ton.


TartanTangerine (was Indiepath)(Posted 2006) [#27]
Yeah, I've removed the majority of my stuff for the time being.


jtfrench(Posted 2008) [#28]
Have any updated versions of that FastAnimImage type, or should I just scrape the from the old (3 years) posts?

(though perhaps this has already been included in version 1.30 of bmax...??)