Commit Graph

950 Commits

Author SHA1 Message Date
Neil Roberts
671abec8b7 Make the material functions for setting the p wrap mode public
Now that we have 3D texture support it makes sense to expose the wrap
mode for the p coordinate.
2010-07-13 14:29:07 +01:00
Neil Roberts
ec718d4ca4 Rename the third texure coordinate from 'r' to 'p'
Using 'r' to name the third component is problematic because that is
commonly used to represent the red component of a vector representing
a color. Under GLSL this is awkward because the texture swizzling for
a vector uses a single letter for each component and the names for
colors, textures and positions are synonymous. GLSL works around this
by naming the components of the texture s, t, p and q. Cogl already
effectively already exposes this naming because it exposes GLSL so it
makes sense to use that naming consistently. Another alternative could
be u, v and w. This is what Blender and Direct3D use. However the w
component conflicts with the w component of a position vertex.
2010-07-13 14:29:07 +01:00
Neil Roberts
5288f6d88d 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.
2010-07-13 14:28:52 +01:00
Neil Roberts
159c7ed7e5 configure: Include gl2ext.h or glext.h under GLES
Under big GL, glext.h is included automatically by gl.h. However under
GLES this doesn't appear to happen so it has to be included explicitly
to get the defines for extensions. This patch changes the
clutter_gl_header to be called cogl_gl_headers and it can now take a
space seperated list of multiple headers. This is then later converted
to a list of #include lines which ends up cogl-defines.h. The gles2
and gles1 backends now add their respective ext header to this list.
2010-07-13 14:28:51 +01:00
Neil Roberts
42dcffbc3a Make a public CoglBitmapError enum
There are many places in the texture backend that need to do
conversion using the CoglBitmap code. Currently none of these
functions can throw an error but they do return a value to indicate
failure. In future it would make sense if new texture functions could
throw an error and in that case they would want to use a CoglBitmap
error if the failure was due to the conversion. This moves the
internal CoglBitmap error from the quartz backend to be public in
cogl-bitmap.h so that it can be used in this way.
2010-07-13 14:28:45 +01:00
Neil Roberts
396ef40d43 Rename COGL_ERROR_MISSING_FEATURE to COGL_ERROR_UNSUPPORTED
We can use this error in more unsupported situations than just when we
have a Cogl feature flag for the error. For example if a non-sliced
texture is created with dimensions that are too large then we could
throw this error. Therefore it seems good to rename to something more
general.
2010-07-13 14:28:36 +01:00
Neil Roberts
c3489a0a22 Move _cogl_texture_2d_is_pot to cogl-util.h
This function could be used in many places in Cogl so it makes sense
to share it in cogl-util.h as _cogl_util_is_pot().
2010-07-13 14:28:35 +01:00
Neil Roberts
ccd45fc723 cogl-gles2-wrapper: Layers aren't equal if one is enabled and one is not
Previously when comparing whether the settings for a layer are equal
it would only check if one of them was enabled. If so then it would
assume the other one was enabled and continue to compare the texture
environment. Now it also checks whether the enabledness differs.
2010-07-13 14:28:35 +01:00
Emmanuele Bassi
23a172935d Merge remote branch 'elliot/cookbook-animation-inversion'
* elliot/cookbook-animation-inversion:
  cookbook: Fixed invalid XML tag
  cookbook: Added "inverting an animation" recipe
  docs: Enabled animation section
2010-07-12 21:25:25 +01:00
Emmanuele Bassi
8dba1349c3 Merge remote branch 'elliot/cookbook-animation-intro'
* elliot/cookbook-animation-intro:
  cookbook: Added introduction for animations section
  docs: Enabled animation section
2010-07-12 21:25:22 +01:00
Emmanuele Bassi
89df91a389 Merge remote branch 'elliot/cookbook-consistency'
* elliot/cookbook-consistency:
  cookbook: Fixed typo
  cookbook: Fix build so CSS files get installed
  cookbook: Moved paragraph where it logically belongs
  cookbook: Added some judicious note elements
  cookbook: Added more information for contributors
  cookbook: Link out to docbook site
  cookbook: Made docbook element usage consistent
  cookbook: Additional selectors in CSS stylesheet
  cookbook: Copy the CSS file into the HTML build directory
