mirror of
https://github.com/libretro/RetroArch
synced 2025-02-02 14:54:10 +00:00
Restructuring of sdlwrap.c for portability reasons -
could need a code review
This commit is contained in:
parent
f29338580b
commit
1386e2ee90
2
Makefile
2
Makefile
@ -100,7 +100,7 @@ ifeq ($(HAVE_COREAUDIO), 1)
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(HAVE_SDL), 1)
|
ifeq ($(HAVE_SDL), 1)
|
||||||
OBJ += gfx/sdl_gfx.o gfx/sdlwrap.o input/sdl_input.o audio/sdl_audio.o fifo_buffer.o
|
OBJ += gfx/sdl_gfx.o gfx/context/sdl_ctx.o input/sdl_input.o audio/sdl_audio.o fifo_buffer.o
|
||||||
DEFINES += $(SDL_CFLAGS) $(BSD_LOCAL_INC)
|
DEFINES += $(SDL_CFLAGS) $(BSD_LOCAL_INC)
|
||||||
LIBS += $(SDL_LIBS)
|
LIBS += $(SDL_LIBS)
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ ifeq ($(TDM_GCC),)
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(HAVE_SDL), 1)
|
ifeq ($(HAVE_SDL), 1)
|
||||||
OBJ += gfx/sdl_gfx.o gfx/gl.o gfx/sdlwrap.o input/sdl_input.o audio/sdl_audio.o fifo_buffer.o
|
OBJ += gfx/sdl_gfx.o gfx/gl.o gfx/context/sdl_ctx.o input/sdl_input.o audio/sdl_audio.o fifo_buffer.o
|
||||||
LIBS += -lSDL
|
LIBS += -lSDL
|
||||||
DEFINES += -ISDL -DHAVE_SDL
|
DEFINES += -ISDL -DHAVE_SDL
|
||||||
endif
|
endif
|
||||||
|
@ -13,16 +13,23 @@
|
|||||||
* If not, see <http://www.gnu.org/licenses/>.
|
* If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "sdlwrap.h"
|
// Compatibility wrapper between SDL 1.2/1.3 for OpenGL.
|
||||||
#include "SDL_syswm.h"
|
// Wraps functions which differ in 1.2 and 1.3.
|
||||||
#include "gfx_common.h"
|
|
||||||
#include "../general.h"
|
#include "SDL.h"
|
||||||
|
#include "SDL_version.h"
|
||||||
|
|
||||||
|
#include "../gfx_context.h"
|
||||||
|
#include "../gfx_common.h"
|
||||||
|
#include "../../general.h"
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
#include <OpenGL/OpenGL.h>
|
#include <OpenGL/OpenGL.h>
|
||||||
#include <OpenGL/gl.h>
|
#include <OpenGL/gl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "sdl_ctx.h"
|
||||||
|
|
||||||
// SDL 1.2 is portable, sure, but you still need some platform specific workarounds ;)
|
// SDL 1.2 is portable, sure, but you still need some platform specific workarounds ;)
|
||||||
// Hopefully SDL 1.3 will solve this more cleanly :D
|
// Hopefully SDL 1.3 will solve this more cleanly :D
|
||||||
// Welcome to #ifdef HELL. :D
|
// Welcome to #ifdef HELL. :D
|
||||||
@ -36,7 +43,7 @@ static SDL_GLContext g_ctx;
|
|||||||
static bool g_fullscreen;
|
static bool g_fullscreen;
|
||||||
static unsigned g_interval;
|
static unsigned g_interval;
|
||||||
|
|
||||||
void sdlwrap_set_swap_interval(unsigned interval, bool inited)
|
void gfx_ctx_set_swap_interval(unsigned interval, bool inited)
|
||||||
{
|
{
|
||||||
g_interval = interval;
|
g_interval = interval;
|
||||||
|
|
||||||
@ -75,7 +82,7 @@ void sdlwrap_set_swap_interval(unsigned interval, bool inited)
|
|||||||
RARCH_WARN("Failed to set swap interval.\n");
|
RARCH_WARN("Failed to set swap interval.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sdlwrap_wm_set_caption(const char *str)
|
static void gfx_ctx_wm_set_caption(const char *str)
|
||||||
{
|
{
|
||||||
#if SDL_MODERN
|
#if SDL_MODERN
|
||||||
SDL_SetWindowTitle(g_window, str);
|
SDL_SetWindowTitle(g_window, str);
|
||||||
@ -84,17 +91,17 @@ static void sdlwrap_wm_set_caption(const char *str)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void sdlwrap_update_window_title(bool reset)
|
void gfx_ctx_update_window_title(bool reset)
|
||||||
{
|
{
|
||||||
if (reset)
|
if (reset)
|
||||||
gfx_window_title_reset();
|
gfx_window_title_reset();
|
||||||
|
|
||||||
char buf[128];
|
char buf[128];
|
||||||
if (gfx_window_title(buf, sizeof(buf)))
|
if (gfx_window_title(buf, sizeof(buf)))
|
||||||
sdlwrap_wm_set_caption(buf);
|
gfx_ctx_wm_set_caption(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void sdlwrap_get_video_size(unsigned *width, unsigned *height)
|
void gfx_ctx_get_video_size(unsigned *width, unsigned *height)
|
||||||
{
|
{
|
||||||
const SDL_VideoInfo *video_info = SDL_GetVideoInfo();
|
const SDL_VideoInfo *video_info = SDL_GetVideoInfo();
|
||||||
rarch_assert(video_info);
|
rarch_assert(video_info);
|
||||||
@ -102,7 +109,7 @@ void sdlwrap_get_video_size(unsigned *width, unsigned *height)
|
|||||||
*height = video_info->current_h;
|
*height = video_info->current_h;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool sdlwrap_init(void)
|
bool gfx_ctx_init(void)
|
||||||
{
|
{
|
||||||
#if SDL_MODERN
|
#if SDL_MODERN
|
||||||
bool ret = SDL_VideoInit(NULL) == 0;
|
bool ret = SDL_VideoInit(NULL) == 0;
|
||||||
@ -118,7 +125,7 @@ bool sdlwrap_init(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if SDL_MODERN
|
#if SDL_MODERN
|
||||||
void sdlwrap_destroy(void)
|
void gfx_ctx_destroy(void)
|
||||||
{
|
{
|
||||||
if (g_ctx)
|
if (g_ctx)
|
||||||
SDL_GL_DeleteContext(g_ctx);
|
SDL_GL_DeleteContext(g_ctx);
|
||||||
@ -130,13 +137,13 @@ void sdlwrap_destroy(void)
|
|||||||
SDL_VideoQuit();
|
SDL_VideoQuit();
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
void sdlwrap_destroy(void)
|
void gfx_ctx_destroy(void)
|
||||||
{
|
{
|
||||||
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool sdlwrap_set_video_mode(
|
bool gfx_ctx_set_video_mode(
|
||||||
unsigned width, unsigned height,
|
unsigned width, unsigned height,
|
||||||
unsigned bits, bool fullscreen)
|
unsigned bits, bool fullscreen)
|
||||||
{
|
{
|
||||||
@ -195,7 +202,7 @@ bool sdlwrap_set_video_mode(
|
|||||||
if (attr <= 0 && g_interval)
|
if (attr <= 0 && g_interval)
|
||||||
{
|
{
|
||||||
RARCH_WARN("SDL failed to setup VSync, attempting to recover using native calls.\n");
|
RARCH_WARN("SDL failed to setup VSync, attempting to recover using native calls.\n");
|
||||||
sdlwrap_set_swap_interval(g_interval, true);
|
gfx_ctx_set_swap_interval(g_interval, true);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -214,7 +221,7 @@ bool sdlwrap_set_video_mode(
|
|||||||
|
|
||||||
// SDL 1.2 has an awkward model where you need to "confirm" window resizing.
|
// SDL 1.2 has an awkward model where you need to "confirm" window resizing.
|
||||||
// SDL 1.3 luckily removes this quirk.
|
// SDL 1.3 luckily removes this quirk.
|
||||||
void sdlwrap_set_resize(unsigned width, unsigned height)
|
void gfx_ctx_set_resize(unsigned width, unsigned height)
|
||||||
{
|
{
|
||||||
#if SDL_MODERN
|
#if SDL_MODERN
|
||||||
(void)width;
|
(void)width;
|
||||||
@ -229,7 +236,7 @@ void sdlwrap_set_resize(unsigned width, unsigned height)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void sdlwrap_swap_buffers(void)
|
void gfx_ctx_swap_buffers(void)
|
||||||
{
|
{
|
||||||
#if SDL_MODERN
|
#if SDL_MODERN
|
||||||
SDL_GL_SwapWindow(g_window);
|
SDL_GL_SwapWindow(g_window);
|
||||||
@ -238,7 +245,7 @@ void sdlwrap_swap_buffers(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool sdlwrap_key_pressed(int key)
|
bool gfx_ctx_key_pressed(int key)
|
||||||
{
|
{
|
||||||
int num_keys;
|
int num_keys;
|
||||||
#if SDL_MODERN
|
#if SDL_MODERN
|
||||||
@ -260,7 +267,7 @@ bool sdlwrap_key_pressed(int key)
|
|||||||
// 1.2 specific workaround for tiling WMs. In 1.3 we call GetSize directly, so we don't need to rely on
|
// 1.2 specific workaround for tiling WMs. In 1.3 we call GetSize directly, so we don't need to rely on
|
||||||
// proper event handling (I hope).
|
// proper event handling (I hope).
|
||||||
#if !defined(__APPLE__) && !defined(_WIN32) && !SDL_MODERN && !defined(XENON)
|
#if !defined(__APPLE__) && !defined(_WIN32) && !SDL_MODERN && !defined(XENON)
|
||||||
static void sdlwrap_get_window_size(unsigned *width, unsigned *height)
|
static void gfx_ctx_get_window_size(unsigned *width, unsigned *height)
|
||||||
{
|
{
|
||||||
SDL_SysWMinfo info;
|
SDL_SysWMinfo info;
|
||||||
SDL_VERSION(&info.version);
|
SDL_VERSION(&info.version);
|
||||||
@ -277,7 +284,7 @@ static void sdlwrap_get_window_size(unsigned *width, unsigned *height)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void sdlwrap_check_window(bool *quit,
|
void gfx_ctx_check_window(bool *quit,
|
||||||
bool *resize, unsigned *width, unsigned *height, unsigned frame_count)
|
bool *resize, unsigned *width, unsigned *height, unsigned frame_count)
|
||||||
{
|
{
|
||||||
*quit = false;
|
*quit = false;
|
||||||
@ -342,7 +349,7 @@ void sdlwrap_check_window(bool *quit,
|
|||||||
if (!*resize && !g_fullscreen)
|
if (!*resize && !g_fullscreen)
|
||||||
{
|
{
|
||||||
unsigned new_width, new_height;
|
unsigned new_width, new_height;
|
||||||
sdlwrap_get_window_size(&new_width, &new_height);
|
gfx_ctx_get_window_size(&new_width, &new_height);
|
||||||
if ((new_width != *width || new_height != *height) || (frame_count == 10)) // Ugly hack :D
|
if ((new_width != *width || new_height != *height) || (frame_count == 10)) // Ugly hack :D
|
||||||
{
|
{
|
||||||
*resize = true;
|
*resize = true;
|
||||||
@ -355,7 +362,7 @@ void sdlwrap_check_window(bool *quit,
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool sdlwrap_get_wm_info(SDL_SysWMinfo *info)
|
bool gfx_ctx_get_wm_info(SDL_SysWMinfo *info)
|
||||||
{
|
{
|
||||||
#ifdef XENON
|
#ifdef XENON
|
||||||
(void)info;
|
(void)info;
|
||||||
@ -370,7 +377,7 @@ bool sdlwrap_get_wm_info(SDL_SysWMinfo *info)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool sdlwrap_window_has_focus(void)
|
bool gfx_ctx_window_has_focus(void)
|
||||||
{
|
{
|
||||||
#if SDL_MODERN
|
#if SDL_MODERN
|
||||||
Uint32 flags = SDL_GetWindowFlags(g_window);
|
Uint32 flags = SDL_GetWindowFlags(g_window);
|
||||||
@ -381,7 +388,7 @@ bool sdlwrap_window_has_focus(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void sdlwrap_input_driver(const input_driver_t **input, void **input_data)
|
void gfx_ctx_input_driver(const input_driver_t **input, void **input_data)
|
||||||
{
|
{
|
||||||
void *sdl_input = input_sdl.init();
|
void *sdl_input = input_sdl.init();
|
||||||
if (sdl_input)
|
if (sdl_input)
|
@ -22,7 +22,6 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "../dynamic.h"
|
#include "../dynamic.h"
|
||||||
#include "../general.h"
|
#include "../general.h"
|
||||||
#include "sdlwrap.h"
|
|
||||||
#include "gfx_common.h"
|
#include "gfx_common.h"
|
||||||
|
|
||||||
#ifdef HAVE_FREETYPE
|
#ifdef HAVE_FREETYPE
|
||||||
|
62
gfx/gfx_context.h
Normal file
62
gfx/gfx_context.h
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
/* RetroArch - A frontend for libretro.
|
||||||
|
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
||||||
|
*
|
||||||
|
|
||||||
|
*
|
||||||
|
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
||||||
|
* of the GNU General Public License as published by the Free Software Found-
|
||||||
|
* ation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with RetroArch.
|
||||||
|
* If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __GFX_CONTEXT_H
|
||||||
|
#define __GFX_CONTEXT_H
|
||||||
|
|
||||||
|
#include "../boolean.h"
|
||||||
|
#include "../driver.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "../config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_SDL
|
||||||
|
#include "SDL_syswm.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void gfx_ctx_set_swap_interval(unsigned interval, bool inited);
|
||||||
|
|
||||||
|
bool gfx_ctx_set_video_mode(
|
||||||
|
unsigned width, unsigned height,
|
||||||
|
unsigned bits, bool fullscreen);
|
||||||
|
|
||||||
|
bool gfx_ctx_init(void);
|
||||||
|
void gfx_ctx_destroy(void);
|
||||||
|
|
||||||
|
void gfx_ctx_get_video_size(unsigned *width, unsigned *height);
|
||||||
|
void gfx_ctx_update_window_title(bool reset);
|
||||||
|
|
||||||
|
void gfx_ctx_swap_buffers(void);
|
||||||
|
|
||||||
|
bool gfx_ctx_key_pressed(int key);
|
||||||
|
|
||||||
|
void gfx_ctx_check_window(bool *quit,
|
||||||
|
bool *resize, unsigned *width, unsigned *height, unsigned frame_count);
|
||||||
|
|
||||||
|
void gfx_ctx_set_resize(unsigned width, unsigned height);
|
||||||
|
|
||||||
|
#ifdef HAVE_SDL
|
||||||
|
bool gfx_ctx_get_wm_info(SDL_SysWMinfo *info);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
bool gfx_ctx_window_has_focus(void);
|
||||||
|
|
||||||
|
void gfx_ctx_input_driver(const input_driver_t **input, void **input_data);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
36
gfx/gl.c
36
gfx/gl.c
@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
#include "gl_common.h"
|
#include "gl_common.h"
|
||||||
#include "gfx_common.h"
|
#include "gfx_common.h"
|
||||||
#include "sdlwrap.h"
|
#include "gfx_context.h"
|
||||||
#include "../compat/strl.h"
|
#include "../compat/strl.h"
|
||||||
|
|
||||||
#ifdef HAVE_SDL
|
#ifdef HAVE_SDL
|
||||||
@ -865,7 +865,7 @@ static void check_window(gl_t *gl)
|
|||||||
{
|
{
|
||||||
bool quit, resize;
|
bool quit, resize;
|
||||||
|
|
||||||
sdlwrap_check_window(&quit,
|
gfx_ctx_check_window(&quit,
|
||||||
&resize, &gl->win_width, &gl->win_height,
|
&resize, &gl->win_width, &gl->win_height,
|
||||||
gl->frame_count);
|
gl->frame_count);
|
||||||
|
|
||||||
@ -1141,7 +1141,7 @@ static bool gl_frame(void *data, const void *frame, unsigned width, unsigned hei
|
|||||||
if (gl->should_resize)
|
if (gl->should_resize)
|
||||||
{
|
{
|
||||||
gl->should_resize = false;
|
gl->should_resize = false;
|
||||||
sdlwrap_set_resize(gl->win_width, gl->win_height);
|
gfx_ctx_set_resize(gl->win_width, gl->win_height);
|
||||||
|
|
||||||
// On resize, we might have to recreate our FBOs due to "Viewport" scale, and set a new viewport.
|
// On resize, we might have to recreate our FBOs due to "Viewport" scale, and set a new viewport.
|
||||||
gl_update_resize(gl);
|
gl_update_resize(gl);
|
||||||
@ -1179,8 +1179,8 @@ static bool gl_frame(void *data, const void *frame, unsigned width, unsigned hei
|
|||||||
if (msg)
|
if (msg)
|
||||||
gl_render_msg(gl, msg);
|
gl_render_msg(gl, msg);
|
||||||
|
|
||||||
sdlwrap_update_window_title(false);
|
gfx_ctx_update_window_title(false);
|
||||||
sdlwrap_swap_buffers();
|
gfx_ctx_swap_buffers();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1200,7 +1200,7 @@ static void gl_free(void *data)
|
|||||||
gl_deinit_fbo(gl);
|
gl_deinit_fbo(gl);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
sdlwrap_destroy();
|
gfx_ctx_destroy();
|
||||||
|
|
||||||
if (gl->empty_buf)
|
if (gl->empty_buf)
|
||||||
free(gl->empty_buf);
|
free(gl->empty_buf);
|
||||||
@ -1214,7 +1214,7 @@ static void gl_set_nonblock_state(void *data, bool state)
|
|||||||
if (gl->vsync)
|
if (gl->vsync)
|
||||||
{
|
{
|
||||||
RARCH_LOG("GL VSync => %s\n", state ? "off" : "on");
|
RARCH_LOG("GL VSync => %s\n", state ? "off" : "on");
|
||||||
sdlwrap_set_swap_interval(state ? 0 : 1, true);
|
gfx_ctx_set_swap_interval(state ? 0 : 1, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1224,14 +1224,14 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo
|
|||||||
gfx_set_dwm();
|
gfx_set_dwm();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!sdlwrap_init())
|
if (!gfx_ctx_init())
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
unsigned full_x = 0, full_y = 0;
|
unsigned full_x = 0, full_y = 0;
|
||||||
sdlwrap_get_video_size(&full_x, &full_y);
|
gfx_ctx_get_video_size(&full_x, &full_y);
|
||||||
RARCH_LOG("Detecting desktop resolution %ux%u.\n", full_x, full_y);
|
RARCH_LOG("Detecting desktop resolution %ux%u.\n", full_x, full_y);
|
||||||
|
|
||||||
sdlwrap_set_swap_interval(video->vsync ? 1 : 0, false);
|
gfx_ctx_set_swap_interval(video->vsync ? 1 : 0, false);
|
||||||
|
|
||||||
unsigned win_width = video->width;
|
unsigned win_width = video->width;
|
||||||
unsigned win_height = video->height;
|
unsigned win_height = video->height;
|
||||||
@ -1241,11 +1241,11 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo
|
|||||||
win_height = full_y;
|
win_height = full_y;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!sdlwrap_set_video_mode(win_width, win_height,
|
if (!gfx_ctx_set_video_mode(win_width, win_height,
|
||||||
g_settings.video.force_16bit ? 15 : 0, video->fullscreen))
|
g_settings.video.force_16bit ? 15 : 0, video->fullscreen))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
sdlwrap_update_window_title(true);
|
gfx_ctx_update_window_title(true);
|
||||||
|
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
|
||||||
@ -1254,7 +1254,7 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo
|
|||||||
// Need to load dynamically :(
|
// Need to load dynamically :(
|
||||||
if (!load_gl_proc())
|
if (!load_gl_proc())
|
||||||
{
|
{
|
||||||
sdlwrap_destroy();
|
gfx_ctx_destroy();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -1262,7 +1262,7 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo
|
|||||||
gl_t *gl = (gl_t*)calloc(1, sizeof(gl_t));
|
gl_t *gl = (gl_t*)calloc(1, sizeof(gl_t));
|
||||||
if (!gl)
|
if (!gl)
|
||||||
{
|
{
|
||||||
sdlwrap_destroy();
|
gfx_ctx_destroy();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1279,7 +1279,7 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo
|
|||||||
if (!gl_shader_init())
|
if (!gl_shader_init())
|
||||||
{
|
{
|
||||||
RARCH_ERR("Shader init failed.\n");
|
RARCH_ERR("Shader init failed.\n");
|
||||||
sdlwrap_destroy();
|
gfx_ctx_destroy();
|
||||||
free(gl);
|
free(gl);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -1375,12 +1375,12 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo
|
|||||||
memcpy(gl->prev_info[i].coord, tex_coords, sizeof(tex_coords));
|
memcpy(gl->prev_info[i].coord, tex_coords, sizeof(tex_coords));
|
||||||
}
|
}
|
||||||
|
|
||||||
sdlwrap_input_driver(input, input_data);
|
gfx_ctx_input_driver(input, input_data);
|
||||||
gl_init_font(gl, g_settings.video.font_path, g_settings.video.font_size);
|
gl_init_font(gl, g_settings.video.font_path, g_settings.video.font_size);
|
||||||
|
|
||||||
if (!gl_check_error())
|
if (!gl_check_error())
|
||||||
{
|
{
|
||||||
sdlwrap_destroy();
|
gfx_ctx_destroy();
|
||||||
free(gl);
|
free(gl);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -1398,7 +1398,7 @@ static bool gl_alive(void *data)
|
|||||||
static bool gl_focus(void *data)
|
static bool gl_focus(void *data)
|
||||||
{
|
{
|
||||||
(void)data;
|
(void)data;
|
||||||
return sdlwrap_window_has_focus();
|
return gfx_ctx_window_has_focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_XML
|
#ifdef HAVE_XML
|
||||||
|
@ -1,78 +0,0 @@
|
|||||||
/* RetroArch - A frontend for libretro.
|
|
||||||
* Copyright (C) 2010-2012 - Hans-Kristian Arntzen
|
|
||||||
*
|
|
||||||
|
|
||||||
*
|
|
||||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
|
||||||
* of the GNU General Public License as published by the Free Software Found-
|
|
||||||
* ation, either version 3 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
||||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE. See the GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
|
||||||
* If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Compatibility wrapper between SDL 1.2/1.3 for OpenGL.
|
|
||||||
// Wraps functions which differ in 1.2 and 1.3.
|
|
||||||
|
|
||||||
#ifndef __SDLWRAP_H
|
|
||||||
#define __SDLWRAP_H
|
|
||||||
|
|
||||||
#include "../boolean.h"
|
|
||||||
#include "../driver.h"
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
#include "../config.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_SDL
|
|
||||||
#include "SDL.h"
|
|
||||||
#include "SDL_version.h"
|
|
||||||
#include "SDL_syswm.h"
|
|
||||||
|
|
||||||
#if SDL_VERSION_ATLEAST(1, 3, 0)
|
|
||||||
#define SDL_MODERN 1
|
|
||||||
#else
|
|
||||||
#define SDL_MODERN 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Not legal to cast (void*) to fn-pointer. Need workaround to be compliant.
|
|
||||||
#define SDL_SYM_WRAP(sym, symbol) { \
|
|
||||||
rarch_assert(sizeof(void*) == sizeof(void (*)(void))); \
|
|
||||||
void *sym__ = SDL_GL_GetProcAddress(symbol); \
|
|
||||||
memcpy(&(sym), &sym__, sizeof(void*)); \
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void sdlwrap_set_swap_interval(unsigned interval, bool inited);
|
|
||||||
|
|
||||||
bool sdlwrap_set_video_mode(
|
|
||||||
unsigned width, unsigned height,
|
|
||||||
unsigned bits, bool fullscreen);
|
|
||||||
|
|
||||||
bool sdlwrap_init(void);
|
|
||||||
void sdlwrap_destroy(void);
|
|
||||||
|
|
||||||
void sdlwrap_get_video_size(unsigned *width, unsigned *height);
|
|
||||||
void sdlwrap_update_window_title(bool reset);
|
|
||||||
|
|
||||||
void sdlwrap_swap_buffers(void);
|
|
||||||
|
|
||||||
bool sdlwrap_key_pressed(int key);
|
|
||||||
|
|
||||||
void sdlwrap_check_window(bool *quit,
|
|
||||||
bool *resize, unsigned *width, unsigned *height, unsigned frame_count);
|
|
||||||
|
|
||||||
void sdlwrap_set_resize(unsigned width, unsigned height);
|
|
||||||
|
|
||||||
bool sdlwrap_get_wm_info(SDL_SysWMinfo *info);
|
|
||||||
|
|
||||||
bool sdlwrap_window_has_focus(void);
|
|
||||||
|
|
||||||
void sdlwrap_input_driver(const input_driver_t **input, void **input_data);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -32,7 +32,8 @@
|
|||||||
|
|
||||||
|
|
||||||
#define NO_SDL_GLEXT
|
#define NO_SDL_GLEXT
|
||||||
#include "sdlwrap.h"
|
#include "gfx_context.h"
|
||||||
|
#include "context/sdl_ctx.h"
|
||||||
#include "SDL_opengl.h"
|
#include "SDL_opengl.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "../gfx/sdlwrap.h"
|
#include "../gfx/gfx_context.h"
|
||||||
|
|
||||||
void sdl_dinput_free(sdl_dinput_t *di)
|
void sdl_dinput_free(sdl_dinput_t *di)
|
||||||
{
|
{
|
||||||
@ -108,7 +108,7 @@ sdl_dinput_t* sdl_dinput_init(void)
|
|||||||
SDL_SysWMinfo info;
|
SDL_SysWMinfo info;
|
||||||
SDL_VERSION(&info.version);
|
SDL_VERSION(&info.version);
|
||||||
|
|
||||||
if (!sdlwrap_get_wm_info(&info))
|
if (!gfx_ctx_get_wm_info(&info))
|
||||||
{
|
{
|
||||||
RARCH_ERR("Failed to get SysWM info.\n");
|
RARCH_ERR("Failed to get SysWM info.\n");
|
||||||
goto error;
|
goto error;
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
#include "../driver.h"
|
#include "../driver.h"
|
||||||
|
|
||||||
#include "../gfx/sdlwrap.h"
|
#include "../gfx/gfx_context.h"
|
||||||
#include "../boolean.h"
|
#include "../boolean.h"
|
||||||
#include "../general.h"
|
#include "../general.h"
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
@ -183,7 +183,7 @@ static void *sdl_input_init(void)
|
|||||||
|
|
||||||
static bool sdl_key_pressed(int key)
|
static bool sdl_key_pressed(int key)
|
||||||
{
|
{
|
||||||
return sdlwrap_key_pressed(keysym_lut[key]);
|
return gfx_ctx_key_pressed(keysym_lut[key]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef HAVE_DINPUT
|
#ifndef HAVE_DINPUT
|
||||||
|
Loading…
x
Reference in New Issue
Block a user