I need to write opengl-based application for Android.
Is there a big difference between OpenGL SL and OpenGL ES 2.0 SL and between OpenGL and OpenGL ES and will it be useful if I learn OpenGL and GLSL using some books related to general OpenGL, not to OpenGL ES?
There are some huge differences between GLSL on a desktop environment and GLSL in OpenGL ES 2.0.
The primary difference would be the introduction of precision to integer and floating-point types. Implementations are required to give you three different precision levels in vertex shaders (low / med / high) and two in fragment shaders (low / med). An implementation may optionally support high precision in fragment shaders, and this can be determined at compile-time by testing whether a pre-processor definition for GL_FRAGMENT_PRECISION_HIGH
exists or not.
Where the first published desktop GLSL spec. corresponds to #version 110
(and GLSL compilers are supposed to assume this is the version a shader was written for if no #version
is present) GLSL ES begins with #version 100
and in many respects the syntax is roughly equivalent to GLSL #version 120
on the desktop. You have to use the old attribute
and varying
variable declarations for vertex shader input/output and fragment shader input instead of in
and out
as defined by desktop GLSL (>= 130).
Vertex texture lookups are an optional feature in OpenGL ES 2.0, and you need to pay special attention to the value of GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS
(it will be 0 if your implementation does not support them).
The number of uniforms and vertex attributes required in GLSL ES are extremely limited compared to desktop GLSL. GLSL ES only requires 8 vertex attributes and 128 vec4
uniforms as opposed to desktop GLSL which requires 16 and 256 respectively.
GLSL ES (100) only requires 2 draw buffers (fragment shader outputs) where as desktop GLSL requires 8.
Rules for what can and cannot be used to index arrays are more strict in GLSL ES. The minimum implementation requirements are such that you may not be able to use a loop counter as an index into a uniform array in a fragment shader in GLSL ES.
Last, while a desktop GLSL shader may target a compatibility profile context and thus support things like gl_FrontColor
and gl_ModelViewMatrix
OpenGL ES 2.0 eliminates all of the features OpenGL deemed deprecated in OpenGL 3.2 (plus a few more things like polygon fill mode). So any shader that was written to reuse fixed-function vertex pointers, matrices, etc. cannot be ported directly to OpenGL ES 2.0.
There are a lot more differences, but this should get you started. If you really want a more thorough list you should probably consult the formal specifications for GLSL 150+ (OpenGL 3.2) and GLSL ES 100 (OpenGL ES 2.0). There is a sub-section at the end of both language specifications (titled Built-in Constants) that outlines implementation minimum requirements, and it is a good idea to familiarize yourself with these. If you take a shader written for desktop GLSL and attempt to port it you will often run into hardware/implementation limitations in GLES.
Differences between OpenGL and OpenGL ES
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:
In addition, the following OpenGL functionality is not present in OpenGL ES 2.0:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With