From f66084b834ce37e7f0143e456df1265cd343a674 Mon Sep 17 00:00:00 2001 From: Karl Schultz Date: Mon, 5 Sep 2005 14:48:39 +0000 Subject: Add support for memory contexts (Thomas Kaltofen). Cleanup compilation warnings. --- src/mesa/drivers/windows/gdi/wgl.c | 30 +++++++++++++--------------- src/mesa/drivers/windows/gdi/wmesa.c | 35 +++++++++++++++++++-------------- src/mesa/drivers/windows/gdi/wmesadef.h | 2 -- 3 files changed, 34 insertions(+), 33 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/drivers/windows/gdi/wgl.c b/src/mesa/drivers/windows/gdi/wgl.c index 2d3f696fb55..1f69f73f9a8 100644 --- a/src/mesa/drivers/windows/gdi/wgl.c +++ b/src/mesa/drivers/windows/gdi/wgl.c @@ -1,4 +1,4 @@ -/* $Id: wgl.c,v 1.9 2005/07/01 15:56:14 kschultz Exp $ */ +/* $Id: wgl.c,v 1.10 2005/09/05 14:48:39 kschultz Exp $ */ /* * This library is free software; you can redistribute it and/or @@ -34,6 +34,7 @@ * we get the right export linkage. */ #define _GDI32_ #include +#include "glapi.h" #include "GL/wmesa.h" /* protos for wmesa* functions */ @@ -155,12 +156,7 @@ static unsigned curPFD = 0; WINGDIAPI HGLRC GLAPIENTRY wglCreateContext(HDC hdc) { - HWND hWnd; int i = 0; - if(!(hWnd = WindowFromDC(hdc))) { - SetLastError(0); - return(NULL); - } if (!ctx_count) { for(i=0;iwidth != width || Current->height != height) { Current->width = width; Current->height = height; @@ -899,9 +898,6 @@ wmesa_resize_buffers(GLcontext *ctx, GLframebuffer *buffer, wmDeleteBackingStore(Current); wmCreateBackingStore(Current, width, height); } - GetClientRect(Current->Window, &CR); - Current->width = CR.right; - Current->height = CR.bottom; } _mesa_resize_framebuffer(ctx, buffer, width, height); } @@ -954,13 +950,12 @@ static void wmesa_update_state(GLcontext *ctx, GLuint new_state) /***** WMESA Functions *****/ /**********************************************************************/ -WMesaContext WMesaCreateContext(HWND hWnd, +WMesaContext WMesaCreateContext(HDC hDC, HPALETTE* Pal, GLboolean rgb_flag, GLboolean db_flag, GLboolean alpha_flag) { - RECT CR; WMesaContext c; struct dd_function_table functions; struct gl_renderbuffer *rb; @@ -974,12 +969,18 @@ WMesaContext WMesaCreateContext(HWND hWnd, c = CALLOC_STRUCT(wmesa_context); if (!c) return NULL; - - c->Window = hWnd; - c->hDC = GetDC(hWnd); - GetClientRect(c->Window, &CR); - c->width = CR.right; - c->height = CR.bottom; + + /* Support memory and device contexts */ + if(WindowFromDC(hDC) != NULL) + { + c->hDC = GetDC(WindowFromDC(hDC)); + } + else + { + c->hDC = hDC; + } + c->width = GetDeviceCaps(c->hDC, HORZRES); + c->height = GetDeviceCaps(c->hDC, VERTRES); c->clearPen = CreatePen(PS_SOLID, 1, 0); c->clearBrush = CreateSolidBrush(0); @@ -997,7 +998,7 @@ WMesaContext WMesaCreateContext(HWND hWnd, 8,8,8, /* color RGB */ alpha_flag ? 8 : 0, /* color A */ 0, /* index bits */ - 16, /* depth_bits */ + DEFAULT_SOFTWARE_DEPTH_BITS, /* depth_bits */ 8, /* stencil_bits */ 16,16,16, /* accum RGB */ alpha_flag ? 16 : 0, /* accum A */ @@ -1133,7 +1134,11 @@ void WMesaDestroyContext( void ) WMesaMakeCurrent(NULL); - ReleaseDC(c->Window, c->hDC); + /* Release for device, not memory contexts */ + if(WindowFromDC(c->hDC) != NULL) + { + ReleaseDC(WindowFromDC(c->hDC), c->hDC); + } DeleteObject(c->clearPen); DeleteObject(c->clearBrush); diff --git a/src/mesa/drivers/windows/gdi/wmesadef.h b/src/mesa/drivers/windows/gdi/wmesadef.h index 9aa0ab20b79..a9d0a447def 100644 --- a/src/mesa/drivers/windows/gdi/wmesadef.h +++ b/src/mesa/drivers/windows/gdi/wmesadef.h @@ -12,8 +12,6 @@ typedef struct wmesa_context{ GLcontext *gl_ctx; /* The core GL/Mesa context */ GLvisual *gl_visual; /* Describes the buffers */ GLframebuffer *gl_buffer; /* Depth, stencil, accum, etc buffers*/ - - HWND Window; HDC hDC; COLORREF clearColorRef; HPEN clearPen; -- cgit v1.2.3