mirror of
https://github.com/gwm17/glfw.git
synced 2024-11-22 18:28:52 -05:00
Added full screen support to tearing test.
This commit is contained in:
parent
d3e25db395
commit
530fc5a431
|
@ -45,7 +45,7 @@ set_target_properties(empty PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Empty Event")
|
||||||
add_executable(sharing WIN32 MACOSX_BUNDLE sharing.c)
|
add_executable(sharing WIN32 MACOSX_BUNDLE sharing.c)
|
||||||
set_target_properties(sharing PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Sharing")
|
set_target_properties(sharing PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Sharing")
|
||||||
|
|
||||||
add_executable(tearing WIN32 MACOSX_BUNDLE tearing.c)
|
add_executable(tearing WIN32 MACOSX_BUNDLE tearing.c ${GETOPT})
|
||||||
set_target_properties(tearing PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Tearing")
|
set_target_properties(tearing PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Tearing")
|
||||||
|
|
||||||
add_executable(threads WIN32 MACOSX_BUNDLE threads.c ${TINYCTHREAD})
|
add_executable(threads WIN32 MACOSX_BUNDLE threads.c ${TINYCTHREAD})
|
||||||
|
|
|
@ -34,9 +34,19 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
|
#include "getopt.h"
|
||||||
|
|
||||||
static int swap_interval;
|
static int swap_interval;
|
||||||
static double frame_rate;
|
static double frame_rate;
|
||||||
|
|
||||||
|
static void usage(void)
|
||||||
|
{
|
||||||
|
printf("Usage: iconify [-h] [-f]\n");
|
||||||
|
printf("Options:\n");
|
||||||
|
printf(" -f create full screen window\n");
|
||||||
|
printf(" -h show this help\n");
|
||||||
|
}
|
||||||
|
|
||||||
static void update_window_title(GLFWwindow* window)
|
static void update_window_title(GLFWwindow* window)
|
||||||
{
|
{
|
||||||
char title[256];
|
char title[256];
|
||||||
|
@ -66,23 +76,53 @@ static void framebuffer_size_callback(GLFWwindow* window, int width, int height)
|
||||||
|
|
||||||
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
|
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
|
||||||
{
|
{
|
||||||
if (key == GLFW_KEY_SPACE && action == GLFW_PRESS)
|
if (action != GLFW_PRESS)
|
||||||
set_swap_interval(window, 1 - swap_interval);
|
return;
|
||||||
|
|
||||||
|
switch (key)
|
||||||
|
{
|
||||||
|
case GLFW_KEY_SPACE:
|
||||||
|
set_swap_interval(window, 1 - swap_interval);
|
||||||
|
break;
|
||||||
|
case GLFW_KEY_ESCAPE:
|
||||||
|
glfwSetWindowShouldClose(window, 1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(void)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
|
int ch;
|
||||||
float position;
|
float position;
|
||||||
unsigned long frame_count = 0;
|
unsigned long frame_count = 0;
|
||||||
double last_time, current_time;
|
double last_time, current_time;
|
||||||
|
GLboolean fullscreen = GL_FALSE;
|
||||||
|
GLFWmonitor* monitor = NULL;
|
||||||
GLFWwindow* window;
|
GLFWwindow* window;
|
||||||
|
|
||||||
|
while ((ch = getopt(argc, argv, "fh")) != -1)
|
||||||
|
{
|
||||||
|
switch (ch)
|
||||||
|
{
|
||||||
|
case 'h':
|
||||||
|
usage();
|
||||||
|
exit(EXIT_SUCCESS);
|
||||||
|
|
||||||
|
case 'f':
|
||||||
|
fullscreen = GL_TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
glfwSetErrorCallback(error_callback);
|
glfwSetErrorCallback(error_callback);
|
||||||
|
|
||||||
if (!glfwInit())
|
if (!glfwInit())
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|
||||||
window = glfwCreateWindow(640, 480, "", NULL, NULL);
|
if (fullscreen)
|
||||||
|
monitor = glfwGetPrimaryMonitor();
|
||||||
|
|
||||||
|
window = glfwCreateWindow(640, 480, "", monitor, NULL);
|
||||||
if (!window)
|
if (!window)
|
||||||
{
|
{
|
||||||
glfwTerminate();
|
glfwTerminate();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user