Commit Graph

200 Commits

Author SHA1 Message Date
Neil Roberts
addf48f62f doc/RELEASING: Add a note to test with all pipeline backends and GLES2
This adds a test step to test all of the pipeline backends and GLES2.
GLES2 is currently known to fail for a few tests so it is recommended
to test it with a for loop and make a note of the list of failed
tests.
2012-02-21 18:23:23 +00:00
Robert Bragg
5cdc9af18a Removes the COGL_PIXEL_FORMAT_{24,32} defines
Although these are in the public headers we should assume that no one is
using them since they were never documented so no could know what they
are useful for.

If you were to guess you'd be forgiven for thinking they were bitmasks
for checking some flags to see if a format is 24 or 32 bits. If you
looked further you might instead be forgiven for thinking that if you
masked of the least significant nibble of a pixel-format then you could
check the value against these defines. Neither of the previous
operations are reliable ways to check if a format is 24 or 32bit and
instead code must use then internal
_cogl_pixel_format_get_bytes_per_pixel() api if they want to know the
pixel size for a given format which relies on a 16 entry lookup table
using the least significant nibble of a pixel-format.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-02-20 23:12:45 +00:00
Robert Bragg
e43246fe1c Remove COGL_UNORDERED_MASK define
Although it's in a public header nothing should be using this define
since it's not documented what it could be used for. The cases where we
were using it internally were quite fragile because they were trying to
mask information from the least significant nibble of CoglPixelFormat
but really that nibble just has to be dealt with using lookup tables.
The least significant nibble of a pixel format gives information about
the bytes per pixel and whether the components are byte aligned but the
information needs to be accessed using
_cogl_pixel_format_get_byes_per_pixel() and
_cogl_pixel_format_is_endian_dependant().

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-02-20 23:12:44 +00:00
Robert Bragg
a203a5e396 Remove COGL_UNPREMULT_MASK define
Since (A & ~COGL_PREMULT_BIT) is basically as readable as (A &
COGL_UNPREMULT_MASK) this patch removes the mask define. Without the
mask the code is slightly more explicit and there's less risk in error
caused by us forgetting to update the COGL_UNPREMULT_MASK if the way
CoglPixelFormat is defined evolves.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-02-20 23:12:44 +00:00
Robert Bragg
ee940a3d0d Move all types/prototypes from cogl.h -> cogl[1]-context.h
So we can get to the point where cogl.h is merely an aggregation of
header includes for the 1.x api this moves all the function prototypes
and type definitions into a cogl-context.h and a new cogl1-context.h.

Ideally no code internally should ever need to include cogl.h as it just
represents the public facing header for accessing the 1.x api which
should only be used by Clutter.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-02-20 23:12:44 +00:00
Neil Roberts
fdc07c865f Add cogl_pipeline_set_layer_null_texture()
This adds a public function to replace the texture for a layer with
the default white texture. It is equivalent to calling
cogl_pipeline_set_layer_texture with NULL for the texture object
except that it also lets you choose a type for the texture. The idea
is that applications using a base pipeline to make multiple copies
that can share the generated shaders can use this function to make the
layer come into existence with the right texture type. Previously the
idiom would be to create a 1x1 dummy texture of the right type but
this ends up creating lots of redundant little textures.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-02-13 17:15:08 +00:00
Neil Roberts
8012eee31f Add _cogl_texture_get_type()
This adds an internal function to get the type of the underlying
hardware texture for any CoglTexture. It can return one of three
values to represent 2D textures, 3D textures or rectangle textures.
The idea is that this can be used as a replacement for
cogl_texture_get_gl_texture when only the target is required to make
it a bit less GL-centric. The implementation adds a new virtual
function which all of the texture backends now implement.

