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 enum class ClientType 32 { 33 // Client types used by the samples. Add as needed. 34 ES1, 35 ES2, 36 ES3_0, 37 ES3_1, 38 }; 39 40 class SampleApplication 41 { 42 public: 43 SampleApplication(std::string name, 44 int argc, 45 char **argv, 46 ClientType clientType = ClientType::ES2, 47 uint32_t width = 1280, 48 uint32_t height = 720); 49 virtual ~SampleApplication(); 50 51 virtual bool initialize(); 52 virtual void destroy(); 53 54 virtual void step(float dt, double totalTime); 55 virtual void draw(); 56 57 virtual void swap(); 58 59 virtual void onKeyUp(const Event::KeyEvent &keyEvent); 60 virtual void onKeyDown(const Event::KeyEvent &keyEvent); 61 62 OSWindow *getWindow() const; 63 EGLConfig getConfig() const; 64 EGLDisplay getDisplay() const; 65 EGLSurface getSurface() const; 66 EGLContext getContext() const; 67 68 int run(); 69 void exit(); 70 71 private: 72 bool popEvent(Event *event); 73 74 std::string mName; 75 uint32_t mWidth; 76 uint32_t mHeight; 77 bool mRunning; 78 79 Timer mTimer; 80 uint32_t mFrameCount; 81 GLWindowBase *mGLWindow; 82 EGLWindow *mEGLWindow; 83 OSWindow *mOSWindow; 84 angle::GLESDriverType mDriverType; 85 86 EGLPlatformParameters mPlatformParams; 87 88 // Handle to the entry point binding library. 89 std::unique_ptr<angle::Library> mEntryPointsLib; 90 }; 91 92 #endif // SAMPLE_UTIL_SAMPLE_APPLICATION_H 93