From 1bfeddaaeed39fa8208b7de69cfb08730343d6ce Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Fri, 6 Jun 2008 14:21:22 +0000 Subject: [PATCH] * clutter/eglnative/clutter-stage-egl.c (clutter_stage_egl_realize): Use ES 2 renderable type when building for GLES 2. * clutter/eglnative/clutter-event-egl.c (get_backend_time): Added a NULL for the microseconds parameter of g_timer_elapsed. * clutter/eglnative/clutter-stage-egl.h: * clutter/eglnative/clutter-egl.h: * clutter/eglnative/clutter-backend-egl.h: Include clutter-egl-headers.h instead of including the GL headers directly so it can include gl2.h when building for GLES 2. * clutter/eglnative/clutter-egl-headers.h: * clutter/eglnative/Makefile.am (libclutter_eglnative_la_SOURCES): Added clutter-egl-headers.h * clutter/cogl/gles/cogl-fixed-fragment-shader.glsl: GLES 2 doesn't provide a default precision for floats in the fragment shader and it will reject the shader if there isn't one. --- ChangeLog | 23 +++++++++++++ .../cogl/gles/cogl-fixed-fragment-shader.glsl | 4 +++ clutter/eglnative/Makefile.am | 3 +- clutter/eglnative/clutter-backend-egl.h | 3 +- clutter/eglnative/clutter-egl-headers.h | 33 +++++++++++++++++++ clutter/eglnative/clutter-egl.h | 3 +- clutter/eglnative/clutter-event-egl.c | 2 +- clutter/eglnative/clutter-stage-egl.c | 32 ++++++++++++------ clutter/eglnative/clutter-stage-egl.h | 3 +- 9 files changed, 88 insertions(+), 18 deletions(-) create mode 100644 clutter/eglnative/clutter-egl-headers.h diff --git a/ChangeLog b/ChangeLog index 1a2135dad..bb5929c52 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,26 @@ +2008-06-06 Neil Roberts + + * clutter/eglnative/clutter-stage-egl.c + (clutter_stage_egl_realize): Use ES 2 renderable type when + building for GLES 2. + + * clutter/eglnative/clutter-event-egl.c (get_backend_time): Added + a NULL for the microseconds parameter of g_timer_elapsed. + + * clutter/eglnative/clutter-stage-egl.h: + * clutter/eglnative/clutter-egl.h: + * clutter/eglnative/clutter-backend-egl.h: Include + clutter-egl-headers.h instead of including the GL headers directly + so it can include gl2.h when building for GLES 2. + + * clutter/eglnative/clutter-egl-headers.h: + * clutter/eglnative/Makefile.am (libclutter_eglnative_la_SOURCES): + Added clutter-egl-headers.h + + * clutter/cogl/gles/cogl-fixed-fragment-shader.glsl: GLES 2 + doesn't provide a default precision for floats in the fragment + shader and it will reject the shader if there isn't one. + 2008-06-06 Matthew Allum Bug #948 - Remove texture rectangle support diff --git a/clutter/cogl/gles/cogl-fixed-fragment-shader.glsl b/clutter/cogl/gles/cogl-fixed-fragment-shader.glsl index bb4ee4dcb..68e026160 100644 --- a/clutter/cogl/gles/cogl-fixed-fragment-shader.glsl +++ b/clutter/cogl/gles/cogl-fixed-fragment-shader.glsl @@ -1,3 +1,7 @@ +/* There is no default precision for floats in fragment shaders in + GLES 2 so we need to define one */ +precision mediump float; + /* Inputs from the vertex shader */ varying vec4 frag_color; varying vec2 tex_coord; diff --git a/clutter/eglnative/Makefile.am b/clutter/eglnative/Makefile.am index d12a931ee..6ff070464 100644 --- a/clutter/eglnative/Makefile.am +++ b/clutter/eglnative/Makefile.am @@ -17,4 +17,5 @@ libclutter_eglnative_la_SOURCES = \ clutter-backend-egl.c \ clutter-event-egl.c \ clutter-stage-egl.h \ - clutter-stage-egl.c + clutter-stage-egl.c \ + clutter-egl-headers.h diff --git a/clutter/eglnative/clutter-backend-egl.h b/clutter/eglnative/clutter-backend-egl.h index 5327e166e..516871a76 100644 --- a/clutter/eglnative/clutter-backend-egl.h +++ b/clutter/eglnative/clutter-backend-egl.h @@ -22,8 +22,7 @@ #ifndef __CLUTTER_BACKEND_EGL_H__ #define __CLUTTER_BACKEND_EGL_H__ -#include -#include +#include "clutter-egl-headers.h" #include #include diff --git a/clutter/eglnative/clutter-egl-headers.h b/clutter/eglnative/clutter-egl-headers.h new file mode 100644 index 000000000..ad7052f0c --- /dev/null +++ b/clutter/eglnative/clutter-egl-headers.h @@ -0,0 +1,33 @@ +/* Clutter. + * An OpenGL based 'interactive canvas' library. + * Authored By Matthew Allum + * Copyright (C) 2006-2007 OpenedHand + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef __CLUTTER_EGL_HEADERS_H__ +#define __CLUTTER_EGL_HEADERS_H__ + +#ifdef HAVE_COGL_GLES2 +#include +#include +#else /* HAVE_COGL_GLES2 */ +#include +#include +#endif /* HAVE_COGL_GLES2 */ + +#endif /* __CLUTTER_EGL_HEADERS_H__ */ diff --git a/clutter/eglnative/clutter-egl.h b/clutter/eglnative/clutter-egl.h index 759d0215d..aebc25c3c 100644 --- a/clutter/eglnative/clutter-egl.h +++ b/clutter/eglnative/clutter-egl.h @@ -28,8 +28,7 @@ #include -#include -#include +#include "clutter-egl-headers.h" #include diff --git a/clutter/eglnative/clutter-event-egl.c b/clutter/eglnative/clutter-event-egl.c index 240d9bc62..ea7ca08df 100644 --- a/clutter/eglnative/clutter-event-egl.c +++ b/clutter/eglnative/clutter-event-egl.c @@ -88,7 +88,7 @@ get_backend_time (void) backend_egl = CLUTTER_BACKEND_EGL (clutter_get_default_backend ()); - return g_timer_elapsed (backend_egl->event_timer) * 1000; + return g_timer_elapsed (backend_egl->event_timer, NULL) * 1000; } void diff --git a/clutter/eglnative/clutter-stage-egl.c b/clutter/eglnative/clutter-stage-egl.c index addfb33d7..e25f1959e 100644 --- a/clutter/eglnative/clutter-stage-egl.c +++ b/clutter/eglnative/clutter-stage-egl.c @@ -72,14 +72,18 @@ clutter_stage_egl_realize (ClutterActor *actor) if (G_LIKELY (!is_offscreen)) { - EGLint cfg_attribs[] = { EGL_BUFFER_SIZE, EGL_DONT_CARE, - EGL_RED_SIZE, 5, - EGL_GREEN_SIZE, 6, - EGL_BLUE_SIZE, 5, - EGL_DEPTH_SIZE, 16, - EGL_ALPHA_SIZE, EGL_DONT_CARE, - EGL_STENCIL_SIZE, 2, - EGL_SURFACE_TYPE, EGL_WINDOW_BIT, + EGLint cfg_attribs[] = { EGL_BUFFER_SIZE, EGL_DONT_CARE, + EGL_RED_SIZE, 5, + EGL_GREEN_SIZE, 6, + EGL_BLUE_SIZE, 5, + EGL_DEPTH_SIZE, 16, + EGL_ALPHA_SIZE, EGL_DONT_CARE, + EGL_STENCIL_SIZE, 2, +#ifdef HAVE_COGL_GLES2 + EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, +#else /* HAVE_COGL_GLES2 */ + EGL_SURFACE_TYPE, EGL_WINDOW_BIT, +#endif /* HAVE_COGL_GLES2 */ EGL_NONE }; status = eglGetConfigs (backend_egl->edpy, @@ -150,12 +154,20 @@ clutter_stage_egl_realize (ClutterActor *actor) if (G_UNLIKELY (backend_egl->egl_context == NULL)) { + static const EGLint attribs[3] + = { EGL_CONTEXT_CLIENT_VERSION, +#ifdef HAVE_COGL_GLES2 + 2, +#else /* HAVE_COGL_GLES2 */ + 1, +#endif + EGL_NONE }; CLUTTER_NOTE (GL, "Creating EGL Context"); backend_egl->egl_context = eglCreateContext (backend_egl->edpy, - configs[0], + configs[0], EGL_NO_CONTEXT, - NULL); + attribs); if (backend_egl->egl_context == EGL_NO_CONTEXT) { diff --git a/clutter/eglnative/clutter-stage-egl.h b/clutter/eglnative/clutter-stage-egl.h index 319cb6515..9141d67e0 100644 --- a/clutter/eglnative/clutter-stage-egl.h +++ b/clutter/eglnative/clutter-stage-egl.h @@ -4,8 +4,7 @@ #include #include -#include -#include +#include "clutter-egl-headers.h" #include "clutter-backend-egl.h" #define CLUTTER_TYPE_STAGE_EGL (clutter_stage_egl_get_type ())