2010-07-12 21:20:30 +01:00
Neil Roberts
044523db26 Add the deprecated ref-counting for cogl_program
cogl_program has always had cogl_program_ref and cogl_program_unref
but this was missed from 89cb325fd4 so they got removed.
2010-07-09 19:09:49 +01:00
Neil Roberts
2c8bf00995 Don't define public cogl_is_* functions for internal types
This adds a COGL_OBJECT_INTERNAL_DEFINE macro and friends that are the
same as COGL_OBJECT_DEFINE except that they prefix the cogl_is_*
function with an underscore so that it doesn't get exported in the
shared library.
2010-07-09 18:57:54 +01:00
Neil Roberts
9e3705ecb3 Add cogl_vertex_buffer_is_indices to the public headers
This function has always been defined in the shared library but it was
missed from the public headers.
2010-07-09 18:57:54 +01:00
Neil Roberts
b25035ad2d cogl: Don't define the deprecated ref/unref accessors for new types
Previously COGL_OBJECT_DEFINE would always define deprecated
cogl_$type_{ref,unref} functions even if the type is new or if the
type is entirely internal. An application would still find it
difficult to use these because they wouldn't be in the headers, but it
still looks bad that they are exported from the shared library. This
patch changes it so that the deprecated ref counting functions are
defined using a separate macro and only the types that have these
functions in the headers call this macro.
2010-07-09 18:57:54 +01:00
Robert Bragg
ea708094c5 material: use common node type for materials and layers
Since 365605cf42, materials and layers are represented in a tree
structure that allows traversing up through parents and iterating down
through children.  This re-works the related typedefs and reparenting
code so that they can be shared.
2010-07-09 18:04:27 +01:00
Damien Lespiau
2d20589d8e cogl-texture-pixmap-x11: This API is new in 1.4, not 1.2
CoglTexturePixmapX11 has been introduced in the 1.3 development cycle. A
Stability: Unstable tag was missing too, so add it.
2010-07-09 17:55:31 +01:00
Damien Lespiau
c0fb59702c cogl: Add Stability tag to new experimental API
Functions guarded with COGL_ENABLE_EXPERIMENTAL API should be also maked
as being Unstable with the Stability gtk-doc tag.

Fixes: http://bugzilla.clutter-project.org/show_bug.cgi?id=2175
2010-07-09 17:17:11 +01:00
Neil Roberts
bf8384baf1 Use GL_MAX_TEXTURE_SIZE on GLES when checking supported tex size
Under big GL, _cogl_texture_driver_size_supported uses the proxy
texture to check whether the given texture size is supported. Proxy
textures aren't available under GLES so previously this would just
return TRUE to assume all texture sizes are supported. This patch
makes it use glGetIntegerv with GL_MAX_TEXTURE_SIZE to give a second
best guess.

This fixes the sliced texture backend so that it will use slices when
the texture is too big.
2010-07-09 11:14:15 +01:00
Neil Roberts
0fbdafd318 Fix cogl_texture_get_data when an intermediate buffer is used
When an intermediate buffer is used for downloading texture data it
was using the wrong byte length for a row so the copy back to the
user's buffer would fail.
2010-07-09 11:14:15 +01:00
Neil Roberts
d3ea1ec6f8 Use GL_NEAREST filter in the draw-and-read get_data texture fallback
The fallback for when glGetTexImage is not available renders the
texture to the framebuffer to read the data using glReadPixels. This
patch just sets the COGL_MATERIAL_FILTER_NEAREST filter mode on the
material before rendering to avoid linear filtering which would alter
the texture data.
2010-07-09 11:14:15 +01:00
Neil Roberts
f8d1955ab7 Use cogl_read_pixels in the cogl texture draw-and-read fallback
The fallback for when glGetTexImage is not available draws parts of
the texture to the framebuffer and uses glReadPixels to extract the
data. However it was using cogl_rectangle to draw and then immediately
using raw glReadPixels to fetch the data. This won't cause a journal
flush so the rectangle won't necessarily have hit the framebuffer
yet. Instead it now uses cogl_read_pixels which does flush the
journal.
2010-07-09 11:14:15 +01:00
Neil Roberts
475a72fd94 cogl-material: Fix some problems with flushing texture overrides
There were a few problems flushing texture overrides so that sliced
textures would not work:

