From: Karl Schultz Date: Mon, 5 Sep 2005 14:48:39 +0000 (+0000) Subject: Add support for memory contexts (Thomas Kaltofen). Cleanup compilation warnings. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f66084b834ce37e7f0143e456df1265cd343a674;p=mesa.git Add support for memory contexts (Thomas Kaltofen). Cleanup compilation warnings. --- diff --git a/include/GL/wmesa.h b/include/GL/wmesa.h index 0a6e8b64246..66f3dbe82f0 100644 --- a/include/GL/wmesa.h +++ b/include/GL/wmesa.h @@ -78,7 +78,7 @@ typedef struct wmesa_context *WMesaContext; * appropriate colormap. * * Input: - * hWnd - Window handle + * hDC - Windows device or memory context * Pal - Palette to use * rgb_flag - GL_TRUE = RGB mode, * GL_FALSE = color index mode @@ -91,7 +91,7 @@ typedef struct wmesa_context *WMesaContext; * * Return: a WMesa_context or NULL if error. */ -extern WMesaContext WMesaCreateContext(HWND hWnd,HPALETTE* pPal, +extern WMesaContext WMesaCreateContext(HDC hDC,HPALETTE* pPal, GLboolean rgb_flag, GLboolean db_flag, GLboolean alpha_flag); 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;