mirror of
https://github.com/glfw/glfw.git
synced 2026-09-22 16:52:57 +00:00
Merge branch 'master' into multi-display-support
Conflicts: src/CMakeLists.txt src/input.c
This commit is contained in:
+47
-34
@@ -1,5 +1,6 @@
|
||||
|
||||
link_libraries(libglfwStatic ${GLFW_LIBRARIES} ${OPENGL_glu_LIBRARY})
|
||||
set(STATIC_DEPS libglfwStatic ${GLFW_LIBRARIES} ${OPENGL_glu_LIBRARY})
|
||||
set(SHARED_DEPS libglfwShared ${GLFW_LIBRARIES} ${OPENGL_glu_LIBRARY})
|
||||
|
||||
if (UNIX AND NOT APPLE AND NOT CYGWIN)
|
||||
find_library(MATH_LIBRARY m)
|
||||
@@ -12,30 +13,52 @@ include_directories(${GLFW_SOURCE_DIR}/include
|
||||
${OPENGL_INCLUDE_DIR})
|
||||
|
||||
add_executable(defaults defaults.c)
|
||||
add_executable(events events.c)
|
||||
add_executable(fsaa fsaa.c getopt.c)
|
||||
add_executable(fsfocus fsfocus.c)
|
||||
add_executable(gamma gamma.c getopt.c)
|
||||
add_executable(glfwinfo glfwinfo.c getopt.c)
|
||||
add_executable(iconify iconify.c getopt.c)
|
||||
add_executable(joysticks joysticks.c)
|
||||
add_executable(listmodes listmodes.c)
|
||||
add_executable(peter peter.c)
|
||||
add_executable(reopen reopen.c)
|
||||
target_link_libraries(defaults ${STATIC_DEPS})
|
||||
|
||||
if(APPLE)
|
||||
# Set fancy names for bundles
|
||||
add_executable(Accuracy MACOSX_BUNDLE accuracy.c)
|
||||
add_executable(Sharing MACOSX_BUNDLE sharing.c)
|
||||
add_executable(Tearing MACOSX_BUNDLE tearing.c)
|
||||
add_executable(Windows MACOSX_BUNDLE windows.c)
|
||||
else()
|
||||
# Set boring names for executables
|
||||
add_executable(accuracy WIN32 accuracy.c)
|
||||
add_executable(sharing WIN32 sharing.c)
|
||||
add_executable(tearing WIN32 tearing.c)
|
||||
add_executable(windows WIN32 windows.c)
|
||||
endif(APPLE)
|
||||
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(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})
|
||||
|
||||
add_executable(sharing WIN32 MACOSX_BUNDLE sharing.c)
|
||||
target_link_libraries(sharing ${STATIC_DEPS})
|
||||
|
||||
add_executable(tearing WIN32 MACOSX_BUNDLE tearing.c)
|
||||
target_link_libraries(tearing ${STATIC_DEPS})
|
||||
|
||||
add_executable(windows WIN32 MACOSX_BUNDLE windows.c)
|
||||
target_link_libraries(windows ${STATIC_DEPS})
|
||||
|
||||
set(WINDOWS_BINARIES accuracy sharing tearing windows)
|
||||
set(CONSOLE_BINARIES defaults events fsaa fsfocus gamma glfwinfo iconify
|
||||
@@ -47,13 +70,3 @@ if(MSVC)
|
||||
LINK_FLAGS "/ENTRY:mainCRTStartup")
|
||||
endif(MSVC)
|
||||
|
||||
if(CYGWIN)
|
||||
# Set cross-compile and subsystem compile and link flags
|
||||
set_target_properties(${WINDOWS_BINARIES} ${CONSOLE_BINARIES} PROPERTIES
|
||||
COMPILE_FLAGS "-mno-cygwin")
|
||||
set_target_properties(${WINDOWS_BINARIES} PROPERTIES
|
||||
LINK_FLAGS "-mno-cygwin -mwindows")
|
||||
set_target_properties(${CONSOLE_BINARIES} PROPERTIES
|
||||
LINK_FLAGS "-mno-cygwin -mconsole")
|
||||
endif(CYGWIN)
|
||||
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
//========================================================================
|
||||
// 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);
|
||||
}
|
||||
|
||||
+26
-17
@@ -32,21 +32,28 @@
|
||||
#include <GL/glfw3.h>
|
||||
#include <GL/glext.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define strcasecmp(x, y) _stricmp(x, y)
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "getopt.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define strcasecmp(x, y) _stricmp(x, y)
|
||||
#endif
|
||||
|
||||
#define PROFILE_NAME_CORE "core"
|
||||
#define PROFILE_NAME_COMPAT "compat"
|
||||
#define PROFILE_NAME_ES2 "es2"
|
||||
|
||||
#define STRATEGY_NAME_NONE "none"
|
||||
#define STRATEGY_NAME_LOSE "lose"
|
||||
|
||||
static void usage(void)
|
||||
{
|
||||
printf("Usage: version [-h] [-m MAJOR] [-n MINOR] [-d] [-l] [-f] [-p PROFILE] [-r STRATEGY]\n");
|
||||
printf("available profiles: core compat es2\n");
|
||||
printf("available strategies: none lose\n");
|
||||
printf("available profiles: " PROFILE_NAME_CORE " " PROFILE_NAME_COMPAT " " PROFILE_NAME_ES2 "\n");
|
||||
printf("available strategies: " STRATEGY_NAME_NONE " " STRATEGY_NAME_LOSE "\n");
|
||||
}
|
||||
|
||||
static void error_callback(int error, const char* description)
|
||||
@@ -57,11 +64,11 @@ static void error_callback(int error, const char* description)
|
||||
static const char* get_glfw_profile_name(int profile)
|
||||
{
|
||||
if (profile == GLFW_OPENGL_COMPAT_PROFILE)
|
||||
return "compatibility";
|
||||
return PROFILE_NAME_COMPAT;
|
||||
else if (profile == GLFW_OPENGL_CORE_PROFILE)
|
||||
return "core";
|
||||
return PROFILE_NAME_CORE;
|
||||
else if (profile == GLFW_OPENGL_ES2_PROFILE)
|
||||
return "es2";
|
||||
return PROFILE_NAME_ES2;
|
||||
|
||||
return "unknown";
|
||||
}
|
||||
@@ -69,9 +76,9 @@ static const char* get_glfw_profile_name(int profile)
|
||||
static const char* get_profile_name(GLint mask)
|
||||
{
|
||||
if (mask & GL_CONTEXT_COMPATIBILITY_PROFILE_BIT)
|
||||
return "compatibility";
|
||||
return PROFILE_NAME_COMPAT;
|
||||
if (mask & GL_CONTEXT_CORE_PROFILE_BIT)
|
||||
return "core";
|
||||
return PROFILE_NAME_CORE;
|
||||
|
||||
return "unknown";
|
||||
}
|
||||
@@ -142,11 +149,11 @@ int main(int argc, char** argv)
|
||||
minor = atoi(optarg);
|
||||
break;
|
||||
case 'p':
|
||||
if (strcasecmp(optarg, "core") == 0)
|
||||
if (strcasecmp(optarg, PROFILE_NAME_CORE) == 0)
|
||||
profile = GLFW_OPENGL_CORE_PROFILE;
|
||||
else if (strcasecmp(optarg, "compat") == 0)
|
||||
else if (strcasecmp(optarg, PROFILE_NAME_COMPAT) == 0)
|
||||
profile = GLFW_OPENGL_COMPAT_PROFILE;
|
||||
else if (strcasecmp(optarg, "es2") == 0)
|
||||
else if (strcasecmp(optarg, PROFILE_NAME_ES2) == 0)
|
||||
profile = GLFW_OPENGL_ES2_PROFILE;
|
||||
else
|
||||
{
|
||||
@@ -155,9 +162,9 @@ int main(int argc, char** argv)
|
||||
}
|
||||
break;
|
||||
case 'r':
|
||||
if (strcasecmp(optarg, "none") == 0)
|
||||
if (strcasecmp(optarg, STRATEGY_NAME_NONE) == 0)
|
||||
strategy = GLFW_OPENGL_NO_RESET_NOTIFICATION;
|
||||
else if (strcasecmp(optarg, "lose") == 0)
|
||||
else if (strcasecmp(optarg, STRATEGY_NAME_LOSE) == 0)
|
||||
strategy = GLFW_OPENGL_LOSE_CONTEXT_ON_RESET;
|
||||
else
|
||||
{
|
||||
@@ -221,7 +228,9 @@ int main(int argc, char** argv)
|
||||
if (major != GLFW_VERSION_MAJOR ||
|
||||
minor != GLFW_VERSION_MINOR ||
|
||||
revision != GLFW_VERSION_REVISION)
|
||||
{
|
||||
printf("*** WARNING: GLFW version mismatch! ***\n");
|
||||
}
|
||||
|
||||
printf("GLFW library version string: \"%s\"\n", glfwGetVersionString());
|
||||
|
||||
@@ -266,7 +275,7 @@ int main(int argc, char** argv)
|
||||
if (major > 1)
|
||||
{
|
||||
printf("OpenGL context shading language version: \"%s\"\n",
|
||||
glGetString(GL_SHADING_LANGUAGE_VERSION));
|
||||
glGetString(GL_SHADING_LANGUAGE_VERSION));
|
||||
}
|
||||
|
||||
// Report OpenGL extensions
|
||||
|
||||
+13
-5
@@ -37,22 +37,32 @@
|
||||
|
||||
static GLboolean cursor_captured = GL_FALSE;
|
||||
static GLFWwindow window_handle = NULL;
|
||||
static int cursor_x;
|
||||
static int cursor_y;
|
||||
|
||||
static GLboolean open_window(void);
|
||||
|
||||
static void toggle_mouse_cursor(GLFWwindow window)
|
||||
{
|
||||
if (cursor_captured)
|
||||
{
|
||||
printf("Released cursor\n");
|
||||
glfwSetCursorMode(window, GLFW_CURSOR_NORMAL);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Captured cursor\n");
|
||||
glfwSetCursorMode(window, GLFW_CURSOR_CAPTURED);
|
||||
}
|
||||
|
||||
cursor_captured = !cursor_captured;
|
||||
}
|
||||
|
||||
static void mouse_position_callback(GLFWwindow window, int x, int y)
|
||||
{
|
||||
printf("Mouse moved to: %i %i\n", x, y);
|
||||
printf("Mouse moved to: %i %i (%i %i)\n", x, y, x - cursor_x, y - cursor_y);
|
||||
cursor_x = x;
|
||||
cursor_y = y;
|
||||
}
|
||||
|
||||
static void key_callback(GLFWwindow window, int key, int action)
|
||||
@@ -87,14 +97,12 @@ static void window_size_callback(GLFWwindow window, int width, int height)
|
||||
|
||||
static GLboolean open_window(void)
|
||||
{
|
||||
int x, y;
|
||||
|
||||
window_handle = glfwOpenWindow(0, 0, GLFW_WINDOWED, "Peter Detector", NULL);
|
||||
if (!window_handle)
|
||||
return GL_FALSE;
|
||||
|
||||
glfwGetMousePos(window_handle, &x, &y);
|
||||
printf("Mouse position: %i %i\n", x, y);
|
||||
glfwGetMousePos(window_handle, &cursor_x, &cursor_y);
|
||||
printf("Mouse position: %i %i\n", cursor_x, cursor_y);
|
||||
|
||||
glfwSetWindowSizeCallback(window_size_callback);
|
||||
glfwSetMousePosCallback(mouse_position_callback);
|
||||
|
||||
Reference in New Issue
Block a user