2014-09-11 02:07:07 +00:00
|
|
|
/* RetroArch - A frontend for libretro.
|
|
|
|
* Copyright (C) 2011-2014 - Daniel De Matteis
|
2014-10-10 17:53:13 +00:00
|
|
|
* Copyright (C) 2014 - Jean-André Santoni
|
2014-09-11 02:07:07 +00:00
|
|
|
*
|
|
|
|
* 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>
|
|
|
|
|
2014-10-17 19:41:23 +00:00
|
|
|
#include "../menu_list.h"
|
2014-09-11 02:07:07 +00:00
|
|
|
#include "../menu_common.h"
|
2014-09-15 22:52:07 +00:00
|
|
|
#include "../menu_driver.h"
|
|
|
|
#include "menu_display.h"
|
2014-09-11 02:07:07 +00:00
|
|
|
#include "../../../general.h"
|
2014-10-20 19:51:04 +00:00
|
|
|
#include "../../../file_path.h"
|
2014-10-02 11:32:42 +00:00
|
|
|
#include "../../../gfx/gl_common.h"
|
2014-10-12 01:24:12 +00:00
|
|
|
#include "../../../gfx/video_thread_wrapper.h"
|
2014-10-21 05:58:58 +00:00
|
|
|
#include <compat/posix_string.h>
|
2014-09-11 02:07:07 +00:00
|
|
|
|
|
|
|
#include "../../../settings_data.h"
|
|
|
|
|
|
|
|
#include "shared.h"
|
|
|
|
|
2014-10-10 14:23:12 +00:00
|
|
|
typedef struct glui_handle
|
|
|
|
{
|
|
|
|
unsigned line_height;
|
|
|
|
unsigned glyph_width;
|
2014-10-11 01:15:02 +00:00
|
|
|
unsigned margin;
|
|
|
|
unsigned term_width;
|
|
|
|
unsigned term_height;
|
2014-10-10 14:23:12 +00:00
|
|
|
char box_message[PATH_MAX];
|
2014-10-11 01:15:02 +00:00
|
|
|
GLuint bg;
|
2014-10-10 14:23:12 +00:00
|
|
|
} glui_handle_t;
|
2014-09-11 02:07:07 +00:00
|
|
|
|
2014-09-13 04:25:41 +00:00
|
|
|
static void glui_blit_line(float x, float y, const char *message, bool green)
|
2014-09-11 02:07:07 +00:00
|
|
|
{
|
2014-09-12 20:18:44 +00:00
|
|
|
gl_t *gl = (gl_t*)driver_video_resolve(NULL);
|
|
|
|
|
2014-09-11 02:07:07 +00:00
|
|
|
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;
|
2014-09-13 04:25:41 +00:00
|
|
|
|
|
|
|
if (driver.video_data && driver.video_poke
|
|
|
|
&& driver.video_poke->set_osd_msg)
|
|
|
|
driver.video_poke->set_osd_msg(driver.video_data,
|
|
|
|
message, ¶ms);
|
2014-09-11 02:07:07 +00:00
|
|
|
}
|
|
|
|
|
2014-10-12 16:22:51 +00:00
|
|
|
static void glui_render_background(bool force_transparency)
|
2014-09-11 02:07:07 +00:00
|
|
|
{
|
2014-10-12 16:22:51 +00:00
|
|
|
float alpha = 0.75f;
|
2014-10-10 14:23:12 +00:00
|
|
|
gl_t *gl = NULL;
|
|
|
|
glui_handle_t *glui = NULL;
|
|
|
|
|
2014-10-12 01:24:12 +00:00
|
|
|
if (!driver.menu)
|
|
|
|
return;
|
|
|
|
|
|
|
|
glui = (glui_handle_t*)driver.menu->userdata;
|
|
|
|
|
|
|
|
if (!glui)
|
|
|
|
return;
|
|
|
|
|
|
|
|
GLfloat color[] = {
|
|
|
|
1.0f, 1.0f, 1.0f, alpha,
|
|
|
|
1.0f, 1.0f, 1.0f, alpha,
|
|
|
|
1.0f, 1.0f, 1.0f, alpha,
|
|
|
|
1.0f, 1.0f, 1.0f, alpha,
|
|
|
|
};
|
|
|
|
|
2014-09-14 08:32:35 +00:00
|
|
|
GLfloat black_color[] = {
|
2014-10-12 01:24:12 +00:00
|
|
|
0.0f, 0.0f, 0.0f, alpha,
|
|
|
|
0.0f, 0.0f, 0.0f, alpha,
|
|
|
|
0.0f, 0.0f, 0.0f, alpha,
|
|
|
|
0.0f, 0.0f, 0.0f, alpha,
|
2014-09-11 02:07:07 +00:00
|
|
|
};
|
|
|
|
|
2014-10-12 01:24:12 +00:00
|
|
|
gl = (gl_t*)driver_video_resolve(NULL);
|
|
|
|
|
|
|
|
if (!gl)
|
|
|
|
return;
|
|
|
|
|
|
|
|
glViewport(0, 0, gl->win_width, gl->win_height);
|
|
|
|
|
2014-09-14 08:32:35 +00:00
|
|
|
static const GLfloat vertex[] = {
|
|
|
|
0, 0,
|
|
|
|
1, 0,
|
|
|
|
0, 1,
|
|
|
|
1, 1,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const GLfloat tex_coord[] = {
|
|
|
|
0, 1,
|
|
|
|
1, 1,
|
|
|
|
0, 0,
|
|
|
|
1, 0,
|
|
|
|
};
|
|
|
|
|
2014-10-12 01:24:12 +00:00
|
|
|
struct gl_coords coords;
|
|
|
|
coords.vertices = 4;
|
|
|
|
coords.vertex = vertex;
|
|
|
|
coords.tex_coord = tex_coord;
|
|
|
|
coords.lut_tex_coord = tex_coord;
|
2014-09-11 02:07:07 +00:00
|
|
|
|
2014-10-12 01:24:12 +00:00
|
|
|
if ((g_settings.menu.pause_libretro
|
|
|
|
|| !g_extern.main_is_init || g_extern.libretro_dummy)
|
2014-10-12 16:22:51 +00:00
|
|
|
&& !force_transparency
|
2014-10-12 01:24:12 +00:00
|
|
|
&& glui->bg)
|
|
|
|
{
|
|
|
|
coords.color = color;
|
|
|
|
glBindTexture(GL_TEXTURE_2D, glui->bg);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
coords.color = black_color;
|
|
|
|
glBindTexture(GL_TEXTURE_2D, 0);
|
|
|
|
}
|
2014-09-11 02:07:07 +00:00
|
|
|
|
2014-10-19 20:24:29 +00:00
|
|
|
gl->shader->use(gl, GL_SHADER_STOCK_BLEND);
|
2014-10-12 01:24:12 +00:00
|
|
|
gl->shader->set_coords(&coords);
|
2014-10-02 13:17:21 +00:00
|
|
|
gl->shader->set_mvp(gl, &gl->mvp_no_rot);
|
2014-09-11 02:07:07 +00:00
|
|
|
|
2014-10-12 01:24:12 +00:00
|
|
|
glEnable(GL_BLEND);
|
2014-09-11 02:07:07 +00:00
|
|
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
|
|
|
glDisable(GL_BLEND);
|
2014-10-12 17:22:01 +00:00
|
|
|
|
|
|
|
gl->coords.color = gl->white_color_ptr;
|
2014-09-11 02:07:07 +00:00
|
|
|
}
|
|
|
|
|
2014-09-15 10:36:52 +00:00
|
|
|
static void glui_get_message(const char *message)
|
|
|
|
{
|
|
|
|
size_t i;
|
2014-10-10 14:23:12 +00:00
|
|
|
glui_handle_t *glui = NULL;
|
2014-09-15 16:26:32 +00:00
|
|
|
(void)i;
|
2014-09-15 10:36:52 +00:00
|
|
|
|
|
|
|
if (!driver.menu || !message || !*message)
|
|
|
|
return;
|
|
|
|
|
2014-10-10 14:23:12 +00:00
|
|
|
glui = (glui_handle_t*)driver.menu->userdata;
|
|
|
|
|
|
|
|
if (!glui)
|
|
|
|
return;
|
|
|
|
|
|
|
|
strlcpy(glui->box_message, message, sizeof(glui->box_message));
|
2014-09-15 10:36:52 +00:00
|
|
|
}
|
|
|
|
|
2014-09-11 02:07:07 +00:00
|
|
|
static void glui_render_messagebox(const char *message)
|
|
|
|
{
|
2014-10-10 14:23:12 +00:00
|
|
|
unsigned i;
|
|
|
|
int x, y;
|
|
|
|
struct string_list *list = NULL;
|
|
|
|
glui_handle_t *glui = NULL;
|
2014-09-15 10:36:52 +00:00
|
|
|
gl_t *gl = (gl_t*)driver_video_resolve(NULL);
|
|
|
|
|
|
|
|
if (!driver.menu || !gl)
|
|
|
|
return;
|
|
|
|
|
2014-10-10 14:23:12 +00:00
|
|
|
glui = (glui_handle_t*)driver.menu->userdata;
|
|
|
|
|
|
|
|
if (!glui)
|
|
|
|
return;
|
|
|
|
|
|
|
|
list = (struct string_list*)string_split(message, "\n");
|
|
|
|
|
2014-09-15 10:36:52 +00:00
|
|
|
if (!list)
|
|
|
|
return;
|
2014-10-10 14:23:12 +00:00
|
|
|
|
2014-09-15 10:36:52 +00:00
|
|
|
if (list->elems == 0)
|
|
|
|
{
|
|
|
|
string_list_free(list);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-10-10 14:23:12 +00:00
|
|
|
x = gl->win_width / 2 - strlen(list->elems[0].data) * glui->glyph_width / 2;
|
|
|
|
y = gl->win_height / 2 - list->size * glui->line_height / 2;
|
|
|
|
|
2014-09-15 10:36:52 +00:00
|
|
|
for (i = 0; i < list->size; i++)
|
|
|
|
{
|
|
|
|
const char *msg = list->elems[i].data;
|
2014-10-10 14:23:12 +00:00
|
|
|
glui_blit_line(x, y + i * glui->line_height, msg, false);
|
2014-09-15 10:36:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
string_list_free(list);
|
2014-09-11 02:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void glui_frame(void)
|
|
|
|
{
|
2014-10-10 14:23:12 +00:00
|
|
|
unsigned x, y;
|
|
|
|
size_t i;
|
|
|
|
char title[PATH_MAX], title_buf[PATH_MAX],
|
|
|
|
title_msg[PATH_MAX];
|
|
|
|
const char *dir = NULL;
|
|
|
|
const char *label = NULL;
|
|
|
|
unsigned menu_type = 0;
|
|
|
|
size_t begin = 0, end;
|
2014-09-12 20:18:44 +00:00
|
|
|
gl_t *gl = (gl_t*)driver_video_resolve(NULL);
|
2014-10-10 14:23:12 +00:00
|
|
|
glui_handle_t *glui = NULL;
|
2014-09-11 02:07:07 +00:00
|
|
|
|
|
|
|
if (!driver.menu || !gl)
|
|
|
|
return;
|
|
|
|
|
2014-10-10 14:23:12 +00:00
|
|
|
glui = (glui_handle_t*)driver.menu->userdata;
|
|
|
|
|
|
|
|
if (!glui)
|
|
|
|
return;
|
|
|
|
|
2014-10-04 01:17:32 +00:00
|
|
|
if (driver.menu->need_refresh
|
|
|
|
&& g_extern.is_menu
|
|
|
|
&& !driver.menu->msg_force)
|
|
|
|
return;
|
|
|
|
|
2014-10-10 14:23:12 +00:00
|
|
|
glui->line_height = g_settings.video.font_size * 4 / 3;
|
|
|
|
glui->glyph_width = glui->line_height / 2;
|
2014-10-11 01:15:02 +00:00
|
|
|
glui->margin = gl->win_width / 20 ;
|
|
|
|
glui->term_width = (gl->win_width - glui->margin * 2) / glui->glyph_width;
|
|
|
|
glui->term_height = (gl->win_height - glui->margin * 2) / glui->line_height - 2;
|
2014-09-13 20:45:38 +00:00
|
|
|
|
2014-09-11 02:07:07 +00:00
|
|
|
glViewport(0, 0, gl->win_width, gl->win_height);
|
|
|
|
|
|
|
|
|
2014-10-11 01:15:02 +00:00
|
|
|
if (driver.menu->selection_ptr >= glui->term_height / 2)
|
|
|
|
begin = driver.menu->selection_ptr - glui->term_height / 2;
|
|
|
|
end = (driver.menu->selection_ptr + glui->term_height <=
|
2014-10-18 00:32:59 +00:00
|
|
|
menu_list_get_size(driver.menu->menu_list)) ?
|
2014-10-11 01:15:02 +00:00
|
|
|
driver.menu->selection_ptr + glui->term_height :
|
2014-10-18 00:32:59 +00:00
|
|
|
menu_list_get_size(driver.menu->menu_list);
|
2014-09-11 02:07:07 +00:00
|
|
|
|
|
|
|
/* Do not scroll if all items are visible. */
|
2014-10-18 00:32:59 +00:00
|
|
|
if (menu_list_get_size(driver.menu->menu_list) <= glui->term_height)
|
2014-09-11 02:07:07 +00:00
|
|
|
begin = 0;
|
|
|
|
|
2014-10-11 01:15:02 +00:00
|
|
|
if (end - begin > glui->term_height)
|
|
|
|
end = begin + glui->term_height;
|
2014-09-13 02:21:48 +00:00
|
|
|
|
2014-10-12 16:22:51 +00:00
|
|
|
glui_render_background(false);
|
2014-09-11 02:07:07 +00:00
|
|
|
|
2014-10-17 23:59:16 +00:00
|
|
|
menu_list_get_last_stack(driver.menu->menu_list, &dir, &label, &menu_type);
|
2014-09-11 02:07:07 +00:00
|
|
|
|
2014-09-16 02:21:31 +00:00
|
|
|
get_title(label, dir, menu_type, title, sizeof(title));
|
2014-09-11 02:07:07 +00:00
|
|
|
|
2014-10-11 01:15:02 +00:00
|
|
|
menu_ticker_line(title_buf, glui->term_width - 3,
|
|
|
|
g_extern.frame_count / glui->margin, title, true);
|
|
|
|
glui_blit_line(glui->margin * 2, glui->margin + glui->line_height,
|
2014-09-13 02:21:48 +00:00
|
|
|
title_buf, true);
|
2014-09-11 02:07:07 +00:00
|
|
|
|
|
|
|
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);
|
2014-09-13 04:25:41 +00:00
|
|
|
glui_blit_line(
|
2014-10-11 01:15:02 +00:00
|
|
|
glui->margin * 2,
|
|
|
|
glui->margin + glui->term_height * glui->line_height
|
2014-10-10 14:23:12 +00:00
|
|
|
+ glui->line_height * 2, title_msg, true);
|
2014-09-11 02:07:07 +00:00
|
|
|
|
|
|
|
|
2014-10-11 01:15:02 +00:00
|
|
|
x = glui->margin;
|
|
|
|
y = glui->margin + glui->line_height * 2;
|
2014-09-11 02:07:07 +00:00
|
|
|
|
2014-10-10 14:23:12 +00:00
|
|
|
for (i = begin; i < end; i++, y += glui->line_height)
|
2014-09-11 02:07:07 +00:00
|
|
|
{
|
2014-09-11 02:22:30 +00:00
|
|
|
char message[PATH_MAX], type_str[PATH_MAX],
|
|
|
|
entry_title_buf[PATH_MAX], type_str_buf[PATH_MAX],
|
|
|
|
path_buf[PATH_MAX];
|
|
|
|
const char *path = NULL, *entry_label = NULL;
|
|
|
|
unsigned type = 0, w = 0;
|
2014-09-11 02:07:07 +00:00
|
|
|
bool selected = false;
|
|
|
|
|
2014-10-17 23:17:00 +00:00
|
|
|
menu_list_get_at_offset(driver.menu->menu_list->selection_buf, i, &path,
|
2014-09-11 02:07:07 +00:00
|
|
|
&entry_label, &type);
|
|
|
|
rarch_setting_t *setting = (rarch_setting_t*)setting_data_find_setting(
|
2014-10-08 22:50:35 +00:00
|
|
|
driver.menu->list_settings,
|
2014-10-17 23:17:00 +00:00
|
|
|
driver.menu->menu_list->selection_buf->list[i].label);
|
2014-09-11 02:07:07 +00:00
|
|
|
(void)setting;
|
|
|
|
|
2014-10-20 17:54:55 +00:00
|
|
|
disp_set_label(driver.menu->menu_list->selection_buf, &w, type, i, label,
|
2014-09-11 02:07:07 +00:00
|
|
|
type_str, sizeof(type_str),
|
2014-09-11 02:22:30 +00:00
|
|
|
entry_label, path,
|
|
|
|
path_buf, sizeof(path_buf));
|
2014-09-11 02:07:07 +00:00
|
|
|
|
|
|
|
selected = (i == driver.menu->selection_ptr);
|
|
|
|
|
2014-10-11 01:15:02 +00:00
|
|
|
menu_ticker_line(entry_title_buf, glui->term_width - (w + 1 + 2),
|
|
|
|
g_extern.frame_count / glui->margin, path_buf, selected);
|
2014-09-13 02:21:48 +00:00
|
|
|
menu_ticker_line(type_str_buf, w,
|
2014-10-11 01:15:02 +00:00
|
|
|
g_extern.frame_count / glui->margin, type_str, selected);
|
2014-09-11 02:07:07 +00:00
|
|
|
|
2014-10-10 14:23:12 +00:00
|
|
|
strlcpy(message, entry_title_buf, sizeof(message));
|
2014-09-11 02:07:07 +00:00
|
|
|
|
2014-09-13 04:25:41 +00:00
|
|
|
glui_blit_line(x, y, message, selected);
|
2014-09-13 01:34:59 +00:00
|
|
|
|
2014-10-11 01:15:02 +00:00
|
|
|
glui_blit_line(gl->win_width - glui->glyph_width * w - glui->margin ,
|
2014-09-13 20:45:38 +00:00
|
|
|
y, type_str_buf, selected);
|
2014-09-11 02:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#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 = "";
|
2014-10-12 18:58:48 +00:00
|
|
|
glui_render_background(true);
|
2014-09-11 02:07:07 +00:00
|
|
|
snprintf(msg, sizeof(msg), "%s\n%s", driver.menu->keyboard.label, str);
|
|
|
|
glui_render_messagebox(msg);
|
|
|
|
}
|
|
|
|
|
2014-10-10 14:23:12 +00:00
|
|
|
if (glui->box_message[0] != '\0')
|
2014-09-15 10:36:52 +00:00
|
|
|
{
|
2014-10-12 16:22:51 +00:00
|
|
|
glui_render_background(true);
|
2014-10-10 14:23:12 +00:00
|
|
|
glui_render_messagebox(glui->box_message);
|
|
|
|
glui->box_message[0] = '\0';
|
2014-09-15 10:36:52 +00:00
|
|
|
}
|
|
|
|
|
2014-09-11 02:07:07 +00:00
|
|
|
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)
|
|
|
|
{
|
2014-09-12 20:18:44 +00:00
|
|
|
menu_handle_t *menu;
|
2014-10-10 14:23:12 +00:00
|
|
|
glui_handle_t *glui = NULL;
|
2014-09-12 20:18:44 +00:00
|
|
|
const video_driver_t *video_driver = NULL;
|
|
|
|
gl_t *gl = (gl_t*)driver_video_resolve(&video_driver);
|
|
|
|
|
|
|
|
if (video_driver != &video_gl || !gl)
|
|
|
|
{
|
|
|
|
RARCH_ERR("Cannot initialize GLUI menu driver: gl video driver is not active.\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
2014-09-11 02:07:07 +00:00
|
|
|
|
2014-09-12 20:18:44 +00:00
|
|
|
menu = (menu_handle_t*)calloc(1, sizeof(*menu));
|
|
|
|
|
|
|
|
if (!menu)
|
2014-09-11 02:07:07 +00:00
|
|
|
return NULL;
|
|
|
|
|
2014-10-10 14:23:12 +00:00
|
|
|
menu->userdata = (glui_handle_t*)calloc(1, sizeof(glui_handle_t));
|
|
|
|
|
|
|
|
if (!menu->userdata)
|
2014-10-12 04:20:47 +00:00
|
|
|
{
|
|
|
|
free(menu);
|
2014-10-10 14:23:12 +00:00
|
|
|
return NULL;
|
2014-10-12 04:20:47 +00:00
|
|
|
}
|
2014-10-10 14:23:12 +00:00
|
|
|
|
|
|
|
glui = (glui_handle_t*)menu->userdata;
|
2014-10-11 01:15:02 +00:00
|
|
|
glui->bg = 0;
|
2014-10-10 14:23:12 +00:00
|
|
|
|
2014-09-11 02:07:07 +00:00
|
|
|
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);
|
|
|
|
|
2014-10-10 14:23:12 +00:00
|
|
|
if (menu->userdata)
|
|
|
|
free(menu->userdata);
|
|
|
|
|
2014-09-11 02:07:07 +00:00
|
|
|
if (g_extern.core_info)
|
|
|
|
core_info_list_free(g_extern.core_info);
|
|
|
|
g_extern.core_info = NULL;
|
|
|
|
}
|
|
|
|
|
2014-10-12 01:24:12 +00:00
|
|
|
static GLuint glui_png_texture_load_(const char * file_name)
|
2014-09-14 08:32:35 +00:00
|
|
|
{
|
2014-10-12 01:24:12 +00:00
|
|
|
if (! path_file_exists(file_name))
|
|
|
|
return 0;
|
|
|
|
|
2014-09-14 08:32:35 +00:00
|
|
|
struct texture_image ti = {0};
|
|
|
|
texture_image_load(&ti, file_name);
|
|
|
|
|
|
|
|
/* Generate the OpenGL texture object */
|
|
|
|
GLuint texture = 0;
|
|
|
|
glGenTextures(1, &texture);
|
|
|
|
glBindTexture(GL_TEXTURE_2D, texture);
|
|
|
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, ti.width, ti.height, 0,
|
|
|
|
GL_RGBA, GL_UNSIGNED_BYTE, ti.pixels);
|
|
|
|
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
|
|
|
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
|
|
|
|
|
|
|
free(ti.pixels);
|
|
|
|
|
|
|
|
return texture;
|
|
|
|
}
|
2014-10-21 03:33:58 +00:00
|
|
|
static int glui_png_texture_load_wrap(void *data)
|
2014-10-12 01:24:12 +00:00
|
|
|
{
|
2014-10-21 03:33:58 +00:00
|
|
|
const char *filename = (const char*)data;
|
|
|
|
return glui_png_texture_load_(filename);
|
2014-10-12 01:24:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static GLuint glui_png_texture_load(const char* file_name)
|
|
|
|
{
|
|
|
|
if (g_settings.video.threaded
|
|
|
|
&& !g_extern.system.hw_render_callback.context_type)
|
|
|
|
{
|
|
|
|
thread_video_t *thr = (thread_video_t*)driver.video_data;
|
|
|
|
thr->cmd_data.custom_command.method = glui_png_texture_load_wrap;
|
|
|
|
thr->cmd_data.custom_command.data = (void*)file_name;
|
|
|
|
thr->send_cmd_func(thr, CMD_CUSTOM_COMMAND);
|
|
|
|
thr->wait_reply_func(thr, CMD_CUSTOM_COMMAND);
|
|
|
|
|
|
|
|
return thr->cmd_data.custom_command.return_value;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return glui_png_texture_load_(file_name);
|
|
|
|
}
|
|
|
|
|
2014-09-14 08:32:35 +00:00
|
|
|
|
2014-09-11 02:07:07 +00:00
|
|
|
static void glui_context_reset(void *data)
|
|
|
|
{
|
2014-10-10 14:23:12 +00:00
|
|
|
char bgpath[PATH_MAX];
|
|
|
|
glui_handle_t *glui = NULL;
|
2014-09-11 02:07:07 +00:00
|
|
|
menu_handle_t *menu = (menu_handle_t*)data;
|
2014-09-12 20:18:44 +00:00
|
|
|
gl_t *gl = (gl_t*)driver_video_resolve(NULL);
|
2014-09-14 23:34:58 +00:00
|
|
|
|
|
|
|
(void)gl;
|
2014-09-11 02:07:07 +00:00
|
|
|
|
|
|
|
driver.gfx_use_rgba = true;
|
|
|
|
|
|
|
|
if (!menu)
|
|
|
|
return;
|
2014-09-14 08:32:35 +00:00
|
|
|
|
2014-10-10 14:23:12 +00:00
|
|
|
glui = (glui_handle_t*)menu->userdata;
|
|
|
|
|
|
|
|
if (!glui)
|
|
|
|
return;
|
2014-09-14 08:32:35 +00:00
|
|
|
|
|
|
|
fill_pathname_join(bgpath, g_settings.assets_directory,
|
|
|
|
"glui", sizeof(bgpath));
|
|
|
|
|
|
|
|
fill_pathname_join(bgpath, bgpath, "bg.png", sizeof(bgpath));
|
|
|
|
|
|
|
|
if (path_file_exists(bgpath))
|
2014-10-11 01:15:02 +00:00
|
|
|
glui->bg = glui_png_texture_load(bgpath);
|
2014-10-12 01:24:12 +00:00
|
|
|
|
|
|
|
printf("%d\n", glui->bg);
|
2014-09-11 02:07:07 +00:00
|
|
|
}
|
|
|
|
|
2014-09-11 05:06:20 +00:00
|
|
|
menu_ctx_driver_t menu_ctx_glui = {
|
2014-09-11 02:07:07 +00:00
|
|
|
NULL,
|
2014-09-15 10:36:52 +00:00
|
|
|
glui_get_message,
|
2014-09-11 02:07:07 +00:00
|
|
|
NULL,
|
|
|
|
glui_frame,
|
|
|
|
glui_init,
|
2014-10-08 23:31:11 +00:00
|
|
|
NULL,
|
2014-09-11 02:07:07 +00:00
|
|
|
glui_free,
|
|
|
|
glui_context_reset,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
2014-09-29 12:55:35 +00:00
|
|
|
NULL,
|
2014-09-11 02:07:07 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
glui_init_core_info,
|
|
|
|
&menu_ctx_backend_common,
|
|
|
|
"glui",
|
|
|
|
};
|