The enum is in a public header because a later patch will want to use
it from the CoglPipeline API. We may want to consider making the
function public too later.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-02-13 17:02:46 +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
f7f730ee84 docs: Updates cogl_primitive_new_xyz symbols listing
Previously we had functions named like
cogl_primitive_new_with_xyz_attributes() but at some point we renamed
them all to functions named like cogl_primitive_new_xyz() instead. This
updates the -sections.txt symbol listing to list the new names.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-01-16 23:27:36 +00:00
Javier Jardón
f3ea514afc docs: Add list of api introduced in 1.8 version 2012-01-13 15:51:34 +00:00
Neil Roberts
85d79ab4fa Add a utility to make a GSource out of a CoglContext
The GSource is created using cogl_glib_source_new which takes a
pointer to a CoglContext. The source calls cogl_poll_get_info() in its
prepare function and cogl_poll_dispatch() in its dispatch
function. The poll FDs on the source are updated according to what
Cogl reports.

The header is only included and the source only compiled if Cogl is
configured with GLib support.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-01-05 13:40:59 +00:00
Neil Roberts
7497475295 Add support for main loop integration
This adds two new functions:

void
cogl_poll_get_info (CoglContext *context,
                    CoglPollFD **poll_fds,
                    int *n_poll_fds,
                    gint64 *timeout);

void
cogl_poll_dispatch (CoglContext *context,
                    const CoglPollFD *poll_fds,
                    int n_poll_fds);

The application is expected to call the first function whenever it is
about to block to go idle, and the second function whenever it comes
out of idle. This gives Cogl winsys's the ability poll file
descriptors for events. For example when handing swap complete
notifications, it can report that it needs to block on a file
descriptor.

The two functions are backed by winsys virtual functions. There are
currently no implementations. The default handler for get_info just
reports no file descriptors and an infinite timeout.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-01-05 13:40:10 +00:00
Neil Roberts
55344ff2c4 Add the missing cogl_is_context() function
This was missing from the CoglContext header.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-01-05 12:58:41 +00:00
Neil Roberts
5f0a57ffdb snippet: Add some more documentation
This adds a documentation section for CoglSnippet which gives an
overview of how to use them. It also fixes some syntax errors in the
existing documentation and adds the missing pipeline functions for
adding snippets to the documentation sections file.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-12-07 14:52:48 +00:00
Neil Roberts
3f28168f1e attribute: Add the buffer and normalized property APIs to the header
The header was missing declarations for
cogl_attribute_{get,set}_{buffer,normalized}.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-12-06 19:02:06 +00:00
Robert Bragg
a4f3d0d18b matrix: Add cogl_matrix_orthographic
This adds an experimental cogl_matrix_orthographic() function that is
more consistent with other Cogl api by taking x_1, y_1, x_2, y_2
arguments to define the top-left and bottom-right coordinates of the
orthographic coordinates instead of OpenGL style left, right, bottom and
top values.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2011-12-06 18:51:56 +00:00
Robert Bragg
607151c717 reference: don't look for $(top_srcdir)/cogl/winsys/*.h
There are no headers built under the winsys directory so avoid looking
for them since that breaks dist rules.
2011-11-22 17:12:43 +00:00
Neil Roberts
4553ca0695 cogl-pipeline: Add support for setting uniform values
This adds the following new public experimental functions to set
uniform values on a CoglPipeline:

void
cogl_pipeline_set_uniform_1f (CoglPipeline *pipeline,
                              int uniform_location,
                              float value);
void
cogl_pipeline_set_uniform_1i (CoglPipeline *pipeline,
                              int uniform_location,
                              int value);
void
cogl_pipeline_set_uniform_float (CoglPipeline *pipeline,
                                 int uniform_location,
                                 int n_components,
                                 int count,
                                 const float *value);
void
cogl_pipeline_set_uniform_int (CoglPipeline *pipeline,
                               int uniform_location,
                               int n_components,
                               int count,
                               const int *value);
void
cogl_pipeline_set_uniform_matrix (CoglPipeline *pipeline,
                                  int uniform_location,
                                  int dimensions,
                                  int count,
                                  gboolean transpose,
                                  const float *value);

These are similar to the old functions used to set uniforms on a
CoglProgram. To get a value to pass in as the uniform_location there
is also:

int
cogl_pipeline_get_uniform_location (CoglPipeline *pipeline,
                                    const char *uniform_name);

