mirror of
https://github.com/CTCaer/RetroArch.git
synced 2025-01-31 00:22:31 +00:00
(GLUI) GL based RGUI display driver clone
This commit is contained in:
parent
478fa43261
commit
5e433abf8b
4
Makefile
4
Makefile
@ -116,6 +116,10 @@ ifeq ($(HAVE_RGUI), 1)
|
||||
OBJ += frontend/menu/disp/rgui.o
|
||||
DEFINES += -DHAVE_MENU -DHAVE_RGUI
|
||||
HAVE_MENU_COMMON = 1
|
||||
ifeq ($(HAVE_GLUI), 1)
|
||||
OBJ += frontend/menu/disp/glui.o
|
||||
DEFINES += -DHAVE_GLUI
|
||||
endif
|
||||
ifeq ($(HAVE_LAKKA), 1)
|
||||
OBJ += frontend/menu/backend/menu_lakka_backend.o frontend/menu/disp/lakka.o
|
||||
DEFINES += -DHAVE_LAKKA
|
||||
|
@ -104,6 +104,7 @@ enum
|
||||
MENU_RMENU,
|
||||
MENU_RMENU_XUI,
|
||||
MENU_LAKKA,
|
||||
MENU_GLUI,
|
||||
};
|
||||
|
||||
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) || defined(__CELLOS_LV2__)
|
||||
|
3
driver.c
3
driver.c
@ -237,6 +237,9 @@ static const menu_ctx_driver_t *menu_ctx_drivers[] = {
|
||||
#if defined(HAVE_LAKKA)
|
||||
&menu_ctx_lakka,
|
||||
#endif
|
||||
#if defined(HAVE_GLUI)
|
||||
&menu_ctx_glui,
|
||||
#endif
|
||||
#if defined(HAVE_RGUI)
|
||||
&menu_ctx_rgui,
|
||||
#endif
|
||||
|
1
driver.h
1
driver.h
@ -652,6 +652,7 @@ extern const input_osk_driver_t input_null_osk;
|
||||
extern const menu_ctx_driver_t menu_ctx_rmenu;
|
||||
extern const menu_ctx_driver_t menu_ctx_rmenu_xui;
|
||||
extern const menu_ctx_driver_t menu_ctx_rgui;
|
||||
extern const menu_ctx_driver_t menu_ctx_glui;
|
||||
extern const menu_ctx_driver_t menu_ctx_lakka;
|
||||
|
||||
extern const menu_ctx_driver_backend_t menu_ctx_backend_common;
|
||||
|
341
frontend/menu/disp/glui.c
Normal file
341
frontend/menu/disp/glui.c
Normal file
@ -0,0 +1,341 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2011-2014 - Daniel De Matteis
|
||||
* Copyright (C) 2012-2014 - Michael Lelli
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include "../backend/menu_common_backend.h"
|
||||
#include "../menu_common.h"
|
||||
#include "../../../general.h"
|
||||
#include "../../../gfx/gfx_common.h"
|
||||
#include "../../../config.def.h"
|
||||
#include "../../../file.h"
|
||||
#include "../../../dynamic.h"
|
||||
#include "../../../compat/posix_string.h"
|
||||
#include "../../../performance.h"
|
||||
#include "../../../input/input_common.h"
|
||||
|
||||
#include "../../../settings_data.h"
|
||||
#include "../../../screenshot.h"
|
||||
#include "../../../gfx/fonts/bitmap.h"
|
||||
|
||||
#include "shared.h"
|
||||
|
||||
#define FONT_HEIGHT_STRIDE 40
|
||||
#define FONT_WIDTH_STRIDE 20
|
||||
#define RGUI_TERM_START_X (gl->win_width / 21)
|
||||
#define RGUI_TERM_START_Y (gl->win_height / 9)
|
||||
#define RGUI_TERM_WIDTH (((gl->win_width - RGUI_TERM_START_X - RGUI_TERM_START_X) / (FONT_WIDTH_STRIDE)))
|
||||
#define RGUI_TERM_HEIGHT (((gl->win_height - RGUI_TERM_START_Y) / (FONT_HEIGHT_STRIDE)) - 1)
|
||||
|
||||
const gl_font_renderer_t *font_driver;
|
||||
|
||||
static void blit_line(float x, float y, const char *message, bool green)
|
||||
{
|
||||
gl_t *gl = (gl_t*)driver.video_data;
|
||||
if (!driver.menu || !gl)
|
||||
return;
|
||||
|
||||
gl_set_viewport(gl, gl->win_width, gl->win_height, false, false);
|
||||
|
||||
struct font_params params = {0};
|
||||
params.x = x / gl->win_width;
|
||||
params.y = 1.0f - y / gl->win_height;
|
||||
|
||||
params.scale = 1.0;
|
||||
params.color = green ? FONT_COLOR_RGBA(100, 255, 100, 255)
|
||||
: FONT_COLOR_RGBA(255, 255, 255, 255);
|
||||
params.full_screen = true;
|
||||
|
||||
if (font_driver)
|
||||
font_driver->render_msg(driver.menu->font, message, ¶ms);
|
||||
}
|
||||
|
||||
static void glui_render_background(void)
|
||||
{
|
||||
GLfloat color[] = {
|
||||
0.0f, 0.0f, 0.0f, 0.9f,
|
||||
0.0f, 0.0f, 0.0f, 0.9f,
|
||||
0.0f, 0.0f, 0.0f, 0.9f,
|
||||
0.0f, 0.0f, 0.0f, 0.9f,
|
||||
};
|
||||
|
||||
gl_t *gl = (gl_t*)driver.video_data;
|
||||
if (!gl)
|
||||
return;
|
||||
|
||||
gl_set_viewport(gl, gl->win_width, gl->win_height, false, false);
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
gl->coords.vertex = gl->vertex_ptr;
|
||||
gl->coords.tex_coord = (GLfloat*)calloc(4, sizeof(GLfloat));
|
||||
gl->coords.color = color;
|
||||
|
||||
gl->coords.vertices = 4;
|
||||
gl_shader_set_coords(gl, &gl->coords, &gl->mvp);
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
glDisable(GL_BLEND);
|
||||
gl->coords.color = gl->white_color_ptr;
|
||||
}
|
||||
|
||||
static void glui_render_messagebox(const char *message)
|
||||
{
|
||||
}
|
||||
|
||||
static void glui_frame(void)
|
||||
{
|
||||
gl_t *gl = (gl_t*)driver.video_data;
|
||||
|
||||
if (!driver.menu || !gl)
|
||||
return;
|
||||
|
||||
glViewport(0, 0, gl->win_width, gl->win_height);
|
||||
|
||||
size_t begin = 0;
|
||||
size_t end;
|
||||
|
||||
if (driver.menu->selection_ptr >= RGUI_TERM_HEIGHT / 2)
|
||||
begin = driver.menu->selection_ptr - RGUI_TERM_HEIGHT / 2;
|
||||
end = (driver.menu->selection_ptr + RGUI_TERM_HEIGHT <=
|
||||
file_list_get_size(driver.menu->selection_buf)) ?
|
||||
driver.menu->selection_ptr + RGUI_TERM_HEIGHT :
|
||||
file_list_get_size(driver.menu->selection_buf);
|
||||
|
||||
/* Do not scroll if all items are visible. */
|
||||
if (file_list_get_size(driver.menu->selection_buf) <= RGUI_TERM_HEIGHT)
|
||||
begin = 0;
|
||||
|
||||
if (end - begin > RGUI_TERM_HEIGHT)
|
||||
end = begin + RGUI_TERM_HEIGHT;
|
||||
|
||||
glui_render_background();
|
||||
|
||||
char title[256];
|
||||
const char *dir = NULL;
|
||||
const char *label = NULL;
|
||||
unsigned menu_type = 0;
|
||||
unsigned menu_type_is = 0;
|
||||
file_list_get_last(driver.menu->menu_stack, &dir, &label, &menu_type);
|
||||
|
||||
if (driver.menu_ctx && driver.menu_ctx->backend &&
|
||||
driver.menu_ctx->backend->type_is)
|
||||
menu_type_is = driver.menu_ctx->backend->type_is(label, menu_type);
|
||||
|
||||
#if 0
|
||||
RARCH_LOG("Dir is: %s\n", label);
|
||||
#endif
|
||||
|
||||
get_title(label, dir, menu_type, menu_type_is,
|
||||
title, sizeof(title));
|
||||
|
||||
char title_buf[256];
|
||||
menu_ticker_line(title_buf, RGUI_TERM_WIDTH - 3,
|
||||
g_extern.frame_count / RGUI_TERM_START_X, title, true);
|
||||
blit_line(RGUI_TERM_START_X + RGUI_TERM_START_X, RGUI_TERM_START_X, title_buf, true);
|
||||
|
||||
char title_msg[64];
|
||||
const char *core_name = g_extern.menu.info.library_name;
|
||||
if (!core_name)
|
||||
core_name = g_extern.system.info.library_name;
|
||||
if (!core_name)
|
||||
core_name = "No Core";
|
||||
|
||||
const char *core_version = g_extern.menu.info.library_version;
|
||||
if (!core_version)
|
||||
core_version = g_extern.system.info.library_version;
|
||||
if (!core_version)
|
||||
core_version = "";
|
||||
|
||||
snprintf(title_msg, sizeof(title_msg), "%s - %s %s", PACKAGE_VERSION,
|
||||
core_name, core_version);
|
||||
blit_line(
|
||||
RGUI_TERM_START_X + RGUI_TERM_START_X,
|
||||
(RGUI_TERM_HEIGHT * FONT_HEIGHT_STRIDE) +
|
||||
RGUI_TERM_START_Y + 2, title_msg, true);
|
||||
|
||||
unsigned x, y;
|
||||
size_t i;
|
||||
|
||||
x = RGUI_TERM_START_X;
|
||||
y = RGUI_TERM_START_Y;
|
||||
|
||||
for (i = begin; i < end; i++, y += FONT_HEIGHT_STRIDE)
|
||||
{
|
||||
char message[256], type_str[256];
|
||||
const char *path = NULL;
|
||||
const char *entry_label = NULL;
|
||||
unsigned type = 0;
|
||||
unsigned w = 0;
|
||||
char entry_title_buf[256];
|
||||
char type_str_buf[64];
|
||||
bool selected = false;
|
||||
|
||||
file_list_get_at_offset(driver.menu->selection_buf, i, &path,
|
||||
&entry_label, &type);
|
||||
rarch_setting_t *setting = (rarch_setting_t*)setting_data_find_setting(
|
||||
setting_data_get_list(),
|
||||
driver.menu->selection_buf->list[i].label);
|
||||
(void)setting;
|
||||
|
||||
disp_set_label(&w, type, i, label,
|
||||
type_str, sizeof(type_str),
|
||||
entry_label, path);
|
||||
|
||||
selected = (i == driver.menu->selection_ptr);
|
||||
|
||||
menu_ticker_line(entry_title_buf, RGUI_TERM_WIDTH - (w + 1 + 2),
|
||||
g_extern.frame_count / RGUI_TERM_START_X, path, selected);
|
||||
menu_ticker_line(type_str_buf, w, g_extern.frame_count / RGUI_TERM_START_X,
|
||||
type_str, selected);
|
||||
|
||||
snprintf(message, sizeof(message), "%c %-*.*s %-*s",
|
||||
selected ? '>' : ' ',
|
||||
RGUI_TERM_WIDTH - (w + 1 + 2),
|
||||
RGUI_TERM_WIDTH - (w + 1 + 2),
|
||||
entry_title_buf,
|
||||
w,
|
||||
type_str_buf);
|
||||
|
||||
blit_line(x, y, message, selected);
|
||||
}
|
||||
|
||||
#ifdef GEKKO
|
||||
const char *message_queue;
|
||||
|
||||
if (driver.menu->msg_force)
|
||||
{
|
||||
message_queue = msg_queue_pull(g_extern.msg_queue);
|
||||
driver.menu->msg_force = false;
|
||||
}
|
||||
else
|
||||
message_queue = driver.current_msg;
|
||||
|
||||
glui_render_messagebox(message_queue);
|
||||
#endif
|
||||
|
||||
if (driver.menu->keyboard.display)
|
||||
{
|
||||
char msg[PATH_MAX];
|
||||
const char *str = *driver.menu->keyboard.buffer;
|
||||
if (!str)
|
||||
str = "";
|
||||
snprintf(msg, sizeof(msg), "%s\n%s", driver.menu->keyboard.label, str);
|
||||
glui_render_messagebox(msg);
|
||||
}
|
||||
|
||||
gl_set_viewport(gl, gl->win_width, gl->win_height, false, false);
|
||||
}
|
||||
|
||||
static void glui_init_core_info(void *data)
|
||||
{
|
||||
(void)data;
|
||||
|
||||
core_info_list_free(g_extern.core_info);
|
||||
g_extern.core_info = NULL;
|
||||
if (*g_settings.libretro_directory)
|
||||
{
|
||||
g_extern.core_info = core_info_list_new(g_settings.libretro_directory);
|
||||
}
|
||||
}
|
||||
|
||||
static void *glui_init(void)
|
||||
{
|
||||
menu_handle_t *menu = (menu_handle_t*)calloc(1, sizeof(*menu));
|
||||
gl_t *gl = (gl_t*)driver.video_data;
|
||||
|
||||
if (!menu || !gl)
|
||||
return NULL;
|
||||
|
||||
glui_init_core_info(menu);
|
||||
|
||||
return menu;
|
||||
}
|
||||
|
||||
static void glui_free(void *data)
|
||||
{
|
||||
menu_handle_t *menu = (menu_handle_t*)data;
|
||||
|
||||
if (menu->alloc_font)
|
||||
free((uint8_t*)menu->font);
|
||||
|
||||
if (g_extern.core_info)
|
||||
core_info_list_free(g_extern.core_info);
|
||||
g_extern.core_info = NULL;
|
||||
}
|
||||
|
||||
static int glui_input_postprocess(uint64_t old_state)
|
||||
{
|
||||
(void)old_state;
|
||||
|
||||
if ((driver.menu->trigger_state & (1ULL << RARCH_MENU_TOGGLE)) &&
|
||||
g_extern.main_is_init &&
|
||||
!g_extern.libretro_dummy)
|
||||
{
|
||||
rarch_main_command(RARCH_CMD_RESUME);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void glui_context_reset(void *data)
|
||||
{
|
||||
char mediapath[256], themepath[256], iconpath[256];
|
||||
menu_handle_t *menu = (menu_handle_t*)data;
|
||||
gl_t *gl = (gl_t*)driver.video_data;
|
||||
|
||||
driver.gfx_use_rgba = true;
|
||||
|
||||
if (!menu)
|
||||
return;
|
||||
|
||||
gl_font_init_first(&font_driver, &menu->font, gl, g_settings.video.font_path,
|
||||
g_settings.video.font_size);
|
||||
}
|
||||
|
||||
const menu_ctx_driver_t menu_ctx_glui = {
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
glui_frame,
|
||||
glui_init,
|
||||
glui_free,
|
||||
glui_context_reset,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
glui_input_postprocess,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
glui_init_core_info,
|
||||
&menu_ctx_backend_common,
|
||||
"glui",
|
||||
};
|
@ -328,6 +328,6 @@ add_define_make OS "$OS"
|
||||
|
||||
# Creates config.mk and config.h.
|
||||
add_define_make GLOBAL_CONFIG_DIR "$GLOBAL_CONFIG_DIR"
|
||||
VARS="RGUI LAKKA ALSA OSS OSS_BSD OSS_LIB AL RSOUND ROAR JACK COREAUDIO PULSE SDL SDL2 D3D9 DINPUT WINXINPUT DSOUND XAUDIO OPENGL LIMA OMAP GLES GLES3 VG EGL KMS GBM DRM DYLIB GETOPT_LONG THREADS CG LIBXML2 ZLIB DYNAMIC FFMPEG AVCODEC AVFORMAT AVUTIL SWSCALE FREETYPE XKBCOMMON XVIDEO X11 XEXT XF86VM XINERAMA WAYLAND MALI_FBDEV VIVANTE_FBDEV NETPLAY NETWORK_CMD STDIN_CMD COMMAND SOCKET_LEGACY FBO STRL STRCASESTR MMAP PYTHON FFMPEG_ALLOC_CONTEXT3 FFMPEG_AVCODEC_OPEN2 FFMPEG_AVIO_OPEN FFMPEG_AVFORMAT_WRITE_HEADER FFMPEG_AVFORMAT_NEW_STREAM FFMPEG_AVCODEC_ENCODE_AUDIO2 FFMPEG_AVCODEC_ENCODE_VIDEO2 BSV_MOVIE VIDEOCORE NEON FLOATHARD FLOATSOFTFP UDEV V4L2 AV_CHANNEL_LAYOUT 7ZIP"
|
||||
VARS="RGUI LAKKA GLUI ALSA OSS OSS_BSD OSS_LIB AL RSOUND ROAR JACK COREAUDIO PULSE SDL SDL2 D3D9 DINPUT WINXINPUT DSOUND XAUDIO OPENGL LIMA OMAP GLES GLES3 VG EGL KMS GBM DRM DYLIB GETOPT_LONG THREADS CG LIBXML2 ZLIB DYNAMIC FFMPEG AVCODEC AVFORMAT AVUTIL SWSCALE FREETYPE XKBCOMMON XVIDEO X11 XEXT XF86VM XINERAMA WAYLAND MALI_FBDEV VIVANTE_FBDEV NETPLAY NETWORK_CMD STDIN_CMD COMMAND SOCKET_LEGACY FBO STRL STRCASESTR MMAP PYTHON FFMPEG_ALLOC_CONTEXT3 FFMPEG_AVCODEC_OPEN2 FFMPEG_AVIO_OPEN FFMPEG_AVFORMAT_WRITE_HEADER FFMPEG_AVFORMAT_NEW_STREAM FFMPEG_AVCODEC_ENCODE_AUDIO2 FFMPEG_AVCODEC_ENCODE_VIDEO2 BSV_MOVIE VIDEOCORE NEON FLOATHARD FLOATSOFTFP UDEV V4L2 AV_CHANNEL_LAYOUT 7ZIP"
|
||||
create_config_make config.mk $VARS
|
||||
create_config_header config.h $VARS
|
||||
|
@ -1,4 +1,5 @@
|
||||
HAVE_RGUI=yes # Disable RGUI
|
||||
HAVE_GLUI=no # Enable GLUI menu
|
||||
HAVE_LAKKA=no # Enable Lakka menu
|
||||
HAVE_DYNAMIC=yes # Disable dynamic loading of libretro library
|
||||
HAVE_SDL=auto # SDL support
|
||||
|
@ -189,6 +189,8 @@ const char *config_get_default_menu(void)
|
||||
return "rmenu_xui";
|
||||
case MENU_LAKKA:
|
||||
return "lakka";
|
||||
case MENU_GLUI:
|
||||
return "glui";
|
||||
default:
|
||||
return "NULL";
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user