2d module, opengl3.3 based WiP

Community Forums/Showcase/2d module, opengl3.3 based WiP

Polan(Posted 2011) [#1]
I''ve been playing around with opengl 3.3 and I thought, why not make a 2d module for blitzmax.. faster than native and with shaders?
The idea starts to turn real and I already achieved nice performance boost in some parts.
Alpha blending, light blend etc. is at similar/same speed as native but solidblend is sometimes mega faster. The larger image you use the faster it goes (interesting huh?)

That image is Build out of 512*512 1pixel images. Running at 40fps.
To compare native blitzmax module run the same code at 20fps.
That example run same at all blends.
Doubled the fps rate for 1image-perpixel. Great. But we can do better.

This one is even more interesting. it draw 22500 256x256 images at once. Blitzmax render it at 2fps rate. No matter what blend we use (image have alpha mask). My module draw it at 2fps while using alpha (to be improved..) and.. at 30fps while ignoring it. :) 15x faster.

We got some raw numbers and processing power. Note this module use glsl3.3 shaders, so you can get ALOT better effects and great speed (blur,hdr,shadows,lights?) with correct shader.


Some technical info about module:
Module will be similar to blitz3d. You will loadimage and then create instance of it, position then , color,rotate. And forget. Everything will be rendered on plrenderworld() call, while all math will be done at plUpdateWorld().
You will be able to set parent for instances for bone animations, participle system or whatever you want.
You will get camera system which will let you move,rotate,color whole world with really few function calls. You will be able to have multiple cameras for stuff like deathcam or whatever.
During loading of images you will be able to generate mipmaps and set filter (NEAREST/LINEAR).
You will be able to use few images per instance. In case you want to use bumpmapping etc.
Module will include plerNet, that's multithreaded networking module I've wrote, and which should let you have 100+ clients running at 24dl/6up, via tcp with 60-70ms ping... all sitting on the same pc (bet that ping was caused by 100-120 app running at same time, my cpu was at crawling speed during that test..).

Last edited 2011

Last edited 2011

Last edited 2011

Last edited 2011


