mirror of
https://github.com/glfw/glfw.git
synced 2026-09-22 16:52:57 +00:00
Merge branch 'master' into clipboard
Conflicts: src/CMakeLists.txt src/libglfw.pc.cmake
This commit is contained in:
+26
-37
@@ -1,6 +1,12 @@
|
||||
|
||||
set(STATIC_DEPS libglfwStatic ${GLFW_LIBRARIES} ${OPENGL_glu_LIBRARY})
|
||||
set(SHARED_DEPS libglfwShared ${GLFW_LIBRARIES} ${OPENGL_glu_LIBRARY})
|
||||
link_libraries(glfw ${OPENGL_glu_LIBRARY})
|
||||
|
||||
if (BUILD_SHARED_LIBS)
|
||||
add_definitions(-DGLFW_DLL)
|
||||
link_libraries(${OPENGL_gl_LIBRARY})
|
||||
else()
|
||||
link_libraries(${glfw_LIBRARIES})
|
||||
endif()
|
||||
|
||||
include_directories(${GLFW_SOURCE_DIR}/include
|
||||
${GLFW_SOURCE_DIR}/support
|
||||
@@ -9,63 +15,46 @@ add_executable(clipboard clipboard.c)
|
||||
target_link_libraries(clipboard ${STATIC_DEPS})
|
||||
|
||||
add_executable(defaults defaults.c)
|
||||
target_link_libraries(defaults ${STATIC_DEPS})
|
||||
|
||||
add_executable(dynamic dynamic.c)
|
||||
target_link_libraries(dynamic ${SHARED_DEPS})
|
||||
|
||||
add_executable(events events.c)
|
||||
target_link_libraries(events ${STATIC_DEPS})
|
||||
|
||||
add_executable(fsaa fsaa.c getopt.c)
|
||||
target_link_libraries(fsaa ${STATIC_DEPS})
|
||||
|
||||
add_executable(fsfocus fsfocus.c)
|
||||
target_link_libraries(fsfocus ${STATIC_DEPS})
|
||||
|
||||
add_executable(gamma gamma.c getopt.c)
|
||||
target_link_libraries(gamma ${STATIC_DEPS})
|
||||
|
||||
add_executable(glfwinfo glfwinfo.c getopt.c)
|
||||
target_link_libraries(glfwinfo ${STATIC_DEPS})
|
||||
|
||||
add_executable(iconify iconify.c getopt.c)
|
||||
target_link_libraries(iconify ${STATIC_DEPS})
|
||||
|
||||
add_executable(joysticks joysticks.c)
|
||||
target_link_libraries(joysticks ${STATIC_DEPS})
|
||||
|
||||
add_executable(listmodes listmodes.c)
|
||||
target_link_libraries(listmodes ${STATIC_DEPS})
|
||||
|
||||
add_executable(modes modes.c getopt.c)
|
||||
add_executable(peter peter.c)
|
||||
target_link_libraries(peter ${STATIC_DEPS})
|
||||
|
||||
add_executable(reopen reopen.c)
|
||||
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 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()
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
+1
-1
@@ -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)));
|
||||
|
||||
+223
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user