Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between OpenGL SL and OpenGL ES 2.0 SL

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?

like image 764
XZen Avatar asked Dec 19 '22 22:12

XZen


2 Answers

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.

like image 172
Andon M. Coleman Avatar answered Jan 12 '23 12:01

Andon M. Coleman


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:

  1. There is no support for glBegin or glEnd. Use vertex arrays and vertex buffer objects instead.
  2. The only supported rasterization primitives are points, lines and triangles. Quads are not supported.
  3. There is no polynomial function evaluation stage.
  4. You cannot send blocks of fragments directly to individual fragment operations.
  5. There is no support for display lists.

In addition, the following OpenGL functionality is not present in OpenGL ES 2.0:

  1. There is no support for the fixed-function graphics pipeline. You must use your own vertex and fragment shader programs.
  2. 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.
  3. There is no support for specialized functions such as glVertexPointer and glNormalPointer. Use glVertexAttribPointer instead.
like image 44
Devesh Agrawal Avatar answered Jan 12 '23 12:01

Devesh Agrawal