blob: e97522e07a2f9b2ba5f1d3c27933f374f94d70bd [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
Jamie Madill5704d6e2014-08-26 13:16:38 -040024#include "shared_utils.h"
Jamie Madill1cfaaf82014-08-21 10:04:04 -040025
26class OSWindow;
27
28class 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 Madill62af5462014-08-26 13:16:37 -040037 void setClientVersion(EGLint glesMajorVersion) { mClientVersion = glesMajorVersion; }
38 void setWidth(size_t width) { mWidth = width; }
39 void setHeight(size_t height) { mHeight = height; }
Jamie Madill3757a5a2014-08-26 13:16:36 -040040 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 Madill1cfaaf82014-08-21 10:04:04 -040049 void swap();
50
Jamie Madill62af5462014-08-26 13:16:37 -040051 GLuint getClientVersion() const { return mClientVersion; }
Jamie Madill1cfaaf82014-08-21 10:04:04 -040052 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 Madill3757a5a2014-08-26 13:16:36 -040058 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 Madill1cfaaf82014-08-21 10:04:04 -040066
Jamie Madill586666c2014-08-21 10:04:05 -040067 bool initializeGL(const OSWindow *osWindow);
Jamie Madill1cfaaf82014-08-21 10:04:04 -040068 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 Madill3757a5a2014-08-26 13:16:36 -040082 int mRedBits;
83 int mGreenBits;
84 int mBlueBits;
85 int mAlphaBits;
86 int mDepthBits;
87 int mStencilBits;
88 bool mMultisample;
89 EGLint mSwapInterval;
Jamie Madill1cfaaf82014-08-21 10:04:04 -040090};
91
92#endif // UTIL_EGLWINDOW_H_