1
0
Fork 0
Commit graph

15 commits

Author SHA1 Message Date
Robert Bragg
3ea7816499 [cogl] Adds a debug option for disabling use of VBOs --cogl-debug=disable-vbos
For testing the VBO fallback paths it helps to be able to disable the
COGL_FEATURE_VBOS feature flag.  When VBOs aren't available Cogl should use
client side malloc()'d buffers instead.
2009-06-30 17:13:35 +01:00
Robert Bragg
845ff67301 [cogl] Improving Cogl journal to minimize driver overheads + GPU state changes
Previously the journal was always flushed at the end of
_cogl_rectangles_with_multitexture_coords, (i.e.  the end of any
cogl_rectangle* calls) but now we have broadened the potential for batching
geometry.  In ideal circumstances we will only flush once per scene.

In summary the journal works like this:

When you use any of the cogl_rectangle* APIs then nothing is emitted to the
GPU at this point, we just log one or more quads into the journal.  A
journal entry consists of the quad coordinates, an associated material
reference, and a modelview matrix.  Ideally the journal only gets flushed
once at the end of a scene, but in fact there are things to consider that
may cause unwanted flushing, including:

- modifying materials mid-scene
    This is because each quad in the journal has an associated material
    reference (i.e. not copy), so if you try and modify a material that is
    already referenced in the journal we force a flush first)

    NOTE: For now this means you should avoid using cogl_set_source_color()
	      since that currently uses a single shared material. Later we
	  should change it to use a pool of materials that is recycled
	  when the journal is flushed.

- modifying any state that isn't currently logged, such as depth, fog and
  backface culling enables.

The first thing that happens when flushing, is to upload all the vertex data
associated with the journal into a single VBO.

We then go through a process of splitting up the journal into batches that
have compatible state so they can be emitted to the GPU together.  This is
currently broken up into 3 levels so we can stagger the state changes:

1) we break the journal up according to changes in the number of material layers
   associated with logged quads. The number of layers in a material determines
   the stride of the associated vertices, so we have to update our vertex
   array offsets at this level. (i.e. calling gl{Vertex,Color},Pointer etc)
2) we further split batches up according to material compatability. (e.g.
   materials with different textures) We flush material state at this level.
3) Finally we split batches up according to modelview changes. At this level
   we update the modelview matrix and actually emit the actual draw command.

This commit is largely about putting the initial design in-place; this will be
followed by other changes that take advantage of the extended batching.
2009-06-30 17:13:34 +01:00
Robert Bragg
24ca92951f [cogl] Adds cogl_read_pixels to replace direct use of glReadPixels
To allow for flushing of batched geometry within Cogl we can't support users
directly calling glReadPixels.  glReadPixels is also awkward, not least
because it returns upside down image data.

All the unit tests have been swithed over and clutter_stage_read_pixels now
sits on top of this too.
2009-06-29 23:49:06 +01:00
Owen W. Taylor
c3448314d5 Default to a blend function that expects premultiplied colors
Many operations, like mixing two textures together or alpha-blending
onto a destination with alpha, are done most logically if texture data
is in premultiplied form. We also have many sources of premultiplied
texture data, like X pixmaps, FBOs, cairo surfaces. Rather than trying
to work with two different types of texture data, simplify things by
always premultiplying texture data before uploading to GL.

Because the default blend function is changed to accommodate this,
uses of pure-color CoglMaterial need to be adapted to add
premultiplication.

gl/cogl-texture.c gles/cogl-texture.c: Always premultiply
  non-premultiplied texture data before uploading to GL.

cogl-material.c cogl-material.h: Switch the default blend functions
  to ONE, ONE_MINUS_SRC_ALPHA so they work correctly with premultiplied
  data.

cogl.c: Make cogl_set_source_color() premultiply the color.

cogl.h.in color-material.h: Add some documentation about
  premultiplication and its interaction with color values.

cogl-pango-render.c clutter-texture.c tests/interactive/test-cogl-offscreen.c:
  Use premultiplied colors.

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

Signed-off-by: Robert Bragg <robert@linux.intel.com>
2009-06-11 14:17:52 +01:00
Emmanuele Bassi
7252c14197 [cogl] Make cogl_setup_viewport() a private function
The setup_viewport() function should only be used by Clutter and
not by application code.

