Added window positioning to sharing test.

This commit is contained in:
Camilla Berglund 2010-10-04 21:08:42 +02:00
parent 4da3bf7827
commit 2899e8765c

View File

@ -32,11 +32,14 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#define WIDTH 400
#define HEIGHT 400
static GLFWwindow open_window(const char* title, GLFWwindow share) static GLFWwindow open_window(const char* title, GLFWwindow share)
{ {
GLFWwindow window; GLFWwindow window;
window = glfwOpenWindow(400, 400, GLFW_WINDOWED, title, share); window = glfwOpenWindow(WIDTH, HEIGHT, GLFW_WINDOWED, title, share);
if (!window) if (!window)
return NULL; return NULL;
@ -100,6 +103,7 @@ int main(int argc, char** argv)
{ {
GLFWwindow windows[2]; GLFWwindow windows[2];
GLuint texture; GLuint texture;
int x, y;
if (!glfwInit()) if (!glfwInit())
{ {
@ -114,6 +118,8 @@ int main(int argc, char** argv)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
glfwGetWindowPos(windows[0], &x, &y);
// This is the one and only time we create a texture // This is the one and only time we create a texture
// It is created inside the first context created above // It is created inside the first context created above
// It will then be shared with the second context created below // It will then be shared with the second context created below
@ -126,6 +132,8 @@ int main(int argc, char** argv)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
glfwSetWindowPos(windows[1], x + WIDTH + 50, y);
while (glfwIsWindow(windows[0]) && glfwIsWindow(windows[1])) while (glfwIsWindow(windows[0]) && glfwIsWindow(windows[1]))
{ {
glfwMakeWindowCurrent(windows[0]); glfwMakeWindowCurrent(windows[0]);