RetroArch
nk_common.h
Go to the documentation of this file.
1 /* RetroArch - A frontend for libretro.
2  * Copyright (C) 2011-2017 - Daniel De Matteis
3  * Copyright (C) 2014-2017 - Jean-André Santoni
4  * Copyright (C) 2016-2017 - Andrés Suárez
5  *
6  * RetroArch is free software: you can redistribute it and/or modify it under the terms
7  * of the GNU General Public License as published by the Free Software Found-
8  * ation, either version 3 of the License, or (at your option) any later version.
9  *
10  * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
11  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  * PURPOSE. See the GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along with RetroArch.
15  * If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 /* This file is intended for backend code. */
19 
20 #ifndef _NK_COMMON_H
21 #define _NK_COMMON_H
22 
23 #define NK_INCLUDE_FIXED_TYPES
24 #define NK_INCLUDE_STANDARD_IO
25 #define NK_INCLUDE_STANDARD_VARARGS
26 #define NK_INCLUDE_DEFAULT_ALLOCATOR
27 #define NK_INCLUDE_VERTEX_BUFFER_OUTPUT
28 #define NK_INCLUDE_FONT_BAKING
29 #define NK_INCLUDE_DEFAULT_FONT
30 
31 #define UNUSED(a) (void)a
32 #define MIN(a,b) ((a) < (b) ? (a) : (b))
33 #define MAX(a,b) ((a) < (b) ? (b) : (a))
34 #define LEN(a) (sizeof(a)/sizeof(a)[0])
35 
36 #define MAX_SIZE 256
37 
38 #include <string.h>
39 #include "../../../deps/nuklear/nuklear.h"
40 #include "../../../deps/stb/stb_image.h"
41 
42 #if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES)
43 #include "../../../gfx/common/gl_common.h"
44 #endif
45 
46 #define MAX_VERTEX_MEMORY (512 * 1024)
47 #define MAX_ELEMENT_MEMORY (128 * 1024)
48 
49 #define NK_SYSTEM_TAB_END NK_SYSTEM_TAB_SETTINGS
50 
51  struct nk_device
52  {
53  struct nk_buffer cmds;
55 #if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES)
56  GLuint vbo, vao, ebo;
57 
58  GLuint prog;
59  GLuint vert_shdr;
60  GLuint frag_shdr;
61 
62  GLint attrib_pos;
63  GLint attrib_uv;
64  GLint attrib_col;
65 
66  GLint uniform_proj;
67  GLuint font_tex;
68 #endif
69 };
70 
71 /* generic nuklear members*/
72 extern struct nk_font *font;
73 extern struct nk_font_atlas atlas;
74 extern struct nk_user_font usrfnt;
75 extern struct nk_allocator nk_alloc;
76 extern struct nk_device device;
77 
78 struct nk_image nk_common_image_load(const char *filename);
79 
80 char* nk_common_file_load(const char* path, size_t* size);
81 
82 void nk_common_device_init(struct nk_device *dev);
83 
84 void nk_common_device_shutdown(struct nk_device *dev);
85 
86 void nk_common_device_draw(struct nk_device *dev,
87  struct nk_context *ctx, int width, int height,
88  enum nk_anti_aliasing AA);
89 
90 void* nk_common_mem_alloc(nk_handle a, void *old, nk_size b);
91 
92 void nk_common_mem_free(nk_handle unused, void *ptr);
93 
94 void nk_upload_atlas(struct nk_device *dev, const void *image, int width, int height);
95 
96 struct nk_image color_bars, test_entry, test_entry2;
97 
98 #endif
void nk_common_mem_free(nk_handle unused, void *ptr)
Definition: nk_common.c:305
const GLvoid * ptr
Definition: nx_glsym.h:242
Definition: nuklear.h:2484
#define const
Definition: zconf.h:217
nk_anti_aliasing
Definition: nuklear.h:969
char * nk_common_file_load(const char *path, size_t *size)
Definition: nk_common.c:75
void * nk_common_mem_alloc(nk_handle a, void *old, nk_size b)
Definition: nk_common.c:299
GLsizei const GLchar ** path
Definition: glext.h:7901
unsigned int GLuint
Definition: nx_gl.h:48
GLsizeiptr size
Definition: glext.h:6559
struct nk_font * font
Definition: nk_common.c:40
struct nk_device device
Definition: nk_common.c:44
struct nk_buffer cmds
Definition: nk_common.h:53
void nk_common_device_init(struct nk_device *dev)
Definition: nk_common.c:83
GLboolean GLboolean GLboolean b
Definition: glext.h:6844
void nk_common_device_shutdown(struct nk_device *dev)
Definition: nk_common.c:147
NK_SIZE_TYPE nk_size
Definition: nuklear.h:401
Definition: nuklear.h:460
AVFormatContext * ctx
Definition: record_ffmpeg.c:247
struct nk_font_atlas atlas
Definition: nk_common.c:41
Definition: nuklear.h:977
GLenum GLsizei GLenum GLenum const GLvoid * image
Definition: glext.h:6305
struct nk_draw_null_texture null
Definition: nk_common.h:54
Definition: nk_common.h:51
struct nk_image color_bars test_entry test_entry2
Definition: nk_common.h:96
struct nk_allocator nk_alloc
Definition: nk_common.c:43
GLint GLint GLsizei width
Definition: glext.h:6293
Definition: nuklear.h:484
struct nk_image nk_common_image_load(const char *filename)
Definition: nk_common.c:52
Definition: nuklear.h:461
Definition: nuklear.h:4133
Definition: nuklear.h:2685
int GLint
Definition: nx_gl.h:45
struct nk_user_font usrfnt
Definition: nk_common.c:42
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6844
void nk_common_device_draw(struct nk_device *dev, struct nk_context *ctx, int width, int height, enum nk_anti_aliasing AA)
Definition: nk_common.c:161
GLint GLint GLsizei GLsizei height
Definition: glext.h:6293
void nk_upload_atlas(struct nk_device *dev, const void *image, int width, int height)
Definition: nk_common.c:137