Commit Graph

547 Commits

Author SHA1 Message Date
Neil Roberts
070a91f311 cogl: Make the callback for foreach_sub_texture_in_region use const
The CoglTextureSliceCallback function pointer now takes const pointers
for the texture coordinates. This makes it clearer that the callback
should not modify the array and therefore the backend can use the same
array for both sets of coords.
2009-12-02 22:03:08 +00:00
Neil Roberts
1a1de0e278 cogl: Add a texture utility function for manually repeating
Given a region of texture coordinates this utility invokes a callback
enough times to cover the region with a subregion that spans the
texture at most once. Eg, if called with tx1 and tx2 as 0.5 and 3.0 it
it would invoke the callback with:

0.5,1.0  1.0,2.0  2.0,3.0

Manual repeating is needed by all texture backends regardless of
whether they can support hardware repeating because when Cogl calls
the foreach_sub_texture_in_region method then it sets the wrap mode to
GL_CLAMP_TO_EDGE and no hardware repeating is possible.
2009-12-02 22:03:08 +00:00
Neil Roberts
5fcb29c916 cogl-primitives: Check for repeating after the coordinate transform
In _cogl_multitexture_quad_single_primitive we use a wrap mode of
GL_CLAMP_TO_EDGE if the texture coordinates are all in the range [0,1]
or GL_REPEAT otherwise. This is to avoid pulling in pixels from either
side when using GL_LINEAR filter mode and rendering the entire
texture. Previously it was checking using the unconverted texture
coordinates. This is ok unless the texture backend is radically
transforming the texture coordinates, such as in the sub texture
backend where the coordinates may map to something completely
different. We now check whether the coordinates are in range after
converting them.
2009-12-02 22:03:07 +00:00
Neil Roberts
812d4d25bb cogl: Move all of the fields from CoglTexture to CoglTexture2DSliced
Most of the fields that were previously in CoglTexture are specific to
the implementation of CoglTexture2DSliced so they should be placed
there instead. For example, the 'mipmaps_dirty' flag is an
implementation detail of the ensure_mipmaps function so it doesn't
make sense to force all texture backends to have this function.

Other fields such as width, height, gl_format and format may make
sense for all textures but I've added them as virtual functions
instead. This may make more sense for a sub-texture backend for
example where it can calculate these based on the full texture.
2009-12-02 22:03:07 +00:00
Neil Roberts
071dea2fbc cogl: Move data only used for upload out of CoglTexture
The CoglTexture struct previously contained some fields which are only
used to upload data such as the CoglBitmap and the source GL
format. These are now moved to a separate CoglTextureUploadData struct
which only exists for the duration of one of the cogl_texture_*_new
functions. In cogl-texture there are utility functions which operate
on this new struct rather than on CoglTexture directly.

Some of the fields that were previously stored in the CoglBitmap
struct are now copied to the CoglTexture such as the width, height,
format and internal GL format.

The rowstride was previously stored in CoglTexture and this was
publicly accessible with the cogl_texture_get_rowstride
function. However this doesn't seem to be a useful function because
there is no need to use the same rowstride again when uploading or
downloading new data. Instead cogl_texture_get_rowstride now just
calculates a suitable rowstride from the format and width of the
texture.
2009-12-02 22:03:07 +00:00
Neil Roberts
7f58c14dcd cogl: Use #ifdef GL around GL_TEXTURE_RECTANGLE_ARB
Commit 558b17ee1e added support for rectangle textures to the
framebuffer code. Under GLES there is no GL_TEXTURE_RECTANGLE_ARB
definition so this was breaking the build. The rest of Cogl uses
ifdef's around that constant so we should do the same here.
2009-12-02 21:59:58 +00:00
Emmanuele Bassi
7a33b706a4 Remove a gtk-doc annotation
The Mesa matrix code still has a comment that looks like a gtk-doc
annotation.
2009-12-02 11:37:13 +00:00
Neil Roberts
1bb034fbd7 cogl: Enable blending if a lighting colour is semi-transparent
We currently enable blending if the material colour has
transparency. This patch makes it also enable blending if any of the
lighting colours have transparency. Arguably this isn't neccessary
because we don't expose any API to enable lighting so there is no
bug. However it is currently possible to enable lighting with a direct
call to glEnable and this otherwise works so it is a shame not to have
it.

