mirror of
https://github.com/gwm17/glfw.git
synced 2024-11-26 20:28:49 -05:00
Improved multi-window test.
Fixed proper Windows colors. Added support for Escape key. Made windows undecorated. Added command-line option for decorated windows.
This commit is contained in:
parent
5abf7841f8
commit
8d4ba0aa83
|
@ -32,12 +32,23 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
static const char* titles[4] =
|
static const char* titles[] =
|
||||||
{
|
{
|
||||||
"Foo",
|
"Red",
|
||||||
"Bar",
|
"Green",
|
||||||
"Baz",
|
"Blue",
|
||||||
"Quux"
|
"Yellow"
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct
|
||||||
|
{
|
||||||
|
float r, g, b;
|
||||||
|
} colors[] =
|
||||||
|
{
|
||||||
|
{ 0.95f, 0.32f, 0.11f },
|
||||||
|
{ 0.50f, 0.80f, 0.16f },
|
||||||
|
{ 0.f, 0.68f, 0.94f },
|
||||||
|
{ 0.98f, 0.74f, 0.04f }
|
||||||
};
|
};
|
||||||
|
|
||||||
static void error_callback(int error, const char* description)
|
static void error_callback(int error, const char* description)
|
||||||
|
@ -47,15 +58,26 @@ static void error_callback(int error, const char* description)
|
||||||
|
|
||||||
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)
|
||||||
|
return;
|
||||||
|
|
||||||
|
switch (key)
|
||||||
{
|
{
|
||||||
int xpos, ypos;
|
case GLFW_KEY_SPACE:
|
||||||
glfwGetWindowPos(window, &xpos, &ypos);
|
{
|
||||||
glfwSetWindowPos(window, xpos, ypos);
|
int xpos, ypos;
|
||||||
|
glfwGetWindowPos(window, &xpos, &ypos);
|
||||||
|
glfwSetWindowPos(window, xpos, ypos);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case GLFW_KEY_ESCAPE:
|
||||||
|
glfwSetWindowShouldClose(window, GL_TRUE);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(void)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
GLboolean running = GL_TRUE;
|
GLboolean running = GL_TRUE;
|
||||||
|
@ -66,6 +88,7 @@ int main(void)
|
||||||
if (!glfwInit())
|
if (!glfwInit())
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|
||||||
|
glfwWindowHint(GLFW_DECORATED, GL_FALSE);
|
||||||
glfwWindowHint(GLFW_VISIBLE, GL_FALSE);
|
glfwWindowHint(GLFW_VISIBLE, GL_FALSE);
|
||||||
|
|
||||||
for (i = 0; i < 4; i++)
|
for (i = 0; i < 4; i++)
|
||||||
|
@ -82,10 +105,7 @@ int main(void)
|
||||||
glfwSetKeyCallback(windows[i], key_callback);
|
glfwSetKeyCallback(windows[i], key_callback);
|
||||||
|
|
||||||
glfwMakeContextCurrent(windows[i]);
|
glfwMakeContextCurrent(windows[i]);
|
||||||
glClearColor((GLclampf) (i & 1),
|
glClearColor(colors[i].r, colors[i].g, colors[i].b, 1.f);
|
||||||
(GLclampf) (i >> 1),
|
|
||||||
i ? 0.f : 1.f,
|
|
||||||
0.f);
|
|
||||||
|
|
||||||
glfwGetWindowFrameSize(windows[i], &left, &top, &right, &bottom);
|
glfwGetWindowFrameSize(windows[i], &left, &top, &right, &bottom);
|
||||||
glfwSetWindowPos(windows[i],
|
glfwSetWindowPos(windows[i],
|
||||||
|
|
Loading…
Reference in New Issue
Block a user