* 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
*
* 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);
-/* $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
* we get the right export linkage. */
#define _GDI32_
#include <windows.h>
+#include "glapi.h"
#include "GL/wmesa.h" /* protos for wmesa* functions */
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;
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;
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));
// 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();
}
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);
/*
- * Windows (Win32) device driver for Mesa
+ * Windows (Win32/Win64) device driver for Mesa
*
*/
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;
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);
}
/***** 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;
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);
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 */
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);
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;