mirror of
https://github.com/libretro/RetroArch
synced 2025-03-23 10:20:57 +00:00
update nuklear
This commit is contained in:
parent
ea56249661
commit
d61d55e3ea
7748
deps/nuklear/nuklear.h
vendored
7748
deps/nuklear/nuklear.h
vendored
File diff suppressed because it is too large
Load Diff
@ -43,6 +43,12 @@ 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;
|
||||
@ -79,9 +85,16 @@ 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);
|
||||
@ -98,29 +111,21 @@ void nk_common_device_init(struct nk_device *dev)
|
||||
dev->attrib_uv = glGetAttribLocation(dev->prog, "TexCoord");
|
||||
dev->attrib_col = glGetAttribLocation(dev->prog, "Color");
|
||||
|
||||
{
|
||||
/* buffer setup */
|
||||
GLsizei vs = sizeof(struct nk_draw_vertex);
|
||||
size_t vp = offsetof(struct nk_draw_vertex, position);
|
||||
size_t vt = offsetof(struct nk_draw_vertex, uv);
|
||||
size_t vc = offsetof(struct nk_draw_vertex, col);
|
||||
glGenBuffers(1, &dev->vbo);
|
||||
glGenBuffers(1, &dev->ebo);
|
||||
glGenVertexArrays(1, &dev->vao);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
}
|
||||
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);
|
||||
@ -165,6 +170,14 @@ void nk_common_device_draw(struct nk_device *dev,
|
||||
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;
|
||||
@ -222,6 +235,8 @@ void nk_common_device_draw(struct nk_device *dev,
|
||||
config.shape_AA = AA;
|
||||
config.line_AA = AA;
|
||||
config.circle_segment_count = 22;
|
||||
config.vertex_layout = vertex_layout;
|
||||
config.vertex_size = sizeof(struct nk_vertex);
|
||||
#if 0
|
||||
config.line_thickness = 1.0f;
|
||||
#endif
|
||||
|
@ -88,7 +88,7 @@ bool nk_wnd_file_picker(nk_menu_handle_t *nk, char* title, char* in, char* out,
|
||||
if (!assets_loaded)
|
||||
load_icons(nk);
|
||||
|
||||
if (nk_begin(ctx, &layout, title, nk_rect(10, 10, 500, 400),
|
||||
if (nk_begin(ctx, title, nk_rect(10, 10, 500, 400),
|
||||
NK_WINDOW_CLOSABLE|NK_WINDOW_MINIMIZABLE|NK_WINDOW_MOVABLE|
|
||||
NK_WINDOW_BORDER))
|
||||
{
|
||||
@ -97,7 +97,7 @@ bool nk_wnd_file_picker(nk_menu_handle_t *nk, char* title, char* in, char* out,
|
||||
if (drives->size == 0)
|
||||
{
|
||||
if(nk_button_image_label(ctx, icons.disk, "/",
|
||||
NK_TEXT_CENTERED, NK_BUTTON_DEFAULT))
|
||||
NK_TEXT_CENTERED))
|
||||
{
|
||||
fill_pathname_join(path, "/",
|
||||
"", sizeof(path));
|
||||
@ -109,7 +109,7 @@ bool nk_wnd_file_picker(nk_menu_handle_t *nk, char* title, char* in, char* out,
|
||||
for (i = 0; i < drives->size; i++)
|
||||
{
|
||||
if(nk_button_image_label(ctx, icons.disk, drives->list[i].path,
|
||||
NK_TEXT_CENTERED, NK_BUTTON_DEFAULT))
|
||||
NK_TEXT_CENTERED))
|
||||
{
|
||||
fill_pathname_join(path, drives->list[i].path,
|
||||
"", sizeof(path));
|
||||
@ -125,7 +125,7 @@ bool nk_wnd_file_picker(nk_menu_handle_t *nk, char* title, char* in, char* out,
|
||||
{
|
||||
if (nk_button_image_label(ctx, path_is_directory(files->elems[i].data) ?
|
||||
icons.folder : icons.file, path_basename(files->elems[i].data),
|
||||
NK_TEXT_RIGHT, NK_BUTTON_DEFAULT))
|
||||
NK_TEXT_RIGHT))
|
||||
{
|
||||
strlcpy (path, files->elems[i].data, sizeof(path));
|
||||
if (path_is_directory (path))
|
||||
@ -135,7 +135,7 @@ bool nk_wnd_file_picker(nk_menu_handle_t *nk, char* title, char* in, char* out,
|
||||
}
|
||||
nk_layout_row_dynamic(ctx, 30, 1);
|
||||
{
|
||||
if (nk_button_text(ctx, "OK", 2, NK_BUTTON_DEFAULT))
|
||||
if (nk_button_text(ctx, "OK", 2))
|
||||
{
|
||||
ret = true;
|
||||
strlcpy(out, path, sizeof(path));
|
||||
|
@ -71,7 +71,7 @@ void nk_wnd_main(nk_menu_handle_t *nk, const char* title)
|
||||
}
|
||||
|
||||
|
||||
if (nk_begin(ctx, &layout, title, nk_rect(240, 10, 600, 400),
|
||||
if (nk_begin(ctx, title, nk_rect(240, 10, 600, 400),
|
||||
NK_WINDOW_CLOSABLE|NK_WINDOW_MINIMIZABLE|NK_WINDOW_MOVABLE|
|
||||
NK_WINDOW_SCALABLE|NK_WINDOW_BORDER))
|
||||
{
|
||||
@ -79,7 +79,7 @@ void nk_wnd_main(nk_menu_handle_t *nk, const char* title)
|
||||
nk_label(ctx,"Core:", NK_TEXT_LEFT);
|
||||
nk_layout_row(ctx, NK_DYNAMIC, 30, 3, ratio);
|
||||
nk_edit_string(ctx, NK_EDIT_SIMPLE, core_basename, &len_core, 64, nk_filter_default);
|
||||
if (nk_button_text(ctx, "...", 3, NK_BUTTON_DEFAULT))
|
||||
if (nk_button_text(ctx, "...", 3))
|
||||
{
|
||||
out = core;
|
||||
strlcpy(picker_title, "Select core", sizeof(picker_title));
|
||||
@ -91,7 +91,7 @@ void nk_wnd_main(nk_menu_handle_t *nk, const char* title)
|
||||
nk_label(ctx,"Content:", NK_TEXT_LEFT);
|
||||
nk_layout_row(ctx, NK_DYNAMIC, 30, 3, ratio);
|
||||
nk_edit_string(ctx, NK_EDIT_SIMPLE, content, &len_content, 64, nk_filter_default);
|
||||
if (nk_button_text(ctx, "...", 3, NK_BUTTON_DEFAULT))
|
||||
if (nk_button_text(ctx, "...", 3))
|
||||
{
|
||||
out = content;
|
||||
strlcpy(picker_title, "Select content", sizeof(picker_title));
|
||||
|
@ -36,7 +36,7 @@ void nk_wnd_settings(nk_menu_handle_t *nk)
|
||||
struct nk_context *ctx = &nk->ctx;
|
||||
const int id = NK_WND_SETTINGS;
|
||||
|
||||
if (nk_begin(ctx, &layout, "Settings", nk_rect(240, 10, 300, 400),
|
||||
if (nk_begin(ctx, "Settings", nk_rect(240, 10, 300, 400),
|
||||
NK_WINDOW_CLOSABLE|NK_WINDOW_MINIMIZABLE|NK_WINDOW_MOVABLE|
|
||||
NK_WINDOW_SCALABLE|NK_WINDOW_BORDER))
|
||||
{
|
||||
|
@ -41,7 +41,7 @@ void nk_wnd_shader_parameters(nk_menu_handle_t *nk)
|
||||
struct nk_context *ctx = &nk->ctx;
|
||||
const int id = NK_WND_SHADER_PARAMETERS;
|
||||
|
||||
if (nk_begin(ctx, &layout, "Shader Parameters", nk_rect(240, 10, 300, 400),
|
||||
if (nk_begin(ctx, "Shader Parameters", nk_rect(240, 10, 300, 400),
|
||||
NK_WINDOW_CLOSABLE|NK_WINDOW_MINIMIZABLE|NK_WINDOW_MOVABLE|
|
||||
NK_WINDOW_SCALABLE|NK_WINDOW_BORDER))
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user