Conceptually the uniform locations are tied to the pipeline so that
whenever setting a value for a new pipeline the application is
expected to call this function. However in practice the uniform
locations are global to the CoglContext. The names are stored in a
linked list where the position in the list is the uniform location.

The global indices are used so that each pipeline can store a mask of
which uniforms it overrides. That way it is quicker to detect which
uniforms are different from the last pipeline that used the same
CoglProgramState so it can avoid flushing uniforms that haven't
changed. Currently the values are not actually compared which means
that it will only avoid flushing a uniform if there is a common
ancestor that sets the value (or if the same pipeline is being flushed
again - in which case the pipeline and its common ancestor are the
same thing).

The uniform values are stored in the big state of the pipeline as a
sparse linked list. A bitmask stores which values have been overridden
and only overridden values are stored in the linked list.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-11-16 16:32:11 +00:00
Neil Roberts
d2fd168351 cogl-matrix: Add a public cogl_matrix_transpose()
This function takes a single matrix argument and replaces the matrix
with its transpose.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-11-16 16:32:11 +00:00
Neil Roberts
5369b3c601 pipeline: Make the backface culling experimental public
This adds two new experimental public functions to replace the old
internal _cogl_pipeline_set_cull_face_state function:

void
cogl_pipeline_set_cull_face_mode (CoglPipeline *pipeline,
                                  CoglPipelineCullFaceMode cull_face_mode);

void
cogl_pipeline_set_front_face_winding (CoglPipeline *pipeline,
                                      CoglWinding front_winding);

There are also the corresponding getters.

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

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-11-14 18:40:27 +00:00
Robert Bragg
e0344468d8 docs: Adds various missing 2.0 sections and symbols
This adds a number of missing sections and symbols to the experimental
2.0 reference manual.
2011-11-01 12:03:04 +00:00
Robert Bragg
18fb1ffab5 texture: Make CoglSubTexture experimental public api
This exposes cogl_sub_texture_new() and cogl_is_sub_texture() as
experimental public API. Previously sub-textures were only exposed via
cogl_texture_new_from_sub_texture() so there wasn't a corresponding
CoglSubTexture type. A CoglSubTexture is a high-level texture defined as
a sub-region of some other parent texture. CoglSubTextures are high
level textures that implement the CoglMetaTexture interface which can
be used to manually handle texture repeating.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2011-11-01 12:03:03 +00:00
Robert Bragg
1ee861a82c framebuffer: adds cogl_framebuffer_get_samples_per_pixel
It's useful to be able to query back the number of
point_samples_per_pixel that may have previously be chosen using
cogl_framebuffer_set_samples_per_pixel().

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2011-11-01 12:03:03 +00:00
Robert Bragg
648bec9523 doc: Adds a cogl-texture-2d to the 2.0 reference manual
When we make CoglTexture2D public as experimental api we forgot to add a
corresponding section the experimental 2.0 reference manual.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2011-11-01 12:03:03 +00:00
Robert Bragg
90f106117f texture: Make CoglTextureRectangle experimentally public
This exposes CoglTextureRectangle in the experimental cogl 2.0 api. For
now we just expose a single constructor;
cogl_texture_rectangle_new_with_size() but we can add more later.

This is part of going work to improve our texture apis with more
emphasis on providing low-level access to the varying semantics of
different texture types understood by the gpu instead of only trying to
present a lowest common denominator api.

CoglTextureRectangle is notably useful for never being restricted to
power of two sizes and for being sampled with non-normalized texture
coordinates which can be convenient for use a lookup tables in glsl due
to not needing separate uniforms for mapping normalized coordinates to
texels. Unlike CoglTexture2D though rectangle textures can't have a
mipmap and they only support the _CLAMP_TO_EDGE wrap mode.

