Commit Graph

85 Commits

Author SHA1 Message Date
Robert Bragg
d40cdfa3e1 Moves all GLX code down from Clutter to Cogl
This migrates all the GLX window system code down from the Clutter
backend code into a Cogl winsys. Moving OpenGL window system binding
code down from Clutter into Cogl is the biggest blocker to having Cogl
become a standalone 3D graphics library, so this is an important step in
that direction.
2011-04-11 17:54:36 +01:00
Robert Bragg
bcd97f35ea Adds renderer,display,onscreen-template and swap-chain stubs
As part of the process of splitting Cogl out as a standalone graphics
API we need to introduce some API concepts that will allow us to
initialize a new CoglContext when Clutter isn't there to handle that for
us...

The new objects roughly in the order that they are (optionally) involved
in constructing a context are: CoglRenderer, CoglOnscreenTemplate,
CoglSwapChain and CoglDisplay.

Conceptually a CoglRenderer represents a means for rendering.  Cogl
supports rendering via OpenGL or OpenGL ES 1/2.0 and those APIs are
accessed through a number of different windowing APIs such as GLX, EGL,
SDL or WGL and more. Potentially in the future Cogl could render using
D3D or even by using libdrm and directly banging the hardware. All these
choices are wrapped up in the configuration of a CoglRenderer.

Conceptually a CoglDisplay represents a display pipeline for a renderer.
Although Cogl doesn't aim to provide a detailed abstraction of display
hardware, on some platforms we can give control over multiple display
planes (On TV platforms for instance video content may be on one plane
and 3D would be on another so a CoglDisplay lets you select the plane
up-front.)

Another aspect of CoglDisplay is that it lets us negotiate a display
pipeline that best supports the type of CoglOnscreen framebuffers we are
planning to create. For instance if you want transparent CoglOnscreen
framebuffers then we have to be sure the display pipeline wont discard
the alpha component of your framebuffers. Or if you want to use
double/tripple buffering that requires support from the display
pipeline.

CoglOnscreenTemplate and CoglSwapChain are how we describe our default
CoglOnscreen framebuffer configuration which can affect the
configuration of the display pipeline.

The default/simple way we expect most CoglContexts to be constructed
will be via something like:

 if (!cogl_context_new (NULL, &error))
   g_error ("Failed to construct a CoglContext: %s", error->message);

Where that NULL is for an optional "display" parameter and NULL says to
Cogl "please just try to do something sensible".

If you want some more control though you can manually construct a
CoglDisplay something like:

 display = cogl_display_new (NULL, NULL);
 cogl_gdl_display_set_plane (display, plane);
 if (!cogl_display_setup (display, &error))
   g_error ("Failed to setup a CoglDisplay: %s", error->message);

And in a similar fashion to cogl_context_new() you can optionally pass
a NULL "renderer" and/or a NULL "onscreen template" so Cogl will try to
just do something sensible.

If you need to change the CoglOnscreen defaults you can provide a
template something like:
  chain = cogl_swap_chain_new ();
  cogl_swap_chain_set_has_alpha (chain, TRUE);
  cogl_swap_chain_set_length (chain, 3);

  onscreen_template = cogl_onscreen_template_new (chain);
  cogl_onscreen_template_set_pixel_format (onscreen_template,
                                           COGL_PIXEL_FORMAT_RGB565);

  display = cogl_display_new (NULL, onscreen_template);
  if (!cogl_display_setup (display, &error))
    g_error ("Failed to setup a CoglDisplay: %s", error->message);
2011-04-11 17:54:35 +01:00
Robert Bragg
c415818537 cogl: consolidate _create_context_driver + _features_init
This moves the functionality of _cogl_create_context_driver from
driver/{gl,gles}/cogl-context-driver-{gl,gles}.c into
driver/{gl,gles}/cogl-{gl,gles}.c as a static function called
initialize_context_driver.

