Geoff Lang | 49be2ad | 2014-02-28 13:05:51 -0500 | [diff] [blame] | 1 | // |
| 2 | // Copyright (c) 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 | |
Geoff Lang | e977efc | 2014-03-04 11:43:04 -0500 | [diff] [blame] | 10 | #include <EGL/egl.h> |
| 11 | #include <EGL/eglext.h> |
Geoff Lang | 49be2ad | 2014-02-28 13:05:51 -0500 | [diff] [blame] | 12 | |
Jamie Madill | 1cfaaf8 | 2014-08-21 10:04:04 -0400 | [diff] [blame] | 13 | #include "OSWindow.h" |
Geoff Lang | 49be2ad | 2014-02-28 13:05:51 -0500 | [diff] [blame] | 14 | #include "Timer.h" |
| 15 | |
| 16 | #include <string> |
| 17 | #include <list> |
| 18 | #include <cstdint> |
| 19 | #include <memory> |
| 20 | |
Jamie Madill | 1cfaaf8 | 2014-08-21 10:04:04 -0400 | [diff] [blame] | 21 | class EGLWindow; |
| 22 | |
Geoff Lang | 49be2ad | 2014-02-28 13:05:51 -0500 | [diff] [blame] | 23 | class SampleApplication |
| 24 | { |
| 25 | public: |
Jamie Madill | 96e46cd | 2014-04-07 15:51:15 -0400 | [diff] [blame] | 26 | SampleApplication(const std::string& name, size_t width, size_t height, |
Corentin Wallez | 98e7d07 | 2015-05-07 12:35:47 -0700 | [diff] [blame^] | 27 | EGLint glesMajorVersion = 2, EGLint requestedRenderer = EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE); |
Geoff Lang | 49be2ad | 2014-02-28 13:05:51 -0500 | [diff] [blame] | 28 | virtual ~SampleApplication(); |
| 29 | |
| 30 | virtual bool initialize(); |
| 31 | virtual void destroy(); |
| 32 | |
| 33 | virtual void step(float dt, double totalTime); |
| 34 | virtual void draw(); |
| 35 | |
Geoff Lang | e977efc | 2014-03-04 11:43:04 -0500 | [diff] [blame] | 36 | virtual void swap(); |
| 37 | |
Jamie Madill | 1cfaaf8 | 2014-08-21 10:04:04 -0400 | [diff] [blame] | 38 | OSWindow *getWindow() const; |
Geoff Lang | e977efc | 2014-03-04 11:43:04 -0500 | [diff] [blame] | 39 | EGLConfig getConfig() const; |
Geoff Lang | f0955f1 | 2014-06-20 16:07:07 -0400 | [diff] [blame] | 40 | EGLDisplay getDisplay() const; |
Geoff Lang | e977efc | 2014-03-04 11:43:04 -0500 | [diff] [blame] | 41 | EGLSurface getSurface() const; |
| 42 | EGLContext getContext() const; |
Geoff Lang | 49be2ad | 2014-02-28 13:05:51 -0500 | [diff] [blame] | 43 | |
| 44 | bool popEvent(Event *event); |
| 45 | |
| 46 | int run(); |
| 47 | void exit(); |
| 48 | |
| 49 | private: |
Geoff Lang | 49be2ad | 2014-02-28 13:05:51 -0500 | [diff] [blame] | 50 | std::string mName; |
Geoff Lang | 49be2ad | 2014-02-28 13:05:51 -0500 | [diff] [blame] | 51 | bool mRunning; |
| 52 | |
| 53 | std::unique_ptr<Timer> mTimer; |
Jamie Madill | 1cfaaf8 | 2014-08-21 10:04:04 -0400 | [diff] [blame] | 54 | std::unique_ptr<EGLWindow> mEGLWindow; |
Jamie Madill | 586666c | 2014-08-21 10:04:05 -0400 | [diff] [blame] | 55 | std::unique_ptr<OSWindow> mOSWindow; |
Geoff Lang | 49be2ad | 2014-02-28 13:05:51 -0500 | [diff] [blame] | 56 | }; |
| 57 | |
| 58 | #endif // SAMPLE_UTIL_SAMPLE_APPLICATION_H |