cogl: Remove unused cogl-gles2 API

This was introduced in:

    commit 010d16f647
    Author: Robert Bragg <robert@linux.intel.com>
    Date:   Tue Mar 6 03:21:30 2012 +0000

        Adds initial GLES2 integration support

        This makes it possible to integrate existing GLES2 code with
        applications using Cogl as the rendering api.

That's maybe a reasonable thing for a standalone cogl to want, but our
cogl has only one consumer. So if we want additional rendering out of
our cogl layer, it makes more sense to just add that to cogl rather than
support clutter or mutter or the javascript bindings creating their own
GLES contexts.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/500
This commit is contained in:
Adam Jackson 2019-03-19 17:50:39 -04:00 committed by Jonas Ådahl
parent f3660dc60e
commit 7e8a864992
27 changed files with 2 additions and 7070 deletions

View File

@ -1,169 +0,0 @@
#ifndef __gl2_h_
#define __gl2_h_
/* $Revision: 16803 $ on $Date:: 2012-02-02 09:49:18 -0800 #$ */
#include <GLES2/gl2platform.h>
#include <cogl/cogl-gles2-types.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* This document is licensed under the SGI Free Software B License Version
* 2.0. For details, see http://oss.sgi.com/projects/FreeB/ .
*/
/*-------------------------------------------------------------------------
* GL core functions.
*-----------------------------------------------------------------------*/
GL_APICALL void GL_APIENTRY glActiveTexture (GLenum texture);
GL_APICALL void GL_APIENTRY glAttachShader (GLuint program, GLuint shader);
GL_APICALL void GL_APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar* name);
GL_APICALL void GL_APIENTRY glBindBuffer (GLenum target, GLuint buffer);
GL_APICALL void GL_APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer);
GL_APICALL void GL_APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer);
GL_APICALL void GL_APIENTRY glBindTexture (GLenum target, GLuint texture);
GL_APICALL void GL_APIENTRY glBlendColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
GL_APICALL void GL_APIENTRY glBlendEquation ( GLenum mode );
GL_APICALL void GL_APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha);
GL_APICALL void GL_APIENTRY glBlendFunc (GLenum sfactor, GLenum dfactor);
GL_APICALL void GL_APIENTRY glBlendFuncSeparate (GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
GL_APICALL void GL_APIENTRY glBufferData (GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage);
GL_APICALL void GL_APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data);
GL_APICALL GLenum GL_APIENTRY glCheckFramebufferStatus (GLenum target);
GL_APICALL void GL_APIENTRY glClear (GLbitfield mask);
GL_APICALL void GL_APIENTRY glClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
GL_APICALL void GL_APIENTRY glClearDepthf (GLclampf depth);
GL_APICALL void GL_APIENTRY glClearStencil (GLint s);
GL_APICALL void GL_APIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
GL_APICALL void GL_APIENTRY glCompileShader (GLuint shader);
GL_APICALL void GL_APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid* data);
GL_APICALL void GL_APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid* data);
GL_APICALL void GL_APIENTRY glCopyTexImage2D (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
GL_APICALL void GL_APIENTRY glCopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
GL_APICALL GLuint GL_APIENTRY glCreateProgram (void);
GL_APICALL GLuint GL_APIENTRY glCreateShader (GLenum type);
GL_APICALL void GL_APIENTRY glCullFace (GLenum mode);
GL_APICALL void GL_APIENTRY glDeleteBuffers (GLsizei n, const GLuint* buffers);
GL_APICALL void GL_APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint* framebuffers);
GL_APICALL void GL_APIENTRY glDeleteProgram (GLuint program);
GL_APICALL void GL_APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint* renderbuffers);
GL_APICALL void GL_APIENTRY glDeleteShader (GLuint shader);
GL_APICALL void GL_APIENTRY glDeleteTextures (GLsizei n, const GLuint* textures);
GL_APICALL void GL_APIENTRY glDepthFunc (GLenum func);
GL_APICALL void GL_APIENTRY glDepthMask (GLboolean flag);
GL_APICALL void GL_APIENTRY glDepthRangef (GLclampf zNear, GLclampf zFar);
GL_APICALL void GL_APIENTRY glDetachShader (GLuint program, GLuint shader);
GL_APICALL void GL_APIENTRY glDisable (GLenum cap);
GL_APICALL void GL_APIENTRY glDisableVertexAttribArray (GLuint index);
GL_APICALL void GL_APIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count);
GL_APICALL void GL_APIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const GLvoid* indices);
GL_APICALL void GL_APIENTRY glEnable (GLenum cap);
GL_APICALL void GL_APIENTRY glEnableVertexAttribArray (GLuint index);
GL_APICALL void GL_APIENTRY glFinish (void);
GL_APICALL void GL_APIENTRY glFlush (void);
GL_APICALL void GL_APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
GL_APICALL void GL_APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
GL_APICALL void GL_APIENTRY glFrontFace (GLenum mode);
GL_APICALL void GL_APIENTRY glGenBuffers (GLsizei n, GLuint* buffers);
GL_APICALL void GL_APIENTRY glGenerateMipmap (GLenum target);
GL_APICALL void GL_APIENTRY glGenFramebuffers (GLsizei n, GLuint* framebuffers);
GL_APICALL void GL_APIENTRY glGenRenderbuffers (GLsizei n, GLuint* renderbuffers);
GL_APICALL void GL_APIENTRY glGenTextures (GLsizei n, GLuint* textures);
GL_APICALL void GL_APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name);
GL_APICALL void GL_APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name);
GL_APICALL void GL_APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders);
GL_APICALL int GL_APIENTRY glGetAttribLocation (GLuint program, const GLchar* name);
GL_APICALL void GL_APIENTRY glGetBooleanv (GLenum pname, GLboolean* params);
GL_APICALL void GL_APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint* params);
GL_APICALL GLenum GL_APIENTRY glGetError (void);
GL_APICALL void GL_APIENTRY glGetFloatv (GLenum pname, GLfloat* params);
GL_APICALL void GL_APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint* params);
GL_APICALL void GL_APIENTRY glGetIntegerv (GLenum pname, GLint* params);
GL_APICALL void GL_APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint* params);
GL_APICALL void GL_APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog);
GL_APICALL void GL_APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint* params);
GL_APICALL void GL_APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint* params);
GL_APICALL void GL_APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog);
GL_APICALL void GL_APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision);
GL_APICALL void GL_APIENTRY glGetShaderSource (GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source);
GL_APICALL const GLubyte* GL_APIENTRY glGetString (GLenum name);
GL_APICALL void GL_APIENTRY glGetTexParameterfv (GLenum target, GLenum pname, GLfloat* params);
GL_APICALL void GL_APIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint* params);
GL_APICALL void GL_APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat* params);
GL_APICALL void GL_APIENTRY glGetUniformiv (GLuint program, GLint location, GLint* params);
GL_APICALL int GL_APIENTRY glGetUniformLocation (GLuint program, const GLchar* name);
GL_APICALL void GL_APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat* params);
GL_APICALL void GL_APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint* params);
GL_APICALL void GL_APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, GLvoid** pointer);
GL_APICALL void GL_APIENTRY glHint (GLenum target, GLenum mode);
GL_APICALL GLboolean GL_APIENTRY glIsBuffer (GLuint buffer);
GL_APICALL GLboolean GL_APIENTRY glIsEnabled (GLenum cap);
GL_APICALL GLboolean GL_APIENTRY glIsFramebuffer (GLuint framebuffer);
GL_APICALL GLboolean GL_APIENTRY glIsProgram (GLuint program);
GL_APICALL GLboolean GL_APIENTRY glIsRenderbuffer (GLuint renderbuffer);
GL_APICALL GLboolean GL_APIENTRY glIsShader (GLuint shader);
GL_APICALL GLboolean GL_APIENTRY glIsTexture (GLuint texture);
GL_APICALL void GL_APIENTRY glLineWidth (GLfloat width);
GL_APICALL void GL_APIENTRY glLinkProgram (GLuint program);
GL_APICALL void GL_APIENTRY glPixelStorei (GLenum pname, GLint param);
GL_APICALL void GL_APIENTRY glPolygonOffset (GLfloat factor, GLfloat units);
GL_APICALL void GL_APIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels);
GL_APICALL void GL_APIENTRY glReleaseShaderCompiler (void);
GL_APICALL void GL_APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
GL_APICALL void GL_APIENTRY glSampleCoverage (GLclampf value, GLboolean invert);
GL_APICALL void GL_APIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height);
GL_APICALL void GL_APIENTRY glShaderBinary (GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length);
GL_APICALL void GL_APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length);
GL_APICALL void GL_APIENTRY glStencilFunc (GLenum func, GLint ref, GLuint mask);
GL_APICALL void GL_APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask);
GL_APICALL void GL_APIENTRY glStencilMask (GLuint mask);
GL_APICALL void GL_APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask);
GL_APICALL void GL_APIENTRY glStencilOp (GLenum fail, GLenum zfail, GLenum zpass);
GL_APICALL void GL_APIENTRY glStencilOpSeparate (GLenum face, GLenum fail, GLenum zfail, GLenum zpass);
GL_APICALL void GL_APIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels);
GL_APICALL void GL_APIENTRY glTexParameterf (GLenum target, GLenum pname, GLfloat param);
GL_APICALL void GL_APIENTRY glTexParameterfv (GLenum target, GLenum pname, const GLfloat* params);
GL_APICALL void GL_APIENTRY glTexParameteri (GLenum target, GLenum pname, GLint param);
GL_APICALL void GL_APIENTRY glTexParameteriv (GLenum target, GLenum pname, const GLint* params);
GL_APICALL void GL_APIENTRY glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels);
GL_APICALL void GL_APIENTRY glUniform1f (GLint location, GLfloat x);
GL_APICALL void GL_APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat* v);
GL_APICALL void GL_APIENTRY glUniform1i (GLint location, GLint x);
GL_APICALL void GL_APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint* v);
GL_APICALL void GL_APIENTRY glUniform2f (GLint location, GLfloat x, GLfloat y);
GL_APICALL void GL_APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat* v);
GL_APICALL void GL_APIENTRY glUniform2i (GLint location, GLint x, GLint y);
GL_APICALL void GL_APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint* v);
GL_APICALL void GL_APIENTRY glUniform3f (GLint location, GLfloat x, GLfloat y, GLfloat z);
GL_APICALL void GL_APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat* v);
GL_APICALL void GL_APIENTRY glUniform3i (GLint location, GLint x, GLint y, GLint z);
GL_APICALL void GL_APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint* v);
GL_APICALL void GL_APIENTRY glUniform4f (GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
GL_APICALL void GL_APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat* v);
GL_APICALL void GL_APIENTRY glUniform4i (GLint location, GLint x, GLint y, GLint z, GLint w);
GL_APICALL void GL_APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint* v);
GL_APICALL void GL_APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
GL_APICALL void GL_APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
GL_APICALL void GL_APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
GL_APICALL void GL_APIENTRY glUseProgram (GLuint program);
GL_APICALL void GL_APIENTRY glValidateProgram (GLuint program);
GL_APICALL void GL_APIENTRY glVertexAttrib1f (GLuint indx, GLfloat x);
GL_APICALL void GL_APIENTRY glVertexAttrib1fv (GLuint indx, const GLfloat* values);
GL_APICALL void GL_APIENTRY glVertexAttrib2f (GLuint indx, GLfloat x, GLfloat y);
GL_APICALL void GL_APIENTRY glVertexAttrib2fv (GLuint indx, const GLfloat* values);
GL_APICALL void GL_APIENTRY glVertexAttrib3f (GLuint indx, GLfloat x, GLfloat y, GLfloat z);
GL_APICALL void GL_APIENTRY glVertexAttrib3fv (GLuint indx, const GLfloat* values);
GL_APICALL void GL_APIENTRY glVertexAttrib4f (GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
GL_APICALL void GL_APIENTRY glVertexAttrib4fv (GLuint indx, const GLfloat* values);
GL_APICALL void GL_APIENTRY glVertexAttribPointer (GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr);
GL_APICALL void GL_APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height);
#ifdef __cplusplus
}
#endif
#endif /* __gl2_h_ */

File diff suppressed because it is too large Load Diff

View File

