commit
865aa05ec1
30 changed files with 925 additions and 585 deletions
@ -0,0 +1,15 @@ |
||||
# Define the cross compilation environment for cross compiling from linux |
||||
# to Win64 it is to be used when Debian cross compilation toolchain is |
||||
# available. |
||||
SET(CMAKE_SYSTEM_NAME Windows) # Target system name |
||||
SET(CMAKE_SYSTEM_VERSION 1) # Not really used. |
||||
SET(CMAKE_C_COMPILER "amd64-mingw32msvc-gcc") |
||||
SET(CMAKE_CXX_COMPILER "amd64-mingw32msvc-g++") |
||||
SET(CMAKE_RANLIB "amd64-mingw32msvc-ranlib") |
||||
|
||||
|
||||
#Configure the behaviour of the find commands |
||||
SET(CMAKE_FIND_ROOT_PATH "/usr/amd64-mingw32msvc") |
||||
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) |
||||
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) |
||||
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) |
@ -1,69 +1,59 @@ |
||||
|
||||
if(UNIX) |
||||
if(_GLFW_HAS_XRANDR) |
||||
set(GLFW_PKGLIBS "${GLFW_PKGLIBS} xrandr") |
||||
endif(_GLFW_HAS_XRANDR) |
||||
if(_GLFW_HAS_XF86VIDMODE) |
||||
set(GLFW_PKGLIBS "${GLFW_PKGLIBS} xxf86vm") |
||||
endif(_GLFW_HAS_XF86VIDMODE) |
||||
if (_GLFW_X11_GLX) |
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libglfw.pc.cmake |
||||
${CMAKE_CURRENT_BINARY_DIR}/libglfw.pc @ONLY) |
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libglfw.pc DESTINATION lib/pkgconfig) |
||||
endif(UNIX) |
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libglfw.pc |
||||
DESTINATION lib/pkgconfig) |
||||
endif() |
||||
|
||||
include_directories(${GLFW_SOURCE_DIR}/src |
||||
${GLFW_BINARY_DIR}/src |
||||
${GLFW_INCLUDE_DIR}) |
||||
${glfw_INCLUDE_DIRS}) |
||||
|
||||
set(common_SOURCES clipboard.c error.c fullscreen.c gamma.c init.c input.c |
||||
joystick.c opengl.c time.c window.c) |
||||
|
||||
if(_GLFW_COCOA_NSGL) |
||||
set(libglfw_SOURCES ${common_SOURCES} cocoa_clipboard.m cocoa_fullscreen.m |
||||
cocoa_gamma.c cocoa_init.m cocoa_input.m |
||||
cocoa_joystick.m cocoa_opengl.m cocoa_time.c |
||||
cocoa_window.m) |
||||
if (_GLFW_COCOA_NSGL) |
||||
set(glfw_SOURCES ${common_SOURCES} cocoa_clipboard.m cocoa_fullscreen.m |
||||
cocoa_gamma.c cocoa_init.m cocoa_input.m cocoa_joystick.m |
||||
cocoa_opengl.m cocoa_time.c cocoa_window.m) |
||||
|
||||
# For some reason, CMake doesn't know about .m |
||||
set_source_files_properties(${libglfw_SOURCES} PROPERTIES LANGUAGE C) |
||||
elseif(_GLFW_WIN32_WGL) |
||||
set(libglfw_SOURCES ${common_SOURCES} win32_clipboard.c win32_fullscreen.c |
||||
set_source_files_properties(${glfw_SOURCES} PROPERTIES LANGUAGE C) |
||||
elseif (_GLFW_WIN32_WGL) |
||||
set(glfw_SOURCES ${common_SOURCES} win32_clipboard.c win32_fullscreen.c |
||||
win32_gamma.c win32_init.c win32_input.c win32_joystick.c |
||||
win32_opengl.c win32_time.c win32_window.c |
||||
win32_dllmain.c) |
||||
elseif(_GLFW_X11_GLX) |
||||
set(libglfw_SOURCES ${common_SOURCES} x11_clipboard.c x11_fullscreen.c |
||||
win32_opengl.c win32_time.c win32_window.c win32_dllmain.c) |
||||
elseif (_GLFW_X11_GLX) |
||||
set(glfw_SOURCES ${common_SOURCES} x11_clipboard.c x11_fullscreen.c |
||||
x11_gamma.c x11_init.c x11_input.c x11_joystick.c |
||||
x11_keysym2unicode.c x11_opengl.c x11_time.c |
||||
x11_window.c) |
||||
else() |
||||
message(FATAL_ERROR "No supported platform was selected") |
||||
endif(_GLFW_COCOA_NSGL) |
||||
x11_keysym2unicode.c x11_opengl.c x11_time.c x11_window.c) |
||||
endif() |
||||
|
||||
add_library(libglfwStatic STATIC ${libglfw_SOURCES}) |
||||
add_library(libglfwShared SHARED ${libglfw_SOURCES}) |
||||
target_link_libraries(libglfwShared ${GLFW_LIBRARIES}) |
||||
set_target_properties(libglfwStatic libglfwShared PROPERTIES |
||||
CLEAN_DIRECT_OUTPUT 1 |
||||
OUTPUT_NAME glfw) |
||||
add_library(glfw ${glfw_SOURCES}) |
||||
|
||||
if(WIN32) |
||||
if (BUILD_SHARED_LIBS) |
||||
|
||||
if (_GLFW_WIN32_WGL) |
||||
# The GLFW DLL needs a special compile-time macro and import library name |
||||
set_target_properties(libglfwShared PROPERTIES |
||||
DEFINE_SYMBOL GLFW_BUILD_DLL |
||||
set_target_properties(glfw PROPERTIES |
||||
COMPILE_DEFINITIONS "_GLFW_BUILD_DLL;_GLFW_NO_DLOAD_GDI32;_GLFW_NO_DLOAD_WINMM" |
||||
PREFIX "" |
||||
IMPORT_PREFIX "" |
||||
IMPORT_SUFFIX "dll.lib") |
||||
endif(WIN32) |
||||
|
||||
if(APPLE) |
||||
elseif (_GLFW_COCOA_NSGL) |
||||
# Append -fno-common to the compile flags to work around a bug in the Apple GCC |
||||
get_target_property(CFLAGS libglfwShared COMPILE_FLAGS) |
||||
if(NOT CFLAGS) |
||||
set(CFLAGS "") |
||||
endif(NOT CFLAGS) |
||||
set_target_properties(libglfwShared PROPERTIES COMPILE_FLAGS "${CFLAGS} -fno-common") |
||||
endif(APPLE) |
||||
|
||||
install(TARGETS libglfwStatic libglfwShared DESTINATION lib) |
||||
get_target_property(glfw_CFLAGS glfw COMPILE_FLAGS) |
||||
if (NOT glfw_CFLAGS) |
||||
set(glfw_CFLAGS "") |
||||
endif() |
||||
set_target_properties(glfw PROPERTIES |
||||
COMPILE_FLAGS "${glfw_CFLAGS} -fno-common") |
||||
endif() |
||||
|
||||
target_link_libraries(glfw ${glfw_LIBRARIES}) |
||||
target_link_libraries(glfw LINK_INTERFACE_LIBRARIES) |
||||
endif() |
||||
|
||||
install(TARGETS glfw DESTINATION lib) |
||||
|
||||
|
@ -1,91 +0,0 @@ |
||||
//========================================================================
|
||||
// Dynamic linking 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 came about as the result of bug #3060461
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#define GLFW_DLL |
||||
#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; |
||||
int major, minor, rev; |
||||
glfwGetVersion(&major, &minor, &rev); |
||||
|
||||
printf("GLFW header version: %i.%i.%i\n", |
||||
GLFW_VERSION_MAJOR, |
||||
GLFW_VERSION_MINOR, |
||||
GLFW_VERSION_REVISION); |
||||
printf("GLFW library version: %i.%i.%i\n", major, minor, rev); |
||||
printf("GLFW library version string: %s\n", glfwGetVersionString()); |
||||
|
||||
if (major != GLFW_VERSION_MAJOR || |
||||
minor != GLFW_VERSION_MINOR || |
||||
rev != GLFW_VERSION_REVISION) |
||||
{ |
||||
fprintf(stderr, "GLFW library version mismatch\n"); |
||||
exit(EXIT_FAILURE); |
||||
} |
||||
|
||||
if (!glfwInit()) |
||||
{ |
||||
fprintf(stderr, "Failed to initialize GLFW\n"); |
||||
exit(EXIT_FAILURE); |
||||
} |
||||
|
||||
window = glfwOpenWindow(0, 0, GLFW_WINDOWED, "Dynamic Linking Test", NULL); |
||||
if (!window) |
||||
{ |
||||
glfwTerminate(); |
||||
|
||||
fprintf(stderr, "Failed to open GLFW window\n"); |
||||
exit(EXIT_FAILURE); |
||||
} |
||||
|
||||
glfwSetWindowSizeCallback(window_size_callback); |
||||
glfwSwapInterval(1); |
||||
|
||||
while (glfwIsWindow(window)) |
||||
{ |
||||
glClear(GL_COLOR_BUFFER_BIT); |
||||
|
||||
glfwSwapBuffers(); |
||||
glfwPollEvents(); |
||||
} |
||||
|
||||
glfwTerminate(); |
||||
exit(EXIT_SUCCESS); |
||||
} |
||||
|
@ -0,0 +1,223 @@ |
||||
//========================================================================
|
||||
// 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; |
||||
} |
||||
} |
||||
|
||||
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); |
||||
} |
||||
|
Loading…
Reference in New Issue