http://bugzilla.openedhand.com/show_bug.cgi?id=1907
2009-11-30 19:08:38 +00:00
Robert Bragg
934eb5d251 primitives: Don't use dynamic arrays since VS2008 can't cope with them :-(
This changes _cogl_path_fill_nodes_scanlines to use g_alloca instead of
using a variable to declare an array length.
2009-11-27 15:24:09 +00:00
Robert Bragg
439f8c62b0 cogl: deprecate cogl_draw_buffer API and replace with a cogl_framebuffer API
cogl_push_draw_buffer, cogl_set_draw_buffer and cogl_pop_draw_buffer are now
deprecated and new code should use the new cogl_framebuffer_* API instead.

Code that previously did:
    cogl_push_draw_buffer ();
    cogl_set_draw_buffer (COGL_OFFSCREEN_BUFFER, buffer);
    /* draw */
    cogl_pop_draw_buffer ();
should now be re-written as:
    cogl_push_framebuffer (buffer);
    /* draw */
    cogl_pop_framebuffer ();

As can be seen from the example above the rename has been used as an
opportunity to remove the redundant target argument from
cogl_set_draw_buffer; it now only takes one call to redirect to an offscreen
buffer, and finally the term framebuffer may be a bit more familiar to
anyone coming from an OpenGL background.
2009-11-26 19:33:14 +00:00
Robert Bragg
b598210e01 cogl_offscreen: deprecate cogl_offscreen_ref/unref.
New code should use cogl_handle_ref/unref
2009-11-26 19:33:13 +00:00
Neil Roberts
e12a691187 cogl: Use a vtable for the texture backends instead of a type and switch
Instead of storing an enum with the backend type for each texture and
then using a switch statement to decide which function to call, we
should store pointers to all of the functions in a struct and have
each texture point to that struct. This is potentially slightly faster
when there are more backends and it makes implementing new backends
easier because it's more obvious which functions have to be
implemented.
2009-11-25 13:47:28 +00:00
Robert Bragg
558b17ee1e offscreen: cogl_offscreen_new_to_texture now supports GL_TEXTURE_RECTANGLE_ARB
cogl_offscreen_new_to_texture previously bailed out if the given texture's
GL target was anything but GL_TEXTURE_2D, but it now also allows
foreign GL_TEXTURE_RECTANGLE_ARB textures.

Thanks to Owen for reporting this issue, ref:
https://bugzilla.gnome.org/show_bug.cgi?id=601032
2009-11-25 02:56:25 +00:00
Robert Bragg
d3a01e0c96 debug: remove the COGL_DEBUG=client-side-matrices option
Cogl only supports client side matrices so this debug option is no longer
useful.
2009-11-25 02:55:56 +00:00
Robert Bragg
b38c6b420f [cogl-material] Adds cogl_material_copy() API
cogl_material_copy can be used to create a new CoglHandle referencing a copy
of some given material.

From now on we will advise that developers always aim to use this function
instead of cogl_material_new() when creating a material that is in any way
derived from another.

By using cogl_material_copy, Cogl can maintain an ancestry for each material
and keep track of "similar" materials.  The plan is that Cogl will use this
information to minimize the cost of GPU state transitions.
2009-11-24 17:58:22 +00:00
Robert Bragg
70ca3bfe41 [cogl] remove unused gles/cogl-utils.[c,h]
The only function in gles/cogl-utils.c was cogl_util_next_p2() and it's
redundant since we also have a cogl/cogl-utils.[c,h]
2009-11-24 17:58:22 +00:00
Robert Bragg
4a63af0c63 docs: Don't document cogl_flush_gl_state as public API
This function was #if 0'd before we released Clutter 1.0 so there's no
implementation of it.  At some point we thought it might assist with
developers breaking out into raw OpenGL.  Breaking out to raw GL is a
difficult problem though so we decided instead we will wait for a specific
use case to arrise before trying to support it.
2009-11-24 17:58:22 +00:00
Neil Roberts
1107fa8797 Minor fix to cogl material
_cogl_material_get_layer expects a CoglMaterial* pointer but it was
being called with a CoglHandle. This doesn't matter because the
CoglHandle is actually just the CoglMaterial* pointer anyway but it
breaks the ability to change the _cogl_material_pointer_from_handle
macro.
2009-11-23 18:36:59 +00:00
Emmanuele Bassi
8d64c4641d docs: Increase consistency in Cogl documentation 2009-11-19 14:19:59 +00:00
Emmanuele Bassi
550c14449e docs: Documentation fixes for CoglMatrix
Clean up the references, the docbook tags, and the style to fit in
with the rest of the API references for Cogl and Clutter.
2009-11-19 13:56:47 +00:00
Emmanuele Bassi
056cfcffc3 Whitespace fix for cogl-color.h 2009-11-19 13:56:47 +00:00
Emmanuele Bassi
851d628cf8 docs: Documentation fixes for CoglMaterial
Clean up the references, the docbook tags, and the style to fit in
with the rest of the API references for Cogl and Clutter.
2009-11-19 13:56:47 +00:00
Emmanuele Bassi
fe804f1d02 docs: Documentation fixes for CoglBitmap
• Use the same style for the Cogl API reference as the one used for
  the Clutter API reference.

• Fix the introspection annotations for cogl_bitmap_get_size_from_file()
2009-11-19 13:56:47 +00:00
Emmanuele Bassi
05a5a7e759 docs: Remove non-gtk-doc annotations
The imported Mesa matrix code has some documentation annotations
that make gtk-doc very angry. Since it's all private anyway we
can safely make gtk-doc ignore the offending stuff.
2009-11-19 13:55:46 +00:00
Neil Roberts
7a011af974 docs: Fix the 'Since' annotation for some functions
The 'Since' annotation needs to have a colon after it or gtk-doc won't
pick it up.
2009-11-19 11:51:21 +00:00
Neil Roberts
8ef57898ad cogl: Use APIENTRY for GL function pointer declarations
This matters for platforms such as Windows that use a different
calling covention from the default for GL functions.
2009-11-18 19:24:09 +00:00
Neil Roberts
be58e5261f build: Fix out-of-tree builds for cogl-defines.h
$(COGL_DRIVER)/cogl-defines.h is generated in the configure script so
it ends up in the build directory. Therefore the build rule for
cogl/cogl-defines.h should depend on the file in $(builddir) not
$(srcdir).
2009-11-18 19:24:09 +00:00
Emmanuele Bassi
19e485325f docs: Clean up deprecation notices
The deprecation notices in gtk-doc should also refer to the
release that added the deprecation, and if the deprecated
symbol has been replaced by something else then the new symbol
should be correctly referenced.
2009-11-18 18:04:13 +00:00
Emmanuele Bassi
5f28c8b654 build: Make cogl.h not conditional on driver defines
The main COGL header cogl.h is currently created at configure time
because it conditionally includes the driver-dependent defines. This
sometimes leads to a stale cogl.h with old definitions which can
break the build until you clean out the whole tree and start from
scratch.

We can generate a stable cogl-defines.h at build time from the
equivalent driver-dependent header and let cogl.h include that
file instead.
2009-11-18 17:49:21 +00:00
Emmanuele Bassi
60fae6a92e build: Add cogl-matrix-private.h to the dist 2009-11-18 14:43:46 +00:00
Emmanuele Bassi
425f3b4660 build: Add cogl-feature-functions.h to the dist 2009-11-18 14:43:46 +00:00
Neil Roberts
142305b1d5 cogl: Add the missing terminators for the arrays of feature functions
_cogl_feature_check expects the array of function names to be
terminated with a NULL pointer but I forgot to add this. This was
causing crashes depending on what happened to be in memory after the
array.
2009-11-18 13:23:10 +00:00
Neil Roberts
2832940603 cogl: Use the GL_EXT_blend_{func,equation}_separate extensions
We should use these extensions to check for glBlendFuncSeparate and
glBlendEquationSeparate as well as checking the GL version number.
2009-11-17 18:06:31 +00:00
Neil Roberts
6e0877507e cogl: Don't bother checking for NPOTs or VBOs on later GLs
For VBOs, we don't need to check for the extension if the GL version
is greater than 1.5. Non-power-of-two textures are given in 2.0.

We could also assume shader support in GL 2.0 except that the function
names are different from those in the extension so it wouldn't work
well with the current mechanism.
2009-11-17 17:22:22 +00:00
Neil Roberts
91cde78a70 cogl: Make it easier to add checks for GL extensions
Previously if you need to depend on a new GL feature you had to:

- Add typedefs for all of the functions in cogl-defines.h.in

- Add function pointers for each of the functions in
  cogl-context-driver.h

- Add an initializer for the function pointers in
  cogl-context-driver.c

- Add a check for the extension and all of the functions in
  cogl_features_init. If the extension is available under multiple
  names then you have to duplicate the checks.

This is quite tedious and error prone. This patch moves all of the
features and their functions into a list of macro invocations in
cogl-feature-functions.h. The macros can be redefined to implement all
of the above tasks from the same header.

The features are described in a struct with a pointer to a table of
functions. A new function takes the feature description from this
struct and checks for its availability. The feature can take a list of
extension names with a list of alternate namespaces (such as "EXT" or
"ARB"). It can also detect the feature from a particular version of
GL.

The typedefs are now gone and instead the function pointer in the Cogl
context just directly contains the type.

Some of the functions in the context were previously declared with the
'ARB' extension. This has been removed so that now all the functions
have no suffix. This makes more sense when the extension could
potentially be merged into GL core as well.
2009-11-17 15:11:26 +00:00
Neil Roberts
62a37d8e53 Use the GL_ARB_multitexture extension on GL 1.2
Cogl requires multi-texturing support. This is only available as an
extension in GL 1.2 so we should check for it before accepting the
driver.

http://bugzilla.openedhand.com/show_bug.cgi?id=1875
2009-11-13 15:56:01 +00:00
Neil Roberts
2e99b276a4 cogl-material: Fallback to BlendFunc if BlendFuncSeparate is unavailable
glBlendFuncSeparate is only available in OpenGL 1.4. If we
conditionally check for this then Clutter will work with OpenGL 1.2.

http://bugzilla.openedhand.com/show_bug.cgi?id=1875
2009-11-13 15:55:55 +00:00
Neil Roberts
568c29ba49 Validate that the GL version is >= 1.2
There is a new internal Cogl function called _cogl_check_driver_valid
which looks at the value of the GL_VERSION string to determine whether
the driver is supported. Clutter now calls this after the stage is
realized. If it fails then the stage is marked as unrealized and a
warning is shown.

_cogl_features_init now also checks the version number before getting
the function pointers for glBlendFuncSeparate and
glBlendEquationSeparate. It is not safe to just check for the presence
of the functions because some drivers may define the function without
fully implementing the spec.

The GLES version of _cogl_check_driver_valid just always returns TRUE
because there are no version requirements yet.

Eventually the function could also check for mandatory extensions if
there were any.

http://bugzilla.openedhand.com/show_bug.cgi?id=1875
2009-11-13 15:55:48 +00:00
Neil Roberts
dab1da20ae [cogl-primitives] Don't clear the whole stencil buffer
When _cogl_add_path_to_stencil_buffer is used to draw a path we don't
need to clear the entire stencil buffer. Instead it can clear just the
bounding box of the path. This adds an extra parameter called
'need_clear' which is only set if the stencil buffer is being used for
clipping.

http://bugzilla.openedhand.com/show_bug.cgi?id=1829
2009-11-13 10:51:47 +00:00
Neil Roberts
bc8faf52f4 Remove _cogl_flush_matrix_stacks from cogl-internal.h
The definition for this function was removed in f7d64e5abvoid so it
should be removed from the header too.
2009-11-12 17:01:44 +00:00
Emmanuele Bassi
9fa562ad21 cogl: Declare cogl_is_bitmap()
The function is automatically defined by the CoglHandle type
definition macro, but it still requires to be declared in the
header file to be used.
2009-11-11 10:32:39 +00:00
Neil Roberts
1ce25ffbb2 cogl: Add an initialiser for enable_flags in cogl_begin_gl
This fixes a warning about an uninitialised value. It could also
potentially fix some crashes for example if the enable_flags value
happened to include a bit for enabling a vertex array if no vertex
buffer pointer was set.
2009-11-09 11:50:16 +00:00
Emmanuele Bassi
7e17822cfd Clean up cogl.h template
The inclusion order is mostly random, and it should really be
in alphabetic order, just like clutter.h.

Also, cogl-vertex-buffer.h is included twice.
2009-11-06 15:06:39 +00:00
Tim Horton
fcd8237ac5 osx: CGBitmapContextCreate can't make 24bpp, alphaless offscreen pixmaps
While loading a JPEG from disk (with clutter_texture_new_from_file),
I got the following:

<Error>: CGBitmapContextCreate: unsupported parameter combination: 8
integer bits/component; 24 bits/pixel; 3-component colorspace;
kCGImageAlphaNone; 3072 bytes/row.
<Error>: CGContextDrawImage: invalid context

Looking around, I found that CGBitmapContextCreate can't make 24bpp
offscreen pixmaps without an alpha channel...

This fixes the bug, and seems to not break other things...

http://bugzilla.openedhand.com/show_bug.cgi?id=1159

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-11-06 14:10:41 +00:00
Emmanuele Bassi
30bc36082e Do not pass flags to g_module_open(NULL)
The flags are ignored when opening the main module, so we
should pass 0 to avoid confusion when reading the source.
2009-11-06 14:06:18 +00:00
Robert Bragg
c1d9e09d38 [clip-stack] stop using deprecated cogl_clip_push_window_rect API
try_pushing_rect_as_window_rect now uses the new
cogl_clip_push_window_rectangle API.
2009-11-05 21:10:17 +00:00
Robert Bragg
272e227109 [cogl-clip] deprecate parts and cleanup the API
cogl_clip_push() which accepts a rectangle in model space shouldn't have
been defined to take x,y,width,height arguments because this isn't consistant
with other Cogl API dealing with model space rectangles.  If you are using a
coordinate system with the origin at the center and the y+ extending up,
then x,y,width,height isn't as natural as (x0,y0)(x1,y1). This API has
now been replace with cogl_clip_push_rectangle()

(As a general note: the Cogl API should only use the x,y,width,height style
when the appropriate coordinate space is defined by Cogl to have a top left
origin.  E.g.  window coordinates, or potentially texture coordinates)

cogl_clip_push_window_rect() shouldn't have been defined to take float
arguments since we only clip with integral pixel precision. We also
shouldn't have abbreviated "rectangle". This API has been replaced with
cogl_clip_push_window_rectangle()

cogl_clip_ensure() wasn't documented at all in Clutter 1.0 and probably
no one even knew it existed. This API isn't useful, and so it's now
deprecated. If no one complains we may remove the API altogether for
Clutter 1.2.

cogl_clip_stack_save() and cogl_clip_stack_restore() were originally added
to allow us to save/restore the clip when switching to/from offscreen
rendering.  Now that offscreen draw buffers are defined to own their clip
state and the state will be automatically saved and restored this API is now
redundant and so deprecated.
2009-11-05 21:10:17 +00:00
Robert Bragg
6cd49fdd40 [clip-stack] Internally track model space clip rects as (x0,y0)(x1,y1) pairs
Don't track the rectangles as x0,y0,width,height. This is in preparation
for some API tidy up.
2009-11-05 21:10:17 +00:00
Robert Bragg
7752ed98f1 [clip-stack] move lots of supporting code from cogl.c to cogl-clip-stack.c
There was quite a bit of code in cogl.c that was only used to support
cogl-clip-stack.c, so this has now been moved to cogl-clip-stack.c
2009-11-05 21:10:16 +00:00
Robert Bragg
864e12df05 [debug] Adds a COGL_DEBUG=force-scanline-paths
For a long time now the GLES driver for Cogl has supported a fallback
scanline rasterizer for filling paths when no stencil buffer is available,
but now that we build the same cogl-primitives code for GL and GLES I
thought it may sometimes be useful for debugging to force Cogl to use the
scanline rasterizer instead of the current stencil buffer approach.
2009-11-05 21:10:16 +00:00