summaryrefslogtreecommitdiff
path: root/src/mesa/drivers/windows/gdi
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/drivers/windows/gdi')
-rw-r--r--src/mesa/drivers/windows/gdi/wgl.c61
-rw-r--r--src/mesa/drivers/windows/gdi/wmesa.c107
-rw-r--r--src/mesa/drivers/windows/gdi/wmesadef.h4
3 files changed, 129 insertions, 43 deletions
diff --git a/src/mesa/drivers/windows/gdi/wgl.c b/src/mesa/drivers/windows/gdi/wgl.c
index fb23d210db..17eed1dc32 100644
--- a/src/mesa/drivers/windows/gdi/wgl.c
+++ b/src/mesa/drivers/windows/gdi/wgl.c
@@ -33,15 +33,30 @@
/* We're essentially building part of GDI here, so define this so that
* we get the right export linkage. */
#ifdef __MINGW32__
-#include <GL/gl.h>
+
+#include <stdarg.h>
+#include <windef.h>
+#include <wincon.h>
+#include <winbase.h>
+
+# if defined(BUILD_GL32)
+# define WINGDIAPI __declspec(dllexport)
+# else
+# define __W32API_USE_DLLIMPORT__
+# endif
+
+#include <wingdi.h>
+#include "GL/mesa_wgl.h"
#include <stdlib.h>
+
#else
+
#define _GDI32_
-#endif
#include <windows.h>
-#include "glapi.h"
+#endif
+#include "glapi.h"
#include "GL/wmesa.h" /* protos for wmesa* functions */
/*
@@ -339,7 +354,7 @@ WINGDIAPI int GLAPIENTRY wglGetPixelFormat(HDC hdc)
}
WINGDIAPI BOOL GLAPIENTRY wglSetPixelFormat(HDC hdc,int iPixelFormat,
- const PIXELFORMATDESCRIPTOR *ppfd)
+ const PIXELFORMATDESCRIPTOR *ppfd)
{
(void) hdc;
@@ -392,12 +407,12 @@ static BOOL wglUseFontBitmaps_FX(HDC fontDevice, DWORD firstChar,
bitDevice = CreateCompatibleDC(fontDevice);
- // Swap fore and back colors so the bitmap has the right polarity
+ /* Swap fore and back colors so the bitmap has the right polarity */
tempColor = GetBkColor(bitDevice);
SetBkColor(bitDevice, GetTextColor(bitDevice));
SetTextColor(bitDevice, tempColor);
- // Place chars based on base line
+ /* Place chars based on base line */
VERIFY(SetTextAlign(bitDevice, TA_BASELINE) != GDI_ERROR ? 1 : 0);
for(i = 0; i < (int)numChars; i++) {
@@ -410,36 +425,36 @@ static BOOL wglUseFontBitmaps_FX(HDC fontDevice, DWORD firstChar,
curChar = (char)(i + firstChar);
- // Find how high/wide this character is
+ /* Find how high/wide this character is */
VERIFY(GetTextExtentPoint32(bitDevice, &curChar, 1, &size));
- // Create the output bitmap
+ /* Create the output bitmap */
charWidth = size.cx;
charHeight = size.cy;
- // Round up to the next multiple of 32 bits
+ /* Round up to the next multiple of 32 bits */
bmapWidth = ((charWidth + 31) / 32) * 32;
bmapHeight = charHeight;
bitObject = CreateCompatibleBitmap(bitDevice,
bmapWidth,
bmapHeight);
- //VERIFY(bitObject);
+ /* VERIFY(bitObject); */
- // Assign the output bitmap to the device
+ /* Assign the output bitmap to the device */
origBmap = SelectObject(bitDevice, bitObject);
(void) VERIFY(origBmap);
VERIFY( PatBlt( bitDevice, 0, 0, bmapWidth, bmapHeight,BLACKNESS ) );
- // Use our source font on the device
+ /* Use our source font on the device */
VERIFY(SelectObject(bitDevice, GetCurrentObject(fontDevice,OBJ_FONT)));
- // Draw the character
+ /* Draw the character */
VERIFY(TextOut(bitDevice, 0, metric.tmAscent, &curChar, 1));
- // Unselect our bmap object
+ /* Unselect our bmap object */
VERIFY(SelectObject(bitDevice, origBmap));
- // Convert the display dependant representation to a 1 bit deep DIB
+ /* Convert the display dependant representation to a 1 bit deep DIB */
numBytes = (bmapWidth * bmapHeight) / 8;
bmap = malloc(numBytes);
dibInfo->bmiHeader.biWidth = bmapWidth;
@@ -447,24 +462,24 @@ static BOOL wglUseFontBitmaps_FX(HDC fontDevice, DWORD firstChar,
res = GetDIBits(bitDevice, bitObject, 0, bmapHeight, bmap,
dibInfo,
DIB_RGB_COLORS);
- //VERIFY(res);
+ /* VERIFY(res); */
- // Create the GL object
+ /* Create the GL object */
glNewList(i + listBase, GL_COMPILE);
glBitmap(bmapWidth, bmapHeight, 0.0, (GLfloat)metric.tmDescent,
(GLfloat)charWidth, 0.0,
bmap);
glEndList();
- // CheckGL();
+ /* CheckGL(); */
- // Destroy the bmap object
+ /* Destroy the bmap object */
DeleteObject(bitObject);
- // Deallocate the bitmap data
+ /* Deallocate the bitmap data */
free(bmap);
}
- // Destroy the DC
+ /* Destroy the DC */
VERIFY(DeleteDC(bitDevice));
free(dibInfo);
@@ -586,8 +601,8 @@ WINGDIAPI HGLRC GLAPIENTRY wglCreateLayerContext(HDC hdc,
WINGDIAPI BOOL GLAPIENTRY wglShareLists(HGLRC hglrc1,
HGLRC hglrc2)
{
- (void) hglrc1; (void) hglrc2;
- return(TRUE);
+ WMesaShareLists(hglrc1, hglrc2);
+ return(TRUE);
}
diff --git a/src/mesa/drivers/windows/gdi/wmesa.c b/src/mesa/drivers/windows/gdi/wmesa.c
index 2eec188912..7e8a87921b 100644
--- a/src/mesa/drivers/windows/gdi/wmesa.c
+++ b/src/mesa/drivers/windows/gdi/wmesa.c
@@ -6,6 +6,7 @@
#include "wmesadef.h"
#include "colors.h"
#include <GL/wmesa.h>
+#include <winuser.h>
#include "context.h"
#include "extensions.h"
#include "framebuffer.h"
@@ -114,7 +115,7 @@ static void wmSetPixelFormat(WMesaFramebuffer pwfb, HDC hDC)
{
pwfb->cColorBits = GetDeviceCaps(hDC, BITSPIXEL);
- // Only 16 and 32 bit targets are supported now
+ /* Only 16 and 32 bit targets are supported now */
assert(pwfb->cColorBits == 0 ||
pwfb->cColorBits == 16 ||
pwfb->cColorBits == 32);
@@ -457,23 +458,84 @@ static void write_rgba_span_front(const GLcontext *ctx,
const GLubyte rgba[][4],
const GLubyte mask[] )
{
- WMesaContext pwc = wmesa_context(ctx);
- GLuint i;
-
- (void) ctx;
- y=FLIP(y);
- if (mask) {
- for (i=0; i<n; i++)
- if (mask[i])
- SetPixel(pwc->hDC, x+i, y, RGB(rgba[i][RCOMP], rgba[i][GCOMP],
- rgba[i][BCOMP]));
- }
- else {
- for (i=0; i<n; i++)
- SetPixel(pwc->hDC, x+i, y, RGB(rgba[i][RCOMP], rgba[i][GCOMP],
- rgba[i][BCOMP]));
- }
-
+ WMesaContext pwc = wmesa_context(ctx);
+ WMesaFramebuffer pwfb = wmesa_lookup_framebuffer(pwc->hDC);
+ CONST BITMAPINFO bmi=
+ {
+ {
+ sizeof(BITMAPINFOHEADER),
+ n, 1, 1, 32, BI_RGB, 0, 1, 1, 0, 0
+ }
+ };
+ HBITMAP bmp=0;
+ HDC mdc=0;
+ typedef union
+ {
+ unsigned i;
+ struct {
+ unsigned b:8, g:8, r:8, a:8;
+ };
+ } BGRA;
+ BGRA *bgra, c;
+ int i;
+
+ if (n < 16) { // the value 16 is just guessed
+ y=FLIP(y);
+ if (mask) {
+ for (i=0; i<n; i++)
+ if (mask[i])
+ SetPixel(pwc->hDC, x+i, y,
+ RGB(rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]));
+ }
+ else {
+ for (i=0; i<n; i++)
+ SetPixel(pwc->hDC, x+i, y,
+ RGB(rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]));
+ }
+ }
+ else {
+ if (!pwfb) {
+ _mesa_problem(NULL, "wmesa: write_rgba_span_front on unknown hdc");
+ return;
+ }
+ bgra=malloc(n*sizeof(BGRA));
+ if (!bgra) {
+ _mesa_problem(NULL, "wmesa: write_rgba_span_front: out of memory");
+ return;
+ }
+ c.a=0;
+ if (mask) {
+ for (i=0; i<n; i++) {
+ if (mask[i]) {
+ c.r=rgba[i][RCOMP];
+ c.g=rgba[i][GCOMP];
+ c.b=rgba[i][BCOMP];
+ c.a=rgba[i][ACOMP];
+ bgra[i]=c;
+ }
+ else
+ bgra[i].i=0;
+ }
+ }
+ else {
+ for (i=0; i<n; i++) {
+ c.r=rgba[i][RCOMP];
+ c.g=rgba[i][GCOMP];
+ c.b=rgba[i][BCOMP];
+ c.a=rgba[i][ACOMP];
+ bgra[i]=c;
+ }
+ }
+ bmp=CreateBitmap(n, 1, 1, 32, bgra);
+ mdc=CreateCompatibleDC(pwfb->hDC);
+ SelectObject(mdc, bmp);
+ y=FLIP(y);
+ BitBlt(pwfb->hDC, x, y, n, 1, mdc, 0, 0, SRCCOPY);
+ SelectObject(mdc, 0);
+ DeleteObject(bmp);
+ DeleteDC(mdc);
+ free(bgra);
+ }
}
/* Write a horizontal span of RGB color pixels with a boolean mask. */
@@ -1171,7 +1233,7 @@ WMesaContext WMesaCreateContext(HDC hDC,
/* I do not understand this contributed code */
/* Support memory and device contexts */
if(WindowFromDC(hDC) != NULL) {
- c->hDC = GetDC(WindowFromDC(hDC)); // huh ????
+ c->hDC = GetDC(WindowFromDC(hDC)); /* huh ???? */
}
else {
c->hDC = hDC;
@@ -1400,10 +1462,16 @@ void WMesaSwapBuffers( HDC hdc )
}
}
+void WMesaShareLists(WMesaContext ctx_to_share, WMesaContext ctx)
+{
+ _mesa_share_state(&ctx->gl_ctx, &ctx_to_share->gl_ctx);
+}
+
/* This is hopefully a temporary hack to define some needed dispatch
* table entries. Hopefully, I'll find a better solution. The
* dispatch table generation scripts ought to be making these dummy
* stubs as well. */
+#if !defined(__MINGW32__) || !defined(GL_NO_STDCALL)
void gl_dispatch_stub_543(void){}
void gl_dispatch_stub_544(void){}
void gl_dispatch_stub_545(void){}
@@ -1471,3 +1539,4 @@ void gl_dispatch_stub_769(void){}
void gl_dispatch_stub_770(void){}
void gl_dispatch_stub_771(void){}
+#endif
diff --git a/src/mesa/drivers/windows/gdi/wmesadef.h b/src/mesa/drivers/windows/gdi/wmesadef.h
index 97b063a8ba..83a42e6082 100644
--- a/src/mesa/drivers/windows/gdi/wmesadef.h
+++ b/src/mesa/drivers/windows/gdi/wmesadef.h
@@ -1,6 +1,8 @@
#ifndef WMESADEF_H
#define WMESADEF_H
-
+#ifdef __MINGW32__
+#include <windows.h>
+#endif
#include "context.h"