mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-08-06 22:08:41 +00:00
eliminate dummy window egl setup
This commit is contained in:
@@ -52,6 +52,53 @@ r_ogl_os_init(CmdLine *cmdln)
|
|||||||
os_abort(1);
|
os_abort(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//- rjf: construct context
|
||||||
|
{
|
||||||
|
B32 debug_mode = cmd_line_has_flag(cmdln, str8_lit("opengl_debug"));
|
||||||
|
#if BUILD_DEBUG
|
||||||
|
debug_mode = 1;
|
||||||
|
#endif
|
||||||
|
EGLint options[] =
|
||||||
|
{
|
||||||
|
EGL_CONTEXT_MAJOR_VERSION, 3,
|
||||||
|
EGL_CONTEXT_MINOR_VERSION, 3,
|
||||||
|
EGL_CONTEXT_OPENGL_PROFILE_MASK, EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT,
|
||||||
|
debug_mode ? EGL_CONTEXT_OPENGL_DEBUG : EGL_NONE, EGL_TRUE,
|
||||||
|
EGL_NONE,
|
||||||
|
};
|
||||||
|
r_ogl_lnx_state->context = eglCreateContext(r_ogl_lnx_state->display, 0, EGL_NO_CONTEXT, options);
|
||||||
|
if(r_ogl_lnx_state->context == EGL_NO_CONTEXT)
|
||||||
|
{
|
||||||
|
os_graphical_message(1, str8_lit("Fatal Error"), str8_lit("Couldn't create OpenGL context with EGL."));
|
||||||
|
os_abort(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
eglMakeCurrent(r_ogl_lnx_state->display, 0, 0, r_ogl_lnx_state->context);
|
||||||
|
glDrawBuffer(GL_BACK);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal R_Handle
|
||||||
|
r_ogl_os_window_equip(OS_Handle window)
|
||||||
|
{
|
||||||
|
OS_LNX_Window *window_os = (OS_LNX_Window *)window.u64[0];
|
||||||
|
R_OGL_LNX_Window *w = r_ogl_lnx_state->free_window;
|
||||||
|
if(w != 0)
|
||||||
|
{
|
||||||
|
SLLStackPop(r_ogl_lnx_state->free_window);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
w = push_array(r_ogl_lnx_state->arena, R_OGL_LNX_Window, 1);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
EGLint surface_options[] =
|
||||||
|
{
|
||||||
|
EGL_GL_COLORSPACE, EGL_GL_COLORSPACE_SRGB,
|
||||||
|
EGL_NONE,
|
||||||
|
};
|
||||||
|
if(r_ogl_lnx_state->config == 0)
|
||||||
|
{
|
||||||
//- rjf: get all EGL configs
|
//- rjf: get all EGL configs
|
||||||
EGLConfig configs[256] = {0};
|
EGLConfig configs[256] = {0};
|
||||||
EGLint configs_count = 0;
|
EGLint configs_count = 0;
|
||||||
@@ -80,19 +127,17 @@ r_ogl_os_init(CmdLine *cmdln)
|
|||||||
|
|
||||||
//- rjf: actually choose the egl config
|
//- rjf: actually choose the egl config
|
||||||
{
|
{
|
||||||
Window dummy_window = XCreateWindow(os_lnx_gfx_state->display, XDefaultRootWindow(os_lnx_gfx_state->display), 0, 0, 100, 100, 0, CopyFromParent, InputOutput, CopyFromParent, 0, 0);
|
EGLint config_options[] =
|
||||||
EGLint options[] =
|
|
||||||
{
|
{
|
||||||
EGL_GL_COLORSPACE, EGL_GL_COLORSPACE_SRGB,
|
EGL_GL_COLORSPACE, EGL_GL_COLORSPACE_SRGB,
|
||||||
EGL_NONE,
|
EGL_NONE,
|
||||||
};
|
};
|
||||||
for(U32 idx = 0; idx < configs_count; idx += 1)
|
for(U32 idx = 0; idx < configs_count; idx += 1)
|
||||||
{
|
{
|
||||||
EGLSurface *dummy_surface = eglCreateWindowSurface(r_ogl_lnx_state->display, configs[idx], dummy_window, options);
|
w->surface = eglCreateWindowSurface(r_ogl_lnx_state->display, configs[idx], window_os->window, config_options);
|
||||||
if(dummy_surface != EGL_NO_SURFACE)
|
if(w->surface != EGL_NO_SURFACE)
|
||||||
{
|
{
|
||||||
r_ogl_lnx_state->config = configs[idx];
|
r_ogl_lnx_state->config = configs[idx];
|
||||||
eglDestroySurface(r_ogl_lnx_state->display, dummy_surface);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -101,54 +146,12 @@ r_ogl_os_init(CmdLine *cmdln)
|
|||||||
os_graphical_message(1, str8_lit("Fatal Error"), str8_lit("Couldn't find a suitable EGL configuration."));
|
os_graphical_message(1, str8_lit("Fatal Error"), str8_lit("Couldn't find a suitable EGL configuration."));
|
||||||
os_abort(1);
|
os_abort(1);
|
||||||
}
|
}
|
||||||
XDestroyWindow(os_lnx_gfx_state->display, dummy_window);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//- rjf: construct context
|
|
||||||
{
|
|
||||||
B32 debug_mode = cmd_line_has_flag(cmdln, str8_lit("opengl_debug"));
|
|
||||||
#if BUILD_DEBUG
|
|
||||||
debug_mode = 1;
|
|
||||||
#endif
|
|
||||||
EGLint options[] =
|
|
||||||
{
|
|
||||||
EGL_CONTEXT_MAJOR_VERSION, 3,
|
|
||||||
EGL_CONTEXT_MINOR_VERSION, 3,
|
|
||||||
EGL_CONTEXT_OPENGL_PROFILE_MASK, EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT,
|
|
||||||
debug_mode ? EGL_CONTEXT_OPENGL_DEBUG : EGL_NONE, EGL_TRUE,
|
|
||||||
EGL_NONE,
|
|
||||||
};
|
|
||||||
r_ogl_lnx_state->context = eglCreateContext(r_ogl_lnx_state->display, r_ogl_lnx_state->config, EGL_NO_CONTEXT, options);
|
|
||||||
if(r_ogl_lnx_state->context == EGL_NO_CONTEXT)
|
|
||||||
{
|
|
||||||
os_graphical_message(1, str8_lit("Fatal Error"), str8_lit("Couldn't create OpenGL context with EGL."));
|
|
||||||
os_abort(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
eglMakeCurrent(r_ogl_lnx_state->display, 0, 0, r_ogl_lnx_state->context);
|
|
||||||
}
|
|
||||||
|
|
||||||
internal R_Handle
|
|
||||||
r_ogl_os_window_equip(OS_Handle window)
|
|
||||||
{
|
|
||||||
OS_LNX_Window *window_os = (OS_LNX_Window *)window.u64[0];
|
|
||||||
R_OGL_LNX_Window *w = r_ogl_lnx_state->free_window;
|
|
||||||
if(w != 0)
|
|
||||||
{
|
|
||||||
SLLStackPop(r_ogl_lnx_state->free_window);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
w = push_array(r_ogl_lnx_state->arena, R_OGL_LNX_Window, 1);
|
w->surface = eglCreateWindowSurface(r_ogl_lnx_state->display, r_ogl_lnx_state->config, window_os->window, surface_options);
|
||||||
}
|
}
|
||||||
{
|
|
||||||
EGLint options[] =
|
|
||||||
{
|
|
||||||
EGL_GL_COLORSPACE, EGL_GL_COLORSPACE_SRGB,
|
|
||||||
EGL_NONE,
|
|
||||||
};
|
|
||||||
w->surface = eglCreateWindowSurface(r_ogl_lnx_state->display, r_ogl_lnx_state->config, window_os->window, options);
|
|
||||||
if(w->surface == EGL_NO_SURFACE)
|
if(w->surface == EGL_NO_SURFACE)
|
||||||
{
|
{
|
||||||
os_graphical_message(1, str8_lit("Fatal Error"), str8_lit("Couldn't create EGL surface."));
|
os_graphical_message(1, str8_lit("Fatal Error"), str8_lit("Couldn't create EGL surface."));
|
||||||
|
|||||||
Reference in New Issue
Block a user