Nuklear/demo/glfw_opengl3/main.c

203 lines
6.9 KiB
C
Raw Permalink Normal View History

/* nuklear - 1.32.0 - public domain */
Release Version 1.0 This is the first release version of nuklear (previously: zahnrad). As for those who no the old version will notice: a lot has changed. Most obvious should be the two biggest changes. First the name change because I got critique that the name is hard to comprehend and remember (understandable for non-germans) and the second is the transistion from four files (zahnrad.h, zahnrad.c, stb_truetype and stb_rect_pack) to one single header library file nuklear.h. I am not 100% convinced that using a single header library is the right choice here but so far I haven't encountered any problems. Noticable should be as well that nuklear now directly embeds three stb libraries: stb_truetype, stb_rect_pack and stb_textedit. Like in previous versions the first two are optional and the library can be compiled without. stb_textedit on the other hand powers the text edit implementation for single as well as multiline text manipulation. The text edit implementation is still relative new and untested so you can expect some bugs I have not found yet. In the demo department a lot changed as well. All platform demos now don't compile one big demo but instead contain a simple demo and small abstraction layer over the platform. Main benefit is better understandablity improved ease of use. The old demo is now split up and transfered into the example folder while each part is self contained and compileable. (All examples use glfw I don't now if this is the best platform but it is at least the simplest. I also removed the apple demo because I don't have an apple system and cannot make sure the new version runs with the old version. Finally a lot of small bugs have been fixed as well as bugs found by clang analyzer and coverity.
2016-04-11 02:34:59 +03:00
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdarg.h>
#include <string.h>
#include <math.h>
#include <assert.h>
2016-04-29 18:06:31 +03:00
#include <limits.h>
#include <time.h>
Release Version 1.0 This is the first release version of nuklear (previously: zahnrad). As for those who no the old version will notice: a lot has changed. Most obvious should be the two biggest changes. First the name change because I got critique that the name is hard to comprehend and remember (understandable for non-germans) and the second is the transistion from four files (zahnrad.h, zahnrad.c, stb_truetype and stb_rect_pack) to one single header library file nuklear.h. I am not 100% convinced that using a single header library is the right choice here but so far I haven't encountered any problems. Noticable should be as well that nuklear now directly embeds three stb libraries: stb_truetype, stb_rect_pack and stb_textedit. Like in previous versions the first two are optional and the library can be compiled without. stb_textedit on the other hand powers the text edit implementation for single as well as multiline text manipulation. The text edit implementation is still relative new and untested so you can expect some bugs I have not found yet. In the demo department a lot changed as well. All platform demos now don't compile one big demo but instead contain a simple demo and small abstraction layer over the platform. Main benefit is better understandablity improved ease of use. The old demo is now split up and transfered into the example folder while each part is self contained and compileable. (All examples use glfw I don't now if this is the best platform but it is at least the simplest. I also removed the apple demo because I don't have an apple system and cannot make sure the new version runs with the old version. Finally a lot of small bugs have been fixed as well as bugs found by clang analyzer and coverity.
2016-04-11 02:34:59 +03:00
#include <GL/glew.h>
#include <GLFW/glfw3.h>
#define NK_INCLUDE_FIXED_TYPES
#define NK_INCLUDE_STANDARD_IO
#define NK_INCLUDE_STANDARD_VARARGS
Release Version 1.0 This is the first release version of nuklear (previously: zahnrad). As for those who no the old version will notice: a lot has changed. Most obvious should be the two biggest changes. First the name change because I got critique that the name is hard to comprehend and remember (understandable for non-germans) and the second is the transistion from four files (zahnrad.h, zahnrad.c, stb_truetype and stb_rect_pack) to one single header library file nuklear.h. I am not 100% convinced that using a single header library is the right choice here but so far I haven't encountered any problems. Noticable should be as well that nuklear now directly embeds three stb libraries: stb_truetype, stb_rect_pack and stb_textedit. Like in previous versions the first two are optional and the library can be compiled without. stb_textedit on the other hand powers the text edit implementation for single as well as multiline text manipulation. The text edit implementation is still relative new and untested so you can expect some bugs I have not found yet. In the demo department a lot changed as well. All platform demos now don't compile one big demo but instead contain a simple demo and small abstraction layer over the platform. Main benefit is better understandablity improved ease of use. The old demo is now split up and transfered into the example folder while each part is self contained and compileable. (All examples use glfw I don't now if this is the best platform but it is at least the simplest. I also removed the apple demo because I don't have an apple system and cannot make sure the new version runs with the old version. Finally a lot of small bugs have been fixed as well as bugs found by clang analyzer and coverity.
2016-04-11 02:34:59 +03:00
#define NK_INCLUDE_DEFAULT_ALLOCATOR
#define NK_INCLUDE_VERTEX_BUFFER_OUTPUT
#define NK_INCLUDE_FONT_BAKING
#define NK_INCLUDE_DEFAULT_FONT
#define NK_IMPLEMENTATION
#define NK_GLFW_GL3_IMPLEMENTATION
#define NK_KEYSTATE_BASED_INPUT
#include "../../nuklear.h"
#include "nuklear_glfw_gl3.h"
Release Version 1.0 This is the first release version of nuklear (previously: zahnrad). As for those who no the old version will notice: a lot has changed. Most obvious should be the two biggest changes. First the name change because I got critique that the name is hard to comprehend and remember (understandable for non-germans) and the second is the transistion from four files (zahnrad.h, zahnrad.c, stb_truetype and stb_rect_pack) to one single header library file nuklear.h. I am not 100% convinced that using a single header library is the right choice here but so far I haven't encountered any problems. Noticable should be as well that nuklear now directly embeds three stb libraries: stb_truetype, stb_rect_pack and stb_textedit. Like in previous versions the first two are optional and the library can be compiled without. stb_textedit on the other hand powers the text edit implementation for single as well as multiline text manipulation. The text edit implementation is still relative new and untested so you can expect some bugs I have not found yet. In the demo department a lot changed as well. All platform demos now don't compile one big demo but instead contain a simple demo and small abstraction layer over the platform. Main benefit is better understandablity improved ease of use. The old demo is now split up and transfered into the example folder while each part is self contained and compileable. (All examples use glfw I don't now if this is the best platform but it is at least the simplest. I also removed the apple demo because I don't have an apple system and cannot make sure the new version runs with the old version. Finally a lot of small bugs have been fixed as well as bugs found by clang analyzer and coverity.
2016-04-11 02:34:59 +03:00
#define WINDOW_WIDTH 1200
#define WINDOW_HEIGHT 800
Release Version 1.0 This is the first release version of nuklear (previously: zahnrad). As for those who no the old version will notice: a lot has changed. Most obvious should be the two biggest changes. First the name change because I got critique that the name is hard to comprehend and remember (understandable for non-germans) and the second is the transistion from four files (zahnrad.h, zahnrad.c, stb_truetype and stb_rect_pack) to one single header library file nuklear.h. I am not 100% convinced that using a single header library is the right choice here but so far I haven't encountered any problems. Noticable should be as well that nuklear now directly embeds three stb libraries: stb_truetype, stb_rect_pack and stb_textedit. Like in previous versions the first two are optional and the library can be compiled without. stb_textedit on the other hand powers the text edit implementation for single as well as multiline text manipulation. The text edit implementation is still relative new and untested so you can expect some bugs I have not found yet. In the demo department a lot changed as well. All platform demos now don't compile one big demo but instead contain a simple demo and small abstraction layer over the platform. Main benefit is better understandablity improved ease of use. The old demo is now split up and transfered into the example folder while each part is self contained and compileable. (All examples use glfw I don't now if this is the best platform but it is at least the simplest. I also removed the apple demo because I don't have an apple system and cannot make sure the new version runs with the old version. Finally a lot of small bugs have been fixed as well as bugs found by clang analyzer and coverity.
2016-04-11 02:34:59 +03:00
#define MAX_VERTEX_BUFFER 512 * 1024
#define MAX_ELEMENT_BUFFER 128 * 1024
/* ===============================================================
*
* EXAMPLE
*
* ===============================================================*/
/* This are some code examples to provide a small overview of what can be
* done with this library. To try out an example uncomment the defines */
/*#define INCLUDE_ALL */
/*#define INCLUDE_STYLE */
/*#define INCLUDE_CALCULATOR */
/*#define INCLUDE_CANVAS */
2024-04-25 23:49:50 +03:00
/*#define INCLUDE_OVERVIEW */
/*#define INCLUDE_NODE_EDITOR */
#ifdef INCLUDE_ALL
#define INCLUDE_STYLE
#define INCLUDE_CALCULATOR
#define INCLUDE_CANVAS
#define INCLUDE_OVERVIEW
#define INCLUDE_NODE_EDITOR
#endif
#ifdef INCLUDE_STYLE
#include "../../demo/common/style.c"
#endif
#ifdef INCLUDE_CALCULATOR
#include "../../demo/common/calculator.c"
#endif
#ifdef INCLUDE_CANVAS
#include "../../demo/common/canvas.c"
#endif
#ifdef INCLUDE_OVERVIEW
#include "../../demo/common/overview.c"
#endif
#ifdef INCLUDE_NODE_EDITOR
#include "../../demo/common/node_editor.c"
#endif
/* ===============================================================
*
* DEMO
*
* ===============================================================*/
static void error_callback(int e, const char *d)
{printf("Error %d: %s\n", e, d);}
Release Version 1.0 This is the first release version of nuklear (previously: zahnrad). As for those who no the old version will notice: a lot has changed. Most obvious should be the two biggest changes. First the name change because I got critique that the name is hard to comprehend and remember (understandable for non-germans) and the second is the transistion from four files (zahnrad.h, zahnrad.c, stb_truetype and stb_rect_pack) to one single header library file nuklear.h. I am not 100% convinced that using a single header library is the right choice here but so far I haven't encountered any problems. Noticable should be as well that nuklear now directly embeds three stb libraries: stb_truetype, stb_rect_pack and stb_textedit. Like in previous versions the first two are optional and the library can be compiled without. stb_textedit on the other hand powers the text edit implementation for single as well as multiline text manipulation. The text edit implementation is still relative new and untested so you can expect some bugs I have not found yet. In the demo department a lot changed as well. All platform demos now don't compile one big demo but instead contain a simple demo and small abstraction layer over the platform. Main benefit is better understandablity improved ease of use. The old demo is now split up and transfered into the example folder while each part is self contained and compileable. (All examples use glfw I don't now if this is the best platform but it is at least the simplest. I also removed the apple demo because I don't have an apple system and cannot make sure the new version runs with the old version. Finally a lot of small bugs have been fixed as well as bugs found by clang analyzer and coverity.
2016-04-11 02:34:59 +03:00
int main(void)
{
/* Platform */
2020-04-30 16:17:24 +03:00
struct nk_glfw glfw = {0};
Release Version 1.0 This is the first release version of nuklear (previously: zahnrad). As for those who no the old version will notice: a lot has changed. Most obvious should be the two biggest changes. First the name change because I got critique that the name is hard to comprehend and remember (understandable for non-germans) and the second is the transistion from four files (zahnrad.h, zahnrad.c, stb_truetype and stb_rect_pack) to one single header library file nuklear.h. I am not 100% convinced that using a single header library is the right choice here but so far I haven't encountered any problems. Noticable should be as well that nuklear now directly embeds three stb libraries: stb_truetype, stb_rect_pack and stb_textedit. Like in previous versions the first two are optional and the library can be compiled without. stb_textedit on the other hand powers the text edit implementation for single as well as multiline text manipulation. The text edit implementation is still relative new and untested so you can expect some bugs I have not found yet. In the demo department a lot changed as well. All platform demos now don't compile one big demo but instead contain a simple demo and small abstraction layer over the platform. Main benefit is better understandablity improved ease of use. The old demo is now split up and transfered into the example folder while each part is self contained and compileable. (All examples use glfw I don't now if this is the best platform but it is at least the simplest. I also removed the apple demo because I don't have an apple system and cannot make sure the new version runs with the old version. Finally a lot of small bugs have been fixed as well as bugs found by clang analyzer and coverity.
2016-04-11 02:34:59 +03:00
static GLFWwindow *win;
int width = 0, height = 0;
struct nk_context *ctx;
2018-01-05 15:09:27 +03:00
struct nk_colorf bg;
Release Version 1.0 This is the first release version of nuklear (previously: zahnrad). As for those who no the old version will notice: a lot has changed. Most obvious should be the two biggest changes. First the name change because I got critique that the name is hard to comprehend and remember (understandable for non-germans) and the second is the transistion from four files (zahnrad.h, zahnrad.c, stb_truetype and stb_rect_pack) to one single header library file nuklear.h. I am not 100% convinced that using a single header library is the right choice here but so far I haven't encountered any problems. Noticable should be as well that nuklear now directly embeds three stb libraries: stb_truetype, stb_rect_pack and stb_textedit. Like in previous versions the first two are optional and the library can be compiled without. stb_textedit on the other hand powers the text edit implementation for single as well as multiline text manipulation. The text edit implementation is still relative new and untested so you can expect some bugs I have not found yet. In the demo department a lot changed as well. All platform demos now don't compile one big demo but instead contain a simple demo and small abstraction layer over the platform. Main benefit is better understandablity improved ease of use. The old demo is now split up and transfered into the example folder while each part is self contained and compileable. (All examples use glfw I don't now if this is the best platform but it is at least the simplest. I also removed the apple demo because I don't have an apple system and cannot make sure the new version runs with the old version. Finally a lot of small bugs have been fixed as well as bugs found by clang analyzer and coverity.
2016-04-11 02:34:59 +03:00
/* GLFW */
glfwSetErrorCallback(error_callback);
if (!glfwInit()) {
fprintf(stdout, "[GFLW] failed to init!\n");
exit(1);
}
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
#ifdef __APPLE__
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
#endif
win = glfwCreateWindow(WINDOW_WIDTH, WINDOW_HEIGHT, "Demo", NULL, NULL);
glfwMakeContextCurrent(win);
glfwGetWindowSize(win, &width, &height);
Release Version 1.0 This is the first release version of nuklear (previously: zahnrad). As for those who no the old version will notice: a lot has changed. Most obvious should be the two biggest changes. First the name change because I got critique that the name is hard to comprehend and remember (understandable for non-germans) and the second is the transistion from four files (zahnrad.h, zahnrad.c, stb_truetype and stb_rect_pack) to one single header library file nuklear.h. I am not 100% convinced that using a single header library is the right choice here but so far I haven't encountered any problems. Noticable should be as well that nuklear now directly embeds three stb libraries: stb_truetype, stb_rect_pack and stb_textedit. Like in previous versions the first two are optional and the library can be compiled without. stb_textedit on the other hand powers the text edit implementation for single as well as multiline text manipulation. The text edit implementation is still relative new and untested so you can expect some bugs I have not found yet. In the demo department a lot changed as well. All platform demos now don't compile one big demo but instead contain a simple demo and small abstraction layer over the platform. Main benefit is better understandablity improved ease of use. The old demo is now split up and transfered into the example folder while each part is self contained and compileable. (All examples use glfw I don't now if this is the best platform but it is at least the simplest. I also removed the apple demo because I don't have an apple system and cannot make sure the new version runs with the old version. Finally a lot of small bugs have been fixed as well as bugs found by clang analyzer and coverity.
2016-04-11 02:34:59 +03:00
/* OpenGL */
glViewport(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT);
glewExperimental = 1;
if (glewInit() != GLEW_OK) {
fprintf(stderr, "Failed to setup GLEW\n");
exit(1);
}
2020-04-30 16:17:24 +03:00
ctx = nk_glfw3_init(&glfw, win, NK_GLFW3_INSTALL_CALLBACKS);
Release Version 1.0 This is the first release version of nuklear (previously: zahnrad). As for those who no the old version will notice: a lot has changed. Most obvious should be the two biggest changes. First the name change because I got critique that the name is hard to comprehend and remember (understandable for non-germans) and the second is the transistion from four files (zahnrad.h, zahnrad.c, stb_truetype and stb_rect_pack) to one single header library file nuklear.h. I am not 100% convinced that using a single header library is the right choice here but so far I haven't encountered any problems. Noticable should be as well that nuklear now directly embeds three stb libraries: stb_truetype, stb_rect_pack and stb_textedit. Like in previous versions the first two are optional and the library can be compiled without. stb_textedit on the other hand powers the text edit implementation for single as well as multiline text manipulation. The text edit implementation is still relative new and untested so you can expect some bugs I have not found yet. In the demo department a lot changed as well. All platform demos now don't compile one big demo but instead contain a simple demo and small abstraction layer over the platform. Main benefit is better understandablity improved ease of use. The old demo is now split up and transfered into the example folder while each part is self contained and compileable. (All examples use glfw I don't now if this is the best platform but it is at least the simplest. I also removed the apple demo because I don't have an apple system and cannot make sure the new version runs with the old version. Finally a lot of small bugs have been fixed as well as bugs found by clang analyzer and coverity.
2016-04-11 02:34:59 +03:00
/* Load Fonts: if none of these are loaded a default font will be used */
/* Load Cursor: if you uncomment cursor loading please hide the cursor */
Release Version 1.0 This is the first release version of nuklear (previously: zahnrad). As for those who no the old version will notice: a lot has changed. Most obvious should be the two biggest changes. First the name change because I got critique that the name is hard to comprehend and remember (understandable for non-germans) and the second is the transistion from four files (zahnrad.h, zahnrad.c, stb_truetype and stb_rect_pack) to one single header library file nuklear.h. I am not 100% convinced that using a single header library is the right choice here but so far I haven't encountered any problems. Noticable should be as well that nuklear now directly embeds three stb libraries: stb_truetype, stb_rect_pack and stb_textedit. Like in previous versions the first two are optional and the library can be compiled without. stb_textedit on the other hand powers the text edit implementation for single as well as multiline text manipulation. The text edit implementation is still relative new and untested so you can expect some bugs I have not found yet. In the demo department a lot changed as well. All platform demos now don't compile one big demo but instead contain a simple demo and small abstraction layer over the platform. Main benefit is better understandablity improved ease of use. The old demo is now split up and transfered into the example folder while each part is self contained and compileable. (All examples use glfw I don't now if this is the best platform but it is at least the simplest. I also removed the apple demo because I don't have an apple system and cannot make sure the new version runs with the old version. Finally a lot of small bugs have been fixed as well as bugs found by clang analyzer and coverity.
2016-04-11 02:34:59 +03:00
{struct nk_font_atlas *atlas;
2020-04-30 16:17:24 +03:00
nk_glfw3_font_stash_begin(&glfw, &atlas);
Release Version 1.0 This is the first release version of nuklear (previously: zahnrad). As for those who no the old version will notice: a lot has changed. Most obvious should be the two biggest changes. First the name change because I got critique that the name is hard to comprehend and remember (understandable for non-germans) and the second is the transistion from four files (zahnrad.h, zahnrad.c, stb_truetype and stb_rect_pack) to one single header library file nuklear.h. I am not 100% convinced that using a single header library is the right choice here but so far I haven't encountered any problems. Noticable should be as well that nuklear now directly embeds three stb libraries: stb_truetype, stb_rect_pack and stb_textedit. Like in previous versions the first two are optional and the library can be compiled without. stb_textedit on the other hand powers the text edit implementation for single as well as multiline text manipulation. The text edit implementation is still relative new and untested so you can expect some bugs I have not found yet. In the demo department a lot changed as well. All platform demos now don't compile one big demo but instead contain a simple demo and small abstraction layer over the platform. Main benefit is better understandablity improved ease of use. The old demo is now split up and transfered into the example folder while each part is self contained and compileable. (All examples use glfw I don't now if this is the best platform but it is at least the simplest. I also removed the apple demo because I don't have an apple system and cannot make sure the new version runs with the old version. Finally a lot of small bugs have been fixed as well as bugs found by clang analyzer and coverity.
2016-04-11 02:34:59 +03:00
/*struct nk_font *droid = nk_font_atlas_add_from_file(atlas, "../../../extra_font/DroidSans.ttf", 14, 0);*/
/*struct nk_font *roboto = nk_font_atlas_add_from_file(atlas, "../../../extra_font/Roboto-Regular.ttf", 14, 0);*/
Release Version 1.0 This is the first release version of nuklear (previously: zahnrad). As for those who no the old version will notice: a lot has changed. Most obvious should be the two biggest changes. First the name change because I got critique that the name is hard to comprehend and remember (understandable for non-germans) and the second is the transistion from four files (zahnrad.h, zahnrad.c, stb_truetype and stb_rect_pack) to one single header library file nuklear.h. I am not 100% convinced that using a single header library is the right choice here but so far I haven't encountered any problems. Noticable should be as well that nuklear now directly embeds three stb libraries: stb_truetype, stb_rect_pack and stb_textedit. Like in previous versions the first two are optional and the library can be compiled without. stb_textedit on the other hand powers the text edit implementation for single as well as multiline text manipulation. The text edit implementation is still relative new and untested so you can expect some bugs I have not found yet. In the demo department a lot changed as well. All platform demos now don't compile one big demo but instead contain a simple demo and small abstraction layer over the platform. Main benefit is better understandablity improved ease of use. The old demo is now split up and transfered into the example folder while each part is self contained and compileable. (All examples use glfw I don't now if this is the best platform but it is at least the simplest. I also removed the apple demo because I don't have an apple system and cannot make sure the new version runs with the old version. Finally a lot of small bugs have been fixed as well as bugs found by clang analyzer and coverity.
2016-04-11 02:34:59 +03:00
/*struct nk_font *future = nk_font_atlas_add_from_file(atlas, "../../../extra_font/kenvector_future_thin.ttf", 13, 0);*/
/*struct nk_font *clean = nk_font_atlas_add_from_file(atlas, "../../../extra_font/ProggyClean.ttf", 12, 0);*/
/*struct nk_font *tiny = nk_font_atlas_add_from_file(atlas, "../../../extra_font/ProggyTiny.ttf", 10, 0);*/
/*struct nk_font *cousine = nk_font_atlas_add_from_file(atlas, "../../../extra_font/Cousine-Regular.ttf", 13, 0);*/
2020-04-30 16:17:24 +03:00
nk_glfw3_font_stash_end(&glfw);
/*nk_style_load_all_cursors(ctx, atlas->cursors);*/
/*nk_style_set_font(ctx, &droid->handle);*/}
Release Version 1.0 This is the first release version of nuklear (previously: zahnrad). As for those who no the old version will notice: a lot has changed. Most obvious should be the two biggest changes. First the name change because I got critique that the name is hard to comprehend and remember (understandable for non-germans) and the second is the transistion from four files (zahnrad.h, zahnrad.c, stb_truetype and stb_rect_pack) to one single header library file nuklear.h. I am not 100% convinced that using a single header library is the right choice here but so far I haven't encountered any problems. Noticable should be as well that nuklear now directly embeds three stb libraries: stb_truetype, stb_rect_pack and stb_textedit. Like in previous versions the first two are optional and the library can be compiled without. stb_textedit on the other hand powers the text edit implementation for single as well as multiline text manipulation. The text edit implementation is still relative new and untested so you can expect some bugs I have not found yet. In the demo department a lot changed as well. All platform demos now don't compile one big demo but instead contain a simple demo and small abstraction layer over the platform. Main benefit is better understandablity improved ease of use. The old demo is now split up and transfered into the example folder while each part is self contained and compileable. (All examples use glfw I don't now if this is the best platform but it is at least the simplest. I also removed the apple demo because I don't have an apple system and cannot make sure the new version runs with the old version. Finally a lot of small bugs have been fixed as well as bugs found by clang analyzer and coverity.
2016-04-11 02:34:59 +03:00
2018-01-05 15:09:27 +03:00
bg.r = 0.10f, bg.g = 0.18f, bg.b = 0.24f, bg.a = 1.0f;
Release Version 1.0 This is the first release version of nuklear (previously: zahnrad). As for those who no the old version will notice: a lot has changed. Most obvious should be the two biggest changes. First the name change because I got critique that the name is hard to comprehend and remember (understandable for non-germans) and the second is the transistion from four files (zahnrad.h, zahnrad.c, stb_truetype and stb_rect_pack) to one single header library file nuklear.h. I am not 100% convinced that using a single header library is the right choice here but so far I haven't encountered any problems. Noticable should be as well that nuklear now directly embeds three stb libraries: stb_truetype, stb_rect_pack and stb_textedit. Like in previous versions the first two are optional and the library can be compiled without. stb_textedit on the other hand powers the text edit implementation for single as well as multiline text manipulation. The text edit implementation is still relative new and untested so you can expect some bugs I have not found yet. In the demo department a lot changed as well. All platform demos now don't compile one big demo but instead contain a simple demo and small abstraction layer over the platform. Main benefit is better understandablity improved ease of use. The old demo is now split up and transfered into the example folder while each part is self contained and compileable. (All examples use glfw I don't now if this is the best platform but it is at least the simplest. I also removed the apple demo because I don't have an apple system and cannot make sure the new version runs with the old version. Finally a lot of small bugs have been fixed as well as bugs found by clang analyzer and coverity.
2016-04-11 02:34:59 +03:00
while (!glfwWindowShouldClose(win))
{
/* Input */
glfwPollEvents();
2020-04-30 16:17:24 +03:00
nk_glfw3_new_frame(&glfw);
Release Version 1.0 This is the first release version of nuklear (previously: zahnrad). As for those who no the old version will notice: a lot has changed. Most obvious should be the two biggest changes. First the name change because I got critique that the name is hard to comprehend and remember (understandable for non-germans) and the second is the transistion from four files (zahnrad.h, zahnrad.c, stb_truetype and stb_rect_pack) to one single header library file nuklear.h. I am not 100% convinced that using a single header library is the right choice here but so far I haven't encountered any problems. Noticable should be as well that nuklear now directly embeds three stb libraries: stb_truetype, stb_rect_pack and stb_textedit. Like in previous versions the first two are optional and the library can be compiled without. stb_textedit on the other hand powers the text edit implementation for single as well as multiline text manipulation. The text edit implementation is still relative new and untested so you can expect some bugs I have not found yet. In the demo department a lot changed as well. All platform demos now don't compile one big demo but instead contain a simple demo and small abstraction layer over the platform. Main benefit is better understandablity improved ease of use. The old demo is now split up and transfered into the example folder while each part is self contained and compileable. (All examples use glfw I don't now if this is the best platform but it is at least the simplest. I also removed the apple demo because I don't have an apple system and cannot make sure the new version runs with the old version. Finally a lot of small bugs have been fixed as well as bugs found by clang analyzer and coverity.
2016-04-11 02:34:59 +03:00
/* GUI */
if (nk_begin(ctx, "Demo", nk_rect(50, 50, 230, 250),
Release Version 1.0 This is the first release version of nuklear (previously: zahnrad). As for those who no the old version will notice: a lot has changed. Most obvious should be the two biggest changes. First the name change because I got critique that the name is hard to comprehend and remember (understandable for non-germans) and the second is the transistion from four files (zahnrad.h, zahnrad.c, stb_truetype and stb_rect_pack) to one single header library file nuklear.h. I am not 100% convinced that using a single header library is the right choice here but so far I haven't encountered any problems. Noticable should be as well that nuklear now directly embeds three stb libraries: stb_truetype, stb_rect_pack and stb_textedit. Like in previous versions the first two are optional and the library can be compiled without. stb_textedit on the other hand powers the text edit implementation for single as well as multiline text manipulation. The text edit implementation is still relative new and untested so you can expect some bugs I have not found yet. In the demo department a lot changed as well. All platform demos now don't compile one big demo but instead contain a simple demo and small abstraction layer over the platform. Main benefit is better understandablity improved ease of use. The old demo is now split up and transfered into the example folder while each part is self contained and compileable. (All examples use glfw I don't now if this is the best platform but it is at least the simplest. I also removed the apple demo because I don't have an apple system and cannot make sure the new version runs with the old version. Finally a lot of small bugs have been fixed as well as bugs found by clang analyzer and coverity.
2016-04-11 02:34:59 +03:00
NK_WINDOW_BORDER|NK_WINDOW_MOVABLE|NK_WINDOW_SCALABLE|
NK_WINDOW_MINIMIZABLE|NK_WINDOW_TITLE))
{
enum {EASY, HARD};
static int op = EASY;
static int property = 20;
nk_layout_row_static(ctx, 30, 80, 1);
if (nk_button_label(ctx, "button"))
Release Version 1.0 This is the first release version of nuklear (previously: zahnrad). As for those who no the old version will notice: a lot has changed. Most obvious should be the two biggest changes. First the name change because I got critique that the name is hard to comprehend and remember (understandable for non-germans) and the second is the transistion from four files (zahnrad.h, zahnrad.c, stb_truetype and stb_rect_pack) to one single header library file nuklear.h. I am not 100% convinced that using a single header library is the right choice here but so far I haven't encountered any problems. Noticable should be as well that nuklear now directly embeds three stb libraries: stb_truetype, stb_rect_pack and stb_textedit. Like in previous versions the first two are optional and the library can be compiled without. stb_textedit on the other hand powers the text edit implementation for single as well as multiline text manipulation. The text edit implementation is still relative new and untested so you can expect some bugs I have not found yet. In the demo department a lot changed as well. All platform demos now don't compile one big demo but instead contain a simple demo and small abstraction layer over the platform. Main benefit is better understandablity improved ease of use. The old demo is now split up and transfered into the example folder while each part is self contained and compileable. (All examples use glfw I don't now if this is the best platform but it is at least the simplest. I also removed the apple demo because I don't have an apple system and cannot make sure the new version runs with the old version. Finally a lot of small bugs have been fixed as well as bugs found by clang analyzer and coverity.
2016-04-11 02:34:59 +03:00
fprintf(stdout, "button pressed\n");
Release Version 1.0 This is the first release version of nuklear (previously: zahnrad). As for those who no the old version will notice: a lot has changed. Most obvious should be the two biggest changes. First the name change because I got critique that the name is hard to comprehend and remember (understandable for non-germans) and the second is the transistion from four files (zahnrad.h, zahnrad.c, stb_truetype and stb_rect_pack) to one single header library file nuklear.h. I am not 100% convinced that using a single header library is the right choice here but so far I haven't encountered any problems. Noticable should be as well that nuklear now directly embeds three stb libraries: stb_truetype, stb_rect_pack and stb_textedit. Like in previous versions the first two are optional and the library can be compiled without. stb_textedit on the other hand powers the text edit implementation for single as well as multiline text manipulation. The text edit implementation is still relative new and untested so you can expect some bugs I have not found yet. In the demo department a lot changed as well. All platform demos now don't compile one big demo but instead contain a simple demo and small abstraction layer over the platform. Main benefit is better understandablity improved ease of use. The old demo is now split up and transfered into the example folder while each part is self contained and compileable. (All examples use glfw I don't now if this is the best platform but it is at least the simplest. I also removed the apple demo because I don't have an apple system and cannot make sure the new version runs with the old version. Finally a lot of small bugs have been fixed as well as bugs found by clang analyzer and coverity.
2016-04-11 02:34:59 +03:00
nk_layout_row_dynamic(ctx, 30, 2);
if (nk_option_label(ctx, "easy", op == EASY)) op = EASY;
if (nk_option_label(ctx, "hard", op == HARD)) op = HARD;
nk_layout_row_dynamic(ctx, 25, 1);
Release Version 1.0 This is the first release version of nuklear (previously: zahnrad). As for those who no the old version will notice: a lot has changed. Most obvious should be the two biggest changes. First the name change because I got critique that the name is hard to comprehend and remember (understandable for non-germans) and the second is the transistion from four files (zahnrad.h, zahnrad.c, stb_truetype and stb_rect_pack) to one single header library file nuklear.h. I am not 100% convinced that using a single header library is the right choice here but so far I haven't encountered any problems. Noticable should be as well that nuklear now directly embeds three stb libraries: stb_truetype, stb_rect_pack and stb_textedit. Like in previous versions the first two are optional and the library can be compiled without. stb_textedit on the other hand powers the text edit implementation for single as well as multiline text manipulation. The text edit implementation is still relative new and untested so you can expect some bugs I have not found yet. In the demo department a lot changed as well. All platform demos now don't compile one big demo but instead contain a simple demo and small abstraction layer over the platform. Main benefit is better understandablity improved ease of use. The old demo is now split up and transfered into the example folder while each part is self contained and compileable. (All examples use glfw I don't now if this is the best platform but it is at least the simplest. I also removed the apple demo because I don't have an apple system and cannot make sure the new version runs with the old version. Finally a lot of small bugs have been fixed as well as bugs found by clang analyzer and coverity.
2016-04-11 02:34:59 +03:00
nk_property_int(ctx, "Compression:", 0, &property, 100, 10, 1);
nk_layout_row_dynamic(ctx, 20, 1);
nk_label(ctx, "background:", NK_TEXT_LEFT);
nk_layout_row_dynamic(ctx, 25, 1);
2018-01-05 15:09:27 +03:00
if (nk_combo_begin_color(ctx, nk_rgb_cf(bg), nk_vec2(nk_widget_width(ctx),400))) {
Release Version 1.0 This is the first release version of nuklear (previously: zahnrad). As for those who no the old version will notice: a lot has changed. Most obvious should be the two biggest changes. First the name change because I got critique that the name is hard to comprehend and remember (understandable for non-germans) and the second is the transistion from four files (zahnrad.h, zahnrad.c, stb_truetype and stb_rect_pack) to one single header library file nuklear.h. I am not 100% convinced that using a single header library is the right choice here but so far I haven't encountered any problems. Noticable should be as well that nuklear now directly embeds three stb libraries: stb_truetype, stb_rect_pack and stb_textedit. Like in previous versions the first two are optional and the library can be compiled without. stb_textedit on the other hand powers the text edit implementation for single as well as multiline text manipulation. The text edit implementation is still relative new and untested so you can expect some bugs I have not found yet. In the demo department a lot changed as well. All platform demos now don't compile one big demo but instead contain a simple demo and small abstraction layer over the platform. Main benefit is better understandablity improved ease of use. The old demo is now split up and transfered into the example folder while each part is self contained and compileable. (All examples use glfw I don't now if this is the best platform but it is at least the simplest. I also removed the apple demo because I don't have an apple system and cannot make sure the new version runs with the old version. Finally a lot of small bugs have been fixed as well as bugs found by clang analyzer and coverity.
2016-04-11 02:34:59 +03:00
nk_layout_row_dynamic(ctx, 120, 1);
2018-01-05 15:09:27 +03:00
bg = nk_color_picker(ctx, bg, NK_RGBA);
Release Version 1.0 This is the first release version of nuklear (previously: zahnrad). As for those who no the old version will notice: a lot has changed. Most obvious should be the two biggest changes. First the name change because I got critique that the name is hard to comprehend and remember (understandable for non-germans) and the second is the transistion from four files (zahnrad.h, zahnrad.c, stb_truetype and stb_rect_pack) to one single header library file nuklear.h. I am not 100% convinced that using a single header library is the right choice here but so far I haven't encountered any problems. Noticable should be as well that nuklear now directly embeds three stb libraries: stb_truetype, stb_rect_pack and stb_textedit. Like in previous versions the first two are optional and the library can be compiled without. stb_textedit on the other hand powers the text edit implementation for single as well as multiline text manipulation. The text edit implementation is still relative new and untested so you can expect some bugs I have not found yet. In the demo department a lot changed as well. All platform demos now don't compile one big demo but instead contain a simple demo and small abstraction layer over the platform. Main benefit is better understandablity improved ease of use. The old demo is now split up and transfered into the example folder while each part is self contained and compileable. (All examples use glfw I don't now if this is the best platform but it is at least the simplest. I also removed the apple demo because I don't have an apple system and cannot make sure the new version runs with the old version. Finally a lot of small bugs have been fixed as well as bugs found by clang analyzer and coverity.
2016-04-11 02:34:59 +03:00
nk_layout_row_dynamic(ctx, 25, 1);
2018-01-05 15:09:27 +03:00
bg.r = nk_propertyf(ctx, "#R:", 0, bg.r, 1.0f, 0.01f,0.005f);
bg.g = nk_propertyf(ctx, "#G:", 0, bg.g, 1.0f, 0.01f,0.005f);
bg.b = nk_propertyf(ctx, "#B:", 0, bg.b, 1.0f, 0.01f,0.005f);
bg.a = nk_propertyf(ctx, "#A:", 0, bg.a, 1.0f, 0.01f,0.005f);
Release Version 1.0 This is the first release version of nuklear (previously: zahnrad). As for those who no the old version will notice: a lot has changed. Most obvious should be the two biggest changes. First the name change because I got critique that the name is hard to comprehend and remember (understandable for non-germans) and the second is the transistion from four files (zahnrad.h, zahnrad.c, stb_truetype and stb_rect_pack) to one single header library file nuklear.h. I am not 100% convinced that using a single header library is the right choice here but so far I haven't encountered any problems. Noticable should be as well that nuklear now directly embeds three stb libraries: stb_truetype, stb_rect_pack and stb_textedit. Like in previous versions the first two are optional and the library can be compiled without. stb_textedit on the other hand powers the text edit implementation for single as well as multiline text manipulation. The text edit implementation is still relative new and untested so you can expect some bugs I have not found yet. In the demo department a lot changed as well. All platform demos now don't compile one big demo but instead contain a simple demo and small abstraction layer over the platform. Main benefit is better understandablity improved ease of use. The old demo is now split up and transfered into the example folder while each part is self contained and compileable. (All examples use glfw I don't now if this is the best platform but it is at least the simplest. I also removed the apple demo because I don't have an apple system and cannot make sure the new version runs with the old version. Finally a lot of small bugs have been fixed as well as bugs found by clang analyzer and coverity.
2016-04-11 02:34:59 +03:00
nk_combo_end(ctx);
}
Release Version 1.0 This is the first release version of nuklear (previously: zahnrad). As for those who no the old version will notice: a lot has changed. Most obvious should be the two biggest changes. First the name change because I got critique that the name is hard to comprehend and remember (understandable for non-germans) and the second is the transistion from four files (zahnrad.h, zahnrad.c, stb_truetype and stb_rect_pack) to one single header library file nuklear.h. I am not 100% convinced that using a single header library is the right choice here but so far I haven't encountered any problems. Noticable should be as well that nuklear now directly embeds three stb libraries: stb_truetype, stb_rect_pack and stb_textedit. Like in previous versions the first two are optional and the library can be compiled without. stb_textedit on the other hand powers the text edit implementation for single as well as multiline text manipulation. The text edit implementation is still relative new and untested so you can expect some bugs I have not found yet. In the demo department a lot changed as well. All platform demos now don't compile one big demo but instead contain a simple demo and small abstraction layer over the platform. Main benefit is better understandablity improved ease of use. The old demo is now split up and transfered into the example folder while each part is self contained and compileable. (All examples use glfw I don't now if this is the best platform but it is at least the simplest. I also removed the apple demo because I don't have an apple system and cannot make sure the new version runs with the old version. Finally a lot of small bugs have been fixed as well as bugs found by clang analyzer and coverity.
2016-04-11 02:34:59 +03:00
}
nk_end(ctx);
Release Version 1.0 This is the first release version of nuklear (previously: zahnrad). As for those who no the old version will notice: a lot has changed. Most obvious should be the two biggest changes. First the name change because I got critique that the name is hard to comprehend and remember (understandable for non-germans) and the second is the transistion from four files (zahnrad.h, zahnrad.c, stb_truetype and stb_rect_pack) to one single header library file nuklear.h. I am not 100% convinced that using a single header library is the right choice here but so far I haven't encountered any problems. Noticable should be as well that nuklear now directly embeds three stb libraries: stb_truetype, stb_rect_pack and stb_textedit. Like in previous versions the first two are optional and the library can be compiled without. stb_textedit on the other hand powers the text edit implementation for single as well as multiline text manipulation. The text edit implementation is still relative new and untested so you can expect some bugs I have not found yet. In the demo department a lot changed as well. All platform demos now don't compile one big demo but instead contain a simple demo and small abstraction layer over the platform. Main benefit is better understandablity improved ease of use. The old demo is now split up and transfered into the example folder while each part is self contained and compileable. (All examples use glfw I don't now if this is the best platform but it is at least the simplest. I also removed the apple demo because I don't have an apple system and cannot make sure the new version runs with the old version. Finally a lot of small bugs have been fixed as well as bugs found by clang analyzer and coverity.
2016-04-11 02:34:59 +03:00
/* -------------- EXAMPLES ---------------- */
#ifdef INCLUDE_CALCULATOR
calculator(ctx);
#endif
#ifdef INCLUDE_CANVAS
canvas(ctx);
#endif
#ifdef INCLUDE_OVERVIEW
overview(ctx);
#endif
#ifdef INCLUDE_NODE_EDITOR
node_editor(ctx);
#endif
/* ----------------------------------------- */
Release Version 1.0 This is the first release version of nuklear (previously: zahnrad). As for those who no the old version will notice: a lot has changed. Most obvious should be the two biggest changes. First the name change because I got critique that the name is hard to comprehend and remember (understandable for non-germans) and the second is the transistion from four files (zahnrad.h, zahnrad.c, stb_truetype and stb_rect_pack) to one single header library file nuklear.h. I am not 100% convinced that using a single header library is the right choice here but so far I haven't encountered any problems. Noticable should be as well that nuklear now directly embeds three stb libraries: stb_truetype, stb_rect_pack and stb_textedit. Like in previous versions the first two are optional and the library can be compiled without. stb_textedit on the other hand powers the text edit implementation for single as well as multiline text manipulation. The text edit implementation is still relative new and untested so you can expect some bugs I have not found yet. In the demo department a lot changed as well. All platform demos now don't compile one big demo but instead contain a simple demo and small abstraction layer over the platform. Main benefit is better understandablity improved ease of use. The old demo is now split up and transfered into the example folder while each part is self contained and compileable. (All examples use glfw I don't now if this is the best platform but it is at least the simplest. I also removed the apple demo because I don't have an apple system and cannot make sure the new version runs with the old version. Finally a lot of small bugs have been fixed as well as bugs found by clang analyzer and coverity.
2016-04-11 02:34:59 +03:00
/* Draw */
glfwGetWindowSize(win, &width, &height);
glViewport(0, 0, width, height);
glClear(GL_COLOR_BUFFER_BIT);
2018-01-05 15:09:27 +03:00
glClearColor(bg.r, bg.g, bg.b, bg.a);
2016-04-30 15:49:28 +03:00
/* IMPORTANT: `nk_glfw_render` modifies some global OpenGL state
* with blending, scissor, face culling, depth test and viewport and
* defaults everything back into a default state.
* Make sure to either a.) save and restore or b.) reset your own state after
* rendering the UI. */
2020-04-30 16:17:24 +03:00
nk_glfw3_render(&glfw, NK_ANTI_ALIASING_ON, MAX_VERTEX_BUFFER, MAX_ELEMENT_BUFFER);
2018-01-05 15:09:27 +03:00
glfwSwapBuffers(win);
Release Version 1.0 This is the first release version of nuklear (previously: zahnrad). As for those who no the old version will notice: a lot has changed. Most obvious should be the two biggest changes. First the name change because I got critique that the name is hard to comprehend and remember (understandable for non-germans) and the second is the transistion from four files (zahnrad.h, zahnrad.c, stb_truetype and stb_rect_pack) to one single header library file nuklear.h. I am not 100% convinced that using a single header library is the right choice here but so far I haven't encountered any problems. Noticable should be as well that nuklear now directly embeds three stb libraries: stb_truetype, stb_rect_pack and stb_textedit. Like in previous versions the first two are optional and the library can be compiled without. stb_textedit on the other hand powers the text edit implementation for single as well as multiline text manipulation. The text edit implementation is still relative new and untested so you can expect some bugs I have not found yet. In the demo department a lot changed as well. All platform demos now don't compile one big demo but instead contain a simple demo and small abstraction layer over the platform. Main benefit is better understandablity improved ease of use. The old demo is now split up and transfered into the example folder while each part is self contained and compileable. (All examples use glfw I don't now if this is the best platform but it is at least the simplest. I also removed the apple demo because I don't have an apple system and cannot make sure the new version runs with the old version. Finally a lot of small bugs have been fixed as well as bugs found by clang analyzer and coverity.
2016-04-11 02:34:59 +03:00
}
2020-04-30 16:17:24 +03:00
nk_glfw3_shutdown(&glfw);
Release Version 1.0 This is the first release version of nuklear (previously: zahnrad). As for those who no the old version will notice: a lot has changed. Most obvious should be the two biggest changes. First the name change because I got critique that the name is hard to comprehend and remember (understandable for non-germans) and the second is the transistion from four files (zahnrad.h, zahnrad.c, stb_truetype and stb_rect_pack) to one single header library file nuklear.h. I am not 100% convinced that using a single header library is the right choice here but so far I haven't encountered any problems. Noticable should be as well that nuklear now directly embeds three stb libraries: stb_truetype, stb_rect_pack and stb_textedit. Like in previous versions the first two are optional and the library can be compiled without. stb_textedit on the other hand powers the text edit implementation for single as well as multiline text manipulation. The text edit implementation is still relative new and untested so you can expect some bugs I have not found yet. In the demo department a lot changed as well. All platform demos now don't compile one big demo but instead contain a simple demo and small abstraction layer over the platform. Main benefit is better understandablity improved ease of use. The old demo is now split up and transfered into the example folder while each part is self contained and compileable. (All examples use glfw I don't now if this is the best platform but it is at least the simplest. I also removed the apple demo because I don't have an apple system and cannot make sure the new version runs with the old version. Finally a lot of small bugs have been fixed as well as bugs found by clang analyzer and coverity.
2016-04-11 02:34:59 +03:00
glfwTerminate();
return 0;
}