mirror of
https://github.com/glfw/glfw.git
synced 2026-11-17 20:28:55 +00:00
Merge branch 'master' of github.com:raedwulf/glfw into clipboard
Conflicts: tests/CMakeLists.txt
This commit is contained in:
@@ -11,12 +11,12 @@ 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)
|
||||
add_executable(version version.c getopt.c)
|
||||
|
||||
if(APPLE)
|
||||
# Set fancy names for bundles
|
||||
@@ -33,8 +33,8 @@ else()
|
||||
endif(APPLE)
|
||||
|
||||
set(WINDOWS_BINARIES accuracy sharing tearing windows)
|
||||
set(CONSOLE_BINARIES clipboard defaults events fsaa fsfocus gamma iconify
|
||||
joysticks listmodes peter reopen version)
|
||||
set(CONSOLE_BINARIES clipboard defaults events fsaa fsfocus gamma glfwinfo iconify
|
||||
joysticks listmodes peter reopen)
|
||||
|
||||
if(MSVC)
|
||||
# Tell MSVC to use main instead of WinMain for Windows subsystem executables
|
||||
|
||||
@@ -78,17 +78,10 @@ int main(void)
|
||||
glfwSetWindowSizeCallback(window_size_callback);
|
||||
glfwSwapInterval(1);
|
||||
|
||||
glClearColor(0, 0, 0, 0);
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
|
||||
while (glfwIsWindow(window))
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glColor3f(1.f, 1.f, 1.f);
|
||||
|
||||
glBegin(GL_LINES);
|
||||
glVertex2f(0.f, (GLfloat) window_height - cursor_y);
|
||||
glVertex2f((GLfloat) window_width, (GLfloat) window_height - cursor_y);
|
||||
|
||||
@@ -132,8 +132,6 @@ int main(int argc, char** argv)
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glColor3f(1.f, 1.f, 1.f);
|
||||
|
||||
glLoadIdentity();
|
||||
glTranslatef(0.25f, 0.25f, 0.f);
|
||||
glRotatef(time, 0.f, 0.f, 1.f);
|
||||
|
||||
@@ -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);
|
||||
|
||||
+1
-4
@@ -62,7 +62,7 @@ static void window_size_callback(GLFWwindow window, int width, int height)
|
||||
static int window_close_callback(GLFWwindow window)
|
||||
{
|
||||
printf("Close callback triggered\n");
|
||||
window_handle = NULL;
|
||||
closed = GL_TRUE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -136,9 +136,6 @@ int main(int argc, char** argv)
|
||||
glOrtho(-1.f, 1.f, -1.f, 1.f, 1.f, -1.f);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
|
||||
glClearColor(0.f, 0.f, 0.f, 0.f);
|
||||
glColor3f(1.f, 1.f, 1.f);
|
||||
|
||||
glfwSetTime(0.0);
|
||||
|
||||
while (glfwGetTime() < 5.0)
|
||||
|
||||
@@ -62,9 +62,6 @@ int main(void)
|
||||
glfwSetWindowSizeCallback(window_size_callback);
|
||||
glfwSwapInterval(1);
|
||||
|
||||
glClearColor(0.f, 0.f, 0.f, 0.f);
|
||||
glColor3f(1.f, 1.f, 1.f);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glOrtho(-1.f, 1.f, -1.f, 1.f, 1.f, -1.f);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
|
||||
+4
-1
@@ -66,7 +66,10 @@ int main(void)
|
||||
|
||||
glfwSetWindowPos(windows[i], 100 + (i & 1) * 300, 100 + (i >> 1) * 300);
|
||||
|
||||
glClearColor((GLclampf) (i & 1), (GLclampf) (i >> 1), 0.0, 0.0);
|
||||
glClearColor((GLclampf) (i & 1),
|
||||
(GLclampf) (i >> 1),
|
||||
i ? 0.0 : 1.0,
|
||||
0.0);
|
||||
}
|
||||
|
||||
while (running)
|
||||
|
||||
Reference in New Issue
Block a user