mirror of
https://github.com/libretro/RetroArch
synced 2025-03-26 02:37:23 +00:00
Implement WGL core context.
This commit is contained in:
parent
e28f5d7cc1
commit
b090f5ab36
@ -39,6 +39,8 @@ static HDC g_hdc;
|
|||||||
static HMONITOR g_last_hm;
|
static HMONITOR g_last_hm;
|
||||||
static HMONITOR g_all_hms[MAX_MONITORS];
|
static HMONITOR g_all_hms[MAX_MONITORS];
|
||||||
static unsigned g_num_mons;
|
static unsigned g_num_mons;
|
||||||
|
static unsigned g_major;
|
||||||
|
static unsigned g_minor;
|
||||||
|
|
||||||
static bool g_quit;
|
static bool g_quit;
|
||||||
static bool g_inited;
|
static bool g_inited;
|
||||||
@ -58,6 +60,9 @@ static void gfx_ctx_destroy(void);
|
|||||||
|
|
||||||
static BOOL (APIENTRY *p_swap_interval)(int);
|
static BOOL (APIENTRY *p_swap_interval)(int);
|
||||||
|
|
||||||
|
typedef HGLRC (APIENTRY *wglCreateContextAttribsProc)(HDC, HGLRC, const int*);
|
||||||
|
static wglCreateContextAttribsProc pcreate_context;
|
||||||
|
|
||||||
static void setup_pixel_format(HDC hdc)
|
static void setup_pixel_format(HDC hdc)
|
||||||
{
|
{
|
||||||
PIXELFORMATDESCRIPTOR pfd = {0};
|
PIXELFORMATDESCRIPTOR pfd = {0};
|
||||||
@ -87,7 +92,53 @@ static void create_gl_context(HWND hwnd)
|
|||||||
g_quit = true;
|
g_quit = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
g_quit = true;
|
g_quit = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (g_major * 1000 + g_minor >= 3001) // Create core context
|
||||||
|
{
|
||||||
|
#ifndef WGL_CONTEXT_MAJOR_VERSION_ARB
|
||||||
|
#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091
|
||||||
|
#endif
|
||||||
|
#ifndef WGL_CONTEXT_MINOR_VERSION_ARB
|
||||||
|
#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092
|
||||||
|
#endif
|
||||||
|
#ifndef WGL_CONTEXT_PROFILE_MASK_ARB
|
||||||
|
#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126
|
||||||
|
#endif
|
||||||
|
#ifndef WGL_CONTEXT_CORE_PROFILE_BIT_ARB
|
||||||
|
#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x0001
|
||||||
|
#endif
|
||||||
|
const int attribs[] = {
|
||||||
|
WGL_CONTEXT_MAJOR_VERSION_ARB, g_major,
|
||||||
|
WGL_CONTEXT_MINOR_VERSION_ARB, g_minor,
|
||||||
|
WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
|
||||||
|
0,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!pcreate_context)
|
||||||
|
pcreate_context = (wglCreateContextAttribsProc)wglGetProcAddress("wglCreateContextAttribsARB");
|
||||||
|
|
||||||
|
if (pcreate_context)
|
||||||
|
{
|
||||||
|
HGLRC context = pcreate_context(g_hdc, NULL, attribs);
|
||||||
|
|
||||||
|
if (context)
|
||||||
|
{
|
||||||
|
wglMakeCurrent(NULL, NULL);
|
||||||
|
wglDeleteContext(g_hrc);
|
||||||
|
g_hrc = context;
|
||||||
|
if (!wglMakeCurrent(g_hdc, g_hrc))
|
||||||
|
g_quit = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
RARCH_ERR("[WGL]: Failed to create core context. Falling back to legacy context.\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
RARCH_ERR("[WGL]: wglCreateContextAttribsARB not supported.\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool BrowseForFile(char *filename)
|
static bool BrowseForFile(char *filename)
|
||||||
@ -462,6 +513,7 @@ static void gfx_ctx_destroy(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
g_inited = false;
|
g_inited = false;
|
||||||
|
g_major = g_minor = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gfx_ctx_input_driver(const input_driver_t **input, void **input_data)
|
static void gfx_ctx_input_driver(const input_driver_t **input, void **input_data)
|
||||||
@ -486,8 +538,8 @@ static gfx_ctx_proc_t gfx_ctx_get_proc_address(const char *symbol)
|
|||||||
|
|
||||||
static bool gfx_ctx_bind_api(enum gfx_ctx_api api, unsigned major, unsigned minor)
|
static bool gfx_ctx_bind_api(enum gfx_ctx_api api, unsigned major, unsigned minor)
|
||||||
{
|
{
|
||||||
(void)major;
|
g_major = major;
|
||||||
(void)minor;
|
g_minor = minor;
|
||||||
return api == GFX_CTX_OPENGL_API;
|
return api == GFX_CTX_OPENGL_API;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
3
gfx/gl.c
3
gfx/gl.c
@ -182,9 +182,6 @@ static PFNGLDELETEVERTEXARRAYSPROC pglDeleteVertexArrays;
|
|||||||
|
|
||||||
static bool load_vao_proc(gl_t *gl)
|
static bool load_vao_proc(gl_t *gl)
|
||||||
{
|
{
|
||||||
if (!gl_query_extension(gl, "ARB_vertex_array_object"))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
LOAD_GL_SYM(GenVertexArrays);
|
LOAD_GL_SYM(GenVertexArrays);
|
||||||
LOAD_GL_SYM(BindVertexArray);
|
LOAD_GL_SYM(BindVertexArray);
|
||||||
LOAD_GL_SYM(DeleteVertexArrays);
|
LOAD_GL_SYM(DeleteVertexArrays);
|
||||||
|
@ -325,7 +325,7 @@ void retro_run(void)
|
|||||||
pglBindFramebuffer(GL_FRAMEBUFFER, hw_render.get_current_framebuffer());
|
pglBindFramebuffer(GL_FRAMEBUFFER, hw_render.get_current_framebuffer());
|
||||||
glClearColor(0.3, 0.4, 0.5, 1.0);
|
glClearColor(0.3, 0.4, 0.5, 1.0);
|
||||||
glViewport(0, 0, width, height);
|
glViewport(0, 0, width, height);
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
||||||
|
|
||||||
pglUseProgram(prog);
|
pglUseProgram(prog);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user