Commit 3757a5ae by Jamie Madill

Allow app to specify EGL Window extra parameters.

Extra parameters include pixel bit sizes, swap interval and if we want multisampling. This gives parity between the tests and samples EGL creation options. BUG=angle:730 Change-Id: I68d619c2ea141794f0089456bb6bba3d3b1c2a07 Reviewed-on: https://chromium-review.googlesource.com/213296Reviewed-by: 's avatarBrandon Jones <bajones@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 8add0eb7
......@@ -15,6 +15,16 @@ SampleApplication::SampleApplication(const std::string& name, size_t width, size
mEGLWindow.reset(new EGLWindow(width, height, glesMajorVersion, requestedRenderer));
mTimer.reset(CreateTimer());
mOSWindow.reset(CreateOSWindow());
mEGLWindow->setConfigRedBits(8);
mEGLWindow->setConfigGreenBits(8);
mEGLWindow->setConfigBlueBits(8);
mEGLWindow->setConfigAlphaBits(8);
mEGLWindow->setConfigDepthBits(24);
mEGLWindow->setConfigStencilBits(8);
// Disable vsync
mEGLWindow->setSwapInterval(0);
}
SampleApplication::~SampleApplication()
......
......@@ -24,7 +24,15 @@ EGLWindow::EGLWindow(size_t width, size_t height,
mClientVersion(glesMajorVersion),
mRequestedRenderer(requestedRenderer),
mWidth(width),
mHeight(height)
mHeight(height),
mRedBits(-1),
mGreenBits(-1),
mBlueBits(-1),
mAlphaBits(-1),
mDepthBits(-1),
mStencilBits(-1),
mMultisample(false),
mSwapInterval(-1)
{
}
......@@ -95,13 +103,13 @@ bool EGLWindow::initializeGL(const OSWindow *osWindow)
const EGLint configAttributes[] =
{
EGL_RED_SIZE, 8,
EGL_GREEN_SIZE, 8,
EGL_BLUE_SIZE, 8,
EGL_ALPHA_SIZE, 8,
EGL_DEPTH_SIZE, 24,
EGL_STENCIL_SIZE, 8,
EGL_SAMPLE_BUFFERS, EGL_DONT_CARE,
EGL_RED_SIZE, (mRedBits >= 0) ? mRedBits : EGL_DONT_CARE,
EGL_GREEN_SIZE, (mGreenBits >= 0) ? mGreenBits : EGL_DONT_CARE,
EGL_BLUE_SIZE, (mBlueBits >= 0) ? mBlueBits : EGL_DONT_CARE,
EGL_ALPHA_SIZE, (mAlphaBits >= 0) ? mAlphaBits : EGL_DONT_CARE,
EGL_DEPTH_SIZE, (mDepthBits >= 0) ? mDepthBits : EGL_DONT_CARE,
EGL_STENCIL_SIZE, (mStencilBits >= 0) ? mStencilBits : EGL_DONT_CARE,
EGL_SAMPLE_BUFFERS, mMultisample ? 1 : 0,
EGL_NONE
};
......@@ -112,6 +120,13 @@ bool EGLWindow::initializeGL(const OSWindow *osWindow)
return false;
}
eglGetConfigAttrib(mDisplay, mConfig, EGL_RED_SIZE, &mRedBits);
eglGetConfigAttrib(mDisplay, mConfig, EGL_GREEN_SIZE, &mGreenBits);
eglGetConfigAttrib(mDisplay, mConfig, EGL_BLUE_SIZE, &mBlueBits);
eglGetConfigAttrib(mDisplay, mConfig, EGL_ALPHA_SIZE, &mBlueBits);
eglGetConfigAttrib(mDisplay, mConfig, EGL_DEPTH_SIZE, &mDepthBits);
eglGetConfigAttrib(mDisplay, mConfig, EGL_STENCIL_SIZE, &mStencilBits);
const EGLint surfaceAttributes[] =
{
EGL_POST_SUB_BUFFER_SUPPORTED_NV, EGL_TRUE,
......@@ -136,6 +151,7 @@ bool EGLWindow::initializeGL(const OSWindow *osWindow)
EGL_CONTEXT_CLIENT_VERSION, mClientVersion,
EGL_NONE
};
mContext = eglCreateContext(mDisplay, mConfig, NULL, contextAttibutes);
if (eglGetError() != EGL_SUCCESS)
{
......@@ -150,8 +166,10 @@ bool EGLWindow::initializeGL(const OSWindow *osWindow)
return false;
}
// Turn off vsync
eglSwapInterval(mDisplay, 0);
if (mSwapInterval != -1)
{
eglSwapInterval(mDisplay, mSwapInterval);
}
return true;
}
......
......@@ -38,6 +38,15 @@ class EGLWindow
~EGLWindow();
void setConfigRedBits(int bits) { mRedBits = bits; }
void setConfigGreenBits(int bits) { mGreenBits = bits; }
void setConfigBlueBits(int bits) { mBlueBits = bits; }
void setConfigAlphaBits(int bits) { mAlphaBits = bits; }
void setConfigDepthBits(int bits) { mDepthBits = bits; }
void setConfigStencilBits(int bits) { mStencilBits = bits; }
void setMultisample(bool multisample) { mMultisample = multisample; }
void setSwapInterval(EGLint swapInterval) { mSwapInterval = swapInterval; }
void swap();
EGLConfig getConfig() const;
......@@ -46,6 +55,14 @@ class EGLWindow
EGLContext getContext() const;
size_t getWidth() const { return mWidth; }
size_t getHeight() const { return mHeight; }
int getConfigRedBits() const { return mRedBits; }
int getConfigGreenBits() const { return mGreenBits; }
int getConfigBlueBits() const { return mBlueBits; }
int getConfigAlphaBits() const { return mAlphaBits; }
int getConfigDepthBits() const { return mDepthBits; }
int getConfigStencilBits() const { return mStencilBits; }
bool isMultisample() const { return mMultisample; }
EGLint getSwapInterval() const { return mSwapInterval; }
bool initializeGL(const OSWindow *osWindow);
void destroyGL();
......@@ -62,6 +79,14 @@ class EGLWindow
EGLint mRequestedRenderer;
size_t mWidth;
size_t mHeight;
int mRedBits;
int mGreenBits;
int mBlueBits;
int mAlphaBits;
int mDepthBits;
int mStencilBits;
bool mMultisample;
EGLint mSwapInterval;
};
#endif // UTIL_EGLWINDOW_H_
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment