which opengl version runs on every device? - opengl

Using llvm you can write a Programm which runs on PC, Mobile and since WebAssembly even in your Webbrowser. But for an Example Android uses Opengl-ES. Is there any opengl version which can be used on each of these platforms?

There is no single version of OpenGL that runs everywhere, but OpenGL ES 2.0 is pretty close to the lowest common denominator.
WebGL 1.0 is very similar to OpenGL ES 2.0. WebGL 2.0 is a subset of OpenGL ES 3.0, with various restrictions which are required for security.
On desktop systems, there is usually a way to create an OpenGL ES 2.0-compatible context and use the exact same API as on Android. Regular desktop OpenGL has a few incompatibilities with OpenGL ES, see for example this page:
https://www.khronos.org/webgl/wiki/WebGL_and_OpenGL_Differences
Mobile devices almost universally support OpenGL ES 2.0, and most flagship phones support OpenGL ES 3.2. The current distribution of support for OpenGL ES on Android phones is at the bottom of this page: https://developer.android.com/about/dashboards/

Related

How to create a texture from an EGLImage in desktop OpenGL?

For OpenGL ES the OES_EGL_image extension provides a function EGLImageTargetTexture2DOES to create a texture from an EGLImage. Is there an equivalent extension/function for desktop OpenGL (not ES)?
I think GL_OES_EGL_image should work with the Mesa drivers and desktop GL. glxinfo shows the extension as supported with both core and compatibility profiles. I did not see any checks for ES with a quick look at the implementation.
A grep through the Mesa provided GL headers shows no other occurrence of EGLImage, so GL_OES_EGL_image is probably your only choice with the Mesa drivers.
I am not sure though whether this behavior is specific to Mesa or other drivers also follow it.

Libgdx - Support for OpenGL 4+

Is it possible to use Libgdx for a desktop development only and access newer versions of Opengl from Libgdx abstraction? I mean, if you want to develop mobile apps you will have to use a some verison of Opengl ES, which does not support lot of things like classic Opengl does (e.g. drawing wireframes, etc.).
Lets say I don't want to use Opengl ES but normal Opengl, version 4+ in these days, and fully use its features for oa desktop development. Does Libgdx have support for this?
On the desktop, libGDX is built on top of LWJGL, which at of the time of this answer supports up to OpenGL version 4.5.
So if you're using libGDX on the desktop, then you can simply access the LWJGL calls directly. This will break your build for mobile or web deployment though.

gl_PointCoord has incorrect/uninitialized value

I am having trouble to get valid values in my fragment-shader's gl_PointCoord variable. I use libgdx, which is a cross-platform java framework that allows to run the same application on the desktop as well on android. The shader works fine with OpenGL ES on android, only the desktop seems to not provide a correctly interpolated value but always zero.
Could this be an issue with libgdx or with the graphics driver?
NVidia Quadro 3000M
Driver 275.33
Win 7 64-bit (Service Pack 1)
libgdx-0.9.6
fyi: Did not do much research yet, but seems to be a bug in lwjgl or the driver that gl_PointCoord is only available when enabling pointsprite-mode via
Gdx.gl20.glEnable(GL11.GL_POINT_SPRITE_OES);
This is not available in OpenGL 4.2 or OpenGL ES 2.0, but seems to be required to be explicitly set on the desktop.

learning OpenGL ES 2.0 under regular OpenGL - compilation

I am learning OpenGL with an aim to build OpenGL ES application for Android / iPhone.
Since I learn it from the beginning, I would prefer to learn the new specification, without touching the old stuff (glBegin etc.). Unfortunately, when I pass some tutorial and implement stuff, it turns out that the examples are incompatible with ES 2.0. For example, after those excellent tutorials I know how to implement lights, what works on my PC, but would not work on a mobile (gl_LightSource is not supported in the latter).
What I would like to do, is to develop the code on my PC, and restrict the API to the commands that are supported under OpenGL ES (like, throw error on glLight). Is that possible?
Assuming you are using Windows for development, then you can restrict the API to just OpenGL ES 2.0 by using Google ANGLE. ANGLE is basically wrapping DirectX, but you use it through a fully standard compliant OpenGL ES 2.0 interface.
If you have an AMD Radeon GPU, you have another option: the AMD OpenGL ES SDK also provides a fully compliant 2.0 interface.
In both cases, if you accidentally use non OpenGL ES 2.0 features, the code will just not compile or fail at runtime in case of unsupported combinations of parameters. Same goes for shaders, the glCompileShader call will fail.
IF you want to learn OpenGL ES 2 and make sure you are only using calls and techniques compatible with OpenGL ES 2, consider learning WebGL.
WebGL is almost identical to OpenGL ES 2. You get the advantage of a javasript console (with firebug or chrome's built-in developer tools) and in some environments (chrome on windows I think?) you get VERY helpful error messages whenever you do something wrong. Add to that you automatically have access to up to 4 implementations of WebGL to test with (firefox, chrome, safari, opera) and you have a pretty good set of tools for testing your OpengGL.
This is essentially how I have been able to learn OpenGL ES 2.
As stated in the Mali GPU OpenGL ES Application Development Guide:
OpenGL ES 1.1 and OpenGL ES 2.0 are subsets of the full OpenGL
standard. When using the OpenGL ES API, there are limitations that you
must be aware of when developing your applications.
For example, the following OpenGL functionality is not present in
either OpenGL ES 1.1 or OpenGL ES 2.0:
There is no support for glBegin or glEnd. Use vertex arrays and vertex buffer objects instead.
The only supported rasterization primitives are points, lines and triangles. Quads are not supported.
There is no polynomial function evaluation stage.
You cannot send blocks of fragments directly to individual fragment operations.
There is no support for display lists.
In addition, the following OpenGL functionality is not present in
OpenGL ES 2.0:
There is no support for the fixed-function graphics pipeline. You must use your own vertex and fragment shader programs.
There is no support for viewing transforms such as glFrustumf. You must compute your own transformation matrix, pass it to the vertex
shader as a uniform variable, and perform the matrix multiplication in
the shader.
There is no support for specialized functions such as glVertexPointer and glNormalPointer. Use glVertexAttribPointer
instead.
You can always refer to the OpenGL ES specification and see if a function / feature is supported.
There is a good set of lessons available for OpenGL ES 2.0 over at http://www.learnopengles.com/. For developing on PC you can try using an emulator; many different GPU vendors provide their own emulators that translate the calls to desktop GL. However, the best way to be sure that your code works as expected is to run it on the actual device.
EDIT: A new emulator for Android has support for OpenGL ES 2.0: http://android-developers.blogspot.ca/2012/04/faster-emulator-with-better-hardware.html

iPhone OpenGL ES

Since I'm not familiar with iPhone development I'd like to know whether it is possible to use OpenGL ES1.0 on the iPhone 3gs rather than 2.0.
I'd like to share a code base across different mobile platforms and not having to deal with the programmable pipeline from OGLES 2.0 could speed up an initial build.
Update -- I'm not used to working with OpenGL Es, but is there a always complete backward compatibility or do phones sometimes only support the latest version, eg 2.0
Thanks
Yes, you can. Simply call the OpenGL ES 1.0 APIs. The hardware is a full 2.0 device, but the software/driver can implement an OpenGL 1.x pipeline for you.