It can be emulated by changing the Stage size and perspective and
requeueing a redraw after calling clutter_stage_ensure_viewport().
2009-05-28 14:14:50 +01:00
Robert Bragg
605243d952 [cogl] renamed cogl_enable_* to cogl_set_*_enabled + added getters
cogl_enable_depth_test and cogl_enable_backface_culling have been renamed
and now have corresponding getters, the new functions are:
  cogl_set_depth_test_enabled
  cogl_get_depth_test_enabled
  cogl_set_backface_culling_enabled
  cogl_get_backface_culling_enabled
2009-05-28 02:43:36 +01:00
Robert Bragg
68214fe4b8 [cogl] Remove cogl_flush_gl_state from the API
This is being removed before we release Clutter 1.0 since the implementation
wasn't complete, and so we assume no one is using this yet.  Util we have
someone with a good usecase, we can't pretend to support breaking out into
raw OpenGL.
2009-05-28 02:43:34 +01:00
Robert Bragg
f322da3794 [material] Reduce the material API in preperation for releasing Clutter 1.0
There were a number of functions intended to support creating of new
primitives using materials, but at this point they aren't used outside of
Cogl so until someone has a usecase and we can get feedback on this
API, it's being removed before we release Clutter 1.0.
2009-05-28 02:43:34 +01:00
Emmanuele Bassi
df1a9b7a74 [cogl] Rework the debug messages
COGL has a debug message system like Clutter's own. In parallel,
it also uses a coupld of #defines. Spread around there are also
calls to printf() instead to the more correct g_log* wrappers.

This commit tries to unify and clean up the macros and the
debug message handling inside COGL to be more consistent.
2009-05-19 14:44:29 +01:00
Emmanuele Bassi
3115a61688 [cogl] Rework the GL-error-to-string conversion
The code for the conversion of the GL error enumeration code
into a string is not following the code style and conventions
we follow in Clutter and COGL.

The GE() macro is also using fprintf(stderr) directly instead
of using g_warning() -- which is redirectable to an alternative
logging system using the g_log* API.
2009-05-19 13:24:56 +01:00
Robert Bragg
e80fcbc298 [cogl-clip-stack] Support pushing rectangles onto the stack using window coords
Previously clipping could only be specified in object coordinates, now
rectangles can also be pushed in window coordinates.

Internally rectangles pushed this way are intersected and then clipped using
scissoring.  We also transparently try to convert rectangles pushed in
object coordinates into window coordinates as we anticipate the scissoring
path will be faster then the clip planes and undoubtably it will be faster
than using the stencil buffer.
2009-05-12 15:44:33 +01:00
Robert Bragg
f85377372c [cogl] Updates all file headers and removes lots of trailing white space
Adds missing notices, and ensures all the notices are consistent. The Cogl
blurb also now reads:

 * Cogl
 *
 * An object oriented GL/GLES Abstraction/Utility Layer
2009-05-02 04:12:25 +01:00
Robert Bragg
741c4bb5e9 [cogl] Adds a bitfield argument to cogl_clear for specifying which buffers to clear
Redundant clearing of depth and stencil buffers every render can be very
expensive, so cogl now gives control over which auxiliary buffers are
cleared.

Note: For now clutter continues to clear the color, depth and stencil buffer
each paint.
2009-05-02 04:12:12 +01:00
Robert Bragg
e4d3b0536f [gl/cogl.c] #include <gmodule.h> for OS X builds
In unifying the {gl,gles}/cogl.c code recently, moving most of the code into
common/cogl.c the gmodule.h include was also mistakenly moved.

Thanks to Felix Rabe for reporting this issue.

Note: I haven't tested this fix myself, as I'm not set up to be able to
build for OS X
2009-04-20 14:20:37 +01:00
Robert Bragg
8a1b4f8326 Unifies 90% of the code in {gl,gles}/cogl.c in common/cogl.c
This code keeps on diverging and we get bugs and fixes in one version but
not the other. This should make things a bit more maintainable.
2009-04-01 13:19:35 +01:00