cogl-context-driver-{gl,gles}.[ch] have now been removed.
2011-04-11 15:26:25 +01:00
Robert Bragg
e9b1ca0165 cogl: Adds experimental cogl_context_new() API
This adds a new experimental function (you need to define
COGL_ENABLE_EXPERIMENTAL_API to access it) which takes us towards being
able to have a standalone Cogl API. This is really a minor aesthetic
change for now since all the GL context creation code still lives in
Clutter but it's a step forward none the less.

Since our current designs introduce a CoglDisplay object as something
that would be passed to the context constructor this provides a stub
cogl-display.h with CoglDisplay typedef.

_cogl_context_get_default() which Clutter uses to access the Cogl
context has been modified to use cogl_context_new() to initialize
the default context.

There is one rather nasty hack used in this patch which is that the
implementation of cogl_context_new() has to forcibly make the allocated
context become the default context because currently all the code in
Cogl assumes it can access the context using _COGL_GET_CONTEXT including
code used to initialize the context.
2011-04-11 15:26:20 +01:00
Robert Bragg
fdbc741770 cogl: rename cogl-context.h cogl-context-private.h
Since we plan to add public cogl_context_* API we need to rename the
current cogl-context.h which contains private member details.
2011-04-11 15:18:12 +01:00
Neil Roberts
c8ddb3b55a cogl-atlas: Try 4 different approaches for migrating textures
Instead of directly banging GL to migrate textures the atlas now uses
the CoglFramebuffer API. It will use one of four approaches; it can
set up two FBOs and use _cogl_blit_framebuffer to copy between them;
it can use a single target fbo and then render the source texture to
the FBO using a Cogl draw call; it can use a single FBO and call
glCopyTexSubImage2D; or it can fallback to reading all of the texture
data back to system memory and uploading it again with a sub texture
update.

Previously GL calls were used directly because Cogl wasn't able to
create a framebuffer without a stencil and depth buffer. However there
is now an internal version of cogl_offscreen_new_to_texture which
takes a set of flags to disable the two buffers.

The code for blitting has now been moved into a separate file called
cogl-blit.c because it has become quite long and it may be useful
outside of the atlas at some point.

The 4 different methods have a fixed order of preference which is:

* Texture render between two FBOs
* glBlitFramebuffer
* glCopyTexSubImage2D
* glGetTexImage + glTexSubImage2D

Once a method is succesfully used it is tried first for all subsequent
blits. The default default can be overridden by setting the
environment variable COGL_ATLAS_DEFAULT_BLIT_MODE to one of the
following values:

* texture-render
* framebuffer
* copy-tex-sub-image
* get-tex-data
2011-02-15 12:10:54 +00:00
Neil Roberts
c4a94439de cogl-debug: Split the flags to support more than 32
The CoglDebugFlags are now stored in an array of unsigned ints rather
than a single variable. The flags are accessed using macros instead of
directly peeking at the cogl_debug_flags variable. The index values
are stored in the enum rather than the actual mask values so that the
enum doesn't need to be more than 32 bits wide. The hope is that the
code to determine the index into the array can be optimized out by the
compiler so it should have exactly the same performance as the old
code.
2011-01-24 15:45:45 +00:00
Robert Bragg
affce86924 cogl: make sure to init ctx->framebuffers
This makes sure to initialize ctx->framebuffers to NULL otherwise we can
get apps crashing when they create their first framebuffer.
2011-01-21 17:28:34 +00: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
1a5a4df326 journal: Support per-framebuffer journals
Instead of having a single journal per context, we now have a
CoglJournal object for each CoglFramebuffer. This means we now don't
have to flush the journal when switching/pushing/popping between
different framebuffers so for example a Clutter scene that involves some
ClutterEffect actors that transiently redirect to an FBO can still be
batched.

