Cogl already add similar defines but with the CLUTTER namespace
(CLUTTER_COGL_HAS_GL and CLUTTER_COGL_HAS_GLES). Let's just add two
similar defines with the COGL namespace. Removing the CLUTTER_COGL ones
could break applications silently for no real good reason.
HAVE_COGL_GLES2 is defined in config.h through the configure script and
should not be used in public headers.
The patch makes configure generate the right define that can be used
later in the header.
COGLenum, COGLint and COGLuint which were simply typedefs for GL{enum,int,uint}
have been removed from the API and replaced with specialised enum typedefs, int
and unsigned int. These were causing problems for generating bindings and also
considered poor style.
The cogl texture filter defines CGL_NEAREST and CGL_LINEAR etc are now replaced
by a namespaced typedef 'CoglTextureFilter' so they should be replaced with
COGL_TEXTURE_FILTER_NEAREST and COGL_TEXTURE_FILTER_LINEAR etc.
The shader type defines CGL_VERTEX_SHADER and CGL_FRAGMENT_SHADER are handled by
a CoglShaderType typedef and should be replaced with COGL_SHADER_TYPE_VERTEX and
COGL_SHADER_TYPE_FRAGMENT.
cogl_shader_get_parameteriv has been replaced by cogl_shader_get_type and
cogl_shader_is_compiled. More getters can be added later if desired.
- In cogl-material.h it directly sets the values of the
CoglMaterialLayerCombineFunc to some GL_* constants. However these
aren't defined in GLES 2 beacuse it has no fixed function texture
combining. Instead the CGL_* versions are now used. cogl-defines.h
now sets these to either the GL_* version if it is available,
otherwise it directly uses the number.
- Under GLES 2 cogl-material.c needs to access the CoglTexture struct
so it needs to include cogl-texture-private.h
- There are now #define's in cogl-gles2-wrapper.h to remap the GL
function names to the wrapper names. These are disabled in
cogl-gles2-wrapper.c by defining COGL_GLES2_WRAPPER_NO_REMAP.
- Added missing wrappers for glLoadMatrixf and glMaterialfv.
- Renamed the TexEnvf wrapper to TexEnvi because the latter is used
instead from the material API.
Multitexturing allows blending multiple layers of texture data when texturing
some geometry. A common use is for pre-baked light maps which can give nice
lighting effects relativly cheaply. Another is for dot-3 bump mapping, and
another is applying alpha channel masks.
The dot-3 bump mapping would be really nice one day, but currently cogl doesn't
support lighting so that's not dealt with in this patch.
notable limitations:
- It can only texture rectangles a.t.m - and like cogl_texture_rectangle there
is no support for rotated texturing.
- Sliced textures are not supported. I think I've figured out how to handle
layers with different slice sizes at least for rectangular geometry, but I'm
not sure how complex it becomes once rotations are possible and texturing
arbitrary cogl_polygons.
- Except for this new API, cogl still doesn't know about more than one texture
unit, and so has no way of caching any enables related to other units. So that
things don't break it's currently necessary to disable anything to do with
additional units as soon as we are done with them which isn't ideal.
- No clutter API yet.
now stored in a separate struct so they can be stored for
application program objects as well.
* clutter/cogl/gles/cogl.c: Moved stub shader functions into
separate files.
(_cogl_features_init): Report support for the shaders feature on
GLES 2
* clutter/cogl/gles/cogl-shader.h:
* clutter/cogl/gles/cogl-shader.c:
* clutter/cogl/gles/cogl-program.h:
* clutter/cogl/gles/cogl-program.c: Separate files to handle
shaders on programs on GLES. If version 1.1 is being used then the
stub functions which all fail are still used.
* clutter/cogl/gles/cogl-gles2-wrapper.c
(cogl_gles2_wrapper_init, cogl_gles2_wrapper_bind_attributes),
(cogl_gles2_wrapper_get_uniforms): Move the uniforms and attribute
bindings into a separate function so they can be used to bind on
application shaders as well.
(cogl_gles2_wrapper_update_matrix): Now takes a parameter and is
no longer static so that it can be used to update all of the
matrices when a new shader is bound.
* clutter/cogl/gles/cogl-defines.h.in: Use GL_COMPILE_STATUS for
CGL_OBJECT_COMPILE_STATUS if the latter isn't available (for
example on GLES 2).
* clutter/cogl/gles/cogl-context.h (CoglContext): Added handle
arrays for programs and shaders.
* clutter/cogl/gles/cogl-context.c (cogl_create_context)
(cogl_destroy_context): Initialize and destroy program and shader
handle array.
* clutter/cogl/gles/Makefile.am (libclutter_cogl_la_SOURCES): Add
cogl-{shader,program}.{c,h}
* clutter/eglx/clutter-stage-egl.h:
* clutter/eglx/clutter-egl-headers.h:
* clutter/eglx/clutter-backend-egl.h:
* clutter/eglx/Makefile.am: Include the GLES and EGL headers via
clutter-egl-headers.h so that the right version can be used
depending on whether the GLES 2 wrapper is being used.
* configure.ac: Added an automake conditional for whether the GLES
2 wrapper should be used.
* clutter/eglx/clutter-stage-egl.c (clutter_stage_egl_realize):
Remove the call to glGetIntegerv to get the max texture size. It
was being called before the GL context was bound so it didn't work
anyway and it was causing trouble for the GLES 2 simulator.
* clutter/cogl/gles/stringify.sh: Shell script to convert the
shaders into a C string.
* clutter/cogl/gles/cogl-gles2-wrapper.h:
* clutter/cogl/gles/cogl-gles2-wrapper.c: Wrappers for most of the
missing GL functions in GLES 2.
* clutter/cogl/gles/cogl-fixed-fragment-shader.glsl:
* clutter/cogl/gles/cogl-fixed-vertex-shader.glsl: New shaders for
GLES 2
* clutter/cogl/gles/cogl-defines.h.in: Use the @CLUTTER_GL_HEADER@
macro instead of always using the GLES 1 header.
* clutter/cogl/gles/cogl-context.h (CoglContext): Include a field
for the state of the GLES 2 wrapper.
* clutter/cogl/gles/cogl-texture.c:
* clutter/cogl/gles/cogl-primitives.c:
* clutter/cogl/gles/cogl.c: Use wrapped versions of the GL
functions where neccessary.
* clutter/cogl/gles/Makefile.am: Add sources for the GLES 2
wrapper and an extra build step to put the GLSL files into a C
string whenever the files change.
wrapped in reference-counted CoglHandles instead.
* clutter/cogl/gl/cogl-shader.c:
* clutter/cogl/gl/cogl-shader.h:
* clutter/cogl/gl/cogl-program.c:
* clutter/cogl/gl/cogl-program.h:
New files to hold the shader and program functions.
* clutter/cogl/gl/cogl.c: Removed shader and program functions.
* clutter/cogl/common/cogl-handle.h: New header to define
COGL_HANDLE_DEFINE which helps build functions to create
reference-counted handles. This reduces the amount of duplicated
code.
* clutter/cogl/gl/cogl-texture.c:
* clutter/cogl/gles/cogl-texture.c:
* clutter/cogl/gl/cogl-fbo.c: Converted to use COGL_HANDLE_DEFINE
from cogl-handle.h to avoid duplicating some of the common code.
* clutter/cogl/gles/cogl-defines.h.in:
* clutter/cogl/gl/cogl-defines.h.in: Removed COGLhandle
* clutter/cogl/gl/cogl-context.h: Added handle arrays for programs
and shaders.
* clutter/cogl/gl/cogl-context.c (cogl_create_context): Added
initialisers for shader_handles and program_handles.
(cogl_destroy_context): Added calls to g_array_free for all handle
arrays.
* clutter/cogl/gl/Makefile.am (libclutter_cogl_la_SOURCES): Added
cogl-{program,shader}.{c,h}
* clutter/cogl/common/Makefile.am
(libclutter_cogl_common_la_SOURCES): Added cogl-handle.h
* clutter/cogl/gles/cogl.c:
* clutter/cogl/cogl.h.in: Programs and shaders are now wrapped in
CoglHandles instead of COGLhandles. cogl_program_destroy and
cogl_shader_destroy is now replaced with cogl_program_unref and
cogl_shader_unref. cogl_program_ref and cogl_shader_ref are also
added.
* clutter/clutter-shader.c: Converted to use CoglHandles for the
programs and shaders instead of COGLhandles.
* cogl/cogl-sections.txt: Added cogl_shader_ref,
cogl_shader_unref, cogl_is_shader, cogl_program_ref,
cogl_program_unref, cogl_is_program and cogl_is_offscreen.