* In _cogl_material_set_layer_texture it ignored the 'overriden'
  parameter and always set texture_overridden to FALSE.

* cogl_texture_get_gl_texture wasn't being called correctly in
  override_layer_texture_cb. It returns a gboolean to indicate the
  error status but this boolean was being assigned to gl_target.

* _cogl_material_layer_texture_equal did not take into account the
  override.

* _cogl_material_layer_get_texture_info did not return the overridden
  texture so it would always use the first texture slice.
2010-07-09 11:14:15 +01:00
Neil Roberts
61cbeeacfa cogl-texture: Share the common code in the set_region virtual
There was a lot of common code that was copied to all of the backends
to convert the data to a suitable format and wrap it into a CoglBitmap
so that it can be passed to _cogl_texture_driver_upload_subregion_to_gl.
This patch moves the common code to cogl-texture.c so that the virtual
just takes a CoglBitmap that is already in the right format.
2010-07-09 11:14:14 +01:00
Neil Roberts
223317c500 cogl-texture: Share the common code in the get_data virtual
Previously cogl_texture_get_data would pretty much directly pass on to
the get_data texture virtual function. This ended up with a lot of
common code that was copied to all of the backends. For example, the
method is expected to return the required data size if the data
pointer is NULL and to calculate its own rowstride if the rowstride is
0. Also it needs to convert the downloaded data if GL can't support
that format directly.

This patch moves the common code to cogl-texture.c so the virtual is
always called with a format that can be downloaded directly by GL and
with a valid rowstride. If the download fails then the virtual can
return FALSE in which case cogl-texture will use the draw and read
fallback.
2010-07-09 11:00:48 +01:00
Neil Roberts
0e49e4f204 cogl-vertex-buffer: Default to GL_CLAMP_TO_EDGE for point sprites
For point sprites you are usually drawing the whole texture so you
most often want GL_CLAMP_TO_EDGE. This patch removes the override for
COGL_MATERIAL_WRAP_MODE_AUTOMATIC when point sprites are enabled for a
layer so that it will clamp to edge.
2010-07-08 16:34:31 +01:00
Neil Roberts
da3be3df6b cogl-material: Add support for point sprites
This adds a new API call to enable point sprite coordinate generation
for a material layer:

void
cogl_material_set_layer_point_sprite_coords_enabled (CoglHandle material,
                                                     int layer_index,
                                                     gboolean enable);

There is also a corresponding get function.

Enabling point sprite coords simply sets the GL_COORD_REPLACE of the
GL_POINT_SPRITE glTexEnv when flusing the material. There is no
separate application control for glEnable(GL_POINT_SPRITE). Instead it
is left permanently enabled under the assumption that it has no affect
unless GL_COORD_REPLACE is enabled for a texture unit.

http://bugzilla.openedhand.com/show_bug.cgi?id=2047
2010-07-08 16:34:30 +01:00
Neil Roberts
06b58baa10 cogl-material: Add a property for setting the point size
This adds cogl_material_{get,set}_point_size. If the point size is not
1.0f then glPointSize will be called when the material is flushed.

