reactos/dll/opengl/opengl32/gl.c

135 lines
6 KiB
C
Raw Normal View History

/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: lib/opengl32/gl.c
* PURPOSE: OpenGL32 lib, glXXX functions
* PROGRAMMER: Anich Gregor (blight)
* UPDATE HISTORY:
* Feb 2, 2004: Created
*/
/* On a x86 we call the ICD functions in a special-way:
*
* For every glXXX function we export a glXXX entry-point which loads the
* matching "real" function pointer from the NtCurrentTeb()->glDispatchTable
* for gl functions in teblist.h and for others it gets the pointer from
* NtCurrentTeb()->glTable and jmps to the address, leaving the stack alone and
* letting the "real" function return for us.
* Royce has implemented this in NASM =D
*
* On other machines we use C to forward the calls (slow...)
*/
#include "opengl32.h"
Merge from amd64 branch: [SPIDER] 44002 Fix 64 bit build. (Samuel Serapión) [PAINT] 43858 Fix 64 bit warnings. (Samuel Serapión) [RAPPS] 43906 Fix 64 bit build. (Samuel Serapión) [SNDREC32] 44389 Fix 64 bit build. (Samuel Serapión) [TFTP] 41097 Fix pointer to DWORD cast. (Timo Kreuzer) [COMCTL32] 36172 Build as unicode. (Samuel Serapión) [USERMGR] 41098 Fix 2 POINTER<->DWORD casts. (Timo Kreuzer) [d3d9] 38149 Fix pointer<->ULONG cast. (Timo Kreuzer) 43839 Fix 64 bit Build. (Samuel Serapión) [DSOUND] 40753 Make DSDRIVERDESC.dnDevNode a DWORD_PTR and DSPROPERTY.InstanceId a ULONG_PTR. (Timo Kreuzer) [LSASRV] 44037 Fix 64 bit Build. (Samuel Serapión) [MMDRV] 40125 Fix 64bit build. (Samuel Serapión) [MSGINA] 40993 fix 64bit build (Timo Kreuzer) [NETSHELL] 41001 Don't cast the 1st parameter of InterlockedExchange to volatile void **, but to void ** (Timo Kreuzer) [OPENGL32] 36502 No need to assert an offset thats only used in i386 specific code. (Samuel Serapión) [POWRPROF] 41044 Don't cast NULL to DWORD. (Timo Kreuzer) 43860 Don't cast NULL to an integer type. (Samuel Serapión) [PSAPI] 38150 Fix a cast (Timo Kreuzer) [SHELL32] 38355 Use Get/SetWindowLongPtr (Samuel Serapión) 41047 Get rid of deprecated LargeInteger functions and use native int64 math instead. (Timo Kreuzer) 41048 DialogProc returns INT_PTR and not BOOL. Don't cast a pointer to LONG. Use INT_PTR instead of int for pointer math. (Timo Kreuzer) 41049 Change return type of OpenMRUListW and CreateMRUListW to HANDLE, add a comment that CREATEMRULISTW is already defined differently in explorer_new/undoc.h (Timo Kreuzer) 44601 Fix a prototype. Convert RtlLargeInteger to native int64. Fixes 64bit built. (Timo Kreuzer) [WDMAUD.DRV] 41101 Don't cast DWORD to PVOID, use UlongToPtr instead. (Timo Kreuzer) [WS2_32] 35777 fix ws2_32 spec file (Timo kreuzer) 44044 Fix ws2_32 64bit build (1 of 2) (Samuel Serapión) 44045 Fix ws2_32 64bit build (2 of 2) (Samuel Serapión) [WS2_32_NEW] 44389 Fix 64 bit built. (Samuel Serapión) svn path=/trunk/; revision=44602
2009-12-15 15:16:01 +00:00
#if defined(_M_IX86)
C_ASSERT(FIELD_OFFSET(TEB, glTable) == 0xbe8);
Merge from amd64 branch: [SPIDER] 44002 Fix 64 bit build. (Samuel Serapión) [PAINT] 43858 Fix 64 bit warnings. (Samuel Serapión) [RAPPS] 43906 Fix 64 bit build. (Samuel Serapión) [SNDREC32] 44389 Fix 64 bit build. (Samuel Serapión) [TFTP] 41097 Fix pointer to DWORD cast. (Timo Kreuzer) [COMCTL32] 36172 Build as unicode. (Samuel Serapión) [USERMGR] 41098 Fix 2 POINTER<->DWORD casts. (Timo Kreuzer) [d3d9] 38149 Fix pointer<->ULONG cast. (Timo Kreuzer) 43839 Fix 64 bit Build. (Samuel Serapión) [DSOUND] 40753 Make DSDRIVERDESC.dnDevNode a DWORD_PTR and DSPROPERTY.InstanceId a ULONG_PTR. (Timo Kreuzer) [LSASRV] 44037 Fix 64 bit Build. (Samuel Serapión) [MMDRV] 40125 Fix 64bit build. (Samuel Serapión) [MSGINA] 40993 fix 64bit build (Timo Kreuzer) [NETSHELL] 41001 Don't cast the 1st parameter of InterlockedExchange to volatile void **, but to void ** (Timo Kreuzer) [OPENGL32] 36502 No need to assert an offset thats only used in i386 specific code. (Samuel Serapión) [POWRPROF] 41044 Don't cast NULL to DWORD. (Timo Kreuzer) 43860 Don't cast NULL to an integer type. (Samuel Serapión) [PSAPI] 38150 Fix a cast (Timo Kreuzer) [SHELL32] 38355 Use Get/SetWindowLongPtr (Samuel Serapión) 41047 Get rid of deprecated LargeInteger functions and use native int64 math instead. (Timo Kreuzer) 41048 DialogProc returns INT_PTR and not BOOL. Don't cast a pointer to LONG. Use INT_PTR instead of int for pointer math. (Timo Kreuzer) 41049 Change return type of OpenMRUListW and CreateMRUListW to HANDLE, add a comment that CREATEMRULISTW is already defined differently in explorer_new/undoc.h (Timo Kreuzer) 44601 Fix a prototype. Convert RtlLargeInteger to native int64. Fixes 64bit built. (Timo Kreuzer) [WDMAUD.DRV] 41101 Don't cast DWORD to PVOID, use UlongToPtr instead. (Timo Kreuzer) [WS2_32] 35777 fix ws2_32 spec file (Timo kreuzer) 44044 Fix ws2_32 64bit build (1 of 2) (Samuel Serapión) 44045 Fix ws2_32 64bit build (2 of 2) (Samuel Serapión) [WS2_32_NEW] 44389 Fix 64 bit built. (Samuel Serapión) svn path=/trunk/; revision=44602
2009-12-15 15:16:01 +00:00
#endif
int WINAPI glEmptyFunc0( void ) { return 0; }
int WINAPI glEmptyFunc4( long l1 ) { return 0; }
int WINAPI glEmptyFunc8( long l1, long l2 ) { return 0; }
int WINAPI glEmptyFunc12( long l1, long l2, long l3 ) { return 0; }
int WINAPI glEmptyFunc16( long l1, long l2, long l3, long l4 ) { return 0; }
int WINAPI glEmptyFunc20( long l1, long l2, long l3, long l4, long l5 )
{ return 0; }
int WINAPI glEmptyFunc24( long l1, long l2, long l3, long l4, long l5,
long l6 ) { return 0; }
int WINAPI glEmptyFunc28( long l1, long l2, long l3, long l4, long l5,
long l6, long l7 ) { return 0; }
int WINAPI glEmptyFunc32( long l1, long l2, long l3, long l4, long l5,
long l6, long l7, long l8 ) { return 0; }
int WINAPI glEmptyFunc36( long l1, long l2, long l3, long l4, long l5,
long l6, long l7, long l8, long l9 ) { return 0; }
int WINAPI glEmptyFunc40( long l1, long l2, long l3, long l4, long l5,
long l6, long l7, long l8, long l9, long l10 )
{ return 0; }
int WINAPI glEmptyFunc44( long l1, long l2, long l3, long l4, long l5,
long l6, long l7, long l8, long l9, long l10,
long l11 ) { return 0; }
int WINAPI glEmptyFunc48( long l1, long l2, long l3, long l4, long l5,
long l6, long l7, long l8, long l9, long l10,
long l11, long l12 ) { return 0; }
int WINAPI glEmptyFunc52( long l1, long l2, long l3, long l4, long l5,
long l6, long l7, long l8, long l9, long l10,
long l11, long l12, long l13 ) { return 0; }
int WINAPI glEmptyFunc56( long l1, long l2, long l3, long l4, long l5,
long l6, long l7, long l8, long l9, long l10,
long l11, long l12, long l13, long l14 )
{ return 0; }
#if defined(_M_IX86)
# define FOO(x) #x
#ifdef __GNUC__
# define X(func, ret, typeargs, args, icdidx, tebidx, stack) \
__asm__(".align 4" "\n\t" \
".globl _"#func"@"#stack "\n\t" \
"_"#func"@"#stack":" "\n\t" \
" movl %fs:0x18, %eax" "\n\t" \
" movl 0xbe8(%eax), %eax" "\n\t" \
" jmp *"FOO((icdidx*4))"(%eax)" "\n\t");
#elif defined(_MSC_VER)
# define X(func, ret, typeargs, args, icdidx, tebidx, stack) \
__declspec(naked) ret WINAPI func typeargs \
{ \
__asm { mov eax, dword ptr fs:[18h] }; \
__asm { mov eax, dword ptr [eax+0be8h] }; \
__asm { jmp dword ptr [eax+icdidx*4] }; \
}
#else
# define X(func, ret, typeargs, args, icdidx, tebidx, stack) \
ret WINAPI func typeargs \
{ \
PROC *table; \
PROC fn; \
if (tebidx >= 0 && 0) \
{ \
table = (PROC *)NtCurrentTeb()->glDispatchTable; \
fn = table[tebidx]; \
} \
else \
{ \
table = (PROC *)NtCurrentTeb()->glTable; \
fn = table[icdidx]; \
} \
return (ret)((ret(*)typeargs)fn)args; \
}
#endif
GLFUNCS_MACRO
# undef FOO
# undef X
#else /* defined(_M_IX86) */
# define X(func, ret, typeargs, args, icdidx, tebidx, stack) \
ret WINAPI func typeargs \
{ \
PROC *table; \
PROC fn; \
if (tebidx >= 0 && 0) \
{ \
table = (PROC *)NtCurrentTeb()->glDispatchTable; \
fn = table[tebidx]; \
} \
else \
{ \
table = (PROC *)NtCurrentTeb()->glTable; \
fn = table[icdidx]; \
} \
return (ret)((ret(*)typeargs)fn)args; \
}
GLFUNCS_MACRO
# undef X
#endif /* !defined(_M_IX86) */
/* Unknown debugging function */
GLint WINAPI glDebugEntry( GLint unknown1, GLint unknown2 )
{
return 0;
}
/* EOF */