commit
1234e0c537
53 changed files with 3276 additions and 1064 deletions
@ -1,88 +0,0 @@ |
||||
# - Check if X11 RandR extension is available |
||||
# Check if the X11 extension RandR is available. |
||||
# This macro defines : |
||||
# - X11_RANDR_FOUND, If set to NO RandR is not available. |
||||
# - X11_RANDR_INCLUDE_DIR, includes directory containing the RandR header. |
||||
# - X11_RANDR_LIBRARIES, libraries to link in the library to use RandR. |
||||
# |
||||
# Created by Olivier Delannoy. |
||||
macro(CHECK_X11_XRANDR) |
||||
message(STATUS "Checking for X11 extension XRandR") |
||||
set(X11_XRANDR_FOUND "NO") |
||||
find_path(X11_XRANDR_INCLUDE_DIR "X11/extensions/Xrandr.h" |
||||
PATHS |
||||
/usr/local/include |
||||
/usr/local/X11/include |
||||
/usr/local/X11R6/include |
||||
/usr/include |
||||
/usr/X11/include |
||||
/usr/X11R6/include) |
||||
|
||||
find_library(X11_XRANDR_LIBRARIES NAMES Xrandr |
||||
PATHS |
||||
/usr/local/lib |
||||
/usr/local/X11/lib |
||||
/usr/local/X11R6/lib |
||||
/usr/lib |
||||
/usr/X11/lib |
||||
/usr/X11R6/lib) |
||||
# Create check if file compiles with randr |
||||
|
||||
if (X11_XRANDR_LIBRARIES AND X11_XRANDR_INCLUDE_DIR) |
||||
set(X11_XRANDR_FOUND "YES") |
||||
endif (X11_XRANDR_LIBRARIES AND X11_XRANDR_INCLUDE_DIR) |
||||
|
||||
if (X11_XRANDR_FOUND) |
||||
message(STATUS "Checking for X11 extension XRandR -- found") |
||||
else (X11_XRANDR_FOUND) |
||||
message(STATUS "Checking for X11 extension XRandR -- not found") |
||||
endif (X11_XRANDR_FOUND) |
||||
|
||||
mark_as_advanced(X11_XRANDR_LIBRARIES X11_XRANDR_INCLUDE_DIR) |
||||
endmacro(CHECK_X11_XRANDR) |
||||
|
||||
|
||||
# - Check if X11 VidMod extension is available |
||||
# Check if the X11 extension VidMod is available. |
||||
# This macro defines : |
||||
# - X11_VIDMOD_FOUND, If set to NO VidMod is not available. |
||||
# - X11_VIDMOD_INCLUDE_DIR, includes directory containing the headers. |
||||
# - X11_VIDMOD_LIBRARIES, libraries to link in the libraries. |
||||
# |
||||
# Created by Olivier Delannoy. |
||||
macro(CHECK_X11_XF86VIDMODE) |
||||
message(STATUS "Checking for X11 extension xf86vidmode") |
||||
set(X11_XF86VIDMODE_FOUND "NO") |
||||
find_path(X11_XF86VIDMODE_INCLUDE_DIR "X11/extensions/xf86vmode.h" |
||||
PATHS |
||||
/usr/local/include |
||||
/usr/local/X11/include |
||||
/usr/local/X11R6/include |
||||
/usr/include |
||||
/usr/X11/include |
||||
/usr/X11R6/include) |
||||
|
||||
find_library(X11_XF86VIDMODE_LIBRARIES NAMES Xxf86vm PATHS |
||||
/usr/local/lib |
||||
/usr/local/X11/lib |
||||
/usr/local/X11R6/lib |
||||
/usr/lib |
||||
/usr/X11/lib |
||||
/usr/X11R6/lib) |
||||
# Add a test case here |
||||
if (X11_XF86VIDMODE_LIBRARIES AND X11_XF86VIDMODE_INCLUDE_DIR) |
||||
set(X11_XF86VIDMODE_FOUND "YES") |
||||
endif (X11_XF86VIDMODE_LIBRARIES AND X11_XF86VIDMODE_INCLUDE_DIR) |
||||
|
||||
if (X11_XF86VIDMODE_FOUND) |
||||
message(STATUS "Checking for X11 extension xf86vidmode -- found") |
||||
else (X11_XF86VIDMODE_FOUND) |
||||
message(STATUS "Checking for X11 extension xf86vidmode -- not found") |
||||
endif(X11_XF86VIDMODE_FOUND) |
||||
|
||||
mark_as_advanced( |
||||
X11_XF86VIDMODE_LIBRARIES |
||||
X11_XF86VIDMODE_INCLUDE_DIR |
||||
) |
||||
|
||||
endmacro(CHECK_X11_XF86VIDMODE) |
File diff suppressed because it is too large
Load Diff
@ -1,192 +0,0 @@ |
||||
//========================================================================
|
||||
// GLFW - An OpenGL library
|
||||
// Platform: Any
|
||||
// API version: 3.0
|
||||
// WWW: http://www.glfw.org/
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||
// Copyright (c) 2006-2010 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.
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#include "internal.h" |
||||
|
||||
|
||||
//========================================================================
|
||||
// Enable and disable sticky keys mode
|
||||
//========================================================================
|
||||
|
||||
static void enableStickyKeys(_GLFWwindow* window) |
||||
{ |
||||
window->stickyKeys = GL_TRUE; |
||||
} |
||||
|
||||
static void disableStickyKeys(_GLFWwindow* window) |
||||
{ |
||||
int i; |
||||
|
||||
window->stickyKeys = GL_FALSE; |
||||
|
||||
// Release all sticky keys
|
||||
for (i = 0; i <= GLFW_KEY_LAST; i++) |
||||
{ |
||||
if (window->key[i] == GLFW_STICK) |
||||
window->key[i] = GLFW_RELEASE; |
||||
} |
||||
} |
||||
|
||||
|
||||
//========================================================================
|
||||
// Enable and disable sticky mouse buttons mode
|
||||
//========================================================================
|
||||
|
||||
static void enableStickyMouseButtons(_GLFWwindow* window) |
||||
{ |
||||
window->stickyMouseButtons = GL_TRUE; |
||||
} |
||||
|
||||
static void disableStickyMouseButtons(_GLFWwindow* window) |
||||
{ |
||||
int i; |
||||
|
||||
window->stickyMouseButtons = GL_FALSE; |
||||
|
||||
// Release all sticky mouse buttons
|
||||
for (i = 0; i <= GLFW_MOUSE_BUTTON_LAST; i++) |
||||
{ |
||||
if (window->mouseButton[i] == GLFW_STICK) |
||||
window->mouseButton[i] = GLFW_RELEASE; |
||||
} |
||||
} |
||||
|
||||
|
||||
//========================================================================
|
||||
// Enable and disable system keys
|
||||
//========================================================================
|
||||
|
||||
static void enableSystemKeys(_GLFWwindow* window) |
||||
{ |
||||
if (!window->sysKeysDisabled) |
||||
return; |
||||
|
||||
_glfwPlatformEnableSystemKeys(window); |
||||
|
||||
// Indicate that system keys are no longer disabled
|
||||
window->sysKeysDisabled = GL_FALSE; |
||||
} |
||||
|
||||
static void disableSystemKeys(_GLFWwindow* window) |
||||
{ |
||||
if (window->sysKeysDisabled) |
||||
return; |
||||
|
||||
_glfwPlatformDisableSystemKeys(window); |
||||
|
||||
// Indicate that system keys are now disabled
|
||||
window->sysKeysDisabled = GL_TRUE; |
||||
} |
||||
|
||||
|
||||
//========================================================================
|
||||
// Enable and disable key repeat
|
||||
//========================================================================
|
||||
|
||||
static void enableKeyRepeat(_GLFWwindow* window) |
||||
{ |
||||
window->keyRepeat = GL_TRUE; |
||||
} |
||||
|
||||
static void disableKeyRepeat(_GLFWwindow* window) |
||||
{ |
||||
window->keyRepeat = GL_FALSE; |
||||
} |
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////// GLFW public API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//========================================================================
|
||||
// Enable certain GLFW/window/system functions
|
||||
//========================================================================
|
||||
|
||||
GLFWAPI void glfwEnable(GLFWwindow window, int token) |
||||
{ |
||||
if (!_glfwInitialized) |
||||
{ |
||||
_glfwSetError(GLFW_NOT_INITIALIZED, NULL); |
||||
return; |
||||
} |
||||
|
||||
switch (token) |
||||
{ |
||||
case GLFW_STICKY_KEYS: |
||||
enableStickyKeys(window); |
||||
break; |
||||
case GLFW_STICKY_MOUSE_BUTTONS: |
||||
enableStickyMouseButtons(window); |
||||
break; |
||||
case GLFW_SYSTEM_KEYS: |
||||
enableSystemKeys(window); |
||||
break; |
||||
case GLFW_KEY_REPEAT: |
||||
enableKeyRepeat(window); |
||||
break; |
||||
default: |
||||
_glfwSetError(GLFW_INVALID_ENUM, NULL); |
||||
break; |
||||
} |
||||
} |
||||
|
||||
|
||||
//========================================================================
|
||||
// Disable certain GLFW/window/system functions
|
||||
//========================================================================
|
||||
|
||||
GLFWAPI void glfwDisable(GLFWwindow window, int token) |
||||
{ |
||||
if (!_glfwInitialized) |
||||
{ |
||||
_glfwSetError(GLFW_NOT_INITIALIZED, NULL); |
||||
return; |
||||
} |
||||
|
||||
switch (token) |
||||
{ |
||||
case GLFW_STICKY_KEYS: |
||||
disableStickyKeys(window); |
||||
break; |
||||
case GLFW_STICKY_MOUSE_BUTTONS: |
||||
disableStickyMouseButtons(window); |
||||
break; |
||||
case GLFW_SYSTEM_KEYS: |
||||
disableSystemKeys(window); |
||||
break; |
||||
case GLFW_KEY_REPEAT: |
||||
disableKeyRepeat(window); |
||||
break; |
||||
default: |
||||
_glfwSetError(GLFW_INVALID_ENUM, NULL); |
||||
break; |
||||
} |
||||
} |
||||
|
@ -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); |
||||
} |
||||
|
@ -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); |
||||
} |
||||
|
Loading…
Reference in New Issue