Commit Graph

46 Commits

Author SHA1 Message Date
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
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
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
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
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
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
Neil Roberts
6ad668c76b cogl-texture: Avoid premult conversion if the dst format has no alpha
The _cogl_texture_needs_premult_conversion function was already
checking whether the source format had an alpha channel before
returning TRUE, but it also doesn't make sense to do the premult
conversion if the destination format has no alpha. This patch adds
that check in too.
2010-06-22 12:22:47 +01:00
Neil Roberts
82e63a4753 cogl-texture: Replace the ensure_mipmaps virtual with pre_paint
Instead of the ensure_mipmaps virtual that is only called whenever the
texture is about to be rendered with a min filter that needs the
mipmap, there is now a pre_paint virtual that is always called when
the texture is about to be painted in any way. It has a flags
parameter which is used to specify whether the mipmap will be needed.

This is useful for CoglTexturePixmapX11 because it needs to do stuff
before painting that is unrelated to mipmapping.
2010-06-22 11:47:33 +01:00
Neil Roberts
ebb05bcb64 cogl-texture: List texture subclass types rather than hardcoding them
Instead of having a hardcoded series of if-statements in
cogl_is_texture to determine which types should appear as texture
subclasses, they are now stored in a GSList attached to the Cogl
context. The list is amended to using a new cogl_texture_register_type
function. There is a convenience macro called COGL_TEXTURE_DEFINE
which uses COGL_HANDLE_DEFINE_WITH_CODE to register the texture type
when the _get_type() function is first called.
2010-06-22 11:47:33 +01:00
Robert Bragg
82e80e6765 material: Avoid redundant glBindTexture calls
This adds a _cogl_bind_gl_texture_transient function that should be used
instead of glBindTexture so we can have a consistent cache of the
textures bound to each texture unit so we can avoid some redundant
binding.
2010-06-09 17:26:15 +01:00
Neil Roberts
dae6ab7d79 cogl-texture: Don't attempt to use GL to convert formats under GLES
In commit abe91784c4 I changed cogl-texture so that it would use the
OpenGL mechanism to specify a different internal texture format from
the image format so that it can do the conversion instead of
Cogl. However under GLES the internal format and the image format must
always be the same and it only supports a limited set of formats. This
patch changes _cogl_texture_prepare_for_upload so that it does the
conversion using the cogl bitmap code when compiling for GLES.

http://bugzilla.openedhand.com/show_bug.cgi?id=2059
2010-04-29 13:15:35 +01:00
Neil Roberts
fb7f1a7fd6 Split the wrap mode of _cogl_texture_set_wrap_mode into three
GL supports setting different wrap modes for the s, t and r
coordinates so we should design the backend interface to support that
also. The r coordinate is not currently used by any of the backends
but we might as well have it to make life easier if we ever add
support for 3D textures.

http://bugzilla.openedhand.com/show_bug.cgi?id=2063
2010-04-12 15:44:23 +01:00
Owen W. Taylor
770ca1311d Fix checks for out-of-bounds coordinates and repeats
Add a return result from CoglTexture.transform_quad_coords_to_gl(),
so that we can properly determine the nature of repeats in
the face of GL_TEXTURE_RECTANGLE_ARB, where the returned
coordinates are not normalized.

The comment "We also work out whether any of the texture
coordinates are outside the range [0.0,1.0]. We need to do
this after calling transform_coords_to_gl in case the texture
backend is munging the coordinates (such as in the sub texture
backend)." is disregarded and removed, since it's actually
the virtual coordinates that determine whether we repeat,
not the GL coordinates.

Warnings about disregarded layers are used in all cases where
applicable, including for subtextures.

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

Signed-off-by: Neil Roberts <neil@linux.intel.com>
2010-03-15 16:09:41 +00:00
Emmanuele Bassi
72f4ddf532 Remove mentions of the FSF address
Since using addresses that might change is something that finally
the FSF acknowledge as a plausible scenario (after changing address
twice), the license blurb in the source files should use the URI
for getting the license in case the library did not come with it.

Not that URIs cannot possibly change, but at least it's easier to
set up a redirection at the same place.

As a side note: this commit closes the oldes bug in Clutter's bug
report tool.