dmaz(Posted 2011) [#2]
Simply awesome! can't wait...


ImaginaryHuman(Posted 2011) [#3]
Sounds fast but how many people have OpenGL 3.3 support. I know my Mac only has 2.0 and it's only 5 years old, so you're going to greatly narrow your audience.


Polan(Posted 2011) [#4]
"Supported Cards: GeForce 8, GeForce 9, GeForce 100, GeForce 200 and GeForce 300 series, Radeon HD series"
I checked steam and about 90% of people have 3.3 support :). Ogl is not direct it doesn't require any specific system and works on old cards (my 5old pc can support it ;))


ImaginaryHuman(Posted 2011) [#5]
Ok but I'm telling you MY 5-year old pc cannot support it and steam statistics are skewed towards higher end gamers.


Taron(Posted 2011) [#6]
HAHAHAHA! (sorry) ...openGL compatibility is insanely tough to keep, even across different brands of same generation gfx boards. Nvidia is extremely generous and tolerant, when it comes to shader coding, but ATI alone can throw a wrench in your endeavors. I have not seen any ogl code of higher versions that takes advantage of the latest features, which would run on any older generation, particularly because it tries to take advantage of the latest features of your gfx board, so at the latest there it will fail.

BUT, I absolutely love your faith and enjoy to not concern myself with such issues, either. At the end even opengl 3.3 will be old and all former versions will be laughed at. So don't let that confuse you, but realize that you may run into many complains of people, who can't run your stuff yet.


Polan(Posted 2011) [#7]
Just incase anyone is interested :).
I'm impleting keyframe like animation, so animating image will be as simples as createanimation(few params goes here) and then just playanimation/animate. This will also include parts for begging-end of animation for seamles animation. You also will be able to create rotation-scale-color state per frame, in case you want to get some bone system going.
Blitzmax animation (tile set images) will have optional linear filter. It means that frames will blend. You can see that effect on image. It should be really fast (as it's done on gpu).



ImaginaryHuman(Posted 2011) [#8]
By the way 30fps is not 15 times faster.

15fps is half the speed of 30fps
7fps is quarter
3.5fps is 1/8th

so it's not more than about 8 times faster

But anyway, good luck with it. Blitz could do with a speed boost.


taumel(Posted 2011) [#9]
People will be interested in it if it works, best on all platforms BlitzMax supports and will be a benefit to them. Otherwise a few will play around with it for some time before it will end up nowhere, again.

Last edited 2011


AltanilConard(Posted 2011) [#10]
By the way 30fps is not 15 times faster.

You say 30fps is not 15 times faster then 2fps ?


Polan(Posted 2011) [#11]
It will be released for windows and probably for linux. Have no mac, and know noone with mac so I won't be able to compile it there. Oh and here's the animation showing the difference between nearest filter and linear :).

Left one is nearest, right one is linear. Both are 10 frame animation.


ImaginaryHuman(Posted 2011) [#12]
Yea you're right, never mind.


dmaz(Posted 2011) [#13]
I'm impleting keyframe like animation, so animating image will be as simples as createanimation(few params goes here) and then just playanimation/animate. This will also include parts for begging-end of animation for seamles animation. You also will be able to create rotation-scale-color state per frame, in case you want to get some bone system going.
Blitzmax animation (tile set images) will have optional linear filter. It means that frames will blend. You can see that effect on image. It should be really fast (as it's done on gpu).
fantastic. and btw, I can compile it for you on a Mac if needed.


JoshK(Posted 2011) [#14]
You need to target OpenGL 3.2 for Mac.

I'm not aware of any advantage OpenGL 3.2 has over OpenGL 2.1, for 2D drawing.


ImaginaryHuman(Posted 2011) [#15]
There's not much advantage of 2.0 over 1.1 for 2d, except perhaps to do stuff in the shader.


Polan(Posted 2011) [#16]
With Ogl3.3 being the new standard, where deprecated functions are deleted you won't have to live in fear of possible (hardly...) drop of support for your code. It might also get some optimalisation and is more elastic :).

And now little update on progress:
Parenting is in, so when you rotate 1 instance, all it's kid get rotated.. Making solar system is just case of few functions. There is move command similar to blitz3d.
I got collision commands that Are based on basic shapes, circle and tris. Rect is also in but it's based on tris.
Tris can be specified by all 3 points so you are not limited by rotation, shape or scaling. There will be helper function for images which will take care of corner position calculation :).
I got "screenshot" function. It just take part or whole screen and save it to file. TGA supported right now but I should add some more formats before release.
There are way more feature on their way and I'm preparing to build some tech demo soon.

Last edited 2011


Polan(Posted 2011) [#17]
UPDATE!
More and more progress is made but now I need little help.
I need to check if other people with ogl 3.3 can run my exe, just for sure I'm not making single-use-mod.
http://www.mediafire.com/?dbngb5sj0qj6tu6

And here's how the code look like.
SuperStrict
Framework BRL.Random
Import pler.pler2d
SeedRnd(MilliSecs())
Global gw:Int = 1024 , gh:Int = 768
plGraphics2d(gw,gh)
Print "Opengl version: "+plGLVersion()


Global size:Int = 24
Global img:Int = plCreateImage(size,size)
   For Local x:Int = 0 To size-1
   For Local y:Int = 0 To size-1
   If plDist(size/2,size/2,x,y) < size/2
      plWritePixel(img,x,y,0,Rand(50,100),0,255)
         EndIf
   Next
   Next
   plBakeImage(img)
   plMidHandleImage(img)
   plSetBlend(img,PL_ALPHA)

Global inst:Int[5]
inst[0] = plCreateInst(img)
   plInstPos(img,inst[0],gw/2,gh/2)
For Local x:Int = 1 To 4
inst[x] = plCreateInst(img,img,inst[x-1])
plInstPos(img,inst[x],0,150-x*30)
Next

While Not KeyHit(key_escape)
plCLS

For Local x:Int = 0 To 4
plInstRot(img,inst[x],.1)
Next

plUpdateWorld
plRenderWorld

Flip
Wend


EDIT:
switched link to debug version

Last edited 2011


BlitzSupport(Posted 2011) [#18]
It seems to work here -- there are some green circles moving about anyway!


Polan(Posted 2011) [#19]
Well that's what you were supposed to see :). You used the machine from tag? (Beta test specs: Windows 7/XP; Intel Core 2 Quad Q6600 @ 2.4 GHz; GeForce GTX260.)?


BlitzSupport(Posted 2011) [#20]
Yep, that's right.


Polan(Posted 2011) [#21]
Update:
Fonts will be bitmap based, I will provide fontgen exe that will generate plf and pli file. plf contains font data and pli is my own image format with compression prepared for images with lots of blank data (like 1 color background in fonts). There is function in engine which let you save to that format. Using it is optional, it's there just to let you secure your arts a little and maybe compress them.
Drawing data is a little different from blitzmax native. You will create string which will be autodrawn, it will save position, spacing between letters, handle, string height, string width, font, color etc. It will let you do some action on every chars in string so effects like waving text will be easy to do :).
Next on todo list is basic gui module with inputs etc. and customizable image.
After this I will write few default shaders like lights, shaders. If it will take to long I will release the engine without default shaders and update it later.