Add support for memory contexts (Thomas Kaltofen). Cleanup compilation warnings.

This commit is contained in:
Karl Schultz 2005-09-05 14:48:39 +00:00
parent e15c2d077a
commit f66084b834
4 changed files with 36 additions and 35 deletions

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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;