From patchwork Thu Jul 21 12:36:33 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandros Frantzis X-Patchwork-Id: 2953 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 65E9323F4D for ; Thu, 21 Jul 2011 12:42:45 +0000 (UTC) Received: from mail-qy0-f180.google.com (mail-qy0-f180.google.com [209.85.216.180]) by fiordland.canonical.com (Postfix) with ESMTP id 2073EA1822A for ; Thu, 21 Jul 2011 12:42:45 +0000 (UTC) Received: by mail-qy0-f180.google.com with SMTP id 30so845420qyk.11 for ; Thu, 21 Jul 2011 05:42:44 -0700 (PDT) Received: by 10.224.176.145 with SMTP id be17mr183223qab.62.1311252163462; Thu, 21 Jul 2011 05:42:43 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.229.217.78 with SMTP id hl14cs139508qcb; Thu, 21 Jul 2011 05:42:43 -0700 (PDT) Received: by 10.216.60.74 with SMTP id t52mr208817wec.30.1311251795760; Thu, 21 Jul 2011 05:36:35 -0700 (PDT) Received: from adelie.canonical.com (adelie.canonical.com [91.189.90.139]) by mx.google.com with ESMTP id x14si2112602weq.139.2011.07.21.05.36.35; Thu, 21 Jul 2011 05:36:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.139 as permitted sender) client-ip=91.189.90.139; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.139 as permitted sender) smtp.mail=bounces@canonical.com Received: from loganberry.canonical.com ([91.189.90.37]) by adelie.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1QjsUU-0000D9-0A for ; Thu, 21 Jul 2011 12:36:34 +0000 Received: from loganberry.canonical.com (localhost [127.0.0.1]) by loganberry.canonical.com (Postfix) with ESMTP id 11C092E890D for ; Thu, 21 Jul 2011 12:36:33 +0000 (UTC) MIME-Version: 1.0 X-Launchpad-Project: glmark2 X-Launchpad-Branch: ~glmark2-dev/glmark2/trunk X-Launchpad-Message-Rationale: Subscriber X-Launchpad-Branch-Revision-Number: 42 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~glmark2-dev/glmark2/trunk] Rev 42: Refactor Screen class. Message-Id: <20110721123633.17019.94905.launchpad@loganberry.canonical.com> Date: Thu, 21 Jul 2011 12:36:33 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="13475"; Instance="initZopeless config overlay" X-Launchpad-Hash: 7d6cc67bddb1808390d7d315c950c0c4654a11ce ------------------------------------------------------------ revno: 42 committer: Alexandros Frantzis timestamp: Mon 2010-07-12 15:15:52 +0300 message: Refactor Screen class. removed: src/screen.cpp added: src/screen-sdl-gl.cpp src/screen-sdl-gl.h src/screen-sdl.cpp src/screen-sdl.h modified: src/main.cpp src/screen.h --- 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 === modified file 'src/main.cpp' --- src/main.cpp 2010-07-12 10:06:29 +0000 +++ src/main.cpp 2010-07-12 12:15:52 +0000 @@ -1,6 +1,6 @@ #include "oglsdl.h" -#include "screen.h" +#include "screen-sdl-gl.h" #include "scene.h" int main(int argc, char *argv[]) @@ -8,13 +8,19 @@ SDL_Event event; int running = 1; unsigned current_scene = 0; - Screen screen; + + // Create the screen + ScreenSDLGL screen(800, 600, 24, 0); + + if (!screen.mInitSuccess) { + printf("Error: %s: Could not initialize screen\n", __FUNCTION__); + return 1; + } printf("===================================================\n"); printf(" GLMark 08\n"); printf("===================================================\n"); - if(!screen.init()) - return 0; + screen.print_info(); printf("===================================================\n"); // Create the scenes. === added file 'src/screen-sdl-gl.cpp' --- src/screen-sdl-gl.cpp 1970-01-01 00:00:00 +0000 +++ src/screen-sdl-gl.cpp 2010-07-12 12:15:52 +0000 @@ -0,0 +1,40 @@ +#include "screen-sdl-gl.h" + +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); + + clear(); +} + +ScreenSDLGL::~ScreenSDLGL() +{ +} + + +void ScreenSDLGL::clear() +{ + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); +} + +void ScreenSDLGL::update() +{ + SDL_GL_SwapBuffers(); +} + +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)); +} + === added file 'src/screen-sdl-gl.h' --- src/screen-sdl-gl.h 1970-01-01 00:00:00 +0000 +++ src/screen-sdl-gl.h 2010-07-12 12:15:52 +0000 @@ -0,0 +1,17 @@ +#ifndef _SCREEN_SDL_GL_H +#define _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(); +}; + +#endif === added file 'src/screen-sdl.cpp' --- src/screen-sdl.cpp 1970-01-01 00:00:00 +0000 +++ src/screen-sdl.cpp 2010-07-12 12:15:52 +0000 @@ -0,0 +1,64 @@ +#include "screen-sdl.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; + +#ifdef _DEBUG + printf("Initializing Screen... "); +#endif + if(SDL_Init(SDL_INIT_VIDEO) < 0) + { + fprintf(stderr, "[ Fail ] - Video initialization failed: %s\n", SDL_GetError()); + return; + } + + mInfo = SDL_GetVideoInfo(); + + 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); + + if(SDL_SetVideoMode(mWidth, mHeight, mBpp, pFlags) == 0) + { + fprintf(stderr, "[ Fail ] - Video mode set failed: %s\n", SDL_GetError()); + return; + } + + SDL_WM_SetCaption("GLMark 08", NULL); + + mProjection.perspective(60.0, mWidth / (float)mHeight, 1.0, 1024.0); + +#ifdef _DEBUG + mProjection.display("Projection"); +#endif + + mInitSuccess = 1; +} + +ScreenSDL::~ScreenSDL() +{ + SDL_Quit(); +} + + +void ScreenSDL::clear() +{ +} + +void ScreenSDL::update() +{ +} + +void ScreenSDL::print_info() +{ +} + === added file 'src/screen-sdl.h' --- src/screen-sdl.h 1970-01-01 00:00:00 +0000 +++ src/screen-sdl.h 2010-07-12 12:15:52 +0000 @@ -0,0 +1,20 @@ +#ifndef _SCREEN_SDL_H +#define _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.cpp' --- src/screen.cpp 2010-07-12 10:06:29 +0000 +++ src/screen.cpp 1970-01-01 00:00:00 +0000 @@ -1,98 +0,0 @@ -#include "screen.h" - -Screen::Screen() -{ - mWidth = 800; - mHeight = 600; - mBpp = 24; - mFlags = SDL_OPENGL; - mFullScreen = false; - - mInfo = SDL_GetVideoInfo(); -} - -Screen::~Screen() -{ - SDL_Quit(); -} - -Screen::Screen(int pWidth, int pHeight, int pBpp, int pFlags) -{ - mWidth = pWidth; - mHeight = pHeight; - mBpp = pBpp; - mFlags = SDL_OPENGL | pFlags; - - mInfo = SDL_GetVideoInfo(); -} - -int Screen::init() -{ -#ifdef _DEBUG - printf("Initializing Screen... "); -#endif - if(SDL_Init(SDL_INIT_VIDEO) < 0) - { - fprintf(stderr, "[ Fail ] - Video initialization failed: %s\n", SDL_GetError()); - return 0; - } - - if(mFullScreen) - mFlags = SDL_OPENGL | SDL_FULLSCREEN; - - mInfo = SDL_GetVideoInfo(); - - 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); - - if(SDL_SetVideoMode(mWidth, mHeight, mBpp, mFlags) == 0) - { - fprintf(stderr, "[ Fail ] - Video mode set failed: %s\n", SDL_GetError()); - return 0; - } - - SDL_WM_SetCaption("GLMark 08", NULL); - - 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); - - clear(); - - mProjection.perspective(60.0, mWidth / (float)mHeight, 1.0, 1024.0); - -#ifdef _DEBUG - mProjection.display("Projection"); - - printf("[ Success ]\n"); -#endif - print_info(); - return 1; -} - -void Screen::clear() -{ - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); -} - -void Screen::update() -{ - SDL_GL_SwapBuffers(); -} - -void Screen::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)); -} - === modified file 'src/screen.h' --- src/screen.h 2010-07-12 10:06:29 +0000 +++ src/screen.h 2010-07-12 12:15:52 +0000 @@ -9,22 +9,16 @@ class Screen { public: - const SDL_VideoInfo *mInfo; - int mWidth; int mHeight; int mBpp; - int mFlags; int mFullScreen; Matrix4f mProjection; + int mInitSuccess; - Screen(); - ~Screen(); - Screen(int pWidth, int pHeight, int pBpp, int pFlags); - int init(); - void clear(); - void update(); - void print_info(); + virtual void clear() = 0; + virtual void update() = 0; + virtual void print_info() = 0; }; #endif