Problem with shaders on Android

Previous topic - Next topic

theprotocol

#15
Quote from: Kitty Hello on 2012-Jun-13
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.

kanonet

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

theprotocol

#17
Quote from: kanonet 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).

Kitty Hello

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.

theprotocol

Quote from: Kitty Hello 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.

bigsofty

#20
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.
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)

mentalthink

@Bigsofty, thanks for the links, it´s very interesting...

Kitty Hello

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.

kanonet

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