Helping with GLES 2.0 shaders

All topics about ZGameEditor goes here.

Moderator: Moderators

User avatar
VilleK
Site Admin
Posts: 2277
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

It is working on my phone although it looks a bit different than on my computer: shader1 is working, shader2 seems to generate all white image. No crashes.

Can you please post the full log and I can see if I can find any clues to what is wrong?

Otherwise all I can recommend is that you try simplifying the GLSL code until it works. It could be a buggy graphics driver on your device.
User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Post by Rado1 »

Here is the full logcat.
Attachments
log.zip
(5.21 KiB) Downloaded 417 times
User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Post by Rado1 »

Hi Ville, you were right. I tested the shaders on Nexus 7 and they worked, even if their performance is very bad. I thought GLSL is much faster on this device.

I also observed a problem with ZApplication's properties ViewportWidth, ViewportHeight, ScreenWidth and ScreenHeight on Android: they are all 100 in OnLoad section. Only in OnUpdate section they return correct values. That's the reason why shaders from the example do not work correctly on Android. Attached is the corrected example.
Attachments
shaderTest2.zgeproj
corrected example
(7.44 KiB) Downloaded 416 times
User avatar
VilleK
Site Admin
Posts: 2277
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

From the log file it can be seen that it crashes in the compileshader call (inside the driver). This is evidence of a buggy driver.

We should probably add a new kind of event, App.OnSurfaceCreated. Which would be called when the OpenGL surface is created and the dimensions are known. On Android this could be called multiple times since the surface is recreated (by the OS) in various situations (switch focus to another app and then back, turn of screen etc). For ZGE projects that make OpenGL calls from scripting this would be the place to create VBOs etc.
Last edited by VilleK on Thu May 30, 2013 1:41 pm, edited 1 time in total.
User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Post by Rado1 »

VilleK wrote:We should probably add a new kind of event, App.OnSurfaceCreated.
I fully agree.
User avatar
Kjell
Posts: 1883
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hmm,

I'd go with a function that return the state* of the Android app instead. Adding a event to the primary component that's only used for Android projects which use raw OpenGL objects is not worth the additional clutter & confusion.

*So for example, when onResume is called the value is 0x2 or something.

K
User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Post by Rado1 »

Kjell wrote:I'd go with a function that return the state* of the Android app instead.
Hi Kjell,

but when to call the function, in OnUpdate? This would be not optimal, because it is called always during application running. In addition there's explicit application event when the OpenGL surface is created and the content of this special section is called. I see special section as more transparent solution. The rule can be: non-graphical application initialization put to OnLoaded and GUI-related things to OnSurfaceCreated...

Also CharCode 255/254 in KeyPress used for application pause and resume is not optimal from this POV. What about to change them to sections of ZApplication and AppState components? On Windows, they can be mapped to loosing focus or something similar.
User avatar
Kjell
Posts: 1883
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Ehm,
Rado1 wrote:but when to call the function, in OnUpdate? This would be not optimal, because it is called always during application running.
One additional call ( per frame ) to a function that only returns a integer isn't going to make a dent in performance whatsoever.
Rado1 wrote:In addition there's explicit application event when the OpenGL surface is created and the content of this special section is called. I see special section as more transparent solution.
It's a event that shouldn't be there ( ideally ) in the first place. Plus, you'll only be using it in conjunction with direct OpenGL calls .. thus having it as a event node doesn't make sense in that way either ( since the only component you'll use it with is ZExpression ).

K
User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Post by Rado1 »

Anyway, would not be a proper solution to put some initialization to OnLoaded and some to OnUpdate sections. Ideally, everything should be in the OnLoaded section.
Post Reply