Applications wanting to use CoglTextureRectangle should first check
cogl_has_feature (COGL_FEATURE_ID_TEXTURE_RECTANGLE).

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2011-11-01 12:03:02 +00:00
Robert Bragg
79719347c8 framebuffer: split out CoglOnscreen code
This factors out the CoglOnscreen code from cogl-framebuffer.c so we now
have cogl-onscreen.c, cogl-onscreen.h and cogl-onscreen-private.h.
Notably some of the functions pulled out are currently namespaced as
cogl_framebuffer but we know we are planning on renaming them to be in
the cogl_onscreen namespace; such as cogl_framebuffer_swap_buffers().

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2011-11-01 12:03:02 +00:00
Robert Bragg
426c8b8f41 features: Support more than 32 features!
Currently features are represented as bits in a 32bit mask so we
obviously can't have more than 32 features with that approach. The new
approach is to use the COGL_FLAGS_ macros which lets us handle bitmasks
without a size limit and we change the public api to accept individual
feature enums instead of a mask. This way there is no limit on the
number of features we can add to Cogl.

Instead of using cogl_features_available() there is a new
cogl_has_feature() function and for checking multiple features there is
cogl_has_features() which takes a zero terminated vararg list of
features.

In addition to being able to check for individual features this also
adds a way to query all the features currently available via
cogl_foreach_feature() which will call a callback for each feature.

Since the new functions take an explicit context pointer there is also
no longer any ambiguity over when users can first start to query
features.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2011-11-01 12:03:01 +00:00
Robert Bragg
a8efe6af06 framebuffer: Adds experimental _finish() API
This adds a new experimental function, cogl_framebuffer_finish(), which
can be used to explicitly synchronize the CPU with the GPU. It's rare
that this level of explicit synchronization is desirable but for example
it can be useful during performance analysys to make sure measurements
reflect the working time of the GPU not just the time to queue commands.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2011-11-01 12:02:55 +00:00
Neil Roberts
8c9c01a6f4 doc/RELEASING: Add a note about testing windows compilation
Now that we have reasonably good Windows support, we'd like to make
sure each release still compiles there.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-10-17 15:00:31 +01:00
Robert Bragg
e230a994a2 doc/RELEASING: note that the conformance tests should be run
This documents that `make check` should be run as part of the release
process.
2011-09-19 17:44:21 +01:00
Robert Bragg
db6c452aaa pipeline: split out all layer state apis
As part of an on-going effort to get cogl-pipeline.c into a more
maintainable state this splits out all the apis relating just to
layer state. This just leaves code relating to the core CoglPipeline
and CoglPipelineLayer design left in cogl-pipeline.c.

This splits out around 2k more lines from cogl-pipeline.c although we
are still left with nearly 4k lines so we still have some way to go!

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2011-09-19 16:40:00 +01:00
Robert Bragg
9b58b6f472 pipeline: split out all core state apis
Since cogl-pipeline.c has become very unwieldy this make a start at
trying to shape this code back into a manageable state. This patche
moves all the API relating to core pipeline state into
cogl-pipeline-state.c. This doesn't move code relating to layer state
out nor does it move any of the code supporting the core design
of CoglPipeline itself.

