31 #include <glad/glad.h> 34 #define NK_IMPLEMENTATION 35 #define NK_INCLUDE_FIXED_TYPES 36 #define NK_INCLUDE_FONT_BAKING 37 #define NK_INCLUDE_DEFAULT_FONT 38 #define NK_INCLUDE_DEFAULT_ALLOCATOR 39 #define NK_INCLUDE_VERTEX_BUFFER_OUTPUT 40 #define NK_INCLUDE_STANDARD_VARARGS 41 #define NK_BUTTON_TRIGGER_ON_RELEASE 44 #define NK_GLFW_GL2_IMPLEMENTATION 52 #define strdup(x) _strdup(x) 61 fprintf(stderr,
"Error: %s\n", description);
92 for (i = 0; i <
count; i++)
96 FILE*
stream = fopen(paths[i],
"rb");
100 fseek(stream, 0, SEEK_END);
101 size = ftell(stream);
102 fseek(stream, 0, SEEK_SET);
104 text = malloc(size + 1);
106 if (fread(text, 1, size, stream) == size)
116 static char label[1024];
130 center =
nk_vec2(area.
x + area.
w / 2.f, area.
y + area.
h / 2.f);
131 radius =
NK_MIN(area.
w, area.
h) / 2.f;
143 const float angles[] =
153 const float cosa = nk_cos(angles[state]);
154 const float sina = nk_sin(angles[state]);
160 center.
x + cosa * p0.
x + sina * p0.
y,
161 center.
y + cosa * p0.
y - sina * p0.
x,
162 center.
x + cosa * p1.
x + sina * p1.
y,
163 center.
y + cosa * p1.
y - sina * p1.
x,
164 center.
x + cosa * p2.
x + sina * p2.
y,
165 center.
y + cosa * p2.
y - sina * p2.
x,
174 struct nk_font_atlas* atlas;
220 nk_rect(width - 200.
f, 0.
f, 200.
f, (
float) height),
246 nk_rect(i * 20.
f, i * 20.f, 550.f, 570.f),
253 int j, axis_count, button_count, hat_count;
255 const unsigned char* buttons;
256 const unsigned char* hats;
269 button_count -= hat_count * 4;
271 for (j = 0; j < axis_count; j++)
276 for (j = 0; j < button_count; j++)
279 snprintf(name,
sizeof(name),
"%i", j + 1);
285 for (j = 0; j < hat_count; j++)
297 "Back",
"Start",
"Guide",
static void error_callback(int error, const char *description)
static void joystick_callback(int jid, int event)
static void drop_callback(GLFWwindow *window, int count, const char **paths)
NK_API int nk_begin(struct nk_context *ctx, const char *title, struct nk_rect bounds, nk_flags flags)
NK_API void nk_stroke_circle(struct nk_command_buffer *, struct nk_rect, float line_thickness, struct nk_color)
static void hat_widget(struct nk_context *nk, unsigned char state)
GLFWAPI void glfwGetWindowSize(GLFWwindow *window, int *width, int *height)
Retrieves the size of the client area of the specified window.
GLuint const GLchar * name
GLFWAPI int glfwGetWindowAttrib(GLFWwindow *window, int attrib)
Returns an attribute of the specified window.
NK_API int nk_select_label(struct nk_context *, const char *, nk_flags align, int value)
The header of the GLFW 3 API.
GLFWAPI GLFWglproc glfwGetProcAddress(const char *procname)
Returns the address of the specified function for the current context.
void *(* GLADloadproc)(const char *name)
static GLFWwindow * window
def axes(out, pos, rotation=np.eye(3), size=0.075, thickness=2)
NK_API void nk_window_set_focus(struct nk_context *, const char *name)
GLsizei const GLuint * paths
GLFWAPI GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun cbfun)
Sets the error callback.
NK_API void nk_label(struct nk_context *, const char *, nk_flags align)
NK_API void nk_glfw3_render(enum nk_anti_aliasing)
NK_API struct nk_color nk_rgb(int r, int g, int b)
#define GLFW_SCALE_TO_MONITOR
Window content area scaling window window hint.
#define GLFW_DISCONNECTED
NK_API struct nk_vec2 nk_vec2(float x, float y)
GLFWAPI int glfwInit(void)
Initializes the GLFW library.
NK_API void nk_layout_row_dynamic(struct nk_context *ctx, float height, int cols)
#define GL_COLOR_BUFFER_BIT
NK_API void nk_glfw3_new_frame(void)
NK_API struct nk_rect nk_rect(float x, float y, float w, float h)
NK_API struct nk_context * nk_glfw3_init(GLFWwindow *win, enum nk_glfw_init_state)
GLFWAPI void glfwSwapInterval(int interval)
Sets the swap interval for the current context.
GLint GLsizei GLsizei height
GLFWAPI void glfwSwapBuffers(GLFWwindow *window)
Swaps the front and back buffers of the specified window.
GLFWAPI void glfwMakeContextCurrent(GLFWwindow *window)
Makes the context of the specified window current for the calling thread.
#define GLFW_JOYSTICK_LAST
NK_API enum nk_widget_layout_states nk_widget(struct nk_rect *, const struct nk_context *)
unsigned char buttons[15]
GLAPI int gladLoadGLLoader(GLADloadproc)
static const textual_icon exit
#define GLFW_FOCUSED
Input focus window hint and attribute.
static int joystick_count
NK_API void nk_fill_triangle(struct nk_command_buffer *, float x0, float y0, float x1, float y1, float x2, float y2, struct nk_color)
NK_API float nk_slide_float(struct nk_context *, float min, float val, float max, float step)
GLFWAPI GLFWwindow * glfwCreateWindow(int width, int height, const char *title, GLFWmonitor *monitor, GLFWwindow *share)
Creates a window and its associated context.
static int joysticks[GLFW_JOYSTICK_LAST+1]
#define GLFW_GAMEPAD_AXIS_LAST
GLFWAPI void glfwRequestWindowAttention(GLFWwindow *window)
Requests user attention to the specified window.
NK_API struct nk_command_buffer * nk_window_get_canvas(struct nk_context *)
GLuint GLsizei const GLchar * label
NK_API int nk_checkbox_label(struct nk_context *, const char *, int *active)
GLFWAPI void glfwTerminate(void)
Terminates the GLFW library.
GLFWAPI void glfwPollEvents(void)
Processes all pending events.
NK_API void nk_glfw3_font_stash_end(void)
NK_API void nk_glfw3_font_stash_begin(struct nk_font_atlas **atlas)
static const char * joystick_label(int jid)
NK_API void nk_end(struct nk_context *ctx)
NK_API int nk_button_label(struct nk_context *, const char *title)
struct GLFWwindow GLFWwindow
GLFWAPI void glfwWindowHint(int hint, int value)
Sets the specified window hint to the desired value.
GLFWAPI int glfwWindowShouldClose(GLFWwindow *window)
Checks the close flag of the specified window.