http://bugzilla.openedhand.com/show_bug.cgi?id=2047
2010-07-08 16:34:30 +01:00
Robert Bragg
dcc8c66fdd material: support dumping layer state graph to dot file
Recently I added a _cogl_debug_dump_materials_dot_file function for
debugging the sparse material state. This extends the state dumped to
include the graph of layer state also.
2010-07-07 20:46:50 +01:00
Robert Bragg
093251776f material: set ->layer_index on new layers for unit0
We were mistakenly only initializing layer->layer_index for new layers
associated with texture units > 0. This had gone unnoticed because
normally layers associated with texture unit0 have a layer index of 0
too. Mutter was hitting this issue because it was initializing layer 1
before layer 0 for one of its materials so layer 1 was temporarily
associated with texture unit 0.
2010-07-07 20:46:04 +01:00
Emmanuele Bassi
added497f4 Merge branch 'cally-merge'
* cally-merge:
  cally: Add introspection generation
  cally: Improving cally doc
  cally: Cleaning CallyText
  cally: Refactoring "window:create" and "window:destroy" emission code
  cally: Use proper backend information on CallyActor
  cally: Check HAVE_CONFIG_H on cally-util.c
  docs: Fix Cally documentation
  cally: Clean up the headers
  Add binaries of the Cally examples to the ignore file
  docs: Add Cally API reference
  Avoid to load cally module on a11y examples
  Add accessibility tests
  Initialize accessibility support on clutter_init
  Rename some methods and includes to avoid -Wshadow warnings
  Cally initialization code
  Add Cally
2010-07-07 16:06:30 +01:00
Emmanuele Bassi
0eb9fc04f5 cally: Add introspection generation
Toolkits and applications not written in C might still need access to
the Cally API to write accessibility extensions based on it for their
own native elements.
2010-07-07 15:57:43 +01:00
Robert Bragg
0c3354acba framebuffer: Replace CoglHandle with CoglFramebuffer *
One more object converted to stop using CoglHandle re:a8c8cbee513
2010-07-07 14:41:54 +01:00
Robert Bragg
8098052d56 material: route fogging state through CoglMaterial
Previously cogl_set_fog would cause a flush of the Cogl journal and
would directly bang the GL state machine to setup fogging. As part of
the ongoing effort to track most state in CoglMaterial to support
renderlists this now adds an indirection so that cogl_set_fog now just
updates ctx->legacy_fog_state. The fogging state then gets enabled as a
legacy override similar to how the old depth testing API is handled.
2010-07-07 14:12:15 +01:00
Robert Bragg
a17dfcf1c2 cogl-buffer: Move malloc fallback logic into CoglBuffer
Since we'll want to share the fallback logic with CoglVertexArray this
moves the malloc based fallback (for when OpenGL doesn't support vertex
or pixel buffer objects) into cogl-buffer.c.
2010-07-07 14:08:11 +01:00
Robert Bragg
f8d58446a8 cogl-buffer: consider it an error to free a mapped buffer
Explicitly warn if we detect that a CoglBuffer is being freed while it
is still mapped. Previously we silently unmapped the buffer, but it's
not something we want to encourage.
2010-07-07 14:08:11 +01:00
Robert Bragg
e98ee6665b cogl-buffer: Track the last used bind target in CoglBuffer
This makes CoglBuffer track the last used bind target as a private
property. This is later used when binding a buffer to map instead of
always using the PIXEL_UNPACK target.

This also adds some additional sanity checks that code doesn't try to
nest binds to the same target or bind a buffer to multiple targets at
the same time.
2010-07-07 14:08:11 +01:00
Robert Bragg
7571cc1923 cogl: expose the semantic differences of gl/gles2 npot textures
This adds three new feature flags COGL_FEATURE_TEXTURE_NPOT_BASIC,
COGL_FEATURE_TEXTURE_NPOT_MIPMAP and COGL_FEATURE_TEXTURE_NPOT_REPEAT
that can tell you if your hardware supports non power of two textures,
npot textures + mipmaps and npot textures + wrap modes other than
CLAMP_TO_EDGE.

The pre-existing COGL_FEATURE_TEXTURE_NPOT feature implies all of the
above.

