1
0
Fork 0
Commit graph

23 commits

Author SHA1 Message Date
Robert Bragg
3ea6acc072 buffer: explicitly relate buffers to a context
All CoglBuffer constructors now take an explicit CoglContext
constructor. This is part of the on going effort to adapt to Cogl API so
it no longer depends on a global, default context.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-02-09 14:28:02 +00:00
Robert Bragg
92c3063014 framebuffer: Add cogl_framebuffer draw methods
This adds cogl_framebuffer_ apis for drawing attributes and primitives
that replace corresponding apis that depend on the default CoglContext.
This is part of the on going effort to adapt the Cogl api so it no
longer depends on a global context variable.

All the new drawing functions also take an explicit pipeline argument
since we are also aiming to avoid being a stateful api like Cairo and
OpenGL. Being stateless makes it easier for orthogonal components to
share access to the GPU. Being stateless should also minimize any
impedance miss-match for those wanting to build higher level stateless
apis on top of Cogl.

Note: none of the legacy, global state options such as
cogl_set_depth_test_enabled(), cogl_set_backface_culling_enabled() or
cogl_program_use() are supported by these new drawing apis and if set
will simply be silently ignored.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-02-09 13:09:15 +00:00
Neil Roberts
77c3b1b905 Add cogl_primitive_get_indices()
This adds a public getter for the indices property of CoglPrimitive.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-02-07 15:25:36 +00:00
Neil Roberts
354e923cbf Add cogl_primitive_foreach_attribute()
This adds a public function to iterate the attributes of a
CoglPrimitive. Previously there was no way to query back the
attributes but there was methods to query back all of the other
properties.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-02-07 15:25:36 +00:00
Neil Roberts
146803c191 Add cogl_primitive_copy()
This adds a public function to make a copy of a primitive. The copy is
shallow which means it will share the same attributes and attribute
buffers. This could be useful for code that wants to have multiple
similar primitives with slightly modified properties.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-02-07 15:25:35 +00:00
Robert Bragg
8cf76ee36b primitive: Add n_indices arg to _set_indices function
When associating indices with a CoglPrimitive you are now forced to
specify the number of indices that should be read when drawing.

It's easy to forget to call cogl_primitive_set_n_vertices() after
associating indices with a primitive (and anyway you can see that someone
could be led to believe Cogl can determine that implicitly somewhow) so
this should avoid a lot of mistakes with using the API.

We'd expect that setting indices and updating the n_vertices property
would go hand in hand 99% of the time anyway so this change should
be more convenient as well as less error prone.

This patch adds some documentation for cogl_primitive_set_indices and
cogl_primitive_get/set_n_vertices. It also tries to clarify how the
CoglPrimitive:n_vertices property is updated and what that property
means in relation to other functions too.

https://bugzilla.gnome.org/show_bug.cgi?id=661019

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2011-11-01 12:03:03 +00:00
Robert Bragg
b72f255c0a Start to reduce dependence on glib
Since we've had several developers from admirable projects say they
would like to use Cogl but would really prefer not to pull in
gobject,gmodule and glib as extra dependencies we are investigating if
we can get to the point where glib is only an optional dependency.
Actually we feel like we only make minimal use of glib anyway, so it may
well be quite straightforward to achieve this.

This adds a --disable-glib configure option that can be used to disable
features that depend on glib.

Actually --disable-glib doesn't strictly disable glib at this point
because it's more helpful if cogl continues to build as we make
incremental progress towards this.

The first use of glib that this patch tackles is the use of
g_return_val_if_fail and g_return_if_fail which have been replaced with
equivalent _COGL_RETURN_VAL_IF_FAIL and _COGL_RETURN_IF_FAIL macros.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2011-11-01 12:03:02 +00:00
Robert Bragg
7a834cf681 primitive: Adds _cogl_primitive_draw api taking flags
This adds an internal _cogl_primitive_draw API that takes CoglDrawFlags
like _cogl_draw_attributes does which allows us to draw a primitive but
skip things like flushing journals, flushing framebuffer state and avoid
validating the current pipeline. This allows us to draw primitives in
places that could otherwise cause recursion.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2011-11-01 12:02:59 +00:00
Robert Bragg
d739892a5c primitive: micro optimize primitive allocations
We've started seeing cases where we want to allocate lots of one-shot
primitives per-frame and the cost of allocating primitives becomes
important in this case since it can start being noticeable in profiles.

The main cost for allocating primitives was the GArray allocation
and appending the attributes to the array. This updates the code to
simply over allocate the primitive storage so we can embed the list
of attributes directly in that allocation.

If the user later sets new attributes and there isn't enough embedded
space then a separate slice allocation for the new attributes is made
but still this should be far less costly than using a GArray as before.
Most of the time we would expect when setting new attributes there will
still be the same number of attributes, so the embedded space can simple
be reused.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2011-09-21 15:50:08 +01:00
Neil Roberts
eb109e6cc0 cogl-primitive: Fix some broken changes for removal of NULL terminator
Commit 3c1e83c7 changed uses of arrays of CoglAttributes to take a
length instead of being NULL terminated. In cogl_primitive_new it was
still adding the NULL terminator to the array it passes to
cogl_primitive_new_with_attributes but then it was also including this
terminator in the count so it would just segfault when it tries to ref
the NULL pointer. Also _cogl_primitive_new_with_attributes_unref was
still trying to detect the NULL terminator so it would also crash.
2011-05-16 18:34:22 +01:00
Robert Bragg
3c1e83c7f5 Don't pass around NULL terminated CoglAttribute arrays
For the first iteration of the CoglAttribute API several of the new
functions accepted a pointer to a NULL terminated list of CoglAttribute
pointers - probably as a way to reduce the number of arguments required.
This style isn't consistent with existing Cogl APIs though and so we now
explicitly pass n_attributes arguments and don't require the NULL
termination.
2011-05-16 14:32:37 +01:00
Robert Bragg
ce7c06dc03 Rename CoglVertexArray to CoglAttributeBuffer
This is part of a broader cleanup of some of the experimental Cogl API.
One of the reasons for this particular rename is to switch away from
using the term "Array" which implies a regular, indexable layout which
isn't the case. We also want to have a strongly implied relationship
between CoglAttributes and CoglAttributeBuffers.
2011-05-16 14:31:31 +01:00
Robert Bragg
9b0fd92527 cogl: rename CoglVertexAttribute CoglAttribute
This is part of a broader cleanup of some of the experimental Cogl API.
One of the reasons for this particular rename is to reduce the verbosity
of using the API. Another reason is that CoglVertexArray is going to be
renamed CoglAttributeBuffer and we want to help emphasize the
relationship between CoglAttributes and CoglAttributeBuffers.
2011-01-21 16:24:14 +00:00
Robert Bragg
87c990a29c cogl: s/Cogl*Vertex/CoglVertex*/
We have a bunch of experimental convenience functions like
cogl_primitive_p2/p2t2 that have corresponding vertex structures but it
seemed a bit odd to have the vertex annotation e.g. "P2T2" be an infix
of the type like CoglP2T2Vertex instead of be a postfix like
CoglVertexP2T2. This switches them all to follow the postfix naming
style.
2011-01-21 16:22:40 +00:00
Robert Bragg
982f1b4bd0 vertex-array: Adds data arg for _vertex_array_new()
This adds an optional data argument for cogl_vertex_array_new() since it
seems that mostly every case where we use this API we follow up with a
cogl_buffer_set_data() matching the size of the new array. This
simplifies all those cases and whenever we want to delay uploading of
data then NULL can simply be passed.
2010-11-19 13:27:30 +00:00
Neil Roberts
6027aa04a4 cogl-buffer: Use void* instead of guint8* for map and set_data
Unless the CoglBuffer is being used for texture data then it's
relatively unlikely that the data will contain an array of bytes. For
example if it's used as a vertex array then it's more likely to be
floats or some vertex struct. In that case it's much more convenient
if set_data and map use void* pointers so that we can avoid a cast.
2010-11-04 18:04:03 +00:00
Neil Roberts
2155bd7546 cogl-primitive: Fix the texture attribute offsets
The offsets for the texture coordinate attributes in the convenience
constructors were all wrong.
2010-11-04 17:59:33 +00:00
Neil Roberts
7aa39f18a4 cogl-primitive: Fix a typo in new_with_attributes_array
A typo in the g_return_val_if_fail was causing it to segfault.
2010-11-04 17:59:33 +00:00
Neil Roberts
ec080f2db0 cogl-primitive: Add the missing cogl_primitive_new_p2 function
There was a struct defined for CoglP2Vertex but there was no
constructor function to use it.
2010-11-04 17:59:28 +00:00
Neil Roberts
5dc1b2fb8f cogl-primitive: Fix the ref-counting for the convenience constuctors
The convenience constructors for the builtin vertex structs were
creating the primitive and then immediately destroying it and
returning the pointer. I think the intention was to unref the
attributes instead. This adds an internal wrapper around the
new_with_attributes_array constructor which unrefs the attributes
instead of the primitive. The convenience constructors now use that.
2010-11-04 17:57:09 +00:00
Robert Bragg
b03f905094 primitive: adds immutable ref/unref mechanism
This adds a way to mark that a primitive is in use so that modifications
will generate a warning. The plan is to use this mechanism when batching
primitives in the journal to warn users that mid-scene modifications of
primitives is not allowed.
2010-11-03 18:04:31 +00:00
Robert Bragg
a03a5814e7 primitive: Adds convenience constructors
This adds convenience primitive constructors named like:
  cogl_primitive_new_p3 or
  cogl_primitive_new_p3c4 or
  cogl_primitive_new_p3t2c4
where the letters correspond to the interleved vertex attributes layouts
such as CoglP3Vertex which is a struct with 3 float x,y,z members for
the [p]osition, or CoglP3T2C4Vertex which is a struct with 3 float x,y,z
members for the [p]osition, 2 float s,t members for the [t]exture
coordinates and 4 unsigned byte r,g,b,a members for the [c]olor.

The hope is that people will find these convenient enough to replace
cogl_polygon.
2010-11-03 18:04:31 +00:00
Robert Bragg
9498d505dd cogl: Adds experimental CoglPrimitive API
A CoglPrimitive is a retainable object for drawing a single primitive,
such as a triangle strip, fan or list.

CoglPrimitives build on CoglVertexAttributes and CoglIndices which
themselves build on CoglVertexArrays and CoglIndexArrays respectively.

A CoglPrimitive encapsulates enough information such that it can be
retained in a queue (e.g. the Cogl Journal, or renderlists in the
future) and drawn at some later time.
2010-11-03 18:04:31 +00:00