This also allows us to track state in the journal that relates to the
current frame of its associated framebuffer which we'll need for our
optimization for using the CPU to handle reading a single pixel back
from a framebuffer when we know the whole scene is currently comprised
of simple rectangles in a journal.
2011-01-21 16:18:10 +00:00
Neil Roberts
a8216aff2f cogl: Fallback to set_data when mapping a buffer to fill it
In the journal code and when generating the stroke path the vertices
are generated on the fly and stored in a CoglBuffer using
cogl_buffer_map. However cogl_buffer_map is allowed to fail but it
wasn't checking for a NULL return value. In particular on GLES it will
always fail because glMapBuffer is only provided by an extension. This
adds a new pair of internal functions called
_cogl_buffer_{un,}map_for_fill_or_fallback which wrap
cogl_buffer_map. If the map fails then it will instead return a
pointer into a GByteArray attached to the context. When the buffer is
unmapped the array is copied into the buffer using
cogl_buffer_set_data.
2011-01-13 16:36:32 +00:00
Neil Roberts
ac81f3b936 cogl-context: Don't enable point sprites on GLES2
On GLES2 there's no builtin mechanism to replace texture coordinates
with point sprite coordinates so calling glEnable(GL_POINT_SPRITE)
isn't valid. Instead the point sprite coords are implemented by using
a special builtin varying variable in GLSL.
2011-01-13 14:26:03 +00:00
Neil Roberts
9aea72fab5 Allow multiple CoglAtlases for textures
Previously Cogl would only ever use one atlas for textures and if it
reached the maximum texture size then all other new textures would get
their own GL texture. This patch makes it so that we create as many
atlases as needed. This should avoid breaking up some batches and it
will be particularly good if we switch to always using multi-texturing
with a default shader that selects between multiple atlases using a
vertex attribute.

Whenever a new atlas is created it is stored in a GSList on the
context. A weak weference is taken on the atlas using
cogl_object_set_user_data so that it can be removed from the list when
the atlas is destroyed. The atlas textures themselves take a reference
to the atlas and this is the only thing that keeps the atlas
alive. This means that once the atlas becomes empty it will
automatically be destroyed.

