mirror of
https://github.com/glfw/glfw.git
synced 2026-11-18 04:44:54 +00:00
Replaced automatic closing with window parameter.
This commit is contained in:
+1
-1
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user