blob: 5fba863ad68d6ed6760b1393edfec2299a68112b [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
Geoff Lang0d3683c2014-10-23 11:08:16 -040028struct EGLPlatformParameters
29{
30 EGLint renderer;
31 EGLint majorVersion;
32 EGLint minorVersion;
Geoff Lang7825f612014-11-26 16:19:41 -050033 EGLint deviceType;
Geoff Lang0d3683c2014-10-23 11:08:16 -040034
35 EGLPlatformParameters();
36 explicit EGLPlatformParameters(EGLint renderer);
Geoff Lang7825f612014-11-26 16:19:41 -050037 EGLPlatformParameters(EGLint renderer, EGLint majorVersion, EGLint minorVersion, EGLint deviceType);
Geoff Lang0d3683c2014-10-23 11:08:16 -040038};
39
Jamie Madill1cfaaf82014-08-21 10:04:04 -040040class EGLWindow
41{
42 public:
Geoff Lang0d3683c2014-10-23 11:08:16 -040043 EGLWindow(size_t width, size_t height, EGLint glesMajorVersion, const EGLPlatformParameters &platform);
Jamie Madill1cfaaf82014-08-21 10:04:04 -040044
45 ~EGLWindow();
46
Jamie Madill62af5462014-08-26 13:16:37 -040047 void setClientVersion(EGLint glesMajorVersion) { mClientVersion = glesMajorVersion; }
48 void setWidth(size_t width) { mWidth = width; }
49 void setHeight(size_t height) { mHeight = height; }
Jamie Madill3757a5a2014-08-26 13:16:36 -040050 void setConfigRedBits(int bits) { mRedBits = bits; }
51 void setConfigGreenBits(int bits) { mGreenBits = bits; }
52 void setConfigBlueBits(int bits) { mBlueBits = bits; }
53 void setConfigAlphaBits(int bits) { mAlphaBits = bits; }
54 void setConfigDepthBits(int bits) { mDepthBits = bits; }
55 void setConfigStencilBits(int bits) { mStencilBits = bits; }
56 void setMultisample(bool multisample) { mMultisample = multisample; }
57 void setSwapInterval(EGLint swapInterval) { mSwapInterval = swapInterval; }
58
Jamie Madill1cfaaf82014-08-21 10:04:04 -040059 void swap();
60
Jamie Madill62af5462014-08-26 13:16:37 -040061 GLuint getClientVersion() const { return mClientVersion; }
Geoff Lang0d3683c2014-10-23 11:08:16 -040062 const EGLPlatformParameters &getPlatform() const { return mPlatform; }
Jamie Madill1cfaaf82014-08-21 10:04:04 -040063 EGLConfig getConfig() const;
64 EGLDisplay getDisplay() const;
65 EGLSurface getSurface() const;
66 EGLContext getContext() const;
67 size_t getWidth() const { return mWidth; }
68 size_t getHeight() const { return mHeight; }
Jamie Madill3757a5a2014-08-26 13:16:36 -040069 int getConfigRedBits() const { return mRedBits; }
70 int getConfigGreenBits() const { return mGreenBits; }
71 int getConfigBlueBits() const { return mBlueBits; }
72 int getConfigAlphaBits() const { return mAlphaBits; }
73 int getConfigDepthBits() const { return mDepthBits; }
74 int getConfigStencilBits() const { return mStencilBits; }
75 bool isMultisample() const { return mMultisample; }
76 EGLint getSwapInterval() const { return mSwapInterval; }
Jamie Madill1cfaaf82014-08-21 10:04:04 -040077
Austin Kinross18b931d2014-09-29 12:58:31 -070078 bool initializeGL(OSWindow *osWindow);
Jamie Madill1cfaaf82014-08-21 10:04:04 -040079 void destroyGL();
80
81 private:
82 DISALLOW_COPY_AND_ASSIGN(EGLWindow);
83
84 EGLConfig mConfig;
85 EGLDisplay mDisplay;
86 EGLSurface mSurface;
87 EGLContext mContext;
88
89 GLuint mClientVersion;
Geoff Lang0d3683c2014-10-23 11:08:16 -040090 EGLPlatformParameters mPlatform;
Jamie Madill1cfaaf82014-08-21 10:04:04 -040091 size_t mWidth;
92 size_t mHeight;
Jamie Madill3757a5a2014-08-26 13:16:36 -040093 int mRedBits;
94 int mGreenBits;
95 int mBlueBits;
96 int mAlphaBits;
97 int mDepthBits;
98 int mStencilBits;
99 bool mMultisample;
100 EGLint mSwapInterval;
Jamie Madill1cfaaf82014-08-21 10:04:04 -0400101};
102
103#endif // UTIL_EGLWINDOW_H_