Introduced window positioning hints and window position properties

This commit is contained in:
m@bitsnbites.eu
2012-10-28 00:23:28 +02:00
committed by m
parent 2b4c556cd0
commit c9f4dedd96
10 changed files with 59 additions and 14 deletions
+6 -8
View File
@@ -51,10 +51,12 @@ static int window_close_callback(GLFWwindow window)
return GL_FALSE;
}
static GLFWwindow open_window(const char* title, GLFWwindow share)
static GLFWwindow open_window(const char* title, GLFWwindow share, int posX, int posY)
{
GLFWwindow window;
glfwWindowHint(GLFW_POSITION_X, posX);
glfwWindowHint(GLFW_POSITION_Y, posY);
window = glfwCreateWindow(WIDTH, HEIGHT, GLFW_WINDOWED, title, share);
if (!window)
return NULL;
@@ -125,7 +127,6 @@ static void draw_quad(GLuint texture)
int main(int argc, char** argv)
{
GLuint texture;
int x, y;
if (!glfwInit())
{
@@ -133,7 +134,7 @@ int main(int argc, char** argv)
exit(EXIT_FAILURE);
}
windows[0] = open_window("First", NULL);
windows[0] = open_window("First", NULL, 0, 0);
if (!windows[0])
{
fprintf(stderr, "Failed to open first GLFW window: %s\n", glfwErrorString(glfwGetError()));
@@ -147,7 +148,8 @@ int main(int argc, char** argv)
// It will then be shared with the second context, created below
texture = create_texture();
windows[1] = open_window("Second", windows[0]);
// Put the second window to the right of the first one
windows[1] = open_window("Second", windows[0], WIDTH + 50, 0);
if (!windows[1])
{
fprintf(stderr, "Failed to open second GLFW window: %s\n", glfwErrorString(glfwGetError()));
@@ -161,10 +163,6 @@ int main(int argc, char** argv)
glColor3f(0.6f, 0.f, 0.6f);
glfwCopyContext(windows[0], windows[1], GL_CURRENT_BIT);
// Put the second window to the right of the first one
glfwGetWindowPos(windows[0], &x, &y);
glfwSetWindowPos(windows[1], x + WIDTH + 50, y);
while (!closed)
{
glfwMakeContextCurrent(windows[0]);
+2 -2
View File
@@ -89,6 +89,8 @@ int main(void)
for (i = 0; i < count; i++)
{
glfwWindowHint(GLFW_POSITION_X, 200 + 250 * i);
glfwWindowHint(GLFW_POSITION_Y, 200);
threads[i].window = glfwCreateWindow(200, 200,
GLFW_WINDOWED,
threads[i].title,
@@ -100,8 +102,6 @@ int main(void)
exit(EXIT_FAILURE);
}
glfwSetWindowPos(threads[i].window, 200 + 250 * i, 200);
if (thrd_create(&threads[i].id, thread_main, threads + i) !=
thrd_success)
{
+2 -2
View File
@@ -55,6 +55,8 @@ int main(void)
for (i = 0; i < 4; i++)
{
glfwWindowHint(GLFW_POSITION_X, 100 + (i & 1) * 300);
glfwWindowHint(GLFW_POSITION_Y, 100 + (i >> 1) * 300);
windows[i] = glfwCreateWindow(200, 200, GLFW_WINDOWED, titles[i], NULL);
if (!windows[i])
{
@@ -70,8 +72,6 @@ int main(void)
(GLclampf) (i >> 1),
i ? 0.f : 1.f,
0.f);
glfwSetWindowPos(windows[i], 100 + (i & 1) * 300, 100 + (i >> 1) * 300);
}
while (running)