Jamie Madill | 1cfaaf8 | 2014-08-21 10:04:04 -0400 | [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 UTIL_EGLWINDOW_H_ |
| 8 | #define UTIL_EGLWINDOW_H_ |
| 9 | |
| 10 | #define GL_GLEXT_PROTOTYPES |
| 11 | |
| 12 | #include <GLES3/gl3.h> |
| 13 | #include <GLES3/gl3ext.h> |
| 14 | #include <GLES2/gl2.h> |
| 15 | #include <GLES2/gl2ext.h> |
| 16 | #include <EGL/egl.h> |
| 17 | #include <EGL/eglext.h> |
| 18 | |
| 19 | #include <string> |
| 20 | #include <list> |
| 21 | #include <cstdint> |
| 22 | #include <memory> |
| 23 | |
| 24 | // A macro to disallow the copy constructor and operator= functions |
| 25 | // This must be used in the private: declarations for a class |
| 26 | #define DISALLOW_COPY_AND_ASSIGN(TypeName) \ |
| 27 | TypeName(const TypeName&); \ |
| 28 | void operator=(const TypeName&) |
| 29 | |
| 30 | class OSWindow; |
| 31 | |
| 32 | class EGLWindow |
| 33 | { |
| 34 | public: |
| 35 | EGLWindow(size_t width, size_t height, |
| 36 | EGLint glesMajorVersion = 2, |
| 37 | EGLint requestedRenderer = EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE); |
| 38 | |
| 39 | ~EGLWindow(); |
| 40 | |
Jamie Madill | 62af546 | 2014-08-26 13:16:37 -0400 | [diff] [blame^] | 41 | void setClientVersion(EGLint glesMajorVersion) { mClientVersion = glesMajorVersion; } |
| 42 | void setWidth(size_t width) { mWidth = width; } |
| 43 | void setHeight(size_t height) { mHeight = height; } |
Jamie Madill | 3757a5a | 2014-08-26 13:16:36 -0400 | [diff] [blame] | 44 | void setConfigRedBits(int bits) { mRedBits = bits; } |
| 45 | void setConfigGreenBits(int bits) { mGreenBits = bits; } |
| 46 | void setConfigBlueBits(int bits) { mBlueBits = bits; } |
| 47 | void setConfigAlphaBits(int bits) { mAlphaBits = bits; } |
| 48 | void setConfigDepthBits(int bits) { mDepthBits = bits; } |
| 49 | void setConfigStencilBits(int bits) { mStencilBits = bits; } |
| 50 | void setMultisample(bool multisample) { mMultisample = multisample; } |
| 51 | void setSwapInterval(EGLint swapInterval) { mSwapInterval = swapInterval; } |
| 52 | |
Jamie Madill | 1cfaaf8 | 2014-08-21 10:04:04 -0400 | [diff] [blame] | 53 | void swap(); |
| 54 | |
Jamie Madill | 62af546 | 2014-08-26 13:16:37 -0400 | [diff] [blame^] | 55 | GLuint getClientVersion() const { return mClientVersion; } |
Jamie Madill | 1cfaaf8 | 2014-08-21 10:04:04 -0400 | [diff] [blame] | 56 | EGLConfig getConfig() const; |
| 57 | EGLDisplay getDisplay() const; |
| 58 | EGLSurface getSurface() const; |
| 59 | EGLContext getContext() const; |
| 60 | size_t getWidth() const { return mWidth; } |
| 61 | size_t getHeight() const { return mHeight; } |
Jamie Madill | 3757a5a | 2014-08-26 13:16:36 -0400 | [diff] [blame] | 62 | int getConfigRedBits() const { return mRedBits; } |
| 63 | int getConfigGreenBits() const { return mGreenBits; } |
| 64 | int getConfigBlueBits() const { return mBlueBits; } |
| 65 | int getConfigAlphaBits() const { return mAlphaBits; } |
| 66 | int getConfigDepthBits() const { return mDepthBits; } |
| 67 | int getConfigStencilBits() const { return mStencilBits; } |
| 68 | bool isMultisample() const { return mMultisample; } |
| 69 | EGLint getSwapInterval() const { return mSwapInterval; } |
Jamie Madill | 1cfaaf8 | 2014-08-21 10:04:04 -0400 | [diff] [blame] | 70 | |
Jamie Madill | 586666c | 2014-08-21 10:04:05 -0400 | [diff] [blame] | 71 | bool initializeGL(const OSWindow *osWindow); |
Jamie Madill | 1cfaaf8 | 2014-08-21 10:04:04 -0400 | [diff] [blame] | 72 | void destroyGL(); |
| 73 | |
| 74 | private: |
| 75 | DISALLOW_COPY_AND_ASSIGN(EGLWindow); |
| 76 | |
| 77 | EGLConfig mConfig; |
| 78 | EGLDisplay mDisplay; |
| 79 | EGLSurface mSurface; |
| 80 | EGLContext mContext; |
| 81 | |
| 82 | GLuint mClientVersion; |
| 83 | EGLint mRequestedRenderer; |
| 84 | size_t mWidth; |
| 85 | size_t mHeight; |
Jamie Madill | 3757a5a | 2014-08-26 13:16:36 -0400 | [diff] [blame] | 86 | int mRedBits; |
| 87 | int mGreenBits; |
| 88 | int mBlueBits; |
| 89 | int mAlphaBits; |
| 90 | int mDepthBits; |
| 91 | int mStencilBits; |
| 92 | bool mMultisample; |
| 93 | EGLint mSwapInterval; |
Jamie Madill | 1cfaaf8 | 2014-08-21 10:04:04 -0400 | [diff] [blame] | 94 | }; |
| 95 | |
| 96 | #endif // UTIL_EGLWINDOW_H_ |