parent
ce4672d74b
commit
c3cba58a71
26 changed files with 152 additions and 152 deletions
@ -1 +1 @@ |
|||||||
*.m linguist-language=Objective-C |
*.m linguist-language=Objective-C |
||||||
|
|||||||
@ -1,3 +1,3 @@ |
|||||||
|
|
||||||
GLFW_ICON ICON "glfw.ico" |
GLFW_ICON ICON "glfw.ico" |
||||||
|
|
||||||
|
|||||||
@ -1,106 +1,106 @@ |
|||||||
//========================================================================
|
//========================================================================
|
||||||
// Window opacity test program
|
// Window opacity test program
|
||||||
// Copyright (c) Camilla Löwy <elmindreda@glfw.org>
|
// Copyright (c) Camilla Löwy <elmindreda@glfw.org>
|
||||||
//
|
//
|
||||||
// This software is provided 'as-is', without any express or implied
|
// This software is provided 'as-is', without any express or implied
|
||||||
// warranty. In no event will the authors be held liable for any damages
|
// warranty. In no event will the authors be held liable for any damages
|
||||||
// arising from the use of this software.
|
// arising from the use of this software.
|
||||||
//
|
//
|
||||||
// Permission is granted to anyone to use this software for any purpose,
|
// Permission is granted to anyone to use this software for any purpose,
|
||||||
// including commercial applications, and to alter it and redistribute it
|
// including commercial applications, and to alter it and redistribute it
|
||||||
// freely, subject to the following restrictions:
|
// freely, subject to the following restrictions:
|
||||||
//
|
//
|
||||||
// 1. The origin of this software must not be misrepresented; you must not
|
// 1. The origin of this software must not be misrepresented; you must not
|
||||||
// claim that you wrote the original software. If you use this software
|
// claim that you wrote the original software. If you use this software
|
||||||
// in a product, an acknowledgment in the product documentation would
|
// in a product, an acknowledgment in the product documentation would
|
||||||
// be appreciated but is not required.
|
// be appreciated but is not required.
|
||||||
//
|
//
|
||||||
// 2. Altered source versions must be plainly marked as such, and must not
|
// 2. Altered source versions must be plainly marked as such, and must not
|
||||||
// be misrepresented as being the original software.
|
// be misrepresented as being the original software.
|
||||||
//
|
//
|
||||||
// 3. This notice may not be removed or altered from any source
|
// 3. This notice may not be removed or altered from any source
|
||||||
// distribution.
|
// distribution.
|
||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
#include <glad/glad.h> |
#include <glad/glad.h> |
||||||
#include <GLFW/glfw3.h> |
#include <GLFW/glfw3.h> |
||||||
|
|
||||||
#define NK_IMPLEMENTATION |
#define NK_IMPLEMENTATION |
||||||
#define NK_INCLUDE_FIXED_TYPES |
#define NK_INCLUDE_FIXED_TYPES |
||||||
#define NK_INCLUDE_FONT_BAKING |
#define NK_INCLUDE_FONT_BAKING |
||||||
#define NK_INCLUDE_DEFAULT_FONT |
#define NK_INCLUDE_DEFAULT_FONT |
||||||
#define NK_INCLUDE_DEFAULT_ALLOCATOR |
#define NK_INCLUDE_DEFAULT_ALLOCATOR |
||||||
#define NK_INCLUDE_VERTEX_BUFFER_OUTPUT |
#define NK_INCLUDE_VERTEX_BUFFER_OUTPUT |
||||||
#define NK_INCLUDE_STANDARD_VARARGS |
#define NK_INCLUDE_STANDARD_VARARGS |
||||||
#include <nuklear.h> |
#include <nuklear.h> |
||||||
|
|
||||||
#define NK_GLFW_GL2_IMPLEMENTATION |
#define NK_GLFW_GL2_IMPLEMENTATION |
||||||
#include <nuklear_glfw_gl2.h> |
#include <nuklear_glfw_gl2.h> |
||||||
|
|
||||||
#include <stdio.h> |
#include <stdio.h> |
||||||
#include <stdlib.h> |
#include <stdlib.h> |
||||||
|
|
||||||
static void error_callback(int error, const char* description) |
static void error_callback(int error, const char* description) |
||||||
{ |
{ |
||||||
fprintf(stderr, "Error: %s\n", description); |
fprintf(stderr, "Error: %s\n", description); |
||||||
} |
} |
||||||
|
|
||||||
int main(int argc, char** argv) |
int main(int argc, char** argv) |
||||||
{ |
{ |
||||||
GLFWmonitor* monitor = NULL; |
GLFWmonitor* monitor = NULL; |
||||||
GLFWwindow* window; |
GLFWwindow* window; |
||||||
struct nk_context* nk; |
struct nk_context* nk; |
||||||
struct nk_font_atlas* atlas; |
struct nk_font_atlas* atlas; |
||||||
|
|
||||||
glfwSetErrorCallback(error_callback); |
glfwSetErrorCallback(error_callback); |
||||||
|
|
||||||
if (!glfwInit()) |
if (!glfwInit()) |
||||||
exit(EXIT_FAILURE); |
exit(EXIT_FAILURE); |
||||||
|
|
||||||
window = glfwCreateWindow(400, 400, "Opacity", NULL, NULL); |
window = glfwCreateWindow(400, 400, "Opacity", NULL, NULL); |
||||||
if (!window) |
if (!window) |
||||||
{ |
{ |
||||||
glfwTerminate(); |
glfwTerminate(); |
||||||
exit(EXIT_FAILURE); |
exit(EXIT_FAILURE); |
||||||
} |
} |
||||||
|
|
||||||
glfwMakeContextCurrent(window); |
glfwMakeContextCurrent(window); |
||||||
gladLoadGLLoader((GLADloadproc) glfwGetProcAddress); |
gladLoadGLLoader((GLADloadproc) glfwGetProcAddress); |
||||||
glfwSwapInterval(1); |
glfwSwapInterval(1); |
||||||
|
|
||||||
nk = nk_glfw3_init(window, NK_GLFW3_INSTALL_CALLBACKS); |
nk = nk_glfw3_init(window, NK_GLFW3_INSTALL_CALLBACKS); |
||||||
nk_glfw3_font_stash_begin(&atlas); |
nk_glfw3_font_stash_begin(&atlas); |
||||||
nk_glfw3_font_stash_end(); |
nk_glfw3_font_stash_end(); |
||||||
|
|
||||||
while (!glfwWindowShouldClose(window)) |
while (!glfwWindowShouldClose(window)) |
||||||
{ |
{ |
||||||
int width, height; |
int width, height; |
||||||
struct nk_rect area; |
struct nk_rect area; |
||||||
|
|
||||||
glfwGetWindowSize(window, &width, &height); |
glfwGetWindowSize(window, &width, &height); |
||||||
area = nk_rect(0.f, 0.f, (float) width, (float) height); |
area = nk_rect(0.f, 0.f, (float) width, (float) height); |
||||||
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT); |
glClear(GL_COLOR_BUFFER_BIT); |
||||||
nk_glfw3_new_frame(); |
nk_glfw3_new_frame(); |
||||||
if (nk_begin(nk, "", area, 0)) |
if (nk_begin(nk, "", area, 0)) |
||||||
{ |
{ |
||||||
float opacity = glfwGetWindowOpacity(window); |
float opacity = glfwGetWindowOpacity(window); |
||||||
nk_layout_row_dynamic(nk, 30, 2); |
nk_layout_row_dynamic(nk, 30, 2); |
||||||
if (nk_slider_float(nk, 0.f, &opacity, 1.f, 0.001f)) |
if (nk_slider_float(nk, 0.f, &opacity, 1.f, 0.001f)) |
||||||
glfwSetWindowOpacity(window, opacity); |
glfwSetWindowOpacity(window, opacity); |
||||||
nk_labelf(nk, NK_TEXT_LEFT, "%0.3f", opacity); |
nk_labelf(nk, NK_TEXT_LEFT, "%0.3f", opacity); |
||||||
} |
} |
||||||
|
|
||||||
nk_end(nk); |
nk_end(nk); |
||||||
nk_glfw3_render(NK_ANTI_ALIASING_ON); |
nk_glfw3_render(NK_ANTI_ALIASING_ON); |
||||||
|
|
||||||
glfwSwapBuffers(window); |
glfwSwapBuffers(window); |
||||||
glfwWaitEventsTimeout(1.0); |
glfwWaitEventsTimeout(1.0); |
||||||
} |
} |
||||||
|
|
||||||
nk_glfw3_shutdown(); |
nk_glfw3_shutdown(); |
||||||
glfwTerminate(); |
glfwTerminate(); |
||||||
exit(EXIT_SUCCESS); |
exit(EXIT_SUCCESS); |
||||||
} |
} |
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue