summaryrefslogtreecommitdiff
path: root/progs/wgl/sharedtex_mt/sharedtex_mt.c
diff options
context:
space:
mode:
authorDave Airlie <airlied@linux.ie>2009-03-22 12:01:21 +1000
committerDave Airlie <airlied@linux.ie>2009-03-22 12:01:21 +1000
commit2d26d4ac66e8c3e48b73d3e172d0e0d2a2ad31a5 (patch)
tree6b0d899db605b28e10b9b953d181b09bf40bb472 /progs/wgl/sharedtex_mt/sharedtex_mt.c
parent407e8ae5b167b0193e1e5b1266a5d61ed836dfb5 (diff)
parent699897e81c623e53be51fba0488f535b0a8d7761 (diff)
Merge remote branch 'origin/master' into HEAD
Diffstat (limited to 'progs/wgl/sharedtex_mt/sharedtex_mt.c')
-rw-r--r--progs/wgl/sharedtex_mt/sharedtex_mt.c67
1 files changed, 37 insertions, 30 deletions
diff --git a/progs/wgl/sharedtex_mt/sharedtex_mt.c b/progs/wgl/sharedtex_mt/sharedtex_mt.c
index 137c9c10af..010eb873b8 100644
--- a/progs/wgl/sharedtex_mt/sharedtex_mt.c
+++ b/progs/wgl/sharedtex_mt/sharedtex_mt.c
@@ -49,6 +49,7 @@ struct window {
HGLRC Context;
float Angle;
int Id;
+ HGLRC sharedContext;
};
@@ -172,8 +173,6 @@ AddWindow(int xpos, int ypos, HGLRC sCtx)
{
struct window *win = &Windows[NumWindows];
WNDCLASS wc = {0};
- PIXELFORMATDESCRIPTOR pfd = {0};
- int visinfo;
int width = 300, height = 300;
if (NumWindows >= MAX_WINDOWS)
@@ -208,33 +207,7 @@ AddWindow(int xpos, int ypos, HGLRC sCtx)
Error("Couldn't create window");
}
- win->hDC = GetDC(win->Win);
- if (!win->hDC) {
- Error("Couldn't obtain HDC");
- }
-
- pfd.cColorBits = 24;
- pfd.cDepthBits = 24;
- pfd.dwFlags = PFD_DOUBLEBUFFER | PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL;
- pfd.iLayerType = PFD_MAIN_PLANE;
- pfd.iPixelType = PFD_TYPE_RGBA;
- pfd.nSize = sizeof(pfd);
- pfd.nVersion = 1;
-
- visinfo = ChoosePixelFormat(win->hDC, &pfd);
- if (!visinfo) {
- Error("Unable to find RGB, Z, double-buffered visual");
- }
-
- SetPixelFormat(win->hDC, visinfo, &pfd);
- win->Context = wglCreateContext(win->hDC);
- if (!win->Context) {
- Error("Couldn't create WGL context");
- }
-
- if (sCtx) {
- wglShareLists(sCtx, win->Context);
- }
+ win->sharedContext = sCtx;
ShowWindow(win->Win, SW_SHOW);
@@ -244,7 +217,6 @@ AddWindow(int xpos, int ypos, HGLRC sCtx)
static void
InitGLstuff(void)
-
{
glGenTextures(3, Textures);
@@ -432,9 +404,41 @@ threadRunner (void *arg)
{
struct thread_init_arg *tia = (struct thread_init_arg *) arg;
struct window *win;
+ PIXELFORMATDESCRIPTOR pfd = {0};
+ int visinfo;
win = &Windows[tia->id];
+ win->hDC = GetDC(win->Win);
+ if (!win->hDC) {
+ Error("Couldn't obtain HDC");
+ }
+
+ pfd.cColorBits = 24;
+ pfd.cDepthBits = 24;
+ pfd.dwFlags = PFD_DOUBLEBUFFER | PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL;
+ pfd.iLayerType = PFD_MAIN_PLANE;
+ pfd.iPixelType = PFD_TYPE_RGBA;
+ pfd.nSize = sizeof(pfd);
+ pfd.nVersion = 1;
+
+ visinfo = ChoosePixelFormat(win->hDC, &pfd);
+ if (!visinfo) {
+ Error("Unable to find RGB, Z, double-buffered visual");
+ }
+
+ SetPixelFormat(win->hDC, visinfo, &pfd);
+ win->Context = wglCreateContext(win->hDC);
+ if (!win->Context) {
+ Error("Couldn't create WGL context");
+ }
+
+ if (win->sharedContext) {
+ wglShareLists(win->sharedContext, win->Context);
+ }
+
+ SendMessage(win->Win, WM_SIZE, 0, 0);
+
while (1) {
MSG msg;
@@ -464,6 +468,9 @@ threadRunner (void *arg)
static void
Resize(struct window *h, unsigned int width, unsigned int height)
{
+ if (!h->Context)
+ return;
+
EnterCriticalSection(&h->drawMutex);
if (!wglMakeCurrent(h->hDC, h->Context)) {