floooh / oryol

A small, portable and extensible C++ 3D coding framework

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is oryol not support OpenGLES2?

smalllixin opened this issue · comments

commented

Hey dear floooh,
After read some articles from README, seems oryol used to support opengles2. I see OpenGLES2 lake lots of features eg. instancing. But for mobile app compatiblities are f*ck-ass thing must be considered. I can choose avoid use these features ES2 not supported.
Some advice to make this happen?

(Chrome just ate my comment when the connection went down, so here it goes again):

The GLES2 render path should support features like instancing as long as the GLES2 driver exposes the right GL extension (for instancing this would be ARB_instanced_arrays or ANGLE_instanced_arrays). The WebGL version uses this (which is basically GLES2).

If this isn't working as expected on mobile devices, it's probably a bug that can be fixed (however I have no idea whether GLES2 drivers on mobile devices expose the *_instanced_arrays extension.

Cheers,
-Floh.

commented

Thanks for replying.
What I want is let oryol are able to work with iPhone5,iPhone4s(32bit CPU, and only OpenGLES2 supported).
Run the examples on iPhone5 I found I got a black screen.
After some hacks. Something like

#define ORYOL_OPENGLES2 1

gl_impl.h

#include <OpenGLES/ES3/gl.h>
#include <OpenGLES/ES3/glext.h>
\\ to
#include <OpenGLES/ES2/gl.h>
#include <OpenGLES/ES2/glext.h>

iosBridge.mm

this->eaglContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3];
\\ to
this->eaglContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];

The simplest triangle&cube example worked. But examples like SimpleRenderTarget not correctly rendered. I will track the reason.

The challenge to embed oryol to my online product is the renderer switching is defined by macro.
Which means only one gfx renderer could be compiled. No way to support GLES3 for iPhone5s and above and a compatibility mode for below.

Does oryol prefered a runtime solution to decide which renderer is used? Something like define a failed-chain for this situation.

Besides that, I found the sokol you made. A very very brilliant project. I love so much! Expecting the day sokol integrated to oryol as the underlying gfx driver.

Hmm yes, the native iOS version has only been tested on my iPad Mini4 so far, so problems on older devices are likely :/

The WebGL2 code path has an automatic runtime fallback to WebGL if a WebGL2 context cannot be created, however, this is very simple to implement with emscripten since I can still include the GLES3 headers, even when the WebGL/GLES2 fallback is used.

It would be best if we could get this runtime fallback also working for native GLES3 to GLES2 (this would also be good for Android).

If this doesn't work for some reason, a compile-time switch and additional build configs would be the next best option (for instance emscripten has emsc-make-* which is hardwired to WebGL, and webgl2-emsc-make-* which tries to use WebGL2, and falls back to WebGL if this isn't available.

For iOS this could mean: ios-xcode-* could be hardwired to the GLES2 renderer, and gles3-ios-xcode-* could either be hardwired to GLES3, or implement a dynamic GLES3-to-GLES2 fallback.

Btw: did you try the Metal render backend (hmm, but I think the GLES2 iPhones didn't support Metal yet, only the GLES3 iPhones... same problem).

PS: the decision which OpenGL version is used for a platform is here:

oryol/fips-include.cmake

Lines 66 to 89 in 095e81a

if (NOT ORYOL_METAL AND NOT ORYOL_D3D11)
set(ORYOL_OPENGL 1)
if (FIPS_RASPBERRYPI)
set(ORYOL_OPENGLES2 1)
elseif (FIPS_LINUX OR FIPS_MACOS OR FIPS_WINDOWS)
set(ORYOL_OPENGL_CORE_PROFILE 1)
elseif (FIPS_IOS)
set(ORYOL_OPENGLES3 1)
elseif (FIPS_EMSCRIPTEN)
if (FIPS_EMSCRIPTEN_USE_WEBGL2)
set(ORYOL_OPENGLES3 1)
else()
set(ORYOL_OPENGLES2 1)
endif()
elseif (FIPS_ANDROID)
set(ORYOL_OPENGLES3 1)
elseif (FIPS_EMSCRIPTEN)
if (FIPS_EMSCRIPTEN_USE_WEBGL2)
set(ORYOL_OPENGLES3 1)
else()
set(ORYOL_OPENGLES2 1)
endif()
endif()
endif()

Note how the emscripten version has an additional check to decide whether it should use WebGL2 or WebGL.

commented

@floooh Good news.
After lots of tests. Finally just add a simple fail-back logic on iOS adaptor layer solve the problems. (And for running the samples on iPhone5 successfully. Fips should support a armv7 (32bit CPU) )
See the merge request for this minor changes.

floooh/fips#162
#276

commented

And, sadly, I don't have android device that only support OpenGLES2.

Ok, the 2 fixes look surprisingly simple :) I'll just merge them even though I can't test at the moment (only in the simulator).

Thanks a lot for the contributions, if you stumble over any other issues with older mobile devices, don't hesitate to contact me directly or open new github issues / PRs. Support for lower-end-devices is definitely an important goal for Oryol.