All of the COGL_NOTEs pertaining to atlases are now prefixed with the
atlas pointer to make it clearer which atlas is changing.
2010-12-13 18:59:41 +00:00
Neil Roberts
0f0f763570 cogl-atlas: Convert to be a CoglObject subclass
To implement multiple atlases it will be useful to have ref-counting
on the CoglAtlas so it makes sense to convert it to be a CoglObject.
2010-12-13 18:59:41 +00:00
Neil Roberts
dc1f1949d0 Remove the GLES2 wrapper
The GLES2 wrapper is no longer needed because the shader generation is
done within the GLSL fragend and vertend and any functions that are
different for GLES2 are now guarded by #ifdefs.
2010-12-13 17:29:14 +00:00
Neil Roberts
a05c701e6b cogl: upload matrices with uniforms on GLES2
Once the GLES2 wrapper is removed we won't be able to upload the
matrices with the fixed function API any more. The fixed function API
gives a global state for setting the matrix but if a custom shader
uniform is used for the matrices then the state is per
program. _cogl_matrix_stack_flush_to_gl is called in a few places and
it is assumed the current pipeline doesn't need to be flushed before
it is called. To allow these semantics to continue to work, on GLES2
the matrix flush now just stores a reference to the matrix stack in
the CoglContext. A pre_paint virtual is added to the progend which is
called whenever a pipeline is flushed, even if the same pipeline was
flushed already. This gives the GLSL progend a chance to upload the
matrices to the uniforms. The combined modelview/projection matrix is
only calculated if it is used. The generated programs end up never
using the modelview or projection matrix so it usually only has to
upload the combined matrix. When a matrix stack is flushed a reference
is taked to it by the pipeline progend and the age is stored so that
if the same state is used with the same program again then we don't
need to reupload the uniform.
2010-12-13 17:29:13 +00:00
Neil Roberts
e38e9e0355 cogl-vertex-attribute: Use glVertexAttribPointer on GLES2
When the GLES2 wrapper is removed we can't use the fixed function API
such as glColorPointer to set the builtin attributes. Instead the GLSL
progend now maintains a cache of attribute locations that are queried
with glGetAttribLocation. The code that previously maintained a cache
of the enabled texture coord arrays has been modified to also cache
the enabled vertex attributes under GLES2. The vertex attribute API is
now the only place that is using this cache so it has been moved into
cogl-vertex-attribute.c
2010-12-13 17:28:29 +00:00
Neil Roberts
fa13f6c107 cogl: Add a vertend to generate GLSL
The GLSL vertend is mostly only useful for GLES2. The fixed function
vertend is kept at higher priority than the GLSL vertend so it is
unlikely to be used in any other circumstances.
2010-12-13 17:28:28 +00:00
Neil Roberts
0c732c27ae cogl-pipeline: Rename the fragment_{source,header}_buffer to codegen
We want to reuse the same buffers for vertends so calling them
fragment_* doesn't make sense.
2010-12-13 17:22:57 +00:00
Neil Roberts
0098dc7acc Rename CoglPipelineBackend to CoglPipelineFragend
The current Cogl pipeline backends are entirely concerned with the
fragment processing state. We also want to eventually have separate
backends to generate shaders for the vertex processing state so we
need to rename the fragment backends. 'Fragend' is a somewhat weird
name but we wanted to avoid ending up with illegible symbols like
CoglPipelineFragmentBackendGlslPrivate.
2010-12-13 17:22:57 +00:00
Robert Bragg
19562fc972 context: only declare arbfp cache for GL
We were trying to declare and initializing an arbfp program cache for
GLES but since the prototypes for the _hash and _equal functions were
only available for GL this broke the GLES builds. By #ifdefing the code
to conditionally declare/initialize for GL only this should hopefully
fix GLES builds.
2010-12-07 16:47:02 +00:00
Robert Bragg
0087910574 arbfp: Adds an ARBfp program cache
This adds a cache (A GHashTable) of ARBfp programs and before ever
starting to code-generate a new program we will always first try and
find an existing program in the cache. This uses _cogl_pipeline_hash and
_cogl_pipeline_equal to hash and compare the keys for the cache.

There is a new COGL_DEBUG=disable-program-caches option that can disable
the cache for debugging purposes.
2010-12-07 16:00:32 +00:00
Robert Bragg
046434e222 pipeline: Implements _cogl_pipeline_hash function
This allows us to get a hash for a set of state groups for a given
pipeline. This can be used for example to get a hash of the fragment
processing state of a pipeline so we can implement a cache for compiled
arbfp/glsl programs.
2010-12-07 16:00:32 +00:00
Neil Roberts
1d88e6c8ac cogl-journal: Attempt to clip manually to avoid breaking up batches
Before flushing the journal there is now a separate iteration that
will try to determine if the matrix of the clip stack and the matrix
of the rectangle in each entry are on the same plane. If they are it
can completely avoid the clip stack and instead manually modify the
vertex and texture coordinates to implement the clip. The has the
advantage that it won't break up batching if a single clipped
rectangle is used in a scene.

The software clip is only used if there is no user program and no
texture matrices. There is a threshold to the size of the batch where
it is assumed that it is worth the cost to break up a batch and
program the GPU to do the clipping. Currently this is set to 8
although this figure is plucked out of thin air.

To check whether the two matrices are on the same plane it tries to
determine if one of the matrices is just a simple translation of the
other. In the process of this it also works out what the translation
would be. These values can be used to translate the clip rectangle
into the coordinate space of the rectangle to be logged. Then we can
do the clip directly in the rectangle's coordinate space.
2010-12-03 17:16:58 +00:00
Neil Roberts
f8449582c8 Revert "cogl: Remove the generated array size for cogl_tex_coord_in"
This reverts commit 4cfe90bde2.

