Problem with shaders on Android

Previous topic - Next topic

fivesprites

Hi,

Has anybody managed to get shaders working on the Android platform? 
No matter what I try, I can't seem to get even the most basic to work - even though they work without fault on PC.

Simple Fragment Shader (test.frag)

Code (glbasic) Select

void main(void)
{
  gl_FragColor = vec4( 1, 1, 0, 1);
}


Any request to load that shader using:

Code (glbasic) Select

IF (X_LOADSHADER(1, "", "test.frg"))
STDOUT "Shader loaded ok\n"
ELSE
STDOUT "FAILED TO LOAD SHADER!\n"
ENDIF


results in "FAILED TO LOAD SHADER" being lobbed out in the Android logs.  No other clues given :(

Any help would be greatly appreciated.

/Andy


mentalthink

HI I think the trouble but I´m not sure it´s the version of OpenGL, GLbasic uses 1.0, and I suppose your device uses 2.0... OpenGL 1.0 to 2.0 changes in the mode how do the things internaly...

Not it´s too much problem beucase you can adapt the Krhonos Library OpenGL2.0 to GLbasic, I´m beggin comming soon to port...


Slydog

Do fragment shaders work with GLBasic? (Since it's only OpenGL 1.1?)
I wonder if the hardware on the PC just didn't mind the shader code, while the Android version is more strict.

@mentalthink: Cool, never heard of the Khhonos Library yet!  So it MAY be possible to run OpenGL 2.0 in GLBasic?!?!
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

fivesprites

Quote from: Ocean on 2012-Jun-11
"test.frg"  in the GLB code misses an 'a' `?

Unfortunately, no - that was a typo by we when writing the post - wish it was that simple!

mentalthink

Quote@mentalthink: Cool, never heard of the Khhonos Library yet!  So it MAY be possible to run OpenGL 2.0 in GLBasic?!?!

Hi Slydog, I think not have to be too much complicated, I  port part of OpenGl 1.1 of Khronos too, and I think have to be very similar... the only trouble it´s testing in PC, but I think using the last Emulator of android , it´s capable of Open GLES 2.0 can be easy...

IF you interested in take a look at this, look this book, it´s awesoming the 3d whit OpenGl 2.0 can do...

http://opengles-book.com/downloads.html

take a look in wiki- installations, the books teaches how install an Emulator and a SDK?¿, about OPENGL ES 2.0, and look running in PC it´s absolutetly fantastic...

PS: If you take a look at krhonos have got a lot of libraries... like OPENAL... (I´m not sure if GLBsic uses this for audio, or it´s whit SDL)   :-[

fivesprites

Quote from: Slydog on 2012-Jun-11
Do fragment shaders work with GLBasic? (Since it's only OpenGL 1.1?)
I wonder if the hardware on the PC just didn't mind the shader code, while the Android version is more strict.

@mentalthink: Cool, never heard of the Khhonos Library yet!  So it MAY be possible to run OpenGL 2.0 in GLBasic?!?!

It does look like it's an 2.0 thing.  It's a shame really as the shaders I'm using look lovely on the PC (using GLB) :(

Hopefully Gernot will be able to introduce support for it in the future.

Thanks guys.

/Andy

Slydog

@fivesprites
QuoteIt's a shame really as the shaders I'm using look lovely on the PC (using GLB) :(

Hmm, so 2.0 shaders work on the PC using GLBasic? 
I thought OpenGL 1.1 was the standard on all platforms?
Or does the PC code just work somehow?!  Weird.

@mentalthink: There's a small chance I own that book already.  I bought a bunch at first to start iPhone programming, but barely cracked any of the covers!   :-[  But still too involved for me to dig into, I'll just program to use whatever features / version GLBasic exposes to me.
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

fivesprites

Yep - works great!

Here's an example:  https://dl.dropbox.com/u/32204670/ShaderTest.zip

This modifies the background image by changing the colour using RGB->HSV->RGB.  Move the mouse around to change the Hue and Saturation and the Left/Right mouse buttons to adjust the Value.

:)


kanonet

Quote from: Slydog on 2012-Jun-11Hmm, so 2.0 shaders work on the PC using GLBasic? 
I thought OpenGL 1.1 was the standard on all platforms?
Or does the PC code just work somehow?!  Weird.
OpenGL <> OpenGL ES
As far as i know on all mobile devices GLB uses just OpenGL ES 1.1. But on desktop it uses OpenGL, i think in higher versions, but i dont know in detail.
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64

theprotocol

Aw, that's a bit disappointing. I assumed shader support for mobile platforms was in. Kinda puts a wrench in some of my ideas. ;(

fuzzy70

As far as I'm aware GLB defaults to the lower versions of GL /GLES for the sake of compatibility for as many target's as possible.

While my desktop can handle OpenGL 4.2 with ease while my laptop tops out on 2.1 I think.

Android is another minefield with regards to specs like gpu's (of which not all have).

Would the PLATFORMINFO$(GLEXT :xxxx)  be of any use or is that PC only?

Or maybe adding what you need along the lines of the gl.gbas include file might help. Am sure I have seen post's on the forum along those sort of lines.

Lee
Sent from my GT-I5700 using Tapatalk 2
"Why don't you just make ten louder and make ten be the top number and make that a little louder?"
- "These go to eleven."

This Is Spinal Tap (1984)

theprotocol

#11
"Thinking out loud" post - will contain a lot of errors!

I've been looking into some makeshift way of overriding GLBasic's EAGLContext initialization when it generates mobile device code.

Thinking out loud, these are my initial assumptions:

- The existence of X_SETSHADER means that GLBasic is using the OpenGL 2.0 spec when available. Therefore, 2.0 functions are implemented somewhere in GLBasic. I'm assuming they are mostly interchangeable with OpenGL ES 2.0 calls.

- When GLBasic builds a mobile app (Android or iOS), the generated code creates a v1.1 GL Context. I'm looking for a way to switch this into a 2.0 context (Looking at this currently for iOS).

- Possible roadblock: even if we somehow manage to override the GLContext code that GLBasic generates with inline C/C++, does GLBasic arbitrarily block shader-related code from being built into mobile projects? It looks like the answer is probably no since shader functions return a "fail." I'm hoping this "false" response isn't hard coded by GLBasic, but rather comes from the OpenGL implementation (which returns false if you attempt shaders in a 1.1 context). If GLBasic is simply blocking 2.0 functions on mobile devices in a pre-determined way, then this is hopeless.

English version: Is the error "FAILED TO LOAD SHADER" coming from GLBasic, or OpenGL? I hope GLBasic leaves it to the OpenGL implementation (not hard coded in GLBasic generated mobile code).


Does anyone see any potential here?


edit: My approach here is iOS-centric. Android might be easier! It seems the Android API provides functions for switching the context version. For example:

Code (glbasic) Select
MGLsurfaceview.SetEGLContextclienntVersion(2)


Would be good if someone more knowledgeable on Android could chime in.

Kitty Hello

GLBasic uses OpenGL|ES 1.1 since some devices don't support 2.0.
So, there's no shader support for mobile devices.

fivesprites

Pretty much figured the same :(

Gernot, do you plan to introduce support for GLES2.0 at some point in the near future?  Is there anything we could do to help move this along?


mentalthink

@fivesprites... I don´t try yet to make a port to opengl 2.0, but if I´m not wrong not it´s too much complex... How i told more above... I port part of the 1.0 whit more things... you can have very nive graphics whit 1.0, but was very easy make the mini-port , about the 2.0 I have plans to do it, becuase I stay very interested in this Library...

You can found in the forum, the way to make a wrap of Open GL, it´s the same manner I do the port of OpenGl-es 1.0, but you can read a bit about how make the things... Krhonos Group have a huge information, and if you search something like OPENGL es tutorial you will find some in english very very interesting...

Don´t care about 2.0 I´m sure in sometime perhaps it´s implemented, but How I told you make our self, not it´s too much complex...

PS: (I´m not proffesional programmer, and I can do it, and it´s very very fun!!!, a part of learn very interesting things.)