Use all core GL functions through indirect pointers
cogl-ext-functions.h now contains definitions for all of the core GL and GLES functions that we would normally link to directly. All of the code has changed to access them through the cogl context pointer. The GE macro now takes an extra parameter to specify the context because the macro itself needs to make GL calls but various points in the Cogl source use different names for the context variable.
This commit is contained in:
parent
dae02a99a5
commit
2b119b07da
@ -47,30 +47,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#if defined (HAVE_COGL_GL)
|
#if ! defined (HAVE_COGL_GL)
|
||||||
|
|
||||||
#define glGenBuffers ctx->glGenBuffers
|
|
||||||
#define glBindBuffer ctx->glBindBuffer
|
|
||||||
#define glBufferData ctx->glBufferData
|
|
||||||
#define glBufferSubData ctx->glBufferSubData
|
|
||||||
#define glGetBufferSubData ctx->glGetBufferSubData
|
|
||||||
#define glDeleteBuffers ctx->glDeleteBuffers
|
|
||||||
#define glMapBuffer ctx->glMapBuffer
|
|
||||||
#define glUnmapBuffer ctx->glUnmapBuffer
|
|
||||||
#define glClientActiveTexture ctx->glClientActiveTexture
|
|
||||||
#ifndef GL_ARRAY_BUFFER
|
|
||||||
#define GL_ARRAY_BUFFER GL_ARRAY_BUFFER_ARB
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define glVertexAttribPointer ctx->glVertexAttribPointer
|
|
||||||
#define glEnableVertexAttribArray ctx->glEnableVertexAttribArray
|
|
||||||
#define glDisableVertexAttribArray ctx->glDisableVertexAttribArray
|
|
||||||
#define MAY_HAVE_PROGRAMABLE_GL
|
|
||||||
|
|
||||||
#define glDrawRangeElements(mode, start, end, count, type, indices) \
|
|
||||||
ctx->glDrawRangeElements (mode, start, end, count, type, indices)
|
|
||||||
|
|
||||||
#else /* GLES 1/2 */
|
|
||||||
|
|
||||||
/* GLES doesn't have glDrawRangeElements, so we simply pretend it does
|
/* GLES doesn't have glDrawRangeElements, so we simply pretend it does
|
||||||
* but that it makes no use of the start, end constraints: */
|
* but that it makes no use of the start, end constraints: */
|
||||||
@ -433,23 +410,23 @@ toggle_enabled_cb (int bit_num, void *user_data)
|
|||||||
const CoglBitmask *new_values = user_data;
|
const CoglBitmask *new_values = user_data;
|
||||||
gboolean enabled = _cogl_bitmask_get (new_values, bit_num);
|
gboolean enabled = _cogl_bitmask_get (new_values, bit_num);
|
||||||
|
|
||||||
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
#ifdef HAVE_COGL_GLES2
|
#ifdef HAVE_COGL_GLES2
|
||||||
|
|
||||||
if (enabled)
|
if (enabled)
|
||||||
GE( glEnableVertexAttribArray (bit_num) );
|
GE( ctx, glEnableVertexAttribArray (bit_num) );
|
||||||
else
|
else
|
||||||
GE( glDisableVertexAttribArray (bit_num) );
|
GE( ctx, glDisableVertexAttribArray (bit_num) );
|
||||||
|
|
||||||
#else /* HAVE_COGL_GLES2 */
|
#else /* HAVE_COGL_GLES2 */
|
||||||
|
|
||||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
GE( ctx, glClientActiveTexture (GL_TEXTURE0 + bit_num) );
|
||||||
|
|
||||||
GE( glClientActiveTexture (GL_TEXTURE0 + bit_num) );
|
|
||||||
|
|
||||||
if (enabled)
|
if (enabled)
|
||||||
GE( glEnableClientState (GL_TEXTURE_COORD_ARRAY) );
|
GE( ctx, glEnableClientState (GL_TEXTURE_COORD_ARRAY) );
|
||||||
else
|
else
|
||||||
GE( glDisableClientState (GL_TEXTURE_COORD_ARRAY) );
|
GE( ctx, glDisableClientState (GL_TEXTURE_COORD_ARRAY) );
|
||||||
|
|
||||||
#endif /* HAVE_COGL_GLES2 */
|
#endif /* HAVE_COGL_GLES2 */
|
||||||
}
|
}
|
||||||
@ -619,7 +596,8 @@ enable_gl_state (CoglDrawFlags flags,
|
|||||||
_cogl_pipeline_progend_glsl_get_color_attribute (source);
|
_cogl_pipeline_progend_glsl_get_color_attribute (source);
|
||||||
if (attrib_location != -1)
|
if (attrib_location != -1)
|
||||||
{
|
{
|
||||||
GE( glVertexAttribPointer (attrib_location,
|
GE( ctx,
|
||||||
|
glVertexAttribPointer (attrib_location,
|
||||||
attribute->n_components,
|
attribute->n_components,
|
||||||
attribute->type,
|
attribute->type,
|
||||||
TRUE, /* normalize */
|
TRUE, /* normalize */
|
||||||
@ -632,8 +610,8 @@ enable_gl_state (CoglDrawFlags flags,
|
|||||||
#else
|
#else
|
||||||
|
|
||||||
enable_flags |= COGL_ENABLE_COLOR_ARRAY;
|
enable_flags |= COGL_ENABLE_COLOR_ARRAY;
|
||||||
/* GE (glEnableClientState (GL_COLOR_ARRAY)); */
|
/* GE (ctx, glEnableClientState (GL_COLOR_ARRAY)); */
|
||||||
GE (glColorPointer (attribute->n_components,
|
GE (ctx, glColorPointer (attribute->n_components,
|
||||||
attribute->type,
|
attribute->type,
|
||||||
attribute->stride,
|
attribute->stride,
|
||||||
base + attribute->offset));
|
base + attribute->offset));
|
||||||
@ -648,7 +626,8 @@ enable_gl_state (CoglDrawFlags flags,
|
|||||||
_cogl_pipeline_progend_glsl_get_normal_attribute (source);
|
_cogl_pipeline_progend_glsl_get_normal_attribute (source);
|
||||||
if (attrib_location != -1)
|
if (attrib_location != -1)
|
||||||
{
|
{
|
||||||
GE( glVertexAttribPointer (attrib_location,
|
GE( ctx,
|
||||||
|
glVertexAttribPointer (attrib_location,
|
||||||
attribute->n_components,
|
attribute->n_components,
|
||||||
attribute->type,
|
attribute->type,
|
||||||
TRUE, /* normalize */
|
TRUE, /* normalize */
|
||||||
@ -660,8 +639,8 @@ enable_gl_state (CoglDrawFlags flags,
|
|||||||
#else
|
#else
|
||||||
|
|
||||||
/* FIXME: go through cogl cache to enable normal array */
|
/* FIXME: go through cogl cache to enable normal array */
|
||||||
GE (glEnableClientState (GL_NORMAL_ARRAY));
|
GE (ctx, glEnableClientState (GL_NORMAL_ARRAY));
|
||||||
GE (glNormalPointer (attribute->type,
|
GE (ctx, glNormalPointer (attribute->type,
|
||||||
attribute->stride,
|
attribute->stride,
|
||||||
base + attribute->offset));
|
base + attribute->offset));
|
||||||
|
|
||||||
@ -675,7 +654,8 @@ enable_gl_state (CoglDrawFlags flags,
|
|||||||
(source, attribute->texture_unit);
|
(source, attribute->texture_unit);
|
||||||
if (attrib_location != -1)
|
if (attrib_location != -1)
|
||||||
{
|
{
|
||||||
GE( glVertexAttribPointer (attrib_location,
|
GE( ctx,
|
||||||
|
glVertexAttribPointer (attrib_location,
|
||||||
attribute->n_components,
|
attribute->n_components,
|
||||||
attribute->type,
|
attribute->type,
|
||||||
FALSE, /* normalize */
|
FALSE, /* normalize */
|
||||||
@ -685,9 +665,9 @@ enable_gl_state (CoglDrawFlags flags,
|
|||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
||||||
GE (glClientActiveTexture (GL_TEXTURE0 +
|
GE (ctx, glClientActiveTexture (GL_TEXTURE0 +
|
||||||
attribute->texture_unit));
|
attribute->texture_unit));
|
||||||
GE (glTexCoordPointer (attribute->n_components,
|
GE (ctx, glTexCoordPointer (attribute->n_components,
|
||||||
attribute->type,
|
attribute->type,
|
||||||
attribute->stride,
|
attribute->stride,
|
||||||
base + attribute->offset));
|
base + attribute->offset));
|
||||||
@ -703,7 +683,8 @@ enable_gl_state (CoglDrawFlags flags,
|
|||||||
_cogl_pipeline_progend_glsl_get_position_attribute (source);
|
_cogl_pipeline_progend_glsl_get_position_attribute (source);
|
||||||
if (attrib_location != -1)
|
if (attrib_location != -1)
|
||||||
{
|
{
|
||||||
GE( glVertexAttribPointer (attrib_location,
|
GE( ctx,
|
||||||
|
glVertexAttribPointer (attrib_location,
|
||||||
attribute->n_components,
|
attribute->n_components,
|
||||||
attribute->type,
|
attribute->type,
|
||||||
FALSE, /* normalize */
|
FALSE, /* normalize */
|
||||||
@ -715,8 +696,8 @@ enable_gl_state (CoglDrawFlags flags,
|
|||||||
#else
|
#else
|
||||||
|
|
||||||
enable_flags |= COGL_ENABLE_VERTEX_ARRAY;
|
enable_flags |= COGL_ENABLE_VERTEX_ARRAY;
|
||||||
/* GE (glEnableClientState (GL_VERTEX_ARRAY)); */
|
/* GE (ctx, glEnableClientState (GL_VERTEX_ARRAY)); */
|
||||||
GE (glVertexPointer (attribute->n_components,
|
GE (ctx, glVertexPointer (attribute->n_components,
|
||||||
attribute->type,
|
attribute->type,
|
||||||
attribute->stride,
|
attribute->stride,
|
||||||
base + attribute->offset));
|
base + attribute->offset));
|
||||||
@ -729,8 +710,8 @@ enable_gl_state (CoglDrawFlags flags,
|
|||||||
/* FIXME: go through cogl cache to enable generic array. */
|
/* FIXME: go through cogl cache to enable generic array. */
|
||||||
/* FIXME: this is going to end up just using the builtins
|
/* FIXME: this is going to end up just using the builtins
|
||||||
on GLES 2 */
|
on GLES 2 */
|
||||||
GE (glEnableVertexAttribArray (generic_index++));
|
GE (ctx, glEnableVertexAttribArray (generic_index++));
|
||||||
GE (glVertexAttribPointer (generic_index,
|
GE (ctx, glVertexAttribPointer (generic_index,
|
||||||
attribute->n_components,
|
attribute->n_components,
|
||||||
attribute->type,
|
attribute->type,
|
||||||
attribute->normalized,
|
attribute->normalized,
|
||||||
@ -788,12 +769,12 @@ disable_gl_state (CoglAttribute **attributes,
|
|||||||
switch (attribute->name_id)
|
switch (attribute->name_id)
|
||||||
{
|
{
|
||||||
case COGL_ATTRIBUTE_NAME_ID_COLOR_ARRAY:
|
case COGL_ATTRIBUTE_NAME_ID_COLOR_ARRAY:
|
||||||
/* GE (glDisableClientState (GL_COLOR_ARRAY)); */
|
/* GE (ctx, glDisableClientState (GL_COLOR_ARRAY)); */
|
||||||
break;
|
break;
|
||||||
case COGL_ATTRIBUTE_NAME_ID_NORMAL_ARRAY:
|
case COGL_ATTRIBUTE_NAME_ID_NORMAL_ARRAY:
|
||||||
/* FIXME: go through cogl cache to enable normal array */
|
/* FIXME: go through cogl cache to enable normal array */
|
||||||
#ifndef HAVE_COGL_GLES2
|
#ifndef HAVE_COGL_GLES2
|
||||||
GE (glDisableClientState (GL_NORMAL_ARRAY));
|
GE (ctx, glDisableClientState (GL_NORMAL_ARRAY));
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case COGL_ATTRIBUTE_NAME_ID_TEXTURE_COORD_ARRAY:
|
case COGL_ATTRIBUTE_NAME_ID_TEXTURE_COORD_ARRAY:
|
||||||
@ -804,12 +785,12 @@ disable_gl_state (CoglAttribute **attributes,
|
|||||||
required */
|
required */
|
||||||
break;
|
break;
|
||||||
case COGL_ATTRIBUTE_NAME_ID_POSITION_ARRAY:
|
case COGL_ATTRIBUTE_NAME_ID_POSITION_ARRAY:
|
||||||
/* GE (glDisableClientState (GL_VERTEX_ARRAY)); */
|
/* GE (ctx, glDisableClientState (GL_VERTEX_ARRAY)); */
|
||||||
break;
|
break;
|
||||||
case COGL_ATTRIBUTE_NAME_ID_CUSTOM_ARRAY:
|
case COGL_ATTRIBUTE_NAME_ID_CUSTOM_ARRAY:
|
||||||
#ifdef MAY_HAVE_PROGRAMABLE_GL
|
#ifdef MAY_HAVE_PROGRAMABLE_GL
|
||||||
/* FIXME: go through cogl cache to enable generic array */
|
/* FIXME: go through cogl cache to enable generic array */
|
||||||
GE (glDisableVertexAttribArray (generic_index++));
|
GE (ctx, glDisableVertexAttribArray (generic_index++));
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -1109,11 +1090,13 @@ _cogl_draw_attributes (CoglVerticesMode mode,
|
|||||||
ValidateLayerState state;
|
ValidateLayerState state;
|
||||||
CoglPipeline *source;
|
CoglPipeline *source;
|
||||||
|
|
||||||
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
flush_state (flags, &state);
|
flush_state (flags, &state);
|
||||||
|
|
||||||
source = enable_gl_state (flags, attributes, n_attributes, &state);
|
source = enable_gl_state (flags, attributes, n_attributes, &state);
|
||||||
|
|
||||||
GE (glDrawArrays ((GLenum)mode, first_vertex, n_vertices));
|
GE (ctx, glDrawArrays ((GLenum)mode, first_vertex, n_vertices));
|
||||||
|
|
||||||
/* FIXME: we shouldn't be disabling state after drawing we should
|
/* FIXME: we shouldn't be disabling state after drawing we should
|
||||||
* just disable the things not needed after enabling state. */
|
* just disable the things not needed after enabling state. */
|
||||||
@ -1223,7 +1206,7 @@ _cogl_draw_indexed_attributes (CoglVerticesMode mode,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
GE (glDrawElements ((GLenum)mode,
|
GE (ctx, glDrawElements ((GLenum)mode,
|
||||||
n_vertices,
|
n_vertices,
|
||||||
indices_gl_type,
|
indices_gl_type,
|
||||||
base + buffer_offset + index_size * first_vertex));
|
base + buffer_offset + index_size * first_vertex));
|
||||||
|
@ -49,21 +49,6 @@
|
|||||||
* GL/GLES compatibility defines for the buffer API:
|
* GL/GLES compatibility defines for the buffer API:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined (HAVE_COGL_GL)
|
|
||||||
|
|
||||||
#define glGenBuffers ctx->glGenBuffers
|
|
||||||
#define glBindBuffer ctx->glBindBuffer
|
|
||||||
#define glBufferData ctx->glBufferData
|
|
||||||
#define glBufferSubData ctx->glBufferSubData
|
|
||||||
#define glGetBufferSubData ctx->glGetBufferSubData
|
|
||||||
#define glDeleteBuffers ctx->glDeleteBuffers
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* These two are always accessed through an extension, even on GLES */
|
|
||||||
#define glMapBuffer ctx->glMapBuffer
|
|
||||||
#define glUnmapBuffer ctx->glUnmapBuffer
|
|
||||||
|
|
||||||
#ifndef GL_PIXEL_PACK_BUFFER
|
#ifndef GL_PIXEL_PACK_BUFFER
|
||||||
#define GL_PIXEL_PACK_BUFFER 0x88EB
|
#define GL_PIXEL_PACK_BUFFER 0x88EB
|
||||||
#endif
|
#endif
|
||||||
@ -165,15 +150,20 @@ bo_map (CoglBuffer *buffer,
|
|||||||
* store is created. */
|
* store is created. */
|
||||||
if (!buffer->store_created || (hints & COGL_BUFFER_MAP_HINT_DISCARD))
|
if (!buffer->store_created || (hints & COGL_BUFFER_MAP_HINT_DISCARD))
|
||||||
{
|
{
|
||||||
GE( glBufferData (gl_target,
|
GLenum gl_enum;
|
||||||
|
|
||||||
|
gl_enum = _cogl_buffer_hints_to_gl_enum (buffer->usage_hint,
|
||||||
|
buffer->update_hint);
|
||||||
|
|
||||||
|
|
||||||
|
GE( ctx, glBufferData (gl_target,
|
||||||
buffer->size,
|
buffer->size,
|
||||||
NULL,
|
NULL,
|
||||||
_cogl_buffer_hints_to_gl_enum (buffer->usage_hint,
|
gl_enum) );
|
||||||
buffer->update_hint)) );
|
|
||||||
buffer->store_created = TRUE;
|
buffer->store_created = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
GE_RET( data, glMapBuffer (gl_target,
|
GE_RET( data, ctx, glMapBuffer (gl_target,
|
||||||
_cogl_buffer_access_to_gl_enum (access)) );
|
_cogl_buffer_access_to_gl_enum (access)) );
|
||||||
if (data)
|
if (data)
|
||||||
buffer->flags |= COGL_BUFFER_FLAG_MAPPED;
|
buffer->flags |= COGL_BUFFER_FLAG_MAPPED;
|
||||||
@ -190,7 +180,8 @@ bo_unmap (CoglBuffer *buffer)
|
|||||||
|
|
||||||
_cogl_buffer_bind (buffer, buffer->last_target);
|
_cogl_buffer_bind (buffer, buffer->last_target);
|
||||||
|
|
||||||
GE( glUnmapBuffer (convert_bind_target_to_gl_target (buffer->last_target)) );
|
GE( ctx, glUnmapBuffer (convert_bind_target_to_gl_target
|
||||||
|
(buffer->last_target)) );
|
||||||
buffer->flags &= ~COGL_BUFFER_FLAG_MAPPED;
|
buffer->flags &= ~COGL_BUFFER_FLAG_MAPPED;
|
||||||
|
|
||||||
_cogl_buffer_unbind (buffer);
|
_cogl_buffer_unbind (buffer);
|
||||||
@ -217,15 +208,16 @@ bo_set_data (CoglBuffer *buffer,
|
|||||||
* store is created. */
|
* store is created. */
|
||||||
if (!buffer->store_created)
|
if (!buffer->store_created)
|
||||||
{
|
{
|
||||||
GE( glBufferData (gl_target,
|
GLenum gl_enum = _cogl_buffer_hints_to_gl_enum (buffer->usage_hint,
|
||||||
|
buffer->update_hint);
|
||||||
|
GE( ctx, glBufferData (gl_target,
|
||||||
buffer->size,
|
buffer->size,
|
||||||
NULL,
|
NULL,
|
||||||
_cogl_buffer_hints_to_gl_enum (buffer->usage_hint,
|
gl_enum) );
|
||||||
buffer->update_hint)) );
|
|
||||||
buffer->store_created = TRUE;
|
buffer->store_created = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
GE( glBufferSubData (gl_target, offset, size, data) );
|
GE( ctx, glBufferSubData (gl_target, offset, size, data) );
|
||||||
|
|
||||||
_cogl_buffer_unbind (buffer);
|
_cogl_buffer_unbind (buffer);
|
||||||
|
|
||||||
@ -294,7 +286,7 @@ _cogl_buffer_initialize (CoglBuffer *buffer,
|
|||||||
buffer->vtable.unmap = bo_unmap;
|
buffer->vtable.unmap = bo_unmap;
|
||||||
buffer->vtable.set_data = bo_set_data;
|
buffer->vtable.set_data = bo_set_data;
|
||||||
|
|
||||||
GE( glGenBuffers (1, &buffer->gl_handle) );
|
GE( ctx, glGenBuffers (1, &buffer->gl_handle) );
|
||||||
buffer->flags |= COGL_BUFFER_FLAG_BUFFER_OBJECT;
|
buffer->flags |= COGL_BUFFER_FLAG_BUFFER_OBJECT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -308,7 +300,7 @@ _cogl_buffer_fini (CoglBuffer *buffer)
|
|||||||
g_return_if_fail (buffer->immutable_ref == 0);
|
g_return_if_fail (buffer->immutable_ref == 0);
|
||||||
|
|
||||||
if (buffer->flags & COGL_BUFFER_FLAG_BUFFER_OBJECT)
|
if (buffer->flags & COGL_BUFFER_FLAG_BUFFER_OBJECT)
|
||||||
GE( glDeleteBuffers (1, &buffer->gl_handle) );
|
GE( ctx, glDeleteBuffers (1, &buffer->gl_handle) );
|
||||||
else
|
else
|
||||||
g_free (buffer->data);
|
g_free (buffer->data);
|
||||||
}
|
}
|
||||||
@ -372,7 +364,7 @@ _cogl_buffer_bind (CoglBuffer *buffer, CoglBufferBindTarget target)
|
|||||||
if (buffer->flags & COGL_BUFFER_FLAG_BUFFER_OBJECT)
|
if (buffer->flags & COGL_BUFFER_FLAG_BUFFER_OBJECT)
|
||||||
{
|
{
|
||||||
GLenum gl_target = convert_bind_target_to_gl_target (buffer->last_target);
|
GLenum gl_target = convert_bind_target_to_gl_target (buffer->last_target);
|
||||||
GE( glBindBuffer (gl_target, buffer->gl_handle) );
|
GE( ctx, glBindBuffer (gl_target, buffer->gl_handle) );
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -392,7 +384,7 @@ _cogl_buffer_unbind (CoglBuffer *buffer)
|
|||||||
if (buffer->flags & COGL_BUFFER_FLAG_BUFFER_OBJECT)
|
if (buffer->flags & COGL_BUFFER_FLAG_BUFFER_OBJECT)
|
||||||
{
|
{
|
||||||
GLenum gl_target = convert_bind_target_to_gl_target (buffer->last_target);
|
GLenum gl_target = convert_bind_target_to_gl_target (buffer->last_target);
|
||||||
GE( glBindBuffer (gl_target, 0) );
|
GE( ctx, glBindBuffer (gl_target, 0) );
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx->current_buffer[buffer->last_target] = NULL;
|
ctx->current_buffer[buffer->last_target] = NULL;
|
||||||
|
@ -117,9 +117,9 @@ set_clip_plane (GLint plane_num,
|
|||||||
#if defined (HAVE_COGL_GLES2)
|
#if defined (HAVE_COGL_GLES2)
|
||||||
g_assert_not_reached ();
|
g_assert_not_reached ();
|
||||||
#elif defined (HAVE_COGL_GLES)
|
#elif defined (HAVE_COGL_GLES)
|
||||||
GE( glClipPlanef (plane_num, plane) );
|
GE( ctx, glClipPlanef (plane_num, plane) );
|
||||||
#else
|
#else
|
||||||
GE( glClipPlane (plane_num, plane) );
|
GE( ctx, glClipPlane (plane_num, plane) );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
_cogl_matrix_stack_pop (modelview_stack);
|
_cogl_matrix_stack_pop (modelview_stack);
|
||||||
@ -213,15 +213,15 @@ add_stencil_clip_rectangle (float x_1,
|
|||||||
|
|
||||||
if (first)
|
if (first)
|
||||||
{
|
{
|
||||||
GE( glEnable (GL_STENCIL_TEST) );
|
GE( ctx, glEnable (GL_STENCIL_TEST) );
|
||||||
|
|
||||||
/* Initially disallow everything */
|
/* Initially disallow everything */
|
||||||
GE( glClearStencil (0) );
|
GE( ctx, glClearStencil (0) );
|
||||||
GE( glClear (GL_STENCIL_BUFFER_BIT) );
|
GE( ctx, glClear (GL_STENCIL_BUFFER_BIT) );
|
||||||
|
|
||||||
/* Punch out a hole to allow the rectangle */
|
/* Punch out a hole to allow the rectangle */
|
||||||
GE( glStencilFunc (GL_NEVER, 0x1, 0x1) );
|
GE( ctx, glStencilFunc (GL_NEVER, 0x1, 0x1) );
|
||||||
GE( glStencilOp (GL_REPLACE, GL_REPLACE, GL_REPLACE) );
|
GE( ctx, glStencilOp (GL_REPLACE, GL_REPLACE, GL_REPLACE) );
|
||||||
|
|
||||||
_cogl_rectangle_immediate (x_1, y_1, x_2, y_2);
|
_cogl_rectangle_immediate (x_1, y_1, x_2, y_2);
|
||||||
}
|
}
|
||||||
@ -229,14 +229,14 @@ add_stencil_clip_rectangle (float x_1,
|
|||||||
{
|
{
|
||||||
/* Add one to every pixel of the stencil buffer in the
|
/* Add one to every pixel of the stencil buffer in the
|
||||||
rectangle */
|
rectangle */
|
||||||
GE( glStencilFunc (GL_NEVER, 0x1, 0x3) );
|
GE( ctx, glStencilFunc (GL_NEVER, 0x1, 0x3) );
|
||||||
GE( glStencilOp (GL_INCR, GL_INCR, GL_INCR) );
|
GE( ctx, glStencilOp (GL_INCR, GL_INCR, GL_INCR) );
|
||||||
_cogl_rectangle_immediate (x_1, y_1, x_2, y_2);
|
_cogl_rectangle_immediate (x_1, y_1, x_2, y_2);
|
||||||
|
|
||||||
/* Subtract one from all pixels in the stencil buffer so that
|
/* Subtract one from all pixels in the stencil buffer so that
|
||||||
only pixels where both the original stencil buffer and the
|
only pixels where both the original stencil buffer and the
|
||||||
rectangle are set will be valid */
|
rectangle are set will be valid */
|
||||||
GE( glStencilOp (GL_DECR, GL_DECR, GL_DECR) );
|
GE( ctx, glStencilOp (GL_DECR, GL_DECR, GL_DECR) );
|
||||||
|
|
||||||
_cogl_matrix_stack_push (projection_stack);
|
_cogl_matrix_stack_push (projection_stack);
|
||||||
_cogl_matrix_stack_load_identity (projection_stack);
|
_cogl_matrix_stack_load_identity (projection_stack);
|
||||||
@ -256,8 +256,8 @@ add_stencil_clip_rectangle (float x_1,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Restore the stencil mode */
|
/* Restore the stencil mode */
|
||||||
GE( glStencilFunc (GL_EQUAL, 0x1, 0x1) );
|
GE( ctx, glStencilFunc (GL_EQUAL, 0x1, 0x1) );
|
||||||
GE( glStencilOp (GL_KEEP, GL_KEEP, GL_KEEP) );
|
GE( ctx, glStencilOp (GL_KEEP, GL_KEEP, GL_KEEP) );
|
||||||
|
|
||||||
/* restore the original source pipeline */
|
/* restore the original source pipeline */
|
||||||
cogl_pop_source ();
|
cogl_pop_source ();
|
||||||
@ -266,25 +266,31 @@ add_stencil_clip_rectangle (float x_1,
|
|||||||
static void
|
static void
|
||||||
disable_stencil_buffer (void)
|
disable_stencil_buffer (void)
|
||||||
{
|
{
|
||||||
GE( glDisable (GL_STENCIL_TEST) );
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
|
GE( ctx, glDisable (GL_STENCIL_TEST) );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
enable_clip_planes (void)
|
enable_clip_planes (void)
|
||||||
{
|
{
|
||||||
GE( glEnable (GL_CLIP_PLANE0) );
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
GE( glEnable (GL_CLIP_PLANE1) );
|
|
||||||
GE( glEnable (GL_CLIP_PLANE2) );
|
GE( ctx, glEnable (GL_CLIP_PLANE0) );
|
||||||
GE( glEnable (GL_CLIP_PLANE3) );
|
GE( ctx, glEnable (GL_CLIP_PLANE1) );
|
||||||
|
GE( ctx, glEnable (GL_CLIP_PLANE2) );
|
||||||
|
GE( ctx, glEnable (GL_CLIP_PLANE3) );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
disable_clip_planes (void)
|
disable_clip_planes (void)
|
||||||
{
|
{
|
||||||
GE( glDisable (GL_CLIP_PLANE3) );
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
GE( glDisable (GL_CLIP_PLANE2) );
|
|
||||||
GE( glDisable (GL_CLIP_PLANE1) );
|
GE( ctx, glDisable (GL_CLIP_PLANE3) );
|
||||||
GE( glDisable (GL_CLIP_PLANE0) );
|
GE( ctx, glDisable (GL_CLIP_PLANE2) );
|
||||||
|
GE( ctx, glDisable (GL_CLIP_PLANE1) );
|
||||||
|
GE( ctx, glDisable (GL_CLIP_PLANE0) );
|
||||||
}
|
}
|
||||||
|
|
||||||
static gpointer
|
static gpointer
|
||||||
@ -612,7 +618,7 @@ _cogl_clip_stack_flush (CoglClipStack *stack)
|
|||||||
COGL_NOTE (CLIPPING, "Flushed empty clip stack");
|
COGL_NOTE (CLIPPING, "Flushed empty clip stack");
|
||||||
|
|
||||||
ctx->current_clip_stack_uses_stencil = FALSE;
|
ctx->current_clip_stack_uses_stencil = FALSE;
|
||||||
GE (glDisable (GL_SCISSOR_TEST));
|
GE (ctx, glDisable (GL_SCISSOR_TEST));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -654,8 +660,8 @@ _cogl_clip_stack_flush (CoglClipStack *stack)
|
|||||||
scissor_x0, scissor_y0,
|
scissor_x0, scissor_y0,
|
||||||
scissor_x1, scissor_y1);
|
scissor_x1, scissor_y1);
|
||||||
|
|
||||||
GE (glEnable (GL_SCISSOR_TEST));
|
GE (ctx, glEnable (GL_SCISSOR_TEST));
|
||||||
GE (glScissor (scissor_x0, scissor_y_start,
|
GE (ctx, glScissor (scissor_x0, scissor_y_start,
|
||||||
scissor_x1 - scissor_x0,
|
scissor_x1 - scissor_x0,
|
||||||
scissor_y1 - scissor_y0));
|
scissor_y1 - scissor_y0));
|
||||||
|
|
||||||
|
@ -47,7 +47,6 @@
|
|||||||
|
|
||||||
#ifdef HAVE_COGL_GL
|
#ifdef HAVE_COGL_GL
|
||||||
#include "cogl-pipeline-fragend-arbfp-private.h"
|
#include "cogl-pipeline-fragend-arbfp-private.h"
|
||||||
#define glActiveTexture _context->glActiveTexture
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* This isn't defined in the GLES headers */
|
/* This isn't defined in the GLES headers */
|
||||||
@ -199,7 +198,7 @@ cogl_context_new (CoglDisplay *display,
|
|||||||
/* See cogl-pipeline.c for more details about why we leave texture unit 1
|
/* See cogl-pipeline.c for more details about why we leave texture unit 1
|
||||||
* active by default... */
|
* active by default... */
|
||||||
context->active_texture_unit = 1;
|
context->active_texture_unit = 1;
|
||||||
GE (glActiveTexture (GL_TEXTURE1));
|
GE (context, glActiveTexture (GL_TEXTURE1));
|
||||||
|
|
||||||
context->legacy_fog_state.enabled = FALSE;
|
context->legacy_fog_state.enabled = FALSE;
|
||||||
|
|
||||||
@ -307,7 +306,7 @@ cogl_context_new (CoglDisplay *display,
|
|||||||
* makes things a bit simpler for us. Under GLES2 the alpha test is
|
* makes things a bit simpler for us. Under GLES2 the alpha test is
|
||||||
* implemented in the fragment shader so there is no enable for it
|
* implemented in the fragment shader so there is no enable for it
|
||||||
*/
|
*/
|
||||||
GE (glEnable (GL_ALPHA_TEST));
|
GE (context, glEnable (GL_ALPHA_TEST));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_COGL_GLES2
|
#ifdef HAVE_COGL_GLES2
|
||||||
@ -355,7 +354,7 @@ cogl_context_new (CoglDisplay *display,
|
|||||||
sprites are handled using a builtin varying in the shader. */
|
sprites are handled using a builtin varying in the shader. */
|
||||||
#ifndef HAVE_COGL_GLES2
|
#ifndef HAVE_COGL_GLES2
|
||||||
if (cogl_features_available (COGL_FEATURE_POINT_SPRITE))
|
if (cogl_features_available (COGL_FEATURE_POINT_SPRITE))
|
||||||
GE (glEnable (GL_POINT_SPRITE));
|
GE (context, glEnable (GL_POINT_SPRITE));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return _cogl_context_object_new (context);
|
return _cogl_context_object_new (context);
|
||||||
|
@ -48,6 +48,219 @@
|
|||||||
* @extension_names: A list of extension names to try. If any of these
|
* @extension_names: A list of extension names to try. If any of these
|
||||||
* extensions match then it will be used.
|
* extensions match then it will be used.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* These are the core GL functions which we assume will always be
|
||||||
|
available */
|
||||||
|
COGL_EXT_BEGIN (core,
|
||||||
|
0, 0,
|
||||||
|
COGL_EXT_IN_GLES | COGL_EXT_IN_GLES2,
|
||||||
|
"\0",
|
||||||
|
"\0")
|
||||||
|
COGL_EXT_FUNCTION (void, glBindTexture,
|
||||||
|
(GLenum target, GLuint texture))
|
||||||
|
COGL_EXT_FUNCTION (void, glBlendFunc,
|
||||||
|
(GLenum sfactor, GLenum dfactor))
|
||||||
|
COGL_EXT_FUNCTION (void, glClear,
|
||||||
|
(GLbitfield mask))
|
||||||
|
COGL_EXT_FUNCTION (void, glClearColor,
|
||||||
|
(GLclampf red,
|
||||||
|
GLclampf green,
|
||||||
|
GLclampf blue,
|
||||||
|
GLclampf alpha))
|
||||||
|
COGL_EXT_FUNCTION (void, glClearStencil,
|
||||||
|
(GLint s))
|
||||||
|
COGL_EXT_FUNCTION (void, glColorMask,
|
||||||
|
(GLboolean red,
|
||||||
|
GLboolean green,
|
||||||
|
GLboolean blue,
|
||||||
|
GLboolean alpha))
|
||||||
|
COGL_EXT_FUNCTION (void, glCopyTexSubImage2D,
|
||||||
|
(GLenum target,
|
||||||
|
GLint level,
|
||||||
|
GLint xoffset,
|
||||||
|
GLint yoffset,
|
||||||
|
GLint x,
|
||||||
|
GLint y,
|
||||||
|
GLsizei width,
|
||||||
|
GLsizei height))
|
||||||
|
COGL_EXT_FUNCTION (void, glDeleteTextures,
|
||||||
|
(GLsizei n, const GLuint* textures))
|
||||||
|
COGL_EXT_FUNCTION (void, glDepthFunc,
|
||||||
|
(GLenum func))
|
||||||
|
COGL_EXT_FUNCTION (void, glDepthMask,
|
||||||
|
(GLboolean flag))
|
||||||
|
COGL_EXT_FUNCTION (void, glDisable,
|
||||||
|
(GLenum cap))
|
||||||
|
COGL_EXT_FUNCTION (void, glDrawArrays,
|
||||||
|
(GLenum mode, GLint first, GLsizei count))
|
||||||
|
COGL_EXT_FUNCTION (void, glDrawElements,
|
||||||
|
(GLenum mode,
|
||||||
|
GLsizei count,
|
||||||
|
GLenum type,
|
||||||
|
const GLvoid* indices))
|
||||||
|
COGL_EXT_FUNCTION (void, glEnable,
|
||||||
|
(GLenum cap))
|
||||||
|
COGL_EXT_FUNCTION (void, glFinish,
|
||||||
|
(void))
|
||||||
|
COGL_EXT_FUNCTION (void, glFlush,
|
||||||
|
(void))
|
||||||
|
COGL_EXT_FUNCTION (void, glFrontFace,
|
||||||
|
(GLenum mode))
|
||||||
|
COGL_EXT_FUNCTION (void, glGenTextures,
|
||||||
|
(GLsizei n, GLuint* textures))
|
||||||
|
COGL_EXT_FUNCTION (GLenum, glGetError,
|
||||||
|
(void))
|
||||||
|
COGL_EXT_FUNCTION (void, glGetIntegerv,
|
||||||
|
(GLenum pname, GLint* params))
|
||||||
|
COGL_EXT_FUNCTION (const GLubyte*, glGetString,
|
||||||
|
(GLenum name))
|
||||||
|
COGL_EXT_FUNCTION (void, glHint,
|
||||||
|
(GLenum target, GLenum mode))
|
||||||
|
COGL_EXT_FUNCTION (GLboolean, glIsTexture,
|
||||||
|
(GLuint texture))
|
||||||
|
COGL_EXT_FUNCTION (void, glPixelStorei,
|
||||||
|
(GLenum pname, GLint param))
|
||||||
|
COGL_EXT_FUNCTION (void, glReadPixels,
|
||||||
|
(GLint x,
|
||||||
|
GLint y,
|
||||||
|
GLsizei width,
|
||||||
|
GLsizei height,
|
||||||
|
GLenum format,
|
||||||
|
GLenum type,
|
||||||
|
GLvoid* pixels))
|
||||||
|
COGL_EXT_FUNCTION (void, glScissor,
|
||||||
|
(GLint x, GLint y, GLsizei width, GLsizei height))
|
||||||
|
COGL_EXT_FUNCTION (void, glStencilFunc,
|
||||||
|
(GLenum func, GLint ref, GLuint mask))
|
||||||
|
COGL_EXT_FUNCTION (void, glStencilMask,
|
||||||
|
(GLuint mask))
|
||||||
|
COGL_EXT_FUNCTION (void, glStencilOp,
|
||||||
|
(GLenum fail, GLenum zfail, GLenum zpass))
|
||||||
|
COGL_EXT_FUNCTION (void, glTexImage2D,
|
||||||
|
(GLenum target,
|
||||||
|
GLint level,
|
||||||
|
GLint internalformat,
|
||||||
|
GLsizei width,
|
||||||
|
GLsizei height,
|
||||||
|
GLint border,
|
||||||
|
GLenum format,
|
||||||
|
GLenum type,
|
||||||
|
const GLvoid* pixels))
|
||||||
|
COGL_EXT_FUNCTION (void, glTexParameterfv,
|
||||||
|
(GLenum target, GLenum pname, const GLfloat* params))
|
||||||
|
COGL_EXT_FUNCTION (void, glTexParameteri,
|
||||||
|
(GLenum target, GLenum pname, GLint param))
|
||||||
|
COGL_EXT_FUNCTION (void, glTexSubImage2D,
|
||||||
|
(GLenum target,
|
||||||
|
GLint level,
|
||||||
|
GLint xoffset,
|
||||||
|
GLint yoffset,
|
||||||
|
GLsizei width,
|
||||||
|
GLsizei height,
|
||||||
|
GLenum format,
|
||||||
|
GLenum type,
|
||||||
|
const GLvoid* pixels))
|
||||||
|
COGL_EXT_FUNCTION (void, glViewport,
|
||||||
|
(GLint x, GLint y, GLsizei width, GLsizei height))
|
||||||
|
COGL_EXT_END ()
|
||||||
|
|
||||||
|
/* These are the core GL functions which are available when the API
|
||||||
|
supports fixed-function (ie, GL and GLES1.1) */
|
||||||
|
COGL_EXT_BEGIN (fixed_function_core,
|
||||||
|
0, 0,
|
||||||
|
COGL_EXT_IN_GLES,
|
||||||
|
"\0",
|
||||||
|
"\0")
|
||||||
|
COGL_EXT_FUNCTION (void, glAlphaFunc,
|
||||||
|
(GLenum func, GLclampf ref))
|
||||||
|
COGL_EXT_FUNCTION (void, glFogf,
|
||||||
|
(GLenum pname, GLfloat param))
|
||||||
|
COGL_EXT_FUNCTION (void, glFogfv,
|
||||||
|
(GLenum pname, const GLfloat *params))
|
||||||
|
COGL_EXT_FUNCTION (void, glLoadMatrixf,
|
||||||
|
(const GLfloat *m))
|
||||||
|
COGL_EXT_FUNCTION (void, glMaterialfv,
|
||||||
|
(GLenum face, GLenum pname, const GLfloat *params))
|
||||||
|
COGL_EXT_FUNCTION (void, glPointSize,
|
||||||
|
(GLfloat size))
|
||||||
|
COGL_EXT_FUNCTION (void, glTexEnvfv,
|
||||||
|
(GLenum target, GLenum pname, const GLfloat *params))
|
||||||
|
COGL_EXT_FUNCTION (void, glColor4ub,
|
||||||
|
(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha))
|
||||||
|
COGL_EXT_FUNCTION (void, glColorPointer,
|
||||||
|
(GLint size,
|
||||||
|
GLenum type,
|
||||||
|
GLsizei stride,
|
||||||
|
const GLvoid *pointer))
|
||||||
|
COGL_EXT_FUNCTION (void, glDisableClientState,
|
||||||
|
(GLenum array))
|
||||||
|
COGL_EXT_FUNCTION (void, glEnableClientState,
|
||||||
|
(GLenum array))
|
||||||
|
COGL_EXT_FUNCTION (void, glLoadIdentity,
|
||||||
|
(void))
|
||||||
|
COGL_EXT_FUNCTION (void, glMatrixMode,
|
||||||
|
(GLenum mode))
|
||||||
|
COGL_EXT_FUNCTION (void, glNormalPointer,
|
||||||
|
(GLenum type, GLsizei stride, const GLvoid *pointer))
|
||||||
|
COGL_EXT_FUNCTION (void, glTexCoordPointer,
|
||||||
|
(GLint size,
|
||||||
|
GLenum type,
|
||||||
|
GLsizei stride,
|
||||||
|
const GLvoid *pointer))
|
||||||
|
COGL_EXT_FUNCTION (void, glTexEnvi,
|
||||||
|
(GLenum target,
|
||||||
|
GLenum pname,
|
||||||
|
GLint param))
|
||||||
|
COGL_EXT_FUNCTION (void, glVertexPointer,
|
||||||
|
(GLint size,
|
||||||
|
GLenum type,
|
||||||
|
GLsizei stride,
|
||||||
|
const GLvoid *pointer))
|
||||||
|
COGL_EXT_END ()
|
||||||
|
|
||||||
|
/* These are the core GL functions which are only available in big
|
||||||
|
GL */
|
||||||
|
COGL_EXT_BEGIN (only_in_big_gl,
|
||||||
|
0, 0,
|
||||||
|
0, /* not in GLES */
|
||||||
|
"\0",
|
||||||
|
"\0")
|
||||||
|
COGL_EXT_FUNCTION (void, glGetTexLevelParameteriv,
|
||||||
|
(GLenum target, GLint level,
|
||||||
|
GLenum pname, GLint *params))
|
||||||
|
COGL_EXT_FUNCTION (void, glGetTexImage,
|
||||||
|
(GLenum target, GLint level,
|
||||||
|
GLenum format, GLenum type,
|
||||||
|
GLvoid *pixels))
|
||||||
|
COGL_EXT_FUNCTION (void, glClipPlane,
|
||||||
|
(GLenum plane, const double *equation))
|
||||||
|
COGL_EXT_FUNCTION (void, glDepthRange,
|
||||||
|
(double near_val, double far_val))
|
||||||
|
COGL_EXT_FUNCTION (void, glDrawBuffer,
|
||||||
|
(GLenum mode))
|
||||||
|
COGL_EXT_END ()
|
||||||
|
|
||||||
|
/* These functions are only available in GLES and are used as
|
||||||
|
replacements for some GL equivalents that only accept double
|
||||||
|
arguments */
|
||||||
|
COGL_EXT_BEGIN (only_in_gles1,
|
||||||
|
255, 255,
|
||||||
|
COGL_EXT_IN_GLES,
|
||||||
|
"\0",
|
||||||
|
"\0")
|
||||||
|
COGL_EXT_FUNCTION (void, glClipPlanef,
|
||||||
|
(GLenum plane, const GLfloat *equation))
|
||||||
|
COGL_EXT_END ()
|
||||||
|
COGL_EXT_BEGIN (only_in_both_gles,
|
||||||
|
255, 255,
|
||||||
|
COGL_EXT_IN_GLES |
|
||||||
|
COGL_EXT_IN_GLES2,
|
||||||
|
"\0",
|
||||||
|
"\0")
|
||||||
|
COGL_EXT_FUNCTION (void, glDepthRangef,
|
||||||
|
(GLfloat near_val, GLfloat far_val))
|
||||||
|
COGL_EXT_END ()
|
||||||
|
|
||||||
COGL_EXT_BEGIN (offscreen,
|
COGL_EXT_BEGIN (offscreen,
|
||||||
255, 255,
|
255, 255,
|
||||||
COGL_EXT_IN_GLES2,
|
COGL_EXT_IN_GLES2,
|
||||||
@ -303,6 +516,12 @@ COGL_EXT_FUNCTION (void, glGetProgramInfoLog,
|
|||||||
GLsizei *length,
|
GLsizei *length,
|
||||||
GLchar *infoLog))
|
GLchar *infoLog))
|
||||||
|
|
||||||
|
COGL_EXT_FUNCTION (void, glVertexAttrib4f,
|
||||||
|
(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w))
|
||||||
|
|
||||||
|
COGL_EXT_FUNCTION (GLint, glGetAttribLocation,
|
||||||
|
(GLuint program, const GLchar *name))
|
||||||
|
|
||||||
COGL_EXT_END ()
|
COGL_EXT_END ()
|
||||||
|
|
||||||
COGL_EXT_BEGIN (vbos, 1, 5,
|
COGL_EXT_BEGIN (vbos, 1, 5,
|
||||||
|
@ -40,25 +40,6 @@
|
|||||||
#include "cogl-journal-private.h"
|
#include "cogl-journal-private.h"
|
||||||
#include "cogl-winsys-private.h"
|
#include "cogl-winsys-private.h"
|
||||||
|
|
||||||
#ifndef HAVE_COGL_GLES2
|
|
||||||
|
|
||||||
#define glGenRenderbuffers ctx->glGenRenderbuffers
|
|
||||||
#define glDeleteRenderbuffers ctx->glDeleteRenderbuffers
|
|
||||||
#define glBindRenderbuffer ctx->glBindRenderbuffer
|
|
||||||
#define glRenderbufferStorage ctx->glRenderbufferStorage
|
|
||||||
#define glGenFramebuffers ctx->glGenFramebuffers
|
|
||||||
#define glBindFramebuffer ctx->glBindFramebuffer
|
|
||||||
#define glFramebufferTexture2D ctx->glFramebufferTexture2D
|
|
||||||
#define glFramebufferRenderbuffer ctx->glFramebufferRenderbuffer
|
|
||||||
#define glCheckFramebufferStatus ctx->glCheckFramebufferStatus
|
|
||||||
#define glDeleteFramebuffers ctx->glDeleteFramebuffers
|
|
||||||
#define glGetFramebufferAttachmentParameteriv \
|
|
||||||
ctx->glGetFramebufferAttachmentParameteriv
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define glBlitFramebuffer ctx->glBlitFramebuffer
|
|
||||||
|
|
||||||
#ifndef GL_FRAMEBUFFER
|
#ifndef GL_FRAMEBUFFER
|
||||||
#define GL_FRAMEBUFFER 0x8D40
|
#define GL_FRAMEBUFFER 0x8D40
|
||||||
#endif
|
#endif
|
||||||
@ -252,9 +233,11 @@ _cogl_clear4f (unsigned long buffers,
|
|||||||
{
|
{
|
||||||
GLbitfield gl_buffers = 0;
|
GLbitfield gl_buffers = 0;
|
||||||
|
|
||||||
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
if (buffers & COGL_BUFFER_BIT_COLOR)
|
if (buffers & COGL_BUFFER_BIT_COLOR)
|
||||||
{
|
{
|
||||||
GE( glClearColor (red, green, blue, alpha) );
|
GE( ctx, glClearColor (red, green, blue, alpha) );
|
||||||
gl_buffers |= GL_COLOR_BUFFER_BIT;
|
gl_buffers |= GL_COLOR_BUFFER_BIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -277,7 +260,7 @@ _cogl_clear4f (unsigned long buffers,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GE (glClear (gl_buffers));
|
GE (ctx, glClear (gl_buffers));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -626,9 +609,7 @@ _cogl_framebuffer_flush_dependency_journals (CoglFramebuffer *framebuffer)
|
|||||||
static inline void
|
static inline void
|
||||||
_cogl_framebuffer_init_bits (CoglFramebuffer *framebuffer)
|
_cogl_framebuffer_init_bits (CoglFramebuffer *framebuffer)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_COGL_GL
|
|
||||||
CoglContext *ctx = framebuffer->context;
|
CoglContext *ctx = framebuffer->context;
|
||||||
#endif
|
|
||||||
|
|
||||||
if (G_LIKELY (!framebuffer->dirty_bitmasks))
|
if (G_LIKELY (!framebuffer->dirty_bitmasks))
|
||||||
return;
|
return;
|
||||||
@ -642,36 +623,39 @@ _cogl_framebuffer_init_bits (CoglFramebuffer *framebuffer)
|
|||||||
attachment = GL_COLOR_ATTACHMENT0;
|
attachment = GL_COLOR_ATTACHMENT0;
|
||||||
|
|
||||||
pname = GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE;
|
pname = GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE;
|
||||||
GE( glGetFramebufferAttachmentParameteriv (GL_FRAMEBUFFER,
|
GE( ctx, glGetFramebufferAttachmentParameteriv (GL_FRAMEBUFFER,
|
||||||
attachment,
|
attachment,
|
||||||
pname,
|
pname,
|
||||||
&framebuffer->red_bits) );
|
&framebuffer->red_bits) );
|
||||||
|
|
||||||
pname = GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE;
|
pname = GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE;
|
||||||
GE( glGetFramebufferAttachmentParameteriv (GL_FRAMEBUFFER,
|
GE( ctx, glGetFramebufferAttachmentParameteriv (GL_FRAMEBUFFER,
|
||||||
attachment,
|
attachment,
|
||||||
pname,
|
pname,
|
||||||
&framebuffer->green_bits) );
|
&framebuffer->green_bits)
|
||||||
|
);
|
||||||
|
|
||||||
pname = GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE;
|
pname = GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE;
|
||||||
GE( glGetFramebufferAttachmentParameteriv (GL_FRAMEBUFFER,
|
GE( ctx, glGetFramebufferAttachmentParameteriv (GL_FRAMEBUFFER,
|
||||||
attachment,
|
attachment,
|
||||||
pname,
|
pname,
|
||||||
&framebuffer->blue_bits) );
|
&framebuffer->blue_bits)
|
||||||
|
);
|
||||||
|
|
||||||
pname = GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE;
|
pname = GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE;
|
||||||
GE( glGetFramebufferAttachmentParameteriv (GL_FRAMEBUFFER,
|
GE( ctx, glGetFramebufferAttachmentParameteriv (GL_FRAMEBUFFER,
|
||||||
attachment,
|
attachment,
|
||||||
pname,
|
pname,
|
||||||
&framebuffer->alpha_bits) );
|
&framebuffer->alpha_bits)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif /* HAVE_COGL_GL */
|
#endif /* HAVE_COGL_GL */
|
||||||
{
|
{
|
||||||
GE( glGetIntegerv (GL_RED_BITS, &framebuffer->red_bits) );
|
GE( ctx, glGetIntegerv (GL_RED_BITS, &framebuffer->red_bits) );
|
||||||
GE( glGetIntegerv (GL_GREEN_BITS, &framebuffer->green_bits) );
|
GE( ctx, glGetIntegerv (GL_GREEN_BITS, &framebuffer->green_bits) );
|
||||||
GE( glGetIntegerv (GL_BLUE_BITS, &framebuffer->blue_bits) );
|
GE( ctx, glGetIntegerv (GL_BLUE_BITS, &framebuffer->blue_bits) );
|
||||||
GE( glGetIntegerv (GL_ALPHA_BITS, &framebuffer->alpha_bits) );
|
GE( ctx, glGetIntegerv (GL_ALPHA_BITS, &framebuffer->alpha_bits) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -729,28 +713,30 @@ try_creating_fbo (CoglOffscreen *offscreen,
|
|||||||
ctx->dirty_bound_framebuffer = 1;
|
ctx->dirty_bound_framebuffer = 1;
|
||||||
|
|
||||||
/* Generate framebuffer */
|
/* Generate framebuffer */
|
||||||
glGenFramebuffers (1, &fbo_gl_handle);
|
ctx->glGenFramebuffers (1, &fbo_gl_handle);
|
||||||
GE (glBindFramebuffer (GL_FRAMEBUFFER, fbo_gl_handle));
|
GE (ctx, glBindFramebuffer (GL_FRAMEBUFFER, fbo_gl_handle));
|
||||||
offscreen->fbo_handle = fbo_gl_handle;
|
offscreen->fbo_handle = fbo_gl_handle;
|
||||||
|
|
||||||
GE (glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
|
GE (ctx, glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
|
||||||
tex_gl_target, tex_gl_handle, data->level));
|
tex_gl_target, tex_gl_handle, data->level));
|
||||||
|
|
||||||
if (flags & _TRY_DEPTH_STENCIL)
|
if (flags & _TRY_DEPTH_STENCIL)
|
||||||
{
|
{
|
||||||
/* Create a renderbuffer for depth and stenciling */
|
/* Create a renderbuffer for depth and stenciling */
|
||||||
GE (glGenRenderbuffers (1, &gl_depth_stencil_handle));
|
GE (ctx, glGenRenderbuffers (1, &gl_depth_stencil_handle));
|
||||||
GE (glBindRenderbuffer (GL_RENDERBUFFER, gl_depth_stencil_handle));
|
GE (ctx, glBindRenderbuffer (GL_RENDERBUFFER, gl_depth_stencil_handle));
|
||||||
GE (glRenderbufferStorage (GL_RENDERBUFFER, GL_DEPTH_STENCIL,
|
GE (ctx, glRenderbufferStorage (GL_RENDERBUFFER, GL_DEPTH_STENCIL,
|
||||||
data->level_width,
|
data->level_width,
|
||||||
data->level_height));
|
data->level_height));
|
||||||
GE (glBindRenderbuffer (GL_RENDERBUFFER, 0));
|
GE (ctx, glBindRenderbuffer (GL_RENDERBUFFER, 0));
|
||||||
GE (glFramebufferRenderbuffer (GL_FRAMEBUFFER,
|
GE (ctx, glFramebufferRenderbuffer (GL_FRAMEBUFFER,
|
||||||
GL_STENCIL_ATTACHMENT,
|
GL_STENCIL_ATTACHMENT,
|
||||||
GL_RENDERBUFFER, gl_depth_stencil_handle));
|
GL_RENDERBUFFER,
|
||||||
GE (glFramebufferRenderbuffer (GL_FRAMEBUFFER,
|
gl_depth_stencil_handle));
|
||||||
|
GE (ctx, glFramebufferRenderbuffer (GL_FRAMEBUFFER,
|
||||||
GL_DEPTH_ATTACHMENT,
|
GL_DEPTH_ATTACHMENT,
|
||||||
GL_RENDERBUFFER, gl_depth_stencil_handle));
|
GL_RENDERBUFFER,
|
||||||
|
gl_depth_stencil_handle));
|
||||||
offscreen->renderbuffers =
|
offscreen->renderbuffers =
|
||||||
g_slist_prepend (offscreen->renderbuffers,
|
g_slist_prepend (offscreen->renderbuffers,
|
||||||
GUINT_TO_POINTER (gl_depth_stencil_handle));
|
GUINT_TO_POINTER (gl_depth_stencil_handle));
|
||||||
@ -758,15 +744,15 @@ try_creating_fbo (CoglOffscreen *offscreen,
|
|||||||
|
|
||||||
if (flags & _TRY_DEPTH)
|
if (flags & _TRY_DEPTH)
|
||||||
{
|
{
|
||||||
GE (glGenRenderbuffers (1, &gl_depth_handle));
|
GE (ctx, glGenRenderbuffers (1, &gl_depth_handle));
|
||||||
GE (glBindRenderbuffer (GL_RENDERBUFFER, gl_depth_handle));
|
GE (ctx, glBindRenderbuffer (GL_RENDERBUFFER, gl_depth_handle));
|
||||||
/* For now we just ask for GL_DEPTH_COMPONENT16 since this is all that's
|
/* For now we just ask for GL_DEPTH_COMPONENT16 since this is all that's
|
||||||
* available under GLES */
|
* available under GLES */
|
||||||
GE (glRenderbufferStorage (GL_RENDERBUFFER, GL_DEPTH_COMPONENT16,
|
GE (ctx, glRenderbufferStorage (GL_RENDERBUFFER, GL_DEPTH_COMPONENT16,
|
||||||
data->level_width,
|
data->level_width,
|
||||||
data->level_height));
|
data->level_height));
|
||||||
GE (glBindRenderbuffer (GL_RENDERBUFFER, 0));
|
GE (ctx, glBindRenderbuffer (GL_RENDERBUFFER, 0));
|
||||||
GE (glFramebufferRenderbuffer (GL_FRAMEBUFFER,
|
GE (ctx, glFramebufferRenderbuffer (GL_FRAMEBUFFER,
|
||||||
GL_DEPTH_ATTACHMENT,
|
GL_DEPTH_ATTACHMENT,
|
||||||
GL_RENDERBUFFER, gl_depth_handle));
|
GL_RENDERBUFFER, gl_depth_handle));
|
||||||
offscreen->renderbuffers =
|
offscreen->renderbuffers =
|
||||||
@ -776,13 +762,13 @@ try_creating_fbo (CoglOffscreen *offscreen,
|
|||||||
|
|
||||||
if (flags & _TRY_STENCIL)
|
if (flags & _TRY_STENCIL)
|
||||||
{
|
{
|
||||||
GE (glGenRenderbuffers (1, &gl_stencil_handle));
|
GE (ctx, glGenRenderbuffers (1, &gl_stencil_handle));
|
||||||
GE (glBindRenderbuffer (GL_RENDERBUFFER, gl_stencil_handle));
|
GE (ctx, glBindRenderbuffer (GL_RENDERBUFFER, gl_stencil_handle));
|
||||||
GE (glRenderbufferStorage (GL_RENDERBUFFER, GL_STENCIL_INDEX8,
|
GE (ctx, glRenderbufferStorage (GL_RENDERBUFFER, GL_STENCIL_INDEX8,
|
||||||
data->level_width,
|
data->level_width,
|
||||||
data->level_height));
|
data->level_height));
|
||||||
GE (glBindRenderbuffer (GL_RENDERBUFFER, 0));
|
GE (ctx, glBindRenderbuffer (GL_RENDERBUFFER, 0));
|
||||||
GE (glFramebufferRenderbuffer (GL_FRAMEBUFFER,
|
GE (ctx, glFramebufferRenderbuffer (GL_FRAMEBUFFER,
|
||||||
GL_STENCIL_ATTACHMENT,
|
GL_STENCIL_ATTACHMENT,
|
||||||
GL_RENDERBUFFER, gl_stencil_handle));
|
GL_RENDERBUFFER, gl_stencil_handle));
|
||||||
offscreen->renderbuffers =
|
offscreen->renderbuffers =
|
||||||
@ -791,18 +777,18 @@ try_creating_fbo (CoglOffscreen *offscreen,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Make sure it's complete */
|
/* Make sure it's complete */
|
||||||
status = glCheckFramebufferStatus (GL_FRAMEBUFFER);
|
status = ctx->glCheckFramebufferStatus (GL_FRAMEBUFFER);
|
||||||
|
|
||||||
if (status != GL_FRAMEBUFFER_COMPLETE)
|
if (status != GL_FRAMEBUFFER_COMPLETE)
|
||||||
{
|
{
|
||||||
GSList *l;
|
GSList *l;
|
||||||
|
|
||||||
GE (glDeleteFramebuffers (1, &fbo_gl_handle));
|
GE (ctx, glDeleteFramebuffers (1, &fbo_gl_handle));
|
||||||
|
|
||||||
for (l = offscreen->renderbuffers; l; l = l->next)
|
for (l = offscreen->renderbuffers; l; l = l->next)
|
||||||
{
|
{
|
||||||
GLuint renderbuffer = GPOINTER_TO_UINT (l->data);
|
GLuint renderbuffer = GPOINTER_TO_UINT (l->data);
|
||||||
GE (glDeleteRenderbuffers (1, &renderbuffer));
|
GE (ctx, glDeleteRenderbuffers (1, &renderbuffer));
|
||||||
}
|
}
|
||||||
|
|
||||||
g_slist_free (offscreen->renderbuffers);
|
g_slist_free (offscreen->renderbuffers);
|
||||||
@ -941,9 +927,7 @@ static void
|
|||||||
_cogl_offscreen_free (CoglOffscreen *offscreen)
|
_cogl_offscreen_free (CoglOffscreen *offscreen)
|
||||||
{
|
{
|
||||||
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (offscreen);
|
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (offscreen);
|
||||||
#ifndef HAVE_COGL_GLES2
|
|
||||||
CoglContext *ctx = framebuffer->context;
|
CoglContext *ctx = framebuffer->context;
|
||||||
#endif
|
|
||||||
GSList *l;
|
GSList *l;
|
||||||
|
|
||||||
/* Chain up to parent */
|
/* Chain up to parent */
|
||||||
@ -952,11 +936,11 @@ _cogl_offscreen_free (CoglOffscreen *offscreen)
|
|||||||
for (l = offscreen->renderbuffers; l; l = l->next)
|
for (l = offscreen->renderbuffers; l; l = l->next)
|
||||||
{
|
{
|
||||||
GLuint renderbuffer = GPOINTER_TO_UINT (l->data);
|
GLuint renderbuffer = GPOINTER_TO_UINT (l->data);
|
||||||
GE (glDeleteRenderbuffers (1, &renderbuffer));
|
GE (ctx, glDeleteRenderbuffers (1, &renderbuffer));
|
||||||
}
|
}
|
||||||
g_slist_free (offscreen->renderbuffers);
|
g_slist_free (offscreen->renderbuffers);
|
||||||
|
|
||||||
GE (glDeleteFramebuffers (1, &offscreen->fbo_handle));
|
GE (ctx, glDeleteFramebuffers (1, &offscreen->fbo_handle));
|
||||||
|
|
||||||
if (offscreen->texture != COGL_INVALID_HANDLE)
|
if (offscreen->texture != COGL_INVALID_HANDLE)
|
||||||
cogl_handle_unref (offscreen->texture);
|
cogl_handle_unref (offscreen->texture);
|
||||||
@ -1368,7 +1352,7 @@ bind_gl_framebuffer (CoglContext *ctx,
|
|||||||
CoglFramebuffer *framebuffer)
|
CoglFramebuffer *framebuffer)
|
||||||
{
|
{
|
||||||
if (framebuffer->type == COGL_FRAMEBUFFER_TYPE_OFFSCREEN)
|
if (framebuffer->type == COGL_FRAMEBUFFER_TYPE_OFFSCREEN)
|
||||||
GE (glBindFramebuffer (target,
|
GE (ctx, glBindFramebuffer (target,
|
||||||
COGL_OFFSCREEN (framebuffer)->fbo_handle));
|
COGL_OFFSCREEN (framebuffer)->fbo_handle));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1377,7 +1361,7 @@ bind_gl_framebuffer (CoglContext *ctx,
|
|||||||
winsys->onscreen_bind (COGL_ONSCREEN (framebuffer));
|
winsys->onscreen_bind (COGL_ONSCREEN (framebuffer));
|
||||||
/* glBindFramebuffer is an an extension with OpenGL ES 1.1 */
|
/* glBindFramebuffer is an an extension with OpenGL ES 1.1 */
|
||||||
if (cogl_features_available (COGL_FEATURE_OFFSCREEN))
|
if (cogl_features_available (COGL_FEATURE_OFFSCREEN))
|
||||||
GE (glBindFramebuffer (target, 0));
|
GE (ctx, glBindFramebuffer (target, 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1435,7 +1419,7 @@ _cogl_framebuffer_flush_state (CoglFramebuffer *draw_buffer,
|
|||||||
draw_buffer->viewport_width,
|
draw_buffer->viewport_width,
|
||||||
draw_buffer->viewport_height);
|
draw_buffer->viewport_height);
|
||||||
|
|
||||||
GE (glViewport (draw_buffer->viewport_x,
|
GE (ctx, glViewport (draw_buffer->viewport_x,
|
||||||
gl_viewport_y,
|
gl_viewport_y,
|
||||||
draw_buffer->viewport_width,
|
draw_buffer->viewport_width,
|
||||||
draw_buffer->viewport_height));
|
draw_buffer->viewport_height));
|
||||||
@ -1596,7 +1580,7 @@ _cogl_blit_framebuffer (unsigned int src_x,
|
|||||||
the scissor */
|
the scissor */
|
||||||
_cogl_clip_stack_flush (NULL);
|
_cogl_clip_stack_flush (NULL);
|
||||||
|
|
||||||
glBlitFramebuffer (src_x, src_y,
|
ctx->glBlitFramebuffer (src_x, src_y,
|
||||||
src_x + width, src_y + height,
|
src_x + width, src_y + height,
|
||||||
dst_x, dst_y,
|
dst_x, dst_y,
|
||||||
dst_x + width, dst_y + height,
|
dst_x + width, dst_y + height,
|
||||||
|
@ -66,10 +66,10 @@ typedef struct _CoglBoxedValue
|
|||||||
const char *
|
const char *
|
||||||
cogl_gl_error_to_string (GLenum error_code);
|
cogl_gl_error_to_string (GLenum error_code);
|
||||||
|
|
||||||
#define GE(x) G_STMT_START { \
|
#define GE(ctx, x) G_STMT_START { \
|
||||||
GLenum __err; \
|
GLenum __err; \
|
||||||
(x); \
|
(ctx)->x; \
|
||||||
while ((__err = glGetError ()) != GL_NO_ERROR) \
|
while ((__err = (ctx)->glGetError ()) != GL_NO_ERROR) \
|
||||||
{ \
|
{ \
|
||||||
g_warning ("%s: GL error (%d): %s\n", \
|
g_warning ("%s: GL error (%d): %s\n", \
|
||||||
G_STRLOC, \
|
G_STRLOC, \
|
||||||
@ -77,10 +77,10 @@ cogl_gl_error_to_string (GLenum error_code);
|
|||||||
cogl_gl_error_to_string (__err)); \
|
cogl_gl_error_to_string (__err)); \
|
||||||
} } G_STMT_END
|
} } G_STMT_END
|
||||||
|
|
||||||
#define GE_RET(ret, x) G_STMT_START { \
|
#define GE_RET(ret, ctx, x) G_STMT_START { \
|
||||||
GLenum __err; \
|
GLenum __err; \
|
||||||
ret = (x); \
|
ret = (ctx)->x; \
|
||||||
while ((__err = glGetError ()) != GL_NO_ERROR) \
|
while ((__err = (ctx)->glGetError ()) != GL_NO_ERROR) \
|
||||||
{ \
|
{ \
|
||||||
g_warning ("%s: GL error (%d): %s\n", \
|
g_warning ("%s: GL error (%d): %s\n", \
|
||||||
G_STRLOC, \
|
G_STRLOC, \
|
||||||
@ -90,8 +90,8 @@ cogl_gl_error_to_string (GLenum error_code);
|
|||||||
|
|
||||||
#else /* !COGL_GL_DEBUG */
|
#else /* !COGL_GL_DEBUG */
|
||||||
|
|
||||||
#define GE(x) (x)
|
#define GE(ctx, x) ((ctx)->x)
|
||||||
#define GE_RET(ret, x) (ret = (x))
|
#define GE_RET(ret, ctx, x) (ret = ((ctx)->x))
|
||||||
|
|
||||||
#endif /* COGL_GL_DEBUG */
|
#endif /* COGL_GL_DEBUG */
|
||||||
|
|
||||||
|
@ -402,15 +402,17 @@ flush_to_fixed_api_gl (gboolean is_identity,
|
|||||||
{
|
{
|
||||||
CoglMatrixStack *stack = user_data;
|
CoglMatrixStack *stack = user_data;
|
||||||
|
|
||||||
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
if (is_identity)
|
if (is_identity)
|
||||||
{
|
{
|
||||||
if (!stack->flushed_identity)
|
if (!stack->flushed_identity)
|
||||||
GE (glLoadIdentity ());
|
GE (ctx, glLoadIdentity ());
|
||||||
stack->flushed_identity = TRUE;
|
stack->flushed_identity = TRUE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GE (glLoadMatrixf (cogl_matrix_get_array (matrix)) );
|
GE (ctx, glLoadMatrixf (cogl_matrix_get_array (matrix)) );
|
||||||
stack->flushed_identity = FALSE;
|
stack->flushed_identity = FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -516,7 +518,7 @@ _cogl_matrix_stack_flush_to_gl (CoglMatrixStack *stack,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
GE (glMatrixMode (gl_mode));
|
GE (ctx, glMatrixMode (gl_mode));
|
||||||
ctx->flushed_matrix_mode = mode;
|
ctx->flushed_matrix_mode = mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,19 +50,6 @@
|
|||||||
#include <glib/gprintf.h>
|
#include <glib/gprintf.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
/*
|
|
||||||
* GL/GLES compatability defines for pipeline thingies:
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef HAVE_COGL_GL
|
|
||||||
#define glProgramString ctx->glProgramString
|
|
||||||
#define glBindProgram ctx->glBindProgram
|
|
||||||
#define glDeletePrograms ctx->glDeletePrograms
|
|
||||||
#define glGenPrograms ctx->glGenPrograms
|
|
||||||
#define glProgramLocalParameter4fv ctx->glProgramLocalParameter4fv
|
|
||||||
#define glUseProgram ctx->glUseProgram
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* This might not be defined on GLES */
|
/* This might not be defined on GLES */
|
||||||
#ifndef GL_TEXTURE_3D
|
#ifndef GL_TEXTURE_3D
|
||||||
#define GL_TEXTURE_3D 0x806F
|
#define GL_TEXTURE_3D 0x806F
|
||||||
@ -135,7 +122,7 @@ arbfp_program_state_unref (ArbfpProgramState *state)
|
|||||||
{
|
{
|
||||||
if (state->gl_program)
|
if (state->gl_program)
|
||||||
{
|
{
|
||||||
GE (glDeletePrograms (1, &state->gl_program));
|
GE (ctx, glDeletePrograms (1, &state->gl_program));
|
||||||
state->gl_program = 0;
|
state->gl_program = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -866,7 +853,7 @@ update_constants_cb (CoglPipeline *pipeline,
|
|||||||
_cogl_pipeline_get_layer_combine_constant (pipeline,
|
_cogl_pipeline_get_layer_combine_constant (pipeline,
|
||||||
layer_index,
|
layer_index,
|
||||||
constant);
|
constant);
|
||||||
GE (glProgramLocalParameter4fv (GL_FRAGMENT_PROGRAM_ARB,
|
GE (ctx, glProgramLocalParameter4fv (GL_FRAGMENT_PROGRAM_ARB,
|
||||||
unit_state->constant_id,
|
unit_state->constant_id,
|
||||||
constant));
|
constant));
|
||||||
unit_state->dirty_combine_constant = FALSE;
|
unit_state->dirty_combine_constant = FALSE;
|
||||||
@ -901,22 +888,22 @@ _cogl_pipeline_fragend_arbfp_end (CoglPipeline *pipeline,
|
|||||||
if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_SHOW_SOURCE)))
|
if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_SHOW_SOURCE)))
|
||||||
g_message ("pipeline program:\n%s", arbfp_program_state->source->str);
|
g_message ("pipeline program:\n%s", arbfp_program_state->source->str);
|
||||||
|
|
||||||
GE (glGenPrograms (1, &arbfp_program_state->gl_program));
|
GE (ctx, glGenPrograms (1, &arbfp_program_state->gl_program));
|
||||||
|
|
||||||
GE (glBindProgram (GL_FRAGMENT_PROGRAM_ARB,
|
GE (ctx, glBindProgram (GL_FRAGMENT_PROGRAM_ARB,
|
||||||
arbfp_program_state->gl_program));
|
arbfp_program_state->gl_program));
|
||||||
|
|
||||||
while ((gl_error = glGetError ()) != GL_NO_ERROR)
|
while ((gl_error = ctx->glGetError ()) != GL_NO_ERROR)
|
||||||
;
|
;
|
||||||
glProgramString (GL_FRAGMENT_PROGRAM_ARB,
|
ctx->glProgramString (GL_FRAGMENT_PROGRAM_ARB,
|
||||||
GL_PROGRAM_FORMAT_ASCII_ARB,
|
GL_PROGRAM_FORMAT_ASCII_ARB,
|
||||||
arbfp_program_state->source->len,
|
arbfp_program_state->source->len,
|
||||||
arbfp_program_state->source->str);
|
arbfp_program_state->source->str);
|
||||||
if (glGetError () != GL_NO_ERROR)
|
if (ctx->glGetError () != GL_NO_ERROR)
|
||||||
{
|
{
|
||||||
g_warning ("\n%s\n%s",
|
g_warning ("\n%s\n%s",
|
||||||
arbfp_program_state->source->str,
|
arbfp_program_state->source->str,
|
||||||
glGetString (GL_PROGRAM_ERROR_STRING_ARB));
|
ctx->glGetString (GL_PROGRAM_ERROR_STRING_ARB));
|
||||||
}
|
}
|
||||||
|
|
||||||
arbfp_program_state->source = NULL;
|
arbfp_program_state->source = NULL;
|
||||||
@ -979,7 +966,7 @@ _cogl_pipeline_fragend_arbfp_end (CoglPipeline *pipeline,
|
|||||||
else
|
else
|
||||||
gl_program = arbfp_program_state->gl_program;
|
gl_program = arbfp_program_state->gl_program;
|
||||||
|
|
||||||
GE (glBindProgram (GL_FRAGMENT_PROGRAM_ARB, gl_program));
|
GE (ctx, glBindProgram (GL_FRAGMENT_PROGRAM_ARB, gl_program));
|
||||||
_cogl_use_fragment_program (0, COGL_PIPELINE_PROGRAM_TYPE_ARBFP);
|
_cogl_use_fragment_program (0, COGL_PIPELINE_PROGRAM_TYPE_ARBFP);
|
||||||
|
|
||||||
if (arbfp_program_state->user_program == COGL_INVALID_HANDLE)
|
if (arbfp_program_state->user_program == COGL_INVALID_HANDLE)
|
||||||
|
@ -62,7 +62,7 @@ _cogl_disable_texture_unit (int unit_index)
|
|||||||
if (unit->enabled_gl_target)
|
if (unit->enabled_gl_target)
|
||||||
{
|
{
|
||||||
_cogl_set_active_texture_unit (unit_index);
|
_cogl_set_active_texture_unit (unit_index);
|
||||||
GE (glDisable (unit->enabled_gl_target));
|
GE (ctx, glDisable (unit->enabled_gl_target));
|
||||||
unit->enabled_gl_target = 0;
|
unit->enabled_gl_target = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -77,7 +77,7 @@ get_max_texture_units (void)
|
|||||||
if (ctx->max_texture_units == -1)
|
if (ctx->max_texture_units == -1)
|
||||||
{
|
{
|
||||||
ctx->max_texture_units = 1;
|
ctx->max_texture_units = 1;
|
||||||
GE (glGetIntegerv (GL_MAX_TEXTURE_UNITS,
|
GE (ctx, glGetIntegerv (GL_MAX_TEXTURE_UNITS,
|
||||||
&ctx->max_texture_units));
|
&ctx->max_texture_units));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,12 +162,12 @@ _cogl_pipeline_fragend_fixed_add_layer (CoglPipeline *pipeline,
|
|||||||
{
|
{
|
||||||
/* Disable the previous target if it's still enabled */
|
/* Disable the previous target if it's still enabled */
|
||||||
if (unit->enabled_gl_target)
|
if (unit->enabled_gl_target)
|
||||||
GE (glDisable (unit->enabled_gl_target));
|
GE (ctx, glDisable (unit->enabled_gl_target));
|
||||||
|
|
||||||
/* Enable the new target */
|
/* Enable the new target */
|
||||||
if (!G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_DISABLE_TEXTURING)))
|
if (!G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_DISABLE_TEXTURING)))
|
||||||
{
|
{
|
||||||
GE (glEnable (gl_target));
|
GE (ctx, glEnable (gl_target));
|
||||||
unit->enabled_gl_target = gl_target;
|
unit->enabled_gl_target = gl_target;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -183,7 +183,7 @@ _cogl_pipeline_fragend_fixed_add_layer (CoglPipeline *pipeline,
|
|||||||
unit->enabled_gl_target == 0)
|
unit->enabled_gl_target == 0)
|
||||||
{
|
{
|
||||||
_cogl_set_active_texture_unit (unit_index);
|
_cogl_set_active_texture_unit (unit_index);
|
||||||
GE (glEnable (unit->gl_target));
|
GE (ctx, glEnable (unit->gl_target));
|
||||||
unit->enabled_gl_target = unit->gl_target;
|
unit->enabled_gl_target = unit->gl_target;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -195,13 +195,13 @@ _cogl_pipeline_fragend_fixed_add_layer (CoglPipeline *pipeline,
|
|||||||
COGL_PIPELINE_LAYER_STATE_COMBINE);
|
COGL_PIPELINE_LAYER_STATE_COMBINE);
|
||||||
CoglPipelineLayerBigState *big_state = authority->big_state;
|
CoglPipelineLayerBigState *big_state = authority->big_state;
|
||||||
|
|
||||||
GE (glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE));
|
GE (ctx, glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE));
|
||||||
|
|
||||||
/* Set the combiner functions... */
|
/* Set the combiner functions... */
|
||||||
GE (glTexEnvi (GL_TEXTURE_ENV,
|
GE (ctx, glTexEnvi (GL_TEXTURE_ENV,
|
||||||
GL_COMBINE_RGB,
|
GL_COMBINE_RGB,
|
||||||
big_state->texture_combine_rgb_func));
|
big_state->texture_combine_rgb_func));
|
||||||
GE (glTexEnvi (GL_TEXTURE_ENV,
|
GE (ctx, glTexEnvi (GL_TEXTURE_ENV,
|
||||||
GL_COMBINE_ALPHA,
|
GL_COMBINE_ALPHA,
|
||||||
big_state->texture_combine_alpha_func));
|
big_state->texture_combine_alpha_func));
|
||||||
|
|
||||||
@ -213,22 +213,22 @@ _cogl_pipeline_fragend_fixed_add_layer (CoglPipeline *pipeline,
|
|||||||
n_rgb_func_args =
|
n_rgb_func_args =
|
||||||
_cogl_get_n_args_for_combine_func (big_state->texture_combine_rgb_func);
|
_cogl_get_n_args_for_combine_func (big_state->texture_combine_rgb_func);
|
||||||
|
|
||||||
GE (glTexEnvi (GL_TEXTURE_ENV, GL_SRC0_RGB,
|
GE (ctx, glTexEnvi (GL_TEXTURE_ENV, GL_SRC0_RGB,
|
||||||
big_state->texture_combine_rgb_src[0]));
|
big_state->texture_combine_rgb_src[0]));
|
||||||
GE (glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND0_RGB,
|
GE (ctx, glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND0_RGB,
|
||||||
big_state->texture_combine_rgb_op[0]));
|
big_state->texture_combine_rgb_op[0]));
|
||||||
if (n_rgb_func_args > 1)
|
if (n_rgb_func_args > 1)
|
||||||
{
|
{
|
||||||
GE (glTexEnvi (GL_TEXTURE_ENV, GL_SRC1_RGB,
|
GE (ctx, glTexEnvi (GL_TEXTURE_ENV, GL_SRC1_RGB,
|
||||||
big_state->texture_combine_rgb_src[1]));
|
big_state->texture_combine_rgb_src[1]));
|
||||||
GE (glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND1_RGB,
|
GE (ctx, glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND1_RGB,
|
||||||
big_state->texture_combine_rgb_op[1]));
|
big_state->texture_combine_rgb_op[1]));
|
||||||
}
|
}
|
||||||
if (n_rgb_func_args > 2)
|
if (n_rgb_func_args > 2)
|
||||||
{
|
{
|
||||||
GE (glTexEnvi (GL_TEXTURE_ENV, GL_SRC2_RGB,
|
GE (ctx, glTexEnvi (GL_TEXTURE_ENV, GL_SRC2_RGB,
|
||||||
big_state->texture_combine_rgb_src[2]));
|
big_state->texture_combine_rgb_src[2]));
|
||||||
GE (glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND2_RGB,
|
GE (ctx, glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND2_RGB,
|
||||||
big_state->texture_combine_rgb_op[2]));
|
big_state->texture_combine_rgb_op[2]));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -236,22 +236,22 @@ _cogl_pipeline_fragend_fixed_add_layer (CoglPipeline *pipeline,
|
|||||||
n_alpha_func_args =
|
n_alpha_func_args =
|
||||||
_cogl_get_n_args_for_combine_func (big_state->texture_combine_alpha_func);
|
_cogl_get_n_args_for_combine_func (big_state->texture_combine_alpha_func);
|
||||||
|
|
||||||
GE (glTexEnvi (GL_TEXTURE_ENV, GL_SRC0_ALPHA,
|
GE (ctx, glTexEnvi (GL_TEXTURE_ENV, GL_SRC0_ALPHA,
|
||||||
big_state->texture_combine_alpha_src[0]));
|
big_state->texture_combine_alpha_src[0]));
|
||||||
GE (glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND0_ALPHA,
|
GE (ctx, glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND0_ALPHA,
|
||||||
big_state->texture_combine_alpha_op[0]));
|
big_state->texture_combine_alpha_op[0]));
|
||||||
if (n_alpha_func_args > 1)
|
if (n_alpha_func_args > 1)
|
||||||
{
|
{
|
||||||
GE (glTexEnvi (GL_TEXTURE_ENV, GL_SRC1_ALPHA,
|
GE (ctx, glTexEnvi (GL_TEXTURE_ENV, GL_SRC1_ALPHA,
|
||||||
big_state->texture_combine_alpha_src[1]));
|
big_state->texture_combine_alpha_src[1]));
|
||||||
GE (glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND1_ALPHA,
|
GE (ctx, glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND1_ALPHA,
|
||||||
big_state->texture_combine_alpha_op[1]));
|
big_state->texture_combine_alpha_op[1]));
|
||||||
}
|
}
|
||||||
if (n_alpha_func_args > 2)
|
if (n_alpha_func_args > 2)
|
||||||
{
|
{
|
||||||
GE (glTexEnvi (GL_TEXTURE_ENV, GL_SRC2_ALPHA,
|
GE (ctx, glTexEnvi (GL_TEXTURE_ENV, GL_SRC2_ALPHA,
|
||||||
big_state->texture_combine_alpha_src[2]));
|
big_state->texture_combine_alpha_src[2]));
|
||||||
GE (glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND2_ALPHA,
|
GE (ctx, glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND2_ALPHA,
|
||||||
big_state->texture_combine_alpha_op[2]));
|
big_state->texture_combine_alpha_op[2]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -263,7 +263,7 @@ _cogl_pipeline_fragend_fixed_add_layer (CoglPipeline *pipeline,
|
|||||||
(layer, COGL_PIPELINE_LAYER_STATE_COMBINE_CONSTANT);
|
(layer, COGL_PIPELINE_LAYER_STATE_COMBINE_CONSTANT);
|
||||||
CoglPipelineLayerBigState *big_state = authority->big_state;
|
CoglPipelineLayerBigState *big_state = authority->big_state;
|
||||||
|
|
||||||
GE (glTexEnvfv (GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR,
|
GE (ctx, glTexEnvfv (GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR,
|
||||||
big_state->texture_combine_constant));
|
big_state->texture_combine_constant));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -315,9 +315,9 @@ _cogl_pipeline_fragend_fixed_end (CoglPipeline *pipeline,
|
|||||||
fogColor[2] = cogl_color_get_blue_float (&fog_state->color);
|
fogColor[2] = cogl_color_get_blue_float (&fog_state->color);
|
||||||
fogColor[3] = cogl_color_get_alpha_float (&fog_state->color);
|
fogColor[3] = cogl_color_get_alpha_float (&fog_state->color);
|
||||||
|
|
||||||
GE (glEnable (GL_FOG));
|
GE (ctx, glEnable (GL_FOG));
|
||||||
|
|
||||||
GE (glFogfv (GL_FOG_COLOR, fogColor));
|
GE (ctx, glFogfv (GL_FOG_COLOR, fogColor));
|
||||||
|
|
||||||
#if HAVE_COGL_GLES
|
#if HAVE_COGL_GLES
|
||||||
switch (fog_state->mode)
|
switch (fog_state->mode)
|
||||||
@ -336,15 +336,15 @@ _cogl_pipeline_fragend_fixed_end (CoglPipeline *pipeline,
|
|||||||
/* TODO: support other modes for GLES2 */
|
/* TODO: support other modes for GLES2 */
|
||||||
|
|
||||||
/* NB: GLES doesn't have glFogi */
|
/* NB: GLES doesn't have glFogi */
|
||||||
GE (glFogf (GL_FOG_MODE, gl_mode));
|
GE (ctx, glFogf (GL_FOG_MODE, gl_mode));
|
||||||
GE (glHint (GL_FOG_HINT, GL_NICEST));
|
GE (ctx, glHint (GL_FOG_HINT, GL_NICEST));
|
||||||
|
|
||||||
GE (glFogf (GL_FOG_DENSITY, fog_state->density));
|
GE (ctx, glFogf (GL_FOG_DENSITY, fog_state->density));
|
||||||
GE (glFogf (GL_FOG_START, fog_state->z_near));
|
GE (ctx, glFogf (GL_FOG_START, fog_state->z_near));
|
||||||
GE (glFogf (GL_FOG_END, fog_state->z_far));
|
GE (ctx, glFogf (GL_FOG_END, fog_state->z_far));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
GE (glDisable (GL_FOG));
|
GE (ctx, glDisable (GL_FOG));
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -45,17 +45,6 @@
|
|||||||
#include "cogl-shader-private.h"
|
#include "cogl-shader-private.h"
|
||||||
#include "cogl-program-private.h"
|
#include "cogl-program-private.h"
|
||||||
|
|
||||||
#ifndef HAVE_COGL_GLES2
|
|
||||||
|
|
||||||
#define glCreateShader ctx->glCreateShader
|
|
||||||
#define glGetShaderiv ctx->glGetShaderiv
|
|
||||||
#define glGetShaderInfoLog ctx->glGetShaderInfoLog
|
|
||||||
#define glCompileShader ctx->glCompileShader
|
|
||||||
#define glShaderSource ctx->glShaderSource
|
|
||||||
#define glDeleteShader ctx->glDeleteShader
|
|
||||||
|
|
||||||
#endif /* HAVE_COGL_GLES2 */
|
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -124,7 +113,7 @@ glsl_shader_state_unref (GlslShaderState *state)
|
|||||||
if (state->ref_count == 0)
|
if (state->ref_count == 0)
|
||||||
{
|
{
|
||||||
if (state->gl_shader)
|
if (state->gl_shader)
|
||||||
GE( glDeleteShader (state->gl_shader) );
|
GE( ctx, glDeleteShader (state->gl_shader) );
|
||||||
|
|
||||||
g_free (state->unit_state);
|
g_free (state->unit_state);
|
||||||
|
|
||||||
@ -277,7 +266,7 @@ _cogl_pipeline_fragend_glsl_start (CoglPipeline *pipeline,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
/* We need to recreate the shader so destroy the existing one */
|
/* We need to recreate the shader so destroy the existing one */
|
||||||
GE( glDeleteShader (priv->glsl_shader_state->gl_shader) );
|
GE( ctx, glDeleteShader (priv->glsl_shader_state->gl_shader) );
|
||||||
priv->glsl_shader_state->gl_shader = 0;
|
priv->glsl_shader_state->gl_shader = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -798,7 +787,7 @@ _cogl_pipeline_fragend_glsl_end (CoglPipeline *pipeline,
|
|||||||
|
|
||||||
g_string_append (glsl_shader_state->source, "}\n");
|
g_string_append (glsl_shader_state->source, "}\n");
|
||||||
|
|
||||||
GE_RET( shader, glCreateShader (GL_FRAGMENT_SHADER) );
|
GE_RET( shader, ctx, glCreateShader (GL_FRAGMENT_SHADER) );
|
||||||
|
|
||||||
lengths[0] = glsl_shader_state->header->len;
|
lengths[0] = glsl_shader_state->header->len;
|
||||||
source_strings[0] = glsl_shader_state->header->str;
|
source_strings[0] = glsl_shader_state->header->str;
|
||||||
@ -817,17 +806,17 @@ _cogl_pipeline_fragend_glsl_end (CoglPipeline *pipeline,
|
|||||||
2, /* count */
|
2, /* count */
|
||||||
source_strings, lengths);
|
source_strings, lengths);
|
||||||
|
|
||||||
GE( glCompileShader (shader) );
|
GE( ctx, glCompileShader (shader) );
|
||||||
GE( glGetShaderiv (shader, GL_COMPILE_STATUS, &compile_status) );
|
GE( ctx, glGetShaderiv (shader, GL_COMPILE_STATUS, &compile_status) );
|
||||||
|
|
||||||
if (!compile_status)
|
if (!compile_status)
|
||||||
{
|
{
|
||||||
GLint len = 0;
|
GLint len = 0;
|
||||||
char *shader_log;
|
char *shader_log;
|
||||||
|
|
||||||
GE( glGetShaderiv (shader, GL_INFO_LOG_LENGTH, &len) );
|
GE( ctx, glGetShaderiv (shader, GL_INFO_LOG_LENGTH, &len) );
|
||||||
shader_log = g_alloca (len);
|
shader_log = g_alloca (len);
|
||||||
GE( glGetShaderInfoLog (shader, len, &len, shader_log) );
|
GE( ctx, glGetShaderInfoLog (shader, len, &len, shader_log) );
|
||||||
g_warning ("Shader compilation failed:\n%s", shader_log);
|
g_warning ("Shader compilation failed:\n%s", shader_log);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,20 +49,6 @@
|
|||||||
* GL/GLES compatability defines for pipeline thingies:
|
* GL/GLES compatability defines for pipeline thingies:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_COGL_GL
|
|
||||||
#define glActiveTexture ctx->glActiveTexture
|
|
||||||
#define glClientActiveTexture ctx->glClientActiveTexture
|
|
||||||
#define glBlendEquation ctx->glBlendEquation
|
|
||||||
#define glBlendColor ctx->glBlendColor
|
|
||||||
|
|
||||||
#define glProgramString ctx->glProgramString
|
|
||||||
#define glBindProgram ctx->glBindProgram
|
|
||||||
#define glDeletePrograms ctx->glDeletePrograms
|
|
||||||
#define glGenPrograms ctx->glGenPrograms
|
|
||||||
#define glProgramLocalParameter4fv ctx->glProgramLocalParameter4fv
|
|
||||||
#define glUseProgram ctx->glUseProgram
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* These aren't defined in the GLES headers */
|
/* These aren't defined in the GLES headers */
|
||||||
#ifndef GL_POINT_SPRITE
|
#ifndef GL_POINT_SPRITE
|
||||||
#define GL_POINT_SPRITE 0x8861
|
#define GL_POINT_SPRITE 0x8861
|
||||||
@ -144,7 +130,7 @@ _cogl_set_active_texture_unit (int unit_index)
|
|||||||
|
|
||||||
if (ctx->active_texture_unit != unit_index)
|
if (ctx->active_texture_unit != unit_index)
|
||||||
{
|
{
|
||||||
GE (glActiveTexture (GL_TEXTURE0 + unit_index));
|
GE (ctx, glActiveTexture (GL_TEXTURE0 + unit_index));
|
||||||
ctx->active_texture_unit = unit_index;
|
ctx->active_texture_unit = unit_index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -196,7 +182,7 @@ _cogl_bind_gl_texture_transient (GLenum gl_target,
|
|||||||
!unit->is_foreign)
|
!unit->is_foreign)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
GE (glBindTexture (gl_target, gl_texture));
|
GE (ctx, glBindTexture (gl_target, gl_texture));
|
||||||
|
|
||||||
unit->dirty_gl_texture = TRUE;
|
unit->dirty_gl_texture = TRUE;
|
||||||
unit->is_foreign = is_foreign;
|
unit->is_foreign = is_foreign;
|
||||||
@ -222,7 +208,7 @@ _cogl_delete_gl_texture (GLuint gl_texture)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GE (glDeleteTextures (1, &gl_texture));
|
GE (ctx, glDeleteTextures (1, &gl_texture));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Whenever the underlying GL texture storage of a CoglTexture is
|
/* Whenever the underlying GL texture storage of a CoglTexture is
|
||||||
@ -266,14 +252,14 @@ set_glsl_program (GLuint gl_program)
|
|||||||
{
|
{
|
||||||
GLenum gl_error;
|
GLenum gl_error;
|
||||||
|
|
||||||
while ((gl_error = glGetError ()) != GL_NO_ERROR)
|
while ((gl_error = ctx->glGetError ()) != GL_NO_ERROR)
|
||||||
;
|
;
|
||||||
glUseProgram (gl_program);
|
ctx->glUseProgram (gl_program);
|
||||||
if (glGetError () == GL_NO_ERROR)
|
if (ctx->glGetError () == GL_NO_ERROR)
|
||||||
ctx->current_gl_program = gl_program;
|
ctx->current_gl_program = gl_program;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GE( glUseProgram (0) );
|
GE( ctx, glUseProgram (0) );
|
||||||
ctx->current_gl_program = 0;
|
ctx->current_gl_program = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -302,7 +288,7 @@ _cogl_use_fragment_program (GLuint gl_program, CoglPipelineProgramType type)
|
|||||||
|
|
||||||
case COGL_PIPELINE_PROGRAM_TYPE_ARBFP:
|
case COGL_PIPELINE_PROGRAM_TYPE_ARBFP:
|
||||||
#ifdef HAVE_COGL_GL
|
#ifdef HAVE_COGL_GL
|
||||||
GE( glDisable (GL_FRAGMENT_PROGRAM_ARB) );
|
GE( ctx, glDisable (GL_FRAGMENT_PROGRAM_ARB) );
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -316,7 +302,7 @@ _cogl_use_fragment_program (GLuint gl_program, CoglPipelineProgramType type)
|
|||||||
{
|
{
|
||||||
case COGL_PIPELINE_PROGRAM_TYPE_ARBFP:
|
case COGL_PIPELINE_PROGRAM_TYPE_ARBFP:
|
||||||
#ifdef HAVE_COGL_GL
|
#ifdef HAVE_COGL_GL
|
||||||
GE( glEnable (GL_FRAGMENT_PROGRAM_ARB) );
|
GE( ctx, glEnable (GL_FRAGMENT_PROGRAM_ARB) );
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -421,7 +407,7 @@ _cogl_get_max_texture_image_units (void)
|
|||||||
if (G_UNLIKELY (ctx->max_texture_image_units == -1))
|
if (G_UNLIKELY (ctx->max_texture_image_units == -1))
|
||||||
{
|
{
|
||||||
ctx->max_texture_image_units = 1;
|
ctx->max_texture_image_units = 1;
|
||||||
GE (glGetIntegerv (GL_MAX_TEXTURE_IMAGE_UNITS,
|
GE (ctx, glGetIntegerv (GL_MAX_TEXTURE_IMAGE_UNITS,
|
||||||
&ctx->max_texture_image_units));
|
&ctx->max_texture_image_units));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -449,13 +435,13 @@ flush_depth_state (CoglDepthState *depth_state)
|
|||||||
|
|
||||||
if (ctx->depth_test_function_cache != depth_state->test_function)
|
if (ctx->depth_test_function_cache != depth_state->test_function)
|
||||||
{
|
{
|
||||||
GE (glDepthFunc (depth_state->test_function));
|
GE (ctx, glDepthFunc (depth_state->test_function));
|
||||||
ctx->depth_test_function_cache = depth_state->test_function;
|
ctx->depth_test_function_cache = depth_state->test_function;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx->depth_writing_enabled_cache != depth_state->write_enabled)
|
if (ctx->depth_writing_enabled_cache != depth_state->write_enabled)
|
||||||
{
|
{
|
||||||
GE (glDepthMask (depth_state->write_enabled ?
|
GE (ctx, glDepthMask (depth_state->write_enabled ?
|
||||||
GL_TRUE : GL_FALSE));
|
GL_TRUE : GL_FALSE));
|
||||||
ctx->depth_writing_enabled_cache = depth_state->write_enabled;
|
ctx->depth_writing_enabled_cache = depth_state->write_enabled;
|
||||||
}
|
}
|
||||||
@ -465,10 +451,10 @@ flush_depth_state (CoglDepthState *depth_state)
|
|||||||
ctx->depth_range_far_cache != depth_state->range_far)
|
ctx->depth_range_far_cache != depth_state->range_far)
|
||||||
{
|
{
|
||||||
#ifdef COGL_HAS_GLES2
|
#ifdef COGL_HAS_GLES2
|
||||||
GE (glDepthRangef (depth_state->range_near,
|
GE (ctx, glDepthRangef (depth_state->range_near,
|
||||||
depth_state->range_far));
|
depth_state->range_far));
|
||||||
#else
|
#else
|
||||||
GE (glDepthRange (depth_state->range_near,
|
GE (ctx, glDepthRange (depth_state->range_near,
|
||||||
depth_state->range_far));
|
depth_state->range_far));
|
||||||
#endif
|
#endif
|
||||||
ctx->depth_range_near_cache = depth_state->range_near;
|
ctx->depth_range_near_cache = depth_state->range_near;
|
||||||
@ -496,7 +482,7 @@ _cogl_pipeline_flush_color_blend_alpha_depth_state (
|
|||||||
{
|
{
|
||||||
CoglPipeline *authority =
|
CoglPipeline *authority =
|
||||||
_cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_COLOR);
|
_cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_COLOR);
|
||||||
GE (glColor4ub (cogl_color_get_red_byte (&authority->color),
|
GE (ctx, glColor4ub (cogl_color_get_red_byte (&authority->color),
|
||||||
cogl_color_get_green_byte (&authority->color),
|
cogl_color_get_green_byte (&authority->color),
|
||||||
cogl_color_get_blue_byte (&authority->color),
|
cogl_color_get_blue_byte (&authority->color),
|
||||||
cogl_color_get_alpha_byte (&authority->color)));
|
cogl_color_get_alpha_byte (&authority->color)));
|
||||||
@ -539,27 +525,27 @@ _cogl_pipeline_flush_color_blend_alpha_depth_state (
|
|||||||
cogl_color_get_alpha_float (&blend_state->blend_constant);
|
cogl_color_get_alpha_float (&blend_state->blend_constant);
|
||||||
|
|
||||||
|
|
||||||
GE (glBlendColor (red, green, blue, alpha));
|
GE (ctx, glBlendColor (red, green, blue, alpha));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (have_blend_equation_seperate &&
|
if (have_blend_equation_seperate &&
|
||||||
blend_state->blend_equation_rgb != blend_state->blend_equation_alpha)
|
blend_state->blend_equation_rgb != blend_state->blend_equation_alpha)
|
||||||
GE (ctx->glBlendEquationSeparate (blend_state->blend_equation_rgb,
|
GE (ctx, glBlendEquationSeparate (blend_state->blend_equation_rgb,
|
||||||
blend_state->blend_equation_alpha));
|
blend_state->blend_equation_alpha));
|
||||||
else
|
else
|
||||||
GE (glBlendEquation (blend_state->blend_equation_rgb));
|
GE (ctx, glBlendEquation (blend_state->blend_equation_rgb));
|
||||||
|
|
||||||
if (have_blend_func_separate &&
|
if (have_blend_func_separate &&
|
||||||
(blend_state->blend_src_factor_rgb != blend_state->blend_src_factor_alpha ||
|
(blend_state->blend_src_factor_rgb != blend_state->blend_src_factor_alpha ||
|
||||||
(blend_state->blend_src_factor_rgb !=
|
(blend_state->blend_src_factor_rgb !=
|
||||||
blend_state->blend_src_factor_alpha)))
|
blend_state->blend_src_factor_alpha)))
|
||||||
GE (ctx->glBlendFuncSeparate (blend_state->blend_src_factor_rgb,
|
GE (ctx, glBlendFuncSeparate (blend_state->blend_src_factor_rgb,
|
||||||
blend_state->blend_dst_factor_rgb,
|
blend_state->blend_dst_factor_rgb,
|
||||||
blend_state->blend_src_factor_alpha,
|
blend_state->blend_src_factor_alpha,
|
||||||
blend_state->blend_dst_factor_alpha));
|
blend_state->blend_dst_factor_alpha));
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
GE (glBlendFunc (blend_state->blend_src_factor_rgb,
|
GE (ctx, glBlendFunc (blend_state->blend_src_factor_rgb,
|
||||||
blend_state->blend_dst_factor_rgb));
|
blend_state->blend_dst_factor_rgb));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -576,7 +562,7 @@ _cogl_pipeline_flush_color_blend_alpha_depth_state (
|
|||||||
&authority->big_state->alpha_state;
|
&authority->big_state->alpha_state;
|
||||||
|
|
||||||
/* NB: Currently the Cogl defines are compatible with the GL ones: */
|
/* NB: Currently the Cogl defines are compatible with the GL ones: */
|
||||||
GE (glAlphaFunc (alpha_state->alpha_func,
|
GE (ctx, glAlphaFunc (alpha_state->alpha_func,
|
||||||
alpha_state->alpha_func_reference));
|
alpha_state->alpha_func_reference));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -589,15 +575,15 @@ _cogl_pipeline_flush_color_blend_alpha_depth_state (
|
|||||||
CoglPipelineLightingState *lighting_state =
|
CoglPipelineLightingState *lighting_state =
|
||||||
&authority->big_state->lighting_state;
|
&authority->big_state->lighting_state;
|
||||||
|
|
||||||
GE (glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT,
|
GE (ctx, glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT,
|
||||||
lighting_state->ambient));
|
lighting_state->ambient));
|
||||||
GE (glMaterialfv (GL_FRONT_AND_BACK, GL_DIFFUSE,
|
GE (ctx, glMaterialfv (GL_FRONT_AND_BACK, GL_DIFFUSE,
|
||||||
lighting_state->diffuse));
|
lighting_state->diffuse));
|
||||||
GE (glMaterialfv (GL_FRONT_AND_BACK, GL_SPECULAR,
|
GE (ctx, glMaterialfv (GL_FRONT_AND_BACK, GL_SPECULAR,
|
||||||
lighting_state->specular));
|
lighting_state->specular));
|
||||||
GE (glMaterialfv (GL_FRONT_AND_BACK, GL_EMISSION,
|
GE (ctx, glMaterialfv (GL_FRONT_AND_BACK, GL_EMISSION,
|
||||||
lighting_state->emission));
|
lighting_state->emission));
|
||||||
GE (glMaterialfv (GL_FRONT_AND_BACK, GL_SHININESS,
|
GE (ctx, glMaterialfv (GL_FRONT_AND_BACK, GL_SHININESS,
|
||||||
&lighting_state->shininess));
|
&lighting_state->shininess));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -613,14 +599,14 @@ _cogl_pipeline_flush_color_blend_alpha_depth_state (
|
|||||||
{
|
{
|
||||||
if (ctx->depth_test_enabled_cache != TRUE)
|
if (ctx->depth_test_enabled_cache != TRUE)
|
||||||
{
|
{
|
||||||
GE (glEnable (GL_DEPTH_TEST));
|
GE (ctx, glEnable (GL_DEPTH_TEST));
|
||||||
ctx->depth_test_enabled_cache = depth_state->test_enabled;
|
ctx->depth_test_enabled_cache = depth_state->test_enabled;
|
||||||
}
|
}
|
||||||
flush_depth_state (depth_state);
|
flush_depth_state (depth_state);
|
||||||
}
|
}
|
||||||
else if (ctx->depth_test_enabled_cache != FALSE)
|
else if (ctx->depth_test_enabled_cache != FALSE)
|
||||||
{
|
{
|
||||||
GE (glDisable (GL_DEPTH_TEST));
|
GE (ctx, glDisable (GL_DEPTH_TEST));
|
||||||
ctx->depth_test_enabled_cache = depth_state->test_enabled;
|
ctx->depth_test_enabled_cache = depth_state->test_enabled;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -628,9 +614,9 @@ _cogl_pipeline_flush_color_blend_alpha_depth_state (
|
|||||||
if (pipeline->real_blend_enable != ctx->gl_blend_enable_cache)
|
if (pipeline->real_blend_enable != ctx->gl_blend_enable_cache)
|
||||||
{
|
{
|
||||||
if (pipeline->real_blend_enable)
|
if (pipeline->real_blend_enable)
|
||||||
GE (glEnable (GL_BLEND));
|
GE (ctx, glEnable (GL_BLEND));
|
||||||
else
|
else
|
||||||
GE (glDisable (GL_BLEND));
|
GE (ctx, glDisable (GL_BLEND));
|
||||||
/* XXX: we shouldn't update any other blend state if blending
|
/* XXX: we shouldn't update any other blend state if blending
|
||||||
* is disabled! */
|
* is disabled! */
|
||||||
ctx->gl_blend_enable_cache = pipeline->real_blend_enable;
|
ctx->gl_blend_enable_cache = pipeline->real_blend_enable;
|
||||||
@ -658,23 +644,23 @@ get_max_activateable_texture_units (void)
|
|||||||
/* Previously this code subtracted the value by one but there
|
/* Previously this code subtracted the value by one but there
|
||||||
was no explanation for why it did this and it doesn't seem
|
was no explanation for why it did this and it doesn't seem
|
||||||
to make sense so it has been removed */
|
to make sense so it has been removed */
|
||||||
GE (glGetIntegerv (GL_MAX_TEXTURE_COORDS, values + n_values++));
|
GE (ctx, glGetIntegerv (GL_MAX_TEXTURE_COORDS, values + n_values++));
|
||||||
|
|
||||||
/* GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS is defined for GLSL but
|
/* GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS is defined for GLSL but
|
||||||
not ARBfp */
|
not ARBfp */
|
||||||
if (cogl_features_available (COGL_FEATURE_SHADERS_GLSL))
|
if (cogl_features_available (COGL_FEATURE_SHADERS_GLSL))
|
||||||
GE (glGetIntegerv (GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS,
|
GE (ctx, glGetIntegerv (GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS,
|
||||||
values + n_values++));
|
values + n_values++));
|
||||||
#endif /* HAVE_COGL_GL */
|
#endif /* HAVE_COGL_GL */
|
||||||
|
|
||||||
#ifdef HAVE_COGL_GLES2
|
#ifdef HAVE_COGL_GLES2
|
||||||
|
|
||||||
GE (glGetIntegerv (GL_MAX_VERTEX_ATTRIBS, values + n_values));
|
GE (ctx, glGetIntegerv (GL_MAX_VERTEX_ATTRIBS, values + n_values));
|
||||||
/* Two of the vertex attribs need to be used for the position
|
/* Two of the vertex attribs need to be used for the position
|
||||||
and color */
|
and color */
|
||||||
values[n_values++] -= 2;
|
values[n_values++] -= 2;
|
||||||
|
|
||||||
GE (glGetIntegerv (GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS,
|
GE (ctx, glGetIntegerv (GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS,
|
||||||
values + n_values++));
|
values + n_values++));
|
||||||
|
|
||||||
#else /* HAVE_COGL_GLES2 */
|
#else /* HAVE_COGL_GLES2 */
|
||||||
@ -684,7 +670,7 @@ get_max_activateable_texture_units (void)
|
|||||||
available in GLES2. These are also tied to the number of
|
available in GLES2. These are also tied to the number of
|
||||||
texture coordinates that can be uploaded so it should be less
|
texture coordinates that can be uploaded so it should be less
|
||||||
than that available from the shader extensions */
|
than that available from the shader extensions */
|
||||||
GE (glGetIntegerv (GL_MAX_TEXTURE_UNITS,
|
GE (ctx, glGetIntegerv (GL_MAX_TEXTURE_UNITS,
|
||||||
values + n_values++));
|
values + n_values++));
|
||||||
|
|
||||||
#endif /* HAVE_COGL_GLES2 */
|
#endif /* HAVE_COGL_GLES2 */
|
||||||
@ -784,7 +770,7 @@ flush_layers_common_gl_state_cb (CoglPipelineLayer *layer, void *user_data)
|
|||||||
if (unit_index == 1)
|
if (unit_index == 1)
|
||||||
unit->dirty_gl_texture = TRUE;
|
unit->dirty_gl_texture = TRUE;
|
||||||
else
|
else
|
||||||
GE (glBindTexture (gl_target, gl_texture));
|
GE (ctx, glBindTexture (gl_target, gl_texture));
|
||||||
unit->gl_texture = gl_texture;
|
unit->gl_texture = gl_texture;
|
||||||
unit->gl_target = gl_target;
|
unit->gl_target = gl_target;
|
||||||
}
|
}
|
||||||
@ -810,7 +796,7 @@ flush_layers_common_gl_state_cb (CoglPipelineLayer *layer, void *user_data)
|
|||||||
|
|
||||||
_cogl_set_active_texture_unit (unit_index);
|
_cogl_set_active_texture_unit (unit_index);
|
||||||
|
|
||||||
GE (glTexEnvi (GL_POINT_SPRITE, GL_COORD_REPLACE,
|
GE (ctx, glTexEnvi (GL_POINT_SPRITE, GL_COORD_REPLACE,
|
||||||
big_state->point_sprite_coords));
|
big_state->point_sprite_coords));
|
||||||
}
|
}
|
||||||
#endif /* HAVE_COGL_GLES2 */
|
#endif /* HAVE_COGL_GLES2 */
|
||||||
@ -1321,7 +1307,8 @@ done:
|
|||||||
|
|
||||||
attribute = _cogl_pipeline_progend_glsl_get_color_attribute (pipeline);
|
attribute = _cogl_pipeline_progend_glsl_get_color_attribute (pipeline);
|
||||||
if (attribute != -1)
|
if (attribute != -1)
|
||||||
GE (glVertexAttrib4f (attribute,
|
GE (ctx,
|
||||||
|
glVertexAttrib4f (attribute,
|
||||||
cogl_color_get_red_float (&authority->color),
|
cogl_color_get_red_float (&authority->color),
|
||||||
cogl_color_get_green_float (&authority->color),
|
cogl_color_get_green_float (&authority->color),
|
||||||
cogl_color_get_blue_float (&authority->color),
|
cogl_color_get_blue_float (&authority->color),
|
||||||
@ -1352,7 +1339,7 @@ done:
|
|||||||
if (cogl_pipeline_get_n_layers (pipeline) > 1 && unit1->dirty_gl_texture)
|
if (cogl_pipeline_get_n_layers (pipeline) > 1 && unit1->dirty_gl_texture)
|
||||||
{
|
{
|
||||||
_cogl_set_active_texture_unit (1);
|
_cogl_set_active_texture_unit (1);
|
||||||
GE (glBindTexture (unit1->gl_target, unit1->gl_texture));
|
GE (ctx, glBindTexture (unit1->gl_target, unit1->gl_texture));
|
||||||
unit1->dirty_gl_texture = FALSE;
|
unit1->dirty_gl_texture = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,21 +42,7 @@
|
|||||||
#include "cogl-pipeline-fragend-glsl-private.h"
|
#include "cogl-pipeline-fragend-glsl-private.h"
|
||||||
#include "cogl-pipeline-vertend-glsl-private.h"
|
#include "cogl-pipeline-vertend-glsl-private.h"
|
||||||
|
|
||||||
#ifndef HAVE_COGL_GLES2
|
#ifdef HAVE_COGL_GLES2
|
||||||
|
|
||||||
#define glCreateProgram ctx->glCreateProgram
|
|
||||||
#define glAttachShader ctx->glAttachShader
|
|
||||||
#define glUseProgram ctx->glUseProgram
|
|
||||||
#define glLinkProgram ctx->glLinkProgram
|
|
||||||
#define glDeleteProgram ctx->glDeleteProgram
|
|
||||||
#define glGetProgramInfoLog ctx->glGetProgramInfoLog
|
|
||||||
#define glGetProgramiv ctx->glGetProgramiv
|
|
||||||
#define glGetUniformLocation ctx->glGetUniformLocation
|
|
||||||
#define glUniform1i ctx->glUniform1i
|
|
||||||
#define glUniform1f ctx->glUniform1f
|
|
||||||
#define glUniform4fv ctx->glUniform4fv
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
/* These are used to generalise updating some uniforms that are
|
/* These are used to generalise updating some uniforms that are
|
||||||
required when building for GLES2 */
|
required when building for GLES2 */
|
||||||
@ -178,12 +164,14 @@ _cogl_pipeline_progend_glsl_get_position_attribute (CoglPipeline *pipeline)
|
|||||||
{
|
{
|
||||||
CoglPipelineProgendPrivate *priv = get_glsl_priv (pipeline);
|
CoglPipelineProgendPrivate *priv = get_glsl_priv (pipeline);
|
||||||
|
|
||||||
|
_COGL_GET_CONTEXT (ctx, -1);
|
||||||
|
|
||||||
g_return_val_if_fail (priv != NULL, -1);
|
g_return_val_if_fail (priv != NULL, -1);
|
||||||
g_return_val_if_fail (priv->program != 0, -1);
|
g_return_val_if_fail (priv->program != 0, -1);
|
||||||
|
|
||||||
if (priv->position_attribute_location == ATTRIBUTE_LOCATION_UNKNOWN)
|
if (priv->position_attribute_location == ATTRIBUTE_LOCATION_UNKNOWN)
|
||||||
GE_RET( priv->position_attribute_location,
|
GE_RET( priv->position_attribute_location,
|
||||||
glGetAttribLocation (priv->program, "cogl_position_in") );
|
ctx, glGetAttribLocation (priv->program, "cogl_position_in") );
|
||||||
|
|
||||||
return priv->position_attribute_location;
|
return priv->position_attribute_location;
|
||||||
}
|
}
|
||||||
@ -193,12 +181,14 @@ _cogl_pipeline_progend_glsl_get_color_attribute (CoglPipeline *pipeline)
|
|||||||
{
|
{
|
||||||
CoglPipelineProgendPrivate *priv = get_glsl_priv (pipeline);
|
CoglPipelineProgendPrivate *priv = get_glsl_priv (pipeline);
|
||||||
|
|
||||||
|
_COGL_GET_CONTEXT (ctx, -1);
|
||||||
|
|
||||||
g_return_val_if_fail (priv != NULL, -1);
|
g_return_val_if_fail (priv != NULL, -1);
|
||||||
g_return_val_if_fail (priv->program != 0, -1);
|
g_return_val_if_fail (priv->program != 0, -1);
|
||||||
|
|
||||||
if (priv->color_attribute_location == ATTRIBUTE_LOCATION_UNKNOWN)
|
if (priv->color_attribute_location == ATTRIBUTE_LOCATION_UNKNOWN)
|
||||||
GE_RET( priv->color_attribute_location,
|
GE_RET( priv->color_attribute_location,
|
||||||
glGetAttribLocation (priv->program, "cogl_color_in") );
|
ctx, glGetAttribLocation (priv->program, "cogl_color_in") );
|
||||||
|
|
||||||
return priv->color_attribute_location;
|
return priv->color_attribute_location;
|
||||||
}
|
}
|
||||||
@ -208,12 +198,14 @@ _cogl_pipeline_progend_glsl_get_normal_attribute (CoglPipeline *pipeline)
|
|||||||
{
|
{
|
||||||
CoglPipelineProgendPrivate *priv = get_glsl_priv (pipeline);
|
CoglPipelineProgendPrivate *priv = get_glsl_priv (pipeline);
|
||||||
|
|
||||||
|
_COGL_GET_CONTEXT (ctx, -1);
|
||||||
|
|
||||||
g_return_val_if_fail (priv != NULL, -1);
|
g_return_val_if_fail (priv != NULL, -1);
|
||||||
g_return_val_if_fail (priv->program != 0, -1);
|
g_return_val_if_fail (priv->program != 0, -1);
|
||||||
|
|
||||||
if (priv->normal_attribute_location == ATTRIBUTE_LOCATION_UNKNOWN)
|
if (priv->normal_attribute_location == ATTRIBUTE_LOCATION_UNKNOWN)
|
||||||
GE_RET( priv->normal_attribute_location,
|
GE_RET( priv->normal_attribute_location,
|
||||||
glGetAttribLocation (priv->program, "cogl_normal_in") );
|
ctx, glGetAttribLocation (priv->program, "cogl_normal_in") );
|
||||||
|
|
||||||
return priv->normal_attribute_location;
|
return priv->normal_attribute_location;
|
||||||
}
|
}
|
||||||
@ -224,6 +216,8 @@ _cogl_pipeline_progend_glsl_get_tex_coord_attribute (CoglPipeline *pipeline,
|
|||||||
{
|
{
|
||||||
CoglPipelineProgendPrivate *priv = get_glsl_priv (pipeline);
|
CoglPipelineProgendPrivate *priv = get_glsl_priv (pipeline);
|
||||||
|
|
||||||
|
_COGL_GET_CONTEXT (ctx, -1);
|
||||||
|
|
||||||
g_return_val_if_fail (priv != NULL, -1);
|
g_return_val_if_fail (priv != NULL, -1);
|
||||||
g_return_val_if_fail (priv->program != 0, -1);
|
g_return_val_if_fail (priv->program != 0, -1);
|
||||||
|
|
||||||
@ -231,7 +225,8 @@ _cogl_pipeline_progend_glsl_get_tex_coord_attribute (CoglPipeline *pipeline,
|
|||||||
{
|
{
|
||||||
if (priv->tex_coord0_attribute_location == ATTRIBUTE_LOCATION_UNKNOWN)
|
if (priv->tex_coord0_attribute_location == ATTRIBUTE_LOCATION_UNKNOWN)
|
||||||
GE_RET( priv->tex_coord0_attribute_location,
|
GE_RET( priv->tex_coord0_attribute_location,
|
||||||
glGetAttribLocation (priv->program, "cogl_tex_coord0_in") );
|
ctx, glGetAttribLocation (priv->program,
|
||||||
|
"cogl_tex_coord0_in") );
|
||||||
|
|
||||||
return priv->tex_coord0_attribute_location;
|
return priv->tex_coord0_attribute_location;
|
||||||
}
|
}
|
||||||
@ -256,7 +251,7 @@ _cogl_pipeline_progend_glsl_get_tex_coord_attribute (CoglPipeline *pipeline,
|
|||||||
|
|
||||||
if (locations[unit - 1] == ATTRIBUTE_LOCATION_UNKNOWN)
|
if (locations[unit - 1] == ATTRIBUTE_LOCATION_UNKNOWN)
|
||||||
GE_RET( locations[unit - 1],
|
GE_RET( locations[unit - 1],
|
||||||
glGetAttribLocation (priv->program, name) );
|
ctx, glGetAttribLocation (priv->program, name) );
|
||||||
|
|
||||||
g_free (name);
|
g_free (name);
|
||||||
|
|
||||||
@ -311,7 +306,7 @@ destroy_glsl_priv (void *user_data)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (priv->program)
|
if (priv->program)
|
||||||
GE( glDeleteProgram (priv->program) );
|
GE( ctx, glDeleteProgram (priv->program) );
|
||||||
|
|
||||||
g_free (priv->unit_state);
|
g_free (priv->unit_state);
|
||||||
|
|
||||||
@ -344,9 +339,9 @@ link_program (GLint gl_program)
|
|||||||
|
|
||||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
GE( glLinkProgram (gl_program) );
|
GE( ctx, glLinkProgram (gl_program) );
|
||||||
|
|
||||||
GE( glGetProgramiv (gl_program, GL_LINK_STATUS, &link_status) );
|
GE( ctx, glGetProgramiv (gl_program, GL_LINK_STATUS, &link_status) );
|
||||||
|
|
||||||
if (!link_status)
|
if (!link_status)
|
||||||
{
|
{
|
||||||
@ -354,11 +349,11 @@ link_program (GLint gl_program)
|
|||||||
GLsizei out_log_length;
|
GLsizei out_log_length;
|
||||||
char *log;
|
char *log;
|
||||||
|
|
||||||
GE( glGetProgramiv (gl_program, GL_INFO_LOG_LENGTH, &log_length) );
|
GE( ctx, glGetProgramiv (gl_program, GL_INFO_LOG_LENGTH, &log_length) );
|
||||||
|
|
||||||
log = g_malloc (log_length);
|
log = g_malloc (log_length);
|
||||||
|
|
||||||
GE( glGetProgramInfoLog (gl_program, log_length,
|
GE( ctx, glGetProgramInfoLog (gl_program, log_length,
|
||||||
&out_log_length, log) );
|
&out_log_length, log) );
|
||||||
|
|
||||||
g_warning ("Failed to link GLSL program:\n%.*s\n",
|
g_warning ("Failed to link GLSL program:\n%.*s\n",
|
||||||
@ -395,7 +390,7 @@ get_uniform_cb (CoglPipeline *pipeline,
|
|||||||
"_cogl_sampler_%i", state->unit);
|
"_cogl_sampler_%i", state->unit);
|
||||||
|
|
||||||
GE_RET( uniform_location,
|
GE_RET( uniform_location,
|
||||||
glGetUniformLocation (state->gl_program,
|
ctx, glGetUniformLocation (state->gl_program,
|
||||||
ctx->codegen_source_buffer->str) );
|
ctx->codegen_source_buffer->str) );
|
||||||
|
|
||||||
/* We can set the uniform immediately because the samplers are the
|
/* We can set the uniform immediately because the samplers are the
|
||||||
@ -403,14 +398,14 @@ get_uniform_cb (CoglPipeline *pipeline,
|
|||||||
change. Unfortunately GL won't let us use a constant instead of a
|
change. Unfortunately GL won't let us use a constant instead of a
|
||||||
uniform */
|
uniform */
|
||||||
if (uniform_location != -1)
|
if (uniform_location != -1)
|
||||||
GE( glUniform1i (uniform_location, state->unit) );
|
GE( ctx, glUniform1i (uniform_location, state->unit) );
|
||||||
|
|
||||||
g_string_set_size (ctx->codegen_source_buffer, 0);
|
g_string_set_size (ctx->codegen_source_buffer, 0);
|
||||||
g_string_append_printf (ctx->codegen_source_buffer,
|
g_string_append_printf (ctx->codegen_source_buffer,
|
||||||
"_cogl_layer_constant_%i", state->unit);
|
"_cogl_layer_constant_%i", state->unit);
|
||||||
|
|
||||||
GE_RET( uniform_location,
|
GE_RET( uniform_location,
|
||||||
glGetUniformLocation (state->gl_program,
|
ctx, glGetUniformLocation (state->gl_program,
|
||||||
ctx->codegen_source_buffer->str) );
|
ctx->codegen_source_buffer->str) );
|
||||||
|
|
||||||
unit_state->combine_constant_uniform = uniform_location;
|
unit_state->combine_constant_uniform = uniform_location;
|
||||||
@ -422,7 +417,7 @@ get_uniform_cb (CoglPipeline *pipeline,
|
|||||||
"cogl_texture_matrix[%i]", state->unit);
|
"cogl_texture_matrix[%i]", state->unit);
|
||||||
|
|
||||||
GE_RET( uniform_location,
|
GE_RET( uniform_location,
|
||||||
glGetUniformLocation (state->gl_program,
|
ctx, glGetUniformLocation (state->gl_program,
|
||||||
ctx->codegen_source_buffer->str) );
|
ctx->codegen_source_buffer->str) );
|
||||||
|
|
||||||
unit_state->texture_matrix_uniform = uniform_location;
|
unit_state->texture_matrix_uniform = uniform_location;
|
||||||
@ -452,7 +447,7 @@ update_constants_cb (CoglPipeline *pipeline,
|
|||||||
_cogl_pipeline_get_layer_combine_constant (pipeline,
|
_cogl_pipeline_get_layer_combine_constant (pipeline,
|
||||||
layer_index,
|
layer_index,
|
||||||
constant);
|
constant);
|
||||||
GE (glUniform4fv (unit_state->combine_constant_uniform,
|
GE (ctx, glUniform4fv (unit_state->combine_constant_uniform,
|
||||||
1, constant));
|
1, constant));
|
||||||
unit_state->dirty_combine_constant = FALSE;
|
unit_state->dirty_combine_constant = FALSE;
|
||||||
}
|
}
|
||||||
@ -467,7 +462,7 @@ update_constants_cb (CoglPipeline *pipeline,
|
|||||||
|
|
||||||
matrix = _cogl_pipeline_get_layer_matrix (pipeline, layer_index);
|
matrix = _cogl_pipeline_get_layer_matrix (pipeline, layer_index);
|
||||||
array = cogl_matrix_get_array (matrix);
|
array = cogl_matrix_get_array (matrix);
|
||||||
GE (glUniformMatrix4fv (unit_state->texture_matrix_uniform,
|
GE (ctx, glUniformMatrix4fv (unit_state->texture_matrix_uniform,
|
||||||
1, FALSE, array));
|
1, FALSE, array));
|
||||||
unit_state->dirty_texture_matrix = FALSE;
|
unit_state->dirty_texture_matrix = FALSE;
|
||||||
}
|
}
|
||||||
@ -575,7 +570,7 @@ _cogl_pipeline_progend_glsl_end (CoglPipeline *pipeline,
|
|||||||
(user_program->age != priv->user_program_age ||
|
(user_program->age != priv->user_program_age ||
|
||||||
n_tex_coord_attribs > priv->n_tex_coord_attribs))
|
n_tex_coord_attribs > priv->n_tex_coord_attribs))
|
||||||
{
|
{
|
||||||
GE( glDeleteProgram (priv->program) );
|
GE( ctx, glDeleteProgram (priv->program) );
|
||||||
priv->program = 0;
|
priv->program = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -584,7 +579,7 @@ _cogl_pipeline_progend_glsl_end (CoglPipeline *pipeline,
|
|||||||
GLuint backend_shader;
|
GLuint backend_shader;
|
||||||
GSList *l;
|
GSList *l;
|
||||||
|
|
||||||
GE_RET( priv->program, glCreateProgram () );
|
GE_RET( priv->program, ctx, glCreateProgram () );
|
||||||
|
|
||||||
/* Attach all of the shader from the user program */
|
/* Attach all of the shader from the user program */
|
||||||
if (user_program)
|
if (user_program)
|
||||||
@ -613,7 +608,7 @@ _cogl_pipeline_progend_glsl_end (CoglPipeline *pipeline,
|
|||||||
|
|
||||||
g_assert (shader->language == COGL_SHADER_LANGUAGE_GLSL);
|
g_assert (shader->language == COGL_SHADER_LANGUAGE_GLSL);
|
||||||
|
|
||||||
GE( glAttachShader (priv->program,
|
GE( ctx, glAttachShader (priv->program,
|
||||||
shader->gl_handle) );
|
shader->gl_handle) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -623,10 +618,10 @@ _cogl_pipeline_progend_glsl_end (CoglPipeline *pipeline,
|
|||||||
/* Attach any shaders from the GLSL backends */
|
/* Attach any shaders from the GLSL backends */
|
||||||
if (pipeline->fragend == COGL_PIPELINE_FRAGEND_GLSL &&
|
if (pipeline->fragend == COGL_PIPELINE_FRAGEND_GLSL &&
|
||||||
(backend_shader = _cogl_pipeline_fragend_glsl_get_shader (pipeline)))
|
(backend_shader = _cogl_pipeline_fragend_glsl_get_shader (pipeline)))
|
||||||
GE( glAttachShader (priv->program, backend_shader) );
|
GE( ctx, glAttachShader (priv->program, backend_shader) );
|
||||||
if (pipeline->vertend == COGL_PIPELINE_VERTEND_GLSL &&
|
if (pipeline->vertend == COGL_PIPELINE_VERTEND_GLSL &&
|
||||||
(backend_shader = _cogl_pipeline_vertend_glsl_get_shader (pipeline)))
|
(backend_shader = _cogl_pipeline_vertend_glsl_get_shader (pipeline)))
|
||||||
GE( glAttachShader (priv->program, backend_shader) );
|
GE( ctx, glAttachShader (priv->program, backend_shader) );
|
||||||
|
|
||||||
link_program (priv->program);
|
link_program (priv->program);
|
||||||
|
|
||||||
@ -669,19 +664,19 @@ _cogl_pipeline_progend_glsl_end (CoglPipeline *pipeline,
|
|||||||
|
|
||||||
for (i = 0; i < G_N_ELEMENTS (builtin_uniforms); i++)
|
for (i = 0; i < G_N_ELEMENTS (builtin_uniforms); i++)
|
||||||
GE_RET( priv->builtin_uniform_locations[i],
|
GE_RET( priv->builtin_uniform_locations[i],
|
||||||
glGetUniformLocation (gl_program,
|
ctx, glGetUniformLocation (gl_program,
|
||||||
builtin_uniforms[i].uniform_name) );
|
builtin_uniforms[i].uniform_name) );
|
||||||
|
|
||||||
GE_RET( priv->modelview_uniform,
|
GE_RET( priv->modelview_uniform,
|
||||||
glGetUniformLocation (gl_program,
|
ctx, glGetUniformLocation (gl_program,
|
||||||
"cogl_modelview_matrix") );
|
"cogl_modelview_matrix") );
|
||||||
|
|
||||||
GE_RET( priv->projection_uniform,
|
GE_RET( priv->projection_uniform,
|
||||||
glGetUniformLocation (gl_program,
|
ctx, glGetUniformLocation (gl_program,
|
||||||
"cogl_projection_matrix") );
|
"cogl_projection_matrix") );
|
||||||
|
|
||||||
GE_RET( priv->mvp_uniform,
|
GE_RET( priv->mvp_uniform,
|
||||||
glGetUniformLocation (gl_program,
|
ctx, glGetUniformLocation (gl_program,
|
||||||
"cogl_modelview_projection_matrix") );
|
"cogl_modelview_projection_matrix") );
|
||||||
}
|
}
|
||||||
if (program_changed ||
|
if (program_changed ||
|
||||||
@ -775,7 +770,9 @@ flush_modelview_cb (gboolean is_identity,
|
|||||||
{
|
{
|
||||||
CoglPipelineProgendPrivate *priv = user_data;
|
CoglPipelineProgendPrivate *priv = user_data;
|
||||||
|
|
||||||
GE( glUniformMatrix4fv (priv->modelview_uniform, 1, FALSE,
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
|
GE( ctx, glUniformMatrix4fv (priv->modelview_uniform, 1, FALSE,
|
||||||
cogl_matrix_get_array (matrix)) );
|
cogl_matrix_get_array (matrix)) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -786,7 +783,9 @@ flush_projection_cb (gboolean is_identity,
|
|||||||
{
|
{
|
||||||
CoglPipelineProgendPrivate *priv = user_data;
|
CoglPipelineProgendPrivate *priv = user_data;
|
||||||
|
|
||||||
GE( glUniformMatrix4fv (priv->projection_uniform, 1, FALSE,
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
|
GE( ctx, glUniformMatrix4fv (priv->projection_uniform, 1, FALSE,
|
||||||
cogl_matrix_get_array (matrix)) );
|
cogl_matrix_get_array (matrix)) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -804,18 +803,22 @@ flush_combined_step_two_cb (gboolean is_identity,
|
|||||||
FlushCombinedData *data = user_data;
|
FlushCombinedData *data = user_data;
|
||||||
CoglMatrix mvp_matrix;
|
CoglMatrix mvp_matrix;
|
||||||
|
|
||||||
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
/* If the modelview is the identity then we can bypass the matrix
|
/* If the modelview is the identity then we can bypass the matrix
|
||||||
multiplication */
|
multiplication */
|
||||||
if (is_identity)
|
if (is_identity)
|
||||||
GE( glUniformMatrix4fv (data->priv->mvp_uniform, 1, FALSE,
|
{
|
||||||
cogl_matrix_get_array (data->projection_matrix)) );
|
const float *array = cogl_matrix_get_array (data->projection_matrix);
|
||||||
|
GE( ctx, glUniformMatrix4fv (data->priv->mvp_uniform, 1, FALSE, array ) );
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cogl_matrix_multiply (&mvp_matrix,
|
cogl_matrix_multiply (&mvp_matrix,
|
||||||
data->projection_matrix,
|
data->projection_matrix,
|
||||||
matrix);
|
matrix);
|
||||||
|
|
||||||
GE( glUniformMatrix4fv (data->priv->mvp_uniform, 1, FALSE,
|
GE( ctx, glUniformMatrix4fv (data->priv->mvp_uniform, 1, FALSE,
|
||||||
cogl_matrix_get_array (&mvp_matrix)) );
|
cogl_matrix_get_array (&mvp_matrix)) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -927,8 +930,10 @@ update_float_uniform (CoglPipeline *pipeline,
|
|||||||
float (* float_getter_func) (CoglPipeline *) = getter_func;
|
float (* float_getter_func) (CoglPipeline *) = getter_func;
|
||||||
float value;
|
float value;
|
||||||
|
|
||||||
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
value = float_getter_func (pipeline);
|
value = float_getter_func (pipeline);
|
||||||
GE( glUniform1f (uniform_location, value) );
|
GE( ctx, glUniform1f (uniform_location, value) );
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -104,7 +104,7 @@ _cogl_pipeline_vertend_fixed_end (CoglPipeline *pipeline,
|
|||||||
|
|
||||||
if (ctx->point_size_cache != authority->big_state->point_size)
|
if (ctx->point_size_cache != authority->big_state->point_size)
|
||||||
{
|
{
|
||||||
GE( glPointSize (authority->big_state->point_size) );
|
GE( ctx, glPointSize (authority->big_state->point_size) );
|
||||||
ctx->point_size_cache = authority->big_state->point_size;
|
ctx->point_size_cache = authority->big_state->point_size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,17 +41,6 @@
|
|||||||
#include "cogl-program-private.h"
|
#include "cogl-program-private.h"
|
||||||
#include "cogl-pipeline-vertend-glsl-private.h"
|
#include "cogl-pipeline-vertend-glsl-private.h"
|
||||||
|
|
||||||
#ifndef HAVE_COGL_GLES2
|
|
||||||
|
|
||||||
#define glCreateShader ctx->glCreateShader
|
|
||||||
#define glGetShaderiv ctx->glGetShaderiv
|
|
||||||
#define glGetShaderInfoLog ctx->glGetShaderInfoLog
|
|
||||||
#define glCompileShader ctx->glCompileShader
|
|
||||||
#define glShaderSource ctx->glShaderSource
|
|
||||||
#define glDeleteShader ctx->glDeleteShader
|
|
||||||
|
|
||||||
#endif /* HAVE_COGL_GLES2 */
|
|
||||||
|
|
||||||
const CoglPipelineVertend _cogl_pipeline_glsl_vertend;
|
const CoglPipelineVertend _cogl_pipeline_glsl_vertend;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
@ -86,7 +75,7 @@ destroy_glsl_priv (void *user_data)
|
|||||||
if (--priv->ref_count == 0)
|
if (--priv->ref_count == 0)
|
||||||
{
|
{
|
||||||
if (priv->gl_shader)
|
if (priv->gl_shader)
|
||||||
GE( glDeleteShader (priv->gl_shader) );
|
GE( ctx, glDeleteShader (priv->gl_shader) );
|
||||||
|
|
||||||
g_slice_free (CoglPipelineVertendPrivate, priv);
|
g_slice_free (CoglPipelineVertendPrivate, priv);
|
||||||
}
|
}
|
||||||
@ -185,7 +174,7 @@ _cogl_pipeline_vertend_glsl_start (CoglPipeline *pipeline,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
/* We need to recreate the shader so destroy the existing one */
|
/* We need to recreate the shader so destroy the existing one */
|
||||||
GE( glDeleteShader (priv->gl_shader) );
|
GE( ctx, glDeleteShader (priv->gl_shader) );
|
||||||
priv->gl_shader = 0;
|
priv->gl_shader = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -234,7 +223,7 @@ _cogl_pipeline_vertend_glsl_start (CoglPipeline *pipeline,
|
|||||||
|
|
||||||
if (ctx->point_size_cache != authority->big_state->point_size)
|
if (ctx->point_size_cache != authority->big_state->point_size)
|
||||||
{
|
{
|
||||||
GE( glPointSize (authority->big_state->point_size) );
|
GE( ctx, glPointSize (authority->big_state->point_size) );
|
||||||
ctx->point_size_cache = authority->big_state->point_size;
|
ctx->point_size_cache = authority->big_state->point_size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -332,7 +321,7 @@ _cogl_pipeline_vertend_glsl_end (CoglPipeline *pipeline,
|
|||||||
" cogl_color_out = cogl_color_in;\n"
|
" cogl_color_out = cogl_color_in;\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
|
|
||||||
GE_RET( shader, glCreateShader (GL_VERTEX_SHADER) );
|
GE_RET( shader, ctx, glCreateShader (GL_VERTEX_SHADER) );
|
||||||
|
|
||||||
lengths[0] = priv->header->len;
|
lengths[0] = priv->header->len;
|
||||||
source_strings[0] = priv->header->str;
|
source_strings[0] = priv->header->str;
|
||||||
@ -346,17 +335,17 @@ _cogl_pipeline_vertend_glsl_end (CoglPipeline *pipeline,
|
|||||||
2, /* count */
|
2, /* count */
|
||||||
source_strings, lengths);
|
source_strings, lengths);
|
||||||
|
|
||||||
GE( glCompileShader (shader) );
|
GE( ctx, glCompileShader (shader) );
|
||||||
GE( glGetShaderiv (shader, GL_COMPILE_STATUS, &compile_status) );
|
GE( ctx, glGetShaderiv (shader, GL_COMPILE_STATUS, &compile_status) );
|
||||||
|
|
||||||
if (!compile_status)
|
if (!compile_status)
|
||||||
{
|
{
|
||||||
GLint len = 0;
|
GLint len = 0;
|
||||||
char *shader_log;
|
char *shader_log;
|
||||||
|
|
||||||
GE( glGetShaderiv (shader, GL_INFO_LOG_LENGTH, &len) );
|
GE( ctx, glGetShaderiv (shader, GL_INFO_LOG_LENGTH, &len) );
|
||||||
shader_log = g_alloca (len);
|
shader_log = g_alloca (len);
|
||||||
GE( glGetShaderInfoLog (shader, len, &len, shader_log) );
|
GE( ctx, glGetShaderInfoLog (shader, len, &len, shader_log) );
|
||||||
g_warning ("Shader compilation failed:\n%s", shader_log);
|
g_warning ("Shader compilation failed:\n%s", shader_log);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,15 +52,6 @@
|
|||||||
|
|
||||||
#if defined (HAVE_COGL_GL)
|
#if defined (HAVE_COGL_GL)
|
||||||
|
|
||||||
#define glGenBuffers ctx->drv.pf_glGenBuffers
|
|
||||||
#define glBindBuffer ctx->drv.pf_glBindBuffer
|
|
||||||
#define glBufferData ctx->drv.pf_glBufferData
|
|
||||||
#define glBufferSubData ctx->drv.pf_glBufferSubData
|
|
||||||
#define glGetBufferSubData ctx->drv.pf_glGetBufferSubData
|
|
||||||
#define glDeleteBuffers ctx->drv.pf_glDeleteBuffers
|
|
||||||
#define glMapBuffer ctx->drv.pf_glMapBuffer
|
|
||||||
#define glUnmapBuffer ctx->drv.pf_glUnmapBuffer
|
|
||||||
|
|
||||||
#ifndef GL_PIXEL_UNPACK_BUFFER
|
#ifndef GL_PIXEL_UNPACK_BUFFER
|
||||||
#define GL_PIXEL_UNPACK_BUFFER GL_PIXEL_UNPACK_BUFFER_ARB
|
#define GL_PIXEL_UNPACK_BUFFER GL_PIXEL_UNPACK_BUFFER_ARB
|
||||||
#endif
|
#endif
|
||||||
|
@ -42,11 +42,6 @@
|
|||||||
|
|
||||||
#define _COGL_MAX_BEZ_RECURSE_DEPTH 16
|
#define _COGL_MAX_BEZ_RECURSE_DEPTH 16
|
||||||
|
|
||||||
#ifdef HAVE_COGL_GL
|
|
||||||
#define glClientActiveTexture ctx->drv.pf_glClientActiveTexture
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct _TextureSlicedQuadState
|
typedef struct _TextureSlicedQuadState
|
||||||
{
|
{
|
||||||
CoglPipeline *pipeline;
|
CoglPipeline *pipeline;
|
||||||
|
@ -48,32 +48,6 @@ COGL_OBJECT_DEFINE_DEPRECATED_REF_COUNTING (program);
|
|||||||
an array and then flushed whenever the material backend requests
|
an array and then flushed whenever the material backend requests
|
||||||
it. */
|
it. */
|
||||||
|
|
||||||
#ifndef HAVE_COGL_GLES2
|
|
||||||
|
|
||||||
#define glGetUniformLocation ctx->glGetUniformLocation
|
|
||||||
#define glUniform1f ctx->glUniform1f
|
|
||||||
#define glUniform2f ctx->glUniform2f
|
|
||||||
#define glUniform3f ctx->glUniform3f
|
|
||||||
#define glUniform4f ctx->glUniform4f
|
|
||||||
#define glUniform1fv ctx->glUniform1fv
|
|
||||||
#define glUniform2fv ctx->glUniform2fv
|
|
||||||
#define glUniform3fv ctx->glUniform3fv
|
|
||||||
#define glUniform4fv ctx->glUniform4fv
|
|
||||||
#define glUniform1i ctx->glUniform1i
|
|
||||||
#define glUniform2i ctx->glUniform2i
|
|
||||||
#define glUniform3i ctx->glUniform3i
|
|
||||||
#define glUniform4i ctx->glUniform4i
|
|
||||||
#define glUniform1iv ctx->glUniform1iv
|
|
||||||
#define glUniform2iv ctx->glUniform2iv
|
|
||||||
#define glUniform3iv ctx->glUniform3iv
|
|
||||||
#define glUniform4iv ctx->glUniform4iv
|
|
||||||
#define glUniformMatrix2fv ctx->glUniformMatrix2fv
|
|
||||||
#define glUniformMatrix3fv ctx->glUniformMatrix3fv
|
|
||||||
#define glUniformMatrix4fv ctx->glUniformMatrix4fv
|
|
||||||
#define glProgramLocalParameter4fv ctx->glProgramLocalParameter4fv
|
|
||||||
|
|
||||||
#endif /* HAVE_COGL_GLES2 */
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_cogl_program_free (CoglProgram *program)
|
_cogl_program_free (CoglProgram *program)
|
||||||
{
|
{
|
||||||
@ -448,10 +422,10 @@ _cogl_program_flush_uniform_glsl (GLint location,
|
|||||||
|
|
||||||
switch (value->size)
|
switch (value->size)
|
||||||
{
|
{
|
||||||
case 1: glUniform1iv (location, value->count, ptr); break;
|
case 1: ctx->glUniform1iv (location, value->count, ptr); break;
|
||||||
case 2: glUniform2iv (location, value->count, ptr); break;
|
case 2: ctx->glUniform2iv (location, value->count, ptr); break;
|
||||||
case 3: glUniform3iv (location, value->count, ptr); break;
|
case 3: ctx->glUniform3iv (location, value->count, ptr); break;
|
||||||
case 4: glUniform4iv (location, value->count, ptr); break;
|
case 4: ctx->glUniform4iv (location, value->count, ptr); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -467,10 +441,10 @@ _cogl_program_flush_uniform_glsl (GLint location,
|
|||||||
|
|
||||||
switch (value->size)
|
switch (value->size)
|
||||||
{
|
{
|
||||||
case 1: glUniform1fv (location, value->count, ptr); break;
|
case 1: ctx->glUniform1fv (location, value->count, ptr); break;
|
||||||
case 2: glUniform2fv (location, value->count, ptr); break;
|
case 2: ctx->glUniform2fv (location, value->count, ptr); break;
|
||||||
case 3: glUniform3fv (location, value->count, ptr); break;
|
case 3: ctx->glUniform3fv (location, value->count, ptr); break;
|
||||||
case 4: glUniform4fv (location, value->count, ptr); break;
|
case 4: ctx->glUniform4fv (location, value->count, ptr); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -487,13 +461,16 @@ _cogl_program_flush_uniform_glsl (GLint location,
|
|||||||
switch (value->size)
|
switch (value->size)
|
||||||
{
|
{
|
||||||
case 2:
|
case 2:
|
||||||
glUniformMatrix2fv (location, value->count, value->transpose, ptr);
|
ctx->glUniformMatrix2fv (location, value->count,
|
||||||
|
value->transpose, ptr);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
glUniformMatrix3fv (location, value->count, value->transpose, ptr);
|
ctx->glUniformMatrix3fv (location, value->count,
|
||||||
|
value->transpose, ptr);
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
glUniformMatrix4fv (location, value->count, value->transpose, ptr);
|
ctx->glUniformMatrix4fv (location, value->count,
|
||||||
|
value->transpose, ptr);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -517,7 +494,7 @@ _cogl_program_flush_uniform_arbfp (GLint location,
|
|||||||
g_return_if_fail (value->size == 4);
|
g_return_if_fail (value->size == 4);
|
||||||
g_return_if_fail (value->count == 1);
|
g_return_if_fail (value->count == 1);
|
||||||
|
|
||||||
GE( glProgramLocalParameter4fv (GL_FRAGMENT_PROGRAM_ARB, location,
|
GE( ctx, glProgramLocalParameter4fv (GL_FRAGMENT_PROGRAM_ARB, location,
|
||||||
value->v.float_value) );
|
value->v.float_value) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -552,7 +529,7 @@ _cogl_program_flush_uniforms (CoglProgram *program,
|
|||||||
if (_cogl_program_get_language (program) ==
|
if (_cogl_program_get_language (program) ==
|
||||||
COGL_SHADER_LANGUAGE_GLSL)
|
COGL_SHADER_LANGUAGE_GLSL)
|
||||||
uniform->location =
|
uniform->location =
|
||||||
glGetUniformLocation (gl_program, uniform->name);
|
ctx->glGetUniformLocation (gl_program, uniform->name);
|
||||||
else
|
else
|
||||||
uniform->location =
|
uniform->location =
|
||||||
get_local_param_index (uniform->name);
|
get_local_param_index (uniform->name);
|
||||||
|
@ -36,22 +36,6 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#ifdef HAVE_COGL_GL
|
|
||||||
#define glCreateShader ctx->glCreateShader
|
|
||||||
#define glGetShaderiv ctx->glGetShaderiv
|
|
||||||
#define glGetShaderInfoLog ctx->glGetShaderInfoLog
|
|
||||||
#define glCompileShader ctx->glCompileShader
|
|
||||||
#define glShaderSource ctx->glShaderSource
|
|
||||||
#define glDeleteShader ctx->glDeleteShader
|
|
||||||
#define glProgramString ctx->glProgramString
|
|
||||||
#define glBindProgram ctx->glBindProgram
|
|
||||||
#define glDeletePrograms ctx->glDeletePrograms
|
|
||||||
#define glGenPrograms ctx->glGenPrograms
|
|
||||||
#define GET_CONTEXT _COGL_GET_CONTEXT
|
|
||||||
#else
|
|
||||||
#define GET_CONTEXT(CTXVAR,RETVAL) G_STMT_START { } G_STMT_END
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static void _cogl_shader_free (CoglShader *shader);
|
static void _cogl_shader_free (CoglShader *shader);
|
||||||
|
|
||||||
COGL_HANDLE_DEFINE (Shader, shader);
|
COGL_HANDLE_DEFINE (Shader, shader);
|
||||||
@ -70,12 +54,12 @@ _cogl_shader_free (CoglShader *shader)
|
|||||||
if (shader->language == COGL_SHADER_LANGUAGE_ARBFP)
|
if (shader->language == COGL_SHADER_LANGUAGE_ARBFP)
|
||||||
{
|
{
|
||||||
if (shader->gl_handle)
|
if (shader->gl_handle)
|
||||||
GE (glDeletePrograms (1, &shader->gl_handle));
|
GE (ctx, glDeletePrograms (1, &shader->gl_handle));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
if (shader->gl_handle)
|
if (shader->gl_handle)
|
||||||
GE (glDeleteShader (shader->gl_handle));
|
GE (ctx, glDeleteShader (shader->gl_handle));
|
||||||
|
|
||||||
#endif /* HAVE_COGL_GLES */
|
#endif /* HAVE_COGL_GLES */
|
||||||
|
|
||||||
@ -87,7 +71,7 @@ cogl_create_shader (CoglShaderType type)
|
|||||||
{
|
{
|
||||||
CoglShader *shader;
|
CoglShader *shader;
|
||||||
|
|
||||||
GET_CONTEXT (ctx, COGL_INVALID_HANDLE);
|
_COGL_GET_CONTEXT (ctx, COGL_INVALID_HANDLE);
|
||||||
|
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
@ -122,13 +106,13 @@ delete_shader (CoglShader *shader)
|
|||||||
if (shader->language == COGL_SHADER_LANGUAGE_ARBFP)
|
if (shader->language == COGL_SHADER_LANGUAGE_ARBFP)
|
||||||
{
|
{
|
||||||
if (shader->gl_handle)
|
if (shader->gl_handle)
|
||||||
GE (glDeletePrograms (1, &shader->gl_handle));
|
GE (ctx, glDeletePrograms (1, &shader->gl_handle));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
if (shader->gl_handle)
|
if (shader->gl_handle)
|
||||||
GE (glDeleteShader (shader->gl_handle));
|
GE (ctx, glDeleteShader (shader->gl_handle));
|
||||||
}
|
}
|
||||||
|
|
||||||
shader->gl_handle = 0;
|
shader->gl_handle = 0;
|
||||||
@ -211,7 +195,7 @@ _cogl_shader_set_source_with_boilerplate (GLuint shader_gl_handle,
|
|||||||
char *tex_coord_declarations = NULL;
|
char *tex_coord_declarations = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
GET_CONTEXT (ctx, NO_RETVAL);
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
#ifdef HAVE_COGL_GLES2
|
#ifdef HAVE_COGL_GLES2
|
||||||
if (cogl_features_available (COGL_FEATURE_TEXTURE_3D))
|
if (cogl_features_available (COGL_FEATURE_TEXTURE_3D))
|
||||||
@ -295,7 +279,7 @@ _cogl_shader_set_source_with_boilerplate (GLuint shader_gl_handle,
|
|||||||
g_string_free (buf, TRUE);
|
g_string_free (buf, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
GE( glShaderSource (shader_gl_handle, count,
|
GE( ctx, glShaderSource (shader_gl_handle, count,
|
||||||
(const char **) strings, lengths) );
|
(const char **) strings, lengths) );
|
||||||
|
|
||||||
#ifdef HAVE_COGL_GLES2
|
#ifdef HAVE_COGL_GLES2
|
||||||
@ -325,30 +309,30 @@ _cogl_shader_compile_real (CoglHandle handle,
|
|||||||
if (shader->gl_handle)
|
if (shader->gl_handle)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
GE (glGenPrograms (1, &shader->gl_handle));
|
GE (ctx, glGenPrograms (1, &shader->gl_handle));
|
||||||
|
|
||||||
GE (glBindProgram (GL_FRAGMENT_PROGRAM_ARB, shader->gl_handle));
|
GE (ctx, glBindProgram (GL_FRAGMENT_PROGRAM_ARB, shader->gl_handle));
|
||||||
|
|
||||||
if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_SHOW_SOURCE)))
|
if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_SHOW_SOURCE)))
|
||||||
g_message ("user ARBfp program:\n%s", shader->source);
|
g_message ("user ARBfp program:\n%s", shader->source);
|
||||||
|
|
||||||
#ifdef COGL_GL_DEBUG
|
#ifdef COGL_GL_DEBUG
|
||||||
while ((gl_error = glGetError ()) != GL_NO_ERROR)
|
while ((gl_error = ctx->glGetError ()) != GL_NO_ERROR)
|
||||||
;
|
;
|
||||||
#endif
|
#endif
|
||||||
glProgramString (GL_FRAGMENT_PROGRAM_ARB,
|
ctx->glProgramString (GL_FRAGMENT_PROGRAM_ARB,
|
||||||
GL_PROGRAM_FORMAT_ASCII_ARB,
|
GL_PROGRAM_FORMAT_ASCII_ARB,
|
||||||
strlen (shader->source),
|
strlen (shader->source),
|
||||||
shader->source);
|
shader->source);
|
||||||
#ifdef COGL_GL_DEBUG
|
#ifdef COGL_GL_DEBUG
|
||||||
gl_error = glGetError ();
|
gl_error = ctx->glGetError ();
|
||||||
if (gl_error != GL_NO_ERROR)
|
if (gl_error != GL_NO_ERROR)
|
||||||
{
|
{
|
||||||
g_warning ("%s: GL error (%d): Failed to compile ARBfp:\n%s\n%s",
|
g_warning ("%s: GL error (%d): Failed to compile ARBfp:\n%s\n%s",
|
||||||
G_STRLOC,
|
G_STRLOC,
|
||||||
gl_error,
|
gl_error,
|
||||||
shader->source,
|
shader->source,
|
||||||
glGetString (GL_PROGRAM_ERROR_STRING_ARB));
|
ctx->glGetString (GL_PROGRAM_ERROR_STRING_ARB));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -380,7 +364,7 @@ _cogl_shader_compile_real (CoglHandle handle,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
shader->gl_handle = glCreateShader (gl_type);
|
shader->gl_handle = ctx->glCreateShader (gl_type);
|
||||||
|
|
||||||
_cogl_shader_set_source_with_boilerplate (shader->gl_handle,
|
_cogl_shader_set_source_with_boilerplate (shader->gl_handle,
|
||||||
gl_type,
|
gl_type,
|
||||||
@ -389,7 +373,7 @@ _cogl_shader_compile_real (CoglHandle handle,
|
|||||||
(const char **) &shader->source,
|
(const char **) &shader->source,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
GE (glCompileShader (shader->gl_handle));
|
GE (ctx, glCompileShader (shader->gl_handle));
|
||||||
|
|
||||||
#ifdef HAVE_COGL_GLES2
|
#ifdef HAVE_COGL_GLES2
|
||||||
shader->n_tex_coord_attribs = n_tex_coord_attribs;
|
shader->n_tex_coord_attribs = n_tex_coord_attribs;
|
||||||
@ -420,7 +404,7 @@ cogl_shader_get_info_log (CoglHandle handle)
|
|||||||
|
|
||||||
CoglShader *shader;
|
CoglShader *shader;
|
||||||
|
|
||||||
GET_CONTEXT (ctx, NULL);
|
_COGL_GET_CONTEXT (ctx, NULL);
|
||||||
|
|
||||||
if (!cogl_is_shader (handle))
|
if (!cogl_is_shader (handle))
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -455,7 +439,7 @@ cogl_shader_get_info_log (CoglHandle handle)
|
|||||||
if (!shader->gl_handle)
|
if (!shader->gl_handle)
|
||||||
_cogl_shader_compile_real (handle, 4);
|
_cogl_shader_compile_real (handle, 4);
|
||||||
|
|
||||||
glGetShaderInfoLog (shader->gl_handle, 511, &len, buffer);
|
ctx->glGetShaderInfoLog (shader->gl_handle, 511, &len, buffer);
|
||||||
buffer[len] = '\0';
|
buffer[len] = '\0';
|
||||||
return g_strdup (buffer);
|
return g_strdup (buffer);
|
||||||
}
|
}
|
||||||
@ -468,7 +452,7 @@ cogl_shader_get_type (CoglHandle handle)
|
|||||||
{
|
{
|
||||||
CoglShader *shader;
|
CoglShader *shader;
|
||||||
|
|
||||||
GET_CONTEXT (ctx, COGL_SHADER_TYPE_VERTEX);
|
_COGL_GET_CONTEXT (ctx, COGL_SHADER_TYPE_VERTEX);
|
||||||
|
|
||||||
if (!cogl_is_shader (handle))
|
if (!cogl_is_shader (handle))
|
||||||
{
|
{
|
||||||
@ -492,7 +476,7 @@ cogl_shader_is_compiled (CoglHandle handle)
|
|||||||
GLint status;
|
GLint status;
|
||||||
CoglShader *shader;
|
CoglShader *shader;
|
||||||
|
|
||||||
GET_CONTEXT (ctx, FALSE);
|
_COGL_GET_CONTEXT (ctx, FALSE);
|
||||||
|
|
||||||
if (!cogl_is_shader (handle))
|
if (!cogl_is_shader (handle))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -523,7 +507,7 @@ cogl_shader_is_compiled (CoglHandle handle)
|
|||||||
if (!shader->gl_handle)
|
if (!shader->gl_handle)
|
||||||
_cogl_shader_compile_real (handle, 4);
|
_cogl_shader_compile_real (handle, 4);
|
||||||
|
|
||||||
GE (glGetShaderiv (shader->gl_handle, GL_COMPILE_STATUS, &status));
|
GE (ctx, glGetShaderiv (shader->gl_handle, GL_COMPILE_STATUS, &status));
|
||||||
if (status == GL_TRUE)
|
if (status == GL_TRUE)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
else
|
else
|
||||||
|
@ -136,6 +136,8 @@ _cogl_texture_2d_set_wrap_mode_parameters (CoglTexture *tex,
|
|||||||
{
|
{
|
||||||
CoglTexture2D *tex_2d = COGL_TEXTURE_2D (tex);
|
CoglTexture2D *tex_2d = COGL_TEXTURE_2D (tex);
|
||||||
|
|
||||||
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
/* Only set the wrap mode if it's different from the current value
|
/* Only set the wrap mode if it's different from the current value
|
||||||
to avoid too many GL calls. Texture 2D doesn't make use of the r
|
to avoid too many GL calls. Texture 2D doesn't make use of the r
|
||||||
coordinate so we can ignore its wrap mode */
|
coordinate so we can ignore its wrap mode */
|
||||||
@ -145,8 +147,12 @@ _cogl_texture_2d_set_wrap_mode_parameters (CoglTexture *tex,
|
|||||||
_cogl_bind_gl_texture_transient (GL_TEXTURE_2D,
|
_cogl_bind_gl_texture_transient (GL_TEXTURE_2D,
|
||||||
tex_2d->gl_texture,
|
tex_2d->gl_texture,
|
||||||
tex_2d->is_foreign);
|
tex_2d->is_foreign);
|
||||||
GE( glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrap_mode_s) );
|
GE( ctx, glTexParameteri (GL_TEXTURE_2D,
|
||||||
GE( glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrap_mode_t) );
|
GL_TEXTURE_WRAP_S,
|
||||||
|
wrap_mode_s) );
|
||||||
|
GE( ctx, glTexParameteri (GL_TEXTURE_2D,
|
||||||
|
GL_TEXTURE_WRAP_T,
|
||||||
|
wrap_mode_t) );
|
||||||
|
|
||||||
tex_2d->wrap_mode_s = wrap_mode_s;
|
tex_2d->wrap_mode_s = wrap_mode_s;
|
||||||
tex_2d->wrap_mode_t = wrap_mode_t;
|
tex_2d->wrap_mode_t = wrap_mode_t;
|
||||||
@ -262,7 +268,7 @@ cogl_texture_2d_new_with_size (CoglContext *ctx,
|
|||||||
_cogl_bind_gl_texture_transient (GL_TEXTURE_2D,
|
_cogl_bind_gl_texture_transient (GL_TEXTURE_2D,
|
||||||
tex_2d->gl_texture,
|
tex_2d->gl_texture,
|
||||||
tex_2d->is_foreign);
|
tex_2d->is_foreign);
|
||||||
GE( glTexImage2D (GL_TEXTURE_2D, 0, gl_intformat,
|
GE( ctx, glTexImage2D (GL_TEXTURE_2D, 0, gl_intformat,
|
||||||
width, height, 0, gl_format, gl_type, NULL) );
|
width, height, 0, gl_format, gl_type, NULL) );
|
||||||
|
|
||||||
return _cogl_texture_2d_handle_new (tex_2d);
|
return _cogl_texture_2d_handle_new (tex_2d);
|
||||||
@ -405,15 +411,15 @@ cogl_texture_2d_new_from_foreign (CoglContext *ctx,
|
|||||||
return COGL_INVALID_HANDLE;
|
return COGL_INVALID_HANDLE;
|
||||||
|
|
||||||
/* Make sure it is a valid GL texture object */
|
/* Make sure it is a valid GL texture object */
|
||||||
if (!glIsTexture (gl_handle))
|
if (!ctx->glIsTexture (gl_handle))
|
||||||
return COGL_INVALID_HANDLE;
|
return COGL_INVALID_HANDLE;
|
||||||
|
|
||||||
/* Make sure binding succeeds */
|
/* Make sure binding succeeds */
|
||||||
while ((gl_error = glGetError ()) != GL_NO_ERROR)
|
while ((gl_error = ctx->glGetError ()) != GL_NO_ERROR)
|
||||||
;
|
;
|
||||||
|
|
||||||
_cogl_bind_gl_texture_transient (GL_TEXTURE_2D, gl_handle, TRUE);
|
_cogl_bind_gl_texture_transient (GL_TEXTURE_2D, gl_handle, TRUE);
|
||||||
if (glGetError () != GL_NO_ERROR)
|
if (ctx->glGetError () != GL_NO_ERROR)
|
||||||
return COGL_INVALID_HANDLE;
|
return COGL_INVALID_HANDLE;
|
||||||
|
|
||||||
/* Obtain texture parameters
|
/* Obtain texture parameters
|
||||||
@ -421,14 +427,14 @@ cogl_texture_2d_new_from_foreign (CoglContext *ctx,
|
|||||||
|
|
||||||
#if HAVE_COGL_GL
|
#if HAVE_COGL_GL
|
||||||
|
|
||||||
GE( glGetTexLevelParameteriv (GL_TEXTURE_2D, 0,
|
GE( ctx, glGetTexLevelParameteriv (GL_TEXTURE_2D, 0,
|
||||||
GL_TEXTURE_COMPRESSED,
|
GL_TEXTURE_COMPRESSED,
|
||||||
&gl_compressed) );
|
&gl_compressed) );
|
||||||
|
|
||||||
{
|
{
|
||||||
GLint val;
|
GLint val;
|
||||||
|
|
||||||
GE( glGetTexLevelParameteriv (GL_TEXTURE_2D, 0,
|
GE( ctx, glGetTexLevelParameteriv (GL_TEXTURE_2D, 0,
|
||||||
GL_TEXTURE_INTERNAL_FORMAT,
|
GL_TEXTURE_INTERNAL_FORMAT,
|
||||||
&val) );
|
&val) );
|
||||||
|
|
||||||
@ -529,10 +535,10 @@ _cogl_egl_texture_2d_new_from_image (CoglContext *ctx,
|
|||||||
tex_2d->gl_texture,
|
tex_2d->gl_texture,
|
||||||
FALSE);
|
FALSE);
|
||||||
|
|
||||||
while ((gl_error = glGetError ()) != GL_NO_ERROR)
|
while ((gl_error = ctx->glGetError ()) != GL_NO_ERROR)
|
||||||
;
|
;
|
||||||
ctx->glEGLImageTargetTexture2D (GL_TEXTURE_2D, image);
|
ctx->glEGLImageTargetTexture2D (GL_TEXTURE_2D, image);
|
||||||
if (glGetError () != GL_NO_ERROR)
|
if (ctx->glGetError () != GL_NO_ERROR)
|
||||||
{
|
{
|
||||||
g_set_error (error,
|
g_set_error (error,
|
||||||
COGL_TEXTURE_ERROR,
|
COGL_TEXTURE_ERROR,
|
||||||
@ -630,6 +636,8 @@ _cogl_texture_2d_copy_from_framebuffer (CoglHandle handle,
|
|||||||
{
|
{
|
||||||
CoglTexture2D *tex_2d;
|
CoglTexture2D *tex_2d;
|
||||||
|
|
||||||
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
g_return_if_fail (cogl_is_texture_2d (handle));
|
g_return_if_fail (cogl_is_texture_2d (handle));
|
||||||
|
|
||||||
tex_2d = COGL_TEXTURE_2D (handle);
|
tex_2d = COGL_TEXTURE_2D (handle);
|
||||||
@ -644,7 +652,7 @@ _cogl_texture_2d_copy_from_framebuffer (CoglHandle handle,
|
|||||||
tex_2d->gl_texture,
|
tex_2d->gl_texture,
|
||||||
tex_2d->is_foreign);
|
tex_2d->is_foreign);
|
||||||
|
|
||||||
glCopyTexSubImage2D (GL_TEXTURE_2D,
|
ctx->glCopyTexSubImage2D (GL_TEXTURE_2D,
|
||||||
0, /* level */
|
0, /* level */
|
||||||
dst_x, dst_y,
|
dst_x, dst_y,
|
||||||
src_x, src_y,
|
src_x, src_y,
|
||||||
@ -721,6 +729,8 @@ _cogl_texture_2d_set_filters (CoglTexture *tex,
|
|||||||
{
|
{
|
||||||
CoglTexture2D *tex_2d = COGL_TEXTURE_2D (tex);
|
CoglTexture2D *tex_2d = COGL_TEXTURE_2D (tex);
|
||||||
|
|
||||||
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
if (min_filter == tex_2d->min_filter
|
if (min_filter == tex_2d->min_filter
|
||||||
&& mag_filter == tex_2d->mag_filter)
|
&& mag_filter == tex_2d->mag_filter)
|
||||||
return;
|
return;
|
||||||
@ -733,8 +743,8 @@ _cogl_texture_2d_set_filters (CoglTexture *tex,
|
|||||||
_cogl_bind_gl_texture_transient (GL_TEXTURE_2D,
|
_cogl_bind_gl_texture_transient (GL_TEXTURE_2D,
|
||||||
tex_2d->gl_texture,
|
tex_2d->gl_texture,
|
||||||
tex_2d->is_foreign);
|
tex_2d->is_foreign);
|
||||||
GE( glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, mag_filter) );
|
GE( ctx, glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, mag_filter) );
|
||||||
GE( glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, min_filter) );
|
GE( ctx, glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, min_filter) );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -760,14 +770,14 @@ _cogl_texture_2d_pre_paint (CoglTexture *tex, CoglTexturePrePaintFlags flags)
|
|||||||
#ifndef HAVE_COGL_GLES2
|
#ifndef HAVE_COGL_GLES2
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GE( glTexParameteri (GL_TEXTURE_2D,
|
GE( ctx, glTexParameteri (GL_TEXTURE_2D,
|
||||||
GL_GENERATE_MIPMAP,
|
GL_GENERATE_MIPMAP,
|
||||||
GL_TRUE) );
|
GL_TRUE) );
|
||||||
GE( glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, 1, 1,
|
GE( ctx, glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, 1, 1,
|
||||||
tex_2d->first_pixel.gl_format,
|
tex_2d->first_pixel.gl_format,
|
||||||
tex_2d->first_pixel.gl_type,
|
tex_2d->first_pixel.gl_type,
|
||||||
tex_2d->first_pixel.data) );
|
tex_2d->first_pixel.data) );
|
||||||
GE( glTexParameteri (GL_TEXTURE_2D,
|
GE( ctx, glTexParameteri (GL_TEXTURE_2D,
|
||||||
GL_GENERATE_MIPMAP,
|
GL_GENERATE_MIPMAP,
|
||||||
GL_FALSE) );
|
GL_FALSE) );
|
||||||
}
|
}
|
||||||
|
@ -49,9 +49,6 @@
|
|||||||
#define GL_TEXTURE_WRAP_R 0x8072
|
#define GL_TEXTURE_WRAP_R 0x8072
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define glTexImage3D ctx->glTexImage3D
|
|
||||||
#define glTexSubImage3D ctx->glTexSubImage3D
|
|
||||||
|
|
||||||
static void _cogl_texture_3d_free (CoglTexture3D *tex_3d);
|
static void _cogl_texture_3d_free (CoglTexture3D *tex_3d);
|
||||||
|
|
||||||
COGL_TEXTURE_DEFINE (Texture3D, texture_3d);
|
COGL_TEXTURE_DEFINE (Texture3D, texture_3d);
|
||||||
@ -140,6 +137,8 @@ _cogl_texture_3d_set_wrap_mode_parameters (CoglTexture *tex,
|
|||||||
{
|
{
|
||||||
CoglTexture3D *tex_3d = COGL_TEXTURE_3D (tex);
|
CoglTexture3D *tex_3d = COGL_TEXTURE_3D (tex);
|
||||||
|
|
||||||
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
/* Only set the wrap mode if it's different from the current value
|
/* Only set the wrap mode if it's different from the current value
|
||||||
to avoid too many GL calls. */
|
to avoid too many GL calls. */
|
||||||
if (tex_3d->wrap_mode_s != wrap_mode_s ||
|
if (tex_3d->wrap_mode_s != wrap_mode_s ||
|
||||||
@ -149,9 +148,15 @@ _cogl_texture_3d_set_wrap_mode_parameters (CoglTexture *tex,
|
|||||||
_cogl_bind_gl_texture_transient (GL_TEXTURE_3D,
|
_cogl_bind_gl_texture_transient (GL_TEXTURE_3D,
|
||||||
tex_3d->gl_texture,
|
tex_3d->gl_texture,
|
||||||
FALSE);
|
FALSE);
|
||||||
GE( glTexParameteri (GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, wrap_mode_s) );
|
GE( ctx, glTexParameteri (GL_TEXTURE_3D,
|
||||||
GE( glTexParameteri (GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, wrap_mode_t) );
|
GL_TEXTURE_WRAP_S,
|
||||||
GE( glTexParameteri (GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, wrap_mode_p) );
|
wrap_mode_s) );
|
||||||
|
GE( ctx, glTexParameteri (GL_TEXTURE_3D,
|
||||||
|
GL_TEXTURE_WRAP_T,
|
||||||
|
wrap_mode_t) );
|
||||||
|
GE( ctx, glTexParameteri (GL_TEXTURE_3D,
|
||||||
|
GL_TEXTURE_WRAP_R,
|
||||||
|
wrap_mode_p) );
|
||||||
|
|
||||||
tex_3d->wrap_mode_s = wrap_mode_s;
|
tex_3d->wrap_mode_s = wrap_mode_s;
|
||||||
tex_3d->wrap_mode_t = wrap_mode_t;
|
tex_3d->wrap_mode_t = wrap_mode_t;
|
||||||
@ -295,7 +300,7 @@ cogl_texture_3d_new_with_size (unsigned int width,
|
|||||||
_cogl_bind_gl_texture_transient (GL_TEXTURE_3D,
|
_cogl_bind_gl_texture_transient (GL_TEXTURE_3D,
|
||||||
tex_3d->gl_texture,
|
tex_3d->gl_texture,
|
||||||
FALSE);
|
FALSE);
|
||||||
GE( glTexImage3D (GL_TEXTURE_3D, 0, gl_intformat,
|
GE( ctx, glTexImage3D (GL_TEXTURE_3D, 0, gl_intformat,
|
||||||
width, height, depth, 0, gl_format, gl_type, NULL) );
|
width, height, depth, 0, gl_format, gl_type, NULL) );
|
||||||
|
|
||||||
return _cogl_texture_3d_handle_new (tex_3d);
|
return _cogl_texture_3d_handle_new (tex_3d);
|
||||||
@ -536,6 +541,8 @@ _cogl_texture_3d_set_filters (CoglTexture *tex,
|
|||||||
{
|
{
|
||||||
CoglTexture3D *tex_3d = COGL_TEXTURE_3D (tex);
|
CoglTexture3D *tex_3d = COGL_TEXTURE_3D (tex);
|
||||||
|
|
||||||
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
if (min_filter == tex_3d->min_filter
|
if (min_filter == tex_3d->min_filter
|
||||||
&& mag_filter == tex_3d->mag_filter)
|
&& mag_filter == tex_3d->mag_filter)
|
||||||
return;
|
return;
|
||||||
@ -548,8 +555,8 @@ _cogl_texture_3d_set_filters (CoglTexture *tex,
|
|||||||
_cogl_bind_gl_texture_transient (GL_TEXTURE_3D,
|
_cogl_bind_gl_texture_transient (GL_TEXTURE_3D,
|
||||||
tex_3d->gl_texture,
|
tex_3d->gl_texture,
|
||||||
FALSE);
|
FALSE);
|
||||||
GE( glTexParameteri (GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, mag_filter) );
|
GE( ctx, glTexParameteri (GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, mag_filter) );
|
||||||
GE( glTexParameteri (GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, min_filter) );
|
GE( ctx, glTexParameteri (GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, min_filter) );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -574,10 +581,10 @@ _cogl_texture_3d_pre_paint (CoglTexture *tex, CoglTexturePrePaintFlags flags)
|
|||||||
#ifndef HAVE_COGL_GLES2
|
#ifndef HAVE_COGL_GLES2
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GE( glTexParameteri (GL_TEXTURE_3D,
|
GE( ctx, glTexParameteri (GL_TEXTURE_3D,
|
||||||
GL_GENERATE_MIPMAP,
|
GL_GENERATE_MIPMAP,
|
||||||
GL_TRUE) );
|
GL_TRUE) );
|
||||||
GE( glTexSubImage3D (GL_TEXTURE_3D,
|
GE( ctx, glTexSubImage3D (GL_TEXTURE_3D,
|
||||||
0, /* level */
|
0, /* level */
|
||||||
0, /* xoffset */
|
0, /* xoffset */
|
||||||
0, /* yoffset */
|
0, /* yoffset */
|
||||||
@ -588,7 +595,7 @@ _cogl_texture_3d_pre_paint (CoglTexture *tex, CoglTexturePrePaintFlags flags)
|
|||||||
tex_3d->first_pixel.gl_format,
|
tex_3d->first_pixel.gl_format,
|
||||||
tex_3d->first_pixel.gl_type,
|
tex_3d->first_pixel.gl_type,
|
||||||
tex_3d->first_pixel.data) );
|
tex_3d->first_pixel.data) );
|
||||||
GE( glTexParameteri (GL_TEXTURE_3D,
|
GE( ctx, glTexParameteri (GL_TEXTURE_3D,
|
||||||
GL_GENERATE_MIPMAP,
|
GL_GENERATE_MIPMAP,
|
||||||
GL_FALSE) );
|
GL_FALSE) );
|
||||||
}
|
}
|
||||||
|
@ -154,6 +154,8 @@ _cogl_texture_rectangle_set_wrap_mode_parameters (CoglTexture *tex,
|
|||||||
{
|
{
|
||||||
CoglTextureRectangle *tex_rect = COGL_TEXTURE_RECTANGLE (tex);
|
CoglTextureRectangle *tex_rect = COGL_TEXTURE_RECTANGLE (tex);
|
||||||
|
|
||||||
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
/* Only set the wrap mode if it's different from the current value
|
/* Only set the wrap mode if it's different from the current value
|
||||||
to avoid too many GL calls. Texture rectangle doesn't make use of
|
to avoid too many GL calls. Texture rectangle doesn't make use of
|
||||||
the r coordinate so we can ignore its wrap mode */
|
the r coordinate so we can ignore its wrap mode */
|
||||||
@ -163,12 +165,12 @@ _cogl_texture_rectangle_set_wrap_mode_parameters (CoglTexture *tex,
|
|||||||
g_assert (can_use_wrap_mode (wrap_mode_s));
|
g_assert (can_use_wrap_mode (wrap_mode_s));
|
||||||
g_assert (can_use_wrap_mode (wrap_mode_t));
|
g_assert (can_use_wrap_mode (wrap_mode_t));
|
||||||
|
|
||||||
GE( _cogl_bind_gl_texture_transient (GL_TEXTURE_RECTANGLE_ARB,
|
_cogl_bind_gl_texture_transient (GL_TEXTURE_RECTANGLE_ARB,
|
||||||
tex_rect->gl_texture,
|
tex_rect->gl_texture,
|
||||||
tex_rect->is_foreign) );
|
tex_rect->is_foreign);
|
||||||
GE( glTexParameteri (GL_TEXTURE_RECTANGLE_ARB,
|
GE( ctx, glTexParameteri (GL_TEXTURE_RECTANGLE_ARB,
|
||||||
GL_TEXTURE_WRAP_S, wrap_mode_s) );
|
GL_TEXTURE_WRAP_S, wrap_mode_s) );
|
||||||
GE( glTexParameteri (GL_TEXTURE_RECTANGLE_ARB,
|
GE( ctx, glTexParameteri (GL_TEXTURE_RECTANGLE_ARB,
|
||||||
GL_TEXTURE_WRAP_T, wrap_mode_t) );
|
GL_TEXTURE_WRAP_T, wrap_mode_t) );
|
||||||
|
|
||||||
tex_rect->wrap_mode_s = wrap_mode_s;
|
tex_rect->wrap_mode_s = wrap_mode_s;
|
||||||
@ -251,6 +253,8 @@ _cogl_texture_rectangle_new_with_size (unsigned int width,
|
|||||||
GLenum gl_format;
|
GLenum gl_format;
|
||||||
GLenum gl_type;
|
GLenum gl_type;
|
||||||
|
|
||||||
|
_COGL_GET_CONTEXT (ctx, COGL_INVALID_HANDLE);
|
||||||
|
|
||||||
/* Since no data, we need some internal format */
|
/* Since no data, we need some internal format */
|
||||||
if (internal_format == COGL_PIXEL_FORMAT_ANY)
|
if (internal_format == COGL_PIXEL_FORMAT_ANY)
|
||||||
internal_format = COGL_PIXEL_FORMAT_RGBA_8888_PRE;
|
internal_format = COGL_PIXEL_FORMAT_RGBA_8888_PRE;
|
||||||
@ -267,10 +271,10 @@ _cogl_texture_rectangle_new_with_size (unsigned int width,
|
|||||||
internal_format);
|
internal_format);
|
||||||
|
|
||||||
_cogl_texture_driver_gen (GL_TEXTURE_RECTANGLE_ARB, 1, &tex_rect->gl_texture);
|
_cogl_texture_driver_gen (GL_TEXTURE_RECTANGLE_ARB, 1, &tex_rect->gl_texture);
|
||||||
GE( _cogl_bind_gl_texture_transient (GL_TEXTURE_RECTANGLE_ARB,
|
_cogl_bind_gl_texture_transient (GL_TEXTURE_RECTANGLE_ARB,
|
||||||
tex_rect->gl_texture,
|
tex_rect->gl_texture,
|
||||||
tex_rect->is_foreign) );
|
tex_rect->is_foreign);
|
||||||
GE( glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, gl_intformat,
|
GE( ctx, glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, gl_intformat,
|
||||||
width, height, 0, gl_format, gl_type, NULL) );
|
width, height, 0, gl_format, gl_type, NULL) );
|
||||||
|
|
||||||
return _cogl_texture_rectangle_handle_new (tex_rect);
|
return _cogl_texture_rectangle_handle_new (tex_rect);
|
||||||
@ -344,33 +348,35 @@ _cogl_texture_rectangle_new_from_foreign (GLuint gl_handle,
|
|||||||
GLenum gl_int_format = 0;
|
GLenum gl_int_format = 0;
|
||||||
CoglTextureRectangle *tex_rect;
|
CoglTextureRectangle *tex_rect;
|
||||||
|
|
||||||
|
_COGL_GET_CONTEXT (ctx, COGL_INVALID_HANDLE);
|
||||||
|
|
||||||
if (!_cogl_texture_driver_allows_foreign_gl_target (GL_TEXTURE_RECTANGLE_ARB))
|
if (!_cogl_texture_driver_allows_foreign_gl_target (GL_TEXTURE_RECTANGLE_ARB))
|
||||||
return COGL_INVALID_HANDLE;
|
return COGL_INVALID_HANDLE;
|
||||||
|
|
||||||
/* Make sure it is a valid GL texture object */
|
/* Make sure it is a valid GL texture object */
|
||||||
if (!glIsTexture (gl_handle))
|
if (!ctx->glIsTexture (gl_handle))
|
||||||
return COGL_INVALID_HANDLE;
|
return COGL_INVALID_HANDLE;
|
||||||
|
|
||||||
/* Make sure binding succeeds */
|
/* Make sure binding succeeds */
|
||||||
while ((gl_error = glGetError ()) != GL_NO_ERROR)
|
while ((gl_error = ctx->glGetError ()) != GL_NO_ERROR)
|
||||||
;
|
;
|
||||||
|
|
||||||
_cogl_bind_gl_texture_transient (GL_TEXTURE_RECTANGLE_ARB, gl_handle, TRUE);
|
_cogl_bind_gl_texture_transient (GL_TEXTURE_RECTANGLE_ARB, gl_handle, TRUE);
|
||||||
if (glGetError () != GL_NO_ERROR)
|
if (ctx->glGetError () != GL_NO_ERROR)
|
||||||
return COGL_INVALID_HANDLE;
|
return COGL_INVALID_HANDLE;
|
||||||
|
|
||||||
/* Obtain texture parameters */
|
/* Obtain texture parameters */
|
||||||
|
|
||||||
#if HAVE_COGL_GL
|
#if HAVE_COGL_GL
|
||||||
|
|
||||||
GE( glGetTexLevelParameteriv (GL_TEXTURE_RECTANGLE_ARB, 0,
|
GE( ctx, glGetTexLevelParameteriv (GL_TEXTURE_RECTANGLE_ARB, 0,
|
||||||
GL_TEXTURE_COMPRESSED,
|
GL_TEXTURE_COMPRESSED,
|
||||||
&gl_compressed) );
|
&gl_compressed) );
|
||||||
|
|
||||||
{
|
{
|
||||||
GLint val;
|
GLint val;
|
||||||
|
|
||||||
GE( glGetTexLevelParameteriv (GL_TEXTURE_RECTANGLE_ARB, 0,
|
GE( ctx, glGetTexLevelParameteriv (GL_TEXTURE_RECTANGLE_ARB, 0,
|
||||||
GL_TEXTURE_INTERNAL_FORMAT,
|
GL_TEXTURE_INTERNAL_FORMAT,
|
||||||
&val) );
|
&val) );
|
||||||
|
|
||||||
@ -499,6 +505,8 @@ _cogl_texture_rectangle_set_filters (CoglTexture *tex,
|
|||||||
{
|
{
|
||||||
CoglTextureRectangle *tex_rect = COGL_TEXTURE_RECTANGLE (tex);
|
CoglTextureRectangle *tex_rect = COGL_TEXTURE_RECTANGLE (tex);
|
||||||
|
|
||||||
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
if (min_filter == tex_rect->min_filter
|
if (min_filter == tex_rect->min_filter
|
||||||
&& mag_filter == tex_rect->mag_filter)
|
&& mag_filter == tex_rect->mag_filter)
|
||||||
return;
|
return;
|
||||||
@ -511,12 +519,12 @@ _cogl_texture_rectangle_set_filters (CoglTexture *tex,
|
|||||||
tex_rect->mag_filter = mag_filter;
|
tex_rect->mag_filter = mag_filter;
|
||||||
|
|
||||||
/* Apply new filters to the texture */
|
/* Apply new filters to the texture */
|
||||||
GE( _cogl_bind_gl_texture_transient (GL_TEXTURE_RECTANGLE_ARB,
|
_cogl_bind_gl_texture_transient (GL_TEXTURE_RECTANGLE_ARB,
|
||||||
tex_rect->gl_texture,
|
tex_rect->gl_texture,
|
||||||
tex_rect->is_foreign) );
|
tex_rect->is_foreign);
|
||||||
GE( glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER,
|
GE( ctx, glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER,
|
||||||
mag_filter) );
|
mag_filter) );
|
||||||
GE( glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER,
|
GE( ctx, glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER,
|
||||||
min_filter) );
|
min_filter) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -580,6 +588,8 @@ _cogl_texture_rectangle_get_data (CoglTexture *tex,
|
|||||||
GLenum gl_format;
|
GLenum gl_format;
|
||||||
GLenum gl_type;
|
GLenum gl_type;
|
||||||
|
|
||||||
|
_COGL_GET_CONTEXT (ctx, FALSE);
|
||||||
|
|
||||||
bpp = _cogl_get_format_bpp (format);
|
bpp = _cogl_get_format_bpp (format);
|
||||||
|
|
||||||
_cogl_pixel_format_to_gl (format,
|
_cogl_pixel_format_to_gl (format,
|
||||||
@ -589,9 +599,9 @@ _cogl_texture_rectangle_get_data (CoglTexture *tex,
|
|||||||
|
|
||||||
_cogl_texture_driver_prep_gl_for_pixels_download (rowstride, bpp);
|
_cogl_texture_driver_prep_gl_for_pixels_download (rowstride, bpp);
|
||||||
|
|
||||||
GE( _cogl_bind_gl_texture_transient (GL_TEXTURE_RECTANGLE_ARB,
|
_cogl_bind_gl_texture_transient (GL_TEXTURE_RECTANGLE_ARB,
|
||||||
tex_rect->gl_texture,
|
tex_rect->gl_texture,
|
||||||
tex_rect->is_foreign) );
|
tex_rect->is_foreign);
|
||||||
return _cogl_texture_driver_gl_get_tex_image (GL_TEXTURE_RECTANGLE_ARB,
|
return _cogl_texture_driver_gl_get_tex_image (GL_TEXTURE_RECTANGLE_ARB,
|
||||||
gl_format,
|
gl_format,
|
||||||
gl_type,
|
gl_type,
|
||||||
|
@ -250,27 +250,31 @@ _cogl_texture_prepare_for_upload (CoglBitmap *src_bmp,
|
|||||||
void
|
void
|
||||||
_cogl_texture_prep_gl_alignment_for_pixels_upload (int pixels_rowstride)
|
_cogl_texture_prep_gl_alignment_for_pixels_upload (int pixels_rowstride)
|
||||||
{
|
{
|
||||||
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
if (!(pixels_rowstride & 0x7))
|
if (!(pixels_rowstride & 0x7))
|
||||||
GE( glPixelStorei (GL_UNPACK_ALIGNMENT, 8) );
|
GE( ctx, glPixelStorei (GL_UNPACK_ALIGNMENT, 8) );
|
||||||
else if (!(pixels_rowstride & 0x3))
|
else if (!(pixels_rowstride & 0x3))
|
||||||
GE( glPixelStorei (GL_UNPACK_ALIGNMENT, 4) );
|
GE( ctx, glPixelStorei (GL_UNPACK_ALIGNMENT, 4) );
|
||||||
else if (!(pixels_rowstride & 0x1))
|
else if (!(pixels_rowstride & 0x1))
|
||||||
GE( glPixelStorei (GL_UNPACK_ALIGNMENT, 2) );
|
GE( ctx, glPixelStorei (GL_UNPACK_ALIGNMENT, 2) );
|
||||||
else
|
else
|
||||||
GE( glPixelStorei (GL_UNPACK_ALIGNMENT, 1) );
|
GE( ctx, glPixelStorei (GL_UNPACK_ALIGNMENT, 1) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
_cogl_texture_prep_gl_alignment_for_pixels_download (int pixels_rowstride)
|
_cogl_texture_prep_gl_alignment_for_pixels_download (int pixels_rowstride)
|
||||||
{
|
{
|
||||||
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
if (!(pixels_rowstride & 0x7))
|
if (!(pixels_rowstride & 0x7))
|
||||||
GE( glPixelStorei (GL_PACK_ALIGNMENT, 8) );
|
GE( ctx, glPixelStorei (GL_PACK_ALIGNMENT, 8) );
|
||||||
else if (!(pixels_rowstride & 0x3))
|
else if (!(pixels_rowstride & 0x3))
|
||||||
GE( glPixelStorei (GL_PACK_ALIGNMENT, 4) );
|
GE( ctx, glPixelStorei (GL_PACK_ALIGNMENT, 4) );
|
||||||
else if (!(pixels_rowstride & 0x1))
|
else if (!(pixels_rowstride & 0x1))
|
||||||
GE( glPixelStorei (GL_PACK_ALIGNMENT, 2) );
|
GE( ctx, glPixelStorei (GL_PACK_ALIGNMENT, 2) );
|
||||||
else
|
else
|
||||||
GE( glPixelStorei (GL_PACK_ALIGNMENT, 1) );
|
GE( ctx, glPixelStorei (GL_PACK_ALIGNMENT, 1) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: wrap modes should be set on pipelines not textures */
|
/* FIXME: wrap modes should be set on pipelines not textures */
|
||||||
@ -1119,10 +1123,10 @@ _cogl_texture_draw_and_read (CoglHandle handle,
|
|||||||
still doesn't seem to have an alpha buffer. This might be just
|
still doesn't seem to have an alpha buffer. This might be just
|
||||||
a PowerVR issue.
|
a PowerVR issue.
|
||||||
GLint r_bits, g_bits, b_bits, a_bits;
|
GLint r_bits, g_bits, b_bits, a_bits;
|
||||||
GE( glGetIntegerv (GL_ALPHA_BITS, &a_bits) );
|
GE( ctx, glGetIntegerv (GL_ALPHA_BITS, &a_bits) );
|
||||||
GE( glGetIntegerv (GL_RED_BITS, &r_bits) );
|
GE( ctx, glGetIntegerv (GL_RED_BITS, &r_bits) );
|
||||||
GE( glGetIntegerv (GL_GREEN_BITS, &g_bits) );
|
GE( ctx, glGetIntegerv (GL_GREEN_BITS, &g_bits) );
|
||||||
GE( glGetIntegerv (GL_BLUE_BITS, &b_bits) );
|
GE( ctx, glGetIntegerv (GL_BLUE_BITS, &b_bits) );
|
||||||
printf ("R bits: %d\n", r_bits);
|
printf ("R bits: %d\n", r_bits);
|
||||||
printf ("G bits: %d\n", g_bits);
|
printf ("G bits: %d\n", g_bits);
|
||||||
printf ("B bits: %d\n", b_bits);
|
printf ("B bits: %d\n", b_bits);
|
||||||
|
20
cogl/cogl.c
20
cogl/cogl.c
@ -47,10 +47,6 @@
|
|||||||
#include "cogl-attribute-private.h"
|
#include "cogl-attribute-private.h"
|
||||||
#include "cogl-framebuffer-private.h"
|
#include "cogl-framebuffer-private.h"
|
||||||
|
|
||||||
#ifdef HAVE_COGL_GL
|
|
||||||
#define glClientActiveTexture ctx->drv.pf_glClientActiveTexture
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef COGL_GL_DEBUG
|
#ifdef COGL_GL_DEBUG
|
||||||
/* GL error to string conversion */
|
/* GL error to string conversion */
|
||||||
static const struct {
|
static const struct {
|
||||||
@ -154,14 +150,14 @@ toggle_flag (CoglContext *ctx,
|
|||||||
{
|
{
|
||||||
if (!(ctx->enable_flags & flag))
|
if (!(ctx->enable_flags & flag))
|
||||||
{
|
{
|
||||||
GE( glEnable (gl_flag) );
|
GE( ctx, glEnable (gl_flag) );
|
||||||
ctx->enable_flags |= flag;
|
ctx->enable_flags |= flag;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (ctx->enable_flags & flag)
|
else if (ctx->enable_flags & flag)
|
||||||
{
|
{
|
||||||
GE( glDisable (gl_flag) );
|
GE( ctx, glDisable (gl_flag) );
|
||||||
ctx->enable_flags &= ~flag;
|
ctx->enable_flags &= ~flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,14 +187,14 @@ toggle_client_flag (CoglContext *ctx,
|
|||||||
{
|
{
|
||||||
if (!(ctx->enable_flags & flag))
|
if (!(ctx->enable_flags & flag))
|
||||||
{
|
{
|
||||||
GE( glEnableClientState (gl_flag) );
|
GE( ctx, glEnableClientState (gl_flag) );
|
||||||
ctx->enable_flags |= flag;
|
ctx->enable_flags |= flag;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (ctx->enable_flags & flag)
|
else if (ctx->enable_flags & flag)
|
||||||
{
|
{
|
||||||
GE( glDisableClientState (gl_flag) );
|
GE( ctx, glDisableClientState (gl_flag) );
|
||||||
ctx->enable_flags &= ~flag;
|
ctx->enable_flags &= ~flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -307,9 +303,9 @@ _cogl_flush_face_winding (void)
|
|||||||
{
|
{
|
||||||
|
|
||||||
if (winding == COGL_FRONT_WINDING_CLOCKWISE)
|
if (winding == COGL_FRONT_WINDING_CLOCKWISE)
|
||||||
GE (glFrontFace (GL_CW));
|
GE (ctx, glFrontFace (GL_CW));
|
||||||
else
|
else
|
||||||
GE (glFrontFace (GL_CCW));
|
GE (ctx, glFrontFace (GL_CCW));
|
||||||
ctx->flushed_front_winding = winding;
|
ctx->flushed_front_winding = winding;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -574,7 +570,7 @@ _cogl_read_pixels_with_rowstride (int x,
|
|||||||
|
|
||||||
_cogl_texture_driver_prep_gl_for_pixels_download (4 * width, 4);
|
_cogl_texture_driver_prep_gl_for_pixels_download (4 * width, 4);
|
||||||
|
|
||||||
GE( glReadPixels (x, y, width, height,
|
GE( ctx, glReadPixels (x, y, width, height,
|
||||||
GL_RGBA, GL_UNSIGNED_BYTE,
|
GL_RGBA, GL_UNSIGNED_BYTE,
|
||||||
tmp_data) );
|
tmp_data) );
|
||||||
|
|
||||||
@ -604,7 +600,7 @@ _cogl_read_pixels_with_rowstride (int x,
|
|||||||
{
|
{
|
||||||
_cogl_texture_driver_prep_gl_for_pixels_download (rowstride, bpp);
|
_cogl_texture_driver_prep_gl_for_pixels_download (rowstride, bpp);
|
||||||
|
|
||||||
GE( glReadPixels (x, y, width, height, gl_format, gl_type, pixels) );
|
GE( ctx, glReadPixels (x, y, width, height, gl_format, gl_type, pixels) );
|
||||||
|
|
||||||
/* Convert to the premult format specified by the caller
|
/* Convert to the premult format specified by the caller
|
||||||
in-place. This will do nothing if the premult status is already
|
in-place. This will do nothing if the premult status is already
|
||||||
|
@ -381,15 +381,15 @@ _cogl_add_path_to_stencil_buffer (CoglPath *path,
|
|||||||
|
|
||||||
_cogl_pipeline_flush_gl_state (ctx->stencil_pipeline, FALSE, 0);
|
_cogl_pipeline_flush_gl_state (ctx->stencil_pipeline, FALSE, 0);
|
||||||
|
|
||||||
GE( glEnable (GL_STENCIL_TEST) );
|
GE( ctx, glEnable (GL_STENCIL_TEST) );
|
||||||
|
|
||||||
GE( glColorMask (FALSE, FALSE, FALSE, FALSE) );
|
GE( ctx, glColorMask (FALSE, FALSE, FALSE, FALSE) );
|
||||||
GE( glDepthMask (FALSE) );
|
GE( ctx, glDepthMask (FALSE) );
|
||||||
|
|
||||||
if (merge)
|
if (merge)
|
||||||
{
|
{
|
||||||
GE (glStencilMask (2));
|
GE (ctx, glStencilMask (2));
|
||||||
GE (glStencilFunc (GL_LEQUAL, 0x2, 0x6));
|
GE (ctx, glStencilFunc (GL_LEQUAL, 0x2, 0x6));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -407,18 +407,18 @@ _cogl_add_path_to_stencil_buffer (CoglPath *path,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Just clear the bounding box */
|
/* Just clear the bounding box */
|
||||||
GE( glStencilMask (~(GLuint) 0) );
|
GE( ctx, glStencilMask (~(GLuint) 0) );
|
||||||
GE( glStencilOp (GL_ZERO, GL_ZERO, GL_ZERO) );
|
GE( ctx, glStencilOp (GL_ZERO, GL_ZERO, GL_ZERO) );
|
||||||
_cogl_rectangle_immediate (data->path_nodes_min.x,
|
_cogl_rectangle_immediate (data->path_nodes_min.x,
|
||||||
data->path_nodes_min.y,
|
data->path_nodes_min.y,
|
||||||
data->path_nodes_max.x,
|
data->path_nodes_max.x,
|
||||||
data->path_nodes_max.y);
|
data->path_nodes_max.y);
|
||||||
}
|
}
|
||||||
GE (glStencilMask (1));
|
GE (ctx, glStencilMask (1));
|
||||||
GE (glStencilFunc (GL_LEQUAL, 0x1, 0x3));
|
GE (ctx, glStencilFunc (GL_LEQUAL, 0x1, 0x3));
|
||||||
}
|
}
|
||||||
|
|
||||||
GE (glStencilOp (GL_INVERT, GL_INVERT, GL_INVERT));
|
GE (ctx, glStencilOp (GL_INVERT, GL_INVERT, GL_INVERT));
|
||||||
|
|
||||||
if (path->data->path_nodes->len >= 3)
|
if (path->data->path_nodes->len >= 3)
|
||||||
_cogl_path_fill_nodes (path);
|
_cogl_path_fill_nodes (path);
|
||||||
@ -427,9 +427,9 @@ _cogl_add_path_to_stencil_buffer (CoglPath *path,
|
|||||||
{
|
{
|
||||||
/* Now we have the new stencil buffer in bit 1 and the old
|
/* Now we have the new stencil buffer in bit 1 and the old
|
||||||
stencil buffer in bit 0 so we need to intersect them */
|
stencil buffer in bit 0 so we need to intersect them */
|
||||||
GE (glStencilMask (3));
|
GE (ctx, glStencilMask (3));
|
||||||
GE (glStencilFunc (GL_NEVER, 0x2, 0x3));
|
GE (ctx, glStencilFunc (GL_NEVER, 0x2, 0x3));
|
||||||
GE (glStencilOp (GL_DECR, GL_DECR, GL_DECR));
|
GE (ctx, glStencilOp (GL_DECR, GL_DECR, GL_DECR));
|
||||||
/* Decrement all of the bits twice so that only pixels where the
|
/* Decrement all of the bits twice so that only pixels where the
|
||||||
value is 3 will remain */
|
value is 3 will remain */
|
||||||
|
|
||||||
@ -450,12 +450,12 @@ _cogl_add_path_to_stencil_buffer (CoglPath *path,
|
|||||||
_cogl_matrix_stack_pop (projection_stack);
|
_cogl_matrix_stack_pop (projection_stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
GE (glStencilMask (~(GLuint) 0));
|
GE (ctx, glStencilMask (~(GLuint) 0));
|
||||||
GE (glDepthMask (TRUE));
|
GE (ctx, glDepthMask (TRUE));
|
||||||
GE (glColorMask (TRUE, TRUE, TRUE, TRUE));
|
GE (ctx, glColorMask (TRUE, TRUE, TRUE, TRUE));
|
||||||
|
|
||||||
GE (glStencilFunc (GL_EQUAL, 0x1, 0x1));
|
GE (ctx, glStencilFunc (GL_EQUAL, 0x1, 0x1));
|
||||||
GE (glStencilOp (GL_KEEP, GL_KEEP, GL_KEEP));
|
GE (ctx, glStencilOp (GL_KEEP, GL_KEEP, GL_KEEP));
|
||||||
|
|
||||||
/* restore the original pipeline */
|
/* restore the original pipeline */
|
||||||
cogl_pop_source ();
|
cogl_pop_source ();
|
||||||
|
@ -40,8 +40,10 @@ _cogl_get_gl_version (int *major_out, int *minor_out)
|
|||||||
const char *version_string, *major_end, *minor_end;
|
const char *version_string, *major_end, *minor_end;
|
||||||
int major = 0, minor = 0;
|
int major = 0, minor = 0;
|
||||||
|
|
||||||
|
_COGL_GET_CONTEXT (ctx, FALSE);
|
||||||
|
|
||||||
/* Get the OpenGL version number */
|
/* Get the OpenGL version number */
|
||||||
if ((version_string = (const char *) glGetString (GL_VERSION)) == NULL)
|
if ((version_string = (const char *) ctx->glGetString (GL_VERSION)) == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/* Extract the major number */
|
/* Extract the major number */
|
||||||
@ -75,6 +77,8 @@ _cogl_gl_check_version (GError **error)
|
|||||||
int major, minor;
|
int major, minor;
|
||||||
const char *gl_extensions;
|
const char *gl_extensions;
|
||||||
|
|
||||||
|
_COGL_GET_CONTEXT (ctx, FALSE);
|
||||||
|
|
||||||
if (!_cogl_get_gl_version (&major, &minor))
|
if (!_cogl_get_gl_version (&major, &minor))
|
||||||
{
|
{
|
||||||
g_set_error (error,
|
g_set_error (error,
|
||||||
@ -88,7 +92,7 @@ _cogl_gl_check_version (GError **error)
|
|||||||
if (COGL_CHECK_GL_VERSION (major, minor, 1, 3))
|
if (COGL_CHECK_GL_VERSION (major, minor, 1, 3))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
gl_extensions = (const char*) glGetString (GL_EXTENSIONS);
|
gl_extensions = (const char*) ctx->glGetString (GL_EXTENSIONS);
|
||||||
|
|
||||||
/* OpenGL 1.2 is only supported if we have the multitexturing
|
/* OpenGL 1.2 is only supported if we have the multitexturing
|
||||||
extension */
|
extension */
|
||||||
@ -131,16 +135,25 @@ _cogl_gl_update_features (CoglContext *context)
|
|||||||
int num_stencil_bits = 0;
|
int num_stencil_bits = 0;
|
||||||
int gl_major = 0, gl_minor = 0;
|
int gl_major = 0, gl_minor = 0;
|
||||||
|
|
||||||
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
|
/* We have to special case getting the pointer to the glGetString
|
||||||
|
function because we need to use it to determine what functions we
|
||||||
|
can expect */
|
||||||
|
context->glGetString =
|
||||||
|
(void *) _cogl_get_proc_address (_cogl_context_get_winsys (context),
|
||||||
|
"glGetString");
|
||||||
|
|
||||||
COGL_NOTE (WINSYS,
|
COGL_NOTE (WINSYS,
|
||||||
"Checking features\n"
|
"Checking features\n"
|
||||||
" GL_VENDOR: %s\n"
|
" GL_VENDOR: %s\n"
|
||||||
" GL_RENDERER: %s\n"
|
" GL_RENDERER: %s\n"
|
||||||
" GL_VERSION: %s\n"
|
" GL_VERSION: %s\n"
|
||||||
" GL_EXTENSIONS: %s",
|
" GL_EXTENSIONS: %s",
|
||||||
glGetString (GL_VENDOR),
|
ctx->glGetString (GL_VENDOR),
|
||||||
glGetString (GL_RENDERER),
|
ctx->glGetString (GL_RENDERER),
|
||||||
glGetString (GL_VERSION),
|
ctx->glGetString (GL_VERSION),
|
||||||
glGetString (GL_EXTENSIONS));
|
ctx->glGetString (GL_EXTENSIONS));
|
||||||
|
|
||||||
_cogl_get_gl_version (&gl_major, &gl_minor);
|
_cogl_get_gl_version (&gl_major, &gl_minor);
|
||||||
|
|
||||||
@ -148,7 +161,7 @@ _cogl_gl_update_features (CoglContext *context)
|
|||||||
| COGL_FEATURE_UNSIGNED_INT_INDICES
|
| COGL_FEATURE_UNSIGNED_INT_INDICES
|
||||||
| COGL_FEATURE_DEPTH_RANGE);
|
| COGL_FEATURE_DEPTH_RANGE);
|
||||||
|
|
||||||
gl_extensions = (const char *)glGetString (GL_EXTENSIONS);
|
gl_extensions = (const char *)ctx->glGetString (GL_EXTENSIONS);
|
||||||
|
|
||||||
_cogl_feature_check_ext_functions (context,
|
_cogl_feature_check_ext_functions (context,
|
||||||
gl_major,
|
gl_major,
|
||||||
@ -172,12 +185,12 @@ _cogl_gl_update_features (CoglContext *context)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
GE( glGetIntegerv (GL_STENCIL_BITS, &num_stencil_bits) );
|
GE( ctx, glGetIntegerv (GL_STENCIL_BITS, &num_stencil_bits) );
|
||||||
/* We need at least three stencil bits to combine clips */
|
/* We need at least three stencil bits to combine clips */
|
||||||
if (num_stencil_bits > 2)
|
if (num_stencil_bits > 2)
|
||||||
flags |= COGL_FEATURE_STENCIL_BUFFER;
|
flags |= COGL_FEATURE_STENCIL_BUFFER;
|
||||||
|
|
||||||
GE( glGetIntegerv (GL_MAX_CLIP_PLANES, &max_clip_planes) );
|
GE( ctx, glGetIntegerv (GL_MAX_CLIP_PLANES, &max_clip_planes) );
|
||||||
if (max_clip_planes >= 4)
|
if (max_clip_planes >= 4)
|
||||||
flags |= COGL_FEATURE_FOUR_CLIP_PLANES;
|
flags |= COGL_FEATURE_FOUR_CLIP_PLANES;
|
||||||
|
|
||||||
|
@ -46,9 +46,6 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#define glGenerateMipmap ctx->glGenerateMipmap
|
|
||||||
#define glTexImage3D ctx->glTexImage3D
|
|
||||||
|
|
||||||
void
|
void
|
||||||
_cogl_texture_driver_gen (GLenum gl_target,
|
_cogl_texture_driver_gen (GLenum gl_target,
|
||||||
GLsizei n,
|
GLsizei n,
|
||||||
@ -56,7 +53,9 @@ _cogl_texture_driver_gen (GLenum gl_target,
|
|||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
GE (glGenTextures (n, textures));
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
|
GE (ctx, glGenTextures (n, textures));
|
||||||
|
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
{
|
{
|
||||||
@ -69,7 +68,7 @@ _cogl_texture_driver_gen (GLenum gl_target,
|
|||||||
case GL_TEXTURE_2D:
|
case GL_TEXTURE_2D:
|
||||||
case GL_TEXTURE_3D:
|
case GL_TEXTURE_3D:
|
||||||
/* GL_TEXTURE_MAG_FILTER defaults to GL_LINEAR, no need to set it */
|
/* GL_TEXTURE_MAG_FILTER defaults to GL_LINEAR, no need to set it */
|
||||||
GE( glTexParameteri (gl_target,
|
GE( ctx, glTexParameteri (gl_target,
|
||||||
GL_TEXTURE_MIN_FILTER,
|
GL_TEXTURE_MIN_FILTER,
|
||||||
GL_LINEAR) );
|
GL_LINEAR) );
|
||||||
break;
|
break;
|
||||||
@ -94,13 +93,16 @@ prep_gl_for_pixels_upload_full (int pixels_rowstride,
|
|||||||
int pixels_src_y,
|
int pixels_src_y,
|
||||||
int pixels_bpp)
|
int pixels_bpp)
|
||||||
{
|
{
|
||||||
GE( glPixelStorei (GL_UNPACK_ROW_LENGTH, pixels_rowstride / pixels_bpp) );
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
GE( glPixelStorei (GL_UNPACK_SKIP_PIXELS, pixels_src_x) );
|
GE( ctx, glPixelStorei (GL_UNPACK_ROW_LENGTH,
|
||||||
GE( glPixelStorei (GL_UNPACK_SKIP_ROWS, pixels_src_y) );
|
pixels_rowstride / pixels_bpp) );
|
||||||
|
|
||||||
|
GE( ctx, glPixelStorei (GL_UNPACK_SKIP_PIXELS, pixels_src_x) );
|
||||||
|
GE( ctx, glPixelStorei (GL_UNPACK_SKIP_ROWS, pixels_src_y) );
|
||||||
|
|
||||||
if (cogl_features_available (COGL_FEATURE_TEXTURE_3D))
|
if (cogl_features_available (COGL_FEATURE_TEXTURE_3D))
|
||||||
GE( glPixelStorei (GL_UNPACK_IMAGE_HEIGHT, image_height) );
|
GE( ctx, glPixelStorei (GL_UNPACK_IMAGE_HEIGHT, image_height) );
|
||||||
|
|
||||||
_cogl_texture_prep_gl_alignment_for_pixels_upload (pixels_rowstride);
|
_cogl_texture_prep_gl_alignment_for_pixels_upload (pixels_rowstride);
|
||||||
}
|
}
|
||||||
@ -121,13 +123,15 @@ prep_gl_for_pixels_download_full (int pixels_rowstride,
|
|||||||
int pixels_src_y,
|
int pixels_src_y,
|
||||||
int pixels_bpp)
|
int pixels_bpp)
|
||||||
{
|
{
|
||||||
GE( glPixelStorei (GL_PACK_ROW_LENGTH, pixels_rowstride / pixels_bpp) );
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
GE( glPixelStorei (GL_PACK_SKIP_PIXELS, pixels_src_x) );
|
GE( ctx, glPixelStorei (GL_PACK_ROW_LENGTH, pixels_rowstride / pixels_bpp) );
|
||||||
GE( glPixelStorei (GL_PACK_SKIP_ROWS, pixels_src_y) );
|
|
||||||
|
GE( ctx, glPixelStorei (GL_PACK_SKIP_PIXELS, pixels_src_x) );
|
||||||
|
GE( ctx, glPixelStorei (GL_PACK_SKIP_ROWS, pixels_src_y) );
|
||||||
|
|
||||||
if (cogl_features_available (COGL_FEATURE_TEXTURE_3D))
|
if (cogl_features_available (COGL_FEATURE_TEXTURE_3D))
|
||||||
GE( glPixelStorei (GL_PACK_IMAGE_HEIGHT, image_height) );
|
GE( ctx, glPixelStorei (GL_PACK_IMAGE_HEIGHT, image_height) );
|
||||||
|
|
||||||
_cogl_texture_prep_gl_alignment_for_pixels_download (pixels_rowstride);
|
_cogl_texture_prep_gl_alignment_for_pixels_download (pixels_rowstride);
|
||||||
}
|
}
|
||||||
@ -156,6 +160,8 @@ _cogl_texture_driver_upload_subregion_to_gl (GLenum gl_target,
|
|||||||
guint8 *data;
|
guint8 *data;
|
||||||
int bpp = _cogl_get_format_bpp (_cogl_bitmap_get_format (source_bmp));
|
int bpp = _cogl_get_format_bpp (_cogl_bitmap_get_format (source_bmp));
|
||||||
|
|
||||||
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
data = _cogl_bitmap_bind (source_bmp, COGL_BUFFER_ACCESS_READ, 0);
|
data = _cogl_bitmap_bind (source_bmp, COGL_BUFFER_ACCESS_READ, 0);
|
||||||
|
|
||||||
/* Setup gl alignment to match rowstride and top-left corner */
|
/* Setup gl alignment to match rowstride and top-left corner */
|
||||||
@ -167,7 +173,7 @@ _cogl_texture_driver_upload_subregion_to_gl (GLenum gl_target,
|
|||||||
|
|
||||||
_cogl_bind_gl_texture_transient (gl_target, gl_handle, is_foreign);
|
_cogl_bind_gl_texture_transient (gl_target, gl_handle, is_foreign);
|
||||||
|
|
||||||
GE( glTexSubImage2D (gl_target, 0,
|
GE( ctx, glTexSubImage2D (gl_target, 0,
|
||||||
dst_x, dst_y,
|
dst_x, dst_y,
|
||||||
width, height,
|
width, height,
|
||||||
source_gl_format,
|
source_gl_format,
|
||||||
@ -189,6 +195,8 @@ _cogl_texture_driver_upload_to_gl (GLenum gl_target,
|
|||||||
guint8 *data;
|
guint8 *data;
|
||||||
int bpp = _cogl_get_format_bpp (_cogl_bitmap_get_format (source_bmp));
|
int bpp = _cogl_get_format_bpp (_cogl_bitmap_get_format (source_bmp));
|
||||||
|
|
||||||
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
data = _cogl_bitmap_bind (source_bmp, COGL_BUFFER_ACCESS_READ, 0);
|
data = _cogl_bitmap_bind (source_bmp, COGL_BUFFER_ACCESS_READ, 0);
|
||||||
|
|
||||||
/* Setup gl alignment to match rowstride and top-left corner */
|
/* Setup gl alignment to match rowstride and top-left corner */
|
||||||
@ -197,7 +205,7 @@ _cogl_texture_driver_upload_to_gl (GLenum gl_target,
|
|||||||
|
|
||||||
_cogl_bind_gl_texture_transient (gl_target, gl_handle, is_foreign);
|
_cogl_bind_gl_texture_transient (gl_target, gl_handle, is_foreign);
|
||||||
|
|
||||||
GE( glTexImage2D (gl_target, 0,
|
GE( ctx, glTexImage2D (gl_target, 0,
|
||||||
internal_gl_format,
|
internal_gl_format,
|
||||||
_cogl_bitmap_get_width (source_bmp),
|
_cogl_bitmap_get_width (source_bmp),
|
||||||
_cogl_bitmap_get_height (source_bmp),
|
_cogl_bitmap_get_height (source_bmp),
|
||||||
@ -235,7 +243,7 @@ _cogl_texture_driver_upload_to_gl_3d (GLenum gl_target,
|
|||||||
|
|
||||||
_cogl_bind_gl_texture_transient (gl_target, gl_handle, is_foreign);
|
_cogl_bind_gl_texture_transient (gl_target, gl_handle, is_foreign);
|
||||||
|
|
||||||
GE( glTexImage3D (gl_target,
|
GE( ctx, glTexImage3D (gl_target,
|
||||||
0, /* level */
|
0, /* level */
|
||||||
internal_gl_format,
|
internal_gl_format,
|
||||||
_cogl_bitmap_get_width (source_bmp),
|
_cogl_bitmap_get_width (source_bmp),
|
||||||
@ -255,7 +263,9 @@ _cogl_texture_driver_gl_get_tex_image (GLenum gl_target,
|
|||||||
GLenum dest_gl_type,
|
GLenum dest_gl_type,
|
||||||
guint8 *dest)
|
guint8 *dest)
|
||||||
{
|
{
|
||||||
GE (glGetTexImage (gl_target,
|
_COGL_GET_CONTEXT (ctx, FALSE);
|
||||||
|
|
||||||
|
GE (ctx, glGetTexImage (gl_target,
|
||||||
0, /* level */
|
0, /* level */
|
||||||
dest_gl_format,
|
dest_gl_format,
|
||||||
dest_gl_type,
|
dest_gl_type,
|
||||||
@ -283,11 +293,11 @@ _cogl_texture_driver_size_supported_3d (GLenum gl_target,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/* Proxy texture allows for a quick check for supported size */
|
/* Proxy texture allows for a quick check for supported size */
|
||||||
GE( glTexImage3D (proxy_target, 0, GL_RGBA,
|
GE( ctx, glTexImage3D (proxy_target, 0, GL_RGBA,
|
||||||
width, height, depth, 0 /* border */,
|
width, height, depth, 0 /* border */,
|
||||||
gl_format, gl_type, NULL) );
|
gl_format, gl_type, NULL) );
|
||||||
|
|
||||||
GE( glGetTexLevelParameteriv (proxy_target, 0,
|
GE( ctx, glGetTexLevelParameteriv (proxy_target, 0,
|
||||||
GL_TEXTURE_WIDTH, &new_width) );
|
GL_TEXTURE_WIDTH, &new_width) );
|
||||||
|
|
||||||
return new_width != 0;
|
return new_width != 0;
|
||||||
@ -303,6 +313,8 @@ _cogl_texture_driver_size_supported (GLenum gl_target,
|
|||||||
GLenum proxy_target;
|
GLenum proxy_target;
|
||||||
GLint new_width = 0;
|
GLint new_width = 0;
|
||||||
|
|
||||||
|
_COGL_GET_CONTEXT (ctx, FALSE);
|
||||||
|
|
||||||
if (gl_target == GL_TEXTURE_2D)
|
if (gl_target == GL_TEXTURE_2D)
|
||||||
proxy_target = GL_PROXY_TEXTURE_2D;
|
proxy_target = GL_PROXY_TEXTURE_2D;
|
||||||
#if HAVE_COGL_GL
|
#if HAVE_COGL_GL
|
||||||
@ -314,11 +326,11 @@ _cogl_texture_driver_size_supported (GLenum gl_target,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/* Proxy texture allows for a quick check for supported size */
|
/* Proxy texture allows for a quick check for supported size */
|
||||||
GE( glTexImage2D (proxy_target, 0, GL_RGBA,
|
GE( ctx, glTexImage2D (proxy_target, 0, GL_RGBA,
|
||||||
width, height, 0 /* border */,
|
width, height, 0 /* border */,
|
||||||
gl_format, gl_type, NULL) );
|
gl_format, gl_type, NULL) );
|
||||||
|
|
||||||
GE( glGetTexLevelParameteriv (proxy_target, 0,
|
GE( ctx, glGetTexLevelParameteriv (proxy_target, 0,
|
||||||
GL_TEXTURE_WIDTH, &new_width) );
|
GL_TEXTURE_WIDTH, &new_width) );
|
||||||
|
|
||||||
return new_width != 0;
|
return new_width != 0;
|
||||||
@ -329,10 +341,12 @@ _cogl_texture_driver_try_setting_gl_border_color (
|
|||||||
GLuint gl_target,
|
GLuint gl_target,
|
||||||
const GLfloat *transparent_color)
|
const GLfloat *transparent_color)
|
||||||
{
|
{
|
||||||
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
/* Use a transparent border color so that we can leave the
|
/* Use a transparent border color so that we can leave the
|
||||||
color buffer alone when using texture co-ordinates
|
color buffer alone when using texture co-ordinates
|
||||||
outside of the texture */
|
outside of the texture */
|
||||||
GE( glTexParameterfv (gl_target, GL_TEXTURE_BORDER_COLOR,
|
GE( ctx, glTexParameterfv (gl_target, GL_TEXTURE_BORDER_COLOR,
|
||||||
transparent_color) );
|
transparent_color) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -504,7 +518,7 @@ _cogl_texture_driver_gl_generate_mipmaps (GLenum gl_target)
|
|||||||
{
|
{
|
||||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
GE( glGenerateMipmap (gl_target) );
|
GE( ctx, glGenerateMipmap (gl_target) );
|
||||||
}
|
}
|
||||||
|
|
||||||
CoglPixelFormat
|
CoglPixelFormat
|
||||||
|
@ -54,18 +54,25 @@ _cogl_gl_update_features (CoglContext *context)
|
|||||||
#endif
|
#endif
|
||||||
int num_stencil_bits = 0;
|
int num_stencil_bits = 0;
|
||||||
|
|
||||||
|
/* We have to special case getting the pointer to the glGetString
|
||||||
|
function because we need to use it to determine what functions we
|
||||||
|
can expect */
|
||||||
|
context->glGetString =
|
||||||
|
(void *) _cogl_get_proc_address (_cogl_context_get_winsys (context),
|
||||||
|
"glGetString");
|
||||||
|
|
||||||
COGL_NOTE (WINSYS,
|
COGL_NOTE (WINSYS,
|
||||||
"Checking features\n"
|
"Checking features\n"
|
||||||
" GL_VENDOR: %s\n"
|
" GL_VENDOR: %s\n"
|
||||||
" GL_RENDERER: %s\n"
|
" GL_RENDERER: %s\n"
|
||||||
" GL_VERSION: %s\n"
|
" GL_VERSION: %s\n"
|
||||||
" GL_EXTENSIONS: %s",
|
" GL_EXTENSIONS: %s",
|
||||||
glGetString (GL_VENDOR),
|
context->glGetString (GL_VENDOR),
|
||||||
glGetString (GL_RENDERER),
|
context->glGetString (GL_RENDERER),
|
||||||
glGetString (GL_VERSION),
|
context->glGetString (GL_VERSION),
|
||||||
glGetString (GL_EXTENSIONS));
|
context->glGetString (GL_EXTENSIONS));
|
||||||
|
|
||||||
gl_extensions = (const char*) glGetString (GL_EXTENSIONS);
|
gl_extensions = (const char*) context->glGetString (GL_EXTENSIONS);
|
||||||
|
|
||||||
_cogl_feature_check_ext_functions (context,
|
_cogl_feature_check_ext_functions (context,
|
||||||
-1 /* GL major version */,
|
-1 /* GL major version */,
|
||||||
@ -78,13 +85,13 @@ _cogl_gl_update_features (CoglContext *context)
|
|||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
|
|
||||||
GE( glGetIntegerv (GL_STENCIL_BITS, &num_stencil_bits) );
|
GE( context, glGetIntegerv (GL_STENCIL_BITS, &num_stencil_bits) );
|
||||||
/* We need at least three stencil bits to combine clips */
|
/* We need at least three stencil bits to combine clips */
|
||||||
if (num_stencil_bits > 2)
|
if (num_stencil_bits > 2)
|
||||||
flags |= COGL_FEATURE_STENCIL_BUFFER;
|
flags |= COGL_FEATURE_STENCIL_BUFFER;
|
||||||
|
|
||||||
#ifndef HAVE_COGL_GLES2
|
#ifndef HAVE_COGL_GLES2
|
||||||
GE( glGetIntegerv (GL_MAX_CLIP_PLANES, &max_clip_planes) );
|
GE( context, glGetIntegerv (GL_MAX_CLIP_PLANES, &max_clip_planes) );
|
||||||
if (max_clip_planes >= 4)
|
if (max_clip_planes >= 4)
|
||||||
flags |= COGL_FEATURE_FOUR_CLIP_PLANES;
|
flags |= COGL_FEATURE_FOUR_CLIP_PLANES;
|
||||||
#endif
|
#endif
|
||||||
|
@ -46,9 +46,6 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#define glTexImage3D ctx->glTexImage3D
|
|
||||||
#define glTexSubImage3D ctx->glTexSubImage3D
|
|
||||||
|
|
||||||
#ifndef GL_TEXTURE_3D
|
#ifndef GL_TEXTURE_3D
|
||||||
#define GL_TEXTURE_3D 0x806F
|
#define GL_TEXTURE_3D 0x806F
|
||||||
#endif
|
#endif
|
||||||
@ -63,7 +60,9 @@ _cogl_texture_driver_gen (GLenum gl_target,
|
|||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
GE (glGenTextures (n, textures));
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
|
GE (ctx, glGenTextures (n, textures));
|
||||||
|
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
{
|
{
|
||||||
@ -74,7 +73,9 @@ _cogl_texture_driver_gen (GLenum gl_target,
|
|||||||
case GL_TEXTURE_2D:
|
case GL_TEXTURE_2D:
|
||||||
case GL_TEXTURE_3D:
|
case GL_TEXTURE_3D:
|
||||||
/* GL_TEXTURE_MAG_FILTER defaults to GL_LINEAR, no need to set it */
|
/* GL_TEXTURE_MAG_FILTER defaults to GL_LINEAR, no need to set it */
|
||||||
GE( glTexParameteri (gl_target, GL_TEXTURE_MIN_FILTER, GL_LINEAR) );
|
GE( ctx, glTexParameteri (gl_target,
|
||||||
|
GL_TEXTURE_MIN_FILTER,
|
||||||
|
GL_LINEAR) );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -143,6 +144,8 @@ _cogl_texture_driver_upload_subregion_to_gl (GLenum gl_target,
|
|||||||
CoglBitmap *slice_bmp;
|
CoglBitmap *slice_bmp;
|
||||||
int rowstride;
|
int rowstride;
|
||||||
|
|
||||||
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
/* If we are copying a sub region of the source bitmap then we need
|
/* If we are copying a sub region of the source bitmap then we need
|
||||||
to copy it because GLES does not support GL_UNPACK_ROW_LENGTH */
|
to copy it because GLES does not support GL_UNPACK_ROW_LENGTH */
|
||||||
if (src_x != 0 || src_y != 0 ||
|
if (src_x != 0 || src_y != 0 ||
|
||||||
@ -177,7 +180,7 @@ _cogl_texture_driver_upload_subregion_to_gl (GLenum gl_target,
|
|||||||
|
|
||||||
_cogl_bind_gl_texture_transient (gl_target, gl_handle, is_foreign);
|
_cogl_bind_gl_texture_transient (gl_target, gl_handle, is_foreign);
|
||||||
|
|
||||||
GE( glTexSubImage2D (gl_target, 0,
|
GE( ctx, glTexSubImage2D (gl_target, 0,
|
||||||
dst_x, dst_y,
|
dst_x, dst_y,
|
||||||
width, height,
|
width, height,
|
||||||
source_gl_format,
|
source_gl_format,
|
||||||
@ -205,6 +208,8 @@ _cogl_texture_driver_upload_to_gl (GLenum gl_target,
|
|||||||
CoglBitmap *bmp;
|
CoglBitmap *bmp;
|
||||||
guint8 *data;
|
guint8 *data;
|
||||||
|
|
||||||
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
bmp = prepare_bitmap_alignment_for_upload (source_bmp);
|
bmp = prepare_bitmap_alignment_for_upload (source_bmp);
|
||||||
rowstride = _cogl_bitmap_get_rowstride (bmp);
|
rowstride = _cogl_bitmap_get_rowstride (bmp);
|
||||||
|
|
||||||
@ -215,7 +220,7 @@ _cogl_texture_driver_upload_to_gl (GLenum gl_target,
|
|||||||
|
|
||||||
data = _cogl_bitmap_bind (bmp, COGL_BUFFER_ACCESS_READ, 0);
|
data = _cogl_bitmap_bind (bmp, COGL_BUFFER_ACCESS_READ, 0);
|
||||||
|
|
||||||
GE( glTexImage2D (gl_target, 0,
|
GE( ctx, glTexImage2D (gl_target, 0,
|
||||||
internal_gl_format,
|
internal_gl_format,
|
||||||
bmp_width, bmp_height,
|
bmp_width, bmp_height,
|
||||||
0,
|
0,
|
||||||
@ -264,7 +269,7 @@ _cogl_texture_driver_upload_to_gl_3d (GLenum gl_target,
|
|||||||
/* Initialize the texture with empty data and then upload each
|
/* Initialize the texture with empty data and then upload each
|
||||||
image with a sub-region update */
|
image with a sub-region update */
|
||||||
|
|
||||||
GE( glTexImage3D (gl_target,
|
GE( ctx, glTexImage3D (gl_target,
|
||||||
0, /* level */
|
0, /* level */
|
||||||
internal_gl_format,
|
internal_gl_format,
|
||||||
bmp_width,
|
bmp_width,
|
||||||
@ -295,7 +300,7 @@ _cogl_texture_driver_upload_to_gl_3d (GLenum gl_target,
|
|||||||
data = _cogl_bitmap_bind (bmp,
|
data = _cogl_bitmap_bind (bmp,
|
||||||
COGL_BUFFER_ACCESS_READ, 0);
|
COGL_BUFFER_ACCESS_READ, 0);
|
||||||
|
|
||||||
GE( glTexSubImage3D (gl_target,
|
GE( ctx, glTexSubImage3D (gl_target,
|
||||||
0, /* level */
|
0, /* level */
|
||||||
0, /* xoffset */
|
0, /* xoffset */
|
||||||
0, /* yoffset */
|
0, /* yoffset */
|
||||||
@ -318,7 +323,7 @@ _cogl_texture_driver_upload_to_gl_3d (GLenum gl_target,
|
|||||||
|
|
||||||
_cogl_texture_driver_prep_gl_for_pixels_upload (rowstride, bpp);
|
_cogl_texture_driver_prep_gl_for_pixels_upload (rowstride, bpp);
|
||||||
|
|
||||||
GE( glTexImage3D (gl_target,
|
GE( ctx, glTexImage3D (gl_target,
|
||||||
0, /* level */
|
0, /* level */
|
||||||
internal_gl_format,
|
internal_gl_format,
|
||||||
bmp_width,
|
bmp_width,
|
||||||
@ -355,10 +360,12 @@ _cogl_texture_driver_size_supported_3d (GLenum gl_target,
|
|||||||
{
|
{
|
||||||
GLint max_size;
|
GLint max_size;
|
||||||
|
|
||||||
|
_COGL_GET_CONTEXT (ctx, FALSE);
|
||||||
|
|
||||||
/* GLES doesn't support a proxy texture target so let's at least
|
/* GLES doesn't support a proxy texture target so let's at least
|
||||||
check whether the size is greater than
|
check whether the size is greater than
|
||||||
GL_MAX_3D_TEXTURE_SIZE_OES */
|
GL_MAX_3D_TEXTURE_SIZE_OES */
|
||||||
GE( glGetIntegerv (GL_MAX_3D_TEXTURE_SIZE_OES, &max_size) );
|
GE( ctx, glGetIntegerv (GL_MAX_3D_TEXTURE_SIZE_OES, &max_size) );
|
||||||
|
|
||||||
return width <= max_size && height <= max_size && depth <= max_size;
|
return width <= max_size && height <= max_size && depth <= max_size;
|
||||||
}
|
}
|
||||||
@ -372,9 +379,11 @@ _cogl_texture_driver_size_supported (GLenum gl_target,
|
|||||||
{
|
{
|
||||||
GLint max_size;
|
GLint max_size;
|
||||||
|
|
||||||
|
_COGL_GET_CONTEXT (ctx, FALSE);
|
||||||
|
|
||||||
/* GLES doesn't support a proxy texture target so let's at least
|
/* GLES doesn't support a proxy texture target so let's at least
|
||||||
check whether the size is greater than GL_MAX_TEXTURE_SIZE */
|
check whether the size is greater than GL_MAX_TEXTURE_SIZE */
|
||||||
GE( glGetIntegerv (GL_MAX_TEXTURE_SIZE, &max_size) );
|
GE( ctx, glGetIntegerv (GL_MAX_TEXTURE_SIZE, &max_size) );
|
||||||
|
|
||||||
return width <= max_size && height <= max_size;
|
return width <= max_size && height <= max_size;
|
||||||
}
|
}
|
||||||
@ -491,7 +500,9 @@ void
|
|||||||
_cogl_texture_driver_gl_generate_mipmaps (GLenum gl_target)
|
_cogl_texture_driver_gl_generate_mipmaps (GLenum gl_target)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_COGL_GLES2
|
#ifdef HAVE_COGL_GLES2
|
||||||
GE( glGenerateMipmap (gl_target) );
|
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||||
|
|
||||||
|
GE( ctx, glGenerateMipmap (gl_target) );
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1116,7 +1116,7 @@ _cogl_winsys_onscreen_swap_region (CoglOnscreen *onscreen,
|
|||||||
* additional extension so we can report the limited region of
|
* additional extension so we can report the limited region of
|
||||||
* the window damage to X/compositors.
|
* the window damage to X/compositors.
|
||||||
*/
|
*/
|
||||||
glFinish ();
|
context->glFinish ();
|
||||||
|
|
||||||
if (have_counter && can_wait)
|
if (have_counter && can_wait)
|
||||||
{
|
{
|
||||||
@ -1148,7 +1148,7 @@ _cogl_winsys_onscreen_swap_region (CoglOnscreen *onscreen,
|
|||||||
int i;
|
int i;
|
||||||
/* XXX: checkout how this state interacts with the code to use
|
/* XXX: checkout how this state interacts with the code to use
|
||||||
* glBlitFramebuffer in Neil's texture atlasing branch */
|
* glBlitFramebuffer in Neil's texture atlasing branch */
|
||||||
glDrawBuffer (GL_FRONT);
|
context->glDrawBuffer (GL_FRONT);
|
||||||
for (i = 0; i < n_rectangles; i++)
|
for (i = 0; i < n_rectangles; i++)
|
||||||
{
|
{
|
||||||
int *rect = &rectangles[4 * i];
|
int *rect = &rectangles[4 * i];
|
||||||
@ -1158,7 +1158,7 @@ _cogl_winsys_onscreen_swap_region (CoglOnscreen *onscreen,
|
|||||||
rect[0], rect[1], x2, y2,
|
rect[0], rect[1], x2, y2,
|
||||||
GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
||||||
}
|
}
|
||||||
glDrawBuffer (GL_BACK);
|
context->glDrawBuffer (GL_BACK);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* NB: unlike glXSwapBuffers, glXCopySubBuffer and
|
/* NB: unlike glXSwapBuffers, glXCopySubBuffer and
|
||||||
@ -1166,7 +1166,7 @@ _cogl_winsys_onscreen_swap_region (CoglOnscreen *onscreen,
|
|||||||
* have to flush ourselves if we want the request to complete in
|
* have to flush ourselves if we want the request to complete in
|
||||||
* a finite amount of time since otherwise the driver can batch
|
* a finite amount of time since otherwise the driver can batch
|
||||||
* the command indefinitely. */
|
* the command indefinitely. */
|
||||||
glFlush ();
|
context->glFlush ();
|
||||||
|
|
||||||
/* NB: It's important we save the counter we read before acting on
|
/* NB: It's important we save the counter we read before acting on
|
||||||
* the swap request since if we are mixing and matching different
|
* the swap request since if we are mixing and matching different
|
||||||
@ -1237,7 +1237,7 @@ _cogl_winsys_onscreen_swap_buffers (CoglOnscreen *onscreen)
|
|||||||
* obviously does not happen when we use _GLX_SWAP and let
|
* obviously does not happen when we use _GLX_SWAP and let
|
||||||
* the driver do the right thing
|
* the driver do the right thing
|
||||||
*/
|
*/
|
||||||
glFinish ();
|
context->glFinish ();
|
||||||
|
|
||||||
if (have_counter && can_wait)
|
if (have_counter && can_wait)
|
||||||
{
|
{
|
||||||
@ -1844,7 +1844,7 @@ _cogl_winsys_texture_pixmap_x11_update (CoglTexturePixmapX11 *tex_pixmap,
|
|||||||
|
|
||||||
COGL_NOTE (TEXTURE_PIXMAP, "Rebinding GLXPixmap for %p", tex_pixmap);
|
COGL_NOTE (TEXTURE_PIXMAP, "Rebinding GLXPixmap for %p", tex_pixmap);
|
||||||
|
|
||||||
GE( _cogl_bind_gl_texture_transient (gl_target, gl_handle, FALSE) );
|
_cogl_bind_gl_texture_transient (gl_target, gl_handle, FALSE);
|
||||||
|
|
||||||
if (glx_tex_pixmap->pixmap_bound)
|
if (glx_tex_pixmap->pixmap_bound)
|
||||||
glx_renderer->pf_glXReleaseTexImage (xlib_renderer->xdpy,
|
glx_renderer->pf_glXReleaseTexImage (xlib_renderer->xdpy,
|
||||||
|
@ -534,7 +534,7 @@ get_wgl_extensions_string (HDC dc)
|
|||||||
extensions isn't supported then we can at least fake it to
|
extensions isn't supported then we can at least fake it to
|
||||||
support the swap control extension */
|
support the swap control extension */
|
||||||
if (_cogl_check_extension ("WGL_EXT_swap_control",
|
if (_cogl_check_extension ("WGL_EXT_swap_control",
|
||||||
(char *) glGetString (GL_EXTENSIONS)))
|
(char *) ctx->glGetString (GL_EXTENSIONS)))
|
||||||
return "WGL_EXT_swap_control";
|
return "WGL_EXT_swap_control";
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user