B4A Library [Class] - OpenGL ES - 2D Image library

V1.5
Added: SetSkew() - To skew to image
Added: Reset() - Resets general image parameters (skew, position, rotation, handle, animation, flipped state)


I have put together a library designed for the purpose of displaying 2D images using OpenGL ES. The library needs Andrew Graham's libraries:

OpenGL ES library.
Reflection Library

Also, if you want to employ error checking you will also need Andrew's Threading library.

OpenGLES_2DLib.png
OpenGLLib_4.png


VIDEO: Jelly Beans


Key Features for the 2D Images
=======================================
* Pixel-Perfect image drawing (with unfiltered or filtered render options)
* Resize, rotate, flip, skew, change colour, alpha, blending modes, cropped areas - All faster than stock bitmap/canvas drawing
* Collision checks (only basic box-box checks)
* Anchor points - Each image has its own anchor hotspot (called handle in the library) so that the image can be rotated/flipped around a particular point
* An image can share the texture from an existing image (to save space and improve memory performance)
* Images don't need to be a power of 2 since the library will re-size them if required.
* Animation - Images can be animated easily by setting 'frames'. Image strips as well as image grids are supported
* Set specific areas of the image to draw

Key Features for the Display
=======================================
* Virtual display setup makes it easy to create a common display which scales to the devices physical screen size
* Global positioning (anchor/handle), scaling, and rotation which impacts all images.
* GL surface view can be made transparent so that GL images appear on top of regular views.

Have a play with the examples to see how the basic implementation works.
Hopefully the commands make sense.

OpenGL ES 2D Image Library v1.5 - Download link -- Select File then Download
NOTE: Demos should be run in Release Mode

V1.1
Added: Transparency for GL surface view. New subs = SetClsAlpha(), SetClsColor()
Changed: ClearScreen() to Cls()
V1.2
Added: Virtual display commands/functions
Added: SetRect() for images
V1.3
Added: GetLeft(), GetRight(), GetTop(), GetBottom(), AtPoint()
Added: More demos
V1.4a Minor change: Removed glBlendEquation
V1.4
Added: SetBlend - To change the rendering appearance of images (Alpha, Light,Dark,Mask)
Added: Jelly Beans demo
Changed: The way images are loaded. Instead of checking for surface changes every time Draw() is called, a dedicated (one-shot) LoadImages() sub is called instead.
 
Last edited:

squaremation

Active Member
Licensed User
Longtime User
I get the following error on some examples:

Error loading module: GLImage
The given key was not resent in the dictionary

I have got all the required libraries installed :(
 

pluton

Active Member
Licensed User
Longtime User
Hi Jim

On first example OpenGLDemo_Animation works fine. I can move bird with finger and no problem with it.
Screenshot here:


On second example the app starts fine and works fine until I start to move slider to the right side. After I move slider I got error and force close app.
Screenshot here:

App start fine:


Then I move slider to right and I got Force close:

This is error in B4A in Debugger mode:


I have downloaded all libraries and testing this on LG P500 Optimus.
And this your class are awesome. Thanks for sharing it.

Later I will test other examples :sign0098:
 

squaremation

Active Member
Licensed User
Longtime User
Still cannot get example to work is there another library needed?


:sign0085:

scrn1-2.jpg
 

Attachments

  • scrn2.jpg
    scrn2.jpg
    55.5 KB · Views: 326

Jim Brown

Active Member
Licensed User
Longtime User
V1.2 uploaded. See top of thread for details of change

@Pluton,
I tend to get the same kind of errors occasionally. Debug mode causes havoc but things seem good in "Release" mode. Can you see if you get the same experience?

@squaremation
Do you want to try the new version v1.2?
I have included all extra libraries in the zip. See Additional_Libs folder. Copy these to your Additional Libraries.
If you open any one of the demos you should also see two extra tabs in the IDE. Like this:
[Main] [GLImage] [GLDisplay]
 
Last edited:

agraham

Expert
Licensed User
Longtime User
Debug mode causes havoc but things seem good in "Release" mode.
As my original demo states in a comment you should not try to debug any code called from the Draw event. The Basic4android debugger assumes that all code is running on the main GUI thread but the OpenGL code runs on its own thread and trying to stop or single step OpenGL drawing code will cause problems.
 

squaremation

Active Member
Licensed User
Longtime User
@squaremation
If you open any one of the demos you should also see two extra tabs in the IDE. Like this:
[Main] [GLImage] [GLDisplay]

Thnx! Got it to work. :sign0060:

At first I tried to add GLImage module manual, and it wouldn't load got same error. Then downloaded module from your link and it loaded. Guess the original got corrupt when I downloaded, only thing I can think of.
 

Jim Brown

Active Member
Licensed User
Longtime User
@Andrew
Thanks for the heads up. I will put comments in the examples to clarify the Debug situation.
Oh and thanks again for the libs. It would not be possible for me to produce my lib without them.
 

Toley

Active Member
Licensed User
Longtime User
Sorry for the stupid question, but how can this be downloaded???

I can see all the individual files but no zip package.
 

Jim Brown

Active Member
Licensed User
Longtime User
Hi Toley
Google Docs is not quite as user-friendly as it could be.
Once you see the list of files though, check the top of the page. You should see some menu choices: File Edit View Help
Click File, then Download option.

BTW all, I will be updating the lib soon with a Jelly Bean mini demo.
 
Last edited:

Jim Brown

Active Member
Licensed User
Longtime User
Another library update:

V1.4
Added: SetBlend - To change the rendering appearance of images (Alpha, Light,Dark,Mask)
Added: Jelly Beans demo
Changed: The way images are loaded. Instead of checking for surface changes every time Draw() is called, a dedicated (one-shot) LoadImages() sub is called instead.

Go to TOP OF THREAD
 
Last edited:

alfcen

Well-Known Member
Licensed User
Longtime User
Hi Jim,
I am still a true fan of your sphere model mesh.
Out of curiosity, have you developed that any further?
So far, I managed to wrap night shadows around planets.
Wouldn't have been possible without your pioneer work :sign0188:
 

Attachments

  • marsglobe.jpg
    marsglobe.jpg
    69.9 KB · Views: 296
Top