highgfx module

BlitzMax Forums/BlitzMax Programming/highgfx module

Diablo(Posted 2006) [#1]
I have just finshed work on a new module which allows you to 3 key things:

* Draw textured polygons
* Draw glowing lines
* Draw to an image (render to texture)

Shot of a demo created with the module:


Code for above demo:


I created these modules because I will find them usefull and as such I will update, etc. when I need to (or if there are are enough requests for a feature, and I know how to add the feature :)

There are limits of course: You can only use it with GLMax2DDriver(): You can not use Max2D drawimage, etc. with them. I have included custom drawimage() and drawimagerect() commands and I might add tileimage and drawimageblock if needed.

You can use it for commercial/free projects, no restrictions apply.

Get It From Here!

Documents are in diablo.mod/highgfx.mod/doc


Chris C(Posted 2006) [#2]
very nice, thanks!

*edit* top marks for the neat integration with max2d, and having the source is extremely useful! makes it very easy to use


popcade(Posted 2006) [#3]
Great Thanks!

Testing with it now, agree that open source is useful to users who want to learn.


ImaginaryHuman(Posted 2006) [#4]
Would it be possible to use the render to texture to select an image to render to, then use normal OpenGL commands with custom textures to do your own rendering, then use your module again to switch back to drawing to the backbuffer?

Also what are the requirements for render to texture, does it rely on having a certain version of OpenGL or a certain extension?


Diablo(Posted 2006) [#5]
Would it be possible to use the render to texture to select an image to render to, then use normal OpenGL commands with custom textures to do your own rendering, then use your module again to switch back to drawing to the backbuffer?


You should be able to do this. When you call the SetBuffer with an image it stores what texture it was using.

Also what are the requirements for render to texture, does it rely on having a certain version of OpenGL or a certain extension?

It requires opengl 1.1 and it shouldnt need any certain extensions


ImaginaryHuman(Posted 2006) [#6]
Then how are you rendering to a texture without using an extension? Is it really a texture in memory or is it basically rendering to a locked image pixmap in main memory?


Chris C(Posted 2006) [#7]
you could always d/load the source and look for yourself, if you can't be bothered, why should Diablo... ;p


Haramanai(Posted 2006) [#8]
Diablo this is great module.
About the restriction of drawingImages. Have you tried to use the enableTx and disableTex that are stricted in the GLMax2D?


degac(Posted 2006) [#9]
A BIG BIG BIG thanks!!!!
[edit:] your examples are very well explained!


Diablo(Posted 2006) [#10]
About the restriction of drawingImages. Have you tried to use the enableTx and disableTex that are stricted in the GLMax2D?

I did have a lil look, but it didnt work... till now! :/. I'll test it out a bit more and update the module (i'll try and make it so you dont have to change offical mods).

Then how are you rendering to a texture without using an extension? Is it really a texture in memory or is it basically rendering to a locked image pixmap in main memory?


Its done using glCopyTexImage2D, I might change it to glCopyTexSubImage2D because I just tried some test on the old laptop and it seemed a lot faster. I'm going to have a read about the differeance's and do some tests using each method. To be honest, the render to texture was an after thought which I only put in to day, havent had much time to try it out fully.

your examples are very well explained!

Thanks, I pride my self on it.


Haramanai(Posted 2006) [#11]
Ooops wrong. I meant private not strict. Well I have writen what I had found out about this and how to draw textured polyies in this Topic.


ImaginaryHuman(Posted 2006) [#12]
Hmm. If I remember, copying from the backbuffer into a texture uses the CPU usually and is not very fast, and certainly not as fast as rendering directly to a texture - you can't really call it render-to-texture when it's really just `render to backbuffer and copy to texture`.


Diablo(Posted 2006) [#13]
Update:
ModuleInfo "History: 1.01"
ModuleInfo "History: You can now yous Max2D Commands while not in SetBuffer()...EndBuffer()"
ModuleInfo "History: Added GetImageName()"
ModuleInfo "History: Added BindTexture()"
ModuleInfo "History: Added UnBindTexture()"
ModuleInfo "History: Added SetTextureBuffer()"
ModuleInfo "History: Added a mode flag to setbuffer()"
ModuleInfo "History: Added flags 'HI_RENDERTOTEXTURE_MODE_DIRECT"


The most important info of this new update is the new mode argument in SetBuffer(). This can be of any of the following:

HI_RENDERTOTEXTURE_MODE_COPY
HI_RENDERTOTEXTURE_MODE_FASTCOPY
HI_RENDERTOTEXTURE_MODE_DIRECT

Direct mode is done using fbo's, but it should do a check if you try and use that mode when its not supported and return false (otherwise true).

Also You should now be able to use normal blitzmax 2d draw commands as long as your not in a setbuffer()...endbuffer()

And...

I added SetTextureBuffer() which takes an opengl texture to rendered to. note you need to give width & height for that function.

Added custom bind texture and unbind for better support of max2d.

Also added getimagename which will return the texture name (%) of the give image (create one if highgfx dosent have it stored).

I'm sure i missed some stuff. Havent really got the time to bug test it today :(

Download from Here
Or the link in my new and imroved slimline sig :)

PS: Yer I no i said I wouldnt add fbo's but It was easier then I thought (dont worry if you dont know what i'm on about)

EDITZ: Oh I knew I forgot somthing... I added a Init function which you have to call if you are going to use HI_REDNERTOTEXTURE_MODE_DIRECT.


ImaginaryHuman(Posted 2006) [#14]
Can you explain the differences between those three render-to-texture modes? What actualy happens?


Diablo(Posted 2006) [#15]
I didnt make OpengGL so i cant tell you the inner workings - however...

HI_RENDERTOTEXTURE_MODE_COPY - Is the mode that was first in there (render to backbuffer and copy)
HI_RENDERTOTEXTURE_MODE_FASTCOPY - Is done using glCopyTexSubImage2D which is less acurrate (sometimes) but a bit faster then using glCopyTexImage2D
HI_RENDERTOTEXTURE_MODE_DIRECT - is done using FBO's or framebuffers which should be the fastest out of the lot but isnt as wildly supported.

Just google the terms for more info.


smilertoo(Posted 2006) [#16]
HI_RENDERTOTEXTURE_MODE_DIRECT nice if it works, i'll be trying that out sometime soon.


ImaginaryHuman(Posted 2006) [#17]
How is FASTCOPY mode less accurate sometimes? I use the same call to do a copy of the backbuffer into a texture, and it doesn't seem to give different results ever.


Diablo(Posted 2006) [#18]
I only said that because sometimes the results I got with it were different to what i got when i just used copy. i could have been of my head at the time tho ;)

Edit: if i recall it had somthing to do with the source image size. As I said I havent had the time to debug it to day, but I should be able to over the week end.

Further Edits: Any way I thought I'd let you decide what mode you want to use.


Diablo(Posted 2006) [#19]
Update:
ModuleInfo "History: 1.02a"
ModuleInfo "History: The results of SetBuffer()...EndBuffer() can now be used with Max2D DrawImage, etc."
ModuleInfo "History: Copy mode no longer works correctly :( (Going to phase it out as it dosent have any advantages)"


I also updated the Render To Texture demo.

Download from Here


jkrankie(Posted 2006) [#20]
Is this no longer available then?

Cheers
Charlie


Diablo(Posted 2006) [#21]
Not at the moment. Mess up on my part - uploaded a seriously bugged version and erm, forgot to back up *ducks for cover*. Once the new version is working I'll re-upload.


H&K(Posted 2006) [#22]
Hi Diablo,

Has you got a new link for HighGfx yet?


Diablo(Posted 2006) [#23]
check back in a couple of weeks, im to busy to even help people atm.


H&K(Posted 2006) [#24]
Errr, two weeks ;)

If you think bugged version is unsavable, then sorry for the hasstle. Any news?


Diablo(Posted 2006) [#25]
Yea, its half-term now. I can finally get some true code fixing done


Sensenwerk(Posted 2006) [#26]
Hi. Again three weeks. I'm really looking forward to the release. : )


Diablo(Posted 2006) [#27]
:P cant do a damm thing atm, I cant upload a single thing ad cant figure out why. Its really annoying me too !


Cruis.In(Posted 2006) [#28]
diablo can I use this to add laser images, and would it be possible to test for collision with something created with this module?


jkrankie(Posted 2006) [#29]
If you need someone to host the files for you then let me know.

Cheers
Charlie


SofaKng(Posted 2007) [#30]
I don't suppose this is going to be available anytime soon is it?


RiK(Posted 2007) [#31]
I've got plenty of space if you need somewhere to host it..


SofaKng(Posted 2007) [#32]
I don't suppose this is available anywhere, is it?

I've e-mailed Diablo but haven't gotten a response yet.

Basically I really want to see how he got the OpenGL framebuffer extension working because I keep getting memory exceptions whenever I try to do anything with them.


JohnK(Posted 2007) [#33]
i have 404 =(


juse4pro(Posted 2011) [#34]
Was it OpenGL-only?
I get a 404, too...


xlsior(Posted 2011) [#35]
I get a 404, too...


Not surprising, since that is what the previous poster got 4 years ago as well. :-?

Anyhoo, I uploaded a copy just now since I happened to find it on my drive: http://www.xlsior.org/temp/diablo.mod.zip

(It uses DX7 under windows, it seems)