Add a Cogl texture 3D backend
authorNeil Roberts <neil@linux.intel.com>
Thu, 1 Jul 2010 21:04:59 +0000 (22:04 +0100)
committerNeil Roberts <neil@linux.intel.com>
Tue, 13 Jul 2010 13:28:52 +0000 (14:28 +0100)
commitdfea57b45ab4636b3484c0c1eed615da0f97f112
tree508461941b40499f1f1bbbaa022091174590962f
parent8ccf8f6f08623492ca2b5af93d3384878e53d912
Add a Cogl texture 3D backend

This adds a publicly exposed experimental API for a 3D texture
backend. There is a feature flag which can be checked for whether 3D
textures are supported. Although we require OpenGL 1.2 which has 3D
textures in core, GLES only provides them through an extension so the
feature can be used to detect that.

The textures can be created with one of two new API functions :-

cogl_texture_3d_new_with_size

 and

cogl_texture_3d_new_from_data

There is also internally a new_from_bitmap function. new_from_data is
implemented in terms of this function.

The two constructors are effectively the only way to upload data to a
3D texture. It does not work to call glTexImage2D with the
GL_TEXTURE_3D target so the virtual for cogl_texture_set_region does
nothing. It would be possible to make cogl_texture_get_data do
something sensible like returning all of the images as a single long
image but this is not currently implemented and instead the virtual
just always fails. We may want to add API specific to the 3D texture
backend to get and set a sub region of the texture.

All of those three functions can throw a GError. This will happen if
the GPU does not support 3D textures or it does not support NPOTs and
an NPOT size is requested. It will also fail if the FBO extension is
not supported and the COGL_TEXTURE_NO_AUTO_MIPMAP flag is not
given. This could be avoided by copying the code for the
GL_GENERATE_MIPMAP TexParameter fallback, but in the interests of
keeping the code simple this is not yet done.

This adds a couple of functions to cogl-texture-driver for uploading
3D data and querying the 3D proxy
texture. prep_gl_for_pixels_upload_full now also takes sets the
GL_UNPACK_IMAGE_HEIGHT parameter so that 3D textures can have padding
between the images. Whenever 3D texture is uploading, both the height
of the images and the height of all of the data is specified (either
explicitly or implicilty from the CoglBitmap) so that the image height
can be deduced by dividing by the depth.
16 files changed:
clutter/cogl/cogl/Makefile.am
clutter/cogl/cogl/cogl-material-arbfp.c
clutter/cogl/cogl/cogl-texture-3d-private.h [new file with mode: 0644]
clutter/cogl/cogl/cogl-texture-3d.c [new file with mode: 0644]
clutter/cogl/cogl/cogl-texture-3d.h [new file with mode: 0644]
clutter/cogl/cogl/cogl-texture-driver.h
clutter/cogl/cogl/cogl-types.h
clutter/cogl/cogl/cogl.h
clutter/cogl/cogl/driver/gl/cogl-feature-functions.h
clutter/cogl/cogl/driver/gl/cogl-texture-driver.c
clutter/cogl/cogl/driver/gles/cogl-feature-functions.h
clutter/cogl/cogl/driver/gles/cogl-gles2-wrapper.c
clutter/cogl/cogl/driver/gles/cogl-gles2-wrapper.h
clutter/cogl/cogl/driver/gles/cogl-texture-driver.c
doc/reference/cogl/cogl-docs.xml.in
doc/reference/cogl/cogl-sections.txt