GLSL 1.00 on GLES doesn't support unsized arrays so the whole idea
can't work.

Conflicts:

	clutter/cogl/cogl/cogl-pipeline-glsl.c
2010-12-03 15:27:17 +00:00
Neil Roberts
6607306a2d cogl: Remove the generated array size for cogl_tex_coord_in
Under GLES2 we were defining the cogl_tex_coord_in varying as an array
with a size determined by the number of texture coordinate arrays
enabled whenever the program is used. This meant that we may have to
regenerate the shader with a different size if the shader is used with
more texture coord arrays later. However in OpenGL the equivalent
builtin varying gl_TexCoord is simply defined as:

varying vec4 gl_TexCoord[]; /* <-- no size */

GLSL is documented that if you declare an array with no size then you
can only access it with a constant index and the size of the array
will be determined by the highest index used. If you want to access it
with a non-constant expression you need to redeclare the array
yourself with a size.

We can replicate the same behaviour in our Cogl shaders by instead
declaring the cogl_tex_coord_in with no size. That way we don't have
to pass around the number of tex coord attributes enabled when we
flush a material. It also means that CoglShader can go back to
directly uploading the source string to GL when cogl_shader_source is
called so that we don't have to keep a copy of it around.

If the user wants to access cogl_tex_coord_in with a non-constant
index then they can simply redeclare the array themself. Hopefully
developers will expect to have to do this if they are accustomed to
the gl_TexCoord array.
2010-12-02 12:27:29 +00:00
Neil Roberts
7474d320f6 cogl-context: Get rid of the features_cached member
The features_cached member of CoglContext is intended to mark when
we've calculated the features so that we know if they are ready in
cogl_get_features. However we always intialize the features while
creating the context so features_cached will never be FALSE so it's
not useful. We also had the odd behaviour that the COGL_DEBUG feature
overrides were only applied in the first call to
cogl_get_features. However there are other functions that use the
feature flags such as cogl_features_available that don't use this
function so in some cases the feature flags will be interpreted before
the overrides are applied. This patch makes it always initialize the
features and apply the overrides immediately while creating the
context. This fixes a problem with COGL_DEBUG=disable-arbfp where the
first material flushed is done before any call to cogl_get_features so
it may still use ARBfp.
2010-11-24 18:39:07 +00:00
Neil Roberts
7da3610e82 Generate GLSL in the CoglPipeline GLSL backend
The GLSL pipeline backend can now generate code to represent the
pipeline state in a similar way to the ARBfp backend. Most of the code
for this is taken from the GLES 2 wrapper.
2010-11-24 18:06:43 +00:00
Neil Roberts
7379a5fc04 cogl: Rename arbfp_source_buffer to fragment_source_buffer
Only one of the material backends can be generating code at the same
time so it seems to make sense to share the same source buffer between
arbfp and glsl. The new name is fragment_source_buffer in case we
later want to create a new buffer for the vertex shader. That probably
couldn't share the same buffer because it will likely need to be
generated at the same time.
2010-11-24 18:06:43 +00:00
Robert Bragg
cce8645aba path 2.0: update path API for experimental 2.0 API
When COGL_ENABLE_EXPERIMENTAL_2_0_API is defined cogl.h will now include
cogl2-path.h which changes cogl_path_new() so it can directly return a
CoglPath pointer; it no longer exposes a prototype for
cogl_{get,set}_path and all the remaining cogl_path_ functions now take
an explicit path as their first argument.

The idea is that we want to encourage developers to retain path objects
for as long as possible so they can take advantage of us uploading the
path geometry to the GPU. Currently although it is possible to start a
new path and query the current path, it is not convenient.

