mirror of
https://github.com/glfw/glfw.git
synced 2026-09-21 16:44:11 +00:00
Merge branch 'master' into cursor-enter-leave
This commit is contained in:
+24
-7
@@ -36,6 +36,9 @@ target_link_libraries(joysticks ${STATIC_DEPS})
|
||||
add_executable(listmodes listmodes.c)
|
||||
target_link_libraries(listmodes ${STATIC_DEPS})
|
||||
|
||||
add_executable(modes modes.c getopt.c)
|
||||
target_link_libraries(modes ${STATIC_DEPS})
|
||||
|
||||
add_executable(peter peter.c)
|
||||
target_link_libraries(peter ${STATIC_DEPS})
|
||||
|
||||
@@ -44,23 +47,37 @@ target_link_libraries(reopen ${STATIC_DEPS})
|
||||
|
||||
add_executable(accuracy WIN32 MACOSX_BUNDLE accuracy.c)
|
||||
target_link_libraries(accuracy ${STATIC_DEPS})
|
||||
set_target_properties(accuracy PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Accuracy")
|
||||
|
||||
add_executable(sharing WIN32 MACOSX_BUNDLE sharing.c)
|
||||
target_link_libraries(sharing ${STATIC_DEPS})
|
||||
set_target_properties(sharing PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Sharing")
|
||||
|
||||
add_executable(tearing WIN32 MACOSX_BUNDLE tearing.c)
|
||||
target_link_libraries(tearing ${STATIC_DEPS})
|
||||
set_target_properties(tearing PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Tearing")
|
||||
|
||||
add_executable(title WIN32 MACOSX_BUNDLE title.c)
|
||||
target_link_libraries(title ${STATIC_DEPS})
|
||||
set_target_properties(title PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Title")
|
||||
|
||||
add_executable(windows WIN32 MACOSX_BUNDLE windows.c)
|
||||
target_link_libraries(windows ${STATIC_DEPS})
|
||||
set_target_properties(windows PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Windows")
|
||||
|
||||
set(WINDOWS_BINARIES accuracy sharing tearing windows)
|
||||
set(WINDOWS_BINARIES accuracy sharing tearing title windows)
|
||||
set(CONSOLE_BINARIES defaults events fsaa fsfocus gamma glfwinfo iconify
|
||||
joysticks listmodes peter reopen)
|
||||
joysticks listmodes modes peter reopen)
|
||||
|
||||
if(MSVC)
|
||||
# Tell MSVC to use main instead of WinMain for Windows subsystem executables
|
||||
set_target_properties(${WINDOWS_BINARIES} ${CONSOLE_BINARIES} PROPERTIES
|
||||
LINK_FLAGS "/ENTRY:mainCRTStartup")
|
||||
endif(MSVC)
|
||||
if (MSVC)
|
||||
# Tell MSVC to use main instead of WinMain for Windows subsystem executables
|
||||
set_target_properties(${WINDOWS_BINARIES} ${CONSOLE_BINARIES} PROPERTIES
|
||||
LINK_FLAGS "/ENTRY:mainCRTStartup")
|
||||
endif()
|
||||
|
||||
if (APPLE)
|
||||
set_target_properties(${WINDOWS_BINARIES} ${CONSOLE_BINARIES} PROPERTIES
|
||||
MACOSX_BUNDLE_SHORT_VERSION_STRING ${GLFW_VERSION}
|
||||
MACOSX_BUNDLE_LONG_VERSION_STRING ${GLFW_VERSION_FULL})
|
||||
endif()
|
||||
|
||||
|
||||
+14
-11
@@ -40,8 +40,9 @@
|
||||
#include <ctype.h>
|
||||
#include <locale.h>
|
||||
|
||||
static GLboolean keyrepeat = 0;
|
||||
static GLboolean systemkeys = 1;
|
||||
static GLboolean keyrepeat = GL_FALSE;
|
||||
static GLboolean systemkeys = GL_TRUE;
|
||||
static GLboolean closeable = GL_TRUE;
|
||||
static unsigned int counter = 0;
|
||||
|
||||
static const char* get_key_name(int key)
|
||||
@@ -230,7 +231,7 @@ static void window_size_callback(GLFWwindow window, int width, int height)
|
||||
static int window_close_callback(GLFWwindow window)
|
||||
{
|
||||
printf("%08x at %0.3f: Window close\n", counter++, glfwGetTime());
|
||||
return 1;
|
||||
return closeable;
|
||||
}
|
||||
|
||||
static void window_refresh_callback(GLFWwindow window)
|
||||
@@ -306,10 +307,7 @@ static void key_callback(GLFWwindow window, int key, int action)
|
||||
case GLFW_KEY_R:
|
||||
{
|
||||
keyrepeat = !keyrepeat;
|
||||
if (keyrepeat)
|
||||
glfwEnable(window, GLFW_KEY_REPEAT);
|
||||
else
|
||||
glfwDisable(window, GLFW_KEY_REPEAT);
|
||||
glfwSetInputMode(window, GLFW_KEY_REPEAT, keyrepeat);
|
||||
|
||||
printf("(( key repeat %s ))\n", keyrepeat ? "enabled" : "disabled");
|
||||
break;
|
||||
@@ -318,14 +316,19 @@ static void key_callback(GLFWwindow window, int key, int action)
|
||||
case GLFW_KEY_S:
|
||||
{
|
||||
systemkeys = !systemkeys;
|
||||
if (systemkeys)
|
||||
glfwEnable(window, GLFW_SYSTEM_KEYS);
|
||||
else
|
||||
glfwDisable(window, GLFW_SYSTEM_KEYS);
|
||||
glfwSetInputMode(window, GLFW_SYSTEM_KEYS, systemkeys);
|
||||
|
||||
printf("(( system keys %s ))\n", systemkeys ? "enabled" : "disabled");
|
||||
break;
|
||||
}
|
||||
|
||||
case GLFW_KEY_C:
|
||||
{
|
||||
closeable = !closeable;
|
||||
|
||||
printf("(( closing %s ))\n", closeable ? "enabled" : "disabled");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -91,7 +91,7 @@ int main(void)
|
||||
}
|
||||
|
||||
glfwSwapInterval(1);
|
||||
glfwSetCursorMode(window, GLFW_CURSOR_NORMAL);
|
||||
glfwSetInputMode(window, GLFW_CURSOR_MODE, GLFW_CURSOR_NORMAL);
|
||||
|
||||
glfwSetWindowFocusCallback(window_focus_callback);
|
||||
glfwSetKeyCallback(window_key_callback);
|
||||
|
||||
+23
-8
@@ -35,11 +35,20 @@
|
||||
|
||||
#include "getopt.h"
|
||||
|
||||
#define STEP_SIZE 0.1f
|
||||
|
||||
static GLfloat gamma = 1.0f;
|
||||
|
||||
static void usage(void)
|
||||
{
|
||||
printf("Usage: gammatest [-h] [-f]\n");
|
||||
printf("Usage: gamma [-h] [-f]\n");
|
||||
}
|
||||
|
||||
static void set_gamma(float value)
|
||||
{
|
||||
gamma = value;
|
||||
printf("Gamma: %f\n", gamma);
|
||||
glfwSetGamma(gamma);
|
||||
}
|
||||
|
||||
static void key_callback(GLFWwindow window, int key, int action)
|
||||
@@ -50,20 +59,26 @@ static void key_callback(GLFWwindow window, int key, int action)
|
||||
switch (key)
|
||||
{
|
||||
case GLFW_KEY_ESCAPE:
|
||||
{
|
||||
glfwCloseWindow(window);
|
||||
break;
|
||||
}
|
||||
|
||||
case GLFW_KEY_KP_ADD:
|
||||
case GLFW_KEY_Q:
|
||||
gamma += 0.1f;
|
||||
printf("Gamma: %f\n", gamma);
|
||||
glfwSetGamma(gamma);
|
||||
{
|
||||
set_gamma(gamma + STEP_SIZE);
|
||||
break;
|
||||
}
|
||||
|
||||
case GLFW_KEY_KP_SUBTRACT:
|
||||
case GLFW_KEY_W:
|
||||
gamma -= 0.1f;
|
||||
printf("Gamma: %f\n", gamma);
|
||||
glfwSetGamma(gamma);
|
||||
{
|
||||
if (gamma - STEP_SIZE > 0.f)
|
||||
set_gamma(gamma - STEP_SIZE);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,7 +139,7 @@ int main(int argc, char** argv)
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
printf("Gamma: %f\n", gamma);
|
||||
set_gamma(1.f);
|
||||
|
||||
glfwSwapInterval(1);
|
||||
glfwSetKeyCallback(key_callback);
|
||||
|
||||
+2
-2
@@ -51,7 +51,7 @@
|
||||
|
||||
static void usage(void)
|
||||
{
|
||||
printf("Usage: version [-h] [-m MAJOR] [-n MINOR] [-d] [-l] [-f] [-p PROFILE] [-r STRATEGY]\n");
|
||||
printf("Usage: glfwinfo [-h] [-m MAJOR] [-n MINOR] [-d] [-l] [-f] [-p PROFILE] [-r STRATEGY]\n");
|
||||
printf("available profiles: " PROFILE_NAME_CORE " " PROFILE_NAME_COMPAT " " PROFILE_NAME_ES2 "\n");
|
||||
printf("available strategies: " STRATEGY_NAME_NONE " " STRATEGY_NAME_LOSE "\n");
|
||||
}
|
||||
@@ -263,7 +263,7 @@ int main(int argc, char** argv)
|
||||
if (major > 3 || (major == 3 && minor >= 2))
|
||||
{
|
||||
glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &mask);
|
||||
printf("OpenGL profile mask: 0x%08x (%s)\n", mask, get_profile_name(mask));
|
||||
printf("OpenGL profile mask: %s (0x%08x)\n", get_profile_name(mask), mask);
|
||||
|
||||
printf("OpenGL profile parsed by GLFW: %s\n",
|
||||
get_glfw_profile_name(glfwGetWindowParam(window, GLFW_OPENGL_PROFILE)));
|
||||
|
||||
@@ -62,6 +62,8 @@ static void key_callback(GLFWwindow window, int key, int action)
|
||||
|
||||
static void size_callback(GLFWwindow window, int width, int height)
|
||||
{
|
||||
printf("%0.2f Size %ix%i\n", glfwGetTime(), width, height);
|
||||
|
||||
glViewport(0, 0, width, height);
|
||||
}
|
||||
|
||||
|
||||
+225
@@ -0,0 +1,225 @@
|
||||
//========================================================================
|
||||
// Video mode test
|
||||
// Copyright (c) Camilla Berglund <elmindreda@elmindreda.org>
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied
|
||||
// warranty. In no event will the authors be held liable for any damages
|
||||
// arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it
|
||||
// freely, subject to the following restrictions:
|
||||
//
|
||||
// 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
|
||||
// in a product, an acknowledgment in the product documentation would
|
||||
// be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such, and must not
|
||||
// be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source
|
||||
// distribution.
|
||||
//
|
||||
//========================================================================
|
||||
//
|
||||
// This test enumerates or verifies video modes
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#include <GL/glfw3.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "getopt.h"
|
||||
|
||||
static GLFWwindow window = NULL;
|
||||
|
||||
enum Mode
|
||||
{
|
||||
NO_MODE,
|
||||
LIST_MODE,
|
||||
TEST_MODE
|
||||
};
|
||||
|
||||
static void usage(void)
|
||||
{
|
||||
printf("Usage: modes -l\n");
|
||||
printf(" modes -t\n");
|
||||
printf(" modes -h\n");
|
||||
}
|
||||
|
||||
static void print_mode(GLFWvidmode* mode)
|
||||
{
|
||||
printf("%i x %i x %i (%i %i %i)",
|
||||
mode->width, mode->height,
|
||||
mode->redBits + mode->greenBits + mode->blueBits,
|
||||
mode->redBits, mode->greenBits, mode->blueBits);
|
||||
}
|
||||
|
||||
static void error_callback(int error, const char* description)
|
||||
{
|
||||
fprintf(stderr, "Error: %s\n", description);
|
||||
}
|
||||
|
||||
static void window_size_callback(GLFWwindow window, int width, int height)
|
||||
{
|
||||
printf("Window resized to %ix%i\n", width, height);
|
||||
|
||||
glViewport(0, 0, width, height);
|
||||
}
|
||||
|
||||
static int window_close_callback(GLFWwindow dummy)
|
||||
{
|
||||
window = NULL;
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
static void list_modes(GLFWvidmode* modes, int count)
|
||||
{
|
||||
int i;
|
||||
GLFWvidmode mode;
|
||||
|
||||
glfwGetDesktopMode(&mode);
|
||||
printf("Desktop mode: ");
|
||||
print_mode(&mode);
|
||||
putchar('\n');
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
printf("%3i: ", i);
|
||||
print_mode(modes + i);
|
||||
putchar('\n');
|
||||
}
|
||||
}
|
||||
|
||||
static void test_modes(GLFWvidmode* modes, int count)
|
||||
{
|
||||
int i, width, height;
|
||||
|
||||
glfwSetWindowSizeCallback(window_size_callback);
|
||||
glfwSetWindowCloseCallback(window_close_callback);
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
glfwOpenWindowHint(GLFW_RED_BITS, modes[i].redBits);
|
||||
glfwOpenWindowHint(GLFW_GREEN_BITS, modes[i].greenBits);
|
||||
glfwOpenWindowHint(GLFW_BLUE_BITS, modes[i].blueBits);
|
||||
|
||||
printf("Opening ");
|
||||
print_mode(modes + i);
|
||||
printf(" window\n");
|
||||
|
||||
window = glfwOpenWindow(modes[i].width, modes[i].height,
|
||||
GLFW_FULLSCREEN, "Video Mode Test",
|
||||
NULL);
|
||||
if (!window)
|
||||
{
|
||||
printf("Failed to enter mode %i: ", i);
|
||||
print_mode(modes + i);
|
||||
putchar('\n');
|
||||
continue;
|
||||
}
|
||||
|
||||
glfwSetTime(0.0);
|
||||
glfwSwapInterval(1);
|
||||
|
||||
while (glfwGetTime() < 5.0)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
glfwSwapBuffers();
|
||||
glfwPollEvents();
|
||||
|
||||
if (!window)
|
||||
{
|
||||
printf("User terminated program\n");
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
}
|
||||
|
||||
if (glfwGetWindowParam(window, GLFW_RED_BITS) != modes[i].redBits ||
|
||||
glfwGetWindowParam(window, GLFW_GREEN_BITS) != modes[i].greenBits ||
|
||||
glfwGetWindowParam(window, GLFW_BLUE_BITS) != modes[i].blueBits)
|
||||
{
|
||||
printf("*** Color bit mismatch: (%i %i %i) instead of (%i %i %i)\n",
|
||||
glfwGetWindowParam(window, GLFW_RED_BITS),
|
||||
glfwGetWindowParam(window, GLFW_GREEN_BITS),
|
||||
glfwGetWindowParam(window, GLFW_BLUE_BITS),
|
||||
modes[i].redBits,
|
||||
modes[i].greenBits,
|
||||
modes[i].blueBits);
|
||||
}
|
||||
|
||||
glfwGetWindowSize(window, &width, &height);
|
||||
|
||||
if (width != modes[i].width || height != height)
|
||||
{
|
||||
printf("*** Size mismatch: %ix%i instead of %ix%i\n",
|
||||
width, height,
|
||||
modes[i].width, modes[i].height);
|
||||
}
|
||||
|
||||
printf("Closing window\n");
|
||||
|
||||
glfwCloseWindow(window);
|
||||
glfwPollEvents();
|
||||
window = NULL;
|
||||
|
||||
sleep(5);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
int ch, found, count = 0, mode = NO_MODE;
|
||||
GLFWvidmode* modes = NULL;
|
||||
|
||||
while ((ch = getopt(argc, argv, "lth")) != -1)
|
||||
{
|
||||
switch (ch)
|
||||
{
|
||||
case 'h':
|
||||
usage();
|
||||
exit(EXIT_SUCCESS);
|
||||
case 'l':
|
||||
mode = LIST_MODE;
|
||||
break;
|
||||
case 't':
|
||||
mode = TEST_MODE;
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
glfwSetErrorCallback(error_callback);
|
||||
|
||||
if (!glfwInit())
|
||||
exit(EXIT_FAILURE);
|
||||
|
||||
for (;;)
|
||||
{
|
||||
count += 256;
|
||||
modes = realloc(modes, sizeof(GLFWvidmode) * count);
|
||||
|
||||
found = glfwGetVideoModes(modes, count);
|
||||
if (found < count)
|
||||
break;
|
||||
}
|
||||
|
||||
if (mode == LIST_MODE)
|
||||
list_modes(modes, found);
|
||||
else if (mode == TEST_MODE)
|
||||
test_modes(modes, found);
|
||||
|
||||
free(modes);
|
||||
modes = NULL;
|
||||
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
+3
-6
@@ -35,7 +35,6 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
static GLboolean cursor_captured = GL_FALSE;
|
||||
static GLFWwindow window_handle = NULL;
|
||||
static int cursor_x;
|
||||
static int cursor_y;
|
||||
@@ -44,18 +43,16 @@ static GLboolean open_window(void);
|
||||
|
||||
static void toggle_mouse_cursor(GLFWwindow window)
|
||||
{
|
||||
if (cursor_captured)
|
||||
if (glfwGetInputMode(window, GLFW_CURSOR_MODE) == GLFW_CURSOR_CAPTURED)
|
||||
{
|
||||
printf("Released cursor\n");
|
||||
glfwSetCursorMode(window, GLFW_CURSOR_NORMAL);
|
||||
glfwSetInputMode(window, GLFW_CURSOR_MODE, GLFW_CURSOR_NORMAL);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Captured cursor\n");
|
||||
glfwSetCursorMode(window, GLFW_CURSOR_CAPTURED);
|
||||
glfwSetInputMode(window, GLFW_CURSOR_MODE, GLFW_CURSOR_CAPTURED);
|
||||
}
|
||||
|
||||
cursor_captured = !cursor_captured;
|
||||
}
|
||||
|
||||
static void mouse_position_callback(GLFWwindow window, int x, int y)
|
||||
|
||||
+5
-2
@@ -92,8 +92,6 @@ static void draw_quad(GLuint texture)
|
||||
glBindTexture(GL_TEXTURE_2D, texture);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
|
||||
glColor3f(0.6f, 0.f, 0.6f);
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
|
||||
glTexCoord2f(0.f, 0.f);
|
||||
@@ -142,6 +140,11 @@ int main(int argc, char** argv)
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
// Set drawing color for the first context and copy it to the second
|
||||
glfwMakeContextCurrent(windows[0]);
|
||||
glColor3f(0.6f, 0.f, 0.6f);
|
||||
glfwCopyContext(windows[0], windows[1], GL_CURRENT_BIT);
|
||||
|
||||
// Put the second window to the right of the first one
|
||||
glfwGetWindowPos(windows[0], &x, &y);
|
||||
glfwSetWindowPos(windows[1], x + WIDTH + 50, y);
|
||||
|
||||
+23
-2
@@ -34,11 +34,30 @@
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
static int swap_interval;
|
||||
|
||||
static void set_swap_interval(int value)
|
||||
{
|
||||
char title[256];
|
||||
|
||||
swap_interval = value;
|
||||
glfwSwapInterval(swap_interval);
|
||||
|
||||
sprintf(title, "Tearing detector (interval %i)", swap_interval);
|
||||
glfwSetWindowTitle(glfwGetCurrentContext(), title);
|
||||
}
|
||||
|
||||
static void window_size_callback(GLFWwindow window, int width, int height)
|
||||
{
|
||||
glViewport(0, 0, width, height);
|
||||
}
|
||||
|
||||
static void key_callback(GLFWwindow window, int key, int action)
|
||||
{
|
||||
if (key == GLFW_KEY_SPACE && action == GLFW_PRESS)
|
||||
set_swap_interval(!swap_interval);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
float position;
|
||||
@@ -50,7 +69,7 @@ int main(void)
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
window = glfwOpenWindow(0, 0, GLFW_WINDOWED, "Tearing Detector", NULL);
|
||||
window = glfwOpenWindow(0, 0, GLFW_WINDOWED, "", NULL);
|
||||
if (!window)
|
||||
{
|
||||
glfwTerminate();
|
||||
@@ -59,8 +78,10 @@ int main(void)
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
set_swap_interval(1);
|
||||
|
||||
glfwSetWindowSizeCallback(window_size_callback);
|
||||
glfwSwapInterval(1);
|
||||
glfwSetKeyCallback(key_callback);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glOrtho(-1.f, 1.f, -1.f, 1.f, 1.f, -1.f);
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
//========================================================================
|
||||
// UTF-8 window title test
|
||||
// Copyright (c) Camilla Berglund <elmindreda@elmindreda.org>
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied
|
||||
// warranty. In no event will the authors be held liable for any damages
|
||||
// arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it
|
||||
// freely, subject to the following restrictions:
|
||||
//
|
||||
// 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
|
||||
// in a product, an acknowledgment in the product documentation would
|
||||
// be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such, and must not
|
||||
// be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source
|
||||
// distribution.
|
||||
//
|
||||
//========================================================================
|
||||
//
|
||||
// This test sets a UTF-8 window title
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#include <GL/glfw3.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
static void window_size_callback(GLFWwindow window, int width, int height)
|
||||
{
|
||||
glViewport(0, 0, width, height);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
GLFWwindow window;
|
||||
|
||||
if (!glfwInit())
|
||||
{
|
||||
fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError()));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
window = glfwOpenWindow(0, 0, GLFW_WINDOWED, "English 日本語 русский язык 官話", NULL);
|
||||
if (!window)
|
||||
{
|
||||
fprintf(stderr, "Failed to open GLFW window: %s\n", glfwErrorString(glfwGetError()));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
glfwSwapInterval(1);
|
||||
|
||||
glfwSetWindowSizeCallback(window_size_callback);
|
||||
|
||||
while (glfwIsWindow(window) == GL_TRUE)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
glfwSwapBuffers();
|
||||
glfwWaitEvents();
|
||||
}
|
||||
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user