mirror of
https://github.com/libretro/RetroArch
synced 2025-03-29 22:20:21 +00:00
Make OVERLAY optional.
This commit is contained in:
parent
9a41c3c1c7
commit
35bf5c82c1
2
Makefile
2
Makefile
@ -199,7 +199,7 @@ ifeq ($(HAVE_OPENGL), 1)
|
||||
endif
|
||||
|
||||
OBJ += gfx/shader_glsl.o
|
||||
DEFINES += -DHAVE_GLSL
|
||||
DEFINES += -DHAVE_GLSL -DHAVE_OVERLAY
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_VG), 1)
|
||||
|
@ -104,7 +104,7 @@ endif
|
||||
|
||||
ifeq ($(HAVE_OPENGL), 1)
|
||||
OBJ += gfx/gl.o gfx/math/matrix.o gfx/fonts/gl_font.o gfx/fonts/gl_raster_font.o gfx/gfx_context.o gfx/context/wgl_ctx.o
|
||||
DEFINES += -DHAVE_OPENGL
|
||||
DEFINES += -DHAVE_OPENGL -DHAVE_OVERLAY
|
||||
LIBS += -lopengl32 -lgdi32
|
||||
endif
|
||||
|
||||
|
@ -58,7 +58,7 @@ ifeq ($(DEBUG_INPUT), 1)
|
||||
LOCAL_CFLAGS += -DRARCH_INPUT_DEBUG
|
||||
endif
|
||||
|
||||
LOCAL_CFLAGS += -O3 -fno-stack-protector -funroll-loops -DNDEBUG -DHAVE_GRIFFIN -DANDROID -DHAVE_DYNAMIC -DHAVE_OPENGL -DHAVE_OPENGLES -DHAVE_VID_CONTEXT -DHAVE_OPENGLES2 -DGLSL_DEBUG -DHAVE_GLSL -DHAVE_ZLIB -DWANT_RZLIB -DINLINE=inline -DLSB_FIRST -DHAVE_THREAD -D__LIBRETRO__ -DRARCH_PERFORMANCE_MODE -DRARCH_GPU_PERFORMANCE_MODE -DPACKAGE_VERSION=\"$(RARCH_VERSION)\" -std=gnu99
|
||||
LOCAL_CFLAGS += -O3 -fno-stack-protector -funroll-loops -DNDEBUG -DHAVE_GRIFFIN -DANDROID -DHAVE_DYNAMIC -DHAVE_OPENGL -DHAVE_OVERLAY -DHAVE_OPENGLES -DHAVE_VID_CONTEXT -DHAVE_OPENGLES2 -DGLSL_DEBUG -DHAVE_GLSL -DHAVE_ZLIB -DWANT_RZLIB -DINLINE=inline -DLSB_FIRST -DHAVE_THREAD -D__LIBRETRO__ -DRARCH_PERFORMANCE_MODE -DRARCH_GPU_PERFORMANCE_MODE -DPACKAGE_VERSION=\"$(RARCH_VERSION)\" -std=gnu99
|
||||
|
||||
LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -landroid -lEGL -lGLESv2 $(LOGGER_LDLIBS) -ldl
|
||||
#LOCAL_C_INCLUDES += $(LIBXML_PATH)
|
||||
|
5
driver.c
5
driver.c
@ -713,7 +713,7 @@ void init_video_input(void)
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: This should probably be done somewhere else.
|
||||
#ifdef HAVE_OVERLAY
|
||||
if (driver.overlay)
|
||||
{
|
||||
input_overlay_free(driver.overlay);
|
||||
@ -726,16 +726,19 @@ void init_video_input(void)
|
||||
if (!driver.overlay)
|
||||
RARCH_ERR("Failed to load overlay.\n");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void uninit_video_input(void)
|
||||
{
|
||||
#ifdef HAVE_OVERLAY
|
||||
if (driver.overlay)
|
||||
{
|
||||
input_overlay_free(driver.overlay);
|
||||
driver.overlay = NULL;
|
||||
driver.overlay_state = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (driver.input_data != driver.video_data && driver.input)
|
||||
input_free_func();
|
||||
|
6
driver.h
6
driver.h
@ -207,6 +207,7 @@ typedef struct input_driver
|
||||
|
||||
struct rarch_viewport;
|
||||
|
||||
#ifdef HAVE_OVERLAY
|
||||
typedef struct video_overlay_interface
|
||||
{
|
||||
void (*enable)(void *data, bool state);
|
||||
@ -214,6 +215,7 @@ typedef struct video_overlay_interface
|
||||
void (*tex_geom)(void *data, float x, float y, float w, float h);
|
||||
void (*vertex_geom)(void *data, float x, float y, float w, float h);
|
||||
} video_overlay_interface_t;
|
||||
#endif
|
||||
|
||||
typedef struct video_driver
|
||||
{
|
||||
@ -243,7 +245,9 @@ typedef struct video_driver
|
||||
// Reads out in BGR byte order (24bpp).
|
||||
bool (*read_viewport)(void *data, uint8_t *buffer);
|
||||
|
||||
#ifdef HAVE_OVERLAY
|
||||
void (*overlay_interface)(void *data, const video_overlay_interface_t **iface);
|
||||
#endif
|
||||
} video_driver_t;
|
||||
|
||||
enum rarch_display_type
|
||||
@ -280,8 +284,10 @@ typedef struct driver
|
||||
struct scaler_ctx scaler;
|
||||
void *scaler_out;
|
||||
|
||||
#ifdef HAVE_OVERLAY
|
||||
input_overlay_t *overlay;
|
||||
uint64_t overlay_state;
|
||||
#endif
|
||||
} driver_t;
|
||||
|
||||
void init_drivers(void);
|
||||
|
@ -56,11 +56,16 @@ static inline bool input_key_pressed_func(int key)
|
||||
return false;
|
||||
|
||||
bool ret = driver.input->key_pressed(driver.input_data, key);
|
||||
|
||||
#ifdef HAVE_OVERLAY
|
||||
ret |= driver.overlay_state & (UINT64_C(1) << key);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_COMMAND
|
||||
if (!ret && driver.command)
|
||||
ret = rarch_cmd_get(driver.command, key);
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
11
gfx/gl.c
11
gfx/gl.c
@ -77,11 +77,13 @@ static const GLfloat tex_coords[] = {
|
||||
1, 1
|
||||
};
|
||||
|
||||
#ifdef HAVE_OVERLAY
|
||||
static void gl_render_overlay(gl_t *gl);
|
||||
static void gl_overlay_vertex_geom(void *data,
|
||||
float x, float y, float w, float h);
|
||||
static void gl_overlay_tex_geom(void *data,
|
||||
float x, float y, float w, float h);
|
||||
#endif
|
||||
|
||||
static inline void set_texture_coords(GLfloat *coords, GLfloat xamt, GLfloat yamt)
|
||||
{
|
||||
@ -1191,8 +1193,10 @@ static bool gl_frame(void *data, const void *frame, unsigned width, unsigned hei
|
||||
|
||||
if (gl->ctx_driver->post_render)
|
||||
context_post_render_func(gl);
|
||||
#ifdef HAVE_OVERLAY
|
||||
else if (gl->overlay_enable)
|
||||
gl_render_overlay(gl);
|
||||
#endif
|
||||
|
||||
#if !defined(RARCH_CONSOLE)
|
||||
context_update_window_title_func(false);
|
||||
@ -1242,8 +1246,11 @@ static void gl_free(void *data)
|
||||
#endif
|
||||
|
||||
glDeleteTextures(TEXTURES, gl->texture);
|
||||
|
||||
#ifdef HAVE_OVERLAY
|
||||
if (gl->tex_overlay)
|
||||
glDeleteTextures(1, &gl->tex_overlay);
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_PSGL)
|
||||
glBindBuffer(GL_TEXTURE_REFERENCE_BUFFER_SCE, 0);
|
||||
@ -1792,6 +1799,7 @@ static void gl_set_aspect_ratio(void *data, unsigned aspectratio_index)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_OVERLAY
|
||||
static bool gl_overlay_load(void *data, const uint32_t *image, unsigned width, unsigned height)
|
||||
{
|
||||
gl_t *gl = (gl_t*)data;
|
||||
@ -1878,6 +1886,7 @@ static void gl_get_overlay_interface(void *data, const video_overlay_interface_t
|
||||
(void)data;
|
||||
*iface = &gl_overlay_interface;
|
||||
}
|
||||
#endif
|
||||
|
||||
const video_driver_t video_gl = {
|
||||
gl_init,
|
||||
@ -1913,7 +1922,9 @@ const video_driver_t video_gl = {
|
||||
NULL,
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_OVERLAY
|
||||
gl_get_overlay_interface,
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
|
@ -280,12 +280,14 @@ typedef struct gl
|
||||
|
||||
bool egl_images;
|
||||
|
||||
#ifdef HAVE_OVERLAY
|
||||
// Overlay rendering
|
||||
bool overlay_enable;
|
||||
GLuint tex_overlay;
|
||||
GLfloat overlay_tex_coord[8];
|
||||
GLfloat overlay_vertex_coord[8];
|
||||
GLfloat overlay_alpha_mod; // TODO. Needs a specific shader.
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_OPENGLES) && defined(HAVE_FFMPEG)
|
||||
// PBOs used for asynchronous viewport readbacks.
|
||||
|
13
retroarch.c
13
retroarch.c
@ -469,7 +469,7 @@ size_t audio_sample_batch(const int16_t *data, size_t frames)
|
||||
return frames;
|
||||
}
|
||||
|
||||
// TODO: This might need to be #ifdeffed out for irrelevant platforms.
|
||||
#ifdef HAVE_OVERLAY
|
||||
static inline void input_poll_overlay(void)
|
||||
{
|
||||
bool pressed = input_input_state_func(NULL, 0,
|
||||
@ -486,14 +486,16 @@ static inline void input_poll_overlay(void)
|
||||
|
||||
driver.overlay_state = input_overlay_poll(driver.overlay, x, y);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void input_poll(void)
|
||||
{
|
||||
input_poll_func();
|
||||
|
||||
// TODO: This might need to be #ifdeffed out for irrelevant platforms.
|
||||
#ifdef HAVE_OVERLAY
|
||||
if (driver.overlay) // Poll overlay state
|
||||
input_poll_overlay();
|
||||
#endif
|
||||
}
|
||||
|
||||
// Turbo scheme: If turbo button is held, all buttons pressed except for D-pad will go into
|
||||
@ -542,8 +544,10 @@ static int16_t input_state(unsigned port, unsigned device, unsigned index, unsig
|
||||
if (id < RARCH_FIRST_META_KEY || device == RETRO_DEVICE_KEYBOARD)
|
||||
res = input_input_state_func(binds, port, device, index, id);
|
||||
|
||||
#ifdef HAVE_OVERLAY
|
||||
if (device == RETRO_DEVICE_JOYPAD && port == 0)
|
||||
res |= driver.overlay_state & (UINT64_C(1) << id) ? 1 : 0;
|
||||
#endif
|
||||
|
||||
// Don't allow turbo for D-pad.
|
||||
if (device == RETRO_DEVICE_JOYPAD && (id < RETRO_DEVICE_ID_JOYPAD_UP || id > RETRO_DEVICE_ID_JOYPAD_RIGHT))
|
||||
@ -2479,6 +2483,7 @@ static void check_block_hotkey(void)
|
||||
driver.block_hotkey = !input_key_pressed_func(RARCH_ENABLE_HOTKEY);
|
||||
}
|
||||
|
||||
#ifdef HAVE_OVERLAY
|
||||
static void check_overlay(void)
|
||||
{
|
||||
if (!driver.overlay)
|
||||
@ -2491,6 +2496,7 @@ static void check_overlay(void)
|
||||
|
||||
old_pressed = pressed;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void do_state_checks(void)
|
||||
{
|
||||
@ -2505,7 +2511,10 @@ static void do_state_checks(void)
|
||||
#endif
|
||||
|
||||
check_turbo();
|
||||
|
||||
#ifdef HAVE_OVERLAY
|
||||
check_overlay();
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_NETPLAY
|
||||
if (!g_extern.netplay)
|
||||
|
Loading…
x
Reference in New Issue
Block a user