diff mbox

[Branch,~glmark2-dev/glmark2/trunk] Rev 96: Merge SDL removal branch.

Message ID 20110721123637.17019.87576.launchpad@loganberry.canonical.com
State Accepted
Headers show

Commit Message

alexandros.frantzis@linaro.org July 21, 2011, 12:36 p.m. UTC
Merge authors:
  Alexandros Frantzis (afrantzis)
------------------------------------------------------------
revno: 96 [merge]
committer: Alexandros Frantzis <alexandros.frantzis@linaro.org>
timestamp: Fri 2011-07-01 10:25:44 +0300
message:
  Merge SDL removal branch.
removed:
  data/textures/crate-base.bmp
  src/glx-disable-vsync.cpp
  src/glx-disable-vsync.h
  src/oglsdl.h
  src/screen-sdl-gl.cpp
  src/screen-sdl-gl.h
  src/screen-sdl-glesv2.cpp
  src/screen-sdl-glesv2.h
  src/screen-sdl.cpp
  src/screen-sdl.h
  src/screen.h
  src/sdlgles/
  src/sdlgles/SDL_gles.c
  src/sdlgles/SDL_gles.h
  src/sdlgles/attribs.inc
added:
  data/textures/crate-base.png
  src/canvas-x11-egl.cpp
  src/canvas-x11-egl.h
  src/canvas-x11-glx.cpp
  src/canvas-x11-glx.h
  src/canvas-x11.cpp
  src/canvas-x11.h
  src/canvas.h
  src/gl-headers.h
modified:
  README
  src/libmatrix/program.cc
  src/main.cpp
  src/mesh.h
  src/options.cpp
  src/scene-build.cpp
  src/scene-shading.cpp
  src/scene-texture.cpp
  src/scene.cpp
  src/scene.h
  src/texture.cpp
  src/texture.h
  src/wscript_build
  wscript


--
lp:glmark2
https://code.launchpad.net/~glmark2-dev/glmark2/trunk

You are subscribed to branch lp:glmark2.
To unsubscribe from this branch go to https://code.launchpad.net/~glmark2-dev/glmark2/trunk/+edit-subscription
diff mbox

Patch

=== modified file 'README'
--- README	2010-07-15 10:04:49 +0000
+++ README	2011-06-30 13:33:37 +0000
@@ -3,14 +3,12 @@ 
 glmark2 was developed by Alexandros Frantzis based on the original glmark
 benchmark by Ben Smith.
 
-For the ES 2.0 variant it uses the SDL_gles addon written by Javier S. Pedro. 
-
 It is licensed under the GPLv3 (see COPYING).
 
 To build glmark2 you need:
 
  * python 2.x (>= 2.4) for the build system (waf)
- * libSDL 1.2
+ * libpng 1.2
 
 and for OpenGL 2.0:
 

=== removed file 'data/textures/crate-base.bmp'
Binary files data/textures/crate-base.bmp	2010-07-07 10:32:18 +0000 and data/textures/crate-base.bmp	1970-01-01 00:00:00 +0000 differ
=== added file 'data/textures/crate-base.png'
Binary files data/textures/crate-base.png	1970-01-01 00:00:00 +0000 and data/textures/crate-base.png	2011-06-28 16:41:09 +0000 differ
=== added file 'src/canvas-x11-egl.cpp'
--- src/canvas-x11-egl.cpp	1970-01-01 00:00:00 +0000
+++ src/canvas-x11-egl.cpp	2011-06-30 12:24:25 +0000
@@ -0,0 +1,215 @@ 
+/*
+ * Copyright © 2010-2011 Linaro Limited
+ *
+ * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
+ *
+ * glmark2 is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ *
+ * glmark2 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 General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * glmark2.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ *  Alexandros Frantzis (glmark2)
+ */
+#include "canvas-x11-egl.h"
+#include "log.h"
+#include "options.h"
+
+#include <fstream>
+#include <sstream>
+
+/*********************
+ * Protected methods *
+ *********************/
+
+XVisualInfo *
+CanvasX11EGL::get_xvisualinfo()
+{
+    XVisualInfo vis_tmpl;
+    XVisualInfo *vis_info;
+    int num_visuals;
+    EGLint vid;
+
+    if (!ensure_egl_config())
+        return 0;
+
+    if (!eglGetConfigAttrib(egl_display_, egl_config_,
+                            EGL_NATIVE_VISUAL_ID, &vid))
+    {
+        Log::error("Error: eglGetConfigAttrib() failed with error: %d\n",
+                   eglGetError());
+        return 0;
+    }
+
+    /* The X window visual must match the EGL config */
+    vis_tmpl.visualid = vid;
+    vis_info = XGetVisualInfo(xdpy_, VisualIDMask, &vis_tmpl,
+                             &num_visuals);
+    if (!vis_info) {
+        Log::error("Error: couldn't get X visual\n");
+        return 0;
+    }
+
+    return vis_info;
+}
+
+/*******************
+ * Private methods *
+ *******************/
+
+bool
+CanvasX11EGL::ensure_egl_display()
+{
+    if (egl_display_)
+        return true;
+
+    egl_display_ = eglGetDisplay((EGLNativeDisplayType) xdpy_);
+    if (!egl_display_) {
+        Log::error("Error: eglGetDisplay() failed with error: %d\n",
+                   eglGetError());
+        return false;
+    }
+    if (!eglInitialize(egl_display_, NULL, NULL)) {
+        Log::error("Error: eglInitialize() failed with error: %d\n",
+                   eglGetError());
+        return false;
+        egl_display_ = 0;
+    }
+
+    return true;
+}
+
+bool
+CanvasX11EGL::ensure_egl_config()
+{
+    static const EGLint attribs[] = {
+        EGL_RED_SIZE, 1,
+        EGL_GREEN_SIZE, 1,
+        EGL_BLUE_SIZE, 1,
+        EGL_ALPHA_SIZE, 1,
+        EGL_DEPTH_SIZE, 1,
+#ifdef USE_GLESv2
+        EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
+#elif USE_GL
+        EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
+#endif
+        EGL_NONE
+    };
+    EGLint num_configs;
+    EGLint vid;
+
+    if (egl_config_)
+        return true;
+
+    if (!ensure_egl_display())
+        return false;
+
+    if (!eglChooseConfig(egl_display_, attribs, &egl_config_,
+                         1, &num_configs))
+    {
+        Log::error("Error: eglChooseConfig() failed with error: %d\n",
+                     eglGetError());
+        return false;
+    }
+
+    if (!eglGetConfigAttrib(egl_display_, egl_config_,
+                            EGL_NATIVE_VISUAL_ID, &vid))
+    {
+        Log::error("Error: eglGetConfigAttrib() failed with error: %d\n",
+                   eglGetError());
+        return false;
+    }
+
+    if (Options::show_debug) {
+        int buf, red, green, blue, alpha, depth, id, native_id;
+        eglGetConfigAttrib(egl_display_, egl_config_, EGL_CONFIG_ID, &id);
+        eglGetConfigAttrib(egl_display_, egl_config_, EGL_NATIVE_VISUAL_ID, &native_id);
+        eglGetConfigAttrib(egl_display_, egl_config_, EGL_BUFFER_SIZE, &buf);
+        eglGetConfigAttrib(egl_display_, egl_config_, EGL_RED_SIZE, &red);
+        eglGetConfigAttrib(egl_display_, egl_config_, EGL_GREEN_SIZE, &green);
+        eglGetConfigAttrib(egl_display_, egl_config_, EGL_BLUE_SIZE, &blue);
+        eglGetConfigAttrib(egl_display_, egl_config_, EGL_ALPHA_SIZE, &alpha);
+        eglGetConfigAttrib(egl_display_, egl_config_, EGL_DEPTH_SIZE, &depth);
+        Log::debug("EGL chosen config ID: 0x%x Native Visual ID: 0x%x\n"
+                   "  Buffer: %d bits\n"
+                   "     Red: %d bits\n"
+                   "   Green: %d bits\n"
+                   "    Blue: %d bits\n"
+                   "   Alpha: %d bits\n"
+                   "   Depth: %d bits\n",
+                   id, native_id,
+                   buf, red, green, blue, alpha, depth);
+    }
+
+    return true;
+}
+
+bool
+CanvasX11EGL::ensure_egl_surface()
+{
+    static const EGLint ctx_attribs[] = {
+#ifdef USE_GLESv2
+        EGL_CONTEXT_CLIENT_VERSION, 2,
+#endif
+        EGL_NONE
+    };
+
+    if (egl_surface_)
+        return true;
+
+    if (!ensure_egl_display())
+        return false;
+
+#ifdef USE_GLESv2
+    eglBindAPI(EGL_OPENGL_ES_API);
+#elif USE_GL
+    eglBindAPI(EGL_OPENGL_API);
+#endif
+
+    egl_context_ = eglCreateContext(egl_display_, egl_config_,
+                                    EGL_NO_CONTEXT, ctx_attribs);
+    if (!egl_context_) {
+        Log::error("Error: eglCreateContext() failed with error: %d\n",
+                     eglGetError());
+        return false;
+    }
+
+    egl_surface_ = eglCreateWindowSurface(egl_display_, egl_config_,
+                                          (EGLNativeWindowType) xwin_,
+                                          NULL);
+    if (!egl_surface_) {
+        Log::error("Error: eglCreateWindowSurface failed with error: %d\n",
+                     eglGetError());
+        return false;
+    }
+
+    return true;
+}
+
+bool
+CanvasX11EGL::make_current()
+{
+    if (!ensure_egl_surface())
+        return false;
+
+    if (egl_context_ == eglGetCurrentContext())
+        return true;
+
+    if (!eglMakeCurrent(egl_display_, egl_surface_, egl_surface_, egl_context_)) {
+        Log::error("Error: eglMakeCurrent failed with error %d\n", eglGetError());
+        return false;
+    }
+
+    if (!eglSwapInterval(egl_display_, 0))
+        Log::info("** Failed to set swap interval. Results may be bounded above by refresh rate.\n");
+
+    return true;
+}

=== added file 'src/canvas-x11-egl.h'
--- src/canvas-x11-egl.h	1970-01-01 00:00:00 +0000
+++ src/canvas-x11-egl.h	2011-06-30 11:45:52 +0000
@@ -0,0 +1,55 @@ 
+/*
+ * Copyright © 2010-2011 Linaro Limited
+ *
+ * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
+ *
+ * glmark2 is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ *
+ * glmark2 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 General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * glmark2.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ *  Alexandros Frantzis (glmark2)
+ */
+#ifndef GLMARK2_CANVAS_X11_EGL_H_
+#define GLMARK2_CANVAS_X11_EGL_H_
+
+#include "canvas-x11.h"
+
+#include <EGL/egl.h>
+
+class CanvasX11EGL : public CanvasX11
+{
+public:
+    CanvasX11EGL(int width, int height) :
+        CanvasX11(width, height), egl_display_(EGL_NO_DISPLAY),
+        egl_surface_(EGL_NO_SURFACE), egl_config_(0),
+        egl_context_(EGL_NO_CONTEXT) {}
+    ~CanvasX11EGL() {}
+
+protected:
+    XVisualInfo *get_xvisualinfo();
+    bool make_current();
+    void swap_buffers() { eglSwapBuffers(egl_display_, egl_surface_); }
+
+private:
+    bool ensure_egl_display();
+    bool ensure_egl_config();
+    bool ensure_egl_surface();
+
+    EGLDisplay egl_display_;
+    EGLSurface egl_surface_;
+    EGLConfig egl_config_;
+    EGLContext egl_context_;
+};
+
+#endif
+

=== added file 'src/canvas-x11-glx.cpp'
--- src/canvas-x11-glx.cpp	1970-01-01 00:00:00 +0000
+++ src/canvas-x11-glx.cpp	2011-06-30 12:24:25 +0000
@@ -0,0 +1,208 @@ 
+/*
+ * Copyright © 2010-2011 Linaro Limited
+ *
+ * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
+ *
+ * glmark2 is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ *
+ * glmark2 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 General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * glmark2.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ *  Alexandros Frantzis (glmark2)
+ */
+#include "canvas-x11-glx.h"
+#include "log.h"
+#include "options.h"
+
+#include <string>
+
+static PFNGLXSWAPINTERVALEXTPROC glXSwapIntervalEXT_;
+static PFNGLXSWAPINTERVALMESAPROC glXSwapIntervalMESA_;
+
+/*********************
+ * Protected methods *
+ *********************/
+
+XVisualInfo *
+CanvasX11GLX::get_xvisualinfo()
+{
+    if (!ensure_glx_fbconfig())
+        return 0;
+
+    XVisualInfo *vis_info = glXGetVisualFromFBConfig(xdpy_, glx_fbconfig_ );
+
+    return vis_info;
+}
+
+bool
+CanvasX11GLX::make_current()
+{
+    if (!ensure_glx_context())
+        return false;
+
+    if (glx_context_ == glXGetCurrentContext())
+        return true;
+
+    init_extensions();
+
+    if (!glXMakeCurrent(xdpy_, xwin_, glx_context_)) {
+        Log::error("Error: glXMakeCurrent failed\n");
+        return false;
+    }
+
+    if ((!glXSwapIntervalEXT_ || glXSwapIntervalEXT_(xdpy_, xwin_, 0)) &&
+        (!glXSwapIntervalMESA_ || glXSwapIntervalMESA_(0)))
+    {
+        Log::info("** Failed to set swap interval. Results may be bounded above by refresh rate.\n");
+    }
+
+    return true;
+}
+
+
+/*******************
+ * Private methods *
+ *******************/
+
+bool
+CanvasX11GLX::check_glx_version()
+{
+    int glx_major, glx_minor;
+
+    if (!glXQueryVersion(xdpy_, &glx_major, &glx_minor ) ||
+        (glx_major == 1  && glx_minor < 3) || glx_major < 1)
+    {
+        Log::error("GLX version >= 1.3 is required\n");
+        return false;
+    }
+
+    return true;
+}
+
+void
+CanvasX11GLX::init_extensions()
+{
+    /*
+     * Parse the extensions we care about from the extension string.
+     * Don't even bother to get function pointers until we know the
+     * extension is present.
+     */
+    std::string extString;
+    const char* exts = glXQueryExtensionsString(xdpy_, 0);
+    if (exts) {
+        extString = exts;
+    }
+
+    /* 
+     * GLX_EXT_swap_control or GL_MESA_swap_control. Note that
+     * GLX_SGI_swap_control is not enough because it doesn't allow 0 as a valid
+     * value (i.e. you can't turn off VSync).
+     */
+    if (extString.find("GLX_EXT_swap_control") != std::string::npos) {
+        glXSwapIntervalEXT_ =
+            reinterpret_cast<PFNGLXSWAPINTERVALEXTPROC>(
+                glXGetProcAddress((const GLubyte *)"glXSwapIntervalEXT"));
+    }
+    else if (extString.find("GLX_MESA_swap_control") != std::string::npos) {
+        glXSwapIntervalMESA_ =
+            reinterpret_cast<PFNGLXSWAPINTERVALMESAPROC>(
+                glXGetProcAddress((const GLubyte *)"glXSwapIntervalMESA"));
+    }
+
+
+    if (!glXSwapIntervalEXT_ && !glXSwapIntervalMESA_) {
+        Log::info("** GLX does not support GLX_EXT_swap_control or GLX_MESA_swap_control!\n");
+    }
+}
+
+bool
+CanvasX11GLX::ensure_glx_fbconfig()
+{
+    static int attribs[] = {
+        GLX_X_RENDERABLE, True,
+        GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT,
+        GLX_RENDER_TYPE, GLX_RGBA_BIT,
+        GLX_X_VISUAL_TYPE, GLX_TRUE_COLOR,
+        GLX_RED_SIZE, 1,
+        GLX_GREEN_SIZE, 1,
+        GLX_BLUE_SIZE, 1,
+        GLX_ALPHA_SIZE, 1,
+        GLX_DEPTH_SIZE, 1,
+        GLX_DOUBLEBUFFER, True,
+        None
+    };
+    int num_configs;
+
+    if (glx_fbconfig_)
+        return true;
+
+    if (!check_glx_version())
+        return false;
+
+    GLXFBConfig *fbc = glXChooseFBConfig(xdpy_, DefaultScreen(xdpy_),
+                                         attribs, &num_configs);
+    if (!fbc) {
+        Log::error("Error: glXChooseFBConfig() failed\n");
+        return false;
+    }
+
+    Log::debug("Found %d matching FB configs.\n", num_configs);
+
+    /* Get the first matching config */
+    glx_fbconfig_ = fbc[0];
+
+    XFree(fbc);
+
+    if (Options::show_debug) {
+        int buf, red, green, blue, alpha, depth, id, native_id;
+        glXGetFBConfigAttrib(xdpy_, glx_fbconfig_, GLX_FBCONFIG_ID, &id);
+        glXGetFBConfigAttrib(xdpy_, glx_fbconfig_, GLX_VISUAL_ID, &native_id);
+        glXGetFBConfigAttrib(xdpy_, glx_fbconfig_, GLX_BUFFER_SIZE, &buf);
+        glXGetFBConfigAttrib(xdpy_, glx_fbconfig_, GLX_RED_SIZE, &red);
+        glXGetFBConfigAttrib(xdpy_, glx_fbconfig_, GLX_GREEN_SIZE, &green);
+        glXGetFBConfigAttrib(xdpy_, glx_fbconfig_, GLX_BLUE_SIZE, &blue);
+        glXGetFBConfigAttrib(xdpy_, glx_fbconfig_, GLX_ALPHA_SIZE, &alpha);
+        glXGetFBConfigAttrib(xdpy_, glx_fbconfig_, GLX_DEPTH_SIZE, &depth);
+        Log::debug("GLX chosen config ID: 0x%x Native Visual ID: 0x%x\n"
+                   "  Buffer: %d bits\n"
+                   "     Red: %d bits\n"
+                   "   Green: %d bits\n"
+                   "    Blue: %d bits\n"
+                   "   Alpha: %d bits\n"
+                   "   Depth: %d bits\n",
+                   id, native_id,
+                   buf, red, green, blue, alpha, depth);
+    }
+
+
+    return true;
+}
+
+bool
+CanvasX11GLX::ensure_glx_context()
+{
+    if (glx_context_)
+        return true;
+
+    if (!ensure_glx_fbconfig())
+        return false;
+
+    glx_context_ = glXCreateNewContext(xdpy_, glx_fbconfig_, GLX_RGBA_TYPE,
+                                       0, True);
+    if (!glx_context_) {
+        Log::error("Error: glXCreateNewContext failed\n");
+        return false;
+    }
+
+    return true;
+}
+

=== added file 'src/canvas-x11-glx.h'
--- src/canvas-x11-glx.h	1970-01-01 00:00:00 +0000
+++ src/canvas-x11-glx.h	2011-06-30 12:17:09 +0000
@@ -0,0 +1,55 @@ 
+/*
+ * Copyright © 2010-2011 Linaro Limited
+ *
+ * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
+ *
+ * glmark2 is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ *
+ * glmark2 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 General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * glmark2.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ *  Alexandros Frantzis (glmark2)
+ */
+#ifndef GLMARK2_CANVAS_X11_GLX_H_
+#define GLMARK2_CANVAS_X11_GLX_H_
+
+#include "canvas-x11.h"
+
+#define GLX_GLXEXT_PROTOTYPES
+#include <GL/glx.h>
+#include <GL/glxext.h>
+
+class CanvasX11GLX : public CanvasX11
+{
+public:
+    CanvasX11GLX(int width, int height) :
+        CanvasX11(width, height), glx_fbconfig_(0), glx_context_(0) {}
+    ~CanvasX11GLX() {}
+
+protected:
+    XVisualInfo *get_xvisualinfo();
+    bool make_current();
+    void swap_buffers() { glXSwapBuffers(xdpy_, xwin_); }
+
+private:
+    bool check_glx_version();
+    void init_extensions();
+    bool ensure_glx_fbconfig();
+    bool ensure_glx_context();
+
+    GLXFBConfig glx_fbconfig_;
+    GLXContext glx_context_;
+
+};
+
+#endif
+

=== added file 'src/canvas-x11.cpp'
--- src/canvas-x11.cpp	1970-01-01 00:00:00 +0000
+++ src/canvas-x11.cpp	2011-06-30 14:01:43 +0000
@@ -0,0 +1,195 @@ 
+/*
+ * Copyright © 2010-2011 Linaro Limited
+ *
+ * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
+ *
+ * glmark2 is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ *
+ * glmark2 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 General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * glmark2.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ *  Alexandros Frantzis (glmark2)
+ */
+#include "canvas-x11.h"
+#include "log.h"
+#include "options.h"
+
+#include <X11/keysym.h>
+#include <fstream>
+#include <sstream>
+
+static Window
+create_canvas_x_window(Display *xdpy, const char *name, int width, int height,
+                       const XVisualInfo *vis_info)
+{
+    XSetWindowAttributes attr;
+    unsigned long mask;
+    Window win = 0;
+    Window root = RootWindow(xdpy, DefaultScreen(xdpy));
+
+    Log::debug("Creating XWindow W: %d H: %d VisualID: 0x%x\n",
+               width, height, (int)vis_info->visualid);
+    /* window attributes */
+    attr.background_pixel = 0;
+    attr.border_pixel = 0;
+    attr.colormap = XCreateColormap(xdpy, root, vis_info->visual, AllocNone);
+    attr.event_mask = KeyPressMask;
+    mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
+
+    win = XCreateWindow(xdpy, root, 0, 0, width, height,
+                        0, vis_info->depth, InputOutput,
+                        vis_info->visual, mask, &attr);
+
+    /* set hints and properties */
+    {
+        XSizeHints sizehints;
+        sizehints.min_width  = width;
+        sizehints.min_height = height;
+        sizehints.max_width  = width;
+        sizehints.max_height = height;
+        sizehints.flags = PMaxSize | PMinSize;
+        XSetNormalHints(xdpy, win, &sizehints);
+        XSetStandardProperties(xdpy, win, name, name,
+                               None, NULL, 0, &sizehints);
+    }
+
+    /* Gracefully handle Window Delete event from window manager */
+    Atom wmDelete = XInternAtom(xdpy, "WM_DELETE_WINDOW", True);
+    XSetWMProtocols(xdpy, win, &wmDelete, 1);
+
+    return win;
+}
+
+bool
+CanvasX11::init()
+{
+    xdpy_ = XOpenDisplay(NULL);
+    if (!xdpy_)
+        return false;
+
+    XVisualInfo *visinfo = get_xvisualinfo();
+
+    xwin_ = create_canvas_x_window(xdpy_, "glmark2 "GLMARK_VERSION, mWidth, mHeight, visinfo);
+
+    XFree(visinfo);
+
+    if (!xwin_)
+        return false;
+
+    if (!make_current())
+        return false;
+
+    glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
+#if USE_GL
+    glClearDepth(1.0f);
+#elif USE_GLESv2
+    glClearDepthf(1.0f);
+#endif
+    glEnable(GL_DEPTH_TEST);
+    glDepthFunc(GL_LEQUAL);
+    glEnable(GL_CULL_FACE);
+    glCullFace(GL_BACK);
+
+    glViewport(0, 0, mWidth, mHeight);
+
+    clear();
+
+    mProjection = LibMatrix::Mat4::perspective(60.0, mWidth / (float)mHeight,
+                                               1.0, 1024.0);
+
+    return true;
+}
+
+void
+CanvasX11::visible(bool visible)
+{
+    if (visible)
+        XMapWindow(xdpy_, xwin_);
+}
+
+void
+CanvasX11::clear()
+{
+    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+}
+
+void
+CanvasX11::update()
+{
+    if (Options::swap_buffers)
+        swap_buffers();
+    else
+        glFinish();
+}
+
+void
+CanvasX11::print_info()
+{
+    make_current();
+
+    std::stringstream ss;
+
+    ss << "    OpenGL Information" << std::endl;
+    ss << "    GL_VENDOR:     " << glGetString(GL_VENDOR) << std::endl;
+    ss << "    GL_RENDERER:   " << glGetString(GL_RENDERER) << std::endl;
+    ss << "    GL_VERSION:    " << glGetString(GL_VERSION) << std::endl;
+
+    Log::info("%s", ss.str().c_str());
+}
+
+Canvas::Pixel
+CanvasX11::read_pixel(int x, int y)
+{
+    uint8_t pixel[4];
+
+    glReadPixels(x, y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixel);
+
+    return Canvas::Pixel(pixel[0], pixel[1], pixel[2], pixel[3]);
+}
+
+void
+CanvasX11::write_to_file(std::string &filename)
+{
+    char *pixels = new char[mWidth * mHeight * 4];
+
+    for (int i = 0; i < mHeight; i++) {
+        glReadPixels(0, i, mWidth, 1, GL_RGBA, GL_UNSIGNED_BYTE,
+                     &pixels[(mHeight - i - 1) * mWidth * 4]);
+    }
+
+    std::ofstream output (filename.c_str(), std::ios::out | std::ios::binary);
+    output.write(pixels, 4 * mWidth * mHeight);
+
+    delete [] pixels;
+}
+
+bool
+CanvasX11::should_quit()
+{ 
+    XEvent event;
+
+    if (!XPending(xdpy_))
+        return false;
+
+    XNextEvent(xdpy_, &event);
+
+    if (event.type == KeyPress) {
+        if (XLookupKeysym(&event.xkey, 0) == XK_Escape)
+            return true;
+    }
+    else if (event.type == ClientMessage) {
+        /* Window Delete event from window manager */
+        return true;
+    }
+
+    return false;
+}

=== added file 'src/canvas-x11.h'
--- src/canvas-x11.h	1970-01-01 00:00:00 +0000
+++ src/canvas-x11.h	2011-06-30 13:13:14 +0000
@@ -0,0 +1,55 @@ 
+/*
+ * Copyright © 2010-2011 Linaro Limited
+ *
+ * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
+ *
+ * glmark2 is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ *
+ * glmark2 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 General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * glmark2.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ *  Alexandros Frantzis (glmark2)
+ */
+#ifndef GLMARK2_CANVAS_X11_H_
+#define GLMARK2_CANVAS_X11_H_
+
+#include "canvas.h"
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+
+class CanvasX11 : public Canvas
+{
+public:
+    ~CanvasX11() {}
+
+    virtual bool init();
+    virtual void visible(bool visible);
+    virtual void clear();
+    virtual void update();
+    virtual void print_info();
+    virtual Pixel read_pixel(int x, int y);
+    virtual void write_to_file(std::string &filename);
+    virtual bool should_quit();
+
+protected:
+    CanvasX11(int width, int height) : Canvas(width, height) {}
+
+    virtual XVisualInfo *get_xvisualinfo() = 0;
+    virtual bool make_current() = 0;
+    virtual void swap_buffers() = 0;
+
+    Window xwin_;
+    Display *xdpy_;
+};
+
+#endif
+

=== added file 'src/canvas.h'
--- src/canvas.h	1970-01-01 00:00:00 +0000
+++ src/canvas.h	2011-06-30 13:39:21 +0000
@@ -0,0 +1,90 @@ 
+/*
+ * Copyright © 2008 Ben Smith
+ * Copyright © 2010-2011 Linaro Limited
+ *
+ * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
+ *
+ * glmark2 is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ *
+ * glmark2 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 General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * glmark2.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ *  Ben Smith (original glmark benchmark)
+ *  Alexandros Frantzis (glmark2)
+ */
+#ifndef GLMARK2_CANVAS_H_
+#define GLMARK2_CANVAS_H_
+
+#include "gl-headers.h"
+#include "mat.h"
+
+#include <sys/types.h>
+#include <string>
+#include <stdio.h>
+
+class Canvas
+{
+public:
+    ~Canvas() {}
+
+    struct Pixel {
+        Pixel():
+            r(0), g(0), b(0), a(0) {}
+        Pixel(uint8_t r, uint8_t g, uint8_t b, uint8_t a):
+            r(r), g(g), b(b), a(a) {}
+        uint32_t to_le32()
+        {
+            return static_cast<uint32_t>(r) +
+                   (static_cast<uint32_t>(g) << 8) +
+                   (static_cast<uint32_t>(b) << 16) +
+                   (static_cast<uint32_t>(a) << 24);
+
+        }
+        uint8_t r;
+        uint8_t g;
+        uint8_t b;
+        uint8_t a;
+    };
+
+    virtual bool init() { return false; }
+    virtual void visible(bool visible) { (void)visible; }
+    virtual void clear() {}
+    virtual void update() {}
+    virtual void print_info() {}
+    virtual Pixel read_pixel(int x, int y)
+    {
+        (void)x;
+        (void)y;
+        return Pixel();
+    }
+    virtual void write_to_file(std::string &filename) { (void)filename; }
+    virtual bool should_quit() { return false; }
+
+    static Canvas &dummy()
+    {
+        static Canvas dummy_canvas(0, 0);
+        return dummy_canvas;
+    }
+
+    int width() { return mWidth; }
+    int height() { return mWidth; }
+    const LibMatrix::mat4 &projection() { return mProjection; }
+
+protected:
+    Canvas(int width, int height) : mWidth(width), mHeight(height) {}
+
+    int mWidth;
+    int mHeight;
+    LibMatrix::mat4 mProjection;
+};
+
+#endif

=== added file 'src/gl-headers.h'
--- src/gl-headers.h	1970-01-01 00:00:00 +0000
+++ src/gl-headers.h	2011-06-30 13:33:37 +0000
@@ -0,0 +1,34 @@ 
+/*
+ * Copyright © 2010-2011 Linaro Limited
+ *
+ * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
+ *
+ * glmark2 is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ *
+ * glmark2 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 General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * glmark2.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ *  Alexandros Frantzis (glmark2)
+ */
+#ifndef GLMARK2_GL_HEADERS_H_
+#define GLMARK2_GL_HEADERS_H_
+
+#if USE_GL
+#define GL_GLEXT_PROTOTYPES
+#include <GL/gl.h>
+#include <GL/glext.h>
+#elif USE_GLESv2
+#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
+#endif
+
+#endif

=== removed file 'src/glx-disable-vsync.cpp'
--- src/glx-disable-vsync.cpp	2011-06-24 11:47:33 +0000
+++ src/glx-disable-vsync.cpp	1970-01-01 00:00:00 +0000
@@ -1,86 +0,0 @@ 
-/*
- * Copyright © 2010-2011 Linaro Limited
- *
- * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
- *
- * glmark2 is free software: you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation, either version 3 of the License, or (at your option) any later
- * version.
- *
- * glmark2 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 General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * glmark2.  If not, see <http://www.gnu.org/licenses/>.
- *
- * Authors:
- *  Alexandros Frantzis (glmark2)
- */
-
-#if USE_GL
-
-#include "glx-disable-vsync.h"
-#include <SDL_syswm.h>
-#include <GL/gl.h>
-#include <GL/glx.h>
-#include <X11/Xlib.h>
-
-#include <string>
-#include "log.h"
-
-PFNGLXSWAPINTERVALEXTPROC glXSwapIntervalEXT_ = 0;
-PFNGLXSWAPINTERVALMESAPROC glXSwapIntervalMESA_ = 0;
-
-void
-glx_disable_vsync()
-{
-    SDL_SysWMinfo info;
-    SDL_VERSION(&info.version);
-
-    if (SDL_GetWMInfo(&info) != 1) {
-        Log::error("Couldn't get windowing system info from SDL.\n");
-        return;
-    }
-
-    Display *display = info.info.x11.gfxdisplay;
-    Window window = info.info.x11.window;
-
-    std::string extString;
-    const char* exts = glXQueryExtensionsString(display, 0);
-    if (exts) {
-        extString = exts;
-    }
-
-    /*
-     * GLX_EXT_swap_control or GL_MESA_swap_control. Note that
-     * GLX_SGI_swap_control is not enough because it doesn't allow 0 as a valid
-     * value (i.e. we can't turn off VSync).
-     */
-    if (extString.find("GLX_EXT_swap_control") != std::string::npos) {
-        glXSwapIntervalEXT_ =
-            reinterpret_cast<PFNGLXSWAPINTERVALEXTPROC>(
-                glXGetProcAddress((const GLubyte *)"glXSwapIntervalEXT"));
-    }
-    else if (extString.find("GLX_MESA_swap_control") != std::string::npos) {
-        glXSwapIntervalMESA_ =
-            reinterpret_cast<PFNGLXSWAPINTERVALMESAPROC>(
-                glXGetProcAddress((const GLubyte *)"glXSwapIntervalMESA"));
-    }
-
-
-    if (!glXSwapIntervalEXT_ && !glXSwapIntervalMESA_) {
-        Log::info("** GLX does not support GLX_EXT_swap_control or GLX_MESA_swap_control!\n");
-    }
-
-    /* Turn off VSync */
-    if ((!glXSwapIntervalEXT_ || glXSwapIntervalEXT_(display, window, 0)) &&
-        (!glXSwapIntervalMESA_ || glXSwapIntervalMESA_(0)))
-    {
-        Log::info("** Failed to set swap interval. Results may be bounded above by refresh rate.\n");
-    }
-}
-
-#endif

=== removed file 'src/glx-disable-vsync.h'
--- src/glx-disable-vsync.h	2011-06-24 11:47:33 +0000
+++ src/glx-disable-vsync.h	1970-01-01 00:00:00 +0000
@@ -1,28 +0,0 @@ 
-/*
- * Copyright © 2010-2011 Linaro Limited
- *
- * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
- *
- * glmark2 is free software: you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation, either version 3 of the License, or (at your option) any later
- * version.
- *
- * glmark2 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 General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * glmark2.  If not, see <http://www.gnu.org/licenses/>.
- *
- * Authors:
- *  Alexandros Frantzis (glmark2)
- */
-
-#ifndef GLMARK2_GLX_DISABLE_VSYNC_H_
-#define GLMARK2_GLX_DISABLE_VSYNC_H_
-
-void glx_disable_vsync();
-
-#endif

=== modified file 'src/libmatrix/program.cc'
--- src/libmatrix/program.cc	2011-06-17 13:09:21 +0000
+++ src/libmatrix/program.cc	2011-06-30 13:33:37 +0000
@@ -15,7 +15,7 @@ 
 #include <fstream>
 #include <iostream>
 
-#include "oglsdl.h"
+#include "gl-headers.h"
 #include "program.h"
 
 using std::string;

=== modified file 'src/main.cpp'
--- src/main.cpp	2011-06-23 12:32:34 +0000
+++ src/main.cpp	2011-06-30 13:33:37 +0000
@@ -21,7 +21,7 @@ 
  *  Ben Smith (original glmark benchmark)
  *  Alexandros Frantzis (glmark2)
  */
-#include "oglsdl.h"
+#include "gl-headers.h"
 #include "scene.h"
 #include "benchmark.h"
 #include "options.h"
@@ -30,9 +30,9 @@ 
 #include <iostream>
 
 #if USE_GL
-#include "screen-sdl-gl.h"
+#include "canvas-x11-glx.h"
 #elif USE_GLESv2
-#include "screen-sdl-glesv2.h"
+#include "canvas-x11-egl.h"
 #endif
 
 using std::vector;
@@ -50,28 +50,6 @@ 
     NULL
 };
 
-bool should_keep_running()
-{
-    bool running = true;
-    SDL_Event event;
-
-    while(SDL_PollEvent(&event))
-    {
-        switch(event.type)
-        {
-            case SDL_QUIT:
-                running = false;
-                break;
-            case SDL_KEYDOWN:
-                if(event.key.keysym.sym == SDLK_ESCAPE)
-                    running = false;
-                break;
-        }
-    }
-
-    return running;
-}
-
 void
 add_default_benchmarks(vector<Benchmark *> &benchmarks)
 {
@@ -122,7 +100,7 @@ 
 }
 
 void
-do_benchmark(Screen &screen, vector<Benchmark *> &benchmarks)
+do_benchmark(Canvas &canvas, vector<Benchmark *> &benchmarks)
 {
     unsigned score = 0;
 
@@ -139,14 +117,14 @@ 
             Log::flush();
 
             while (scene.is_running() &&
-                   (keep_running = should_keep_running()))
+                   (keep_running = !canvas.should_quit()))
             {
-                screen.clear();
+                canvas.clear();
 
                 scene.draw();
                 scene.update();
 
-                screen.update();
+                canvas.update();
             }
 
             Log::info(" FPS: %u\n", scene.average_fps());
@@ -166,7 +144,7 @@ 
 }
 
 void
-do_validation(Screen &screen, vector<Benchmark *> &benchmarks)
+do_validation(Canvas &canvas, vector<Benchmark *> &benchmarks)
 {
     for (vector<Benchmark *>::iterator bench_iter = benchmarks.begin();
          bench_iter != benchmarks.end();
@@ -179,9 +157,9 @@ 
             Log::info("%s", scene.info_string().c_str());
             Log::flush();
 
-            screen.clear();
+            canvas.clear();
             scene.draw();
-            screen.update();
+            canvas.update();
 
             string result;
             switch(scene.validate()) {
@@ -216,29 +194,29 @@ 
         return 0;
     }
 
-    // Create the screen
+    // Create the canvas
 #if USE_GL
-    ScreenSDLGL screen(800, 600, 24, 0);
+    CanvasX11GLX canvas(800, 600);
 #elif USE_GLESv2
-    ScreenSDLGLESv2 screen(800, 600, 24, 0);
+    CanvasX11EGL canvas(800, 600);
 #endif
 
-    if (!screen.mInitSuccess) {
-        Log::error("Error: %s: Could not initialize screen\n", __FUNCTION__);
-        return 1;
-    }
-
     // Register the scenes, so they can be looked-up by name
-    Benchmark::register_scene(*new SceneDefaultOptions(screen));
-    Benchmark::register_scene(*new SceneBuild(screen));
-    Benchmark::register_scene(*new SceneTexture(screen));
-    Benchmark::register_scene(*new SceneShading(screen));
+    Benchmark::register_scene(*new SceneDefaultOptions(canvas));
+    Benchmark::register_scene(*new SceneBuild(canvas));
+    Benchmark::register_scene(*new SceneTexture(canvas));
+    Benchmark::register_scene(*new SceneShading(canvas));
 
     if (Options::list_scenes) {
         list_scenes();
         return 0;
     }
 
+    if (!canvas.init()) {
+        Log::error("Error: %s: Could not initialize canvas\n", __FUNCTION__);
+        return 1;
+    }
+
     // Add the benchmarks to run
     vector<Benchmark *> benchmarks;
 
@@ -250,13 +228,15 @@ 
     Log::info("=======================================================\n");
     Log::info("    glmark2 %s\n", GLMARK_VERSION);
     Log::info("=======================================================\n");
-    screen.print_info();
+    canvas.print_info();
     Log::info("=======================================================\n");
 
+    canvas.visible(true);
+
     if (Options::validate)
-        do_validation(screen, benchmarks);
+        do_validation(canvas, benchmarks);
     else
-        do_benchmark(screen, benchmarks);
+        do_benchmark(canvas, benchmarks);
 
     return 0;
 }

=== modified file 'src/mesh.h'
--- src/mesh.h	2011-06-17 13:16:16 +0000
+++ src/mesh.h	2011-06-30 08:38:35 +0000
@@ -24,7 +24,7 @@ 
 #ifndef GLMARK2_MESH_H_
 #define GLMARK2_MESH_H_
 
-#include "screen.h"
+#include "canvas.h"
 #include "vec.h"
 
 #include <stdio.h>

=== removed file 'src/oglsdl.h'
--- src/oglsdl.h	2011-03-08 23:12:05 +0000
+++ src/oglsdl.h	1970-01-01 00:00:00 +0000
@@ -1,38 +0,0 @@ 
-/*
- * Copyright © 2008 Ben Smith
- * Copyright © 2010-2011 Linaro Limited
- *
- * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
- *
- * glmark2 is free software: you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation, either version 3 of the License, or (at your option) any later
- * version.
- *
- * glmark2 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 General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * glmark2.  If not, see <http://www.gnu.org/licenses/>.
- *
- * Authors:
- *  Ben Smith (original glmark benchmark)
- *  Alexandros Frantzis (glmark2)
- */
-#ifndef GLMARK2_OGLSDL_H_
-#define GLMARK2_OGLSDL_H_
-
-#include <SDL/SDL.h>
-
-#if USE_GL
-#define GL_GLEXT_PROTOTYPES
-#include <GL/gl.h>
-#include <GL/glext.h>
-#elif USE_GLESv2
-#include <GLES2/gl2.h>
-#include <GLES2/gl2ext.h>
-#endif
-
-#endif

=== modified file 'src/options.cpp'
--- src/options.cpp	2011-06-15 11:25:14 +0000
+++ src/options.cpp	2011-06-30 08:38:35 +0000
@@ -55,7 +55,7 @@ 
            "                         (the option can be used multiple times)\n"
            "      --validate         Run a quick output validation test instead of \n"
            "                         running the benchmarks\n"
-           "      --no-swap-buffers  Don't update the screen by swapping the front and\n"
+           "      --no-swap-buffers  Don't update the canvas by swapping the front and\n"
            "                         back buffer, use glFinish() instead\n"
            "  -l, --list-scenes      Display information about the available scenes\n"
            "                         and their options\n"

=== modified file 'src/scene-build.cpp'
--- src/scene-build.cpp	2011-06-23 12:48:15 +0000
+++ src/scene-build.cpp	2011-06-30 15:07:34 +0000
@@ -27,8 +27,8 @@ 
 #include "stack.h"
 #include <cmath>
 
-SceneBuild::SceneBuild(Screen &pScreen) :
-    Scene(pScreen, "build")
+SceneBuild::SceneBuild(Canvas &pCanvas) :
+    Scene(pCanvas, "build")
 {
     mOptions["use-vbo"] = Scene::Option("use-vbo", "true",
                                         "Whether to use VBOs for rendering [true,false]");
@@ -97,7 +97,7 @@ 
     mCurrentFrame = 0;
     mRotation = 0.0;
     mRunning = true;
-    mStartTime = SDL_GetTicks() / 1000.0;
+    mStartTime = Scene::get_timestamp_us() / 1000000.0;
     mLastUpdateTime = mStartTime;
 }
 
@@ -114,7 +114,7 @@ 
 
 void SceneBuild::update()
 {
-    double current_time = SDL_GetTicks() / 1000.0;
+    double current_time = Scene::get_timestamp_us() / 1000000.0;
     double dt = current_time - mLastUpdateTime;
     double elapsed_time = current_time - mStartTime;
 
@@ -135,7 +135,7 @@ 
     LibMatrix::Stack4 model_view;
 
     // Load the ModelViewProjectionMatrix uniform in the shader
-    LibMatrix::mat4 model_view_proj(mScreen.mProjection);
+    LibMatrix::mat4 model_view_proj(mCanvas.projection());
 
     model_view.translate(0.0f, 0.0f, -2.5f);
     model_view.rotate(mRotation, 0.0f, 1.0f, 0.0f);
@@ -169,9 +169,9 @@ 
     if (mRotation != 0)
         return Scene::ValidationUnknown;
 
-    Screen::Pixel ref(0xa7, 0xa7, 0xa7, 0xff);
-    Screen::Pixel pixel = mScreen.read_pixel(mScreen.mWidth / 2,
-                                             mScreen.mHeight / 2);
+    Canvas::Pixel ref(0xcf, 0xcf, 0xcf, 0xff);
+    Canvas::Pixel pixel = mCanvas.read_pixel(mCanvas.width() / 2,
+                                             mCanvas.height() / 2);
 
     double dist = pixel_value_distance(pixel, ref);
     if (dist < radius_3d + 0.01) {

=== modified file 'src/scene-shading.cpp'
--- src/scene-shading.cpp	2011-06-23 12:48:15 +0000
+++ src/scene-shading.cpp	2011-06-30 15:07:34 +0000
@@ -29,8 +29,8 @@ 
 
 #include <cmath>
 
-SceneShading::SceneShading(Screen &pScreen) :
-    Scene(pScreen, "shading")
+SceneShading::SceneShading(Canvas &pCanvas) :
+    Scene(pCanvas, "shading")
 {
     mOptions["shading"] = Scene::Option("shading", "gouraud",
                                         "[gouraud, phong]");
@@ -121,7 +121,7 @@ 
     mCurrentFrame = 0;
     mRotation = 0.0f;
     mRunning = true;
-    mStartTime = SDL_GetTicks() / 1000.0;
+    mStartTime = Scene::get_timestamp_us() / 1000000.0;
     mLastUpdateTime = mStartTime;
 }
 
@@ -135,7 +135,7 @@ 
 
 void SceneShading::update()
 {
-    double current_time = SDL_GetTicks() / 1000.0;
+    double current_time = Scene::get_timestamp_us() / 1000000.0;
     double dt = current_time - mLastUpdateTime;
     double elapsed_time = current_time - mStartTime;
 
@@ -155,7 +155,7 @@ 
 {
     // Load the ModelViewProjectionMatrix uniform in the shader
     LibMatrix::Stack4 model_view;
-    LibMatrix::mat4 model_view_proj(mScreen.mProjection);
+    LibMatrix::mat4 model_view_proj(mCanvas.projection());
 
     model_view.translate(0.0f, 0.0f, -5.0f);
     model_view.rotate(mRotation, 0.0f, 1.0f, 0.0f);
@@ -182,17 +182,17 @@ 
     if (mRotation != 0) 
         return Scene::ValidationUnknown;
 
-    Screen::Pixel ref;
+    Canvas::Pixel ref;
 
-    Screen::Pixel pixel = mScreen.read_pixel(mScreen.mWidth / 2,
-                                             mScreen.mHeight / 2);
+    Canvas::Pixel pixel = mCanvas.read_pixel(mCanvas.width() / 3,
+                                             mCanvas.height() / 3);
 
     const std::string &filter = mOptions["shading"].value;
 
     if (filter == "gouraud")
-        ref = Screen::Pixel(0x00, 0x00, 0xca, 0xff);
+        ref = Canvas::Pixel(0x00, 0x00, 0x76, 0xff);
     else if (filter == "phong")
-        ref = Screen::Pixel(0x1a, 0x1a, 0xbb, 0xff);
+        ref = Canvas::Pixel(0x1a, 0x1a, 0x79, 0xff);
     else
         return Scene::ValidationUnknown;
 

=== modified file 'src/scene-texture.cpp'
--- src/scene-texture.cpp	2011-06-24 08:04:32 +0000
+++ src/scene-texture.cpp	2011-06-30 15:07:34 +0000
@@ -30,8 +30,8 @@ 
 #include "program.h"
 #include <cmath>
 
-SceneTexture::SceneTexture(Screen &pScreen) :
-    Scene(pScreen, "texture")
+SceneTexture::SceneTexture(Canvas &pCanvas) :
+    Scene(pCanvas, "texture")
 {
     mOptions["texture-filter"] = Scene::Option("texture-filter", "nearest",
                                                "[nearest, linear, mipmap]");
@@ -103,7 +103,7 @@ 
         mag_filter = GL_LINEAR;
     }
 
-    Texture::load(GLMARK_DATA_PATH"/textures/crate-base.bmp", &mTexture,
+    Texture::load(GLMARK_DATA_PATH"/textures/crate-base.png", &mTexture,
                   min_filter, mag_filter, 0);
 
     mProgram.start();
@@ -117,7 +117,7 @@ 
     mCurrentFrame = 0;
     mRotation = LibMatrix::vec3();
     mRunning = true;
-    mStartTime = SDL_GetTicks() / 1000.0;
+    mStartTime = Scene::get_timestamp_us() / 1000000.0;
     mLastUpdateTime = mStartTime;
 }
 
@@ -131,7 +131,7 @@ 
 
 void SceneTexture::update()
 {
-    double current_time = SDL_GetTicks() / 1000.0;
+    double current_time = Scene::get_timestamp_us() / 1000000.0;
     double dt = current_time - mLastUpdateTime;
     double elapsed_time = current_time - mStartTime;
 
@@ -151,7 +151,7 @@ 
 {
     // Load the ModelViewProjectionMatrix uniform in the shader
     LibMatrix::Stack4 model_view;
-    LibMatrix::mat4 model_view_proj(mScreen.mProjection);
+    LibMatrix::mat4 model_view_proj(mCanvas.projection());
 
     model_view.translate(0.0f, 0.0f, -5.0f);
     model_view.rotate(mRotation.x(), 1.0f, 0.0f, 0.0f);
@@ -183,19 +183,19 @@ 
     if (mRotation.x() != 0 || mRotation.y() != 0 || mRotation.z() != 0)
         return Scene::ValidationUnknown;
 
-    Screen::Pixel ref;
+    Canvas::Pixel ref;
 
-    Screen::Pixel pixel = mScreen.read_pixel(mScreen.mWidth / 2 - 3,
-                                             mScreen.mHeight / 2 - 3);
+    Canvas::Pixel pixel = mCanvas.read_pixel(mCanvas.width() / 2 - 3,
+                                             mCanvas.height() / 2 - 3);
 
     const std::string &filter = mOptions["texture-filter"].value;
 
     if (filter == "nearest")
-        ref = Screen::Pixel(0x2b, 0x2a, 0x28, 0xff);
+        ref = Canvas::Pixel(0x24, 0x22, 0x23, 0xff);
     else if (filter == "linear")
-        ref = Screen::Pixel(0x2c, 0x2b, 0x29, 0xff);
+        ref = Canvas::Pixel(0x29, 0x27, 0x28, 0xff);
     else if (filter == "mipmap")
-        ref = Screen::Pixel(0x2d, 0x2c, 0x2a, 0xff);
+        ref = Canvas::Pixel(0x2c, 0x2a, 0x2b, 0xff);
     else
         return Scene::ValidationUnknown;
 

=== modified file 'src/scene.cpp'
--- src/scene.cpp	2011-06-23 12:32:34 +0000
+++ src/scene.cpp	2011-06-30 12:39:37 +0000
@@ -25,13 +25,14 @@ 
 #include "log.h"
 #include <sstream>
 #include <cmath>
+#include <sys/time.h>
 
 using std::stringstream;
 using std::string;
 using std::map;
 
-Scene::Scene(Screen &pScreen, const string &name) :
-    mScreen(pScreen), mName(name),
+Scene::Scene(Canvas &pCanvas, const string &name) :
+    mCanvas(pCanvas), mName(name),
     mStartTime(0), mLastUpdateTime(0), mCurrentFrame(0), mAverageFPS(0), 
     mRunning(0), mDuration(0)
 {
@@ -152,7 +153,7 @@ 
 }
 
 double
-Scene::pixel_value_distance(Screen::Pixel p1, Screen::Pixel p2,
+Scene::pixel_value_distance(Canvas::Pixel p1, Canvas::Pixel p2,
                             bool use_alpha)
 {
     double s(0.0);
@@ -215,3 +216,13 @@ 
 
     return true;
 }
+
+uint64_t
+Scene::get_timestamp_us()
+{
+    struct timeval tv;
+    gettimeofday(&tv, NULL);
+    uint64_t now = static_cast<uint64_t>(tv.tv_sec) * 1000000 +
+                   static_cast<double>(tv.tv_usec);
+    return now;
+}

=== modified file 'src/scene.h'
--- src/scene.h	2011-06-23 12:32:34 +0000
+++ src/scene.h	2011-06-30 13:33:37 +0000
@@ -24,7 +24,7 @@ 
 #ifndef GLMARK2_SCENE_H_
 #define GLMARK2_SCENE_H_
 
-#include "oglsdl.h"
+#include "gl-headers.h"
 
 #include "mesh.h"
 #include "model.h"
@@ -87,7 +87,7 @@ 
 
     static Scene &dummy()
     {
-        static Scene dummy_scene(Screen::dummy(), "");
+        static Scene dummy_scene(Canvas::dummy(), "");
         return dummy_scene;
     }
 
@@ -97,13 +97,15 @@ 
                              const std::string &vtx_shader_filename,
                              const std::string &frg_shader_filename);
 
+    static uint64_t get_timestamp_us();
+
 protected:
-    Scene(Screen &pScreen, const std::string &name);
+    Scene(Canvas &pCanvas, const std::string &name);
     std::string construct_title(const std::string &title);
-    double pixel_value_distance(Screen::Pixel p1, Screen::Pixel p2,
+    double pixel_value_distance(Canvas::Pixel p1, Canvas::Pixel p2,
                                 bool use_alpha=false);
 
-    Screen &mScreen;
+    Canvas &mCanvas;
     std::string mName;
     std::map<std::string, Option> mOptions;
 
@@ -122,7 +124,7 @@ 
 class SceneDefaultOptions : public Scene
 {
 public:
-    SceneDefaultOptions(Screen &pScreen) : Scene(pScreen, "") {}
+    SceneDefaultOptions(Canvas &pCanvas) : Scene(pCanvas, "") {}
     bool set_option(const std::string &opt, const std::string &val);
     void setup();
 
@@ -133,7 +135,7 @@ 
 class SceneBuild : public Scene
 {
 public:
-    SceneBuild(Screen &pScreen);
+    SceneBuild(Canvas &pCanvas);
     int load();
     void unload();
     void setup();
@@ -159,7 +161,7 @@ 
 class SceneTexture : public Scene
 {
 public:
-    SceneTexture(Screen &pScreen);
+    SceneTexture(Canvas &pCanvas);
     int load();
     void unload();
     void setup();
@@ -185,7 +187,7 @@ 
 class SceneShading : public Scene
 {
 public:
-    SceneShading(Screen &pScreen);
+    SceneShading(Canvas &pCanvas);
     int load();
     void unload();
     void setup();

=== removed file 'src/screen-sdl-gl.cpp'
--- src/screen-sdl-gl.cpp	2011-06-24 11:47:33 +0000
+++ src/screen-sdl-gl.cpp	1970-01-01 00:00:00 +0000
@@ -1,101 +0,0 @@ 
-/*
- * Copyright © 2008 Ben Smith
- * Copyright © 2010-2011 Linaro Limited
- *
- * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
- *
- * glmark2 is free software: you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation, either version 3 of the License, or (at your option) any later
- * version.
- *
- * glmark2 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 General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * glmark2.  If not, see <http://www.gnu.org/licenses/>.
- *
- * Authors:
- *  Ben Smith (original glmark benchmark)
- *  Alexandros Frantzis (glmark2)
- */
-#include "screen-sdl-gl.h"
-#include "options.h"
-#include "glx-disable-vsync.h"
-#include <fstream>
-
-ScreenSDLGL::ScreenSDLGL(int pWidth, int pHeight, int pBpp, int pFullScreen, int pFlags)
-    : ScreenSDL(pWidth, pHeight, pBpp, pFullScreen, pFlags | SDL_OPENGL)
-{
-    glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
-    glClearDepth(1.0f);
-    glEnable(GL_DEPTH_TEST);
-    glDepthFunc(GL_LEQUAL);
-    glEnable(GL_CULL_FACE);
-    glCullFace(GL_BACK);
-
-    glViewport(0, 0, mWidth, mHeight);
-
-    /*
-     * There is a bug in SDL that prevents us from setting the swap
-     * interval using the SDL_GL_SWAP_CONTROL attribute. We take care
-     * of this manually for now.
-     */
-    glx_disable_vsync();
-    
-    clear();
-}
-
-ScreenSDLGL::~ScreenSDLGL()
-{
-}
-
-
-void ScreenSDLGL::clear()
-{
-    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-}
-
-void ScreenSDLGL::update()
-{
-    if (Options::swap_buffers)
-        SDL_GL_SwapBuffers();
-    else
-        glFinish();
-}
-
-void ScreenSDLGL::print_info()
-{
-    printf("    OpenGL Information\n");
-    printf("    GL_VENDOR:     %s\n", glGetString(GL_VENDOR));
-    printf("    GL_RENDERER:   %s\n", glGetString(GL_RENDERER));
-    printf("    GL_VERSION:    %s\n", glGetString(GL_VERSION));
-}
-
-Screen::Pixel
-ScreenSDLGL::read_pixel(int x, int y)
-{
-    Uint8 pixel[4];
-
-    glReadPixels(x, y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixel);
-
-    return Screen::Pixel(pixel[0], pixel[1], pixel[2], pixel[3]);
-}
-
-void
-ScreenSDLGL::write_to_file(std::string &filename)
-{
-    char *pixels = new char[mWidth * mHeight * 4];
-
-    for (int i = 0; i < mHeight; i++) {
-        glReadPixels(0, i, mWidth, 1, GL_RGBA, GL_UNSIGNED_BYTE,
-                     &pixels[(mHeight - i - 1) * mWidth * 4]);
-    }
-
-    std::ofstream output(filename.c_str(), std::ios::out | std::ios::binary);
-    output.write(pixels, 4 * mWidth * mHeight);
-
-    delete [] pixels;
-}

=== removed file 'src/screen-sdl-gl.h'
--- src/screen-sdl-gl.h	2011-06-15 10:11:13 +0000
+++ src/screen-sdl-gl.h	1970-01-01 00:00:00 +0000
@@ -1,42 +0,0 @@ 
-/*
- * Copyright © 2008 Ben Smith
- * Copyright © 2010-2011 Linaro Limited
- *
- * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
- *
- * glmark2 is free software: you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation, either version 3 of the License, or (at your option) any later
- * version.
- *
- * glmark2 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 General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * glmark2.  If not, see <http://www.gnu.org/licenses/>.
- *
- * Authors:
- *  Ben Smith (original glmark benchmark)
- *  Alexandros Frantzis (glmark2)
- */
-#ifndef GLMARK2_SCREEN_SDL_GL_H_
-#define GLMARK2_SCREEN_SDL_GL_H_
-
-#include "screen-sdl.h"
-
-class ScreenSDLGL : public ScreenSDL
-{
-public:
-    ScreenSDLGL(int pWidth, int pHeight, int pBpp, int pFullscreen, int pFlags = 0);
-    ~ScreenSDLGL();
-
-    virtual void clear();
-    virtual void update();
-    virtual void print_info();
-    virtual Pixel read_pixel(int x, int y);
-    virtual void write_to_file(std::string &filename);
-};
-
-#endif

=== removed file 'src/screen-sdl-glesv2.cpp'
--- src/screen-sdl-glesv2.cpp	2011-06-21 12:38:07 +0000
+++ src/screen-sdl-glesv2.cpp	1970-01-01 00:00:00 +0000
@@ -1,138 +0,0 @@ 
-/*
- * Copyright © 2008 Ben Smith
- * Copyright © 2010-2011 Linaro Limited
- *
- * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
- *
- * glmark2 is free software: you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation, either version 3 of the License, or (at your option) any later
- * version.
- *
- * glmark2 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 General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * glmark2.  If not, see <http://www.gnu.org/licenses/>.
- *
- * Authors:
- *  Ben Smith (original glmark benchmark)
- *  Alexandros Frantzis (glmark2)
- */
-#include "screen-sdl-glesv2.h"
-#include "sdlgles/SDL_gles.h"
-#include "options.h"
-#include "log.h"
-#include <fstream>
-
-ScreenSDLGLESv2::ScreenSDLGLESv2(int pWidth, int pHeight, int pBpp, int pFullScreen, int pFlags)
-    : ScreenSDL(pWidth, pHeight, pBpp, pFullScreen, pFlags)
-{
-    mInitSuccess = 0;
-
-    if (SDL_GLES_Init(SDL_GLES_VERSION_2_0) < 0) {
-        fprintf(stderr, "[ Fail ] - GLES initialization failed: %s\n", SDL_GetError());
-    }
-
-    SDL_GLES_Context *context;
-    context = SDL_GLES_CreateContext();
-    if (context == NULL) {
-        fprintf(stderr, "[ Fail ] - GLES create context: %s\n", SDL_GetError());
-        return;
-    }
-
-    if (SDL_GLES_MakeCurrent(context) != 0) {
-        fprintf(stderr, "[ Fail ] - GLES make context current: %s\n", SDL_GetError());
-        return;
-    }
-
-    if (SDL_GLES_SetSwapInterval(0) != 0) {
-        fprintf(stderr, "[ Fail ] - GLES set swap interval: %s\n", SDL_GetError());
-        return;
-    }
-
-    if (Options::show_debug) {
-        int buf, red, green, blue, alpha, depth;
-        SDL_GLES_GetAttribute(SDL_GLES_BUFFER_SIZE, &buf);
-        SDL_GLES_GetAttribute(SDL_GLES_RED_SIZE, &red);
-        SDL_GLES_GetAttribute(SDL_GLES_GREEN_SIZE, &green);
-        SDL_GLES_GetAttribute(SDL_GLES_BLUE_SIZE, &blue);
-        SDL_GLES_GetAttribute(SDL_GLES_ALPHA_SIZE, &alpha);
-        SDL_GLES_GetAttribute(SDL_GLES_DEPTH_SIZE, &depth);
-        Log::debug("EGL chosen config:\n"
-                   "  Buffer: %d bits\n"
-                   "     Red: %d bits\n"
-                   "   Green: %d bits\n"
-                   "    Blue: %d bits\n"
-                   "   Alpha: %d bits\n"
-                   "   Depth: %d bits\n",
-                   buf, red, green, blue, alpha, depth);
-    }
-
-    glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
-    glClearDepthf(1.0f);
-    glEnable(GL_DEPTH_TEST);
-    glDepthFunc(GL_LEQUAL);
-    glEnable(GL_CULL_FACE);
-    glCullFace(GL_BACK);
-
-    glViewport(0, 0, mWidth, mHeight);
-
-    clear();
-
-    mInitSuccess = 1;
-}
-
-ScreenSDLGLESv2::~ScreenSDLGLESv2()
-{
-}
-
-
-void ScreenSDLGLESv2::clear()
-{
-    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-}
-
-void ScreenSDLGLESv2::update()
-{
-    if (Options::swap_buffers)
-        SDL_GLES_SwapBuffers();
-    else
-        glFinish();
-}
-
-void ScreenSDLGLESv2::print_info()
-{
-    printf("    OpenGL Information\n");
-    printf("    GL_VENDOR:     %s\n", glGetString(GL_VENDOR));
-    printf("    GL_RENDERER:   %s\n", glGetString(GL_RENDERER));
-    printf("    GL_VERSION:    %s\n", glGetString(GL_VERSION));
-}
-
-Screen::Pixel
-ScreenSDLGLESv2::read_pixel(int x, int y)
-{
-    Uint8 pixel[4];
-
-    glReadPixels(x, y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixel);
-
-    return Screen::Pixel(pixel[0], pixel[1], pixel[2], pixel[3]);
-}
-
-void
-ScreenSDLGLESv2::write_to_file(std::string &filename)
-{
-    char *pixels = new char[mWidth * mHeight * 4];
-
-    for (int i = 0; i < mHeight; i++) {
-        glReadPixels(0, i, mWidth, 1, GL_RGBA, GL_UNSIGNED_BYTE,
-                     &pixels[(mHeight - i - 1) * mWidth * 4]);
-    }
-
-    std::ofstream output (filename.c_str(), std::ios::out | std::ios::binary);
-    output.write(pixels, 4 * mWidth * mHeight);
-
-    delete [] pixels;
-}

=== removed file 'src/screen-sdl-glesv2.h'
--- src/screen-sdl-glesv2.h	2011-06-15 10:11:13 +0000
+++ src/screen-sdl-glesv2.h	1970-01-01 00:00:00 +0000
@@ -1,42 +0,0 @@ 
-/*
- * Copyright © 2008 Ben Smith
- * Copyright © 2010-2011 Linaro Limited
- *
- * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
- *
- * glmark2 is free software: you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation, either version 3 of the License, or (at your option) any later
- * version.
- *
- * glmark2 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 General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * glmark2.  If not, see <http://www.gnu.org/licenses/>.
- *
- * Authors:
- *  Ben Smith (original glmark benchmark)
- *  Alexandros Frantzis (glmark2)
- */
-#ifndef GLMARK2_SCREEN_SDL_GLESv2_H_
-#define GLMARK2_SCREEN_SDL_GLESv2_H_
-
-#include "screen-sdl.h"
-
-class ScreenSDLGLESv2 : public ScreenSDL
-{
-public:
-    ScreenSDLGLESv2(int pWidth, int pHeight, int pBpp, int pFullscreen, int pFlags = 0);
-    ~ScreenSDLGLESv2();
-
-    virtual void clear();
-    virtual void update();
-    virtual void print_info();
-    virtual Pixel read_pixel(int x, int y);
-    virtual void write_to_file(std::string &filename);
-};
-
-#endif

=== removed file 'src/screen-sdl.cpp'
--- src/screen-sdl.cpp	2011-06-21 12:38:07 +0000
+++ src/screen-sdl.cpp	1970-01-01 00:00:00 +0000
@@ -1,84 +0,0 @@ 
-/*
- * Copyright © 2008 Ben Smith
- * Copyright © 2010-2011 Linaro Limited
- *
- * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
- *
- * glmark2 is free software: you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation, either version 3 of the License, or (at your option) any later
- * version.
- *
- * glmark2 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 General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * glmark2.  If not, see <http://www.gnu.org/licenses/>.
- *
- * Authors:
- *  Ben Smith (original glmark benchmark)
- *  Alexandros Frantzis (glmark2)
- */
-#include "screen-sdl.h"
-#include "log.h"
-
-ScreenSDL::ScreenSDL(int pWidth, int pHeight, int pBpp, int pFullScreen, int pFlags)
-{
-    mWidth = pWidth;
-    mHeight = pHeight;
-    mFullScreen = pFullScreen;
-    mBpp = pBpp;
-
-    if (mFullScreen)
-        pFlags |= SDL_FULLSCREEN;
-
-    if(SDL_Init(SDL_INIT_VIDEO) < 0)
-    {
-        Log::error("[ Fail ] - Video initialization failed: %s\n", SDL_GetError());
-        return;
-    }
-
-    mInfo = SDL_GetVideoInfo();
-
-    if (pFlags & SDL_OPENGL) {
-        SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
-        SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5);
-        SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
-        SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
-        SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
-        SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 0);
-    }
-
-    if(SDL_SetVideoMode(mWidth, mHeight, mBpp, pFlags) == 0)
-    {
-        Log::error("[ Fail ] - Video mode set failed: %s\n", SDL_GetError());
-        return;
-    }
-
-    SDL_WM_SetCaption("glmark2 " GLMARK_VERSION, NULL);
-
-    mProjection = LibMatrix::Mat4::perspective(60.0, mWidth / (float)mHeight,
-                                               1.0, 1024.0);
-    mInitSuccess = 1;
-}
-
-ScreenSDL::~ScreenSDL()
-{
-    SDL_Quit();
-}
-
-
-void ScreenSDL::clear()
-{
-}
-
-void ScreenSDL::update()
-{
-}
-
-void ScreenSDL::print_info()
-{
-}
-

=== removed file 'src/screen-sdl.h'
--- src/screen-sdl.h	2011-01-25 15:06:04 +0000
+++ src/screen-sdl.h	1970-01-01 00:00:00 +0000
@@ -1,43 +0,0 @@ 
-/*
- * Copyright © 2008 Ben Smith
- * Copyright © 2010-2011 Linaro Limited
- *
- * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
- *
- * glmark2 is free software: you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation, either version 3 of the License, or (at your option) any later
- * version.
- *
- * glmark2 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 General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * glmark2.  If not, see <http://www.gnu.org/licenses/>.
- *
- * Authors:
- *  Ben Smith (original glmark benchmark)
- *  Alexandros Frantzis (glmark2)
- */
-#ifndef GLMARK2_SCREEN_SDL_H_
-#define GLMARK2_SCREEN_SDL_H_
-
-#include "screen.h"
-
-class ScreenSDL : public Screen
-{
-public:
-    ScreenSDL(int pWidth, int pHeight, int pBpp, int pFullscreen, int pFlags = 0);
-    ~ScreenSDL();
-
-    virtual void clear();
-    virtual void update();
-    virtual void print_info();
-
-protected:
-    const SDL_VideoInfo *mInfo;
-};
-
-#endif

=== removed file 'src/screen.h'
--- src/screen.h	2011-06-17 08:27:49 +0000
+++ src/screen.h	1970-01-01 00:00:00 +0000
@@ -1,85 +0,0 @@ 
-/*
- * Copyright © 2008 Ben Smith
- * Copyright © 2010-2011 Linaro Limited
- *
- * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
- *
- * glmark2 is free software: you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation, either version 3 of the License, or (at your option) any later
- * version.
- *
- * glmark2 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 General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * glmark2.  If not, see <http://www.gnu.org/licenses/>.
- *
- * Authors:
- *  Ben Smith (original glmark benchmark)
- *  Alexandros Frantzis (glmark2)
- */
-#ifndef GLMARK2_SCREEN_H_
-#define GLMARK2_SCREEN_H_
-
-#include "oglsdl.h"
-#include "mat.h"
-
-#include <string>
-#include <stdio.h>
-
-class Screen
-{
-public:
-    ~Screen() {}
-
-    struct Pixel {
-        Pixel():
-            r(0), g(0), b(0), a(0) {}
-        Pixel(Uint8 r, Uint8 g, Uint8 b, Uint8 a):
-            r(r), g(g), b(b), a(a) {}
-        Uint32 to_le32()
-        {
-            return static_cast<Uint32>(r) +
-                   (static_cast<Uint32>(g) << 8) +
-                   (static_cast<Uint32>(b) << 16) +
-                   (static_cast<Uint32>(a) << 24);
-
-        }
-        Uint8 r;
-        Uint8 g;
-        Uint8 b;
-        Uint8 a;
-    };
-
-    int mWidth;
-    int mHeight;
-    int mBpp;
-    int mFullScreen;
-    LibMatrix::mat4 mProjection;
-    int mInitSuccess;
-
-    virtual void clear() {}
-    virtual void update() {}
-    virtual void print_info() {}
-    virtual Pixel read_pixel(int x, int y)
-    {
-        (void)x;
-        (void)y;
-        return Pixel();
-    }
-    virtual void write_to_file(std::string &filename) { (void)filename; }
-
-    static Screen &dummy()
-    {
-        static Screen dummy_screen;
-        return dummy_screen;
-    }
-
-protected:
-    Screen() {}
-};
-
-#endif

=== removed directory 'src/sdlgles'
=== removed file 'src/sdlgles/SDL_gles.c'
--- src/sdlgles/SDL_gles.c	2011-04-15 18:20:15 +0000
+++ src/sdlgles/SDL_gles.c	1970-01-01 00:00:00 +0000
@@ -1,439 +0,0 @@ 
-/* This file is part of SDL_gles - SDL addon for OpenGL|ES
- * Copyright (C) 2010 Javier S. Pedro
- *
- * 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 3 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 or see <http://www.gnu.org/licenses/>.
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <dlfcn.h>
-#include <assert.h>
-
-#include <EGL/egl.h>
-
-#include <SDL.h>
-#include <SDL_syswm.h>
-
-#include "SDL_gles.h"
-
-typedef struct SDL_GLES_ContextPriv
-{
-	SDL_GLES_Context p;
-
-	EGLConfig egl_config;
-	EGLContext egl_context;
-} SDL_GLES_ContextPriv;
-
-static const char * default_libgl[] = {
-	[SDL_GLES_VERSION_1_1] = "/usr/lib/libGLES_CM.so",
-	[SDL_GLES_VERSION_2_0] = "/usr/lib/libGLESv2.so"
-};
-
-/** SDL GFX display */
-static Display *display = NULL;
-/** EGLDisplay for the above X11 display */
-static EGLDisplay *egl_display = EGL_NO_DISPLAY;
-/** The current surface. Recreated by SDL_GLES_SetVideoMode(). */
-static EGLSurface egl_surface = EGL_NO_SURFACE;
-/** A pointer to the current active context. */
-static SDL_GLES_ContextPriv *cur_context = NULL;
-
-/** The desired GLES version, as selected by the SDL_GLES_Init() call. */
-static SDL_GLES_Version gl_version = SDL_GLES_VERSION_NONE;
-/** A handle to the dynamically loaded GL library. */
-static void* gl_handle = NULL;
-/** EGL version. */
-static EGLint egl_major, egl_minor;
-
-/** Your average countof() macro. */
-#define countof(a) (sizeof(a)/sizeof(a[0]))
-
-/** List of EGLConfig attributes we care about;
-  * Used for filtering; modified by SDL_GLES_Get/SetAttribute(). */
-static EGLint attrib_list[] = {
-#define A(number, attrib, default_value) \
-	attrib, default_value,
-#include "attribs.inc"
-#undef A
-	EGL_NONE
-};
-/** A enum which maps A_EGL_* attrib constants to attrib_list positions. */
-typedef enum {
-#define A(number, attrib, default_value) \
-	A_ ## attrib = (number * 2),
-#include "attribs.inc"
-#undef A
-} attrib_enum;
-static EGLint context_attrib_list[] = {
-	EGL_CONTEXT_CLIENT_VERSION,	1,
-	EGL_NONE
-};
-
-static const char * get_error_string(int error) {
-	switch (error) {
-		case EGL_SUCCESS:
-			return "EGL_SUCCESS";
-		case EGL_NOT_INITIALIZED:
-			return "EGL_NOT_INITIALIZED";
-		case EGL_BAD_ACCESS:
-			return "EGL_BAD_ACCESS";
-		case EGL_BAD_ALLOC:
-			return "EGL_BAD_ALLOC";
-		case EGL_BAD_ATTRIBUTE:
-			return "EGL_BAD_ATTRIBUTE";
-		case EGL_BAD_CONFIG:
-			return "EGL_BAD_CONFIG";
-		case EGL_BAD_CONTEXT:
-			return "EGL_BAD_CONTEXT";
-		case EGL_BAD_CURRENT_SURFACE:
-			return "EGL_BAD_CURRENT_SURFACE";
-		case EGL_BAD_DISPLAY:
-			return "EGL_BAD_DISPLAY";
-		case EGL_BAD_MATCH:
-			return "EGL_BAD_MATCH";
-		case EGL_BAD_NATIVE_PIXMAP:
-			return "EGL_BAD_NATIVE_PIXMAP";
-		case EGL_BAD_NATIVE_WINDOW:
-			return "EGL_BAD_NATIVE_WINDOW";
-		case EGL_BAD_PARAMETER:
-			return "EGL_BAD_PARAMETER";
-		case EGL_BAD_SURFACE:
-			return "EGL_BAD_SURFACE";
-		case EGL_CONTEXT_LOST:
-			return "EGL_CONTEXT_LOST";
-		default:
-			return "EGL_UNKNOWN_ERROR";
-    }
-}
-
-static inline void set_egl_attrib(attrib_enum attrib, EGLint value)
-{
-	const unsigned int i = (unsigned int)attrib + 1;
-	assert(i < countof(attrib_list));
-	attrib_list[i] = value;
-}
-
-static inline EGLint get_egl_attrib(attrib_enum attrib)
-{
-	const unsigned int i = (unsigned int)attrib + 1;
-	assert(i < countof(attrib_list));
-	return attrib_list[i];
-}
-
-static inline void set_egl_context_attrib(EGLenum attrib, EGLint value)
-{
-	/* Only one attribute supported here. */
-	assert(attrib == EGL_CONTEXT_CLIENT_VERSION);
-	context_attrib_list[1] = value;
-}
-
-int SDL_GLES_LoadLibrary(const char *path)
-{
-	/* If path is NULL, try first to use path from SDL_VIDEO_GL_DRIVER,
-	 * otherwise use a sane default depending on selected GLES version. */
-	if (!path) {
-		path = getenv("SDL_VIDEO_GL_DRIVER");
-		if (!path) {
-			switch (gl_version) {
-				case SDL_GLES_VERSION_1_1:
-				case SDL_GLES_VERSION_2_0:
-					path = default_libgl[gl_version];
-				break;
-				default:
-					SDL_SetError("No GL version specific and SDL_VIDEO_GL_DRIVER set");
-					return -1;
-			}
-		}
-	}
-
-	/* Dynamically load the desired GL library */
-	gl_handle = dlopen(path, RTLD_LAZY|RTLD_GLOBAL);
-	if (!gl_handle) {
-		SDL_SetError("Failed to open GL library: %s (%s)", path, dlerror());
-		return -2;
-	}
-
-	return 0;
-}
-
-void* SDL_GLES_GetProcAddress(const char *proc)
-{
-	if (!gl_handle) return NULL;
-	return dlsym(gl_handle, proc);
-}
-
-int SDL_GLES_Init(SDL_GLES_Version version)
-{
-	SDL_SysWMinfo info;
-	EGLBoolean res;
-
-	SDL_VERSION(&info.version);
-	if (SDL_GetWMInfo(&info) != 1) {
-		SDL_SetError("SDL_gles is incompatible with this SDL version");
-		return -1;
-	}
-
-	/* We use the SDL GFX display (we're using the GFX window too after all) */
-	display = info.info.x11.gfxdisplay;
-
-	egl_display = eglGetDisplay((EGLNativeDisplayType)display);
-	if (egl_display == EGL_NO_DISPLAY) {
-		SDL_SetError("EGL found no available displays");
-		return -2;
-	}
-
-	res = eglInitialize(egl_display, &egl_major, &egl_minor);
-	if (!res) {
-		SDL_SetError("EGL failed to initialize: %s",
-			get_error_string(eglGetError()));
-		return -2;
-	}
-
-	/* Configure some context attributes and bind the required API now. */
-	EGLenum api_to_bind = EGL_OPENGL_ES_API;
-	gl_version = version;
-	switch (gl_version) {
-		case SDL_GLES_VERSION_1_1:
-			/* OpenGL|ES 1.1 */
-			api_to_bind = EGL_OPENGL_ES_API;
-			/* filter non ES 1.0 renderable configurations */
-			set_egl_attrib(A_EGL_RENDERABLE_TYPE, EGL_OPENGL_ES_BIT);
-			/* default egl_context_client_version is OK */
-			break;
-		case SDL_GLES_VERSION_2_0:
-			/* OpenGL|ES 2.0 */
-			api_to_bind = EGL_OPENGL_ES_API; /* Note: no EGL_OPENGL_ES2_API */
-			/* filter non ES 2.0 renderable configurations */
-			set_egl_attrib(A_EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT);
-			/* and request GL ES 2.0 contexts */
-			set_egl_context_attrib(EGL_CONTEXT_CLIENT_VERSION, 2);
-			break;
-		default:
-			SDL_SetError("Unsupported API version");
-			return -1;
-	}
-
-	res = eglBindAPI(api_to_bind);
-	if (!res) {
-		SDL_SetError("EGL failed to bind the required API");
-		return -2;
-	}
-
-	return 0;
-}
-
-void SDL_GLES_Quit()
-{
-	/* Close the loaded GL library (if any) */
-	if (gl_handle) {
-		dlclose(gl_handle);
-		gl_handle = NULL;
-	}
-	/* Unallocate most stuff we can unallocate. */
-	if (egl_display != EGL_NO_DISPLAY) {
-		eglMakeCurrent(egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE,
-			EGL_NO_CONTEXT);
-
-		if (cur_context) {
-			eglDestroyContext(egl_display, cur_context->egl_context);
-			free(cur_context);
-			cur_context = 0;
-		}
-		if (egl_surface != EGL_NO_SURFACE) {
-			eglDestroySurface(egl_display, egl_surface);
-			egl_surface = EGL_NO_SURFACE;
-		}
-
-		eglTerminate(egl_display);
-		egl_display = EGL_NO_DISPLAY;
-	}
-}
-
-int SDL_GLES_SetVideoMode()
-{
-	SDL_SysWMinfo info;
-	EGLBoolean res;
-
-	SDL_VERSION(&info.version);
-	if (SDL_GetWMInfo(&info) != 1) {
-		SDL_SetError("SDL_gles is incompatible with this SDL version");
-		return -1;
-	}
-
-	/* Destroy previous surface, if any. */
-	if (egl_surface != EGL_NO_SURFACE) {
-		/* Ensure the surface is not the current one,
-		 * thus freeing memory earlier. */
-		eglMakeCurrent(egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE,
-			 EGL_NO_CONTEXT);
-		eglDestroySurface(egl_display, egl_surface);
-		egl_surface = EGL_NO_SURFACE;
-	}
-
-	/* No current context? Quietly defer surface creation.
-	 * Surface will be created on the call to MakeCurrent. */
-	if (!cur_context) {
-		return 0;
-	}
-
-	/* Create the new window surface. */
-	egl_surface = eglCreateWindowSurface(egl_display, cur_context->egl_config,
-		(EGLNativeWindowType)info.info.x11.window, NULL);
-	if (egl_surface == EGL_NO_SURFACE) {
-		SDL_SetError("EGL failed to create a window surface: %s",
-			get_error_string(eglGetError()));
-		return -2;
-	}
-
-	/* New surface created. Make it active. */
-	assert(cur_context && cur_context->egl_context != EGL_NO_CONTEXT);
-	res = eglMakeCurrent(egl_display, egl_surface, egl_surface,
-		cur_context->egl_context);
-
-	if (!res) {
-		SDL_SetError("EGL failed to change current surface: %s",
-			get_error_string(eglGetError()));
-		cur_context = NULL;
-		return -2;
-	}
-
-	return 0;
-}
-
-SDL_GLES_Context* SDL_GLES_CreateContext(void)
-{
-	SDL_GLES_ContextPriv *context = malloc(sizeof(SDL_GLES_ContextPriv));
-	if (!context) {
-		SDL_Error(SDL_ENOMEM);
-		return NULL;
-	}
-
-	EGLBoolean res;
-	EGLConfig configs[1];
-	EGLint num_config;
-
-	res = eglChooseConfig(egl_display, attrib_list, configs, 1, &num_config);
-	if (!res || num_config < 1) {
-		SDL_SetError("EGL failed to find any valid config with required attributes: %s",
-			get_error_string(eglGetError()));
-		free(context);
-		return NULL;
-	}
-
-	context->egl_config = configs[0];
-	context->egl_context = eglCreateContext(egl_display, configs[0],
-		EGL_NO_CONTEXT, context_attrib_list);
-	if (context->egl_context == EGL_NO_CONTEXT) {
-		SDL_SetError("EGL failed to create context: %s",
-			get_error_string(eglGetError()));
-		free(context);
-		return NULL;
-	}
-
-	return (SDL_GLES_Context*) context;
-}
-
-void SDL_GLES_DeleteContext(SDL_GLES_Context* c)
-{
-	SDL_GLES_ContextPriv *context = (SDL_GLES_ContextPriv*)c;
-	if (!context) return;
-
-	if (cur_context == context) {
-		/* Deleting the active context */
-		SDL_GLES_MakeCurrent(NULL);
-	}
-
-	eglDestroyContext(egl_display, context->egl_context);
-	free(context);
-}
-
-int SDL_GLES_MakeCurrent(SDL_GLES_Context* c)
-{
-	SDL_GLES_ContextPriv *context = (SDL_GLES_ContextPriv*)c;
-	int res;
-
-	cur_context = context;
-
-	/* SDL_GLES_SetVideoMode() will appropiately clear the current context
-	 * (and surface), then create a new surface matching the selected context
-	 * config and make both the surface and the context the active ones. */
-	res = SDL_GLES_SetVideoMode();
-	if (res != 0) return res; /* Surface (re-)creation failed. */
-
-	return 0;
-}
-
-int SDL_GLES_SetSwapInterval(int interval)
-{
-	if (!eglSwapInterval(egl_display, interval)) {
-		SDL_SetError("EGL failed to set swap interval: %s",
-			get_error_string(eglGetError()));
-		return -1;
-	}
-
-	return 0;
-}
-
-void SDL_GLES_SwapBuffers()
-{
-	eglSwapBuffers(egl_display, egl_surface);
-}
-
-/** A simple map between SDL_GLES_* attributes and EGL ones.
-  * More abstraction layers is always good.
-  */
-static const attrib_enum attrib_map[] = {
-	[SDL_GLES_BUFFER_SIZE]		= A_EGL_BUFFER_SIZE,
-	[SDL_GLES_RED_SIZE]			= A_EGL_RED_SIZE,
-	[SDL_GLES_GREEN_SIZE]		= A_EGL_GREEN_SIZE,
-	[SDL_GLES_BLUE_SIZE]		= A_EGL_BLUE_SIZE,
-	[SDL_GLES_ALPHA_SIZE]		= A_EGL_ALPHA_SIZE,
-	[SDL_GLES_LUMINANCE_SIZE]	= A_EGL_LUMINANCE_SIZE,
-	[SDL_GLES_DEPTH_SIZE]		= A_EGL_DEPTH_SIZE,
-	[SDL_GLES_STENCIL_SIZE]		= A_EGL_STENCIL_SIZE,
-};
-
-int SDL_GLES_SetAttribute(SDL_GLES_Attr attr, int value)
-{
-	if (attr >= countof(attrib_map)) return -1;
-	attrib_enum list_attr = attrib_map[attr];
-	set_egl_attrib(list_attr, value);
-	return 0;
-}
-
-int SDL_GLES_GetAttribute(SDL_GLES_Attr attr, int *value)
-{
-	if (attr >= countof(attrib_map)) return -1;
-	attrib_enum list_attr = attrib_map[attr];
-	if (cur_context) {
-		EGLenum egl_attr = attrib_list[list_attr];
-		EGLint egl_value = 0;
-		EGLBoolean res = eglGetConfigAttrib(egl_display,
-			cur_context->egl_config, egl_attr, &egl_value);
-		if (res) {
-			*value = egl_value;
-			return 0;
-		} else {
-			printf("Failed: %s\n", get_error_string(eglGetError()));
-			return -1;
-		}
-	} else {
-		*value = get_egl_attrib(list_attr);
-		return 0;
-	}
-}
-

=== removed file 'src/sdlgles/SDL_gles.h'
--- src/sdlgles/SDL_gles.h	2011-04-15 18:20:15 +0000
+++ src/sdlgles/SDL_gles.h	1970-01-01 00:00:00 +0000
@@ -1,127 +0,0 @@ 
-/* This file is part of SDL_gles - SDL addon for OpenGL|ES
- * Copyright (C) 2010 Javier S. Pedro
- *
- * 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 3 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 or see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef __SDL_GLES_H
-#define __SDL_GLES_H
-
-/* Set up for C function definitions, even when using C++ */
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef enum SDL_GLES_Version
-{
-	SDL_GLES_VERSION_NONE = 0,
-	SDL_GLES_VERSION_1_1 = 1,
-	SDL_GLES_VERSION_2_0 = 2
-} SDL_GLES_Version;
-
-typedef enum SDL_GLES_Attr
-{
-	SDL_GLES_BUFFER_SIZE = 0,
-	SDL_GLES_RED_SIZE,
-	SDL_GLES_GREEN_SIZE,
-	SDL_GLES_BLUE_SIZE,
-	SDL_GLES_ALPHA_SIZE,
-	SDL_GLES_LUMINANCE_SIZE,
-	SDL_GLES_DEPTH_SIZE,
-	SDL_GLES_STENCIL_SIZE
-} SDL_GLES_Attr;
-
-typedef struct SDL_GLES_Context
-{
-	/* Opaque pointer to an EGLContext */
-} SDL_GLES_Context;
-
-/** Invoke after SDL_Init.
-	@return 0 if SDL_gles was initialized correctly.
-  */
-extern DECLSPEC int SDLCALL SDL_GLES_Init(SDL_GLES_Version version);
-
-/** Invoke just before SDL_Quit.
-  */
-extern DECLSPEC void SDLCALL SDL_GLES_Quit();
-
-/** Call before calling GetProcAddress. Dynamically loads a GLES library.
-  * @param path full path to the library to load, or leave as NULL to load
-  *		the default GL ES library (version as specified in SDL_GLES_Init()).
-  * @return 0 if everything went OK.
-  */
-extern DECLSPEC int SDLCALL SDL_GLES_LoadLibrary(const char *path);
-/** Returns the address of a symbol in the loaded GL ES library.
-  * @param name of the symbol to look up.
-  * @return address of the symbol or NULL.
-  */
-extern DECLSPEC void* SDLCALL SDL_GLES_GetProcAddress(const char *proc);
-
-/** Creates a new GL ES rendering context. This is where all your textures,
-  * etc. are stored. You need one for rendering; after creating it, make sure
-  * it is the current one calling SDL_GLES_MakeCurrent().
-  * @return the created context or NULL.
-  */
-extern DECLSPEC SDL_GLES_Context* SDLCALL SDL_GLES_CreateContext(void);
-/** Deletes an existing GL ES rendering context. This can delete the current
-  * context, but after that no context will be current.
-  * @param context context to delete
-  */
-extern DECLSPEC void SDLCALL SDL_GLES_DeleteContext(SDL_GLES_Context *context);
-
-/** Call after calling SDL_SetVideoMode() if you have an active context
-  * to refresh the surface parameters.
-  * @return 0 if everything went OK.
-  */
-extern DECLSPEC int SDLCALL SDL_GLES_SetVideoMode(void);
-/** Makes a context the current one. All GLES calls will use it from now on.
-  * @param context context to use
-  * @return 0 if everything went OK.
-  */
-extern DECLSPEC int SDLCALL SDL_GLES_MakeCurrent(SDL_GLES_Context *context);
-
-/** Sets the swap interval for the current SDL_GLES context
-  * @param interval 0 for immediate updates, 1 for updates synchronized with the vertical retrace.
-  * @return 0 if everything went OK.
-  */
-extern DECLSPEC int SDLCALL SDL_GLES_SetSwapInterval(int interval);
-
-/** Equivalent to SDL_Flip(). Call when you're finished issuing GL calls
-  * and want to draw the color buffer contents to the window surface.
-  */
-extern DECLSPEC void SDLCALL SDL_GLES_SwapBuffers(void);
-
-/** Sets a specific context attribute before calling SDL_CreateContext().
-  * @param attr
-  * @param value
-  * @return 0 if the attribute exists, -1 otherwise.
-  */
-extern DECLSPEC int SDLCALL SDL_GLES_SetAttribute(SDL_GLES_Attr attr, int value);
-
-/** Gets a context attribute from the current context, or from the wanted
-  * attribute set if no context is current.
-  * @param attr
-  * @param value pointer where the result will be stored.
-  * @return 0 if the attribute exists, -1 otherwise.
-  */
-extern DECLSPEC int SDLCALL SDL_GLES_GetAttribute(SDL_GLES_Attr attr, int *value);
-
-/* Ends C function definitions when using C++ */
-#ifdef __cplusplus
-}
-#endif
-
-#endif

=== removed file 'src/sdlgles/attribs.inc'
--- src/sdlgles/attribs.inc	2010-11-19 18:09:32 +0000
+++ src/sdlgles/attribs.inc	1970-01-01 00:00:00 +0000
@@ -1,22 +0,0 @@ 
-/* List of EGL attributes we care about */
-A(0,	EGL_BUFFER_SIZE,			1)
-A(1,	EGL_RED_SIZE,				0)
-A(2,	EGL_GREEN_SIZE,				0)
-A(3,	EGL_BLUE_SIZE,				0)
-A(4,	EGL_LUMINANCE_SIZE,			0)
-A(5,	EGL_ALPHA_SIZE,				0)
-A(6,	EGL_CONFIG_CAVEAT,			EGL_DONT_CARE)
-A(7,	EGL_CONFIG_ID,				EGL_DONT_CARE)
-A(8,	EGL_DEPTH_SIZE,				1)
-A(9,	EGL_LEVEL,					0)
-A(10,	EGL_NATIVE_RENDERABLE,		EGL_DONT_CARE)
-A(11,	EGL_NATIVE_VISUAL_TYPE,		EGL_DONT_CARE)
-A(12,	EGL_RENDERABLE_TYPE,		0)
-A(13,	EGL_SAMPLE_BUFFERS,			0)
-A(14,	EGL_SAMPLES,				0)
-A(15,	EGL_STENCIL_SIZE,			0)
-A(16,	EGL_SURFACE_TYPE,			EGL_WINDOW_BIT)
-A(17,	EGL_TRANSPARENT_TYPE,		EGL_NONE)
-A(18,	EGL_TRANSPARENT_RED_VALUE,	EGL_DONT_CARE)
-A(19,	EGL_TRANSPARENT_GREEN_VALUE,EGL_DONT_CARE)
-A(20,	EGL_TRANSPARENT_BLUE_VALUE,	EGL_DONT_CARE)

=== modified file 'src/texture.cpp'
--- src/texture.cpp	2011-06-08 08:44:03 +0000
+++ src/texture.cpp	2011-06-30 13:33:37 +0000
@@ -22,17 +22,119 @@ 
  *  Alexandros Frantzis (glmark2)
  */
 #include "texture.h"
+#include "log.h"
+
+#include <cstdarg>
+#include <png.h>
+
+class ImageData {
+public:
+    ImageData() : pixels(0), width(0), height(0), bpp(0) {}
+    ~ImageData() { delete [] pixels; }
+    bool load_png(const std::string &filename);
+    void resize(int w, int h, int b)
+    {
+        width = w;
+        height = h;
+        bpp = b;
+        delete [] pixels;
+        pixels = new unsigned char[bpp * w * h];
+    }
+
+    unsigned char *pixels;
+    int width;
+    int height;
+    int bpp;
+};
+
+bool
+ImageData::load_png(const std::string &filename)
+{
+    bool ret = false;
+    png_structp png_ptr = 0;
+    png_infop info_ptr = 0;
+    png_bytepp row_pointers = 0;
+    static const int png_transforms = PNG_TRANSFORM_STRIP_16 |
+                                      PNG_TRANSFORM_GRAY_TO_RGB |
+                                      PNG_TRANSFORM_PACKING |
+                                      PNG_TRANSFORM_EXPAND;
+
+    Log::debug("Reading PNG file %s\n", filename.c_str());
+
+    FILE *fp = fopen(filename.c_str(), "rb");
+    if (!fp) {
+        Log::error("Cannot open file %s!\n", filename.c_str());
+        goto out;
+    }
+
+    /* Set up all the libpng structs we need */
+    png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, 0, 0, 0);
+    if (!png_ptr) {
+        Log::error("Couldn't create libpng read struct\n");
+        goto out;
+    }
+
+    info_ptr = png_create_info_struct(png_ptr);
+    if (!info_ptr) {
+        Log::error("Couldn't create libpng info struct\n");
+        goto out;
+    }
+
+    /* Set up libpng error handling */
+    if (setjmp(png_jmpbuf(png_ptr))) {
+        Log::error("libpng error while reading file %s\n", filename.c_str());
+        goto out;
+    }
+
+    /* Read the image information and data */
+    png_init_io(png_ptr, fp);
+
+    png_read_png(png_ptr, info_ptr, png_transforms, 0);
+
+    row_pointers = png_get_rows(png_ptr, info_ptr);
+
+    resize(png_get_image_width(png_ptr, info_ptr),
+           png_get_image_height(png_ptr, info_ptr),
+           png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_RGB ? 3 : 4);
+
+
+    Log::debug("    Height: %d Width: %d Bpp: %d\n", width, height, bpp);
+
+    /*
+     * Copy the image data to a contiguous memory area suitable for texture
+     * upload.
+     */
+    for (int i = 0; i < height; i++) {
+        memcpy(&pixels[bpp * width * i],
+               row_pointers[height - i - 1],
+               width * bpp);
+    }
+
+    ret = true;
+
+out:
+    if (fp)
+       fclose(fp);
+
+    if (png_ptr)
+        png_destroy_read_struct(&png_ptr,
+                                info_ptr != 0 ? &info_ptr : 0,
+                                0);
+
+    return ret;
+}
 
 static void
-setup_texture(GLuint *tex, GLenum format, SDL_Surface *surface,
-              GLint min_filter, GLint mag_filter)
+setup_texture(GLuint *tex, ImageData &image, GLint min_filter, GLint mag_filter)
 {
+    GLenum format = image.bpp == 3 ? GL_RGB : GL_RGBA;
+
     glGenTextures(1, tex);
     glBindTexture(GL_TEXTURE_2D, *tex);
     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, min_filter);
     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, mag_filter);
-    glTexImage2D(GL_TEXTURE_2D, 0, format, surface->w, surface->h, 0,
-                 format, GL_UNSIGNED_BYTE, surface->pixels);
+    glTexImage2D(GL_TEXTURE_2D, 0, format, image.width, image.height, 0,
+                 format, GL_UNSIGNED_BYTE, image.pixels);
 
     if ((min_filter != GL_NEAREST && min_filter != GL_LINEAR) ||
         (mag_filter != GL_NEAREST && mag_filter != GL_LINEAR))
@@ -44,79 +146,22 @@ 
 int
 Texture::load(const std::string &filename, GLuint *pTexture, ...)
 {
-    SDL_Surface *surface;
-    GLenum texture_format = GL_RGB;
-    GLint  nOfColors;
-
-    if ((surface = SDL_LoadBMP(filename.c_str()))) {
-        if ((surface->w & (surface->w - 1)) != 0)
-            printf("warning: image.bmp's width is not a power of 2\n");
-
-        if ((surface->h & (surface->h - 1)) != 0)
-            printf("warning: image.bmp's height is not a power of 2\n");
-
-        nOfColors = surface->format->BytesPerPixel;
-        if (nOfColors == 4) {
-            texture_format = GL_RGBA;
-            // If the picture is not RGBA convert it
-            if (surface->format->Rmask != 0x000000ff) {
-                SDL_PixelFormat format = {
-                    surface->format->palette,
-                    surface->format->BitsPerPixel,
-                    surface->format->BytesPerPixel,
-                    surface->format->Rloss, surface->format->Gloss,
-                    surface->format->Bloss, surface->format->Aloss,
-                    0,  8, 16, 24,
-                    0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000,
-                    surface->format->colorkey, surface->format->alpha
-                };
-                SDL_Surface *tmp = SDL_ConvertSurface(surface, &format, 0);
-                SDL_FreeSurface(surface);
-                surface = tmp;
-            }
-        }
-        else if (nOfColors == 3) {
-            texture_format = GL_RGB;
-            // If the picture is not RGB convert it
-            if (surface->format->Rmask != 0x000000ff) {
-                SDL_PixelFormat format = {
-                    surface->format->palette,
-                    surface->format->BitsPerPixel,
-                    surface->format->BytesPerPixel,
-                    surface->format->Rloss, surface->format->Gloss,
-                    surface->format->Bloss, surface->format->Aloss,
-                    0,  8, 16, 24,
-                    0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000,
-                    surface->format->colorkey, surface->format->alpha
-                };
-                SDL_Surface *tmp = SDL_ConvertSurface(surface, &format, 0);
-                SDL_FreeSurface(surface);
-                surface = tmp;
-            }
-        }
-        else {
-            printf("warning: the image is not truecolor..  this will probably break\n");
-        }
-
-        va_list ap;
-        va_start(ap, pTexture);
-        GLint arg;
-
-        while ((arg = va_arg(ap, GLint)) != 0) {
-            GLint arg2 = va_arg(ap, GLint);
-            setup_texture(pTexture, texture_format, surface, arg, arg2);
-            pTexture++;
-        }
-
-        va_end(ap);
-    }
-    else {
-        fprintf(stderr, "SDL could not load image.bmp: %s\n", SDL_GetError());
+    ImageData image;
+
+    if (!image.load_png(filename))
         return 0;
+
+    va_list ap;
+    va_start(ap, pTexture);
+    GLint arg;
+
+    while ((arg = va_arg(ap, GLint)) != 0) {
+        GLint arg2 = va_arg(ap, GLint);
+        setup_texture(pTexture, image, arg, arg2);
+        pTexture++;
     }
 
-    if (surface)
-        SDL_FreeSurface(surface);
+    va_end(ap);
 
     return 1;
 }

=== modified file 'src/texture.h'
--- src/texture.h	2011-06-08 08:44:03 +0000
+++ src/texture.h	2011-06-30 13:33:37 +0000
@@ -24,7 +24,7 @@ 
 #ifndef GLMARK2_TEXTURE_H_
 #define GLMARK2_TEXTURE_H_
 
-#include "oglsdl.h"
+#include "gl-headers.h"
 
 #include <string>
 

=== modified file 'src/wscript_build'
--- src/wscript_build	2011-06-17 13:09:21 +0000
+++ src/wscript_build	2011-06-30 14:13:04 +0000
@@ -1,7 +1,7 @@ 
 all_sources = bld.path.ant_glob('*.cpp')
-common_sources = [f for f in all_sources if f.name.find('screen-') == -1]
-gl_sources = ['screen-sdl.cpp', 'screen-sdl-gl.cpp']
-glesv2_sources = ['screen-sdl.cpp', 'screen-sdl-glesv2.cpp']
+common_sources = [f for f in all_sources if f.name.find('canvas-') == -1]
+gl_sources = ['canvas-x11.cpp', 'canvas-x11-glx.cpp']
+glesv2_sources = ['canvas-x11.cpp', 'canvas-x11-egl.cpp']
 libmatrix_sources = [f for f in bld.path.ant_glob('libmatrix/*.cc')
                      if not f.name.endswith('test.cc')]
 
@@ -19,7 +19,7 @@ 
         features     = ['cxx', 'cprogram'],
         source       = common_sources + gl_sources,
         target       = 'glmark2',
-        use          = ['sdl', 'gl', 'matrix'],
+        use          = ['x11', 'gl', 'matrix', 'libpng12'],
         lib          = ['m'],
         defines      = ['USE_GL']
         )
@@ -35,16 +35,10 @@ 
         defines  = ['USE_GLESv2']
         )
     bld(
-        features     = ['c', 'cstlib'],
-        source       = bld.path.ant_glob('sdlgles/*.c'),
-        target       = 'sdlgles',
-        uselib       = ['sdl', 'glesv2', 'egl']
-        )
-    bld(
         features     = ['cxx', 'cprogram'],
         source       = common_sources + glesv2_sources,
         target       = 'glmark2-es2',
-        use          = ['sdl', 'glesv2', 'sdlgles', 'matrix-es2'],
+        use          = ['x11', 'egl', 'glesv2', 'matrix-es2', 'libpng12'],
         lib          = ['m', 'dl'],
         defines      = ['USE_GLESv2']
         )

=== modified file 'wscript'
--- wscript	2011-06-24 12:17:59 +0000
+++ wscript	2011-06-30 14:13:04 +0000
@@ -49,7 +49,7 @@ 
                       uselib = uselib, mandatory = True)
 
     # Check required packages
-    req_pkgs = [('sdl', 'sdl')]
+    req_pkgs = [('x11', 'x11'), ('libpng12', 'libpng12')]
     for (pkg, uselib) in req_pkgs:
         ctx.check_cfg(package = pkg, uselib_store = uselib,
                       args = '--cflags --libs', mandatory = True)