By default GLES 2 core supports npot textures but mipmaps and repeat
modes can only be used with power of two textures. This patch also makes
GLES check for the GL_OES_texture_npot extension to determine if mipmaps
and repeating are supported with npot textures.
2010-07-07 13:26:41 +01:00
Neil Roberts
c243086f44 cogl-vertex-buffer: Fix the #define for glDisableVertexAttribArray
glDisableVertexAttribArray was defined to glEnableVertexAttribArray so
it would probably cause crashes if it was ever used. Presumably
nothing is using these yet because the generic attributes are not yet
tied to shader attributes in a predictable way.
2010-07-06 16:08:44 +01:00
Alexandros Frantzis
bf56e798c6 build: Exclude built sources from the dist
http://bugzilla.clutter-project.org/show_bug.cgi?id=2169

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2010-07-06 13:24:00 +01:00
Robert Bragg
3b4b5ba01c debug: Adds a COGL_DEBUG=disable-pbos debug option
For testing purposes, either to identify bugs in Cogl or the driver or
simulate lack of PBO support COGL_DEBUG=disable-pbos can be used to
fallback to malloc instead.
2010-07-06 12:09:01 +01:00
Robert Bragg
72e1ff05a8 pango-render: set CLAMP_TO_EDGE wrap mode on glyph_material
The pango renderer was causing lots of override materials to be allocated
because the vertex_buffer API converts AUTOMATIC mode into REPEAT for
backwards compatibility. By explicitly setting the wrap mode to
CLAMP_TO_EDGE when creating the glyph_material then the vertex_buffer
API will leave it untouched.
2010-07-06 12:07:29 +01:00
Robert Bragg
92d0322766 pixel-array: Allow passing of hints to cogl_buffer_map
This allows you to tell Cogl that you are planning to replace all the
buffer's data once it is mapped with cogl_buffer_map. This means if the
buffer is currently being accessed by the GPU then the driver doesn't
have to stall and wait for it to finish before it can access it from the
CPU and can instead potentially allocate a new buffer with undefined
data and map that.
2010-07-06 12:07:28 +01:00
Robert Bragg
51e4245ce1 cogl-object: cogl_is_XYZ prototype should take void *
This changes the cogl_is_XYZ function prototypes generated when using
the COGL_OBJECT_DEFINE macro to take a void * argument instead of a
CoglHandle argument.
2010-07-05 15:47:02 +01:00
Robert Bragg
9e25f8c40d pixel-array: Only allow allocation of arrays with a 2D size
This removes cogl_pixel_array_new which just took a size in bytes.

Without the image size and pixel format then the driver often doesn't
have enough information to allocate optimal GPU memory that can be
textured from directly. This is because GPUs often have ways to
spatially alter the layout of a texture to improve cache access patterns
which may require special alignment and padding dependant in the images
width, height and bpp.

Although currently we are limited by OpenGL because it doesn't let us
pass on the width and height when allocating a PBO, the hope is that we
can define a better extension at some point.
2010-07-05 15:20:04 +01:00
Robert Bragg
daa34aeb0e pixel-array: rename new_from_size to new_with_size
It is more in keeping with other coding conventions in Cogl to use new
"with" size instead of new "from" size.
2010-07-05 15:20:04 +01:00
Robert Bragg
a46cc22c1b cogl-buffer-private.h: cleanup up the coding style
This file was following the Clutter coding style of arranging prototypes
into columns which Cogl doesn't copy.
2010-07-05 15:20:04 +01:00
Robert Bragg
521d9ca203 rename CoglPixelBuffer to CoglPixelArray
This renames CoglPixelBuffer to CoglPixelArray to be consistent with the
new CoglVertexArray API.
2010-07-05 15:20:04 +01:00
Robert Bragg
cafeb02531 cogl-buffer: make the COGL_BUFFER_USAGE_HINT private
The usage hint should be implied by the CoglBuffer subclass type so the
public getter and setter APIs for manually changing the usage hint of a
CoglBuffer have now been removed.
2010-07-05 15:20:04 +01:00
Robert Bragg
9ceb0edf26 cogl-buffer: Handle subclass registration like cogl-texture
Instead of having to extend cogl_is_buffer with new buffer types
manually this now adds a new COGL_BUFFER_DEFINE macro to be used instead
of COGL_OBJECT_DEFINE for CoglBuffer subclasses. This macro will
automatically register the new type with ctx->buffer_types which will
iterated by cogl_is_buffer. This is the same coding pattern used for
CoglTexture.
2010-07-05 15:20:03 +01:00