Commit Graph

11 Commits

Author SHA1 Message Date
Robert Bragg
983c9f0dc4 cogl-crate: remove spurious cogl_set_depth_test_enabled call
Use of cogl_set_depth_test_enabled() has been deprecated for some time
and cogl-create already uses the new api for enabling depth testing so
it was just an oversight that we forgot to remove the old call to
cogl_set_depth_test_enabled().

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-02-09 13:20:27 +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
Robert Bragg
0365f6cda3 examples: use framebuffer matrix stack apis
Instead of using apis like cogl_push/pop_matrix, cogl_rotate,
cogl_translate and cogl_scale all the examples now use the
cogl_framebuffer_* equivalents. Our aim is to remove the need for the
default CoglContext and so we are switching towards apis that
are explicitly tied to a specific context.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-02-09 13:09:15 +00:00
Robert Bragg
7287dd1faf examples: use cogl_framebuffer_clear4f not cogl_clear
cogl_clear depends on the default CoglContext which we are trying to
steer the API away from requiring. cogl_framebuffer_clear4f is
explicitly passed a framebuffer pointer which is implicitly related to a
specific context.

This updates all the examples to use cogl_framebuffer_clear4f instead of
cogl_clear and removes any redundant CoglColor that was previously
passed to cogl_clear.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-02-09 13:09:15 +00:00
Robert Bragg
cdbc1dc9b1 examples: Remove explicit framebuffer allocations
It used to be that cogl_framebuffer_allocate() had to be done explicitly
but we have since made Cogl lazily allocate framebuffers when they are
first used if they haven't already been explicitly allocated. Developers
only need to explicitly allocate framebuffers if they are planning to
gracefully handle any errors. In cases where the program will simply
abort due to an allocation error they can simply rely on implicit
allocation which will cause an abort on error.

This updates the examples to not explicitly allocate the framebuffers
since they all just abort on error anyway.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-02-09 13:09:15 +00:00
Neil Roberts
e28db24f7d cogl-crate: Optionally use the swap buffers notify mechanism
If the swap buffers notify mechanism is advertised then the crate
example will now register a callback for it and call g_poll with the
proper timeout from cogl_context_begin_idle instead of trying to
repaint continuously.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-01-09 18:59:59 +00:00
Neil Roberts
6731569c18 Update all of the examples to use cogl_poll_get_info
The aim is that it should be a requirement that all Cogl applications
hook their mainloops into Cogl so we should lead by examples. Most of
the examples now just call cogl_poll_get_info and then g_poll with a
zero timeout so that they can continue to constantly redraw.

The SDL example is a bit special because SDL makes it very difficult
to wait on either a timeout or any file descriptors. The SDL winsys is
documented not to require blocking on any file descriptors so we can
ignore that. It implements the timeout by adding an SDL timer which
pushes an event to the queue to wake up SDL_GetEvent.

The Cogland example was already using the glib main loop so that one
has been updated to add the CoglGLibSource to it.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-01-05 13:41:00 +00:00
Rob Bradford
3bf8d45529 examples: Query the size of the framebuffer
The size of the framebuffer may not be the size of the framebuffer that we
requested - we should use the actual size of the framebuffer in the
calculations to position the crate in the center.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-11-14 18:59:52 +00:00
Jasper St. Pierre
5f7cdfed69 crate: Use indices
https://bugzilla.gnome.org/show_bug.cgi?id=661019

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-11-01 12:50:43 +00:00
Neil Roberts
dedee399d6 Rotate according to time not number of frames in the crate example
Previously the crate example incremented the angle of rotation of the
cube every frame so depending on the framerate the cube might rotate
too fast to see. This just changes it to calculate the rotation based
on the elapsed time using a GTimer. The rate that frames are drawn is
unaffected.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-10-17 13:57:29 +01:00
Robert Bragg
7669fdc827 examples: Allow installing of examples
This namespaces all of the examples and marks them for installation
if --enable-examples-install has been passed to ./configure. This
simplifies packaging the examples which can be quite convenient
for smoke testing Cogl on various platform.

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

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2011-10-14 11:55:28 +01:00