mirror of
https://github.com/libretro/RetroArch
synced 2025-03-23 10:20:57 +00:00
* Get rid of video_shader_driver_use
* Get rid of Nuklear - ozone/menu widgets is probably the replacement for it - Zarch will go next
This commit is contained in:
parent
92d0b4a237
commit
9aa542b1ae
3
Makefile
3
Makefile
@ -260,9 +260,6 @@ install: $(TARGET)
|
||||
if test $(HAVE_MATERIALUI) = 1; then \
|
||||
cp -r media/assets/glui/ $(DESTDIR)$(ASSETS_DIR)/assets; \
|
||||
fi; \
|
||||
if test $(HAVE_NUKLEAR) = 1; then \
|
||||
cp -r media/assets/nuklear/ $(DESTDIR)$(ASSETS_DIR)/assets; \
|
||||
fi; \
|
||||
if test $(HAVE_XMB) = 1; then \
|
||||
cp -r media/assets/xmb/ $(DESTDIR)$(ASSETS_DIR)/assets; \
|
||||
fi; \
|
||||
|
@ -682,10 +682,6 @@ ifeq ($(HW_CONTEXT_MENU_DRIVERS), 1)
|
||||
HAVE_MATERIALUI = 1
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_NUKLEAR),)
|
||||
HAVE_NUKLEAR = 0
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_XMB),)
|
||||
HAVE_XMB = 1
|
||||
endif
|
||||
@ -701,7 +697,6 @@ else
|
||||
HAVE_ZARCH ?= 0
|
||||
HAVE_RGUI ?= 0
|
||||
HAVE_MATERIALUI ?= 0
|
||||
HAVE_NUKLEAR ?= 0
|
||||
HAVE_XMB ?= 0
|
||||
HAVE_STRIPES ?= 0
|
||||
HAVE_OZONE ?= 0
|
||||
@ -722,15 +717,6 @@ ifeq ($(HAVE_MENU), 1)
|
||||
HAVE_ASSETS = 1
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_NUKLEAR), 1)
|
||||
OBJ += menu/drivers/nuklear/nk_common.o \
|
||||
menu/drivers/nuklear/nk_menu.o \
|
||||
menu/drivers/nuklear/nk_wnd_debug.o \
|
||||
menu/drivers/nuklear.o
|
||||
DEFINES += -DHAVE_NUKLEAR
|
||||
HAVE_ASSETS = 1
|
||||
endif
|
||||
|
||||
ifeq ($(HAVE_ZARCH), 1)
|
||||
OBJ += menu/drivers/zarch.o
|
||||
DEFINES += -DHAVE_ZARCH
|
||||
|
@ -239,6 +239,8 @@ struct gl
|
||||
struct video_tex_info prev_info[GFX_MAX_TEXTURES];
|
||||
struct video_fbo_rect fbo_rect[GFX_MAX_SHADERS];
|
||||
|
||||
const shader_backend_t *shader;
|
||||
void *shader_data;
|
||||
void *renderchain_data;
|
||||
void *ctx_data;
|
||||
const gfx_ctx_driver_t *ctx_driver;
|
||||
|
@ -549,7 +549,6 @@ static void gl2_renderchain_render(
|
||||
int i;
|
||||
video_shader_ctx_coords_t coords;
|
||||
video_shader_ctx_params_t params;
|
||||
video_shader_ctx_info_t shader_info;
|
||||
static GLfloat fbo_tex_coords[8] = {0.0f};
|
||||
struct video_tex_info fbo_tex_info[GFX_MAX_SHADERS];
|
||||
struct video_tex_info *fbo_info = NULL;
|
||||
@ -588,11 +587,10 @@ static void gl2_renderchain_render(
|
||||
|
||||
gl2_bind_fb(chain->fbo[i]);
|
||||
|
||||
shader_info.data = gl;
|
||||
shader_info.idx = i + 1;
|
||||
shader_info.set_active = true;
|
||||
if (gl->shader->use)
|
||||
gl->shader->use(gl, gl->shader_data,
|
||||
i + 1, true);
|
||||
|
||||
video_shader_driver_use(&shader_info);
|
||||
glBindTexture(GL_TEXTURE_2D, chain->fbo_texture[i - 1]);
|
||||
|
||||
mip_level = i + 1;
|
||||
@ -662,11 +660,9 @@ static void gl2_renderchain_render(
|
||||
/* Render our FBO texture to back buffer. */
|
||||
gl2_renderchain_bind_backbuffer();
|
||||
|
||||
shader_info.data = gl;
|
||||
shader_info.idx = chain->fbo_pass + 1;
|
||||
shader_info.set_active = true;
|
||||
|
||||
video_shader_driver_use(&shader_info);
|
||||
if (gl->shader->use)
|
||||
gl->shader->use(gl, gl->shader_data,
|
||||
chain->fbo_pass + 1, true);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, chain->fbo_texture[chain->fbo_pass - 1]);
|
||||
|
||||
@ -2014,6 +2010,7 @@ static bool gl_shader_init(gl_t *gl, const gfx_ctx_driver_t *ctx_driver,
|
||||
)
|
||||
{
|
||||
video_shader_ctx_init_t init_data;
|
||||
bool ret = false;
|
||||
enum rarch_shader_type type = DEFAULT_SHADER_TYPE;
|
||||
const char *shader_path = retroarch_get_shader_preset();
|
||||
|
||||
@ -2053,14 +2050,23 @@ static bool gl_shader_init(gl_t *gl, const gfx_ctx_driver_t *ctx_driver,
|
||||
init_data.path = shader_path;
|
||||
|
||||
if (video_shader_driver_init(&init_data))
|
||||
{
|
||||
gl->shader = init_data.shader;
|
||||
gl->shader_data = init_data.shader_data;
|
||||
return true;
|
||||
}
|
||||
|
||||
RARCH_ERR("[GL]: Failed to initialize shader, falling back to stock.\n");
|
||||
|
||||
init_data.shader = NULL;
|
||||
init_data.path = NULL;
|
||||
|
||||
return video_shader_driver_init(&init_data);
|
||||
ret = video_shader_driver_init(&init_data);
|
||||
|
||||
gl->shader = init_data.shader;
|
||||
gl->shader_data = init_data.shader_data;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static uintptr_t gl_get_current_framebuffer(void *data)
|
||||
@ -3673,13 +3679,18 @@ static bool gl_set_shader(void *data,
|
||||
|
||||
video_shader_driver_init(&init_data);
|
||||
|
||||
gl->shader = init_data.shader;
|
||||
gl->shader_data = init_data.shader_data;
|
||||
|
||||
RARCH_WARN("[GL]: Failed to set multipass shader. Falling back to stock.\n");
|
||||
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (gl)
|
||||
gl_update_tex_filter_frame(gl);
|
||||
gl->shader = init_data.shader;
|
||||
gl->shader_data = init_data.shader_data;
|
||||
|
||||
gl_update_tex_filter_frame(gl);
|
||||
|
||||
video_shader_driver_get_prev_textures(&texture_info);
|
||||
|
||||
|
@ -396,8 +396,6 @@ static void gl_raster_font_render_message(
|
||||
static void gl_raster_font_setup_viewport(unsigned width, unsigned height,
|
||||
gl_raster_t *font, bool full_screen)
|
||||
{
|
||||
video_shader_ctx_info_t shader_info;
|
||||
|
||||
video_driver_set_viewport(width, height, full_screen, false);
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
@ -406,11 +404,9 @@ static void gl_raster_font_setup_viewport(unsigned width, unsigned height,
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, font->tex);
|
||||
|
||||
shader_info.data = NULL;
|
||||
shader_info.idx = VIDEO_SHADER_STOCK_BLEND;
|
||||
shader_info.set_active = true;
|
||||
|
||||
video_shader_driver_use(&shader_info);
|
||||
if (font->gl->shader && font->gl->shader->use)
|
||||
font->gl->shader->use(font->gl,
|
||||
font->gl->shader_data, VIDEO_SHADER_STOCK_BLEND, true);
|
||||
}
|
||||
|
||||
static void gl_raster_font_render_msg(
|
||||
|
@ -125,8 +125,6 @@ typedef struct video_pixel_scaler
|
||||
void *scaler_out;
|
||||
} video_pixel_scaler_t;
|
||||
|
||||
static void (*video_driver_cb_shader_use)(void *data,
|
||||
void *shader_data, unsigned index, bool set_active);
|
||||
static bool (*video_driver_cb_shader_set_mvp)(void *data,
|
||||
void *shader_data, const void *mat_data);
|
||||
bool (*video_driver_cb_has_focus)(void);
|
||||
@ -2739,14 +2737,6 @@ bool video_driver_texture_unload(uintptr_t *id)
|
||||
return true;
|
||||
}
|
||||
|
||||
static void video_shader_driver_use_null(void *data,
|
||||
void *shader_data, unsigned idx, bool set_active)
|
||||
{
|
||||
(void)data;
|
||||
(void)idx;
|
||||
(void)set_active;
|
||||
}
|
||||
|
||||
static bool video_driver_cb_set_coords(void *handle_data,
|
||||
void *shader_data, const struct video_coords *coords)
|
||||
{
|
||||
@ -3468,13 +3458,6 @@ static const shader_backend_t *video_shader_set_backend(
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void video_shader_driver_use(video_shader_ctx_info_t *shader_info)
|
||||
{
|
||||
if (current_shader && current_shader->use)
|
||||
current_shader->use(shader_info->data, current_shader_data,
|
||||
shader_info->idx, shader_info->set_active);
|
||||
}
|
||||
|
||||
void video_shader_driver_set_parameter(struct uniform_info *param)
|
||||
{
|
||||
if (current_shader && current_shader->set_uniform_parameter)
|
||||
@ -3621,13 +3604,6 @@ static void video_shader_driver_reset_to_defaults(void)
|
||||
if (!current_shader->set_coords)
|
||||
current_shader->set_coords = video_driver_cb_set_coords;
|
||||
|
||||
if (current_shader->use)
|
||||
video_driver_cb_shader_use = current_shader->use;
|
||||
else
|
||||
{
|
||||
current_shader->use = video_shader_driver_use_null;
|
||||
video_driver_cb_shader_use = video_shader_driver_use_null;
|
||||
}
|
||||
if (!current_shader->set_params)
|
||||
current_shader->set_params = video_shader_driver_set_params_null;
|
||||
if (!current_shader->shader_scale)
|
||||
@ -3677,6 +3653,7 @@ bool video_shader_driver_init(video_shader_ctx_init_t *init)
|
||||
init->shader->init_menu_shaders(tmp);
|
||||
}
|
||||
|
||||
init->shader_data = tmp;
|
||||
current_shader_data = tmp;
|
||||
|
||||
RARCH_LOG("Resetting shader to defaults ... \n");
|
||||
|
@ -250,6 +250,7 @@ typedef struct video_shader_ctx_init
|
||||
const char *path;
|
||||
const shader_backend_t *shader;
|
||||
void *data;
|
||||
void *shader_data;
|
||||
struct
|
||||
{
|
||||
bool core_context_enabled;
|
||||
@ -1219,8 +1220,6 @@ bool video_shader_driver_filter_type(video_shader_ctx_filter_t *filter);
|
||||
|
||||
bool video_shader_driver_compile_program(struct shader_program_info *program_info);
|
||||
|
||||
void video_shader_driver_use(video_shader_ctx_info_t *shader_info);
|
||||
|
||||
bool video_shader_driver_wrap_type(video_shader_ctx_wrap_t *wrap);
|
||||
|
||||
float video_driver_get_refresh_rate(void);
|
||||
|
@ -1307,13 +1307,6 @@ MENU
|
||||
#include "../menu/drivers/materialui.c"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_NUKLEAR
|
||||
#include "../menu/drivers/nuklear/nk_common.c"
|
||||
#include "../menu/drivers/nuklear/nk_menu.c"
|
||||
#include "../menu/drivers/nuklear/nk_wnd_debug.c"
|
||||
#include "../menu/drivers/nuklear.c"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_ZARCH
|
||||
#include "../menu/drivers/zarch.c"
|
||||
#endif
|
||||
|
@ -1,444 +0,0 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2011-2017 - Daniel De Matteis
|
||||
* Copyright (C) 2014-2017 - Jean-André Santoni
|
||||
* Copyright (C) 2016-2017 - Andrés Suárez
|
||||
*
|
||||
* 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 <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <retro_assert.h>
|
||||
#include <compat/posix_string.h>
|
||||
#include <compat/strl.h>
|
||||
#include <file/file_path.h>
|
||||
#include <formats/image.h>
|
||||
#include <gfx/math/matrix_4x4.h>
|
||||
#include <streams/file_stream.h>
|
||||
#include <string/stdstring.h>
|
||||
#include <lists/string_list.h>
|
||||
|
||||
#include "menu_generic.h"
|
||||
#include "nuklear/nk_menu.h"
|
||||
|
||||
#include "../menu_driver.h"
|
||||
#include "../menu_animation.h"
|
||||
|
||||
#include "../../core.h"
|
||||
#include "../../core_info.h"
|
||||
#include "../../configuration.h"
|
||||
#include "../../frontend/frontend_driver.h"
|
||||
#include "../../retroarch.h"
|
||||
#include "../../verbosity.h"
|
||||
#include "../../tasks/tasks_internal.h"
|
||||
|
||||
static void nk_menu_init_device(nk_menu_handle_t *nk)
|
||||
{
|
||||
const void *image;
|
||||
int w, h;
|
||||
char buf[PATH_MAX_LENGTH] = {0};
|
||||
|
||||
fill_pathname_join(buf, "assets/nuklear",
|
||||
"font.ttf", sizeof(buf));
|
||||
|
||||
nk_alloc.userdata.ptr = NULL;
|
||||
nk_alloc.alloc = nk_common_mem_alloc;
|
||||
nk_alloc.free = nk_common_mem_free;
|
||||
nk_buffer_init(&device.cmds, &nk_alloc, 1024);
|
||||
nk_font_atlas_init_default(&atlas);
|
||||
nk_font_atlas_begin(&atlas);
|
||||
|
||||
struct nk_font *font;
|
||||
|
||||
font = nk_font_atlas_add_from_file(&atlas, buf, 16, 0);
|
||||
image = nk_font_atlas_bake(&atlas, &w, &h, NK_FONT_ATLAS_RGBA32);
|
||||
nk_upload_atlas(&device, image, w, h);
|
||||
nk_font_atlas_end(&atlas, nk_handle_id((int)device.font_tex), &device.null);
|
||||
nk_init_default(&nk->ctx, &font->handle);
|
||||
|
||||
nk_common_device_init(&device);
|
||||
|
||||
nk->size_changed = true;
|
||||
nk_common_set_style(&nk->ctx);
|
||||
}
|
||||
|
||||
static void *nk_menu_init(void **userdata, bool video_is_threaded)
|
||||
{
|
||||
|
||||
unsigned i;
|
||||
|
||||
settings_t *settings = config_get_ptr();
|
||||
nk_menu_handle_t *nk = NULL;
|
||||
menu_handle_t *menu = (menu_handle_t*)
|
||||
calloc(1, sizeof(*menu));
|
||||
unsigned width, height = 0;
|
||||
|
||||
video_driver_get_size(&width, &height);
|
||||
|
||||
if (!menu)
|
||||
goto error;
|
||||
|
||||
if (!menu_display_init_first_driver(video_is_threaded))
|
||||
goto error;
|
||||
|
||||
nk = (nk_menu_handle_t*)calloc(1, sizeof(nk_menu_handle_t));
|
||||
|
||||
if (!nk)
|
||||
goto error;
|
||||
|
||||
*userdata = nk;
|
||||
fill_pathname_join(nk->assets_directory, settings->paths.directory_assets,
|
||||
"nuklear", sizeof(nk->assets_directory));
|
||||
nk_menu_init_device(nk);
|
||||
|
||||
for (i = 0; i < NK_WND_LAST; i++)
|
||||
nk->window[i].open = true;
|
||||
|
||||
return menu;
|
||||
error:
|
||||
|
||||
if (menu)
|
||||
free(menu);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void nk_menu_input_gamepad(nk_menu_handle_t *nk)
|
||||
{
|
||||
switch (nk->action)
|
||||
{
|
||||
case MENU_ACTION_LEFT:
|
||||
nk_input_key(&nk->ctx, NK_KEY_LEFT, 1);
|
||||
break;
|
||||
case MENU_ACTION_RIGHT:
|
||||
nk_input_key(&nk->ctx, NK_KEY_RIGHT, 1);
|
||||
break;
|
||||
case MENU_ACTION_DOWN:
|
||||
nk_input_key(&nk->ctx, NK_KEY_DOWN, 1);
|
||||
break;
|
||||
case MENU_ACTION_UP:
|
||||
nk_input_key(&nk->ctx, NK_KEY_UP, 1);
|
||||
break;
|
||||
default:
|
||||
nk_input_key(&nk->ctx, NK_KEY_UP, 0);
|
||||
nk_input_key(&nk->ctx, NK_KEY_DOWN, 0);
|
||||
nk_input_key(&nk->ctx, NK_KEY_LEFT, 0);
|
||||
nk_input_key(&nk->ctx, NK_KEY_RIGHT, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void nk_menu_input_mouse_movement(struct nk_context *ctx)
|
||||
{
|
||||
int16_t mouse_x = menu_input_mouse_state(MENU_MOUSE_X_AXIS);
|
||||
int16_t mouse_y = menu_input_mouse_state(MENU_MOUSE_Y_AXIS);
|
||||
|
||||
nk_input_motion(ctx, mouse_x, mouse_y);
|
||||
struct nk_vec2 scroll = {0 ,menu_input_mouse_state(MENU_MOUSE_WHEEL_UP) -
|
||||
menu_input_mouse_state(MENU_MOUSE_WHEEL_DOWN)};
|
||||
nk_input_scroll(ctx, scroll);
|
||||
}
|
||||
|
||||
static void nk_menu_input_mouse_button(struct nk_context *ctx)
|
||||
{
|
||||
int16_t mouse_x = menu_input_mouse_state(MENU_MOUSE_X_AXIS);
|
||||
int16_t mouse_y = menu_input_mouse_state(MENU_MOUSE_Y_AXIS);
|
||||
|
||||
nk_input_button(ctx, NK_BUTTON_LEFT,
|
||||
mouse_x, mouse_y, menu_input_mouse_state(MENU_MOUSE_LEFT_BUTTON));
|
||||
nk_input_button(ctx, NK_BUTTON_RIGHT,
|
||||
mouse_x, mouse_y, menu_input_mouse_state(MENU_MOUSE_RIGHT_BUTTON));
|
||||
}
|
||||
|
||||
static void nk_menu_input_keyboard(struct nk_context *ctx)
|
||||
{
|
||||
/* placeholder, it just presses 1 on right click
|
||||
needs to be hooked up correctly
|
||||
*/
|
||||
if(menu_input_mouse_state(MENU_MOUSE_RIGHT_BUTTON))
|
||||
nk_input_char(ctx, '1');
|
||||
}
|
||||
|
||||
static void nk_menu_get_message(void *data, const char *message)
|
||||
{
|
||||
nk_menu_handle_t *nk = (nk_menu_handle_t*)data;
|
||||
if (!nk || !message || !*message)
|
||||
return;
|
||||
strlcpy(nk->box_message, message, sizeof(nk->box_message));
|
||||
}
|
||||
|
||||
/* this is the main control function, it opens and closes windows and will
|
||||
control the logic of the whole menu driver */
|
||||
static void nk_menu_main(nk_menu_handle_t *nk)
|
||||
{
|
||||
|
||||
struct nk_context *ctx = &nk->ctx;
|
||||
|
||||
if (nk->window[NK_WND_DEBUG].open)
|
||||
nk_wnd_debug(nk);
|
||||
|
||||
nk_buffer_info(&nk->status, &nk->ctx.memory);
|
||||
}
|
||||
|
||||
static void nk_menu_frame(void *data, video_frame_info_t *video_info)
|
||||
{
|
||||
unsigned ticker_limit, i;
|
||||
float coord_black[16], coord_white[16];
|
||||
nk_menu_handle_t *nk = (nk_menu_handle_t*)data;
|
||||
settings_t *settings = config_get_ptr();
|
||||
unsigned width = video_info->width;
|
||||
unsigned height = video_info->height;
|
||||
bool libretro_running = video_info->libretro_running;
|
||||
float white_bg[16] = {
|
||||
0.98, 0.98, 0.98, 1,
|
||||
0.98, 0.98, 0.98, 1,
|
||||
0.98, 0.98, 0.98, 1,
|
||||
0.98, 0.98, 0.98, 1,
|
||||
};
|
||||
|
||||
for (i = 0; i < 16; i++)
|
||||
{
|
||||
coord_black[i] = 0;
|
||||
coord_white[i] = 1.0f;
|
||||
}
|
||||
|
||||
menu_display_set_alpha(coord_black, 0.75);
|
||||
menu_display_set_alpha(coord_white, 0.75);
|
||||
|
||||
if (!nk)
|
||||
return;
|
||||
|
||||
menu_display_set_viewport(video_info->width, video_info->height);
|
||||
|
||||
nk_input_begin(&nk->ctx);
|
||||
nk_menu_input_gamepad(nk);
|
||||
nk_menu_input_mouse_movement(&nk->ctx);
|
||||
nk_menu_input_mouse_button(&nk->ctx);
|
||||
nk_menu_input_keyboard(&nk->ctx);
|
||||
|
||||
if (width != nk->size.x || height != nk->size.y)
|
||||
{
|
||||
nk->size.x = width;
|
||||
nk->size.y = height;
|
||||
nk->size_changed = true;
|
||||
}
|
||||
|
||||
nk_input_end(&nk->ctx);
|
||||
nk_menu_main(nk);
|
||||
nk_common_device_draw(&device, &nk->ctx, width, height, NK_ANTI_ALIASING_ON);
|
||||
|
||||
menu_display_draw_cursor(
|
||||
&white_bg[0],
|
||||
64,
|
||||
nk->textures.pointer,
|
||||
menu_input_mouse_state(MENU_MOUSE_X_AXIS),
|
||||
menu_input_mouse_state(MENU_MOUSE_Y_AXIS),
|
||||
width,
|
||||
height);
|
||||
|
||||
menu_display_restore_clear_color();
|
||||
menu_display_unset_viewport(video_info->width, video_info->height);
|
||||
}
|
||||
|
||||
static void nk_menu_free(void *data)
|
||||
{
|
||||
nk_menu_handle_t *nk = (nk_menu_handle_t*)data;
|
||||
|
||||
if (!nk)
|
||||
return;
|
||||
free(font);
|
||||
nk_free(&nk->ctx);
|
||||
nk_buffer_free(&device.cmds);
|
||||
nk_common_device_shutdown(&device);
|
||||
|
||||
video_coord_array_free(&nk->list_block.carr);
|
||||
font_driver_bind_block(NULL, NULL);
|
||||
}
|
||||
|
||||
static void nk_menu_context_load_textures(nk_menu_handle_t *nk,
|
||||
const char *iconpath)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
struct texture_image ti;
|
||||
char path[PATH_MAX_LENGTH];
|
||||
|
||||
path[0] = '\0';
|
||||
|
||||
ti.width = 0;
|
||||
ti.height = 0;
|
||||
ti.pixels = NULL;
|
||||
ti.supports_rgba = video_driver_supports_rgba();
|
||||
|
||||
fill_pathname_join(path, iconpath,
|
||||
"pointer.png", sizeof(path));
|
||||
if (!string_is_empty(path) && filestream_exists(path))
|
||||
{
|
||||
image_texture_load(&ti, path);
|
||||
video_driver_texture_load(&ti,
|
||||
TEXTURE_FILTER_MIPMAP_NEAREST, &nk->textures.pointer);
|
||||
}
|
||||
|
||||
fill_pathname_join(path, iconpath,
|
||||
"bg.png", sizeof(path));
|
||||
if (!string_is_empty(path) && filestream_exists(path))
|
||||
{
|
||||
image_texture_load(&ti, path);
|
||||
video_driver_texture_load(&ti,
|
||||
TEXTURE_FILTER_MIPMAP_NEAREST, &nk->textures.bg);
|
||||
}
|
||||
}
|
||||
|
||||
static void nk_menu_context_reset(void *data, bool is_threaded)
|
||||
{
|
||||
char iconpath[PATH_MAX_LENGTH] = {0};
|
||||
nk_menu_handle_t *nk = (nk_menu_handle_t*)data;
|
||||
settings_t *settings = config_get_ptr();
|
||||
unsigned width = 0;
|
||||
unsigned height = 0;
|
||||
|
||||
video_driver_get_size(&width, &height);
|
||||
|
||||
if (!nk || !settings)
|
||||
return;
|
||||
|
||||
fill_pathname_join(iconpath, settings->paths.directory_assets,
|
||||
"nuklear", sizeof(iconpath));
|
||||
fill_pathname_slash(iconpath, sizeof(iconpath));
|
||||
|
||||
nk_menu_init_device(nk);
|
||||
nk_menu_context_load_textures(nk, iconpath);
|
||||
|
||||
if (filestream_exists(settings->paths.path_menu_wallpaper))
|
||||
task_push_image_load(settings->paths.path_menu_wallpaper,
|
||||
menu_display_handle_wallpaper_upload, NULL);
|
||||
}
|
||||
|
||||
static void nk_menu_context_destroy(void *data)
|
||||
{
|
||||
unsigned i;
|
||||
nk_menu_handle_t *nk = (nk_menu_handle_t*)data;
|
||||
|
||||
if (!nk)
|
||||
return;
|
||||
|
||||
video_driver_texture_unload((uintptr_t*)&nk->textures.pointer);
|
||||
video_driver_texture_unload((uintptr_t*)&nk->textures.bg);
|
||||
}
|
||||
|
||||
/* not sure what these two are needed for, seem to be rather important
|
||||
in the menu driver so I didn't touch them */
|
||||
static bool nk_menu_init_list(void *data)
|
||||
{
|
||||
menu_displaylist_info_t info;
|
||||
file_list_t *menu_stack = menu_entries_get_menu_stack_ptr(0);
|
||||
file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0);
|
||||
|
||||
menu_displaylist_info_init(&info);
|
||||
|
||||
info.label = strdup(
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_HISTORY_TAB));
|
||||
info.enum_idx = MENU_ENUM_LABEL_HISTORY_TAB;
|
||||
|
||||
menu_entries_append_enum(menu_stack,
|
||||
info.path, info.label, MSG_UNKNOWN,
|
||||
info.type, info.flags, 0);
|
||||
|
||||
command_event(CMD_EVENT_HISTORY_INIT, NULL);
|
||||
|
||||
info.list = selection_buf;
|
||||
|
||||
if (menu_displaylist_ctl(DISPLAYLIST_HISTORY, &info))
|
||||
{
|
||||
bool ret = false;
|
||||
info.need_push = true;
|
||||
ret = menu_displaylist_process(&info);
|
||||
menu_displaylist_info_free(&info);
|
||||
return ret;
|
||||
}
|
||||
|
||||
menu_displaylist_info_free(&info);
|
||||
return false;
|
||||
}
|
||||
|
||||
/* not sure what these two are needed for, seem to be rather important
|
||||
in the menu driver so I didn't touch them */
|
||||
static int nk_menu_iterate(void *data, void *userdata, enum menu_action action)
|
||||
{
|
||||
int ret;
|
||||
menu_entry_t entry;
|
||||
nk_menu_handle_t *nk = (nk_menu_handle_t*)userdata;
|
||||
size_t selection = menu_navigation_get_selection();
|
||||
|
||||
if (!nk)
|
||||
return -1;
|
||||
|
||||
menu_entry_init(&entry);
|
||||
menu_entry_get(&entry, 0, selection, NULL, false);
|
||||
|
||||
nk->action = action;
|
||||
|
||||
ret = menu_entry_action(&entry, selection, action);
|
||||
menu_entry_free(&entry);
|
||||
if (ret)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
menu_ctx_driver_t menu_ctx_nuklear = {
|
||||
NULL,
|
||||
nk_menu_get_message,
|
||||
nk_menu_iterate,
|
||||
NULL,
|
||||
nk_menu_frame,
|
||||
nk_menu_init,
|
||||
nk_menu_free,
|
||||
nk_menu_context_reset,
|
||||
nk_menu_context_destroy,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
nk_menu_init_list,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
"nuklear",
|
||||
NULL, /* environ */
|
||||
NULL, /* pointer_tap */
|
||||
NULL, /* update_thumbnail_path */
|
||||
NULL, /* update_thumbnail_image */
|
||||
NULL, /* set_thumbnail_system */
|
||||
NULL, /* set_thumbnail_content */
|
||||
NULL, /* osk_ptr_at_pos */
|
||||
NULL, /* update_savestate_thumbnail_path */
|
||||
NULL, /* update_savestate_thumbnail_image */
|
||||
};
|
@ -1,308 +0,0 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2011-2017 - Daniel De Matteis
|
||||
* Copyright (C) 2014-2017 - Jean-André Santoni
|
||||
* Copyright (C) 2016-2017 - Andrés Suárez
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
/* This file is intended for backend code. */
|
||||
|
||||
#include <streams/file_stream.h>
|
||||
|
||||
#define NK_INCLUDE_FIXED_TYPES
|
||||
#define NK_INCLUDE_STANDARD_IO
|
||||
#define NK_INCLUDE_DEFAULT_ALLOCATOR
|
||||
#define NK_INCLUDE_VERTEX_BUFFER_OUTPUT
|
||||
#define NK_INCLUDE_FONT_BAKING
|
||||
#define NK_INCLUDE_DEFAULT_FONT
|
||||
#define NK_IMPLEMENTATION
|
||||
|
||||
#include "nk_common.h"
|
||||
|
||||
#include "../../menu_driver.h"
|
||||
#include "../../../gfx/video_driver.h"
|
||||
|
||||
#ifdef HAVE_GLSL
|
||||
#include "../../../gfx/drivers/gl_shaders/pipeline_nuklear.glsl.vert.h"
|
||||
#include "../../../gfx/drivers/gl_shaders/pipeline_nuklear.glsl.frag.h"
|
||||
#endif
|
||||
|
||||
struct nk_font *font;
|
||||
struct nk_font_atlas atlas;
|
||||
struct nk_user_font usrfnt;
|
||||
struct nk_allocator nk_alloc;
|
||||
struct nk_device device;
|
||||
|
||||
struct nk_vertex {
|
||||
float position[2];
|
||||
float uv[2];
|
||||
nk_byte col[4];
|
||||
};
|
||||
|
||||
struct nk_image nk_common_image_load(const char *filename)
|
||||
{
|
||||
int x,y,n;
|
||||
struct texture_image ti;
|
||||
uintptr_t tex;
|
||||
|
||||
ti.width = 0;
|
||||
ti.height = 0;
|
||||
ti.pixels = NULL;
|
||||
ti.supports_rgba = video_driver_supports_rgba();
|
||||
|
||||
image_texture_load(&ti, filename);
|
||||
|
||||
if (!ti.pixels)
|
||||
printf("Failed to load image: %s\n", filename);
|
||||
|
||||
video_driver_texture_load(&ti, TEXTURE_FILTER_MIPMAP_NEAREST, &tex);
|
||||
|
||||
image_texture_free(&ti);
|
||||
|
||||
return nk_image_id((int)tex);
|
||||
}
|
||||
|
||||
char* nk_common_file_load(const char* path, size_t* size)
|
||||
{
|
||||
void *buf;
|
||||
ssize_t *length = (ssize_t*)size;
|
||||
filestream_read_file(path, &buf, length);
|
||||
return (char*)buf;
|
||||
}
|
||||
|
||||
void nk_common_device_init(struct nk_device *dev)
|
||||
{
|
||||
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES)
|
||||
GLint status;
|
||||
|
||||
/* buffer setup */
|
||||
GLsizei vs = sizeof(struct nk_vertex);
|
||||
size_t vp = offsetof(struct nk_vertex, position);
|
||||
size_t vt = offsetof(struct nk_vertex, uv);
|
||||
size_t vc = offsetof(struct nk_vertex, col);
|
||||
|
||||
dev->prog = glCreateProgram();
|
||||
dev->vert_shdr = glCreateShader(GL_VERTEX_SHADER);
|
||||
dev->frag_shdr = glCreateShader(GL_FRAGMENT_SHADER);
|
||||
|
||||
glShaderSource(dev->vert_shdr, 1, &nuklear_vertex_shader, 0);
|
||||
glShaderSource(dev->frag_shdr, 1, &nuklear_fragment_shader, 0);
|
||||
glCompileShader(dev->vert_shdr);
|
||||
glCompileShader(dev->frag_shdr);
|
||||
glGetShaderiv(dev->vert_shdr, GL_COMPILE_STATUS, &status);
|
||||
glGetShaderiv(dev->frag_shdr, GL_COMPILE_STATUS, &status);
|
||||
glAttachShader(dev->prog, dev->vert_shdr);
|
||||
glAttachShader(dev->prog, dev->frag_shdr);
|
||||
glLinkProgram(dev->prog);
|
||||
glGetProgramiv(dev->prog, GL_LINK_STATUS, &status);
|
||||
|
||||
dev->uniform_proj = glGetUniformLocation(dev->prog, "ProjMtx");
|
||||
dev->attrib_pos = glGetAttribLocation(dev->prog, "Position");
|
||||
dev->attrib_uv = glGetAttribLocation(dev->prog, "TexCoord");
|
||||
dev->attrib_col = glGetAttribLocation(dev->prog, "Color");
|
||||
|
||||
glGenBuffers(1, &dev->vbo);
|
||||
glGenBuffers(1, &dev->ebo);
|
||||
glGenVertexArrays(1, &dev->vao);
|
||||
|
||||
glBindVertexArray(dev->vao);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, dev->vbo);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, dev->ebo);
|
||||
|
||||
glEnableVertexAttribArray((GLuint)dev->attrib_pos);
|
||||
glEnableVertexAttribArray((GLuint)dev->attrib_uv);
|
||||
glEnableVertexAttribArray((GLuint)dev->attrib_col);
|
||||
|
||||
glVertexAttribPointer((GLuint)dev->attrib_pos, 2, GL_FLOAT, GL_FALSE, vs, (void*)vp);
|
||||
glVertexAttribPointer((GLuint)dev->attrib_uv, 2, GL_FLOAT, GL_FALSE, vs, (void*)vt);
|
||||
glVertexAttribPointer((GLuint)dev->attrib_col, 4, GL_UNSIGNED_BYTE, GL_TRUE, vs, (void*)vc);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
glBindVertexArray(0);
|
||||
#endif
|
||||
}
|
||||
|
||||
void nk_upload_atlas(struct nk_device *dev, const void *image, int width, int height)
|
||||
{
|
||||
glGenTextures(1, &dev->font_tex);
|
||||
glBindTexture(GL_TEXTURE_2D, dev->font_tex);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, (GLsizei)width, (GLsizei)height, 0,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE, image);
|
||||
}
|
||||
|
||||
void nk_common_device_shutdown(struct nk_device *dev)
|
||||
{
|
||||
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES)
|
||||
glDetachShader(dev->prog, dev->vert_shdr);
|
||||
glDetachShader(dev->prog, dev->frag_shdr);
|
||||
glDeleteShader(dev->vert_shdr);
|
||||
glDeleteShader(dev->frag_shdr);
|
||||
glDeleteProgram(dev->prog);
|
||||
glDeleteTextures(1, &dev->font_tex);
|
||||
glDeleteBuffers(1, &dev->vbo);
|
||||
glDeleteBuffers(1, &dev->ebo);
|
||||
#endif
|
||||
}
|
||||
|
||||
void nk_common_device_draw(struct nk_device *dev,
|
||||
struct nk_context *ctx, int width, int height,
|
||||
enum nk_anti_aliasing AA)
|
||||
{
|
||||
video_shader_ctx_info_t shader_info;
|
||||
struct nk_buffer vbuf, ebuf;
|
||||
struct nk_convert_config config;
|
||||
uintptr_t last_prog;
|
||||
const struct nk_draw_command *cmd = NULL;
|
||||
void *vertices = NULL;
|
||||
void *elements = NULL;
|
||||
const nk_draw_index *offset = NULL;
|
||||
const struct nk_draw_vertex_layout_element vertex_layout[] =
|
||||
{
|
||||
{NK_VERTEX_POSITION, NK_FORMAT_FLOAT, NK_OFFSETOF(struct nk_vertex, position)},
|
||||
{NK_VERTEX_TEXCOORD, NK_FORMAT_FLOAT, NK_OFFSETOF(struct nk_vertex, uv)},
|
||||
{NK_VERTEX_COLOR, NK_FORMAT_R8G8B8A8, NK_OFFSETOF(struct nk_vertex, col)},
|
||||
{NK_VERTEX_LAYOUT_END}
|
||||
};
|
||||
|
||||
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES)
|
||||
GLint last_tex;
|
||||
GLint last_ebo, last_vbo, last_vao;
|
||||
GLfloat ortho[4][4] = {
|
||||
{2.0f, 0.0f, 0.0f, 0.0f},
|
||||
{0.0f,-2.0f, 0.0f, 0.0f},
|
||||
{0.0f, 0.0f,-1.0f, 0.0f},
|
||||
{-1.0f,1.0f, 0.0f, 1.0f},
|
||||
};
|
||||
ortho[0][0] /= (GLfloat)width;
|
||||
ortho[1][1] /= (GLfloat)height;
|
||||
|
||||
/* save previous opengl state */
|
||||
glGetIntegerv(GL_CURRENT_PROGRAM, (GLint*)&last_prog);
|
||||
glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_tex);
|
||||
glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &last_vao);
|
||||
glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, &last_ebo);
|
||||
glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &last_vbo);
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
#endif
|
||||
|
||||
menu_display_blend_begin();
|
||||
|
||||
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES)
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
#endif
|
||||
|
||||
/* setup program */
|
||||
shader_info.data = NULL;
|
||||
shader_info.idx = dev->prog;
|
||||
shader_info.set_active = false;
|
||||
video_shader_driver_use(shader_info);
|
||||
|
||||
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES)
|
||||
glUniformMatrix4fv(dev->uniform_proj, 1, GL_FALSE, &ortho[0][0]);
|
||||
|
||||
/* convert from command queue into draw list and draw to screen */
|
||||
|
||||
/* allocate vertex and element buffer */
|
||||
glBindVertexArray(dev->vao);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, dev->vbo);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, dev->ebo);
|
||||
|
||||
glBufferData(GL_ARRAY_BUFFER, MAX_VERTEX_MEMORY, NULL, GL_STREAM_DRAW);
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, MAX_ELEMENT_MEMORY, NULL, GL_STREAM_DRAW);
|
||||
|
||||
/* load draw vertices & elements directly into vertex + element buffer */
|
||||
vertices = glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
|
||||
elements = glMapBuffer(GL_ELEMENT_ARRAY_BUFFER, GL_WRITE_ONLY);
|
||||
#endif
|
||||
|
||||
/* fill converting configuration */
|
||||
|
||||
NK_MEMSET(&config, 0, sizeof(config));
|
||||
config.vertex_layout = vertex_layout;
|
||||
config.vertex_size = sizeof(struct nk_vertex);
|
||||
config.vertex_alignment = NK_ALIGNOF(struct nk_vertex);
|
||||
config.null = dev->null;
|
||||
config.circle_segment_count = 22;
|
||||
config.curve_segment_count = 22;
|
||||
config.arc_segment_count = 22;
|
||||
config.global_alpha = 1.0f;
|
||||
config.shape_AA = AA;
|
||||
config.line_AA = AA;
|
||||
|
||||
#if 0
|
||||
config.line_thickness = 1.0f;
|
||||
#endif
|
||||
config.null = dev->null;
|
||||
|
||||
/* setup buffers to load vertices and elements */
|
||||
nk_buffer_init_fixed(&vbuf, vertices, MAX_VERTEX_MEMORY);
|
||||
nk_buffer_init_fixed(&ebuf, elements, MAX_ELEMENT_MEMORY);
|
||||
nk_convert(ctx, &dev->cmds, &vbuf, &ebuf, &config);
|
||||
|
||||
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES)
|
||||
glUnmapBuffer(GL_ARRAY_BUFFER);
|
||||
glUnmapBuffer(GL_ELEMENT_ARRAY_BUFFER);
|
||||
#endif
|
||||
|
||||
/* iterate over and execute each draw command */
|
||||
nk_draw_foreach(cmd, ctx, &dev->cmds)
|
||||
{
|
||||
if (!cmd->elem_count)
|
||||
continue;
|
||||
|
||||
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES)
|
||||
glBindTexture(GL_TEXTURE_2D, (GLuint)cmd->texture.id);
|
||||
glScissor((GLint)cmd->clip_rect.x,
|
||||
height - (GLint)(cmd->clip_rect.y + cmd->clip_rect.h),
|
||||
(GLint)cmd->clip_rect.w,
|
||||
(GLint)cmd->clip_rect.h);
|
||||
glDrawElements(GL_TRIANGLES, (GLsizei)cmd->elem_count,
|
||||
GL_UNSIGNED_SHORT, offset);
|
||||
#endif
|
||||
|
||||
offset += cmd->elem_count;
|
||||
}
|
||||
nk_clear(ctx);
|
||||
|
||||
/* restore old state */
|
||||
shader_info.data = NULL;
|
||||
shader_info.idx = (GLint)last_prog;
|
||||
shader_info.set_active = false;
|
||||
video_shader_driver_use(shader_info);
|
||||
|
||||
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES)
|
||||
glBindTexture(GL_TEXTURE_2D, (GLuint)last_tex);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, (GLuint)last_vbo);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, (GLuint)last_ebo);
|
||||
glBindVertexArray((GLuint)last_vao);
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
#endif
|
||||
|
||||
menu_display_blend_end();
|
||||
}
|
||||
|
||||
void* nk_common_mem_alloc(nk_handle a, void *old, nk_size b)
|
||||
{
|
||||
(void)a;
|
||||
return calloc(1, b);
|
||||
}
|
||||
|
||||
void nk_common_mem_free(nk_handle unused, void *ptr)
|
||||
{
|
||||
(void)unused;
|
||||
free(ptr);
|
||||
}
|
@ -1,98 +0,0 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2011-2017 - Daniel De Matteis
|
||||
* Copyright (C) 2014-2017 - Jean-André Santoni
|
||||
* Copyright (C) 2016-2017 - Andrés Suárez
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
/* This file is intended for backend code. */
|
||||
|
||||
#ifndef _NK_COMMON_H
|
||||
#define _NK_COMMON_H
|
||||
|
||||
#define NK_INCLUDE_FIXED_TYPES
|
||||
#define NK_INCLUDE_STANDARD_IO
|
||||
#define NK_INCLUDE_STANDARD_VARARGS
|
||||
#define NK_INCLUDE_DEFAULT_ALLOCATOR
|
||||
#define NK_INCLUDE_VERTEX_BUFFER_OUTPUT
|
||||
#define NK_INCLUDE_FONT_BAKING
|
||||
#define NK_INCLUDE_DEFAULT_FONT
|
||||
|
||||
#define UNUSED(a) (void)a
|
||||
#define MIN(a,b) ((a) < (b) ? (a) : (b))
|
||||
#define MAX(a,b) ((a) < (b) ? (b) : (a))
|
||||
#define LEN(a) (sizeof(a)/sizeof(a)[0])
|
||||
|
||||
#define MAX_SIZE 256
|
||||
|
||||
#include <string.h>
|
||||
#include "../../../deps/nuklear/nuklear.h"
|
||||
#include "../../../deps/stb/stb_image.h"
|
||||
|
||||
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES)
|
||||
#include "../../../gfx/common/gl_common.h"
|
||||
#endif
|
||||
|
||||
#define MAX_VERTEX_MEMORY (512 * 1024)
|
||||
#define MAX_ELEMENT_MEMORY (128 * 1024)
|
||||
|
||||
#define NK_SYSTEM_TAB_END NK_SYSTEM_TAB_SETTINGS
|
||||
|
||||
struct nk_device
|
||||
{
|
||||
struct nk_buffer cmds;
|
||||
struct nk_draw_null_texture null;
|
||||
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES)
|
||||
GLuint vbo, vao, ebo;
|
||||
|
||||
GLuint prog;
|
||||
GLuint vert_shdr;
|
||||
GLuint frag_shdr;
|
||||
|
||||
GLint attrib_pos;
|
||||
GLint attrib_uv;
|
||||
GLint attrib_col;
|
||||
|
||||
GLint uniform_proj;
|
||||
GLuint font_tex;
|
||||
#endif
|
||||
};
|
||||
|
||||
/* generic nuklear members*/
|
||||
extern struct nk_font *font;
|
||||
extern struct nk_font_atlas atlas;
|
||||
extern struct nk_user_font usrfnt;
|
||||
extern struct nk_allocator nk_alloc;
|
||||
extern struct nk_device device;
|
||||
|
||||
struct nk_image nk_common_image_load(const char *filename);
|
||||
|
||||
char* nk_common_file_load(const char* path, size_t* size);
|
||||
|
||||
void nk_common_device_init(struct nk_device *dev);
|
||||
|
||||
void nk_common_device_shutdown(struct nk_device *dev);
|
||||
|
||||
void nk_common_device_draw(struct nk_device *dev,
|
||||
struct nk_context *ctx, int width, int height,
|
||||
enum nk_anti_aliasing AA);
|
||||
|
||||
void* nk_common_mem_alloc(nk_handle a, void *old, nk_size b);
|
||||
|
||||
void nk_common_mem_free(nk_handle unused, void *ptr);
|
||||
|
||||
void nk_upload_atlas(struct nk_device *dev, const void *image, int width, int height);
|
||||
|
||||
struct nk_image color_bars, test_entry, test_entry2;
|
||||
|
||||
#endif
|
@ -1,74 +0,0 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2011-2017 - Daniel De Matteis
|
||||
* Copyright (C) 2014-2017 - Jean-André Santoni
|
||||
* Copyright (C) 2016-2017 - Andrés Suárez
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
/* This file is intended for menu functions, custom controls, etc. */
|
||||
|
||||
#include "nk_menu.h"
|
||||
|
||||
/* sets window position and size */
|
||||
void nk_wnd_set_state(nk_menu_handle_t *nk, const int id,
|
||||
struct nk_vec2 pos, struct nk_vec2 size)
|
||||
{
|
||||
nk->window[id].position = pos;
|
||||
nk->window[id].size = size;
|
||||
}
|
||||
|
||||
/* gets window position and size */
|
||||
void nk_wnd_get_state(nk_menu_handle_t *nk, const int id,
|
||||
struct nk_vec2 *pos, struct nk_vec2 *size)
|
||||
{
|
||||
*pos = nk->window[id].position;
|
||||
*size = nk->window[id].size;
|
||||
}
|
||||
|
||||
/* sets the theme */
|
||||
void nk_common_set_style(struct nk_context *ctx)
|
||||
{
|
||||
/* standard nuklear colors */
|
||||
nk_colors[NK_COLOR_TEXT] = nk_rgba(158, 158, 158, 255);
|
||||
nk_colors[NK_COLOR_WINDOW] = nk_rgba(57, 67, 71, 215);
|
||||
nk_colors[NK_COLOR_HEADER] = nk_rgba(51, 51, 56, 220);
|
||||
nk_colors[NK_COLOR_BORDER] = nk_rgba(46, 46, 46, 255);
|
||||
nk_colors[NK_COLOR_BUTTON] = nk_rgba(255, 112, 67, 255);
|
||||
nk_colors[NK_COLOR_BUTTON_HOVER] = nk_rgba(58, 93, 121, 255);
|
||||
nk_colors[NK_COLOR_BUTTON_ACTIVE] = nk_rgba(63, 98, 126, 255);
|
||||
nk_colors[NK_COLOR_TOGGLE] = nk_rgba(50, 58, 61, 255);
|
||||
nk_colors[NK_COLOR_TOGGLE_HOVER] = nk_rgba(45, 53, 56, 255);
|
||||
nk_colors[NK_COLOR_TOGGLE_CURSOR] = nk_rgba(48, 83, 111, 255);
|
||||
nk_colors[NK_COLOR_SELECT] = nk_rgba(57, 67, 61, 255);
|
||||
nk_colors[NK_COLOR_SELECT_ACTIVE] = nk_rgba(48, 83, 111, 255);
|
||||
nk_colors[NK_COLOR_SLIDER] = nk_rgba(50, 58, 61, 255);
|
||||
nk_colors[NK_COLOR_SLIDER_CURSOR] = nk_rgba(48, 83, 111, 245);
|
||||
nk_colors[NK_COLOR_SLIDER_CURSOR_HOVER] = nk_rgba(53, 88, 116, 255);
|
||||
nk_colors[NK_COLOR_SLIDER_CURSOR_ACTIVE] = nk_rgba(58, 93, 121, 255);
|
||||
nk_colors[NK_COLOR_PROPERTY] = nk_rgba(50, 58, 61, 255);
|
||||
nk_colors[NK_COLOR_EDIT] = nk_rgba(50, 58, 61, 225);
|
||||
nk_colors[NK_COLOR_EDIT_CURSOR] = nk_rgba(210, 210, 210, 255);
|
||||
nk_colors[NK_COLOR_COMBO] = nk_rgba(50, 58, 61, 255);
|
||||
nk_colors[NK_COLOR_CHART] = nk_rgba(50, 58, 61, 255);
|
||||
nk_colors[NK_COLOR_CHART_COLOR] = nk_rgba(48, 83, 111, 255);
|
||||
nk_colors[NK_COLOR_CHART_COLOR_HIGHLIGHT] = nk_rgba(255, 0, 0, 255);
|
||||
nk_colors[NK_COLOR_SCROLLBAR] = nk_rgba(50, 58, 61, 0);
|
||||
nk_colors[NK_COLOR_SCROLLBAR_CURSOR] = nk_rgba(48, 83, 111, 0);
|
||||
nk_colors[NK_COLOR_SCROLLBAR_CURSOR_HOVER] = nk_rgba(53, 88, 116, 50);
|
||||
nk_colors[NK_COLOR_SCROLLBAR_CURSOR_ACTIVE] = nk_rgba(58, 93, 121, 100);
|
||||
nk_colors[NK_COLOR_TAB_HEADER] = nk_rgba(48, 83, 111, 255);
|
||||
nk_style_from_table(ctx, nk_colors);
|
||||
|
||||
/* style */
|
||||
ctx->style.button.text_alignment = NK_TEXT_ALIGN_CENTERED;
|
||||
}
|
@ -1,89 +0,0 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2011-2017 - Daniel De Matteis
|
||||
* Copyright (C) 2014-2017 - Jean-André Santoni
|
||||
* Copyright (C) 2016-2017- Andrés Suárez
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
/* This file is intended for menu functions, custom controls, etc. */
|
||||
|
||||
#ifndef _NK_MENU_H
|
||||
#define _NK_MENU_H
|
||||
|
||||
#include "nk_common.h"
|
||||
|
||||
#include "../../menu_driver.h"
|
||||
#include "../../menu_input.h"
|
||||
|
||||
enum
|
||||
{
|
||||
NK_WND_DEBUG = 0,
|
||||
NK_WND_LAST
|
||||
};
|
||||
|
||||
struct icons {
|
||||
struct nk_image folder;
|
||||
struct nk_image monitor;
|
||||
struct nk_image gamepad;
|
||||
struct nk_image settings;
|
||||
struct nk_image speaker;
|
||||
struct nk_image invader;
|
||||
struct nk_image page_on;
|
||||
struct nk_image page_off;
|
||||
};
|
||||
|
||||
struct window {
|
||||
bool open;
|
||||
struct nk_vec2 position;
|
||||
struct nk_vec2 size;
|
||||
};
|
||||
|
||||
typedef struct nk_menu_handle
|
||||
{
|
||||
/* nuklear mandatory */
|
||||
void *memory;
|
||||
struct nk_context ctx;
|
||||
struct nk_memory_status status;
|
||||
enum menu_action action;
|
||||
|
||||
/* window control variables */
|
||||
struct nk_vec2 size;
|
||||
bool size_changed;
|
||||
struct window window[5];
|
||||
|
||||
/* menu driver variables */
|
||||
char box_message[PATH_MAX_LENGTH];
|
||||
|
||||
/* image & theme related variables */
|
||||
char assets_directory[PATH_MAX_LENGTH];
|
||||
struct icons icons;
|
||||
|
||||
struct
|
||||
{
|
||||
menu_texture_item bg;
|
||||
menu_texture_item pointer;
|
||||
} textures;
|
||||
|
||||
video_font_raster_block_t list_block;
|
||||
} nk_menu_handle_t;
|
||||
|
||||
struct nk_color nk_colors[NK_COLOR_COUNT];
|
||||
|
||||
void nk_wnd_debug(nk_menu_handle_t *nk);
|
||||
void nk_wnd_set_state(nk_menu_handle_t *nk, const int id,
|
||||
struct nk_vec2 pos, struct nk_vec2 size);
|
||||
void nk_wnd_get_state(nk_menu_handle_t *nk, const int id,
|
||||
struct nk_vec2 *pos, struct nk_vec2 *size);
|
||||
void nk_common_set_style(struct nk_context *ctx);
|
||||
|
||||
#endif
|
@ -1,71 +0,0 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2011-2017 - Daniel De Matteis
|
||||
* Copyright (C) 2014-2017 - Jean-André Santoni
|
||||
* Copyright (C) 2016-2017 - Andrés Suárez
|
||||
*
|
||||
* 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 "nk_menu.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <file/file_path.h>
|
||||
#include <string/stdstring.h>
|
||||
#include <lists/string_list.h>
|
||||
|
||||
#include "../../menu_driver.h"
|
||||
|
||||
#include "../../../gfx/common/gl_common.h"
|
||||
#include "../../../core_info.h"
|
||||
#include "../../../configuration.h"
|
||||
#include "../../../retroarch.h"
|
||||
|
||||
void nk_wnd_debug(nk_menu_handle_t *nk)
|
||||
{
|
||||
unsigned i;
|
||||
video_shader_ctx_t shader_info;
|
||||
struct nk_panel layout;
|
||||
struct nk_context *ctx = &nk->ctx;
|
||||
const int id = NK_WND_DEBUG;
|
||||
|
||||
if (nk_begin(ctx, "Debug", nk_rect(10, 10, 400, 500),
|
||||
NK_WINDOW_CLOSABLE|NK_WINDOW_MINIMIZABLE|NK_WINDOW_MOVABLE|
|
||||
NK_WINDOW_BORDER))
|
||||
{
|
||||
nk_layout_row_dynamic(ctx, 30, 1);
|
||||
|
||||
video_shader_driver_get_current_shader(&shader_info);
|
||||
|
||||
if (shader_info.data)
|
||||
{
|
||||
for (i = 0; i < GFX_MAX_PARAMETERS; i++)
|
||||
{
|
||||
if (!string_is_empty(shader_info.data->parameters[i].desc))
|
||||
{
|
||||
nk_property_float(ctx, shader_info.data->parameters[i].desc,
|
||||
shader_info.data->parameters[i].minimum,
|
||||
&(shader_info.data->parameters[i].current),
|
||||
shader_info.data->parameters[i].maximum,
|
||||
shader_info.data->parameters[i].step, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* save position and size to restore after context reset */
|
||||
nk_wnd_set_state(nk, id, nk_window_get_position(ctx), nk_window_get_size(ctx));
|
||||
nk_end(ctx);
|
||||
}
|
@ -79,16 +79,14 @@ static GLenum menu_display_prim_to_gl_enum(
|
||||
|
||||
static void menu_display_gl_blend_begin(video_frame_info_t *video_info)
|
||||
{
|
||||
video_shader_ctx_info_t shader_info;
|
||||
gl_t *gl = (gl_t*)video_info->userdata;
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
shader_info.data = NULL;
|
||||
shader_info.idx = VIDEO_SHADER_STOCK_BLEND;
|
||||
shader_info.set_active = true;
|
||||
|
||||
video_shader_driver_use(&shader_info);
|
||||
if (gl && gl->shader && gl->shader->use)
|
||||
gl->shader->use(gl, gl->shader_data, VIDEO_SHADER_STOCK_BLEND,
|
||||
true);
|
||||
}
|
||||
|
||||
static void menu_display_gl_blend_end(video_frame_info_t *video_info)
|
||||
@ -108,8 +106,7 @@ static void menu_display_gl_draw(menu_display_ctx_draw_t *draw,
|
||||
{
|
||||
video_shader_ctx_mvp_t mvp;
|
||||
video_shader_ctx_coords_t coords;
|
||||
gl_t *gl = video_info ?
|
||||
(gl_t*)video_info->userdata : NULL;
|
||||
gl_t *gl = (gl_t*)video_info->userdata;
|
||||
|
||||
if (!gl || !draw)
|
||||
return;
|
||||
@ -146,8 +143,9 @@ static void menu_display_gl_draw_pipeline(menu_display_ctx_draw_t *draw,
|
||||
video_frame_info_t *video_info)
|
||||
{
|
||||
#ifdef HAVE_SHADERPIPELINE
|
||||
video_shader_ctx_info_t shader_info;
|
||||
struct uniform_info uniform_param;
|
||||
gl_t *gl = video_info ?
|
||||
(gl_t*)video_info->userdata : NULL;
|
||||
static float t = 0;
|
||||
video_coord_array_t *ca = menu_display_get_coords_array();
|
||||
|
||||
@ -175,11 +173,9 @@ static void menu_display_gl_draw_pipeline(menu_display_ctx_draw_t *draw,
|
||||
case VIDEO_SHADER_MENU_4:
|
||||
case VIDEO_SHADER_MENU_5:
|
||||
case VIDEO_SHADER_MENU_6:
|
||||
shader_info.data = NULL;
|
||||
shader_info.idx = draw->pipeline.id;
|
||||
shader_info.set_active = true;
|
||||
|
||||
video_shader_driver_use(&shader_info);
|
||||
if (gl && gl->shader && gl->shader->use)
|
||||
gl->shader->use(gl, gl->shader_data, draw->pipeline.id,
|
||||
true);
|
||||
|
||||
t += 0.01;
|
||||
|
||||
|
@ -88,9 +88,6 @@ static const menu_ctx_driver_t *menu_ctx_drivers[] = {
|
||||
#if defined(HAVE_MATERIALUI)
|
||||
&menu_ctx_mui,
|
||||
#endif
|
||||
#if defined(HAVE_NUKLEAR)
|
||||
&menu_ctx_nuklear,
|
||||
#endif
|
||||
#if defined(HAVE_OZONE)
|
||||
&menu_ctx_ozone,
|
||||
#endif
|
||||
|
@ -495,7 +495,6 @@ if [ "$HAVE_MENU" != 'no' ]; then
|
||||
HAVE_MATERIALUI=no
|
||||
HAVE_OZONE=no
|
||||
HAVE_XMB=no
|
||||
HAVE_NUKLEAR=no
|
||||
HAVE_STRIPES=no
|
||||
HAVE_ZARCH=no
|
||||
fi
|
||||
|
@ -15,7 +15,6 @@ HAVE_XMB=auto # XMB menu
|
||||
HAVE_OZONE=auto # Ozone menu
|
||||
HAVE_STRIPES=no # Stripes menu
|
||||
HAVE_ZARCH=no # Zarch menu
|
||||
HAVE_NUKLEAR=no # Nuklear menu
|
||||
HAVE_RUNAHEAD=yes # Runahead support
|
||||
HAVE_SSL=auto # SSL/mbedtls support
|
||||
C89_SSL=no
|
||||
|
Loading…
x
Reference in New Issue
Block a user