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

Jim Brown

Active Member
Licensed User
Longtime User
@magicuser68,
Are you running in Release Mode?

@alfcen,
No, I have not done much in terms of 3D development, but now that the 2D lib is pretty much nailed I might pop back into 3D land.
 

Toley

Active Member
Licensed User
Longtime User
I got the same error as magicuser68 (with jelly bean demo) is it working only on Jelly Bean OS ?

btw here is the Log

edit : seems to do that with all the demos.
 

Jim Brown

Active Member
Licensed User
Longtime User
By the looks of it glBlendEquation is a trouble maker. I have removed this particular call. In any case it served no purpose (all blending equations were the same default value).

For those getting errors try replacing the attached GlImage.bas with the one in the main folder Or, download the library again.
Please run the OpenGLDemo_BlendModes to see if blending works.

OpenGL 2D Lib 1.4a - Choose File then Download


Go to TOP OF THREAD
 

Attachments

  • GLImage.bas
    15.3 KB · Views: 219
Last edited:

Toley

Active Member
Licensed User
Longtime User
Hi Jim sorry for the late feedback I was out for a diner with old friends.

Everything work perfectly now. Thank you very much for the great work.
 

Jim Brown

Active Member
Licensed User
Longtime User
You can leave free space in the display. For example, here, the gl surface view fills the main display but leaving 20% free space at the bottom, where you could put the ad:

glsv_Initialize
Activity.AddView(glsv,0%x,0%y,100%x,80%y)
 

walterf25

Expert
Licensed User
Longtime User
Making grass move

Hello, i have a quick question regarding the capabilities of this great library, i need to create a game for a client, but i need to decide what components and libraries i will be using and that will provide me with the best way to create good graphics, is there a way to make for example make the grass move, i've seen some apps where there's a static image of either a flower a palm tree or grass and they move giving the app a natural look as if the wind is blowing, is this possible with this library or does anyone here know of a way to accomplish this effect?

thanks,
Walter
 

walterf25

Expert
Licensed User
Longtime User
Examples not working propperly

Hello, i downloaded this library yesterday night and everything was working just fine, i came to work this morning and downloaded the library and the example again on my work's computer and now all i see when i run each example are tiny little white squares moving around the screen, did something change between last night and today, it doesn't make any sense what is going on?

below is a screenshot of the example that has a few birds and a dog running across the screen, but all i see now are small white squares



anyone has any idea what's going on?



thank,
Walter
 

walterf25

Expert
Licensed User
Longtime User
One of the Modules

Ok, i found the one of the old example versions and it works just fine, i'm thinking either the GLImage.bas or the GLDisplay module on the latest version has an issue, can you fix this please, pretty please, i'm about to get started on a game app and i'm going to use your great library.

Thanks,
Walter
 

walterf25

Expert
Licensed User
Longtime User
Duhhhh

Never mind all, i figured it out, i upgraded Basic4Android from 1.9 to 2.02 and everything works like a charm, disregard all the previous posts, sorry!

Duhhh!

 

Jim Brown

Active Member
Licensed User
Longtime User
One trick is to place the images handle/hotspot at the bottom/centre then use math Sin() to rotate, giving a metronome type swing motion.
Other than that I might be able to add some Skew commands which would warp the image. Click HERE for an example.
You would then skew the image horizontally and place the handle/hotspot at the bottom/centre, resulting in a sway effect
 

walterf25

Expert
Licensed User
Longtime User
Awesome

Hey Jim, that would be so awesome, how hard would it be to add the skew commands, or do you have an actual code example to do it the other way, "metronome" way?

thanks for your help Jim.

While on the subject, is it possible to create a water ripple effect with this library, if so do you have a sample on how to do that?

thanks again Jim

Cheers,
Walter
 

Jim Brown

Active Member
Licensed User
Longtime User
V1.5 uploaded. See TOP THREAD

I have now added a SetSkew() command to skew the edges of the image by varying amounts.
The OpenGLDemo_Skew.b4a demo will give an indication of how this works.
 

bloxa69

Active Member
Licensed User
Longtime User
when I add GLSurfaceView to Activity, the whole screen goes black

hey Jim,
thank you for a great lib.
I have question: when I add GLSurfaceView to Activity, the whole screen goes black for a fraction of a second, but it's visible to the eye. Is it possible to avoid it somehow? (I tried it on my hardware devices and emulators - same thing)

B4X:
   glsv_Initialize
        'this is where I get a black flash over the whole screen
   Activity.AddView(glsv,0%x,0%y,100%x,100%y)

As a workaround, I've tried to load GLSurfaceView view first, then all others views on top of it. It worked and I didn't get any blackout. There is only one problem: after that I cannot bring GLSurfaceView view back to front (that was the idea).
glsv.BringToFront and glsv.SendToBack
don't work on it.

Thanks


Edited - Udate:

Hey Jim, I guess you are busy. After spending some time trying to fix that black screen issue, this is the solution I came up with (may be not very elegant, but it works):
1. Initialize the OpenGL 2D view, add it to Activity and then remove it right away
B4X:
   glsv_Initialize
   Activity.AddView(glsv,0%x,0%y,100%x,100%y)
       glsv.RemoveView
2. Build UI, load layouts etc
3. Add OpenGL 2D view again when done with everything else
B4X:
        'this is a fix for slower phones - remove it again just in case (otherwise OpenGL 2d view will not load at all on some phones, probably because the removal process still going on in background)
        glsv.RemoveView
        'end of the slow phone fix, load the view
   Activity.AddView(glsv,0%x,0%y,100%x,100%y)

It doesn't make much sense but it works. I sure appreciate it if you could provide a more elegant solution.
Thanks for the library.
 
Last edited:

mcmanu

Active Member
Licensed User
Longtime User
Possible?

Hi,Is it Possible to use For example your Exaple in a Other Activity? (not Main)
I tried it, but it seems to not work. Does it only works for the Main Activity?

Thanks in Advance
 

Informatix

Expert
Licensed User
Longtime User
I tried your class and I was a bit surprised to see a very high FPS in your performance demo while on screen smileys were moving very slowly. I looked at your code and saw that you counted the number of ticks per second and not at all the number of frames per second. You should move the FPS computation at the end of glsv_Draw. The count will be in line with what we see on the screen.

There's something more important annoying me. The performance is terrible for an OpenGL demo. I don't know if there's something wrong in the library or in your class, but there's obviously something wrong.
To give you an idea, I did a test under Gingerbread with the (fixed) demo and I got about 22-23 FPS for the settings 10/100.
I made a clone of your app but used a simple canvas and I got 60-62 FPS for the same settings.

I repeated the same test on a device under Jelly Bean and used a library of my own (an accelerated surface calling OpenGL methods, not yet publicly available). Logically, we should get the same results with the settings 10/500, but:
Your demo: about 14 FPS
My demo: about 58 FPS.
 

bloxa69

Active Member
Licensed User
Longtime User
There's something more important annoying me. The performance is terrible for an OpenGL demo.

Although I really appreciate that free library, still, I agree with Informatix - the performance of an OpenGL surface should be better. As an example, I can point out Erel's Game View - it's much smoother though it's canvas based, I think. Too bad I cannot use it for Android below version 3.0, so I have to create 2 versions for each app where I need it - one OpenGL ES for Android below 3.0, and the other one using the Game View lib. Then I switch them depending on OS. That almost doubles the amount of work.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…