aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/GL/wmesa.h4
-rw-r--r--src/mesa/drivers/windows/gdi/wgl.c30
-rw-r--r--src/mesa/drivers/windows/gdi/wmesa.c35
-rw-r--r--src/mesa/drivers/windows/gdi/wmesadef.h2
4 files changed, 36 insertions, 35 deletions
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 <windows.h>
+#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;i<MESAWGL_CTX_MAX_COUNT;i++) {
wgl_ctx[i].ctx = NULL;
@@ -170,10 +166,11 @@ WINGDIAPI HGLRC GLAPIENTRY wglCreateContext(HDC hdc)
for( i = 0; i < MESAWGL_CTX_MAX_COUNT; i++ ) {
if ( wgl_ctx[i].ctx == NULL ) {
wgl_ctx[i].ctx =
- WMesaCreateContext(hWnd, NULL, GL_TRUE,
- pfd[curPFD-1].doubleBuffered,
- pfd[curPFD-1].pfd.cAlphaBits ?
- GL_TRUE : GL_FALSE);
+ WMesaCreateContext(hdc, NULL, (GLboolean)GL_TRUE,
+ (GLboolean) (pfd[curPFD-1].doubleBuffered ?
+ GL_TRUE : GL_FALSE),
+ (GLboolean)(pfd[curPFD-1].pfd.cAlphaBits ?
+ GL_TRUE : GL_FALSE) );
if (wgl_ctx[i].ctx == NULL)
break;
wgl_ctx[i].hdc = hdc;
@@ -418,7 +415,7 @@ static BOOL wglUseFontBitmaps_FX(HDC fontDevice, DWORD firstChar,
HGDIOBJ origBmap;
unsigned char *bmap;
- curChar = i + firstChar;
+ curChar = (char)(i + firstChar);
// Find how high/wide this character is
VERIFY(GetTextExtentPoint32(bitDevice, &curChar, 1, &size));
@@ -461,8 +458,8 @@ static BOOL wglUseFontBitmaps_FX(HDC fontDevice, DWORD firstChar,
// Create the GL object
glNewList(i + listBase, GL_COMPILE);
- glBitmap(bmapWidth, bmapHeight, 0.0, metric.tmDescent,
- charWidth, 0.0,
+ glBitmap(bmapWidth, bmapHeight, 0.0, (GLfloat)metric.tmDescent,
+ (GLfloat)charWidth, 0.0,
bmap);
glEndList();
// CheckGL();
@@ -559,9 +556,10 @@ WINGDIAPI BOOL GLAPIENTRY wglUseFontBitmapsA(HDC hdc, DWORD first,
}
glBitmap(gm.gmBlackBoxX,gm.gmBlackBoxY,
- -gm.gmptGlyphOrigin.x,
- gm.gmptGlyphOrigin.y,
- gm.gmCellIncX,gm.gmCellIncY,
+ (GLfloat)-gm.gmptGlyphOrigin.x,
+ (GLfloat)gm.gmptGlyphOrigin.y,
+ (GLfloat)gm.gmCellIncX,
+ (GLfloat)gm.gmCellIncY,
(const GLubyte * )lpBits);
GlobalUnlock(hBits);
diff --git a/src/mesa/drivers/windows/gdi/wmesa.c b/src/mesa/drivers/windows/gdi/wmesa.c
index 00cd37550d0..cc68fe622a2 100644
--- a/src/mesa/drivers/windows/gdi/wmesa.c
+++ b/src/mesa/drivers/windows/gdi/wmesa.c
@@ -1,5 +1,5 @@
/*
- * Windows (Win32) device driver for Mesa
+ * Windows (Win32/Win64) device driver for Mesa
*
*/
@@ -890,7 +890,6 @@ static void
wmesa_resize_buffers(GLcontext *ctx, GLframebuffer *buffer,
GLuint width, GLuint height)
{
- RECT CR;
if (Current->width != 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;