mirror of
https://github.com/glfw/glfw.git
synced 2024-11-22 04:54:35 +00:00
Updated test program to new API.
This commit is contained in:
parent
ae57d13868
commit
e142a3ec63
@ -28,7 +28,7 @@
|
|||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
#include <GL/glfw.h>
|
#include <GL/glfw3.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -37,10 +37,10 @@
|
|||||||
|
|
||||||
static void usage(void)
|
static void usage(void)
|
||||||
{
|
{
|
||||||
printf("iconify [-h] [-f]\n");
|
printf("Usage: iconify [-h] [-f]\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void GLFWCALL key_callback(int key, int action)
|
static void key_callback(GLFWwindow window, int key, int action)
|
||||||
{
|
{
|
||||||
printf("%0.2f Key %s\n",
|
printf("%0.2f Key %s\n",
|
||||||
glfwGetTime(),
|
glfwGetTime(),
|
||||||
@ -52,15 +52,15 @@ static void GLFWCALL key_callback(int key, int action)
|
|||||||
switch (key)
|
switch (key)
|
||||||
{
|
{
|
||||||
case GLFW_KEY_SPACE:
|
case GLFW_KEY_SPACE:
|
||||||
glfwIconifyWindow();
|
glfwIconifyWindow(window);
|
||||||
break;
|
break;
|
||||||
case GLFW_KEY_ESC:
|
case GLFW_KEY_ESC:
|
||||||
glfwCloseWindow();
|
glfwCloseWindow(window);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void GLFWCALL size_callback(int width, int height)
|
static void size_callback(GLFWwindow window, int width, int height)
|
||||||
{
|
{
|
||||||
glViewport(0, 0, width, height);
|
glViewport(0, 0, width, height);
|
||||||
}
|
}
|
||||||
@ -68,8 +68,9 @@ static void GLFWCALL size_callback(int width, int height)
|
|||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
int width, height, ch;
|
int width, height, ch;
|
||||||
int mode = GLFW_WINDOW;
|
int mode = GLFW_WINDOWED;
|
||||||
GLboolean active = -1, iconified = -1;
|
GLboolean active = -1, iconified = -1;
|
||||||
|
GLFWwindow window;
|
||||||
|
|
||||||
while ((ch = getopt(argc, argv, "fh")) != -1)
|
while ((ch = getopt(argc, argv, "fh")) != -1)
|
||||||
{
|
{
|
||||||
@ -99,8 +100,8 @@ int main(int argc, char** argv)
|
|||||||
{
|
{
|
||||||
GLFWvidmode mode;
|
GLFWvidmode mode;
|
||||||
glfwGetDesktopMode(&mode);
|
glfwGetDesktopMode(&mode);
|
||||||
width = mode.Width;
|
width = mode.width;
|
||||||
height = mode.Height;
|
height = mode.height;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -108,7 +109,8 @@ int main(int argc, char** argv)
|
|||||||
height = 0;
|
height = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!glfwOpenWindow(width, height, 0, 0, 0, 0, 0, 0, mode))
|
window = glfwOpenWindow(width, height, mode);
|
||||||
|
if (!window)
|
||||||
{
|
{
|
||||||
glfwTerminate();
|
glfwTerminate();
|
||||||
|
|
||||||
@ -116,22 +118,22 @@ int main(int argc, char** argv)
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
glfwSetWindowTitle("Iconify");
|
glfwSetWindowTitle(window, "Iconify");
|
||||||
glfwSwapInterval(1);
|
glfwSwapInterval(1);
|
||||||
glfwSetKeyCallback(key_callback);
|
glfwSetKeyCallback(window, key_callback);
|
||||||
glfwSetWindowSizeCallback(size_callback);
|
glfwSetWindowSizeCallback(window, size_callback);
|
||||||
|
|
||||||
glEnable(GL_SCISSOR_TEST);
|
glEnable(GL_SCISSOR_TEST);
|
||||||
|
|
||||||
while (glfwGetWindowParam(GLFW_OPENED))
|
while (glfwIsWindow(window))
|
||||||
{
|
{
|
||||||
int width, height;
|
int width, height;
|
||||||
|
|
||||||
if (iconified != glfwGetWindowParam(GLFW_ICONIFIED) ||
|
if (iconified != glfwGetWindowParam(window, GLFW_ICONIFIED) ||
|
||||||
active != glfwGetWindowParam(GLFW_ACTIVE))
|
active != glfwGetWindowParam(window, GLFW_ACTIVE))
|
||||||
{
|
{
|
||||||
iconified = glfwGetWindowParam(GLFW_ICONIFIED);
|
iconified = glfwGetWindowParam(window, GLFW_ICONIFIED);
|
||||||
active = glfwGetWindowParam(GLFW_ACTIVE);
|
active = glfwGetWindowParam(window, GLFW_ACTIVE);
|
||||||
|
|
||||||
printf("%0.2f %s %s\n",
|
printf("%0.2f %s %s\n",
|
||||||
glfwGetTime(),
|
glfwGetTime(),
|
||||||
@ -139,7 +141,7 @@ int main(int argc, char** argv)
|
|||||||
active ? "Active" : "Inactive");
|
active ? "Active" : "Inactive");
|
||||||
}
|
}
|
||||||
|
|
||||||
glfwGetWindowSize(&width, &height);
|
glfwGetWindowSize(window, &width, &height);
|
||||||
|
|
||||||
glScissor(0, 0, width, height);
|
glScissor(0, 0, width, height);
|
||||||
glClearColor(0, 0, 0, 0);
|
glClearColor(0, 0, 0, 0);
|
||||||
@ -150,6 +152,7 @@ int main(int argc, char** argv)
|
|||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
glfwSwapBuffers();
|
glfwSwapBuffers();
|
||||||
|
glfwPollEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
glfwTerminate();
|
glfwTerminate();
|
||||||
|
Loading…
Reference in New Issue
Block a user