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