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 | |
Jamie Madill | 5704d6e | 2014-08-26 13:16:38 -0400 | [diff] [blame] | 24 | #include "shared_utils.h" |
Jamie Madill | 1cfaaf8 | 2014-08-21 10:04:04 -0400 | [diff] [blame] | 25 | |
| 26 | class OSWindow; |
| 27 | |
| 28 | class EGLWindow |
| 29 | { |
| 30 | public: |
| 31 | EGLWindow(size_t width, size_t height, |
| 32 | EGLint glesMajorVersion = 2, |
| 33 | EGLint requestedRenderer = EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE); |
| 34 | |
| 35 | ~EGLWindow(); |
| 36 | |
Jamie Madill | 62af546 | 2014-08-26 13:16:37 -0400 | [diff] [blame] | 37 | void setClientVersion(EGLint glesMajorVersion) { mClientVersion = glesMajorVersion; } |
| 38 | void setWidth(size_t width) { mWidth = width; } |
| 39 | void setHeight(size_t height) { mHeight = height; } |
Jamie Madill | 3757a5a | 2014-08-26 13:16:36 -0400 | [diff] [blame] | 40 | void setConfigRedBits(int bits) { mRedBits = bits; } |
| 41 | void setConfigGreenBits(int bits) { mGreenBits = bits; } |
| 42 | void setConfigBlueBits(int bits) { mBlueBits = bits; } |
| 43 | void setConfigAlphaBits(int bits) { mAlphaBits = bits; } |
| 44 | void setConfigDepthBits(int bits) { mDepthBits = bits; } |
| 45 | void setConfigStencilBits(int bits) { mStencilBits = bits; } |
| 46 | void setMultisample(bool multisample) { mMultisample = multisample; } |
| 47 | void setSwapInterval(EGLint swapInterval) { mSwapInterval = swapInterval; } |
| 48 | |
Jamie Madill | 1cfaaf8 | 2014-08-21 10:04:04 -0400 | [diff] [blame] | 49 | void swap(); |
| 50 | |
Jamie Madill | 62af546 | 2014-08-26 13:16:37 -0400 | [diff] [blame] | 51 | GLuint getClientVersion() const { return mClientVersion; } |
Jamie Madill | 1cfaaf8 | 2014-08-21 10:04:04 -0400 | [diff] [blame] | 52 | EGLConfig getConfig() const; |
| 53 | EGLDisplay getDisplay() const; |
| 54 | EGLSurface getSurface() const; |
| 55 | EGLContext getContext() const; |
| 56 | size_t getWidth() const { return mWidth; } |
| 57 | size_t getHeight() const { return mHeight; } |
Jamie Madill | 3757a5a | 2014-08-26 13:16:36 -0400 | [diff] [blame] | 58 | int getConfigRedBits() const { return mRedBits; } |
| 59 | int getConfigGreenBits() const { return mGreenBits; } |
| 60 | int getConfigBlueBits() const { return mBlueBits; } |
| 61 | int getConfigAlphaBits() const { return mAlphaBits; } |
| 62 | int getConfigDepthBits() const { return mDepthBits; } |
| 63 | int getConfigStencilBits() const { return mStencilBits; } |
| 64 | bool isMultisample() const { return mMultisample; } |
| 65 | EGLint getSwapInterval() const { return mSwapInterval; } |
Jamie Madill | 1cfaaf8 | 2014-08-21 10:04:04 -0400 | [diff] [blame] | 66 | |
Jamie Madill | 586666c | 2014-08-21 10:04:05 -0400 | [diff] [blame] | 67 | bool initializeGL(const OSWindow *osWindow); |
Jamie Madill | 1cfaaf8 | 2014-08-21 10:04:04 -0400 | [diff] [blame] | 68 | void destroyGL(); |
| 69 | |
| 70 | private: |
| 71 | DISALLOW_COPY_AND_ASSIGN(EGLWindow); |
| 72 | |
| 73 | EGLConfig mConfig; |
| 74 | EGLDisplay mDisplay; |
| 75 | EGLSurface mSurface; |
| 76 | EGLContext mContext; |
| 77 | |
| 78 | GLuint mClientVersion; |
| 79 | EGLint mRequestedRenderer; |
| 80 | size_t mWidth; |
| 81 | size_t mHeight; |
Jamie Madill | 3757a5a | 2014-08-26 13:16:36 -0400 | [diff] [blame] | 82 | int mRedBits; |
| 83 | int mGreenBits; |
| 84 | int mBlueBits; |
| 85 | int mAlphaBits; |
| 86 | int mDepthBits; |
| 87 | int mStencilBits; |
| 88 | bool mMultisample; |
| 89 | EGLint mSwapInterval; |
Jamie Madill | 1cfaaf8 | 2014-08-21 10:04:04 -0400 | [diff] [blame] | 90 | }; |
| 91 | |
| 92 | #endif // UTIL_EGLWINDOW_H_ |