Wish: OpenGL 2D

Jim Brown

Active Member
Licensed User
Longtime User
I guess this a *big* request but I would eventually like to see an OpenGL library geared towards 2D gaming in Basic4Android
Even as a separate "paid-for" library

I had a crack at writing a library for another language, but would have no idea how to create such a library in Android and interface it with b4a

The general features I have in mind:

+ Images load as textures (auto-resized to power of 2)

+ Each image has an anchor/hotspot (for rotating/offsetting). Commands Such as image.MidHandle , image.SetHandle(xoffs,yoffs) would determine the hotspot position

+ Each image can have its own colour, alpha, blend mode, scaling **, and rotation defined
** Images can be flipped by setting negative scaling values

+ Animation - Since the image is a texture then animation is best done via defining an area within an area of the texture. This is good for memory and performance (single-surface). Three commands come into play:
B4X:
image.SetFrames(columns,rows) 
image.Frame=thisframe    ' set frame to view (0=first frame)

+ Images can be duplicated (thus sharing the same texture for single-surface reasons)
B4X:
image.DuplicateImage(thisimage)
image.SetFrameRect(x,y,w,h)  ' determine area within the images texture to use

+ Global screen scale and rotation
Effects all rendered images

+ A reset option to restore the image to its basic defaults
This resets rotation, scaling, blend, colour


Yup, now that's a feature request!
 

Smee

Well-Known Member
Licensed User
Longtime User
Jim,

+ Each image can have its own colour, alpha, blend mode, scaling **, and rotation defined
** Images can be flipped by setting negative scaling values

I have just downloaded some of your gl apps to have a look at. From what i understand in your request list it would incorporate the ability to be able to display a frame and then be able to turn it as in a flip book?

I have posted a few times re this. Hopefully there will be a solution down the track. I have used the functionality in other software using 3rd part dll's. It always looks good

Good luck and keep developing

Joe

EDIT:

just had a look at the example. Awesome, so much happening with so little code
 
Last edited:

Jim Brown

Active Member
Licensed User
Longtime User
Hi Joe
What I mean by image flip is being able to show an image 'flipped around' (or mirrored). This is useful for game characters and saves you having to have multiple versions of the same character facing in different directions

OpenGL is good for this since you can easily flip the image by manipulating the texture coordinates or the verticies (which construct the quad)

I have had a look at you flip book links. Interesting stuff. In OpenGL though I can only imagine this being done by a grid of verticies. Getting them to bend in a convincing manor is another thing though
 

Smee

Well-Known Member
Licensed User
Longtime User
Hi Jim,

Thanks for looking. I have picked up some code which purports to do the page flipping. It is PD so i will be posting it shortly. I am pretty sure I will not be able to untangle it but there are some exceptionally clever people on here who may be able to do something with it. It is commented but in vietnamese and broken in to sections so hopefully it is complete

Joe
 
Top