mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 07:52:56 +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
|
TARGET_NAME = opengl32
|
||||||
|
|
||||||
# -fno-builtin
|
# -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
|
# require os code to explicitly request A/W version of structs/functions
|
||||||
TARGET_CFLAGS += -D_DISABLE_TIDENTS -Wall -Werror
|
TARGET_CFLAGS += -D_DISABLE_TIDENTS -Wall -Werror
|
||||||
|
@ -21,7 +21,7 @@ TARGET_OBJECTS = \
|
||||||
gl.o \
|
gl.o \
|
||||||
opengl32.o \
|
opengl32.o \
|
||||||
wgl.o \
|
wgl.o \
|
||||||
tebimports.o
|
#tebimports.o
|
||||||
|
|
||||||
DEP_OBJECTS = $(TARGET_OBJECTS)
|
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 )
|
long l11, long l12, long l13, long l14 )
|
||||||
{ return 0; }
|
{ return 0; }
|
||||||
|
|
||||||
#if !defined(_M_IX86)
|
#if 1//!defined(_M_IX86)
|
||||||
# define X(func, ret, typeargs, args, icdidx, tebidx, stack) \
|
# define X(func, ret, typeargs, args, icdidx, tebidx, stack) \
|
||||||
ret STDCALL func typeargs \
|
ret STDCALL func typeargs \
|
||||||
{ \
|
{ \
|
||||||
|
|
|
@ -16,7 +16,7 @@ typedef struct tagICDTable
|
||||||
{
|
{
|
||||||
DWORD num_funcs; /* Normally 336 (0x150) */
|
DWORD num_funcs; /* Normally 336 (0x150) */
|
||||||
PROC dispatch_table[812];
|
PROC dispatch_table[812];
|
||||||
} ICDTable;
|
} ICDTable, *PICDTable;
|
||||||
|
|
||||||
#endif /* OPENGL32_PRIVATE_ICDTABLE_H */
|
#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
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -75,21 +75,6 @@ ULONG DbgPrint(PCH Format,...);
|
||||||
/* gl function list */
|
/* gl function list */
|
||||||
#include "glfuncs.h"
|
#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 */
|
/* GL data types - x86 typedefs */
|
||||||
typedef unsigned int GLenum;
|
typedef unsigned int GLenum;
|
||||||
typedef unsigned char GLboolean;
|
typedef unsigned char GLboolean;
|
||||||
|
@ -109,7 +94,7 @@ typedef double GLclampd;
|
||||||
typedef void GLvoid;
|
typedef void GLvoid;
|
||||||
|
|
||||||
/* Called by the driver to set the dispatch table */
|
/* Called by the driver to set the dispatch table */
|
||||||
typedef DWORD (CALLBACK * SetContextCallBack)( const ICDTable * );
|
typedef DWORD APIENTRY (*SetContextCallBack)( const ICDTable * );
|
||||||
|
|
||||||
/* OpenGL ICD data */
|
/* OpenGL ICD data */
|
||||||
typedef struct tagGLDRIVERDATA
|
typedef struct tagGLDRIVERDATA
|
||||||
|
@ -123,23 +108,23 @@ typedef struct tagGLDRIVERDATA
|
||||||
DWORD driver_version; /* DriverVersion value from registry */
|
DWORD driver_version; /* DriverVersion value from registry */
|
||||||
DWORD flags; /* Flags value from registry */
|
DWORD flags; /* Flags value from registry */
|
||||||
|
|
||||||
BOOL (*DrvCopyContext)( HGLRC, HGLRC, UINT );
|
BOOL APIENTRY (*DrvCopyContext)( HGLRC, HGLRC, UINT );
|
||||||
HGLRC (*DrvCreateContext)( HDC );
|
HGLRC APIENTRY (*DrvCreateContext)( HDC );
|
||||||
HGLRC (*DrvCreateLayerContext)( HDC, int );
|
HGLRC APIENTRY (*DrvCreateLayerContext)( HDC, int );
|
||||||
BOOL (*DrvDeleteContext)( HGLRC );
|
BOOL APIENTRY (*DrvDeleteContext)( HGLRC );
|
||||||
BOOL (*DrvDescribeLayerPlane)( HDC, int, int, UINT, LPLAYERPLANEDESCRIPTOR );
|
BOOL APIENTRY (*DrvDescribeLayerPlane)( HDC, int, int, UINT, LPLAYERPLANEDESCRIPTOR );
|
||||||
int (*DrvDescribePixelFormat)( IN HDC, IN int, IN UINT, OUT LPPIXELFORMATDESCRIPTOR );
|
int APIENTRY (*DrvDescribePixelFormat)( IN HDC, IN int, IN UINT, OUT LPPIXELFORMATDESCRIPTOR );
|
||||||
int (*DrvGetLayerPaletteEntries)( HDC, int, int, int, COLORREF * );
|
int APIENTRY (*DrvGetLayerPaletteEntries)( HDC, int, int, int, COLORREF * );
|
||||||
FARPROC (*DrvGetProcAddress)( LPCSTR lpProcName );
|
FARPROC APIENTRY (*DrvGetProcAddress)( LPCSTR lpProcName );
|
||||||
void (*DrvReleaseContext)();
|
void APIENTRY (*DrvReleaseContext)();
|
||||||
BOOL (*DrvRealizeLayerPalette)( HDC, int, BOOL );
|
BOOL APIENTRY (*DrvRealizeLayerPalette)( HDC, int, BOOL );
|
||||||
int (*DrvSetContext)( HDC hdc, HGLRC hglrc, SetContextCallBack callback );
|
PICDTable APIENTRY (*DrvSetContext)( HDC hdc, HGLRC hglrc, SetContextCallBack callback );
|
||||||
int (*DrvSetLayerPaletteEntries)( HDC, int, int, int, CONST COLORREF * );
|
int APIENTRY (*DrvSetLayerPaletteEntries)( HDC, int, int, int, CONST COLORREF * );
|
||||||
BOOL (*DrvSetPixelFormat)( IN HDC, IN int, IN CONST PIXELFORMATDESCRIPTOR * );
|
BOOL APIENTRY (*DrvSetPixelFormat)( IN HDC, IN int, IN CONST PIXELFORMATDESCRIPTOR * );
|
||||||
BOOL (*DrvShareLists)( HGLRC, HGLRC );
|
BOOL APIENTRY (*DrvShareLists)( HGLRC, HGLRC );
|
||||||
BOOL (*DrvSwapBuffers)( HDC );
|
BOOL APIENTRY (*DrvSwapBuffers)( HDC );
|
||||||
BOOL (*DrvSwapLayerBuffers)( HDC, UINT );
|
BOOL APIENTRY (*DrvSwapLayerBuffers)( HDC, UINT );
|
||||||
BOOL (*DrvValidateVersion)( DWORD );
|
BOOL APIENTRY (*DrvValidateVersion)( DWORD );
|
||||||
|
|
||||||
struct tagGLDRIVERDATA *next; /* next ICD -- linked list */
|
struct tagGLDRIVERDATA *next; /* next ICD -- linked list */
|
||||||
} GLDRIVERDATA;
|
} GLDRIVERDATA;
|
||||||
|
|
|
@ -147,8 +147,7 @@ WGL_SetContextCallBack( const ICDTable *table )
|
||||||
memcpy( tebTable, table->dispatch_table,
|
memcpy( tebTable, table->dispatch_table,
|
||||||
sizeof (PROC) * table->num_funcs );
|
sizeof (PROC) * table->num_funcs );
|
||||||
memset( tebTable + sizeof (PROC) * table->num_funcs, 0,
|
memset( tebTable + sizeof (PROC) * table->num_funcs, 0,
|
||||||
(sizeof (table->dispatch_table) / sizeof (PROC)) -
|
sizeof (table->dispatch_table) - (sizeof (PROC) * table->num_funcs) );
|
||||||
(sizeof (PROC) * table->num_funcs) );
|
|
||||||
|
|
||||||
/* FIXME: pull in software fallbacks -- need mesa */
|
/* FIXME: pull in software fallbacks -- need mesa */
|
||||||
#if 0 /* unused atm */
|
#if 0 /* unused atm */
|
||||||
|
@ -196,7 +195,7 @@ rosglChoosePixelFormat( HDC hdc, CONST PIXELFORMATDESCRIPTOR *pfd )
|
||||||
GLDRIVERDATA *icd;
|
GLDRIVERDATA *icd;
|
||||||
PIXELFORMATDESCRIPTOR icdPfd;
|
PIXELFORMATDESCRIPTOR icdPfd;
|
||||||
int i;
|
int i;
|
||||||
int best = -1;
|
int best = 0;
|
||||||
int score, bestScore = 0x7fff; /* used to choose a pfd if no exact match */
|
int score, bestScore = 0x7fff; /* used to choose a pfd if no exact match */
|
||||||
int icdNumFormats;
|
int icdNumFormats;
|
||||||
const DWORD compareFlags = PFD_DRAW_TO_WINDOW | PFD_DRAW_TO_BITMAP |
|
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? */
|
/* get number of formats -- FIXME: use 1 or 0 as index? */
|
||||||
icdNumFormats = icd->DrvDescribePixelFormat( hdc, 1,
|
icdNumFormats = icd->DrvDescribePixelFormat( hdc, 0,
|
||||||
sizeof (PIXELFORMATDESCRIPTOR), NULL );
|
sizeof (PIXELFORMATDESCRIPTOR), NULL );
|
||||||
if (icdNumFormats == 0)
|
if (icdNumFormats == 0)
|
||||||
{
|
{
|
||||||
DBGPRINT( "DrvDescribePixelFormat failed (%d)", GetLastError() );
|
DBGPRINT( "Error: DrvDescribePixelFormat failed (%d)", GetLastError() );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
DBGPRINT( "Info: Enumerating %d pixelformats", icdNumFormats );
|
||||||
|
|
||||||
/* try to find best format */
|
/* try to find best format */
|
||||||
for (i = 0; i < icdNumFormats; i++)
|
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 */
|
SetLastError( 0 ); /* FIXME: set appropriate error */
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
DBGPRINT( "Info: Suggesting pixelformat %d", best );
|
||||||
return best;
|
return best;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -504,7 +502,7 @@ rosglDescribePixelFormat( HDC hdc, int iFormat, UINT nBytes,
|
||||||
{
|
{
|
||||||
ret = icd->DrvDescribePixelFormat( hdc, iFormat, nBytes, pfd );
|
ret = icd->DrvDescribePixelFormat( hdc, iFormat, nBytes, pfd );
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
DBGPRINT( "Error: DrvDescribePixelFormat failed (%d)", GetLastError() );
|
DBGPRINT( "Error: DrvDescribePixelFormat(format=%d) failed (%d)", iFormat, GetLastError() );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: implement own functionality? */
|
/* FIXME: implement own functionality? */
|
||||||
|
@ -613,6 +611,7 @@ APIENTRY
|
||||||
rosglMakeCurrent( HDC hdc, HGLRC hglrc )
|
rosglMakeCurrent( HDC hdc, HGLRC hglrc )
|
||||||
{
|
{
|
||||||
GLRC *glrc = (GLRC *)hglrc;
|
GLRC *glrc = (GLRC *)hglrc;
|
||||||
|
ICDTable *icdTable = NULL;
|
||||||
|
|
||||||
/* flush current context */
|
/* flush current context */
|
||||||
if (OPENGL32_threaddata->glrc != NULL)
|
if (OPENGL32_threaddata->glrc != NULL)
|
||||||
|
@ -644,8 +643,9 @@ rosglMakeCurrent( HDC hdc, HGLRC hglrc )
|
||||||
/* call the ICD */
|
/* call the ICD */
|
||||||
if (glrc->hglrc != NULL)
|
if (glrc->hglrc != NULL)
|
||||||
{
|
{
|
||||||
if (!glrc->icd->DrvSetContext( hdc, glrc->hglrc,
|
icdTable = glrc->icd->DrvSetContext( hdc, glrc->hglrc,
|
||||||
WGL_SetContextCallBack ))
|
WGL_SetContextCallBack );
|
||||||
|
if (icdTable == NULL)
|
||||||
{
|
{
|
||||||
DBGPRINT( "Error: DrvSetContext failed (%d)\n", GetLastError() );
|
DBGPRINT( "Error: DrvSetContext failed (%d)\n", GetLastError() );
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -661,6 +661,12 @@ rosglMakeCurrent( HDC hdc, HGLRC hglrc )
|
||||||
glrc->hdc = hdc;
|
glrc->hdc = hdc;
|
||||||
OPENGL32_threaddata->glrc = glrc;
|
OPENGL32_threaddata->glrc = glrc;
|
||||||
|
|
||||||
|
if (icdTable != NULL)
|
||||||
|
if (WGL_SetContextCallBack( icdTable ) != ERROR_SUCCESS)
|
||||||
|
{
|
||||||
|
DBGPRINT( "Warning: WGL_SetContextCallBack failed!" );
|
||||||
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -696,7 +702,8 @@ rosglSetPixelFormat( HDC hdc, int iFormat, CONST PIXELFORMATDESCRIPTOR *pfd )
|
||||||
|
|
||||||
if (!icd->DrvSetPixelFormat( hdc, iFormat, pfd ))
|
if (!icd->DrvSetPixelFormat( hdc, iFormat, pfd ))
|
||||||
{
|
{
|
||||||
DBGPRINT( "Warning: DrvSetPixelFormat failed (%d)", GetLastError() );
|
DBGPRINT( "Warning: DrvSetPixelFormat(format=%d) failed (%d)",
|
||||||
|
iFormat, GetLastError() );
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -751,27 +758,6 @@ BOOL
|
||||||
APIENTRY
|
APIENTRY
|
||||||
rosglSwapBuffers( HDC hdc )
|
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 );
|
GLDRIVERDATA *icd = OPENGL32_LoadICDForHDC( hdc );
|
||||||
if (icd != NULL)
|
if (icd != NULL)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue