OpenGL ES 2.0 with static (Fixed Function) pipeline API? - opengl-es

I know that OpenGL ES 2.0 standard threw out all the methods that can achieve the same results only keeping one. This is the result why static pipeline is removed from the specification and only dynamic pipeline is present. But it is strange that I use this code and it works:
glColor3f(0, 1, 1);//white
glBegin(GL_LINE_LOOP);
glVertex2f(lower.x, lower.y);
glVertex2f(upper.x, lower.y);
glVertex2f(upper.x, upper.y);
glVertex2f(lower.x, upper.y);
glEnd();
This API function I use belong to static pipeline, right as I draw without using a shader. BTW I do this is cocos2d-x 3.5 that is based on OpenGL ES 2.0.

BTW I do this is cocos2d-x 3.5 that is based on OpenGL ES 2.0.
From the cocos2d-x github page (my emphasis):
OpenGL ES 2.0 (mobile) / OpenGL 2.1 (desktop) based
You are very likely not using an GLES2 context at all, but a GL 2.1 one, which does support all of those legacy features like the fixed function pipeline and immediate mode.
Note that the immediate mode (glBegin/glEnd) was never a feature of GLES, not even in 1.x which did implement the fixed-function pipeline. It does only exist in legacy desktop GL. Your code will fail if you run it on mobile devices.

Related

What are the latest versions of OpenGL ES supported by emscripten, and how do I use them?

I am trying to make use of some ES 3.1 features, and it's unclear if this is supported:
I notice that there is an OpenGL ES 3.1 header in the emscripten repository which defines some of the functions I'm looking for, and I can include them successfully in my project. However, they are not available when I try to link:
error: undefined symbol: glDispatchCompute (referenced by top-level compiled C/C++ code)
warning: _glDispatchCompute may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
The documentation says that OpenGL ES3 is supported if I specify -s FULL_ES3=1 (which I am doing).
Since there are headers for it, is this functionality available? If so, how do I enable support for it? (Does it require manually loading extensions or enabling experimental support in emscripten, for example?)
First thing to realize, is that decent Browsers currently implement only WebGL 1.0 (based on OpenGL ES 2.0) and WebGL 2.0 (based on OpenGL ES 3.0). So that Emscripten SDK may implement only features presented by WebGL 2.0 + extensions, and, unfortunately, Compute Shaders are not presented in any way in WebGL (and there are no more plans to add this functionality in future).
By the way, WebGL 2.0 support has been added to Safari 15 (iOS 15) only this (2021) year, so that even OpenGL ES 2.0 will not work on all devices.
I notice that there is an OpenGL ES 3.1 header in the emscripten
The extra <GLES3\gl3*.h> headers are there not because Emscripten implements all of them, but because this is a common way to distribute OpenGL ES 3.x headers that existing applications may rely on to conditionally load / use OpenGL ES 3.x functions at runtime, when they available.
The documentation says that OpenGL ES3 is supported if I specify -s FULL_ES3=1 (which I am doing).
I think that documentation is more or less clear about what FULL_ES3=1 adds:
To enable OpenGL ES 3.0 emulation, specify the emcc option -s FULL_ES3=1 when linking the final executable (.js/.html) of the project.
This adds emulation for mapping memory blocks to client side memory.
There is no word about OpenGL ES 3.1 here, nor a reason to expect a wonder from Emscripten, as I can barely imagine a reasonable hardware-accelerated way to emulate things like Compute Shaders on top of OpenGL ES 3.0. And software emulation would be certainly of no use for most applications.
WebGPU 1.0 that promised to appear mid '2022, is more capable than WebGL 2.0. So that WebGPU developers already see that at one time native WebGL 2.0 implementation in the Browsers could be replaced by a WebAssembly module implementing this legacy API on top of WebGPU - but in some very distant future. The same could also bring OpenGL ES 3.1/3.2 features to Emscripten SDK - at least theoretically, if somebody will be still interested to work on this.

Which version of OpenGL is supported by WebGL?

I am in the process of reading WebGL and going through some tutorials .
But I think I had to learn OpenGL explicitly in order to work with WebGL more efficiently.
But there are many versions of OpenGL and this wiki link shows that WebGL uses OpenGL 2.0 but the latest version of OpenGL is 4.5 .
Can anybody suggest how to know which version of OpenGL is supported through some script in WebGL ,if possible.
WebGL is based on the OpenGL ES 2.0 API, however, there are some limitations they have adopted for increased availability.
The APIs of (modern) OpenGL, OpenGL ES, and WebGL, while not the same, are all closely related. If you know one, the usage of the other two is quite similar. In fact, you may be able to reuse a large amount of code between the three. So, knowing OpenGL would certainly help you implement a WebGL application, however, learning WebGL first is also plausible.
WebGL is not based on OpenGL. It is based on OpenGL ES 2.0. The same OpenGL ES found on Android and iOS.
There's significant differences between OpenGL and OpenGL ES. While OpenGL ES is a subset of OpenGL it is missing the old deprecated fixed function pipeline that so many people continue to use and so many outdated tutorials (like Nehe GL, still teach)
What's the fixed function pipeline? Anything having to do with glVertex, glColor, glNormal, glLight, glPushMatrix, glPopMatrix, glMatrixMode, etc... in GLSL using any of the variables that access the fixed function data like gl_Vertex, gl_Normal, gl_Color, gl_MultiTexCoord, gl_FogCoord, gl_ModelViewMatrix and the various other matrices from the fixed function pipeline.
Those are all removed from OpenGL ES 2.0 and therefore don't exist in WebGL
WebGL is based on OpenGL-ES 2.0

Use OpenGL ES 1.1 rendering engine with QCAR?

I wanna use a rendering engine with QCAR (vuforia) to build an AR app. Is it possible to incorporate a rendering engine which uses OpenGL ES 1.1 with QCAR?
I QCAR is using opengl 2.0 for sample applications.
QCAR supports both 1.x and 2.0 but by default 2.0 is enable. If your rendering engine only supports 1.x you can easily tweak QCAR to use 1.x by changing this:
USE_OPENGL_ES_1_1 := false
to TRUE in Android.mk file which is located under JNI folder. I assume that you are using QCAR for Android but for iOS the steps are pretty much the same.

glFenceSync alternative in OpenGL ES 2.0

I see that glFenceSync does not exist in OpenGL ES 2.0, it was added only in OpenGL ES 3.0.
Does OpenGL ES 2.0 offer any alternative of syncing between CPU and GPU, aside from the brutal force glFinish?
You have different calls in OpenGL ES 2.0 that give some insight into different matters concerning GL, but mainly, you're left with glFinish only.
In glext.h.
GL_API GLsync glFenceSyncAPPLE(GLenum condition, GLbitfield flags) __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_6_0);
I am pretty sure this is what you want. Anyway available only on iOS 6.0 or later.

OpenGL-ES 2.0 and egl* functions (iOS)

There're set of definition called "egl" in GLES 1.1: http://www.khronos.org/opengles/sdk/1.1/docs/man/
It's the "Native Platform Graphics Interface Layer":
http://www.khronos.org/opengles/
However, they're not in GLES 2.0: http://www.khronos.org/opengles/sdk/docs/man/
So I got some questions:
Is this a separated spec from GLES? Or a part of GLES1.1?
Where did they gone (in 2.0)? Or still exist (in 2.0)?
Where is the manual (guide)?
Should I manage eglContext in GLES 2.0 too?
EGL is a separate spec from OpenGL ES, it can manage contexts for OpenGL ES 1.0/1.1 and OpenGL ES 2.0 (and algo OpenVG), so it's not really gone.
The latest spec is here.
I think eonil was premature to accept the answer. Unless I am consistently missing things at the "latest spec" Valdenegro provided. For what I find there is that in order to choose the client API for the current context, one must use EGL_CONTEXT_CLIENT_VERSION, which is itself supported only in EGL 1.2, which is not on any Android phone I have seen: they are all EGL 1.1.
In EGL 1.0 or 1.1, you can only use the default client version, which is openGL ES.

Resources