Reintroduced glfwGetWindowPos, glfwSetWindowPos.

This commit is contained in:
Camilla Berglund
2013-01-24 19:30:31 +01:00
parent ee5f30ea8f
commit 7c1932381b
11 changed files with 191 additions and 125 deletions

View File

@@ -35,6 +35,7 @@
#define WIDTH 400
#define HEIGHT 400
#define OFFSET 50
static GLFWwindow* windows[2];
static GLboolean closed = GL_FALSE;
@@ -60,14 +61,15 @@ static GLFWwindow* open_window(const char* title, GLFWwindow* share, int posX, i
{
GLFWwindow* window;
glfwWindowHint(GLFW_POSITION_X, posX);
glfwWindowHint(GLFW_POSITION_Y, posY);
glfwWindowHint(GLFW_VISIBLE, GL_FALSE);
window = glfwCreateWindow(WIDTH, HEIGHT, title, NULL, share);
if (!window)
return NULL;
glfwMakeContextCurrent(window);
glfwSwapInterval(1);
glfwSetWindowPos(window, posX, posY);
glfwShowWindow(window);
glfwSetWindowCloseCallback(window, window_close_callback);
glfwSetKeyCallback(window, key_callback);
@@ -131,6 +133,7 @@ static void draw_quad(GLuint texture)
int main(int argc, char** argv)
{
int x, y, width;
GLuint texture;
glfwSetErrorCallback(error_callback);
@@ -138,7 +141,7 @@ int main(int argc, char** argv)
if (!glfwInit())
exit(EXIT_FAILURE);
windows[0] = open_window("First", NULL, 0, 0);
windows[0] = open_window("First", NULL, OFFSET, OFFSET);
if (!windows[0])
{
glfwTerminate();
@@ -150,8 +153,11 @@ int main(int argc, char** argv)
// It will then be shared with the second context, created below
texture = create_texture();
glfwGetWindowPos(windows[0], &x, &y);
glfwGetWindowSize(windows[0], &width, NULL);
// Put the second window to the right of the first one
windows[1] = open_window("Second", windows[0], WIDTH + 50, 0);
windows[1] = open_window("Second", windows[0], x + width + OFFSET, y);
if (!windows[1])
{
glfwTerminate();

View File

@@ -90,10 +90,10 @@ int main(void)
if (!glfwInit())
exit(EXIT_FAILURE);
glfwWindowHint(GLFW_VISIBLE, GL_FALSE);
for (i = 0; i < count; i++)
{
glfwWindowHint(GLFW_POSITION_X, 200 + 250 * i);
glfwWindowHint(GLFW_POSITION_Y, 200);
threads[i].window = glfwCreateWindow(200, 200,
threads[i].title,
NULL, NULL);
@@ -103,6 +103,9 @@ int main(void)
exit(EXIT_FAILURE);
}
glfwSetWindowPos(threads[i].window, 200 + 250 * i, 200);
glfwShowWindow(threads[i].window);
if (thrd_create(&threads[i].id, thread_main, threads + i) !=
thrd_success)
{

View File

@@ -56,10 +56,10 @@ int main(void)
if (!glfwInit())
exit(EXIT_FAILURE);
glfwWindowHint(GLFW_VISIBLE, GL_FALSE);
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, titles[i], NULL, NULL);
if (!windows[i])
{
@@ -72,6 +72,9 @@ int main(void)
(GLclampf) (i >> 1),
i ? 0.f : 1.f,
0.f);
glfwSetWindowPos(windows[i], 100 + (i & 1) * 300, 100 + (i >> 1) * 300);
glfwShowWindow(windows[i]);
}
while (running)