The other thing is that we want to get Cogl to the point where nothing
depends on a global, current context variable. This will allow us to one
day define a sensible threading model if/when that is ever desired.
2010-11-11 13:17:26 +00:00
Robert Bragg
353ea5299b cogl-shader: Prepend boilerplate for portable shaders
We now prepend a set of defines to any given GLSL shader so that we can
define builtin uniforms/attributes within the "cogl" namespace that we
can use to provide compatibility across a range of the earlier versions
of GLSL.

This updates test-cogl-shader-glsl.c and test-shader.c so they no longer
needs to special case GLES vs GL when splicing together its shaders as
well as the blur, colorize and desaturate effects.

To get a feel for the new, portable uniform/attribute names here are the
defines for OpenGL vertex shaders:

 #define cogl_position_in gl_Vertex
 #define cogl_color_in gl_Color
 #define cogl_tex_coord_in  gl_MultiTexCoord0
 #define cogl_tex_coord0_in gl_MultiTexCoord0
 #define cogl_tex_coord1_in gl_MultiTexCoord1
 #define cogl_tex_coord2_in gl_MultiTexCoord2
 #define cogl_tex_coord3_in gl_MultiTexCoord3
 #define cogl_tex_coord4_in gl_MultiTexCoord4
 #define cogl_tex_coord5_in gl_MultiTexCoord5
 #define cogl_tex_coord6_in gl_MultiTexCoord6
 #define cogl_tex_coord7_in gl_MultiTexCoord7
 #define cogl_normal_in gl_Normal

 #define cogl_position_out gl_Position
 #define cogl_point_size_out gl_PointSize
 #define cogl_color_out gl_FrontColor
 #define cogl_tex_coord_out gl_TexCoord

 #define cogl_modelview_matrix gl_ModelViewMatrix
 #define cogl_modelview_projection_matrix gl_ModelViewProjectionMatrix
 #define cogl_projection_matrix gl_ProjectionMatrix
 #define cogl_texture_matrix gl_TextureMatrix

And for fragment shaders we have:

 #define cogl_color_in gl_Color
 #define cogl_tex_coord_in gl_TexCoord

 #define cogl_color_out gl_FragColor
 #define cogl_depth_out gl_FragDepth

 #define cogl_front_facing gl_FrontFacing
2010-11-10 14:24:52 +00:00
Maxim Ermilov
ff8130101a CoglContext: correct initialization order
http://bugzilla.clutter-project.org/show_bug.cgi?id=2401
2010-11-06 18:06:19 +00:00
Robert Bragg
e5eff5fc89 cogl: add separate material for blended source_colors
When using cogl_set_source_color4ub there is a notable difference
between colors that require blending and those that dont. When trying to
modify the color of pipeline referenced by the journal we don't force a
flush of the journal unless the color change will also change the
blending state. By using two separate pipeline objects for handing
opaque or transparent colors we can avoid ever flushing the journal when
repeatedly using cogl_set_source_color and jumping between opaque and
transparent colors.
2010-11-04 18:22:40 +00:00
Neil Roberts
0c8eb904c0 cogl: Move the clip stack dirtiness to the context rather than the FB
Previously we tracked whether the clip stack needs flushing as part of
the CoglClipState which is part of the CoglFramebuffer state. This is
a bit odd because most of the clipping state (such as the clip planes
and the scissor) are part of the GL context's state rather than the
framebuffer. We were marking the clip state on the framebuffer dirty
every time we change the framebuffer anyway so it seems to make more
sense to have the dirtiness be part of the global context.

Instead of a just a single boolean to record whether the state needs
flushing, the CoglContext now holds a reference to the clip stack that
was flushed. That way we can flush arbitrary stack states and if it
happens to be the same as the state already flushed then Cogl will do
nothing. This will be useful if we log the clip stack in the journal
because then we will need to flush unrelated clip stack states for
each batch.
2010-11-04 18:08:27 +00:00
Robert Bragg
f80cb197a9 cogl: rename CoglMaterial -> CoglPipeline
This applies an API naming change that's been deliberated over for a
while now which is to rename CoglMaterial to CoglPipeline.

