mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-01 10:18:05 +02:00
Fixes from Brian to help migrate to render buffer DD interfaces. Also fix bug in the viewport function that was using the viewport size to resize the buffer, when it should have been using the window size. Fix bug in write_rgb_span_32 where the incoming pixel data parameter was coded as a [][4] instead of [][3]. Now all the demos work correctly except singlebuffer.
This commit is contained in:
parent
a8c9ecfab0
commit
87af12dbdc
3 changed files with 418 additions and 296 deletions
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: wgl.c,v 1.11 2006/01/25 06:02:55 kschultz Exp $ */
|
||||
/* $Id: wgl.c,v 1.12 2006/03/30 07:58:24 kschultz Exp $ */
|
||||
|
||||
/*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
|
|
@ -38,8 +38,6 @@
|
|||
|
||||
#include "GL/wmesa.h" /* protos for wmesa* functions */
|
||||
|
||||
typedef struct wmesa_context *PWMC;
|
||||
|
||||
/*
|
||||
* Pixel Format Descriptors
|
||||
*/
|
||||
|
|
@ -143,7 +141,6 @@ int npfd = sizeof(pfd) / sizeof(pfd[0]);
|
|||
|
||||
typedef struct {
|
||||
WMesaContext ctx;
|
||||
HDC hdc;
|
||||
} MesaWglCtx;
|
||||
|
||||
#define MESAWGL_CTX_MAX_COUNT 20
|
||||
|
|
@ -154,13 +151,15 @@ static unsigned ctx_count = 0;
|
|||
static int ctx_current = -1;
|
||||
static unsigned curPFD = 0;
|
||||
|
||||
static HDC CurrentHDC = 0;
|
||||
|
||||
|
||||
WINGDIAPI HGLRC GLAPIENTRY wglCreateContext(HDC hdc)
|
||||
{
|
||||
int i = 0;
|
||||
if (!ctx_count) {
|
||||
for(i=0;i<MESAWGL_CTX_MAX_COUNT;i++) {
|
||||
wgl_ctx[i].ctx = NULL;
|
||||
wgl_ctx[i].hdc = NULL;
|
||||
}
|
||||
}
|
||||
for( i = 0; i < MESAWGL_CTX_MAX_COUNT; i++ ) {
|
||||
|
|
@ -173,7 +172,6 @@ WINGDIAPI HGLRC GLAPIENTRY wglCreateContext(HDC hdc)
|
|||
GL_TRUE : GL_FALSE) );
|
||||
if (wgl_ctx[i].ctx == NULL)
|
||||
break;
|
||||
wgl_ctx[i].hdc = hdc;
|
||||
ctx_count++;
|
||||
return ((HGLRC)wgl_ctx[i].ctx);
|
||||
}
|
||||
|
|
@ -186,11 +184,10 @@ WINGDIAPI BOOL GLAPIENTRY wglDeleteContext(HGLRC hglrc)
|
|||
{
|
||||
int i;
|
||||
for ( i = 0; i < MESAWGL_CTX_MAX_COUNT; i++ ) {
|
||||
if ( wgl_ctx[i].ctx == (PWMC) hglrc ){
|
||||
WMesaMakeCurrent((PWMC) hglrc);
|
||||
WMesaDestroyContext();
|
||||
if ( wgl_ctx[i].ctx == (WMesaContext) hglrc ){
|
||||
WMesaMakeCurrent((WMesaContext) hglrc, NULL);
|
||||
WMesaDestroyContext(wgl_ctx[i].ctx);
|
||||
wgl_ctx[i].ctx = NULL;
|
||||
wgl_ctx[i].hdc = NULL;
|
||||
ctx_count--;
|
||||
return(TRUE);
|
||||
}
|
||||
|
|
@ -209,26 +206,24 @@ WINGDIAPI HGLRC GLAPIENTRY wglGetCurrentContext(VOID)
|
|||
|
||||
WINGDIAPI HDC GLAPIENTRY wglGetCurrentDC(VOID)
|
||||
{
|
||||
if (ctx_current < 0)
|
||||
return 0;
|
||||
else
|
||||
return wgl_ctx[ctx_current].hdc;
|
||||
return CurrentHDC;
|
||||
}
|
||||
|
||||
WINGDIAPI BOOL GLAPIENTRY wglMakeCurrent(HDC hdc,HGLRC hglrc)
|
||||
WINGDIAPI BOOL GLAPIENTRY wglMakeCurrent(HDC hdc, HGLRC hglrc)
|
||||
{
|
||||
int i;
|
||||
|
||||
CurrentHDC = hdc;
|
||||
|
||||
if (!hdc || !hglrc) {
|
||||
WMesaMakeCurrent(NULL);
|
||||
WMesaMakeCurrent(NULL, NULL);
|
||||
ctx_current = -1;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
for ( i = 0; i < MESAWGL_CTX_MAX_COUNT; i++ ) {
|
||||
if ( wgl_ctx[i].ctx == (PWMC) hglrc ) {
|
||||
wgl_ctx[i].hdc = hdc;
|
||||
WMesaMakeCurrent( (WMesaContext) hglrc );
|
||||
if ( wgl_ctx[i].ctx == (WMesaContext) hglrc ) {
|
||||
WMesaMakeCurrent( (WMesaContext) hglrc, hdc );
|
||||
ctx_current = i;
|
||||
return TRUE;
|
||||
}
|
||||
|
|
@ -353,16 +348,8 @@ WINGDIAPI BOOL GLAPIENTRY wglSetPixelFormat(HDC hdc,int iPixelFormat,
|
|||
|
||||
WINGDIAPI BOOL GLAPIENTRY wglSwapBuffers(HDC hdc)
|
||||
{
|
||||
(void) hdc;
|
||||
if (ctx_current < 0)
|
||||
return FALSE;
|
||||
|
||||
if(wgl_ctx[ctx_current].ctx == NULL) {
|
||||
SetLastError(0);
|
||||
return(FALSE);
|
||||
}
|
||||
WMesaSwapBuffers();
|
||||
return(TRUE);
|
||||
WMesaSwapBuffers(hdc);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static FIXED FixedFromDouble(double d)
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -1,27 +1,28 @@
|
|||
#ifndef WMESADEF_H
|
||||
#define WMESADEF_H
|
||||
|
||||
#include "context.h"
|
||||
|
||||
typedef struct _dibSection{
|
||||
typedef struct _dibSection {
|
||||
HDC hDC;
|
||||
HANDLE hFileMap;
|
||||
BOOL fFlushed;
|
||||
LPVOID base;
|
||||
}WMDIBSECTION, *PWMDIBSECTION;
|
||||
} WMDIBSECTION, *PWMDIBSECTION;
|
||||
|
||||
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*/
|
||||
/**
|
||||
* The Windows Mesa rendering context, derived from GLcontext.
|
||||
*/
|
||||
struct wmesa_context {
|
||||
GLcontext gl_ctx; /* The core GL/Mesa context */
|
||||
HDC hDC;
|
||||
COLORREF clearColorRef;
|
||||
HPEN clearPen;
|
||||
HBRUSH clearBrush;
|
||||
GLuint width;
|
||||
GLuint height;
|
||||
GLuint ScanWidth;
|
||||
GLboolean rgb_flag;
|
||||
GLboolean db_flag;
|
||||
GLboolean alpha_flag;
|
||||
GLuint ScanWidth; /* XXX move into wmesa_framebuffer */
|
||||
GLboolean rgb_flag; /* XXX remove - use gl_visual field */
|
||||
GLboolean db_flag; /* XXX remove - use gl_visual field */
|
||||
GLboolean alpha_flag; /* XXX remove - use gl_visual field */
|
||||
WMDIBSECTION dib;
|
||||
BITMAPINFO bmi;
|
||||
HBITMAP hbmDIB;
|
||||
|
|
@ -29,6 +30,20 @@ typedef struct wmesa_context{
|
|||
PBYTE pbPixels;
|
||||
BYTE cColorBits;
|
||||
int pixelformat;
|
||||
} *PWMC;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Windows framebuffer, derived from gl_framebuffer
|
||||
*/
|
||||
struct wmesa_framebuffer
|
||||
{
|
||||
struct gl_framebuffer Base;
|
||||
HDC hdc;
|
||||
struct wmesa_framebuffer *next;
|
||||
};
|
||||
|
||||
typedef struct wmesa_framebuffer *WMesaFramebuffer;
|
||||
|
||||
|
||||
#endif /* WMESADEF_H */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue