Author Topic: Problem with shaders on Android  (Read 7361 times)

Offline theprotocol

  • Mc. Print
  • *
  • Posts: 22
    • View Profile
Re: Problem with shaders on Android
« Reply #15 on: 2012-Jun-14 »
GLBasic uses OpenGL|ES 1.1 since some devices don't support 2.0.
So, there's no shader support for mobile devices.

Isn't it just a matter of creating a 2.0 GL context instead of 1.1 in the initialization? GLBasic already has this implemented for non-mobile platforms. Isn't it a trivial change to just optionally include this code path for mobile platforms? Like, some kind of initialization command to tell GLBasic to generate a 2.0 context when building mobile code.
« Last Edit: 2012-Jun-14 by theprotocol »

Offline kanonet

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1142
    • View Profile
    • My GLBasic code archiv
Re: Problem with shaders on Android
« Reply #16 on: 2012-Jun-14 »
the protocol again: OpenGL|ES <> OpenGL
This are to different libraries and you can not run OpenGl on mobile devices.
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64

Offline theprotocol

  • Mc. Print
  • *
  • Posts: 22
    • View Profile
Re: Problem with shaders on Android
« Reply #17 on: 2012-Jun-14 »
the protocol again: OpenGL|ES <> OpenGL
This are to different libraries and you can not run OpenGl on mobile devices.


I know the difference between OpenGL and OpenGL ES. However, their implementations are VERY similar. The vast majority of commands are interchangeable. I sincerely doubt GLBasic on desktops using the programmable pipeline (2.0+) uses any code that doesn't exist in ES 2.0.

Most of the groundwork is done in the non-mobile codepath. To "port" it to OpenGL ES should be almost trivial. Almost the same commands and API (a few restrictions on shader variables come to mind).


In fact, the X_SETSHADER command can be run on mobiles - it just returns an error. If this error isn't some hardcoded thing that GLBasic has ("block all 2.0 commands if mobile") then it's coming from OpenGL ES, which is saying "Sorry, you're using 1.1, this command fails."

So, the first step is to switch to a 2.0 context in OpenGL ES. This is 1 line of code that needs to be changed. The rest shouldn't be too hard (fixed function commands wouldn't work anymore, but who cares - you want to program your pipeline anyway or else stick to 1.1).


edit: Summary version in case you still don't understand my point: OpenGL and OpenGL ES are extremely similar. Maybe 90% similar. If we simply establish a 2.0 GL Context then if we're lucky, GLBasic's OpenGL code should be THE SAME as required for OpenGL ES 2.0. If not, then we need some very minor tweaks (and obviously disable all fixed function commands and use the programmable pipeline commands only).
« Last Edit: 2012-Jun-14 by theprotocol »

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10746
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: Problem with shaders on Android
« Reply #18 on: 2012-Jun-14 »
wrong. ES 2.0 is totally different. There's no fixed function pipeline anymore. You have to program everything using shaders. (no glRotate, no glMultMatrix, no glEnable(GL_TEXTURE2D) )
It might be worth to do this at one point, but currently I'm having a lot more urgent things to push forward.

Offline theprotocol

  • Mc. Print
  • *
  • Posts: 22
    • View Profile
Re: Problem with shaders on Android
« Reply #19 on: 2012-Jun-14 »
wrong. ES 2.0 is totally different. There's no fixed function pipeline anymore. You have to program everything using shaders. (no glRotate, no glMultMatrix, no glEnable(GL_TEXTURE2D) )
It might be worth to do this at one point, but currently I'm having a lot more urgent things to push forward.

The bolded part is exactly consistent with what I said. My point is GLBasic already has the shader codepath, and that part 99% the same in ES as it is in regular OpenGL (some changes within the shaders themselves though). I acknowledged many times already that you do indeed remove the entire fixed function pipeline. But the idea is there isn't really much "porting" to be done, pretty much copypaste the existing shader codepath and don't include fixed function stuff.

However, I'm not pressuring you or anything! I understand that you have priorities. But I'm saying there could be potential for a community driven effort to do this (I'm looking into it!) somehow.

Offline bigsofty

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 2681
    • View Profile
Re: Problem with shaders on Android
« Reply #20 on: 2012-Jun-15 »
The biggest problem is the name, OpenGL 2.0, implies that this version is backwards compatible. The main thing they did with 2.0 is cut things out, no glbegin/end, no matrice stuff at all, some state changes are completely missing, etc... This means its not just a matter of changing some of your GL 1.1 engine, it's a complete re-write for 50%.

BTW Gernot, I don't know if you've seen this project, maybe it could help a move to 2.0 in the future... http://code.google.com/p/gles2-bc/

I would love shaders personally as I have to emulate them currently for shader like FX and I really could speed up my rendering with them too but i do realise it's a large project on its own right, Esp. for one developer and the large amount of platforms that GLB covers.
« Last Edit: 2012-Jun-15 by bigsofty »
Cheers,

Ian.

“It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration.”
(E. W. Dijkstra)

Offline mentalthink

  • Prof. Inline
  • *****
  • Posts: 3372
  • Integrated Brain
    • View Profile
Re: Problem with shaders on Android
« Reply #21 on: 2012-Jun-15 »
@Bigsofty, thanks for the links, it´s very interesting...

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10746
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: Problem with shaders on Android
« Reply #22 on: 2012-Jun-18 »
Quote
Known limitations¶
•currently supports only iPhone platform
◦porting to some other platforms should be easy
•fixed-point versions of the OpenGL ES 1.x API functions are not supported
•glColor4* is not supported

That's pretty much the stuff I was talking about.

Offline kanonet

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1142
    • View Profile
    • My GLBasic code archiv
Re: Problem with shaders on Android
« Reply #23 on: 2012-Jun-18 »
Yeah and no news since almost 3 Years, looks pretty death.
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64