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 class GLWindowBase; 23 24 namespace angle 25 { 26 class Library; 27 } // namespace angle 28 29 bool IsGLExtensionEnabled(const std::string &extName); 30 31 class SampleApplication 32 { 33 public: 34 SampleApplication(std::string name, 35 int argc, 36 char **argv, 37 EGLint glesMajorVersion = 2, 38 EGLint glesMinorVersion = 0, 39 uint32_t width = 1280, 40 uint32_t height = 720); 41 virtual ~SampleApplication(); 42 43 virtual bool initialize(); 44 virtual void destroy(); 45 46 virtual void step(float dt, double totalTime); 47 virtual void draw(); 48 49 virtual void swap(); 50 51 virtual void onKeyUp(const Event::KeyEvent &keyEvent); 52 virtual void onKeyDown(const Event::KeyEvent &keyEvent); 53 54 OSWindow *getWindow() const; 55 EGLConfig getConfig() const; 56 EGLDisplay getDisplay() const; 57 EGLSurface getSurface() const; 58 EGLContext getContext() const; 59 60 int run(); 61 void exit(); 62 63 private: 64 bool popEvent(Event *event); 65 66 std::string mName; 67 uint32_t mWidth; 68 uint32_t mHeight; 69 bool mRunning; 70 71 Timer mTimer; 72 uint32_t mFrameCount; 73 GLWindowBase *mGLWindow; 74 EGLWindow *mEGLWindow; 75 OSWindow *mOSWindow; 76 angle::GLESDriverType mDriverType; 77 78 EGLPlatformParameters mPlatformParams; 79 80 // Handle to the entry point binding library. 81 std::unique_ptr<angle::Library> mEntryPointsLib; 82 }; 83 84 #endif // SAMPLE_UTIL_SAMPLE_APPLICATION_H 85