mirror of
https://github.com/libretro/RetroArch
synced 2025-03-22 16:20:58 +00:00
compile fixes
bind API before initializing context
This commit is contained in:
parent
d0e220bbf1
commit
df77bbd0bd
2
Makefile
2
Makefile
@ -164,7 +164,7 @@ ifeq ($(HAVE_SDL), 1)
|
|||||||
# videocore's libs set later
|
# videocore's libs set later
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(HAVE_X11), 1)
|
ifeq ($(HAVE_XVIDEO), 1)
|
||||||
ifeq ($(HAVE_EGL), 1)
|
ifeq ($(HAVE_EGL), 1)
|
||||||
OBJ += gfx/context/xegl_ctx.o
|
OBJ += gfx/context/xegl_ctx.o
|
||||||
DEFINES += $(EGL_CFLAGS)
|
DEFINES += $(EGL_CFLAGS)
|
||||||
|
@ -442,7 +442,7 @@ static bool gfx_ctx_set_video_mode(
|
|||||||
if (!eglChooseConfig(g_egl_dpy, config_attribs, &g_config, 1, &n) || n != 1)
|
if (!eglChooseConfig(g_egl_dpy, config_attribs, &g_config, 1, &n) || n != 1)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
g_egl_ctx = eglCreateContext(g_egl_dpy, g_config, EGL_NO_CONTEXT, (driver.video == &video_gl) ? context_attribs : NULL);
|
g_egl_ctx = eglCreateContext(g_egl_dpy, g_config, EGL_NO_CONTEXT, (g_api == GFX_CTX_OPENGL_ES_API) ? context_attribs : NULL);
|
||||||
if (!g_egl_ctx)
|
if (!g_egl_ctx)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ static EGLConfig g_config;
|
|||||||
|
|
||||||
static volatile sig_atomic_t g_quit;
|
static volatile sig_atomic_t g_quit;
|
||||||
static bool g_inited;
|
static bool g_inited;
|
||||||
static gfx_ctx_api g_api;
|
static enum gfx_ctx_api g_api;
|
||||||
|
|
||||||
static unsigned g_fb_width; // Just use something for now.
|
static unsigned g_fb_width; // Just use something for now.
|
||||||
static unsigned g_fb_height;
|
static unsigned g_fb_height;
|
||||||
@ -60,7 +60,7 @@ static void sighandler(int sig)
|
|||||||
g_quit = 1;
|
g_quit = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gfx_ctx_set_swap_interval(unsigned interval, bool inited)
|
static void gfx_ctx_swap_interval(unsigned interval)
|
||||||
{
|
{
|
||||||
eglSwapInterval(g_egl_dpy, interval);
|
eglSwapInterval(g_egl_dpy, interval);
|
||||||
}
|
}
|
||||||
@ -100,6 +100,7 @@ static void gfx_ctx_get_video_size(unsigned *width, unsigned *height)
|
|||||||
|
|
||||||
static bool gfx_ctx_init(void)
|
static bool gfx_ctx_init(void)
|
||||||
{
|
{
|
||||||
|
RARCH_LOG("[VC/EGL]: Initializing...\n");
|
||||||
if (g_inited)
|
if (g_inited)
|
||||||
{
|
{
|
||||||
RARCH_ERR("[VC/EGL]: Attempted to re-initialize driver.\n");
|
RARCH_ERR("[VC/EGL]: Attempted to re-initialize driver.\n");
|
||||||
@ -150,7 +151,7 @@ static bool gfx_ctx_init(void)
|
|||||||
rarch_assert(result != EGL_FALSE);
|
rarch_assert(result != EGL_FALSE);
|
||||||
|
|
||||||
// create an EGL rendering context
|
// create an EGL rendering context
|
||||||
g_egl_ctx = eglCreateContext(g_egl_dpy, g_config, EGL_NO_CONTEXT, (driver.video == &video_gl) ? context_attributes : NULL);
|
g_egl_ctx = eglCreateContext(g_egl_dpy, g_config, EGL_NO_CONTEXT, (g_api == GFX_CTX_OPENGL_ES_API) ? context_attributes : NULL);
|
||||||
rarch_assert(g_egl_ctx != EGL_NO_CONTEXT);
|
rarch_assert(g_egl_ctx != EGL_NO_CONTEXT);
|
||||||
|
|
||||||
// create an EGL window surface
|
// create an EGL window surface
|
||||||
@ -238,7 +239,7 @@ static void gfx_ctx_input_driver(const input_driver_t **input, void **input_data
|
|||||||
*input_data = linuxinput;
|
*input_data = linuxinput;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool gfx_ctx_window_has_focus(void)
|
static bool gfx_ctx_has_focus(void)
|
||||||
{
|
{
|
||||||
return g_inited;
|
return g_inited;
|
||||||
}
|
}
|
||||||
|
@ -307,7 +307,7 @@ static bool gfx_ctx_set_video_mode(
|
|||||||
CWBorderPixel | CWColormap | CWEventMask, &swa);
|
CWBorderPixel | CWColormap | CWEventMask, &swa);
|
||||||
XSetWindowBackground(g_dpy, g_win, 0);
|
XSetWindowBackground(g_dpy, g_win, 0);
|
||||||
|
|
||||||
g_egl_ctx = eglCreateContext(g_egl_dpy, g_config, EGL_NO_CONTEXT, (driver.video == &video_gl) ? egl_ctx_attribs : NULL);
|
g_egl_ctx = eglCreateContext(g_egl_dpy, g_config, EGL_NO_CONTEXT, (g_api == GFX_CTX_OPENGL_ES_API) ? egl_ctx_attribs : NULL);
|
||||||
if (!g_egl_ctx)
|
if (!g_egl_ctx)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ static const gfx_ctx_driver_t *gfx_ctx_drivers[] = {
|
|||||||
#if defined(HAVE_SDL) && defined(HAVE_OPENGL)
|
#if defined(HAVE_SDL) && defined(HAVE_OPENGL)
|
||||||
&gfx_ctx_sdl_gl,
|
&gfx_ctx_sdl_gl,
|
||||||
#endif
|
#endif
|
||||||
#if defined(HAVE_X11) && defined(HAVE_EGL)
|
#if defined(HAVE_XVIDEO) && defined(HAVE_EGL)
|
||||||
&gfx_ctx_x_egl,
|
&gfx_ctx_x_egl,
|
||||||
#endif
|
#endif
|
||||||
#if defined(HAVE_KMS)
|
#if defined(HAVE_KMS)
|
||||||
@ -52,15 +52,12 @@ const gfx_ctx_driver_t *gfx_ctx_init_first(enum gfx_ctx_api api)
|
|||||||
{
|
{
|
||||||
for (unsigned i = 0; i < sizeof(gfx_ctx_drivers) / sizeof(gfx_ctx_drivers[0]); i++)
|
for (unsigned i = 0; i < sizeof(gfx_ctx_drivers) / sizeof(gfx_ctx_drivers[0]); i++)
|
||||||
{
|
{
|
||||||
if (gfx_ctx_drivers[i]->init())
|
if (gfx_ctx_drivers[i]->bind_api(api))
|
||||||
{
|
{
|
||||||
if (gfx_ctx_drivers[i]->bind_api(api))
|
if (gfx_ctx_drivers[i]->init())
|
||||||
return gfx_ctx_drivers[i];
|
return gfx_ctx_drivers[i];
|
||||||
else
|
|
||||||
gfx_ctx_drivers[i]->destroy();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
43
gfx/vg.c
43
gfx/vg.c
@ -30,6 +30,7 @@
|
|||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
const gfx_ctx_driver_t *driver;
|
||||||
uint32_t mScreenWidth;
|
uint32_t mScreenWidth;
|
||||||
uint32_t mScreenHeight;
|
uint32_t mScreenHeight;
|
||||||
float mScreenAspect;
|
float mScreenAspect;
|
||||||
@ -60,8 +61,8 @@ typedef struct
|
|||||||
|
|
||||||
static void vg_set_nonblock_state(void *data, bool state)
|
static void vg_set_nonblock_state(void *data, bool state)
|
||||||
{
|
{
|
||||||
(void)data;
|
vg_t *vg = (vg_t*)data;
|
||||||
gfx_ctx_set_swap_interval(state ? 0 : 1, true);
|
vg->driver->swap_interval(state ? 0 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *vg_init(const video_info_t *video, const input_driver_t **input, void **input_data)
|
static void *vg_init(const video_info_t *video, const input_driver_t **input, void **input_data)
|
||||||
@ -70,23 +71,39 @@ static void *vg_init(const video_info_t *video, const input_driver_t **input, vo
|
|||||||
if (!vg)
|
if (!vg)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!eglBindAPI(EGL_OPENVG_API))
|
vg->driver = gfx_ctx_init_first(GFX_CTX_OPENVG_API);
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if (!gfx_ctx_init())
|
if (!vg->driver)
|
||||||
{
|
{
|
||||||
free(vg);
|
free(vg);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx_ctx_get_video_size(&vg->mScreenWidth, &vg->mScreenHeight);
|
vg->driver->get_video_size(&vg->mScreenWidth, &vg->mScreenHeight);
|
||||||
RARCH_LOG("Detecting screen resolution %ux%u.\n", vg->mScreenWidth, vg->mScreenHeight);
|
RARCH_LOG("Detecting screen resolution %ux%u.\n", vg->mScreenWidth, vg->mScreenHeight);
|
||||||
|
|
||||||
gfx_ctx_set_swap_interval(video->vsync ? 1 : 0, false);
|
vg->driver->swap_interval(video->vsync ? 1 : 0);
|
||||||
|
|
||||||
vg->mTexType = video->rgb32 ? VG_sABGR_8888 : VG_sARGB_1555;
|
vg->mTexType = video->rgb32 ? VG_sABGR_8888 : VG_sARGB_1555;
|
||||||
vg->mKeepAspect = video->force_aspect;
|
vg->mKeepAspect = video->force_aspect;
|
||||||
|
|
||||||
|
unsigned win_width = video->width;
|
||||||
|
unsigned win_height = video->height;
|
||||||
|
if (video->fullscreen && (win_width == 0) && (win_height == 0))
|
||||||
|
{
|
||||||
|
win_width = vg->mScreenWidth;
|
||||||
|
win_height = vg->mScreenHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!vg->driver->set_video_mode(vg->mScreenWidth, vg->mScreenHeight,
|
||||||
|
g_settings.video.force_16bit ? 15 : 0, video->fullscreen))
|
||||||
|
{
|
||||||
|
free(vg);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
vg->driver->get_video_size(&vg->mScreenWidth, &vg->mScreenHeight);
|
||||||
|
|
||||||
// check for SD televisions: they should always be 4:3
|
// check for SD televisions: they should always be 4:3
|
||||||
if ((vg->mScreenWidth == 640 || vg->mScreenWidth == 720) && (vg->mScreenHeight == 480 || vg->mScreenHeight == 576))
|
if ((vg->mScreenWidth == 640 || vg->mScreenWidth == 720) && (vg->mScreenHeight == 480 || vg->mScreenHeight == 576))
|
||||||
vg->mScreenAspect = 4.0f / 3.0f;
|
vg->mScreenAspect = 4.0f / 3.0f;
|
||||||
@ -106,7 +123,7 @@ static void *vg_init(const video_info_t *video, const input_driver_t **input, vo
|
|||||||
video->smooth ? VG_IMAGE_QUALITY_BETTER : VG_IMAGE_QUALITY_NONANTIALIASED);
|
video->smooth ? VG_IMAGE_QUALITY_BETTER : VG_IMAGE_QUALITY_NONANTIALIASED);
|
||||||
vg_set_nonblock_state(vg, !video->vsync);
|
vg_set_nonblock_state(vg, !video->vsync);
|
||||||
|
|
||||||
gfx_ctx_input_driver(input, input_data);
|
vg->driver->input_driver(input, input_data);
|
||||||
|
|
||||||
#ifdef HAVE_FREETYPE
|
#ifdef HAVE_FREETYPE
|
||||||
if (g_settings.video.font_enable)
|
if (g_settings.video.font_enable)
|
||||||
@ -157,7 +174,7 @@ static void vg_free(void *data)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
gfx_ctx_destroy();
|
vg->driver->destroy();
|
||||||
|
|
||||||
free(vg);
|
free(vg);
|
||||||
}
|
}
|
||||||
@ -322,7 +339,7 @@ static bool vg_frame(void *data, const void *frame, unsigned width, unsigned hei
|
|||||||
(void)msg;
|
(void)msg;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
gfx_ctx_swap_buffers();
|
vg->driver->swap_buffers();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -332,7 +349,7 @@ static bool vg_alive(void *data)
|
|||||||
vg_t *vg = (vg_t*)data;
|
vg_t *vg = (vg_t*)data;
|
||||||
bool quit, resize;
|
bool quit, resize;
|
||||||
|
|
||||||
gfx_ctx_check_window(&quit,
|
vg->driver->check_window(&quit,
|
||||||
&resize, &vg->mScreenWidth, &vg->mScreenHeight,
|
&resize, &vg->mScreenWidth, &vg->mScreenHeight,
|
||||||
vg->frame_count);
|
vg->frame_count);
|
||||||
return !quit;
|
return !quit;
|
||||||
@ -340,8 +357,8 @@ static bool vg_alive(void *data)
|
|||||||
|
|
||||||
static bool vg_focus(void *data)
|
static bool vg_focus(void *data)
|
||||||
{
|
{
|
||||||
(void)data;
|
vg_t *vg = (vg_t*)data;
|
||||||
return gfx_ctx_window_has_focus();
|
return vg->driver->has_focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
const video_driver_t video_vg = {
|
const video_driver_t video_vg = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user