@ -1,28 +0,0 @@
#ifndef __gl2platform_h_
#define __gl2platform_h_
/* $Revision: 10602 $ on $Date:: 2010-03-04 22:35:34 -0800 #$ */
/*
* This document is licensed under the SGI Free Software B License Version
* 2.0. For details, see http://oss.sgi.com/projects/FreeB/ .
*/
/* Platform-specific types and definitions for OpenGL ES 2.X gl2.h
*
* Adopters may modify khrplatform.h and this file to suit their platform.
* You are encouraged to submit all modifications to the Khronos group so that
* they can be included in future versions of this file. Please submit changes
* by sending them to the public Khronos Bugzilla (http://khronos.org/bugzilla)
* by filing a bug against product "OpenGL-ES" component "Registry".
*/
#ifndef GL_APICALL
#define GL_APICALL
#endif
#ifndef GL_APIENTRY
#define GL_APIENTRY
#endif
#endif /* __gl2platform_h_ */

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +0,0 @@
{
local:
*;
};

View File

@ -1,45 +0,0 @@
cogl_gles2_public_headers = [
'GLES2/gl2.h',
'GLES2/gl2ext.h',
'GLES2/gl2platform.h',
]
cogl_gles2_sources = [
'cogl-gles2-api.c',
]
libmutter_cogl_gles2_map = 'libmutter-cogl-gles2.map'
libmutter_cogl_gles2_link_args = [
'-Wl,--version-script,@0@/@1@'.format(meson.current_source_dir(),
libmutter_cogl_gles2_map),
]
libmutter_cogl_gles2 = shared_library('mutter-cogl-gles2-' + libmutter_api_version,
sources: [cogl_gles2_sources, cogl_gles2_public_headers],
version: '0.0.0',
soversion: 0,
c_args: cogl_c_args,
include_directories: [cogl_includepath, cogl_path_includepath],
link_depends: libmutter_cogl_gles2_map,
link_args: libmutter_cogl_gles2_link_args,
dependencies: libmutter_cogl_dep,
install_rpath: pkglibdir,
install_dir: pkglibdir,
install: true,
)
cogl_gles2_includesubdir = join_paths(cogl_includesubdir, 'cogl-gles2/GLES2')
install_headers(cogl_gles2_public_headers,
subdir: cogl_gles2_includesubdir)
pkg.generate(libmutter_cogl_gles2,
name: 'CoglGles2',
filebase: 'mutter-cogl-gles2-' + libmutter_api_version,
description: 'A cogl GLES2 helper library for mutter',
subdirs: join_paths(pkgname, 'cogl'),
requires: [cogl_pkg_deps, libmutter_cogl_name],
version: meson.project_version(),
variables: [
'apiversion=' + libmutter_api_version,
],
install_dir: pcdir,
)

View File

@ -1,13 +0,0 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
apiversion=@LIBMUTTER_API_VERSION@
libdir=@libdir@/mutter-${apiversion}
includedir=@includedir@/mutter-${apiversion}
requires=@COGL_PKG_REQUIRES@ mutter-cogl-${apiversion}
Name: Cogl
Description: An object oriented GL/GLES Abstraction/Utility Layer
Version: @MUTTER_VERSION@
Libs: -L${libdir} -lmutter-cogl-gles2-${apiversion}
Cflags: -I${includedir}/cogl
Requires: ${requires}

View File

@ -212,9 +212,6 @@ struct _CoglContext
CoglList onscreen_dirty_queue;
CoglClosure *onscreen_dispatch_idle;
CoglGLES2Context *current_gles2_context;
GQueue gles2_context_stack;
/* This becomes TRUE the first time the context is bound to an
* onscreen buffer. This is used by cogl-framebuffer-gl to determine
* when to initialise the glDrawBuffer state */

View File

