mirror of
https://github.com/glfw/glfw.git
synced 2024-11-10 00:51:47 +00:00
Add full screen option to tearing test
This commit is contained in:
parent
2053f3ed22
commit
9b0c16596c
@ -33,7 +33,7 @@ add_executable(icon WIN32 MACOSX_BUNDLE icon.c ${GLAD})
|
||||
add_executable(inputlag WIN32 MACOSX_BUNDLE inputlag.c ${GETOPT} ${GLAD})
|
||||
add_executable(joysticks WIN32 MACOSX_BUNDLE joysticks.c ${GLAD})
|
||||
add_executable(opacity WIN32 MACOSX_BUNDLE opacity.c ${GLAD})
|
||||
add_executable(tearing WIN32 MACOSX_BUNDLE tearing.c ${GLAD})
|
||||
add_executable(tearing WIN32 MACOSX_BUNDLE tearing.c ${GETOPT} ${GLAD})
|
||||
add_executable(threads WIN32 MACOSX_BUNDLE threads.c ${TINYCTHREAD} ${GLAD})
|
||||
add_executable(timeout WIN32 MACOSX_BUNDLE timeout.c ${GLAD})
|
||||
add_executable(title WIN32 MACOSX_BUNDLE title.c ${GLAD})
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "getopt.h"
|
||||
#include "linmath.h"
|
||||
|
||||
static const struct
|
||||
@ -68,6 +69,14 @@ static int swap_tear;
|
||||
static int swap_interval;
|
||||
static double frame_rate;
|
||||
|
||||
static void usage(void)
|
||||
{
|
||||
printf("Usage: tearing [-f] [-h]\n");
|
||||
printf("Options:\n");
|
||||
printf(" -f use full screen\n");
|
||||
printf(" -h show this help\n");
|
||||
}
|
||||
|
||||
static void update_window_title(GLFWwindow* window)
|
||||
{
|
||||
char title[256];
|
||||
@ -154,6 +163,8 @@ static void key_callback(GLFWwindow* window, int key, int scancode, int action,
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
unsigned long frame_count = 0;
|
||||
GLFWmonitor* monitor = NULL;
|
||||
int ch, width, height;
|
||||
double last_time, current_time;
|
||||
GLFWwindow* window;
|
||||
GLuint vertex_buffer, vertex_shader, fragment_shader, program;
|
||||
@ -164,10 +175,46 @@ int main(int argc, char** argv)
|
||||
if (!glfwInit())
|
||||
exit(EXIT_FAILURE);
|
||||
|
||||
while ((ch = getopt(argc, argv, "hf")) != -1)
|
||||
{
|
||||
switch (ch)
|
||||
{
|
||||
case 'h':
|
||||
usage();
|
||||
exit(EXIT_SUCCESS);
|
||||
|
||||
case 'f':
|
||||
monitor = glfwGetPrimaryMonitor();
|
||||
break;
|
||||
|
||||
default:
|
||||
usage();
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
if (monitor)
|
||||
{
|
||||
const GLFWvidmode* mode = glfwGetVideoMode(monitor);
|
||||
|
||||
glfwWindowHint(GLFW_REFRESH_RATE, mode->refreshRate);
|
||||
glfwWindowHint(GLFW_RED_BITS, mode->redBits);
|
||||
glfwWindowHint(GLFW_GREEN_BITS, mode->greenBits);
|
||||
glfwWindowHint(GLFW_BLUE_BITS, mode->blueBits);
|
||||
|
||||
width = mode->width;
|
||||
height = mode->height;
|
||||
}
|
||||
else
|
||||
{
|
||||
width = 640;
|
||||
height = 480;
|
||||
}
|
||||
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
|
||||
|
||||
window = glfwCreateWindow(640, 480, "Tearing detector", NULL, NULL);
|
||||
window = glfwCreateWindow(width, height, "Tearing detector", monitor, NULL);
|
||||
if (!window)
|
||||
{
|
||||
glfwTerminate();
|
||||
|
Loading…
Reference in New Issue
Block a user