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>
when printing a matrix we aim to print out the matrix type but we
weren't checking the flags first to see if the type is valid. We now
check for the DIRTY_TYPE flag and if not set we also validate the matrix
type isn't out of range.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
In cogl_matrix_look_at we have a tmp CoglMatrix allocated on the stack
but we weren't initializing its flags before passing it to
cogl_matrix_translate which meant if we were using COGL_DEBUG=matrices
we would end up trying to print out an invalid matrix type resulting in
a crash when overrunning an array of type names.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
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>
It could be nice to extend this as Cogl gains more APIs for
introspecting its own features but for now cogl-info just uses the new
cogl_foreach_feature() API to enumerate the available features for
a default context and prints those to the terminal.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
This adds COGL_PIPELINE_WRAP_MODE_MIRRORED_REPEAT enum so that mirrored
texture repeating can be used. This also adds support for emulating the
MIRRORED_REPEAT mode via the cogl-spans API so it can also be used with
meta textures such as sliced and atlas textures.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
CoglMetaTexture is an interface for dealing with high level textures
that may be comprised of one or more low-level textures internally. The
interface allows the development of primitive drawing APIs that can draw
with high-level textures (such as atlas textures) even though the
GPU doesn't natively understand these texture types.
There is currently just one function that's part of this interface:
cogl_meta_texture_foreach_in_region() which allows an application to
resolve the internal, low-level textures of a high-level texture.
cogl_rectangle() uses this API for example so that it can easily emulate
the _REPEAT wrap mode for textures that the hardware can't natively
handle repeating of.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
Instead of using integers to represent spans we now use floats instead.
This means we are no longer forced to iterate using non-normalized
coordinates so we should hopefully be able to avoid numerous redundant
unnormalize/normalize steps when using the spans api.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
Since we can assume that all slices are CoglTexture2D textures we don't
need to chain on our implementation of _foreach_sub_texture_in_region
by calling _cogl_texture_foreach_sub_texture_in_region() for each slice.
We now simply determine the normalized virtual coordinates for the
current span inline and call the given callback inline too.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
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>
Cogl provides a consistent public interface regardless of whether the
underlying GL driver supports VBOs so it doesn't make much sense to have
this feature as part of the public api. We can't break the api by
removing the enum but at least we no longer ever set the feature flag.
We now have a replacement private feature flag COGL_PRIVATE_FEATURE_VBOS
which cogl now checks for internally.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
Cogl provides a consistent public interface regardless of whether the
underlying GL driver supports PBOs so it doesn't make much sense to have
this feature as part of the public api. We can't break the api by
removing the enum but at least we no longer ever set the feature flag.
We now have a replacement private feature flag COGL_PRIVATE_FEATURE_PBOS
which cogl now checks for internally.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
Cogl doesn't currently expose public api for clip planes so it
doesn't make much sense to have this feature as part of the public api.
We can't break the api by removing the enum but at least we no longer
ever set the feature flag.
We now have a replacement private feature flag
COGL_PRIVATE_FEATURE_FOUR_CLIP_PLANES which cogl now checks for
internally.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
Cogl doesn't expose public api for blitting between framebuffers so it
doesn't make much sense to have this feature as part of the public api
currently. We can't break the api by removing the enum but at least we
no longer ever set the feature flag.
We now have a replacement private feature flag
COGL_PRIVATE_FEATURE_OFFSCREEN_BLIT which cogl now checks for
internally.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
Although we have to leave the COGL_FEATURE_STENCIL_BUFFER enum as part
of the public api we no longer ever set this feature flag.
Cogl doesn't currently expose the concept of a stencil buffer in the
public api (we only indirectly expose it via the clip stack api) so it
doesn't make much sense to have a stencil buffer feature flag.
We now have a COGL_PRIVATE_FEATURE_STENCIL_BUFFER flag instead which
we can check when we need to use the buffer for clipping.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
Actual support for yuv textures isn't fully plumbed into Cogl currently
so the check for GL_MESA_ycbcr_texture is meaningless. For now we just
remove the check.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
make sure to #include "cogl-texture-private.h" in cogl-pipeline-layer.c
otherwise the build fails on win32.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
This fixes validate_first_layer_cb so that it update the override
pipeline not the user's original pipeline. It also makes the check
for when to override the wrap mode more robust by considering that
we might add more wrap modes in the future.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
To save users of the api having to manually check if each iterated span
intersects the region of interest we now guarantee that any span
iterated implicitly intersects the region of interest.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
This make the CoglTexture2DSliced type public and adds
cogl_texture_2d_sliced_new_with_size() as an experimental API that can
be used to construct a sliced texture without any initial data.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
This adds a new experimental function, cogl_clip_push_primitive, that
allows you to push a CoglPrimitive onto the clip stack. The primitive
should describe a flat 2D shape and the geometry shouldn't include any
self intersections. When pushing a primitive you also need to tell
Cogl what the bounding box of that shape is (in shape local coordinates)
so that Cogl is able to efficiently update the required region of the
stencil buffer.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
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>
The code that adds the silhouette of a path to the stencil buffer was
living in cogl2-path.c which seemed out of place when the bulk of the
work really related more to how the stencil buffer is managed and
basically only one line (a call to _cogl_path_fill_nodes) really related
to the path code directly.
This moves the code into cogl-clip-stack.c alone with similar code
that can add rectangle masks to the stencil buffer.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
If we are asked to fill a path using any sliced textures then we need
to fallback to adding a mask of the path to the stencil buffer
and then drawing a bounding rectangle with the source textures instead.
Previously we were sharing some of the clip-stack code for adding
the path mask to the stencil buffer and being careful to check
that the current clip stack has been flushed already. We then made
sure to dirty the clip stack to be sure the path mask would be cleared
from the stencil buffer later.
This patch aims to simplify how this fallback is dealt with by just
using the public clipping API instead of relying on more fiddly tricks
to modify the stencil buffer directly without conflicting with the clip
stack.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
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>
This adds a very basic test of onscreen and offscreen multisample
rendering with 4 samples per pixel. The test simply draws two triangles;
the one on the left is rendered directly to the onscreen framebuffer and
the other is first rendered offscreen before copying it onscreen.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
This adds support for multisample rendering to offscreen framebuffers.
After an offscreen framebuffer is first instantiated using
cogl_offscreen_new_to_texture() it is then possible to use
cogl_framebuffer_set_samples_per_pixel() to request multisampling before
the framebuffer is allocated. This also adds
cogl_framebuffer_resolve_samples() for explicitly resolving point
samples into pixels. Even though we currently only support the
IMG_multisampled_render_to_texture extension which doesn't require an
explicit resolve, the plan is to also support the
EXT_framebuffer_multisample extension which uses the framebuffer_blit
extension to issue an explicit resolve.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
This adds support for multisample based rendering of onscreen windows
whereby multiple point samples per pixel can be requested and if the
hardware supports that it results in reduced aliasing (especially
considering the jagged edges of polygons)
Reviewed-by: Neil Roberts <neil@linux.intel.com>
When creating new onscreen framebuffers we need to take the
configuration in cogl terms and translate that into a configuration
applicable to any given winsys, e.g. an EGLConfig or a GLXFBConfig
or a PIXELFORMATDESCRIPTOR.
Also when we first create a context we typically have to do a very
similar thing because most OpenGL winsys APIs also associate a
framebuffer config with the context and all future configs need to be
compatible with that.
This patch introduces an internal CoglFramebufferConfig to wrap up some
of the configuration parameters that are common to CoglOnscreenTemplate
and to CoglFramebuffer so we aim to re-use code when dealing with the
above two problems.
This patch also aims to rework the winsys code so it can be more
naturally extended as we start adding more configureability to how
onscreen framebuffers are created.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
This adds cogl_framebuffer_discard_buffers API that allows applications
to explicitly discard depth and stencil buffers which really helps when
using a tile based GPU architexture by potentially avoiding the need to
save the results of depth and stencil buffer changes to system memory
between frames since these can usually be handled directly with on-chip
memory instead.
The semantics for cogl_framebuffer_swap_buffers and
cogl_framebuffer_swap_region are now documented to include an implicit
discard of all buffers, including the color buffer.
We now recommend that all rendering to a CoglOffscreen framebuffer
should be followed by a call like:
cogl_framebuffer_discard_buffers (fb,
COGL_BUFFER_BIT_DEPTH|
COGL_BUFFER_BIT_STENCIL);
Reviewed-by: Neil Roberts <neil@linux.intel.com>
Most of the conformance tests read a pixel value and assert that it
matches a known value. However they were all doing this with slightly
different methods. This adds a common test_utils_check_pixel function
which they now all use. The function takes an x and y coordinate and a
32-bit value representing the color. It is assumed that writing a
known color is most convenient as an 8 digit hex sequence which this
function allows. There is also a test_utils_check_pixel_rgb function
wrapper which takes the components as separate arguments. This is more
convenient when the expected color is also calculated by the test.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
Both the GLSL and the ARBfp pipeline backends were using a variable
called last_used_for_pipeline to keep track of the last pipeline that
the shader or program state was used for. If this address is the same
as last time when the pipeline state is flushed then Cogl will only
flush the uniforms that have been modified, otherwise it will flush
all of them. The problem with this is that there was nothing to keep
that address alive so it could be destroyed and reused for a different
pipeline by the time the shader state is reused. This is quite likely
to happen in an application using legacy state because in that case
the shader state will always be used with a one-shot pipeline that
will likely be recycled in the next frame.
There is already a destroy callback to unref the shader state when the
pipeline is destroyed so this patch just makes that callback also
clear the last_used_for_pipeline pointer if it matches the pipeline
being destroyed.
https://bugzilla.gnome.org/show_bug.cgi?id=662542
Reviewed-by: Robert Bragg <robert@linux.intel.com>
This adds a description of the replacement Cogl names for the GLSL
builtins. It also updates some of the deprecation tags and corrects
some misinformation.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
Previously the EGL backend was directly prodding the width/height
members of the framebuffer structure when a configure notify event is
received. However this doesn't set the dirty flag for the viewport so
Cogl will continue using the wrong viewport y offset. The GLX backend
is already using an abstraction for updating the size which does set
the flag. This patch just makes the EGL backend also use that
abstraction.
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>
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>
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>
When freeing a pipeline in _cogl_pipeline_free we weren't making sure to
free the layers_cache which was leading to a memory leak.
Thanks to Sunjin Yang for finding this.
https://bugzilla.gnome.org/show_bug.cgi?id=660986
Reviewed-by: Neil Roberts <neil@linux.intel.com>