Replaced automatic closing with window parameter.

This commit is contained in:
Camilla Berglund
2012-08-10 13:31:15 +02:00
parent 2212cd94bf
commit 2410e2aaf4
21 changed files with 53 additions and 112 deletions
+1 -1
View File
@@ -106,7 +106,7 @@ int main(void)
set_swap_interval(window, swap_interval);
while (glfwGetCurrentContext())
while (!glfwGetWindowParam(window, GLFW_CLOSE_REQUESTED))
{
glClear(GL_COLOR_BUFFER_BIT);
+1 -1
View File
@@ -136,7 +136,7 @@ int main(int argc, char** argv)
glClearColor(0.5f, 0.5f, 0.5f, 0);
while (glfwGetCurrentContext())
while (!glfwGetWindowParam(window, GLFW_CLOSE_REQUESTED))
{
glClear(GL_COLOR_BUFFER_BIT);
+1 -7
View File
@@ -48,9 +48,6 @@ static GLboolean closeable = GL_TRUE;
// Event index
static unsigned int counter = 0;
// Should we keep running?
static GLboolean running = GL_TRUE;
static const char* get_key_name(int key)
{
switch (key)
@@ -238,9 +235,6 @@ static int window_close_callback(GLFWwindow window)
{
printf("%08x at %0.3f: Window close\n", counter++, glfwGetTime());
if (closeable)
running = GL_FALSE;
return closeable;
}
@@ -399,7 +393,7 @@ int main(void)
printf("Main loop starting\n");
while (running)
while (!glfwGetWindowParam(window, GLFW_CLOSE_REQUESTED))
glfwWaitEvents();
glfwTerminate();
+1 -1
View File
@@ -127,7 +127,7 @@ int main(int argc, char** argv)
gluOrtho2D(0.f, 1.f, 0.f, 0.5f);
glMatrixMode(GL_MODELVIEW);
while (glfwGetCurrentContext())
while (!glfwGetWindowParam(window, GLFW_CLOSE_REQUESTED))
{
GLfloat time = (GLfloat) glfwGetTime();
+1 -1
View File
@@ -151,7 +151,7 @@ int main(int argc, char** argv)
glClearColor(0.5f, 0.5f, 0.5f, 0);
while (glfwGetCurrentContext())
while (!glfwGetWindowParam(window, GLFW_CLOSE_REQUESTED))
{
glClear(GL_COLOR_BUFFER_BIT);
+1 -1
View File
@@ -126,7 +126,7 @@ int main(int argc, char** argv)
glEnable(GL_SCISSOR_TEST);
while (glfwGetCurrentContext())
while (!glfwGetWindowParam(window, GLFW_CLOSE_REQUESTED))
{
int width, height;
+1 -1
View File
@@ -198,7 +198,7 @@ int main(void)
glfwSetWindowSizeCallback(window_size_callback);
glfwSwapInterval(1);
while (glfwGetCurrentContext())
while (!glfwGetWindowParam(window, GLFW_CLOSE_REQUESTED))
{
glClear(GL_COLOR_BUFFER_BIT);
+1 -1
View File
@@ -127,7 +127,7 @@ int main(void)
glClearColor(0.f, 0.f, 0.f, 0.f);
while (glfwGetCurrentContext())
while (!glfwGetWindowParam(window_handle, GLFW_CLOSE_REQUESTED))
{
glClear(GL_COLOR_BUFFER_BIT);
+1 -1
View File
@@ -90,7 +90,7 @@ int main(void)
glOrtho(-1.f, 1.f, -1.f, 1.f, 1.f, -1.f);
glMatrixMode(GL_MODELVIEW);
while (glfwGetCurrentContext())
while (!glfwGetWindowParam(window, GLFW_CLOSE_REQUESTED))
{
glClear(GL_COLOR_BUFFER_BIT);
+1 -1
View File
@@ -58,7 +58,7 @@ int main(void)
glfwSetWindowSizeCallback(window_size_callback);
while (glfwGetCurrentContext())
while (!glfwGetWindowParam(window, GLFW_CLOSE_REQUESTED))
{
glClear(GL_COLOR_BUFFER_BIT);
glfwSwapBuffers(window);
+4 -10
View File
@@ -32,14 +32,6 @@
#include <stdio.h>
#include <stdlib.h>
static GLboolean running = GL_TRUE;
static int window_close_callback(GLFWwindow window)
{
running = GL_FALSE;
return GL_TRUE;
}
static const char* titles[] =
{
"Foo",
@@ -51,6 +43,7 @@ static const char* titles[] =
int main(void)
{
int i;
GLboolean running = GL_TRUE;
GLFWwindow windows[4];
if (!glfwInit())
@@ -60,8 +53,6 @@ int main(void)
exit(EXIT_FAILURE);
}
glfwSetWindowCloseCallback(window_close_callback);
for (i = 0; i < 4; i++)
{
windows[i] = glfwCreateWindow(200, 200, GLFW_WINDOWED, titles[i], NULL);
@@ -88,6 +79,9 @@ int main(void)
glfwMakeContextCurrent(windows[i]);
glClear(GL_COLOR_BUFFER_BIT);
glfwSwapBuffers(windows[i]);
if (glfwGetWindowParam(windows[i], GLFW_CLOSE_REQUESTED))
running = GL_FALSE;
}
glfwPollEvents();