For now the new pipeline API is marked as experimental and public
headers continue to talk about materials not pipelines. The CoglMaterial
API is now maintained in terms of the cogl_pipeline API internally.
Currently this API is targeting Cogl 2.0 so we will have time to
integrate it properly with other upcoming Cogl 2.0 work.

The basic reasons for the rename are:
- That the term "material" implies to many people that they are
  constrained to fragment processing; perhaps as some kind of high-level
  texture abstraction.
    - In Clutter they get exposed by ClutterTexture actors which may be
      re-inforcing this misconception.
- When comparing how other frameworks use the term material, a material
  sometimes describes a multi-pass fragment processing technique which
  isn't the case in Cogl.
- In code, "CoglPipeline" will hopefully be a much more self documenting
  summary of what these objects represent; a full GPU pipeline
  configuration including, for example, vertex processing, fragment
  processing and blending.
- When considering the API documentation story, at some point we need a
  document introducing developers to how the "GPU pipeline" works so it
  should become intuitive that CoglPipeline maps back to that
  description of the GPU pipeline.
- This is consistent in terminology and concept to OpenGL 4's new
  pipeline object which is a container for program objects.

Note: The cogl-material.[ch] files have been renamed to
cogl-material-compat.[ch] because otherwise git doesn't seem to treat
the change as a moving the old cogl-material.c->cogl-pipeline.c and so
we loose all our git-blame history.
2010-11-03 18:09:23 +00:00
Robert Bragg
44644d0a9e primitives: implements cogl_polygon on vertex_attributes
This updates the implementation of cogl_polygon so it sits on the new
CoglVertexArray and CoglVertexAttribute apis. This lets us minimize the
number of different drawing paths we have to maintain in Cogl.

Since the sliced texture support for cogl_polygon has been broken for a
long time now and no one has complained this patch also greatly
simplifies the code by not doing any special material validation so
cogl_polygon will be restricted in the same way as
cogl_draw_vertex_attributes. (i.e. sliced textures not supported).
2010-11-03 18:09:22 +00:00
Robert Bragg
37657a5dd8 journal: port to the vertex_attributes API
Instead of using raw OpenGL in the journal we now use the vertex
attributes API instead. This is part of an ongoing effort to reduce the
number of drawing paths we maintain in Cogl.
2010-11-03 18:09:22 +00:00
Robert Bragg
afb8a64bc4 vertex-buffer: use cogl_get_rectangle_indices
The functionality of cogl_vertex_buffer_indices_get_for_quads is now
provided by cogl_get_rectangle_indices so this reworks the former to now
work in terms of the latter so we don't have duplicated logic.
2010-11-03 18:09:22 +00:00
Robert Bragg
6e620e94b6 cogl: Adds experimental CoglIndices API
CoglIndices define a range of indices inside a CoglIndexArray. I.e. a
CoglIndexArray is simply a buffer of N bytes and you can then
instantiate multiple CoglIndices collections that define a sub-region of
a CoglIndexArray by specifying a start offset and an index data type.
2010-11-03 18:04:00 +00:00
Neil Roberts
7ab928a4e0 cogl: Use separate materials for set_source_color and texture
Previously cogl_set_source_color and cogl_set_source_texture modified
a single global material. If an application then mixes using
cogl_set_source_color and texture then the material will constantly
need a new ARBfp program because the numbers of layers alternates
between 0 and 1. This patch just adds a second global material that is
only used for cogl_set_source_texture. I think it would still end up
flushing the journal if cogl_set_source_texture is used with multiple
different textures but at least it should avoid a recompile unless the
texture target also changes. It might be nice to somehow attach a
material to the CoglTexture for use with cogl_set_source_texture but
it would be difficult to implement this without creating a circular
reference.
2010-10-27 15:07:03 +01:00
Robert Bragg
1b9a247174 cogl: Adds {push,pop,get}_source functions
This exposes the idea of a stack of source materials instead of just
having a single current material. This allows the writing of orthogonal
code that can change the current source material and restore it to its
previous state. It also allows the implementation of new composite
primitives that may want to validate the current source material and
possibly make override changes in a derived material.
2010-10-26 12:08:20 +01:00
Robert Bragg
eabce897dc Initialize the cogl uprof state in cogl_create_context
This avoids the use of of gcc constructor and destructor attributes to
initialize the cogl uprof context and optionally print a cogl uprof
report at app exit. We now initialize the uprof context in
cogl_context_create instead.
2010-09-14 12:43:17 +01:00
Neil Roberts
b2f2e69264 cogl-atlas-texture: Split out the atlas data structure
Instead of storing a pointer to the CoglRectangleMap and a handle to
the atlas texture in the context, there is a now a separate data
structure called a CoglAtlas to manage these two. The context just
contains a pointer to this. The code to reorganise the atlas has been
moved from cogl-atlas-texture.c to cogl-atlas.c
2010-08-12 11:56:59 +01:00
Neil Roberts
bc20010582 cogl-atlas: Rename to CoglRectangleMap
This simply renames CoglAtlas to CoglRectangleMap without making any
functional changes. The old 'CoglAtlas' is just a data structure for
managing unused areas of a rectangle and it doesn't neccessarily have
to be used for an atlas so it wasn't a very good name.
2010-08-12 11:54:42 +01:00
Robert Bragg
5442e429ba material: split the texture unit management out
In general cogl-material.c has become far to large to manage in one
source file. As one of the ways to try and break it down this patch
starts to move some of lower level texture unit state management out
into cogl-material-opengl.c. The naming is such because the plan is to
follow up and migrate the very GL specific state flushing code into the
same file.
2010-07-13 19:26:58 +01:00
Neil Roberts
da3be3df6b cogl-material: Add support for point sprites
This adds a new API call to enable point sprite coordinate generation
for a material layer:

