diff options
author | Neil Roberts <neil@linux.intel.com> | 2010-07-01 22:04:59 +0100 |
---|---|---|
committer | Neil Roberts <neil@linux.intel.com> | 2010-07-13 14:28:52 +0100 |
commit | 5288f6d88d94988875d69d8a850053f66319d042 (patch) | |
tree | 0f02eb45671007b729c61b585ba2fb1a88c60618 /cogl/cogl-texture-driver.h | |
parent | 159c7ed7e55dadd203dc15762951e6769ae1b02f (diff) | |
download | cogl-5288f6d88d94988875d69d8a850053f66319d042.tar.gz |
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.
Diffstat (limited to 'cogl/cogl-texture-driver.h')
-rw-r--r-- | cogl/cogl-texture-driver.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/cogl/cogl-texture-driver.h b/cogl/cogl-texture-driver.h index 725629b2..bc1ca63b 100644 --- a/cogl/cogl-texture-driver.h +++ b/cogl/cogl-texture-driver.h @@ -88,6 +88,24 @@ _cogl_texture_driver_upload_to_gl (GLenum gl_target, GLuint source_gl_type); /* + * Replaces the contents of the GL texture with the entire bitmap. The + * width of the texture is inferred from the bitmap. The height and + * depth of the texture is given directly. The 'image_height' (which + * is the number of rows between images) is inferred by dividing the + * height of the bitmap by the depth. + */ +void +_cogl_texture_driver_upload_to_gl_3d (GLenum gl_target, + GLuint gl_handle, + gboolean is_foreign, + GLint height, + GLint depth, + CoglBitmap *source_bmp, + GLint internal_gl_format, + GLuint source_gl_format, + GLuint source_gl_type); + +/* * This sets up the glPixelStore state for an download to a destination with * the same size, and with no offset. */ @@ -131,6 +149,14 @@ _cogl_texture_driver_size_supported (GLenum gl_target, int width, int height); +gboolean +_cogl_texture_driver_size_supported_3d (GLenum gl_target, + GLenum gl_format, + GLenum gl_type, + int width, + int height, + int depth); + /* * This driver abstraction is needed because GLES doesn't support setting * a texture border color. |