http://bugzilla.openedhand.com/show_bug.cgi?id=521
2010-03-01 12:56:10 +00:00
Robert Bragg
e48b817b0a cogl: resolves some low hanging issues flagged by clang
An initial pass over the Cogl source code using the Clang static
analysis tool flagged a few low hanging issues such as un-used variables
or redundant initializing of variables which this patch fixes.
2010-02-12 14:05:02 +00:00
Robert Bragg
0f5f4e8645 cogl: improves header and coding style consistency
We've had complaints that our Cogl code/headers are a bit "special" so
this is a first pass at tidying things up by giving them some
consistency. These changes are all consistent with how new code in Cogl
is being written, but the style isn't consistently applied across all
code yet.

There are two parts to this patch; but since each one required a large
amount of effort to maintain tidy indenting it made sense to combine the
changes to reduce the time spent re indenting the same lines.

The first change is to use a consistent style for declaring function
prototypes in headers. Cogl headers now consistently use this style for
prototypes:

 return_type
 cogl_function_name (CoglType arg0,
                     CoglType arg1);

Not everyone likes this style, but it seems that most of the currently
active Cogl developers agree on it.

The second change is to constrain the use of redundant glib data types
in Cogl. Uses of gint, guint, gfloat, glong, gulong and gchar have all
been replaced with int, unsigned int, float, long, unsigned long and char
respectively. When talking about pixel data; use of guchar has been
replaced with guint8, otherwise unsigned char can be used.

The glib types that we continue to use for portability are gboolean,
gint{8,16,32,64}, guint{8,16,32,64} and gsize.

The general intention is that Cogl should look palatable to the widest
range of C programmers including those outside the Gnome community so
- especially for the public API - we want to minimize the number of
foreign looking typedefs.
2010-02-12 14:05:00 +00:00
Halton Huo
2ecb6f7b20 Remove return from void functions
This patch fixes compilation on suncc.

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

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2010-02-09 10:24:25 +00:00
Damien Lespiau
273fd23742 cogl-buffer: make sure the code compiles on GL ES
OpenGL ES has no PBO extension, so we fallback to using a malloc'ed
buffer. Make sure the OpenGL-only defines don't leak into the OpenGL ES
compilation.
2010-02-08 17:14:49 +00:00
Damien Lespiau
ca80e8802b cogl-pixel-buffer: Add a fallback path
First, let's add a new public feature called, surprisingly,
COGL_FEATURE_PBOS to check the availability of PBOs and provide a
fallback path when running on older GL implementations or on OpenGL ES

