blob: 076bc1643dd0f49393233b1fa1f1c59968c70746 [file] [log] [blame]
Jamie Madill1cfaaf82014-08-21 10:04:04 -04001//
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
30class OSWindow;
31
32class 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 Madill62af5462014-08-26 13:16:37 -040041 void setClientVersion(EGLint glesMajorVersion) { mClientVersion = glesMajorVersion; }
42 void setWidth(size_t width) { mWidth = width; }
43 void setHeight(size_t height) { mHeight = height; }
Jamie Madill3757a5a2014-08-26 13:16:36 -040044 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 Madill1cfaaf82014-08-21 10:04:04 -040053 void swap();
54
Jamie Madill62af5462014-08-26 13:16:37 -040055 GLuint getClientVersion() const { return mClientVersion; }
Jamie Madill1cfaaf82014-08-21 10:04:04 -040056 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 Madill3757a5a2014-08-26 13:16:36 -040062 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 Madill1cfaaf82014-08-21 10:04:04 -040070
Jamie Madill586666c2014-08-21 10:04:05 -040071 bool initializeGL(const OSWindow *osWindow);
Jamie Madill1cfaaf82014-08-21 10:04:04 -040072 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 Madill3757a5a2014-08-26 13:16:36 -040086 int mRedBits;
87 int mGreenBits;
88 int mBlueBits;
89 int mAlphaBits;
90 int mDepthBits;
91 int mStencilBits;
92 bool mMultisample;
93 EGLint mSwapInterval;
Jamie Madill1cfaaf82014-08-21 10:04:04 -040094};
95
96#endif // UTIL_EGLWINDOW_H_