Update Mirror Window context creation
This commit is contained in:
@@ -17,6 +17,8 @@
|
||||
|
||||
#include <xcb/xcb.h>
|
||||
|
||||
#include "context.inl"
|
||||
|
||||
#ifdef __unix
|
||||
#include <signal.h>
|
||||
#endif
|
||||
@@ -118,82 +120,6 @@ static const EGLint egl_surface_attribs[] = {
|
||||
EGL_NONE,
|
||||
};
|
||||
|
||||
void CreateContext(
|
||||
EGLint api,
|
||||
EGLNativeWindowType native_window,
|
||||
EGLDisplay* out_display,
|
||||
EGLConfig* out_config,
|
||||
EGLContext* out_context,
|
||||
EGLSurface* out_window_surface) {
|
||||
|
||||
EGLint ignore;
|
||||
EGLBoolean ok;
|
||||
|
||||
ok = eglBindAPI(api);
|
||||
if (!ok)
|
||||
exit(-1);
|
||||
|
||||
EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
||||
if (display == EGL_NO_DISPLAY)
|
||||
exit(-1);
|
||||
|
||||
ok = eglInitialize(display, &ignore, &ignore);
|
||||
if (!ok)
|
||||
exit(-1);
|
||||
|
||||
EGLint configs_size = 256;
|
||||
EGLConfig configs [configs_size];
|
||||
EGLint num_configs;
|
||||
ok = eglChooseConfig(
|
||||
display,
|
||||
egl_config_attribs,
|
||||
configs,
|
||||
configs_size, // num requested configs
|
||||
&num_configs); // num returned configs
|
||||
if (!ok)
|
||||
exit(-1);
|
||||
if (num_configs == 0)
|
||||
exit(-1);
|
||||
EGLConfig config = configs[0];
|
||||
|
||||
EGLContext context = eglCreateContext(
|
||||
display,
|
||||
config,
|
||||
EGL_NO_CONTEXT, // can't share between 2 different drivers
|
||||
egl_context_attribs);
|
||||
if (!context)
|
||||
exit(-1);
|
||||
|
||||
EGLSurface surface = eglCreateWindowSurface(
|
||||
display,
|
||||
config,
|
||||
native_window,
|
||||
egl_surface_attribs);
|
||||
if (!surface)
|
||||
exit(-1);
|
||||
|
||||
ok = eglMakeCurrent(display, surface, surface, context);
|
||||
if (!ok)
|
||||
exit(-1);
|
||||
|
||||
// Check if surface is double buffered.
|
||||
EGLint render_buffer;
|
||||
ok = eglQueryContext(
|
||||
display,
|
||||
context,
|
||||
EGL_RENDER_BUFFER,
|
||||
&render_buffer);
|
||||
if (!ok)
|
||||
exit(-1);
|
||||
if (render_buffer == EGL_SINGLE_BUFFER)
|
||||
printf("warn: EGL surface is single buffered\n");
|
||||
|
||||
*out_display = display;
|
||||
*out_config = config;
|
||||
*out_context = context;
|
||||
*out_window_surface = surface;
|
||||
}
|
||||
|
||||
void init_gl(gl_ctx* ctx, int w, int h)
|
||||
{
|
||||
memset(ctx, 0, sizeof(gl_ctx));
|
||||
@@ -217,16 +143,11 @@ void init_gl(gl_ctx* ctx, int w, int h)
|
||||
ctx->h = h;
|
||||
ctx->is_fullscreen = 0;
|
||||
|
||||
CreateContext(EGL_OPENGL_API,
|
||||
ctx->x_window,
|
||||
&ctx->egl_display,
|
||||
&ctx->egl_config,
|
||||
&ctx->egl_context,
|
||||
&ctx->egl_surface);
|
||||
bool bContextCreated = create_context(EGL_DEFAULT_DISPLAY, ctx->x_window, egl_config_attribs, egl_context_attribs, egl_surface_attribs, &ctx->egl_display, &ctx->egl_context, &ctx->egl_surface);
|
||||
|
||||
if(ctx->egl_context == EGL_NO_CONTEXT)
|
||||
if(!bContextCreated || ctx->egl_context == EGL_NO_CONTEXT)
|
||||
{
|
||||
printf("CreateContext\n");
|
||||
printf("CreateContext failed\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user