@ -288,8 +288,6 @@ cogl_context_new (CoglDisplay *display,
_cogl_list_init (&context->onscreen_events_queue);
_cogl_list_init (&context->onscreen_dirty_queue);
g_queue_init (&context->gles2_context_stack);
context->journal_flush_attributes_array =
g_array_new (TRUE, FALSE, sizeof (CoglAttribute *));
context->journal_clip_bounds = NULL;
@ -454,8 +452,6 @@ _cogl_context_free (CoglContext *context)
if (context->swap_callback_closures)
g_hash_table_destroy (context->swap_callback_closures);
g_warn_if_fail (context->gles2_context_stack.length == 0);
if (context->journal_flush_attributes_array)
g_array_free (context->journal_flush_attributes_array, TRUE);
if (context->journal_clip_bounds)

View File

@ -202,8 +202,6 @@ cogl_is_context (void *object);
* @COGL_FEATURE_ID_BUFFER_AGE: Available if the age of #CoglOnscreen back
* buffers are tracked and so cogl_onscreen_get_buffer_age() can be
* expected to return age values other than 0.
* @COGL_FEATURE_ID_GLES2_CONTEXT: Whether creating new GLES2 contexts is
* suported.
* @COGL_FEATURE_ID_DEPTH_TEXTURE: Whether #CoglFramebuffer support rendering
* the depth buffer to a texture.
* @COGL_FEATURE_ID_PRESENTATION_TIME: Whether frame presentation
@ -227,7 +225,6 @@ typedef enum _CoglFeatureID
COGL_FEATURE_ID_MAP_BUFFER_FOR_WRITE,
COGL_FEATURE_ID_MIRRORED_REPEAT,
COGL_FEATURE_ID_SWAP_BUFFERS_EVENT,
COGL_FEATURE_ID_GLES2_CONTEXT,
COGL_FEATURE_ID_DEPTH_TEXTURE,
COGL_FEATURE_ID_PRESENTATION_TIME,
COGL_FEATURE_ID_FENCE,

View File

@ -1,201 +0,0 @@
/*
* Cogl
*
* A Low Level GPU Graphics and Utilities API
*
* Copyright (C) 2011 Collabora Ltd.
* Copyright (C) 2012 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* Authors:
* Tomeu Vizoso <tomeu.vizoso@collabora.com>
* Robert Bragg <robert@linux.intel.com>
*
*/
#ifndef __COGL_GLES2_CONTEXT_PRIVATE_H
#define __COGL_GLES2_CONTEXT_PRIVATE_H
#include <glib.h>
#include "cogl-object-private.h"
#include "cogl-framebuffer-private.h"
#include "cogl-list.h"
typedef struct _CoglGLES2Offscreen
{
CoglList link;
CoglOffscreen *original_offscreen;
CoglGLFramebuffer gl_framebuffer;
} CoglGLES2Offscreen;
typedef struct
{
/* GL's ID for the shader */
GLuint object_id;
/* Shader type */
GLenum type;
/* Number of references to this shader. The shader will have one
* reference when it is created. This reference will be removed when
* glDeleteShader is called. An additional reference will be taken
* whenever the shader is attached to a program. This is necessary
* to correctly detect when a shader is destroyed because
* glDeleteShader doesn't actually delete the object if it is
* attached to a program */
int ref_count;
/* Set once this object has had glDeleteShader called on it. We need
* to keep track of this so we don't deref the data twice if the
* application calls glDeleteShader multiple times */
gboolean deleted;
} CoglGLES2ShaderData;
typedef enum
{
COGL_GLES2_FLIP_STATE_UNKNOWN,
COGL_GLES2_FLIP_STATE_NORMAL,
COGL_GLES2_FLIP_STATE_FLIPPED
} CoglGLES2FlipState;
typedef struct
{
/* GL's ID for the program */
GLuint object_id;
/* List of shaders attached to this program */
GList *attached_shaders;
/* Reference count. There can be up to two references. One of these
* will exist between glCreateProgram and glDeleteShader, the other
* will exist while the program is made current. This is necessary
* to correctly detect when the program is deleted because
* glDeleteShader will delay the deletion if the program is
* current */
int ref_count;
/* Set once this object has had glDeleteProgram called on it. We need
* to keep track of this so we don't deref the data twice if the
* application calls glDeleteProgram multiple times */
gboolean deleted;
GLuint flip_vector_location;
/* A cache of what value we've put in the flip vector uniform so
* that we don't flush unless it's changed */
CoglGLES2FlipState flip_vector_state;
CoglGLES2Context *context;
} CoglGLES2ProgramData;
/* State tracked for each texture unit */
typedef struct
{
/* The currently bound texture for the GL_TEXTURE_2D */
GLuint current_texture_2d;
} CoglGLES2TextureUnitData;
/* State tracked for each texture object */
typedef struct
{
/* GL's ID for this object */
GLuint object_id;
GLenum target;
/* The details for texture when it has a 2D target */
int width, height;
GLenum format;
} CoglGLES2TextureObjectData;
struct _CoglGLES2Context
{
CoglObject _parent;
CoglContext *context;
/* This is set to FALSE until the first time the GLES2 context is
* bound to something. We need to keep track of this so we can set
* the viewport and scissor the first time it is bound. */
gboolean has_been_bound;
CoglFramebuffer *read_buffer;
CoglGLES2Offscreen *gles2_read_buffer;
CoglFramebuffer *write_buffer;
CoglGLES2Offscreen *gles2_write_buffer;
GLuint current_fbo_handle;
CoglList foreign_offscreens;
CoglGLES2Vtable *vtable;
/* Hash table mapping GL's IDs for shaders and objects to ShaderData
* and ProgramData so that we can maintain extra data for these
* objects. Although technically the IDs will end up global across
* all GLES2 contexts because they will all be in the same share
* list, we don't really want to expose this outside of the Cogl API
* so we will assume it is undefined behaviour if an application
* relies on this. */
GHashTable *shader_map;
GHashTable *program_map;
/* Currently in use program. We need to keep track of this so that
* we can keep a reference to the data for the program while it is
* current */
CoglGLES2ProgramData *current_program;
/* Whether the currently bound framebuffer needs flipping. This is
* used to check for changes so that we can dirty the following
* state flags */
CoglGLES2FlipState current_flip_state;
/* The following state is tracked separately from the GL context
* because we need to modify it depending on whether we are flipping
* the geometry. */
gboolean viewport_dirty;
int viewport[4];
gboolean scissor_dirty;
int scissor[4];
gboolean front_face_dirty;
GLenum front_face;
/* We need to keep track of the pack alignment so we can flip the
* results of glReadPixels read from a CoglOffscreen */
int pack_alignment;
/* A hash table of CoglGLES2TextureObjects indexed by the texture
* object ID so that we can track some state */
GHashTable *texture_object_map;
/* Array of CoglGLES2TextureUnits to keep track of state for each
* texture unit */
GArray *texture_units;
/* The currently active texture unit indexed from 0 (not from
* GL_TEXTURE0) */
int current_texture_unit;
void *winsys;
};
#endif /* __COGL_GLES2_CONTEXT_PRIVATE_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,475 +0,0 @@
#ifndef __COGL_GLES2_TYPES_H_
#define __COGL_GLES2_TYPES_H_
/* $Revision: 16803 $ on $Date:: 2012-02-02 09:49:18 -0800 #$ */
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* This document is licensed under the SGI Free Software B License Version
* 2.0. For details, see http://oss.sgi.com/projects/FreeB/ .
*/
/*-------------------------------------------------------------------------
* Data type definitions
*-----------------------------------------------------------------------*/
typedef void GLvoid;
typedef char GLchar;
typedef unsigned int GLenum;
typedef unsigned char GLboolean;
typedef unsigned int GLbitfield;
typedef int8_t GLbyte;
typedef short GLshort;
typedef int GLint;
typedef int GLsizei;
typedef uint8_t GLubyte;
typedef unsigned short GLushort;
typedef unsigned int GLuint;
typedef float GLfloat;
typedef float GLclampf;
typedef int32_t GLfixed;
/* GL types for handling large vertex buffer objects */
typedef signed long int GLintptr;
typedef long GLsizeiptr;
/* OpenGL ES core versions */
#define GL_ES_VERSION_2_0 1
/* ClearBufferMask */
#define GL_DEPTH_BUFFER_BIT 0x00000100
#define GL_STENCIL_BUFFER_BIT 0x00000400
#define GL_COLOR_BUFFER_BIT 0x00004000
/* Boolean */
#define GL_FALSE 0
#define GL_TRUE 1
/* BeginMode */
#define GL_POINTS 0x0000
#define GL_LINES 0x0001
#define GL_LINE_LOOP 0x0002
#define GL_LINE_STRIP 0x0003
#define GL_TRIANGLES 0x0004
#define GL_TRIANGLE_STRIP 0x0005
#define GL_TRIANGLE_FAN 0x0006
/* AlphaFunction (not supported in ES20) */
/* GL_NEVER */
/* GL_LESS */
/* GL_EQUAL */
/* GL_LEQUAL */
/* GL_GREATER */
/* GL_NOTEQUAL */
/* GL_GEQUAL */
/* GL_ALWAYS */
/* BlendingFactorDest */
#define GL_ZERO 0
#define GL_ONE 1
#define GL_SRC_COLOR 0x0300
#define GL_ONE_MINUS_SRC_COLOR 0x0301
#define GL_SRC_ALPHA 0x0302
#define GL_ONE_MINUS_SRC_ALPHA 0x0303
#define GL_DST_ALPHA 0x0304
#define GL_ONE_MINUS_DST_ALPHA 0x0305
/* BlendingFactorSrc */
/* GL_ZERO */
/* GL_ONE */
#define GL_DST_COLOR 0x0306
#define GL_ONE_MINUS_DST_COLOR 0x0307
#define GL_SRC_ALPHA_SATURATE 0x0308
/* GL_SRC_ALPHA */
/* GL_ONE_MINUS_SRC_ALPHA */
/* GL_DST_ALPHA */
/* GL_ONE_MINUS_DST_ALPHA */
/* BlendEquationSeparate */
#define GL_FUNC_ADD 0x8006
#define GL_BLEND_EQUATION 0x8009
#define GL_BLEND_EQUATION_RGB 0x8009 /* same as BLEND_EQUATION */
#define GL_BLEND_EQUATION_ALPHA 0x883D
/* BlendSubtract */
#define GL_FUNC_SUBTRACT 0x800A
#define GL_FUNC_REVERSE_SUBTRACT 0x800B
/* Separate Blend Functions */
#define GL_BLEND_DST_RGB 0x80C8
#define GL_BLEND_SRC_RGB 0x80C9
#define GL_BLEND_DST_ALPHA 0x80CA
#define GL_BLEND_SRC_ALPHA 0x80CB
#define GL_CONSTANT_COLOR 0x8001
#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002
#define GL_CONSTANT_ALPHA 0x8003
#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004
#define GL_BLEND_COLOR 0x8005
/* Buffer Objects */
#define GL_ARRAY_BUFFER 0x8892
#define GL_ELEMENT_ARRAY_BUFFER 0x8893
#define GL_ARRAY_BUFFER_BINDING 0x8894
#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895
#define GL_STREAM_DRAW 0x88E0
#define GL_STATIC_DRAW 0x88E4
#define GL_DYNAMIC_DRAW 0x88E8
#define GL_BUFFER_SIZE 0x8764
#define GL_BUFFER_USAGE 0x8765
#define GL_CURRENT_VERTEX_ATTRIB 0x8626
/* CullFaceMode */
#define GL_FRONT 0x0404
#define GL_BACK 0x0405
#define GL_FRONT_AND_BACK 0x0408
/* DepthFunction */
/* GL_NEVER */
/* GL_LESS */
/* GL_EQUAL */
/* GL_LEQUAL */
/* GL_GREATER */
/* GL_NOTEQUAL */
/* GL_GEQUAL */
/* GL_ALWAYS */
/* EnableCap */
#define GL_TEXTURE_2D 0x0DE1
#define GL_CULL_FACE 0x0B44
#define GL_BLEND 0x0BE2
#define GL_DITHER 0x0BD0
#define GL_STENCIL_TEST 0x0B90
#define GL_DEPTH_TEST 0x0B71
#define GL_SCISSOR_TEST 0x0C11
#define GL_POLYGON_OFFSET_FILL 0x8037
#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E
#define GL_SAMPLE_COVERAGE 0x80A0
#define GL_TEXTURE_EXTERNAL_OES 0x8D65
/* ErrorCode */
#define GL_NO_ERROR 0
#define GL_INVALID_ENUM 0x0500
#define GL_INVALID_VALUE 0x0501
#define GL_INVALID_OPERATION 0x0502
#define GL_OUT_OF_MEMORY 0x0505
/* FrontFaceDirection */
#define GL_CW 0x0900
#define GL_CCW 0x0901
/* GetPName */
#define GL_LINE_WIDTH 0x0B21
#define GL_ALIASED_POINT_SIZE_RANGE 0x846D
#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E
#define GL_CULL_FACE_MODE 0x0B45
#define GL_FRONT_FACE 0x0B46
#define GL_DEPTH_RANGE 0x0B70
#define GL_DEPTH_WRITEMASK 0x0B72
#define GL_DEPTH_CLEAR_VALUE 0x0B73
#define GL_DEPTH_FUNC 0x0B74
#define GL_STENCIL_CLEAR_VALUE 0x0B91
#define GL_STENCIL_FUNC 0x0B92
#define GL_STENCIL_FAIL 0x0B94
#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95
#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96
#define GL_STENCIL_REF 0x0B97
#define GL_STENCIL_VALUE_MASK 0x0B93
#define GL_STENCIL_WRITEMASK 0x0B98
#define GL_STENCIL_BACK_FUNC 0x8800
#define GL_STENCIL_BACK_FAIL 0x8801
#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802
#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803
#define GL_STENCIL_BACK_REF 0x8CA3
#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4
#define GL_STENCIL_BACK_WRITEMASK 0x8CA5
#define GL_VIEWPORT 0x0BA2
#define GL_SCISSOR_BOX 0x0C10
/* GL_SCISSOR_TEST */
#define GL_COLOR_CLEAR_VALUE 0x0C22
#define GL_COLOR_WRITEMASK 0x0C23
#define GL_UNPACK_ALIGNMENT 0x0CF5
#define GL_PACK_ALIGNMENT 0x0D05
#define GL_MAX_TEXTURE_SIZE 0x0D33
#define GL_MAX_VIEWPORT_DIMS 0x0D3A
#define GL_SUBPIXEL_BITS 0x0D50
#define GL_RED_BITS 0x0D52
#define GL_GREEN_BITS 0x0D53
#define GL_BLUE_BITS 0x0D54
#define GL_ALPHA_BITS 0x0D55
#define GL_DEPTH_BITS 0x0D56
#define GL_STENCIL_BITS 0x0D57
#define GL_POLYGON_OFFSET_UNITS 0x2A00
/* GL_POLYGON_OFFSET_FILL */
#define GL_POLYGON_OFFSET_FACTOR 0x8038
#define GL_TEXTURE_BINDING_2D 0x8069
#define GL_SAMPLE_BUFFERS 0x80A8
#define GL_SAMPLES 0x80A9
#define GL_SAMPLE_COVERAGE_VALUE 0x80AA
#define GL_SAMPLE_COVERAGE_INVERT 0x80AB
/* GetTextureParameter */
/* GL_TEXTURE_MAG_FILTER */
/* GL_TEXTURE_MIN_FILTER */
/* GL_TEXTURE_WRAP_S */
/* GL_TEXTURE_WRAP_T */
#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2
#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3
/* HintMode */
#define GL_DONT_CARE 0x1100
#define GL_FASTEST 0x1101
#define GL_NICEST 0x1102
/* HintTarget */
#define GL_GENERATE_MIPMAP_HINT 0x8192
/* DataType */
#define GL_BYTE 0x1400
#define GL_UNSIGNED_BYTE 0x1401
#define GL_SHORT 0x1402
#define GL_UNSIGNED_SHORT 0x1403
#define GL_INT 0x1404
#define GL_UNSIGNED_INT 0x1405
#define GL_FLOAT 0x1406
#define GL_FIXED 0x140C
/* PixelFormat */
#define GL_DEPTH_COMPONENT 0x1902
#define GL_ALPHA 0x1906
#define GL_RGB 0x1907
#define GL_RGBA 0x1908
#define GL_LUMINANCE 0x1909
#define GL_LUMINANCE_ALPHA 0x190A
/* PixelType */
/* GL_UNSIGNED_BYTE */
#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033
#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034
#define GL_UNSIGNED_SHORT_5_6_5 0x8363
/* Shaders */
#define GL_FRAGMENT_SHADER 0x8B30
#define GL_VERTEX_SHADER 0x8B31
#define GL_MAX_VERTEX_ATTRIBS 0x8869
#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB
#define GL_MAX_VARYING_VECTORS 0x8DFC
#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D
#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C
#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872
#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD
#define GL_SHADER_TYPE 0x8B4F
#define GL_DELETE_STATUS 0x8B80
#define GL_LINK_STATUS 0x8B82
#define GL_VALIDATE_STATUS 0x8B83
#define GL_ATTACHED_SHADERS 0x8B85
#define GL_ACTIVE_UNIFORMS 0x8B86
#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87
#define GL_ACTIVE_ATTRIBUTES 0x8B89
#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A
#define GL_SHADING_LANGUAGE_VERSION 0x8B8C
#define GL_CURRENT_PROGRAM 0x8B8D
/* StencilFunction */
#define GL_NEVER 0x0200
#define GL_LESS 0x0201
#define GL_EQUAL 0x0202
#define GL_LEQUAL 0x0203
#define GL_GREATER 0x0204
#define GL_NOTEQUAL 0x0205
#define GL_GEQUAL 0x0206
#define GL_ALWAYS 0x0207
/* StencilOp */
/* GL_ZERO */
#define GL_KEEP 0x1E00
#define GL_REPLACE 0x1E01
#define GL_INCR 0x1E02
#define GL_DECR 0x1E03
#define GL_INVERT 0x150A
#define GL_INCR_WRAP 0x8507
#define GL_DECR_WRAP 0x8508
/* StringName */
#define GL_VENDOR 0x1F00
#define GL_RENDERER 0x1F01
#define GL_VERSION 0x1F02
#define GL_EXTENSIONS 0x1F03
/* TextureMagFilter */
#define GL_NEAREST 0x2600
#define GL_LINEAR 0x2601
/* TextureMinFilter */
/* GL_NEAREST */
/* GL_LINEAR */
#define GL_NEAREST_MIPMAP_NEAREST 0x2700
#define GL_LINEAR_MIPMAP_NEAREST 0x2701
#define GL_NEAREST_MIPMAP_LINEAR 0x2702
#define GL_LINEAR_MIPMAP_LINEAR 0x2703
/* TextureParameterName */
#define GL_TEXTURE_MAG_FILTER 0x2800
#define GL_TEXTURE_MIN_FILTER 0x2801
#define GL_TEXTURE_WRAP_S 0x2802
#define GL_TEXTURE_WRAP_T 0x2803
/* TextureTarget */
/* GL_TEXTURE_2D */
#define GL_TEXTURE 0x1702
#define GL_TEXTURE_CUBE_MAP 0x8513
#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514
#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515
#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516
#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517
#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518
#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519
#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A
#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C
/* TextureUnit */
#define GL_TEXTURE0 0x84C0
#define GL_TEXTURE1 0x84C1
#define GL_TEXTURE2 0x84C2
#define GL_TEXTURE3 0x84C3
#define GL_TEXTURE4 0x84C4
#define GL_TEXTURE5 0x84C5
#define GL_TEXTURE6 0x84C6
#define GL_TEXTURE7 0x84C7
#define GL_TEXTURE8 0x84C8
#define GL_TEXTURE9 0x84C9
#define GL_TEXTURE10 0x84CA
#define GL_TEXTURE11 0x84CB
#define GL_TEXTURE12 0x84CC
#define GL_TEXTURE13 0x84CD
#define GL_TEXTURE14 0x84CE
#define GL_TEXTURE15 0x84CF
#define GL_TEXTURE16 0x84D0
#define GL_TEXTURE17 0x84D1
#define GL_TEXTURE18 0x84D2
#define GL_TEXTURE19 0x84D3
#define GL_TEXTURE20 0x84D4
#define GL_TEXTURE21 0x84D5
#define GL_TEXTURE22 0x84D6
#define GL_TEXTURE23 0x84D7
#define GL_TEXTURE24 0x84D8
#define GL_TEXTURE25 0x84D9
#define GL_TEXTURE26 0x84DA
#define GL_TEXTURE27 0x84DB
#define GL_TEXTURE28 0x84DC
#define GL_TEXTURE29 0x84DD
#define GL_TEXTURE30 0x84DE
#define GL_TEXTURE31 0x84DF
#define GL_ACTIVE_TEXTURE 0x84E0
/* TextureWrapMode */
#define GL_REPEAT 0x2901
#define GL_CLAMP_TO_EDGE 0x812F
#define GL_MIRRORED_REPEAT 0x8370
/* Uniform Types */
#define GL_FLOAT_VEC2 0x8B50
#define GL_FLOAT_VEC3 0x8B51
#define GL_FLOAT_VEC4 0x8B52
#define GL_INT_VEC2 0x8B53
#define GL_INT_VEC3 0x8B54
#define GL_INT_VEC4 0x8B55
#define GL_BOOL 0x8B56
#define GL_BOOL_VEC2 0x8B57
#define GL_BOOL_VEC3 0x8B58
#define GL_BOOL_VEC4 0x8B59
#define GL_FLOAT_MAT2 0x8B5A
#define GL_FLOAT_MAT3 0x8B5B
#define GL_FLOAT_MAT4 0x8B5C
#define GL_SAMPLER_2D 0x8B5E
#define GL_SAMPLER_CUBE 0x8B60
/* Vertex Arrays */
#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622
#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623
#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624
#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625
#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A
#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645
#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F
/* Read Format */
#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A
#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B
/* Shader Source */
#define GL_COMPILE_STATUS 0x8B81
#define GL_INFO_LOG_LENGTH 0x8B84
#define GL_SHADER_SOURCE_LENGTH 0x8B88
#define GL_SHADER_COMPILER 0x8DFA
/* Shader Binary */
#define GL_SHADER_BINARY_FORMATS 0x8DF8
#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9
/* Shader Precision-Specified Types */
#define GL_LOW_FLOAT 0x8DF0
#define GL_MEDIUM_FLOAT 0x8DF1
#define GL_HIGH_FLOAT 0x8DF2
#define GL_LOW_INT 0x8DF3
#define GL_MEDIUM_INT 0x8DF4
#define GL_HIGH_INT 0x8DF5
/* Framebuffer Object. */
#define GL_FRAMEBUFFER 0x8D40
#define GL_RENDERBUFFER 0x8D41
#define GL_RGBA4 0x8056
#define GL_RGB5_A1 0x8057
#define GL_RGB565 0x8D62
#define GL_DEPTH_COMPONENT16 0x81A5
#define GL_STENCIL_INDEX8 0x8D48
#define GL_RENDERBUFFER_WIDTH 0x8D42
#define GL_RENDERBUFFER_HEIGHT 0x8D43
#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44
#define GL_RENDERBUFFER_RED_SIZE 0x8D50
#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51
#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52
#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53
#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54
#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55
#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0
#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1
#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2
#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3
#define GL_COLOR_ATTACHMENT0 0x8CE0
#define GL_DEPTH_ATTACHMENT 0x8D00
#define GL_STENCIL_ATTACHMENT 0x8D20
#define GL_NONE 0
#define GL_FRAMEBUFFER_COMPLETE 0x8CD5
#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6
#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7
#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS 0x8CD9
#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD
#define GL_FRAMEBUFFER_BINDING 0x8CA6
#define GL_RENDERBUFFER_BINDING 0x8CA7
#define GL_MAX_RENDERBUFFER_SIZE 0x84E8
#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506
#ifdef __cplusplus
}
#endif
#endif /* __COGL_GLES2_TYPES_H_ */

View File

@ -1,416 +0,0 @@
/*
* Cogl
*
* A Low Level GPU Graphics and Utilities API
*
* Copyright (C) 2011 Collabora Ltd.
* Copyright (C) 2012 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* Authors:
* Tomeu Vizoso <tomeu.vizoso@collabora.com>
* Robert Bragg <robert@linux.intel.com>
*
*/
#ifndef __COGL_GLES2_H__
#define __COGL_GLES2_H__
/* NB: cogl-gles2.h is a top-level header that can be included directly
* but we want to be careful not to define __COGL_H_INSIDE__ when this
* is included internally while building Cogl itself since
* __COGL_H_INSIDE__ is used in headers to guard public vs private
* api definitions
*/
#ifndef COGL_COMPILATION
/* Note: When building Cogl .gir we explicitly define
* __COGL_H_INSIDE__ */
#ifndef __COGL_H_INSIDE__
#define __COGL_H_INSIDE__
#define __COGL_MUST_UNDEF_COGL_H_INSIDE_COGL_GLES2__
#endif
#endif /* COGL_COMPILATION */
#include <cogl/cogl-defines.h>
#include <cogl/cogl-context.h>
#include <cogl/cogl-framebuffer.h>
#include <cogl/cogl-texture.h>
#include <cogl/cogl-texture-2d.h>
/* CoglGLES2Vtable depends on GLES 2.0 typedefs being available but we
* want to be careful that the public api doesn't expose arbitrary
* system GL headers as part of the Cogl API so although when building
* internally we consistently refer to the system headers to avoid
* conflicts we only expose the minimal set of GLES 2.0 types and enums
* publicly.
*/
#if defined(COGL_COMPILATION) || defined(COGL_ENABLE_MUTTER_API)
#include "cogl-gl-header.h"
#else
#include <cogl/cogl-gles2-types.h>
#endif
G_BEGIN_DECLS
/**
* SECTION:cogl-gles2
* @short_description: A portable api to access OpenGLES 2.0
*
* Cogl provides portable access to the OpenGLES api through a single
* library that is able to smooth over inconsistencies between the
* different vendor drivers for OpenGLES in a single place.
*
* The api is designed to allow Cogl to transparently implement the
* api on top of other drivers, such as OpenGL, D3D or on Cogl's own
* drawing api so even if your platform doesn't come with an
* OpenGLES 2.0 api Cogl may still be able to expose the api to your
* application.
*
* Since Cogl is a library and not an api specification it is possible
* to add OpenGLES 2.0 api features to Cogl which can immidiately
* benefit developers regardless of what platform they are running on.
*
* With this api it's possible to re-use existing OpenGLES 2.0 code
* within applications that are rendering with the Cogl API and also
* it's possible for applications that render using OpenGLES 2.0 to
* incorporate content rendered with Cogl.
*
* Applications can check for OpenGLES 2.0 api support by checking for
* %COGL_FEATURE_ID_GLES2_CONTEXT support with cogl_has_feature().
*
* Since: 1.12
* Stability: unstable
*/
/**
* CoglGLES2Context:
*
* Represents an OpenGLES 2.0 api context used as a sandbox for
* OpenGLES 2.0 state. This is comparable to an EGLContext for those
* who have used OpenGLES 2.0 with EGL before.
*
* Since: 1.12
* Stability: unstable
*/
typedef struct _CoglGLES2Context CoglGLES2Context;
/**
* CoglGLES2Vtable:
*
* Provides function pointers for the full OpenGLES 2.0 api. The
* api must be accessed this way and not by directly calling
* symbols of any system OpenGLES 2.0 api.
*
* Since: 1.12
* Stability: unstable
*/
typedef struct _CoglGLES2Vtable CoglGLES2Vtable;
struct _CoglGLES2Vtable
{
/*< private >*/
#define COGL_EXT_BEGIN(name, \
min_gl_major, min_gl_minor, \
gles_availability, \
extension_suffixes, extension_names)
#define COGL_EXT_FUNCTION(ret, name, args) \
ret (* name) args;
#define COGL_EXT_END()
#include <cogl/gl-prototypes/cogl-gles2-functions.h>
#include <glib-object.h>
#undef COGL_EXT_BEGIN
#undef COGL_EXT_FUNCTION
#undef COGL_EXT_END
};
/**
* cogl_gles2_context_get_gtype:
*
* Returns: a #GType that can be used with the GLib type system.
*/
GType cogl_gles2_context_get_gtype (void);
uint32_t
_cogl_gles2_context_error_quark (void);
/**
* COGL_GLES2_CONTEXT_ERROR:
*
* An error domain for runtime exceptions relating to the
* cogl_gles2_context api.
*
* Since: 2.0
* Stability: unstable
*/
#define COGL_GLES2_CONTEXT_ERROR (_cogl_gles2_context_error_quark ())
/**
* CoglGLES2ContextError:
* @COGL_GLES2_CONTEXT_ERROR_UNSUPPORTED: Creating GLES2 contexts
* isn't supported. Applications should use cogl_has_feature() to
* check for the %COGL_FEATURE_ID_GLES2_CONTEXT.
* @COGL_GLES2_CONTEXT_ERROR_DRIVER: An underlying driver error
* occured.
*
* Error codes that relate to the cogl_gles2_context api.
*/
typedef enum /*< prefix=COGL_GLES2_CONTEXT_ERROR >*/
{
COGL_GLES2_CONTEXT_ERROR_UNSUPPORTED,
COGL_GLES2_CONTEXT_ERROR_DRIVER
} CoglGLES2ContextError;
/**
* cogl_gles2_context_new:
* @ctx: A #CoglContext
* @error: A pointer to a #GError for returning exceptions
*
* Allocates a new OpenGLES 2.0 context that can be used to render to
* #CoglOffscreen framebuffers (Rendering to #CoglOnscreen
* framebuffers is not currently supported).
*
* To actually access the OpenGLES 2.0 api itself you need to use
* cogl_gles2_context_get_vtable(). You should not try to directly link
* to and use the symbols provided by the a system OpenGLES 2.0
* driver.
*
* Once you have allocated an OpenGLES 2.0 context you can make it
* current using cogl_push_gles2_context(). For those familiar with
* using the EGL api, this serves a similar purpose to eglMakeCurrent.
*
* <note>Before using this api applications can check for OpenGLES 2.0
* api support by checking for %COGL_FEATURE_ID_GLES2_CONTEXT support
* with cogl_has_feature(). This function will return %FALSE and
* return an %COGL_GLES2_CONTEXT_ERROR_UNSUPPORTED error if the
* feature isn't available.</note>
*
* Since: 2.0
* Return value: A newly allocated #CoglGLES2Context or %NULL if there
* was an error and @error will be updated in that case.
* Stability: unstable
*/
CoglGLES2Context *
cogl_gles2_context_new (CoglContext *ctx, GError **error);
/**
* cogl_gles2_context_get_vtable:
* @gles2_ctx: A #CoglGLES2Context allocated with
* cogl_gles2_context_new()
*
* Queries the OpenGLES 2.0 api function pointers that should be
* used for rendering with the given @gles2_ctx.
*
* <note>You should not try to directly link to and use the symbols
* provided by any system OpenGLES 2.0 driver.</note>
*
* Since: 2.0
* Return value: A pointer to a #CoglGLES2Vtable providing pointers
* to functions for the full OpenGLES 2.0 api.
* Stability: unstable
*/
const CoglGLES2Vtable *
cogl_gles2_context_get_vtable (CoglGLES2Context *gles2_ctx);
/**
* cogl_push_gles2_context:
* @ctx: A #CoglContext
* @gles2_ctx: A #CoglGLES2Context allocated with
* cogl_gles2_context_new()
* @read_buffer: A #CoglFramebuffer to access to read operations
* such as glReadPixels. (must be a #CoglOffscreen
* framebuffer currently)
* @write_buffer: A #CoglFramebuffer to access for drawing operations
* such as glDrawArrays. (must be a #CoglOffscreen
* framebuffer currently)
* @error: A pointer to a #GError for returning exceptions
*
* Pushes the given @gles2_ctx onto a stack associated with @ctx so
* that the OpenGLES 2.0 api can be used instead of the Cogl
* rendering apis to read and write to the specified framebuffers.
*
* Usage of the api available through a #CoglGLES2Vtable is only
* allowed between cogl_push_gles2_context() and
* cogl_pop_gles2_context() calls.
*
* If there is a runtime problem with switching over to the given
* @gles2_ctx then this function will return %FALSE and return
* an error through @error.
*
* Since: 2.0
* Return value: %TRUE if operation was successfull or %FALSE
* otherwise and @error will be updated.
* Stability: unstable
*/
gboolean
cogl_push_gles2_context (CoglContext *ctx,
CoglGLES2Context *gles2_ctx,
CoglFramebuffer *read_buffer,
CoglFramebuffer *write_buffer,
GError **error);
/**
* cogl_pop_gles2_context:
* @ctx: A #CoglContext
*
* Restores the previously active #CoglGLES2Context if there
* were nested calls to cogl_push_gles2_context() or otherwise
* restores the ability to render with the Cogl api instead
* of OpenGLES 2.0.
*
* The behaviour is undefined if calls to cogl_pop_gles2_context()
* are not balenced with the number of corresponding calls to
* cogl_push_gles2_context().
*
* Since: 2.0
* Stability: unstable
*/
void
cogl_pop_gles2_context (CoglContext *ctx);
/**
* cogl_gles2_get_current_vtable:
*
* Returns the OpenGL ES 2.0 api vtable for the currently pushed
* #CoglGLES2Context (last pushed with cogl_push_gles2_context()) or
* %NULL if no #CoglGLES2Context has been pushed.
*
* Return value: The #CoglGLES2Vtable for the currently pushed
* #CoglGLES2Context or %NULL if none has been pushed.
* Since: 2.0
* Stability: unstable
*/
CoglGLES2Vtable *
cogl_gles2_get_current_vtable (void);
/**
* cogl_gles2_texture_2d_new_from_handle:
* @ctx: A #CoglContext
* @gles2_ctx: A #CoglGLES2Context allocated with
* cogl_gles2_context_new()
* @handle: An OpenGL ES 2.0 texture handle created with
* glGenTextures()
* @width: Width of the texture to allocate
* @height: Height of the texture to allocate
* @format: The format of the texture
*
* Creates a #CoglTexture2D from an OpenGL ES 2.0 texture handle that
* was created within the given @gles2_ctx via glGenTextures(). The
* texture needs to have been associated with the GL_TEXTURE_2D target.
*
* <note>This interface is only intended for sharing textures to read
* from. The behaviour is undefined if the texture is modified using
* the Cogl api.</note>
*
* <note>Applications should only pass this function handles that were
* created via a #CoglGLES2Vtable or via libcogl-gles2 and not pass
* handles created directly using the system's native libGLESv2
* api.</note>
*
* Since: 2.0
* Stability: unstable
*/
CoglTexture2D *
cogl_gles2_texture_2d_new_from_handle (CoglContext *ctx,
CoglGLES2Context *gles2_ctx,
unsigned int handle,
int width,
int height,
CoglPixelFormat format);
/**
* cogl_gles2_texture_get_handle:
* @texture: A #CoglTexture
* @handle: A return location for an OpenGL ES 2.0 texture handle
* @target: A return location for an OpenGL ES 2.0 texture target
*
* Gets an OpenGL ES 2.0 texture handle for a #CoglTexture that can
* then be referenced by a #CoglGLES2Context. As well as returning
* a texture handle the texture's target (such as GL_TEXTURE_2D) is
* also returned.
*
* If the #CoglTexture can not be shared with a #CoglGLES2Context then
* this function will return %FALSE.
*
* This api does not affect the lifetime of the CoglTexture and you
* must take care not to reference the returned handle after the
* original texture has been freed.
*
* <note>This interface is only intended for sharing textures to read
* from. The behaviour is undefined if the texture is modified by a
* GLES2 context.</note>
*
* <note>This function will only return %TRUE for low-level
* #CoglTexture<!-- -->s such as #CoglTexture2D but not for high level
* meta textures such as #CoglTexture2DSliced</note>
*
* <note>The handle returned should not be passed directly to a system
* OpenGL ES 2.0 library, the handle is only intended to be used via
* a #CoglGLES2Vtable or via libcogl-gles2.</note>
*
* Return value: %TRUE if a handle and target could be returned
* otherwise %FALSE is returned.
* Since: 2.0
* Stability: unstable
*/
gboolean
cogl_gles2_texture_get_handle (CoglTexture *texture,
unsigned int *handle,
unsigned int *target);
/**
* cogl_is_gles2_context:
* @object: A #CoglObject pointer
*
* Gets whether the given object references a #CoglGLES2Context.
*
* Return value: %TRUE if the object references a #CoglGLES2Context
* and %FALSE otherwise.
* Since: 2.0
* Stability: unstable
*/
gboolean
cogl_is_gles2_context (void *object);
G_END_DECLS
/* The gobject introspection scanner seems to parse public headers in
* isolation which means we need to be extra careful about how we
* define and undefine __COGL_H_INSIDE__ used to detect when internal
* headers are incorrectly included by developers. In the gobject
* introspection case we have to manually define __COGL_H_INSIDE__ as
* a commandline argument for the scanner which means we must be
* careful not to undefine it in a header...
*/
#ifdef __COGL_MUST_UNDEF_COGL_H_INSIDE_COGL_GLES2__
#undef __COGL_H_INSIDE__
#undef __COGL_MUST_UNDEF_COGL_H_INSIDE_COGL_GLES2__
#endif
#endif /* __COGL_GLES2_H__ */

View File

@ -84,11 +84,6 @@ struct _CoglRenderer
void *winsys;
};
/* Mask of constraints that effect driver selection. All of the other
* constraints effect only the winsys selection */
#define COGL_RENDERER_DRIVER_CONSTRAINTS \
COGL_RENDERER_CONSTRAINT_SUPPORTS_COGL_GLES2
typedef CoglFilterReturn (* CoglNativeFilterFunc) (void *native_event,
void *data);

View File

@ -76,7 +76,6 @@ typedef struct _CoglDriverDescription
{
CoglDriver id;
const char *name;
CoglRendererConstraint constraints;
/* It would be nice to make this a pointer and then use a compound
* literal from C99 to initialise it but we probably can't get away
* with using C99 here. Instead we'll just use a fixed-size array.
@ -94,7 +93,6 @@ static CoglDriverDescription _cogl_drivers[] =
{
COGL_DRIVER_GL,
"gl",
0,
{ COGL_PRIVATE_FEATURE_ANY_GL,
COGL_PRIVATE_FEATURE_GL_FIXED,
COGL_PRIVATE_FEATURE_GL_PROGRAMMABLE,
@ -106,7 +104,6 @@ static CoglDriverDescription _cogl_drivers[] =
{
COGL_DRIVER_GL3,
"gl3",
0,
{ COGL_PRIVATE_FEATURE_ANY_GL,
COGL_PRIVATE_FEATURE_GL_PROGRAMMABLE,
-1 },
@ -119,7 +116,6 @@ static CoglDriverDescription _cogl_drivers[] =
{
COGL_DRIVER_GLES2,
"gles2",
COGL_RENDERER_CONSTRAINT_SUPPORTS_COGL_GLES2,
{ COGL_PRIVATE_FEATURE_ANY_GL,
COGL_PRIVATE_FEATURE_GL_EMBEDDED,
COGL_PRIVATE_FEATURE_GL_PROGRAMMABLE,
@ -132,7 +128,6 @@ static CoglDriverDescription _cogl_drivers[] =
{
COGL_DRIVER_NOP,
"nop",
0, /* constraints satisfied */
{ -1 },
&_cogl_driver_nop,
NULL, /* texture driver */
@ -398,31 +393,15 @@ driver_id_to_name (CoglDriver id)
typedef struct _SatisfyConstraintsState
{
GList *constraints;
const CoglDriverDescription *driver_description;
} SatisfyConstraintsState;
/* XXX this is still uglier than it needs to be */
static gboolean
satisfy_constraints (CoglDriverDescription *description,
void *user_data)
{
SatisfyConstraintsState *state = user_data;
GList *l;
for (l = state->constraints; l; l = l->next)
{
CoglRendererConstraint constraint = GPOINTER_TO_UINT (l->data);
/* Most of the constraints only affect the winsys selection so
* we'll filter them out */
if (!(constraint & COGL_RENDERER_DRIVER_CONSTRAINTS))
continue;
/* If the driver doesn't satisfy any constraint then continue
* to the next driver description */
if (!(constraint & description->constraints))
return TRUE;
}
state->driver_description = description;
@ -493,7 +472,6 @@ _cogl_renderer_choose_driver (CoglRenderer *renderer,
}
state.driver_description = NULL;
state.constraints = renderer->constraints;
foreach_driver_description (driver_override,
satisfy_constraints,

View File

@ -261,10 +261,6 @@ cogl_renderer_connect (CoglRenderer *renderer, GError **error);
* @COGL_RENDERER_CONSTRAINT_USES_XLIB: Require the renderer to be X11
* based and use Xlib
* @COGL_RENDERER_CONSTRAINT_USES_EGL: Require the renderer to be EGL based
* @COGL_RENDERER_CONSTRAINT_SUPPORTS_COGL_GLES2: Require that the
* renderer supports creating a #CoglGLES2Context via
* cogl_gles2_context_new(). This can be used to integrate GLES 2.0
* code into Cogl based applications.
*
* These constraint flags are hard-coded features of the different renderer
* backends. Sometimes a platform may support multiple rendering options which
@ -286,7 +282,6 @@ typedef enum
COGL_RENDERER_CONSTRAINT_USES_X11 = (1 << 0),
COGL_RENDERER_CONSTRAINT_USES_XLIB = (1 << 1),
COGL_RENDERER_CONSTRAINT_USES_EGL = (1 << 2),
COGL_RENDERER_CONSTRAINT_SUPPORTS_COGL_GLES2 = (1 << 3)
} CoglRendererConstraint;

View File

@ -334,15 +334,6 @@ cogl_get_static_identity_quaternion
cogl_get_static_zero_quaternion
cogl_get_viewport
#ifdef COGL_HAS_GTYPE_SUPPORT
cogl_gles2_context_get_gtype
#endif
cogl_gles2_context_get_vtable
cogl_gles2_context_new
cogl_gles2_get_current_vtable
cogl_gles2_texture_get_handle
cogl_gles2_texture_2d_new_from_handle
#ifdef COGL_HAS_GLIB_SUPPORT
cogl_glib_renderer_source_new
cogl_glib_source_new
@ -381,7 +372,6 @@ cogl_is_bitmap
cogl_is_buffer
cogl_is_context
cogl_is_frame_info
cogl_is_gles2_context
cogl_is_index_buffer
#if 0
/* not implemented! */
@ -690,7 +680,6 @@ cogl_polygon
cogl_pop_draw_buffer
#endif
cogl_pop_framebuffer
cogl_pop_gles2_context
cogl_pop_matrix
cogl_pop_source
@ -752,7 +741,6 @@ cogl_push_draw_buffer
#endif
cogl_push_framebuffer
cogl_push_gles2_context
cogl_push_matrix
cogl_push_source

View File

@ -106,8 +106,6 @@ cogl_nonintrospected_headers = [
'cogl-display.h',
'cogl-context.h',
'cogl-snippet.h',
'cogl-gles2.h',
'cogl-gles2-types.h',
'cogl-index-buffer.h',
'cogl-attribute-buffer.h',
'cogl-indices.h',
@ -362,8 +360,6 @@ cogl_sources = [
'cogl-memory-stack.c',
'cogl-magazine-private.h',
'cogl-magazine.c',
'cogl-gles2-context-private.h',
'cogl-gles2-context.c',
'cogl-closure-list-private.h',
'cogl-closure-list.c',
'cogl-fence.c',

View File

@ -41,7 +41,6 @@
#include "cogl-swap-chain-private.h"
#include "cogl-renderer-private.h"
#include "cogl-onscreen-template-private.h"
#include "cogl-gles2-context-private.h"
#include "cogl-egl.h"
#include "cogl-private.h"
#include "winsys/cogl-winsys-egl-private.h"
@ -110,40 +109,6 @@ static const CoglFeatureData winsys_feature_data[] =
#include "winsys/cogl-winsys-egl-feature-functions.h"
};
static const char *
get_error_string (void)
{
switch (eglGetError()){
case EGL_BAD_DISPLAY:
return "Invalid display";
case EGL_NOT_INITIALIZED:
return "Display not initialized";
case EGL_BAD_ALLOC:
return "Not enough resources to allocate context";
case EGL_BAD_ATTRIBUTE:
return "Invalid attribute";
case EGL_BAD_CONFIG:
return "Invalid config";
case EGL_BAD_CONTEXT:
return "Invalid context";
case EGL_BAD_CURRENT_SURFACE:
return "Invalid current surface";
case EGL_BAD_MATCH:
return "Bad match";
case EGL_BAD_NATIVE_PIXMAP:
return "Invalid native pixmap";
case EGL_BAD_NATIVE_WINDOW:
return "Invalid native window";
case EGL_BAD_PARAMETER:
return "Invalid parameter";
case EGL_BAD_SURFACE:
return "Invalid surface";
default:
g_assert_not_reached ();
return NULL;
}
}
static GCallback
_cogl_winsys_renderer_get_proc_address (CoglRenderer *renderer,
const char *name,
@ -556,14 +521,6 @@ _cogl_winsys_context_init (CoglContext *context, GError **error)
COGL_FLAGS_SET (context->features, COGL_FEATURE_ID_BUFFER_AGE, TRUE);
}
/* NB: We currently only support creating standalone GLES2 contexts
* for offscreen rendering and so we need a dummy (non-visible)
* surface to be able to bind those contexts */
if (egl_display->dummy_surface != EGL_NO_SURFACE &&
context->driver == COGL_DRIVER_GLES2)
COGL_FLAGS_SET (context->features,
COGL_FEATURE_ID_GLES2_CONTEXT, TRUE);
if (egl_renderer->platform_vtable->context_init &&
!egl_renderer->platform_vtable->context_init (context, error))
return FALSE;
@ -583,54 +540,6 @@ _cogl_winsys_context_deinit (CoglContext *context)
g_free (context->winsys);
}
typedef struct _CoglGLES2ContextEGL
{
EGLContext egl_context;
EGLSurface dummy_surface;
} CoglGLES2ContextEGL;
static void *
_cogl_winsys_context_create_gles2_context (CoglContext *ctx, GError **error)
{
CoglRendererEGL *egl_renderer = ctx->display->renderer->winsys;
CoglDisplayEGL *egl_display = ctx->display->winsys;
EGLint attribs[3];
EGLContext egl_context;
attribs[0] = EGL_CONTEXT_CLIENT_VERSION;
attribs[1] = 2;
attribs[2] = EGL_NONE;
egl_context = eglCreateContext (egl_renderer->edpy,
egl_display->egl_config,
egl_display->egl_context,
attribs);
if (egl_context == EGL_NO_CONTEXT)
{
g_set_error (error, COGL_WINSYS_ERROR,
COGL_WINSYS_ERROR_CREATE_GLES2_CONTEXT,
"%s", get_error_string ());
return NULL;
}
return (void *)egl_context;
}
static void
_cogl_winsys_destroy_gles2_context (CoglGLES2Context *gles2_ctx)
{
CoglContext *context = gles2_ctx->context;
CoglDisplay *display = context->display;
CoglDisplayEGL *egl_display = display->winsys;
CoglRenderer *renderer = display->renderer;
CoglRendererEGL *egl_renderer = renderer->winsys;
EGLContext egl_context = gles2_ctx->winsys;
g_return_if_fail (egl_display->current_context != egl_context);
eglDestroyContext (egl_renderer->edpy, egl_context);
}
static gboolean
_cogl_winsys_onscreen_init (CoglOnscreen *onscreen,
GError **error)
@ -878,58 +787,6 @@ _cogl_winsys_onscreen_swap_buffers_with_damage (CoglOnscreen *onscreen,
eglSwapBuffers (egl_renderer->edpy, egl_onscreen->egl_surface);
}
static void
_cogl_winsys_save_context (CoglContext *ctx)
{
CoglContextEGL *egl_context = ctx->winsys;
CoglDisplayEGL *egl_display = ctx->display->winsys;
egl_context->saved_draw_surface = egl_display->current_draw_surface;
egl_context->saved_read_surface = egl_display->current_read_surface;
}
static gboolean
_cogl_winsys_set_gles2_context (CoglGLES2Context *gles2_ctx, GError **error)
{
CoglContext *ctx = gles2_ctx->context;
CoglDisplayEGL *egl_display = ctx->display->winsys;
gboolean status;
if (gles2_ctx->write_buffer &&
cogl_is_onscreen (gles2_ctx->write_buffer))
status =
bind_onscreen_with_context (COGL_ONSCREEN (gles2_ctx->write_buffer),
gles2_ctx->winsys);
else
status = _cogl_winsys_egl_make_current (ctx->display,
egl_display->dummy_surface,
egl_display->dummy_surface,
gles2_ctx->winsys);
if (!status)
{
g_set_error (error,
COGL_WINSYS_ERROR,
COGL_WINSYS_ERROR_MAKE_CURRENT,
"Failed to make gles2 context current");
return FALSE;
}
return TRUE;
}
static void
_cogl_winsys_restore_context (CoglContext *ctx)
{
CoglContextEGL *egl_context = ctx->winsys;
CoglDisplayEGL *egl_display = ctx->display->winsys;
_cogl_winsys_egl_make_current (ctx->display,
egl_context->saved_draw_surface,
egl_context->saved_read_surface,
egl_display->egl_context);
}
#if defined(EGL_KHR_fence_sync) || defined(EGL_KHR_reusable_sync)
static void *
_cogl_winsys_fence_add (CoglContext *context)
@ -971,8 +828,7 @@ _cogl_winsys_fence_destroy (CoglContext *context, void *fence)
static CoglWinsysVtable _cogl_winsys_vtable =
{
.constraints = COGL_RENDERER_CONSTRAINT_USES_EGL |
COGL_RENDERER_CONSTRAINT_SUPPORTS_COGL_GLES2,
.constraints = COGL_RENDERER_CONSTRAINT_USES_EGL,
/* This winsys is only used as a base for the EGL-platform
winsys's so it does not have an ID or a name */
@ -984,9 +840,6 @@ static CoglWinsysVtable _cogl_winsys_vtable =
.display_destroy = _cogl_winsys_display_destroy,
.context_init = _cogl_winsys_context_init,
.context_deinit = _cogl_winsys_context_deinit,
.context_create_gles2_context =
_cogl_winsys_context_create_gles2_context,
.destroy_gles2_context = _cogl_winsys_destroy_gles2_context,
.onscreen_init = _cogl_winsys_onscreen_init,
.onscreen_deinit = _cogl_winsys_onscreen_deinit,
.onscreen_bind = _cogl_winsys_onscreen_bind,
@ -995,11 +848,6 @@ static CoglWinsysVtable _cogl_winsys_vtable =
.onscreen_swap_region = _cogl_winsys_onscreen_swap_region,
.onscreen_get_buffer_age = _cogl_winsys_onscreen_get_buffer_age,
/* CoglGLES2Context related methods */
.save_context = _cogl_winsys_save_context,
.set_gles2_context = _cogl_winsys_set_gles2_context,
.restore_context = _cogl_winsys_restore_context,
#if defined(EGL_KHR_fence_sync) || defined(EGL_KHR_reusable_sync)
.fence_add = _cogl_winsys_fence_add,
.fence_is_complete = _cogl_winsys_fence_is_complete,

View File

@ -33,7 +33,6 @@
#include "cogl-renderer.h"
#include "cogl-onscreen.h"
#include "cogl-gles2.h"
#ifdef COGL_HAS_XLIB_SUPPORT
#include "cogl-texture-pixmap-x11-private.h"
@ -61,7 +60,6 @@ typedef enum /*< prefix=COGL_WINSYS_ERROR >*/
COGL_WINSYS_ERROR_CREATE_CONTEXT,
COGL_WINSYS_ERROR_CREATE_ONSCREEN,
COGL_WINSYS_ERROR_MAKE_CURRENT,
COGL_WINSYS_ERROR_CREATE_GLES2_CONTEXT,
} CoglWinsysError;
typedef struct _CoglWinsysVtable
@ -99,9 +97,6 @@ typedef struct _CoglWinsysVtable
void
(*context_deinit) (CoglContext *context);
void *
(*context_create_gles2_context) (CoglContext *ctx, GError **error);
gboolean
(*onscreen_init) (CoglOnscreen *onscreen, GError **error);
@ -158,18 +153,6 @@ typedef struct _CoglWinsysVtable
CoglTexturePixmapStereoMode stereo_mode);
#endif
void
(*save_context) (CoglContext *ctx);
gboolean
(*set_gles2_context) (CoglGLES2Context *gles2_ctx, GError **error);
void
(*restore_context) (CoglContext *ctx);
void
(*destroy_gles2_context) (CoglGLES2Context *gles2_ctx);
void *
(*fence_add) (CoglContext *ctx);

View File

@ -117,9 +117,6 @@ endif
subdir('cogl')
subdir('cogl-path')
subdir('cogl-pango')
if have_gles2
subdir('cogl-gles2')
endif
if have_cogl_tests
subdir('tests')
endif

View File

@ -42,12 +42,6 @@ check_flags (TestFlags flags,
return FALSE;
}
if (flags & TEST_REQUIREMENT_GLES2_CONTEXT &&
!cogl_has_feature (test_ctx, COGL_FEATURE_ID_GLES2_CONTEXT))
{
return FALSE;
}
if (flags & TEST_REQUIREMENT_MAP_WRITE &&
!cogl_has_feature (test_ctx, COGL_FEATURE_ID_MAP_BUFFER_FOR_WRITE))
{

View File

@ -36,7 +36,6 @@ typedef enum _TestFlags
TEST_REQUIREMENT_TEXTURE_RECTANGLE = 1<<4,
TEST_REQUIREMENT_TEXTURE_RG = 1<<5,
TEST_REQUIREMENT_POINT_SPRITE = 1<<6,
TEST_REQUIREMENT_GLES2_CONTEXT = 1<<7,
TEST_REQUIREMENT_MAP_WRITE = 1<<8,
TEST_REQUIREMENT_GLSL = 1<<9,
TEST_REQUIREMENT_OFFSCREEN = 1<<10,

View File

@ -25,7 +25,6 @@ cogl_test_conformance_sources = [
'test-point-sprite.c',
'test-no-gl-header.c',
'test-version.c',
'test-gles2-context.c',
'test-euler-quaternion.c',
'test-layer-remove.c',
'test-alpha-test.c',

View File

@ -127,12 +127,6 @@ main (int argc, char **argv)
UNPORTED_TEST (test_viewport);
ADD_TEST (test_gles2_context, TEST_REQUIREMENT_GLES2_CONTEXT, 0);
ADD_TEST (test_gles2_context_fbo, TEST_REQUIREMENT_GLES2_CONTEXT, 0);
ADD_TEST (test_gles2_context_copy_tex_image,
TEST_REQUIREMENT_GLES2_CONTEXT,
0);
ADD_TEST (test_euler_quaternion, 0, 0);
ADD_TEST (test_color_hsl, 0, 0);

View File

@ -1,963 +0,0 @@
#include <cogl/cogl.h>
#include <cogl/cogl-gles2.h>
#include <string.h>
#include "test-declarations.h"
#include "test-utils.h"
typedef struct _TestState
{
CoglTexture *offscreen_texture;
CoglOffscreen *offscreen;
CoglGLES2Context *gles2_ctx;
const CoglGLES2Vtable *gles2;
} TestState;
static void
test_push_pop_single_context (void)
{
CoglTexture *offscreen_texture;
CoglOffscreen *offscreen;
CoglPipeline *pipeline;
CoglGLES2Context *gles2_ctx;
const CoglGLES2Vtable *gles2;
GError *error = NULL;
offscreen_texture =
cogl_texture_2d_new_with_size (test_ctx,
cogl_framebuffer_get_width (test_fb),
cogl_framebuffer_get_height (test_fb));
offscreen = cogl_offscreen_new_with_texture (offscreen_texture);
pipeline = cogl_pipeline_new (test_ctx);
cogl_pipeline_set_layer_texture (pipeline, 0, offscreen_texture);
gles2_ctx = cogl_gles2_context_new (test_ctx, &error);
if (!gles2_ctx)
g_error ("Failed to create GLES2 context: %s\n", error->message);
gles2 = cogl_gles2_context_get_vtable (gles2_ctx);
/* Clear onscreen to 0xffff00 using GLES2 */
if (!cogl_push_gles2_context (test_ctx,
gles2_ctx,
test_fb,
test_fb,
&error))
{
g_error ("Failed to push gles2 context: %s\n", error->message);
}
gles2->glClearColor (1, 1, 0, 1);
gles2->glClear (GL_COLOR_BUFFER_BIT);
cogl_pop_gles2_context (test_ctx);
test_utils_check_pixel (test_fb, 0, 0, 0xffff00ff);
/* Clear offscreen to 0xff0000 using GLES2 and then copy the result
* onscreen.
*
* If we fail to bind the new context here then we'd probably end up
* clearing onscreen to 0xff0000 and copying 0xffff00 to onscreen
* instead.
*/
if (!cogl_push_gles2_context (test_ctx,
gles2_ctx,
offscreen,
offscreen,
&error))
{
g_error ("Failed to push gles2 context: %s\n", error->message);
}
gles2->glClearColor (1, 0, 0, 1);
gles2->glClear (GL_COLOR_BUFFER_BIT);
cogl_pop_gles2_context (test_ctx);
cogl_framebuffer_draw_rectangle (test_fb,
pipeline,
-1, 1, 1, -1);
/* NB: Cogl doesn't automatically support mid-scene modifications
* of textures and so we explicitly flush the drawn rectangle to the
* framebuffer now otherwise it may be batched until after the
* offscreen texture has been modified again. */
cogl_flush ();
/* Clear the offscreen framebuffer to blue using GLES2 before
* reading back from the onscreen framebuffer in case we mistakenly
* read from the offscreen framebuffer and get a false positive
*/
if (!cogl_push_gles2_context (test_ctx,
gles2_ctx,
offscreen,
offscreen,
&error))
{
g_error ("Failed to push gles2 context: %s\n", error->message);
}
gles2->glClearColor (0, 0, 1, 1);
gles2->glClear (GL_COLOR_BUFFER_BIT);
cogl_pop_gles2_context (test_ctx);
test_utils_check_pixel (test_fb, 0, 0, 0xff0000ff);
/* Now copy the offscreen blue clear to the onscreen framebufer and
* check that too */
cogl_framebuffer_draw_rectangle (test_fb,
pipeline,
-1, 1, 1, -1);
test_utils_check_pixel (test_fb, 0, 0, 0x0000ffff);
if (!cogl_push_gles2_context (test_ctx,
gles2_ctx,
test_fb,
test_fb,
&error))
{
g_error ("Failed to push gles2 context: %s\n", error->message);
}
gles2->glClearColor (1, 0, 1, 1);
gles2->glClear (GL_COLOR_BUFFER_BIT);
cogl_pop_gles2_context (test_ctx);
test_utils_check_pixel (test_fb, 0, 0, 0xff00ffff);
cogl_object_unref (gles2_ctx);
cogl_object_unref (pipeline);
}
static void
create_gles2_context (CoglTexture **offscreen_texture,
CoglOffscreen **offscreen,
CoglPipeline **pipeline,
CoglGLES2Context **gles2_ctx,
const CoglGLES2Vtable **gles2)
{
GError *error = NULL;
*offscreen_texture =
cogl_texture_2d_new_with_size (test_ctx,
cogl_framebuffer_get_width (test_fb),
cogl_framebuffer_get_height (test_fb));
*offscreen = cogl_offscreen_new_with_texture (*offscreen_texture);
*pipeline = cogl_pipeline_new (test_ctx);
cogl_pipeline_set_layer_texture (*pipeline, 0, *offscreen_texture);
*gles2_ctx = cogl_gles2_context_new (test_ctx, &error);
if (!*gles2_ctx)
g_error ("Failed to create GLES2 context: %s\n", error->message);
*gles2 = cogl_gles2_context_get_vtable (*gles2_ctx);
}
static void
test_push_pop_multi_context (void)
{
CoglTexture *offscreen_texture0;
CoglOffscreen *offscreen0;
CoglPipeline *pipeline0;
CoglGLES2Context *gles2_ctx0;
const CoglGLES2Vtable *gles20;
CoglTexture *offscreen_texture1;
CoglOffscreen *offscreen1;
CoglPipeline *pipeline1;
CoglGLES2Context *gles2_ctx1;
const CoglGLES2Vtable *gles21;
GError *error = NULL;
create_gles2_context (&offscreen_texture0,
&offscreen0,
&pipeline0,
&gles2_ctx0,
&gles20);
create_gles2_context (&offscreen_texture1,
&offscreen1,
&pipeline1,
&gles2_ctx1,
&gles21);
cogl_framebuffer_clear4f (test_fb, COGL_BUFFER_BIT_COLOR, 1, 1, 1, 1);
if (!cogl_push_gles2_context (test_ctx,
gles2_ctx0,
offscreen0,
offscreen0,
&error))
{
g_error ("Failed to push gles2 context 0: %s\n", error->message);
}
gles20->glClearColor (1, 0, 0, 1);
gles20->glClear (GL_COLOR_BUFFER_BIT);
if (!cogl_push_gles2_context (test_ctx,
gles2_ctx1,
offscreen1,
offscreen1,
&error))
{
g_error ("Failed to push gles2 context 1: %s\n", error->message);
}
gles21->glClearColor (0, 1, 0, 1);
gles21->glClear (GL_COLOR_BUFFER_BIT);
cogl_pop_gles2_context (test_ctx);
cogl_pop_gles2_context (test_ctx);
test_utils_check_pixel (test_fb, 0, 0, 0xffffffff);
cogl_framebuffer_draw_rectangle (test_fb,
pipeline0,
-1, 1, 1, -1);
test_utils_check_pixel (test_fb, 0, 0, 0xff0000ff);
cogl_framebuffer_draw_rectangle (test_fb,
pipeline1,
-1, 1, 1, -1);
test_utils_check_pixel (test_fb, 0, 0, 0x00ff00ff);
}
static GLuint
create_gles2_framebuffer (const CoglGLES2Vtable *gles2,
int width,
int height)
{
GLuint texture_handle;
GLuint fbo_handle;
GLenum status;
gles2->glGenTextures (1, &texture_handle);
gles2->glGenFramebuffers (1, &fbo_handle);
gles2->glBindTexture (GL_TEXTURE_2D, texture_handle);
gles2->glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
gles2->glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
gles2->glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA,
GL_UNSIGNED_BYTE, NULL);
gles2->glBindTexture (GL_TEXTURE_2D, 0);
gles2->glBindFramebuffer (GL_FRAMEBUFFER, fbo_handle);
gles2->glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
GL_TEXTURE_2D, texture_handle, 0);
status = gles2->glCheckFramebufferStatus (GL_FRAMEBUFFER);
if (cogl_test_verbose ())
g_print ("status for gles2 framebuffer = 0x%x %s\n",
status, status == GL_FRAMEBUFFER_COMPLETE ? "(complete)" : "(?)");
gles2->glBindFramebuffer (GL_FRAMEBUFFER, 0);
return fbo_handle;
}
static void
test_gles2_read_pixels (void)
{
CoglTexture *offscreen_texture;
CoglOffscreen *offscreen;
CoglPipeline *pipeline;
CoglGLES2Context *gles2_ctx;
const CoglGLES2Vtable *gles2;
GError *error = NULL;
GLubyte pixel[4];
GLuint fbo_handle;
create_gles2_context (&offscreen_texture,
&offscreen,
&pipeline,
&gles2_ctx,
&gles2);
cogl_framebuffer_clear4f (test_fb, COGL_BUFFER_BIT_COLOR, 1, 1, 1, 1);
if (!cogl_push_gles2_context (test_ctx,
gles2_ctx,
offscreen,
offscreen,
&error))
{
g_error ("Failed to push gles2 context: %s\n", error->message);
}
gles2->glClearColor (1, 0, 0, 1);
gles2->glClear (GL_COLOR_BUFFER_BIT);
gles2->glReadPixels (0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixel);
test_utils_compare_pixel (pixel, 0xff0000ff);
fbo_handle = create_gles2_framebuffer (gles2, 256, 256);
gles2->glBindFramebuffer (GL_FRAMEBUFFER, fbo_handle);
gles2->glClearColor (0, 1, 0, 1);
gles2->glClear (GL_COLOR_BUFFER_BIT);
gles2->glReadPixels (0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixel);
test_utils_compare_pixel (pixel, 0x00ff00ff);
gles2->glBindFramebuffer (GL_FRAMEBUFFER, 0);
gles2->glClearColor (0, 1, 1, 1);
gles2->glClear (GL_COLOR_BUFFER_BIT);
gles2->glReadPixels (0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixel);
test_utils_compare_pixel (pixel, 0x00ffffff);
cogl_pop_gles2_context (test_ctx);
test_utils_check_pixel (test_fb, 0, 0, 0xffffffff);
/* Bind different read and write buffers */
if (!cogl_push_gles2_context (test_ctx,
gles2_ctx,
offscreen,
test_fb,
&error))
{
g_error ("Failed to push gles2 context: %s\n", error->message);
}
gles2->glReadPixels (0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixel);
test_utils_compare_pixel (pixel, 0x00ffffff);
cogl_pop_gles2_context (test_ctx);
test_utils_check_pixel (test_fb, 0, 0, 0xffffffff);
/* Bind different read and write buffers (the other way around from
* before so when we test with COGL_TEST_ONSCREEN=1 we will read
* from an onscreen framebuffer) */
if (!cogl_push_gles2_context (test_ctx,
gles2_ctx,
test_fb,
offscreen,
&error))
{
g_error ("Failed to push gles2 context: %s\n", error->message);
}
gles2->glReadPixels (0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixel);
test_utils_compare_pixel (pixel, 0xffffffff);
cogl_pop_gles2_context (test_ctx);
}
void
test_gles2_context (void)
{
test_push_pop_single_context ();
test_push_pop_multi_context ();
test_gles2_read_pixels ();
if (cogl_test_verbose ())
g_print ("OK\n");
}
static GLuint
create_shader (const CoglGLES2Vtable *gles2,
GLenum type,
const char *source)
{
GLuint shader;
GLint status;
int length = strlen (source);
shader = gles2->glCreateShader (type);
gles2->glShaderSource (shader, 1, &source, &length);
gles2->glCompileShader (shader);
gles2->glGetShaderiv (shader, GL_COMPILE_STATUS, &status);
if (!status)
{
char buf[512];
gles2->glGetShaderInfoLog (shader, sizeof (buf), NULL, buf);
g_error ("Shader compilation failed:\n%s", buf);
}
return shader;
}
static GLuint
create_program (const CoglGLES2Vtable *gles2,
const char *vertex_shader_source,
const char *fragment_shader_source)
{
GLuint fragment_shader, vertex_shader, program;
GLint status;
vertex_shader =
create_shader (gles2, GL_VERTEX_SHADER, vertex_shader_source);
fragment_shader =
create_shader (gles2, GL_FRAGMENT_SHADER, fragment_shader_source);
program = gles2->glCreateProgram ();
gles2->glAttachShader (program, vertex_shader);
gles2->glAttachShader (program, fragment_shader);
gles2->glLinkProgram (program);
gles2->glGetProgramiv (program, GL_LINK_STATUS, &status);
if (!status)
{
char buf[512];
gles2->glGetProgramInfoLog (program, sizeof (buf), NULL, buf);
g_error ("Program linking failed:\n%s", buf);
}
return program;
}
typedef struct
{
const CoglGLES2Vtable *gles2;
GLint color_location;
GLint pos_location;
int fb_width, fb_height;
} PaintData;
typedef void (* PaintMethod) (PaintData *data);
/* Top vertices are counter-clockwise */
static const float top_vertices[] =
{
-1.0f, 0.0f,
1.0f, 0.0f,
-1.0f, 1.0f,
1.0f, 1.0f
};
/* Bottom vertices are clockwise */
static const float bottom_vertices[] =
{
1.0f, 0.0f,
1.0f, -1.0f,
-1.0f, 0.0f,
-1.0f, -1.0f
};
static void
paint_quads (PaintData *data)
{
const CoglGLES2Vtable *gles2 = data->gles2;
gles2->glEnableVertexAttribArray (data->pos_location);
/* Paint the top half in red */
gles2->glUniform4f (data->color_location,
1.0f, 0.0f, 0.0f, 1.0f);
gles2->glVertexAttribPointer (data->pos_location,
2, /* size */
GL_FLOAT,
GL_FALSE, /* not normalized */
sizeof (float) * 2,
top_vertices);
gles2->glDrawArrays (GL_TRIANGLE_STRIP, 0, 4);
/* Paint the bottom half in blue */
gles2->glUniform4f (data->color_location,
0.0f, 0.0f, 1.0f, 1.0f);
gles2->glVertexAttribPointer (data->pos_location,
2, /* size */
GL_FLOAT,
GL_FALSE, /* not normalized */
sizeof (float) * 2,
bottom_vertices);
gles2->glDrawArrays (GL_TRIANGLE_STRIP, 0, 4);
}
static void
paint_viewport (PaintData *data)
{
const CoglGLES2Vtable *gles2 = data->gles2;
int viewport[4];
/* Vertices to fill the entire framebuffer */
static const float vertices[] =
{
-1.0f, -1.0f,
1.0f, -1.0f,
-1.0f, 1.0f,
1.0f, 1.0f
};
gles2->glEnableVertexAttribArray (data->pos_location);
gles2->glVertexAttribPointer (data->pos_location,
2, /* size */
GL_FLOAT,
GL_FALSE, /* not normalized */
sizeof (float) * 2,
vertices);
/* Paint the top half in red */
gles2->glViewport (0, data->fb_height / 2,
data->fb_width, data->fb_height / 2);
gles2->glUniform4f (data->color_location,
1.0f, 0.0f, 0.0f, 1.0f);
gles2->glDrawArrays (GL_TRIANGLE_STRIP, 0, 4);
/* Paint the bottom half in blue */
gles2->glViewport (0, 0, data->fb_width, data->fb_height / 2);
gles2->glUniform4f (data->color_location,
0.0f, 0.0f, 1.0f, 1.0f);
gles2->glDrawArrays (GL_TRIANGLE_STRIP, 0, 4);
gles2->glGetIntegerv (GL_VIEWPORT, viewport);
g_assert_cmpint (viewport[0], ==, 0.0f);
g_assert_cmpint (viewport[1], ==, 0.0f);
g_assert_cmpint (viewport[2], ==, data->fb_width);
g_assert_cmpint (viewport[3], ==, data->fb_height / 2);
}
static void
paint_scissor (PaintData *data)
{
const CoglGLES2Vtable *gles2 = data->gles2;
float scissor[4];
gles2->glEnable (GL_SCISSOR_TEST);
/* Paint the top half in red */
gles2->glScissor (0, data->fb_height / 2,
data->fb_width, data->fb_height / 2);
gles2->glClearColor (1.0, 0.0, 0.0, 1.0);
gles2->glClear (GL_COLOR_BUFFER_BIT);
/* Paint the bottom half in blue */
gles2->glScissor (0, 0, data->fb_width, data->fb_height / 2);
gles2->glClearColor (0.0, 0.0, 1.0, 1.0);
gles2->glClear (GL_COLOR_BUFFER_BIT);
gles2->glGetFloatv (GL_SCISSOR_BOX, scissor);
g_assert_cmpfloat (scissor[0], ==, 0.0f);
g_assert_cmpfloat (scissor[1], ==, 0.0f);
g_assert_cmpfloat (scissor[2], ==, data->fb_width);
g_assert_cmpfloat (scissor[3], ==, data->fb_height / 2);
}
static void
paint_cull (PaintData *data)
{
const CoglGLES2Vtable *gles2 = data->gles2;
GLint front_face;
int i;
gles2->glEnableVertexAttribArray (data->pos_location);
gles2->glEnable (GL_CULL_FACE);
/* First time round we'll use GL_CCW as the front face so that the
* bottom quad will be culled */
gles2->glFrontFace (GL_CCW);
gles2->glUniform4f (data->color_location,
1.0f, 0.0f, 0.0f, 1.0f);
gles2->glGetIntegerv (GL_FRONT_FACE, &front_face);
g_assert_cmpint (front_face, ==, GL_CCW);
for (i = 0; i < 2; i++)
{
/* Paint both quads in the same color. One of these will be
* culled */
gles2->glVertexAttribPointer (data->pos_location,
2, /* size */
GL_FLOAT,
GL_FALSE, /* not normalized */
sizeof (float) * 2,
top_vertices);
gles2->glDrawArrays (GL_TRIANGLE_STRIP, 0, 4);
gles2->glVertexAttribPointer (data->pos_location,
2, /* size */
GL_FLOAT,
GL_FALSE, /* not normalized */
sizeof (float) * 2,
bottom_vertices);
gles2->glDrawArrays (GL_TRIANGLE_STRIP, 0, 4);
/* Second time round we'll use GL_CW as the front face so that the
* top quad will be culled */
gles2->glFrontFace (GL_CW);
gles2->glUniform4f (data->color_location,
0.0f, 0.0f, 1.0f, 1.0f);
gles2->glGetIntegerv (GL_FRONT_FACE, &front_face);
g_assert_cmpint (front_face, ==, GL_CW);
}
}
static void
verify_read_pixels (const PaintData *data)
{
int stride = data->fb_width * 4;
uint8_t *buf = g_malloc (data->fb_height * stride);
data->gles2->glReadPixels (0, 0, /* x/y */
data->fb_width, data->fb_height,
GL_RGBA,
GL_UNSIGNED_BYTE,
buf);
/* In GL, the lines earlier in the buffer are the bottom */
/* Bottom should be blue */
test_utils_compare_pixel (buf + data->fb_width / 2 * 4 +
data->fb_height / 4 * stride,
0x0000ffff);
/* Top should be red */
test_utils_compare_pixel (buf + data->fb_width / 2 * 4 +
data->fb_height * 3 / 4 * stride,
0xff0000ff);
g_free (buf);
}
void
test_gles2_context_fbo (void)
{
static const char vertex_shader_source[] =
"attribute vec2 pos;\n"
"\n"
"void\n"
"main ()\n"
"{\n"
" gl_Position = vec4 (pos, 0.0, 1.0);\n"
"}\n";
static const char fragment_shader_source[] =
"precision mediump float;\n"
"uniform vec4 color;\n"
"\n"
"void\n"
"main ()\n"
"{\n"
" gl_FragColor = color;\n"
"}\n";
static const PaintMethod paint_methods[] =
{
paint_quads,
paint_viewport,
paint_scissor,
paint_cull
};
int i;
PaintData data;
data.fb_width = cogl_framebuffer_get_width (test_fb);
data.fb_height = cogl_framebuffer_get_height (test_fb);
for (i = 0; i < G_N_ELEMENTS (paint_methods); i++)
{
CoglTexture *offscreen_texture;
CoglOffscreen *offscreen;
CoglPipeline *pipeline;
CoglGLES2Context *gles2_ctx;
GLuint program;
GError *error = NULL;
create_gles2_context (&offscreen_texture,
&offscreen,
&pipeline,
&gles2_ctx,
&data.gles2);
if (!cogl_push_gles2_context (test_ctx,
gles2_ctx,
offscreen,
offscreen,
&error))
g_error ("Failed to push gles2 context: %s\n", error->message);
program = create_program (data.gles2,
vertex_shader_source,
fragment_shader_source);
data.gles2->glClearColor (1.0, 1.0, 0.0, 1.0);
data.gles2->glClear (GL_COLOR_BUFFER_BIT);
data.gles2->glUseProgram (program);
data.color_location = data.gles2->glGetUniformLocation (program, "color");
if (data.color_location == -1)
g_error ("Couldn't find color uniform");
data.pos_location = data.gles2->glGetAttribLocation (program, "pos");
if (data.pos_location == -1)
g_error ("Couldn't find pos attribute");
paint_methods[i] (&data);
verify_read_pixels (&data);
cogl_pop_gles2_context (test_ctx);
cogl_object_unref (offscreen);
cogl_object_unref (gles2_ctx);
cogl_framebuffer_draw_rectangle (test_fb,
pipeline,
-1.0f, 1.0f,
1.0f, -1.0f);
cogl_object_unref (pipeline);
cogl_object_unref (offscreen_texture);
/* Top half of the framebuffer should be red */
test_utils_check_pixel (test_fb,
data.fb_width / 2, data.fb_height / 4,
0xff0000ff);
/* Bottom half should be blue */
test_utils_check_pixel (test_fb,
data.fb_width / 2, data.fb_height * 3 / 4,
0x0000ffff);
}
}
/* Position to draw a rectangle in. The top half of this rectangle
* will be red, and the bottom will be blue */
#define RECTANGLE_DRAW_X 10
#define RECTANGLE_DRAW_Y 15
/* Position to copy the rectangle to in the destination texture */
#define RECTANGLE_COPY_X 110
#define RECTANGLE_COPY_Y 115
#define RECTANGLE_WIDTH 30
#define RECTANGLE_HEIGHT 40
static void
verify_region (const CoglGLES2Vtable *gles2,
int x,
int y,
int width,
int height,
uint32_t expected_pixel)
{
uint8_t *buf, *p;
buf = g_malloc (width * height * 4);
gles2->glReadPixels (x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, buf);
for (p = buf + width * height * 4; p > buf; p -= 4)
test_utils_compare_pixel (p - 4, expected_pixel);
g_free (buf);
}
void
test_gles2_context_copy_tex_image (void)
{
static const char vertex_shader_source[] =
"attribute vec2 pos;\n"
"attribute vec2 tex_coord_attrib;\n"
"varying vec2 tex_coord_varying;\n"
"\n"
"void\n"
"main ()\n"
"{\n"
" gl_Position = vec4 (pos, 0.0, 1.0);\n"
" tex_coord_varying = tex_coord_attrib;\n"
"}\n";
static const char fragment_shader_source[] =
"precision mediump float;\n"
"varying vec2 tex_coord_varying;\n"
"uniform sampler2D tex;\n"
"\n"
"void\n"
"main ()\n"
"{\n"
" gl_FragColor = texture2D (tex, tex_coord_varying);\n"
"}\n";
static const float verts[] =
{
-1.0f, -1.0f, 0.0f, 0.0f,
1.0f, -1.0f, 1.0f, 0.0f,
-1.0f, 1.0f, 0.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f
};
int fb_width = cogl_framebuffer_get_width (test_fb);
int fb_height = cogl_framebuffer_get_height (test_fb);
CoglTexture *offscreen_texture;
CoglOffscreen *offscreen;
CoglPipeline *pipeline;
CoglGLES2Context *gles2_ctx;
const CoglGLES2Vtable *gles2;
GError *error = NULL;
GLuint tex;
GLint tex_uniform_location;
GLint pos_location;
GLint tex_coord_location;
GLuint program;
create_gles2_context (&offscreen_texture,
&offscreen,
&pipeline,
&gles2_ctx,
&gles2);
if (!cogl_push_gles2_context (test_ctx,
gles2_ctx,
offscreen,
offscreen,
&error))
g_error ("Failed to push gles2 context: %s\n", error->message);
gles2->glClearColor (1.0, 1.0, 0.0, 1.0);
gles2->glClear (GL_COLOR_BUFFER_BIT);
/* Draw a rectangle using clear and the scissor so that we don't
* have to create a shader */
gles2->glEnable (GL_SCISSOR_TEST);
/* Top half red */
gles2->glScissor (RECTANGLE_DRAW_X,
RECTANGLE_DRAW_Y + RECTANGLE_HEIGHT / 2,
RECTANGLE_WIDTH,
RECTANGLE_HEIGHT / 2);
gles2->glClearColor (1.0, 0.0, 0.0, 1.0);
gles2->glClear (GL_COLOR_BUFFER_BIT);
/* Bottom half blue */
gles2->glScissor (RECTANGLE_DRAW_X,
RECTANGLE_DRAW_Y,
RECTANGLE_WIDTH,
RECTANGLE_HEIGHT / 2);
gles2->glClearColor (0.0, 0.0, 1.0, 1.0);
gles2->glClear (GL_COLOR_BUFFER_BIT);
/* Draw where the rectangle would be if the coordinates were flipped
* in white to make it obvious that that is the problem if the
* assertion fails */
gles2->glScissor (RECTANGLE_DRAW_X,
fb_width - (RECTANGLE_DRAW_Y + RECTANGLE_HEIGHT),
RECTANGLE_WIDTH,
RECTANGLE_HEIGHT);
gles2->glClearColor (1.0, 1.0, 1.0, 1.0);
gles2->glClear (GL_COLOR_BUFFER_BIT);
gles2->glDisable (GL_SCISSOR_TEST);
/* Create a texture */
gles2->glGenTextures (1, &tex);
gles2->glBindTexture (GL_TEXTURE_2D, tex);
gles2->glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
gles2->glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
/* Copy the entire framebuffer into the texture */
gles2->glCopyTexImage2D (GL_TEXTURE_2D,
0, /* level */
GL_RGBA,
0, 0, /* x/y */
fb_width, fb_height,
0 /* border */);
/* Copy the rectangle into another part of the texture */
gles2->glCopyTexSubImage2D (GL_TEXTURE_2D,
0, /* level */
RECTANGLE_COPY_X,
RECTANGLE_COPY_Y,
RECTANGLE_DRAW_X,
RECTANGLE_DRAW_Y,
RECTANGLE_WIDTH,
RECTANGLE_HEIGHT);
/* Clear the framebuffer to make the test more thorough */
gles2->glClearColor (1.0, 1.0, 0.0, 1.0);
gles2->glClear (GL_COLOR_BUFFER_BIT);
/* Create a program to render the texture */
program = create_program (gles2,
vertex_shader_source,
fragment_shader_source);
pos_location =
gles2->glGetAttribLocation (program, "pos");
if (pos_location == -1)
g_error ("Couldn't find pos attribute");
tex_coord_location =
gles2->glGetAttribLocation (program, "tex_coord_attrib");
if (tex_coord_location == -1)
g_error ("Couldn't find tex_coord_attrib attribute");
tex_uniform_location =
gles2->glGetUniformLocation (program, "tex");
if (tex_uniform_location == -1)
g_error ("Couldn't find tex uniform");
gles2->glUseProgram (program);
gles2->glUniform1i (tex_uniform_location, 0);
/* Render the texture to fill the framebuffer */
gles2->glEnableVertexAttribArray (pos_location);
gles2->glVertexAttribPointer (pos_location,
2, /* n_components */
GL_FLOAT,
FALSE, /* normalized */
sizeof (float) * 4,
verts);
gles2->glEnableVertexAttribArray (tex_coord_location);
gles2->glVertexAttribPointer (tex_coord_location,
2, /* n_components */
GL_FLOAT,
FALSE, /* normalized */
sizeof (float) * 4,
verts + 2);
gles2->glDrawArrays (GL_TRIANGLE_STRIP, 0, 4);
/* Verify top of drawn rectangle is red */
verify_region (gles2,
RECTANGLE_DRAW_X,
RECTANGLE_DRAW_Y + RECTANGLE_HEIGHT / 2,
RECTANGLE_WIDTH,
RECTANGLE_HEIGHT / 2,
0xff0000ff);
/* Verify bottom of drawn rectangle is blue */
verify_region (gles2,
RECTANGLE_DRAW_X,
RECTANGLE_DRAW_Y,
RECTANGLE_WIDTH,
RECTANGLE_HEIGHT / 2,
0x0000ffff);
/* Verify top of copied rectangle is red */
verify_region (gles2,
RECTANGLE_COPY_X,
RECTANGLE_COPY_Y + RECTANGLE_HEIGHT / 2,
RECTANGLE_WIDTH,
RECTANGLE_HEIGHT / 2,
0xff0000ff);
/* Verify bottom of copied rectangle is blue */
verify_region (gles2,
RECTANGLE_COPY_X,
RECTANGLE_COPY_Y,
RECTANGLE_WIDTH,
RECTANGLE_HEIGHT / 2,
0x0000ffff);
cogl_pop_gles2_context (test_ctx);
cogl_object_unref (offscreen);
cogl_object_unref (gles2_ctx);
cogl_object_unref (pipeline);
cogl_object_unref (offscreen_texture);
}