mirror of
https://github.com/reactos/reactos.git
synced 2024-12-29 02:25:17 +00:00
Patch from Gregor Anich:
NeHe Lesson 3 works (crashes at close); Lesson 8 does not work - fixed some bugs in wgl.c and disable asm proxy functions for the moment because they crash svn path=/trunk/; revision=8152
This commit is contained in:
parent
6deb9707f4
commit
d54eeab6a3
5 changed files with 43 additions and 72 deletions
|
@ -7,7 +7,7 @@ TARGET_NORC = yes
|
|||
TARGET_NAME = opengl32
|
||||
|
||||
# -fno-builtin
|
||||
TARGET_CFLAGS = -D__USE_W32API -DUNICODE -D_M_IX86 -Os
|
||||
TARGET_CFLAGS = -D__USE_W32API -DUNICODE -D_M_IX86 -Os -g3
|
||||
|
||||
# require os code to explicitly request A/W version of structs/functions
|
||||
TARGET_CFLAGS += -D_DISABLE_TIDENTS -Wall -Werror
|
||||
|
@ -21,7 +21,7 @@ TARGET_OBJECTS = \
|
|||
gl.o \
|
||||
opengl32.o \
|
||||
wgl.o \
|
||||
tebimports.o
|
||||
#tebimports.o
|
||||
|
||||
DEP_OBJECTS = $(TARGET_OBJECTS)
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ int STDCALL glEmptyFunc56( long l1, long l2, long l3, long l4, long l5,
|
|||
long l11, long l12, long l13, long l14 )
|
||||
{ return 0; }
|
||||
|
||||
#if !defined(_M_IX86)
|
||||
#if 1//!defined(_M_IX86)
|
||||
# define X(func, ret, typeargs, args, icdidx, tebidx, stack) \
|
||||
ret STDCALL func typeargs \
|
||||
{ \
|
||||
|
|
|
@ -16,7 +16,7 @@ typedef struct tagICDTable
|
|||
{
|
||||
DWORD num_funcs; /* Normally 336 (0x150) */
|
||||
PROC dispatch_table[812];
|
||||
} ICDTable;
|
||||
} ICDTable, *PICDTable;
|
||||
|
||||
#endif /* OPENGL32_PRIVATE_ICDTABLE_H */
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: opengl32.h,v 1.12 2004/02/09 08:00:15 vizzini Exp $
|
||||
/* $Id: opengl32.h,v 1.13 2004/02/11 17:39:24 vizzini Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -75,21 +75,6 @@ ULONG DbgPrint(PCH Format,...);
|
|||
/* gl function list */
|
||||
#include "glfuncs.h"
|
||||
|
||||
/* table indices for funcnames and function pointers */
|
||||
#if 0
|
||||
enum glfunc_indices
|
||||
{
|
||||
GLIDX_INVALID = -1,
|
||||
#define X(func, ret, typeargs, args) GLIDX_##func,
|
||||
GLFUNCS_MACRO
|
||||
#undef X
|
||||
GLIDX_COUNT
|
||||
};
|
||||
|
||||
/* function name table */
|
||||
extern const char* OPENGL32_funcnames[GLIDX_COUNT];
|
||||
#endif//0
|
||||
|
||||
/* GL data types - x86 typedefs */
|
||||
typedef unsigned int GLenum;
|
||||
typedef unsigned char GLboolean;
|
||||
|
@ -109,7 +94,7 @@ typedef double GLclampd;
|
|||
typedef void GLvoid;
|
||||
|
||||
/* Called by the driver to set the dispatch table */
|
||||
typedef DWORD (CALLBACK * SetContextCallBack)( const ICDTable * );
|
||||
typedef DWORD APIENTRY (*SetContextCallBack)( const ICDTable * );
|
||||
|
||||
/* OpenGL ICD data */
|
||||
typedef struct tagGLDRIVERDATA
|
||||
|
@ -123,23 +108,23 @@ typedef struct tagGLDRIVERDATA
|
|||
DWORD driver_version; /* DriverVersion value from registry */
|
||||
DWORD flags; /* Flags value from registry */
|
||||
|
||||
BOOL (*DrvCopyContext)( HGLRC, HGLRC, UINT );
|
||||
HGLRC (*DrvCreateContext)( HDC );
|
||||
HGLRC (*DrvCreateLayerContext)( HDC, int );
|
||||
BOOL (*DrvDeleteContext)( HGLRC );
|
||||
BOOL (*DrvDescribeLayerPlane)( HDC, int, int, UINT, LPLAYERPLANEDESCRIPTOR );
|
||||
int (*DrvDescribePixelFormat)( IN HDC, IN int, IN UINT, OUT LPPIXELFORMATDESCRIPTOR );
|
||||
int (*DrvGetLayerPaletteEntries)( HDC, int, int, int, COLORREF * );
|
||||
FARPROC (*DrvGetProcAddress)( LPCSTR lpProcName );
|
||||
void (*DrvReleaseContext)();
|
||||
BOOL (*DrvRealizeLayerPalette)( HDC, int, BOOL );
|
||||
int (*DrvSetContext)( HDC hdc, HGLRC hglrc, SetContextCallBack callback );
|
||||
int (*DrvSetLayerPaletteEntries)( HDC, int, int, int, CONST COLORREF * );
|
||||
BOOL (*DrvSetPixelFormat)( IN HDC, IN int, IN CONST PIXELFORMATDESCRIPTOR * );
|
||||
BOOL (*DrvShareLists)( HGLRC, HGLRC );
|
||||
BOOL (*DrvSwapBuffers)( HDC );
|
||||
BOOL (*DrvSwapLayerBuffers)( HDC, UINT );
|
||||
BOOL (*DrvValidateVersion)( DWORD );
|
||||
BOOL APIENTRY (*DrvCopyContext)( HGLRC, HGLRC, UINT );
|
||||
HGLRC APIENTRY (*DrvCreateContext)( HDC );
|
||||
HGLRC APIENTRY (*DrvCreateLayerContext)( HDC, int );
|
||||
BOOL APIENTRY (*DrvDeleteContext)( HGLRC );
|
||||
BOOL APIENTRY (*DrvDescribeLayerPlane)( HDC, int, int, UINT, LPLAYERPLANEDESCRIPTOR );
|
||||
int APIENTRY (*DrvDescribePixelFormat)( IN HDC, IN int, IN UINT, OUT LPPIXELFORMATDESCRIPTOR );
|
||||
int APIENTRY (*DrvGetLayerPaletteEntries)( HDC, int, int, int, COLORREF * );
|
||||
FARPROC APIENTRY (*DrvGetProcAddress)( LPCSTR lpProcName );
|
||||
void APIENTRY (*DrvReleaseContext)();
|
||||
BOOL APIENTRY (*DrvRealizeLayerPalette)( HDC, int, BOOL );
|
||||
PICDTable APIENTRY (*DrvSetContext)( HDC hdc, HGLRC hglrc, SetContextCallBack callback );
|
||||
int APIENTRY (*DrvSetLayerPaletteEntries)( HDC, int, int, int, CONST COLORREF * );
|
||||
BOOL APIENTRY (*DrvSetPixelFormat)( IN HDC, IN int, IN CONST PIXELFORMATDESCRIPTOR * );
|
||||
BOOL APIENTRY (*DrvShareLists)( HGLRC, HGLRC );
|
||||
BOOL APIENTRY (*DrvSwapBuffers)( HDC );
|
||||
BOOL APIENTRY (*DrvSwapLayerBuffers)( HDC, UINT );
|
||||
BOOL APIENTRY (*DrvValidateVersion)( DWORD );
|
||||
|
||||
struct tagGLDRIVERDATA *next; /* next ICD -- linked list */
|
||||
} GLDRIVERDATA;
|
||||
|
|
|
@ -147,8 +147,7 @@ WGL_SetContextCallBack( const ICDTable *table )
|
|||
memcpy( tebTable, table->dispatch_table,
|
||||
sizeof (PROC) * table->num_funcs );
|
||||
memset( tebTable + sizeof (PROC) * table->num_funcs, 0,
|
||||
(sizeof (table->dispatch_table) / sizeof (PROC)) -
|
||||
(sizeof (PROC) * table->num_funcs) );
|
||||
sizeof (table->dispatch_table) - (sizeof (PROC) * table->num_funcs) );
|
||||
|
||||
/* FIXME: pull in software fallbacks -- need mesa */
|
||||
#if 0 /* unused atm */
|
||||
|
@ -196,7 +195,7 @@ rosglChoosePixelFormat( HDC hdc, CONST PIXELFORMATDESCRIPTOR *pfd )
|
|||
GLDRIVERDATA *icd;
|
||||
PIXELFORMATDESCRIPTOR icdPfd;
|
||||
int i;
|
||||
int best = -1;
|
||||
int best = 0;
|
||||
int score, bestScore = 0x7fff; /* used to choose a pfd if no exact match */
|
||||
int icdNumFormats;
|
||||
const DWORD compareFlags = PFD_DRAW_TO_WINDOW | PFD_DRAW_TO_BITMAP |
|
||||
|
@ -215,13 +214,14 @@ rosglChoosePixelFormat( HDC hdc, CONST PIXELFORMATDESCRIPTOR *pfd )
|
|||
}
|
||||
|
||||
/* get number of formats -- FIXME: use 1 or 0 as index? */
|
||||
icdNumFormats = icd->DrvDescribePixelFormat( hdc, 1,
|
||||
icdNumFormats = icd->DrvDescribePixelFormat( hdc, 0,
|
||||
sizeof (PIXELFORMATDESCRIPTOR), NULL );
|
||||
if (icdNumFormats == 0)
|
||||
{
|
||||
DBGPRINT( "DrvDescribePixelFormat failed (%d)", GetLastError() );
|
||||
DBGPRINT( "Error: DrvDescribePixelFormat failed (%d)", GetLastError() );
|
||||
return 0;
|
||||
}
|
||||
DBGPRINT( "Info: Enumerating %d pixelformats", icdNumFormats );
|
||||
|
||||
/* try to find best format */
|
||||
for (i = 0; i < icdNumFormats; i++)
|
||||
|
@ -267,12 +267,10 @@ rosglChoosePixelFormat( HDC hdc, CONST PIXELFORMATDESCRIPTOR *pfd )
|
|||
}
|
||||
}
|
||||
|
||||
if (best == -1)
|
||||
{
|
||||
if (best == 0)
|
||||
SetLastError( 0 ); /* FIXME: set appropriate error */
|
||||
return 0;
|
||||
}
|
||||
|
||||
DBGPRINT( "Info: Suggesting pixelformat %d", best );
|
||||
return best;
|
||||
}
|
||||
|
||||
|
@ -504,7 +502,7 @@ rosglDescribePixelFormat( HDC hdc, int iFormat, UINT nBytes,
|
|||
{
|
||||
ret = icd->DrvDescribePixelFormat( hdc, iFormat, nBytes, pfd );
|
||||
if (ret == 0)
|
||||
DBGPRINT( "Error: DrvDescribePixelFormat failed (%d)", GetLastError() );
|
||||
DBGPRINT( "Error: DrvDescribePixelFormat(format=%d) failed (%d)", iFormat, GetLastError() );
|
||||
}
|
||||
|
||||
/* FIXME: implement own functionality? */
|
||||
|
@ -613,6 +611,7 @@ APIENTRY
|
|||
rosglMakeCurrent( HDC hdc, HGLRC hglrc )
|
||||
{
|
||||
GLRC *glrc = (GLRC *)hglrc;
|
||||
ICDTable *icdTable = NULL;
|
||||
|
||||
/* flush current context */
|
||||
if (OPENGL32_threaddata->glrc != NULL)
|
||||
|
@ -644,8 +643,9 @@ rosglMakeCurrent( HDC hdc, HGLRC hglrc )
|
|||
/* call the ICD */
|
||||
if (glrc->hglrc != NULL)
|
||||
{
|
||||
if (!glrc->icd->DrvSetContext( hdc, glrc->hglrc,
|
||||
WGL_SetContextCallBack ))
|
||||
icdTable = glrc->icd->DrvSetContext( hdc, glrc->hglrc,
|
||||
WGL_SetContextCallBack );
|
||||
if (icdTable == NULL)
|
||||
{
|
||||
DBGPRINT( "Error: DrvSetContext failed (%d)\n", GetLastError() );
|
||||
return FALSE;
|
||||
|
@ -661,6 +661,12 @@ rosglMakeCurrent( HDC hdc, HGLRC hglrc )
|
|||
glrc->hdc = hdc;
|
||||
OPENGL32_threaddata->glrc = glrc;
|
||||
|
||||
if (icdTable != NULL)
|
||||
if (WGL_SetContextCallBack( icdTable ) != ERROR_SUCCESS)
|
||||
{
|
||||
DBGPRINT( "Warning: WGL_SetContextCallBack failed!" );
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -696,7 +702,8 @@ rosglSetPixelFormat( HDC hdc, int iFormat, CONST PIXELFORMATDESCRIPTOR *pfd )
|
|||
|
||||
if (!icd->DrvSetPixelFormat( hdc, iFormat, pfd ))
|
||||
{
|
||||
DBGPRINT( "Warning: DrvSetPixelFormat failed (%d)", GetLastError() );
|
||||
DBGPRINT( "Warning: DrvSetPixelFormat(format=%d) failed (%d)",
|
||||
iFormat, GetLastError() );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -751,27 +758,6 @@ BOOL
|
|||
APIENTRY
|
||||
rosglSwapBuffers( HDC hdc )
|
||||
{
|
||||
#if 0
|
||||
/* check if there is a current GLRC */
|
||||
if (OPENGL32_threaddata->glrc == NULL)
|
||||
{
|
||||
DBGPRINT( "Error: No current GL context!" );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* ask ICD to swap buffers */
|
||||
/* FIXME: also ask ICD when we didnt use it to create the context/it couldnt? */
|
||||
if (OPENGL32_threaddata->glrc->hglrc != NULL)
|
||||
{
|
||||
if (!OPENGL32_threaddata->glrc->icd->DrvSwapBuffers( hdc ))
|
||||
{
|
||||
DBGPRINT( "Error: DrvSwapBuffers failed (%d)", GetLastError() );
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
GLDRIVERDATA *icd = OPENGL32_LoadICDForHDC( hdc );
|
||||
if (icd != NULL)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue