1 // 2 // Copyright 2014 The ANGLE Project Authors. All rights reserved. 3 // Use of this source code is governed by a BSD-style license that can be 4 // found in the LICENSE file. 5 // 6 7 #ifndef SAMPLE_UTIL_SAMPLE_APPLICATION_H 8 #define SAMPLE_UTIL_SAMPLE_APPLICATION_H 9 10 #include <stdint.h> 11 #include <list> 12 #include <memory> 13 #include <string> 14 15 #include "common/system_utils.h" 16 #include "util/EGLPlatformParameters.h" 17 #include "util/OSWindow.h" 18 #include "util/Timer.h" 19 #include "util/egl_loader_autogen.h" 20 21 class EGLWindow; 22 23 namespace angle 24 { 25 class Library; 26 } // namespace angle 27 28 class SampleApplication 29 { 30 public: 31 SampleApplication(std::string name, 32 int argc, 33 char **argv, 34 EGLint glesMajorVersion = 2, 35 EGLint glesMinorVersion = 0, 36 uint32_t width = 1280, 37 uint32_t height = 720); 38 virtual ~SampleApplication(); 39 40 virtual bool initialize(); 41 virtual void destroy(); 42 43 virtual void step(float dt, double totalTime); 44 virtual void draw(); 45 46 virtual void swap(); 47 48 virtual void onKeyUp(const Event::KeyEvent &keyEvent); 49 virtual void onKeyDown(const Event::KeyEvent &keyEvent); 50 51 OSWindow *getWindow() const; 52 EGLConfig getConfig() const; 53 EGLDisplay getDisplay() const; 54 EGLSurface getSurface() const; 55 EGLContext getContext() const; 56 57 int run(); 58 void exit(); 59 60 private: 61 bool popEvent(Event *event); 62 63 std::string mName; 64 uint32_t mWidth; 65 uint32_t mHeight; 66 bool mRunning; 67 68 Timer mTimer; 69 EGLWindow *mEGLWindow; 70 OSWindow *mOSWindow; 71 72 EGLPlatformParameters mPlatformParams; 73 74 // Handle to the entry point binding library. 75 std::unique_ptr<angle::Library> mEntryPointsLib; 76 }; 77 78 #endif // SAMPLE_UTIL_SAMPLE_APPLICATION_H 79