This change alone factors out 2k lines of code from cogl-pipeline.c
which is obviously a good start. The next step will be to factor
out the layer state and then probably look at breaking all of this
state code down into state-groups.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2011-09-19 16:35:59 +01:00
Damien Lespiau
c36652a4c3 renderer: Add cogl_renderer_get_n_fragment_texture_units()
Add a method on the renderer to know how many texture image units are
accessible from fragment shaders.

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

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-09-05 17:54:46 +01:00
Damien Lespiau
6a2e21183c display: Add an accessor to get the renderer out of a display
https://bugzilla.gnome.org/show_bug.cgi?id=657347

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-09-05 17:54:46 +01:00
Damien Lespiau
6584c183f0 context: Add an accessor to get display associated with the context
https://bugzilla.gnome.org/show_bug.cgi?id=657347

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-09-05 17:54:46 +01:00
Robert Bragg
f37d9bbb4d matrix: Add cogl_matrix_look_at
Similar to the widely used gluLookAt API, this adds a CoglMatrix utility
for setting up a view transform in terms of positioning a camera/eye
position that points to a given object position aligned to a given
world-up vector.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2011-08-12 15:28:44 +01:00
Robert Bragg
a3ad808f57 framebuffer: Make framebuffer_clear APIs public experimental
This makes cogl_framebuffer_clear and cogl_framebuffer_clear4f public as
experimental API. Since these functions take explicit framebuffer
pointers you don't need to push/pop a framebuffer just to clear it. Also
these functions are implicitly tied to a specific CoglContext via the
framebuffer pointer unlike cogl_clear.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2011-08-12 15:28:43 +01:00
Robert Bragg
64b2bbab84 framebuffer: Adds a context getter for CoglFramebuffer
This adds a function to query what CoglContext a given framebuffer
belongs too. This can be useful if you pass framebuffer pointers around
and at some point you want to create another framebuffer as part of the
same context as a given framebuffer without assuming there is a single
default context.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2011-08-12 15:28:43 +01:00
Robert Bragg
2215588c29 dist: enable more features for distcheck
As a bare minimum we want to ensure that are releases are able to build
with support for gles1, gles2, gl, egl and glx. Previously we only
checked the build with gl + glx enabled and our last release actually
missed a header file required for building with egl.
2011-07-20 16:58:46 +01:00
Robert Bragg
278952fcd9 Add note about updating libtool versioning in doc/RELEASING 2011-07-20 16:58:46 +01:00
Robert Bragg
8b34a39319 Adds ColorMask support to Cogl
This adds CoglPipeline and CoglFramebuffer support for setting a color
mask which is a bit mask defining which color channels should be written
to the current framebuffer.

The final color mask is the intersection of the framebuffer color mask
and the pipeline color mask. The framebuffer mask affects all rendering
to the framebuffer while the pipeline masks can be used to affect
individual primitives.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2011-07-19 19:27:09 +01:00
Robert Bragg
40970ce915 dist: give 2.0 manual unique DOC_MODULE name
The experimental 2.0 reference manual was setup with  DOC_MODULE name of
"cogl" which conflicted with the 1.x API manual. This meant that when
running make install for both the reference manuals all the html files
would end up bundled together in the same location. The 2.0 API
reference now has a DOC_MODULE name of "cogl-2.0-experimental" the
corresponding -sections.txt and -docs.xml.in files have also been
renamed to match this.

Signed-off-by: Neil Roberts <neil@linux.intel.com>
2011-07-11 15:40:02 +01:00
Robert Bragg
38b67e2884 onscreen: make platform specific onscreen apis consistent
There were several CoglOnscreen functions named like:
cogl_onscreen_<platform>_blah instead of cogl_<platform>_onscreen_blah
so this patch updates those to be consistent with other platform
specific apis we have in cogl.

Signed-off-by: Neil Roberts <neil@linux.intel.com>
2011-07-11 14:07:01 +01:00
Robert Bragg
94148717aa docs: update cogl-context 2.0 docs
This fixes the 2.0 reference manual Makefile to not ignore
cogl-context.h; it also adds cogl_context_new to cogl-sections.txt and
removes cogl_begin/end_gl. (For using raw GL with Cogl 2.0 the plan was
to add some API for creating additional GL contexts via some Cogl API
and a way to push/pop those contexts.)

Signed-off-by: Neil Roberts <neil@linux.intel.com>
2011-07-04 15:33:31 +01:00
Robert Bragg
a3fa7f5d96 docs: Adds missing cogl_framebuffer syms to reference
This adds a description for the cogl-framebuffer section and adds lots
of missing symbols to the 2.0 reference manual.

Signed-off-by: Neil Roberts <neil@linux.intel.com>
2011-07-04 15:31:50 +01:00
Robert Bragg
d4cd0c3e95 doc: Adds missing cogl_matrix syms to 2.0 reference
There were a few cogl_matrix symbols missing from the cogl-sections.txt
for the 2.0 reference manual.

Signed-off-by: Neil Roberts <neil@linux.intel.com>
2011-07-04 15:31:50 +01:00
Robert Bragg
d74cf9de81 matrix: Adds cogl_matrix_is_identity API
This adds a function called cogl_matrix_is_identity that can determine
if a given matrix is an identity matrix or not.

Signed-off-by: Neil Roberts <neil@linux.intel.com>
2011-07-04 15:31:50 +01:00