void
cogl_material_set_layer_point_sprite_coords_enabled (CoglHandle material,
                                                     int layer_index,
                                                     gboolean enable);

There is also a corresponding get function.

Enabling point sprite coords simply sets the GL_COORD_REPLACE of the
GL_POINT_SPRITE glTexEnv when flusing the material. There is no
separate application control for glEnable(GL_POINT_SPRITE). Instead it
is left permanently enabled under the assumption that it has no affect
unless GL_COORD_REPLACE is enabled for a texture unit.

http://bugzilla.openedhand.com/show_bug.cgi?id=2047
2010-07-08 16:34:30 +01:00
Neil Roberts
06b58baa10 cogl-material: Add a property for setting the point size
This adds cogl_material_{get,set}_point_size. If the point size is not
1.0f then glPointSize will be called when the material is flushed.

http://bugzilla.openedhand.com/show_bug.cgi?id=2047
2010-07-08 16:34:30 +01:00
Robert Bragg
8098052d56 material: route fogging state through CoglMaterial
Previously cogl_set_fog would cause a flush of the Cogl journal and
would directly bang the GL state machine to setup fogging. As part of
the ongoing effort to track most state in CoglMaterial to support
renderlists this now adds an indirection so that cogl_set_fog now just
updates ctx->legacy_fog_state. The fogging state then gets enabled as a
legacy override similar to how the old depth testing API is handled.
2010-07-07 14:12:15 +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
9ceb0edf26 cogl-buffer: Handle subclass registration like cogl-texture
Instead of having to extend cogl_is_buffer with new buffer types
manually this now adds a new COGL_BUFFER_DEFINE macro to be used instead
of COGL_OBJECT_DEFINE for CoglBuffer subclasses. This macro will
automatically register the new type with ctx->buffer_types which will
iterated by cogl_is_buffer. This is the same coding pattern used for
CoglTexture.
2010-07-05 15:20:03 +01:00