In case the underlying OpenGL implementation does not provide PBOs, we
need a fallback path (a malloc'ed buffer). The CoglPixelBufer
constructors will instanciate a subclass of CoglBuffer that handles
map/unmap and set_data() with a malloc'ed buffer.

The public feature is useful to check before using set_data() on a
buffer as it will mean doing a memcpy() when not supporting PBOs (in
that case, it's better to create the texture directly instead of using a
CoglBuffer).
2010-02-08 17:14:49 +00:00
Damien Lespiau
cf960cfb3d cogl-texture: Add a new constructor to turn CoglBuffers into textures
The only goal of using COGL buffers is to use them to create
textures. cogl_texture_new_from_buffer() is the new symbol to create
textures out of buffers.
2010-02-08 17:14:49 +00:00
Neil Roberts
b9a9bf60b7 cogl-bitmap: Update the format after (un)premultiplying
The pixel format of the bitmap needs to have its premult flag cleared
or set after the premult conversion otherwise it may get converted
again.
2010-02-06 00:13:25 +00:00
Neil Roberts
264f0f0f05 cogl-texture: Avoid copying the bitmap when premultiplying from a file
In cogl_texture_new_from_file we create and own a temporary
bitmap. There's no need to copy this data if we need to do a premult
conversion so instead it just does conversion before passing it on to
cogl_texture_new_from_bitmap.
2010-02-03 23:27:45 +00:00
Neil Roberts
e83e0c3e5b cogl-texture: Split out _cogl_texture_prepare_for_upload
The Cogl atlas code was using _cogl_texture_prepare_for_upload with a
NULL pointer for the dst_bmp to determine the internal format of the
texture without converting the bitmap. It needs to do this to decide
whether the texture will go in the atlas before wasting time on the
conversion. This use of the function is a little confusing so that
part of it has been split out into a new function called
_cogl_texture_determine_internal_format. The code to decide whether a
premult conversion is needed has also been split out.
2010-02-03 23:10:52 +00:00
Neil Roberts
e20c98e548 cogl: Let GL do the format conversion when uploading texture data
Cogl accepts a pixel format for both the data in memory and the
internal format to be used for the texture. If they do not match then
it would convert them using the CoglBitmap functions before uploading
the data. However, GL also lets you specify both formats so it makes
more sense to let GL do the conversion. The driver may need the
texture in a specific format so it may end up being converted anyway.

The cogl_texture_upload_data functions have been removed and replaced
with a single function to prepare the bitmap. This will only do the
premultiplication conversion because that is the only part that GL
can't do directly.
2010-02-01 13:27:34 +00:00
Neil Roberts
a6f061e41f cogl: Do the premult conversion in-place rather than copying to a new buffer
The premult part of _cogl_convert_premult has now been split out as
_cogl_convert_premult_status. _cogl_convert_premult has been renamed
to _cogl_convert_format to make it less confusing. The premult
conversion is now done in-place instead of copying the
buffer. Previously it was copying the buffer once for the format
conversion and then copying it again for the premult conversion. The
premult conversion never changes the size of the buffer so it's quite
easy to do in place. We can also use the separated out function
independently.
2010-02-01 13:27:34 +00:00
Neil Roberts
ae7825275e cogl: Make CoglSubTexture only work for quad rendering
The sub texture backend doesn't work well as a completely general
texture backend because for example when rendering with cogl_polygon
it needs to be able to tranform arbitrary texture coordinates without
reference to the other coordintes. This can't be done when the texture
coordinates are a multiple of one because sometimes the coordinate
should represent the left or top edge and sometimes it should
represent the bottom or top edge. For example if the s coordinates are
0 and 1 then 1 represents the right edge but if they are 1 and 2 then
1 represents the left edge.

Instead the sub-textures are now documented not to support coordinates
outside the range [0,1]. The coordinates for the sub-region are now
represented as integers as this helps avoid rounding issues. The
region can no longer be a super-region of the texture as this
simplifies the code quite a lot.

There are two new texture virtual functions:

transform_quad_coords_to_gl - This transforms two pairs of coordinates
     representing a quad. It will return FALSE if the coordinates can
     not be transformed. The sub texture backend uses this to detect
     coordinates that require repeating which causes cogl-primitives
     to use manual repeating.

ensure_non_quad_rendering - This is used in cogl_polygon and
     cogl_vertex_buffer to inform the texture backend that
     transform_quad_to_gl is going to be used. The atlas backend
     migrates the texture out of the atlas when it hits this.
2010-01-18 09:22:04 +00:00
Neil Roberts
963afa88c5 cogl-texture: Fix manual repeating for negative coordinates
When calculating the next integer position for negative coordinates it
would not increment if the position is already a multiple of one so we
need to manually add one.
2010-01-15 12:16:06 +00:00
Neil Roberts
f5d809f1e8 Merge branch 'master' into more-texture-backends 2010-01-15 12:15:46 +00:00
Halton Huo
9b441ec309 cogl-texture: Remove return in void functions
http://bugzilla.o-hand.com/show_bug.cgi?id=1929

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2010-01-04 11:51:06 +00:00
Neil Roberts
bec2600087 cogl: Add an atlased texture backend
This adds a CoglAtlas type which is a data structure that keeps track
of unused sub rectangles of a larger rectangle. There is a new atlased
texture backend which uses this to put multiple textures into a single
larger texture.

Currently the atlas is always sized 256x256 and the textures are never
moved once they are put in. Eventually it needs to be able to
reorganise the atlas and grow it if necessary. It also needs to
migrate the textures out of the atlas if mipmaps are required.
2009-12-04 20:26:39 +00:00
Neil Roberts
05d42ed390 cogl: Add a CoglTexture2D backend
This is an optimised version of CoglTexture2DSliced that always deals
with a single texture and always uses the GL_TEXTURE_2D
target. cogl_texture_new_from_bitmap now tries to use this backend
first. If it can't create a texture with that size then it falls back
the sliced backend.

cogl_texture_upload_data_prepare has been split into two functions
because the sliced backend needs to know the real internal format
before the conversion is performed. Otherwise the converted bitmap
will be wasted if the backend can't support the size.
2009-12-02 22:03:27 +00:00
Neil Roberts
8753422ef5 cogl: Move some of the texture_2d_sliced_new_* functions into cogl-texture
new_from_data and new_from_file can be implemented in terms of
new_from_bitmap so it makes sense to move these to cogl-texture rather
than having to implement them in every texture backend.
2009-12-02 22:03:26 +00:00
Neil Roberts
c9cafc798c cogl: Add a sub texture backend
This adds a new texture backend which represents a sub texture of a
larger texture. The texture is created with a reference to the full
texture and a set of coordinates describing the region. The backend
simply defers to the full texture for all operations and maps the
coordinates to the other range. You can also use coordinates outside
the range [0,1] to create a repeated version of the full texture.

A new public API function called cogl_texture_new_from_sub_texture is
available to create the sub texture.
2009-12-02 22:03:08 +00:00
Neil Roberts
6bc3319c86 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
25f3b993c6 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
5030356e0e 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
Robert Bragg
944423a8d9 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
Neil Roberts
1df0e36c6c 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
bb3a008318 [draw-buffers] First pass at overhauling Cogl's framebuffer management
Cogl's support for offscreen rendering was originally written just to support
the clutter_texture_new_from_actor API and due to lack of documentation and
several confusing - non orthogonal - side effects of using the API it wasn't
really possible to use directly.

This commit does a number of things:
- It removes {gl,gles}/cogl-fbo.{c,h} and adds shared cogl-draw-buffer.{c,h}
  files instead which should be easier to maintain.
- internally CoglFbo objects are now called CoglDrawBuffers. A
  CoglDrawBuffer is an abstract base class that is inherited from to
  implement CoglOnscreen and CoglOffscreen draw buffers.  CoglOffscreen draw
  buffers will initially be used to support the
  cogl_offscreen_new_to_texture API, and CoglOnscreen draw buffers will
  start to be used internally to represent windows as we aim to migrate some
  of Clutter's backend code to Cogl.
- It makes draw buffer objects the owners of the following state:
  - viewport
  - projection matrix stack
  - modelview matrix stack
  - clip state
(This means when you switch between draw buffers you will automatically be
 switching to their associated viewport, matrix and clip state)

Aside from hopefully making cogl_offscreen_new_to_texture be more useful
short term by having simpler and well defined semantics for
cogl_set_draw_buffer, as mentioned above this is the first step for a couple
of other things:
- Its a step toward moving ownership for windows down from Clutter backends
  into Cogl, by (internally at least) introducing the CoglOnscreen draw
  buffer.  Note: the plan is that cogl_set_draw_buffer will accept on or
  offscreen draw buffer handles, and the "target" argument will become
  redundant since we will instead query the type of the given draw buffer
  handle.
- Because we have a common type for on and offscreen framebuffers we can
  provide a unified API for framebuffer management. Things like:
  - blitting between buffers
  - managing ancillary buffers (e.g. attaching depth and stencil buffers)
  - size requisition
  - clearing
2009-11-03 17:23:03 +00:00
Robert Bragg
eed2479556 [cogl] Removes the cogl-current-matrix abstraction
The indirection through this API isn't necessary since we no longer
arbitrate between the OpenGL matrix API and Cogl's client side API.  Also it
doesn't help to maintain an OpenGL style matrix mode API for internal use
since it's awkward to keep restoring the MODELVIEW mode and easy enough to
directly work with the matrix stacks of interest.

This replaces use of the _cogl_current_matrix API with direct use of the
_cogl_matrix_stack API.  All the unused cogl_current_matrix API is removed
and the matrix utility code left in cogl-current-matrix.c was moved to
cogl.c.
2009-10-20 12:32:50 +01:00
Vladimir Nadvornik
65015a137e [cogl-texture] Split CoglTexture into an abstract class + CoglTexture2dSliced
cogl-texture-2d-sliced provides an implementation of CoglTexture and this
seperation lays the foundation for potentially supporting atlas textures,
pixmap textures (as in GLX_EXT_texture_from_pixmap) and fast-path
GL_TEXTURE_{1D,2D,3D,RECTANGLE} textures in a maintainable fashion.
2009-10-16 18:58:51 +01:00
Robert Bragg
c40d5ae9ea [cogl-texture] Seal CoglTexture internals from cogl-primitives.c
cogl-primitives.c was previously digging right into CoglTextures so it could
manually iterate the texture slices for texturing quads and polygons and
because we were missing some state getters we were lazily just poking into
the structures directly.

This adds some extra state getter functions, and adds a higher level
_cogl_texture_foreach_slice () API that hopefully simplifies the way in
which sliced textures may be used to render primitives.  This lets you
specify a rectangle in "virtual" texture coords and it will call a given
callback for each slice that intersects that rectangle giving the virtual
coords of the current slice and corresponding "real" texture coordinates for
the underlying gl texture.

At the same time a noteable bug in how we previously iterated sliced
textures was fixed, whereby we weren't correctly handling inverted texture
coordinates.  E.g.  with the previous code if you supplied texture coords of
tx1=100,ty1=0,tx2=0,ty2=100 (inverted along y axis) that would result in a
back-facing quad, which could be discarded if using back-face culling.
2009-10-16 18:58:51 +01:00
Robert Bragg
0bce7eac53 Intial Re-layout of the Cogl source code and introduction of a Cogl Winsys
As part of an incremental process to have Cogl be a standalone project we
want to re-consider how we organise the Cogl source code.

Currently this is the structure I'm aiming for:
cogl/
    cogl/
	<put common source here>
	winsys/
	   cogl-glx.c
	   cogl-wgl.c
	driver/
	    gl/
	    gles/
	os/ ?
    utils/
	cogl-fixed
	cogl-matrix-stack?
        cogl-journal?
        cogl-primitives?
    pango/

The new winsys component is a starting point for migrating window system
code (i.e.  x11,glx,wgl,osx,egl etc) from Clutter to Cogl.

The utils/ and pango/ directories aren't added by this commit, but they are
noted because I plan to add them soon.

Overview of the planned structure:

* The winsys/ API is the API that binds OpenGL to a specific window system,
  be that X11 or win32 etc.  Example are glx, wgl and egl. Much of the logic
  under clutter/{glx,osx,win32 etc} should migrate here.

* Note there is also the idea of a winsys-base that may represent a window
  system for which there are multiple winsys APIs.  An example of this is
  x11, since glx and egl may both be used with x11.  (currently only Clutter
  has the idea of a winsys-base)

* The driver/ represents a specific varient of OpenGL. Currently we have "gl"
  representing OpenGL 1.4-2.1 (mostly fixed function) and "gles" representing
  GLES 1.1 (fixed funciton) and 2.0 (fully shader based)

* Everything under cogl/ should fundamentally be supporting access to the
  GPU.  Essentially Cogl's most basic requirement is to provide a nice GPU
  Graphics API and drawing a line between this and the utility functionality
  we add to support Clutter should help keep this lean and maintainable.

* Code under utils/ as suggested builds on cogl/ adding more convenient
  APIs or mechanism to optimize special cases. Broadly speaking you can
  compare cogl/ to OpenGL and utils/ to GLU.

* clutter/pango will be moved to clutter/cogl/pango

How some of the internal configure.ac/pkg-config terminology has changed:
backendextra -> CLUTTER_WINSYS_BASE # e.g. "x11"
backendextralib -> CLUTTER_WINSYS_BASE_LIB # e.g. "x11/libclutter-x11.la"
clutterbackend -> {CLUTTER,COGL}_WINSYS # e.g. "glx"
CLUTTER_FLAVOUR -> {CLUTTER,COGL}_WINSYS
clutterbackendlib -> CLUTTER_WINSYS_LIB
CLUTTER_COGL -> COGL_DRIVER # e.g. "gl"

Note: The CLUTTER_FLAVOUR and CLUTTER_COGL defines are kept for apps

As the first thing to take advantage of the new winsys component in Cogl;
cogl_get_proc_address() has been moved from cogl/{gl,gles}/cogl.c into
cogl/common/cogl.c and this common implementation first trys
_cogl_winsys_get_proc_address() but if that fails then it falls back to
gmodule.
2009-10-16 18:58:50 +01:00