ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

gl.c
Go to the documentation of this file.
00001 /*
00002  * COPYRIGHT:            See COPYING in the top level directory
00003  * PROJECT:              ReactOS kernel
00004  * FILE:                 lib/opengl32/gl.c
00005  * PURPOSE:              OpenGL32 lib, glXXX functions
00006  * PROGRAMMER:           Anich Gregor (blight)
00007  * UPDATE HISTORY:
00008  *                       Feb 2, 2004: Created
00009  */
00010 
00011 /* On a x86 we call the ICD functions in a special-way:
00012  *
00013  * For every glXXX function we export a glXXX entry-point which loads the
00014  * matching "real" function pointer from the NtCurrentTeb()->glDispatchTable
00015  * for gl functions in teblist.h and for others it gets the pointer from
00016  * NtCurrentTeb()->glTable and jmps to the address, leaving the stack alone and
00017  * letting the "real" function return for us.
00018  * Royce has implemented this in NASM =D
00019  *
00020  * On other machines we use C to forward the calls (slow...)
00021  */
00022 
00023 #include "opengl32.h"
00024 
00025 #if defined(_M_IX86)
00026 C_ASSERT(FIELD_OFFSET(TEB, glTable) == 0xbe8);
00027 #endif
00028 
00029 int WINAPI glEmptyFunc0( void ) { return 0; }
00030 int WINAPI glEmptyFunc4( long l1 ) { return 0; }
00031 int WINAPI glEmptyFunc8( long l1, long l2 ) { return 0; }
00032 int WINAPI glEmptyFunc12( long l1, long l2, long l3 ) { return 0; }
00033 int WINAPI glEmptyFunc16( long l1, long l2, long l3, long l4 ) { return 0; }
00034 int WINAPI glEmptyFunc20( long l1, long l2, long l3, long l4, long l5 )
00035                           { return 0; }
00036 int WINAPI glEmptyFunc24( long l1, long l2, long l3, long l4, long l5,
00037                           long l6 ) { return 0; }
00038 int WINAPI glEmptyFunc28( long l1, long l2, long l3, long l4, long l5,
00039                           long l6, long l7 ) { return 0; }
00040 int WINAPI glEmptyFunc32( long l1, long l2, long l3, long l4, long l5,
00041                           long l6, long l7, long l8 ) { return 0; }
00042 int WINAPI glEmptyFunc36( long l1, long l2, long l3, long l4, long l5,
00043                           long l6, long l7, long l8, long l9 ) { return 0; }
00044 int WINAPI glEmptyFunc40( long l1, long l2, long l3, long l4, long l5,
00045                           long l6, long l7, long l8, long l9, long l10 )
00046                           { return 0; }
00047 int WINAPI glEmptyFunc44( long l1, long l2, long l3, long l4, long l5,
00048                           long l6, long l7, long l8, long l9, long l10,
00049                           long l11 ) { return 0; }
00050 int WINAPI glEmptyFunc48( long l1, long l2, long l3, long l4, long l5,
00051                           long l6, long l7, long l8, long l9, long l10,
00052                           long l11, long l12 ) { return 0; }
00053 int WINAPI glEmptyFunc52( long l1, long l2, long l3, long l4, long l5,
00054                           long l6, long l7, long l8, long l9, long l10,
00055                           long l11, long l12, long l13 ) { return 0; }
00056 int WINAPI glEmptyFunc56( long l1, long l2, long l3, long l4, long l5,
00057                           long l6, long l7, long l8, long l9, long l10,
00058                           long l11, long l12, long l13, long l14 )
00059                           { return 0; }
00060 
00061 #if defined(_M_IX86)
00062 # define FOO(x) #x
00063 
00064 #ifdef __GNUC__
00065 # define X(func, ret, typeargs, args, icdidx, tebidx, stack) \
00066 __asm__(".align 4"                                    "\n\t" \
00067         ".globl _"#func"@"#stack                      "\n\t" \
00068         "_"#func"@"#stack":"                          "\n\t" \
00069         "       movl %fs:0x18, %eax"                  "\n\t" \
00070         "       movl 0xbe8(%eax), %eax"               "\n\t" \
00071         "       jmp *"FOO((icdidx*4))"(%eax)"         "\n\t");
00072 #elif defined(_MSC_VER)
00073 # define X(func, ret, typeargs, args, icdidx, tebidx, stack) \
00074 __declspec(naked) ret WINAPI func typeargs                   \
00075 {                                                            \
00076     __asm { mov eax, dword ptr fs:[18h] };                   \
00077     __asm { mov eax, dword ptr [eax+0be8h] };                \
00078     __asm { jmp dword ptr [eax+icdidx*4] };                  \
00079 }
00080 #else
00081 # define X(func, ret, typeargs, args, icdidx, tebidx, stack) \
00082 ret WINAPI func typeargs                                     \
00083 {                                                            \
00084     PROC *table;                                             \
00085     PROC fn;                                                 \
00086     if (tebidx >= 0 && 0)                                    \
00087     {                                                        \
00088         table = (PROC *)NtCurrentTeb()->glDispatchTable;     \
00089         fn = table[tebidx];                                  \
00090     }                                                        \
00091     else                                                     \
00092     {                                                        \
00093         table = (PROC *)NtCurrentTeb()->glTable;             \
00094         fn = table[icdidx];                                  \
00095     }                                                        \
00096     return (ret)((ret(*)typeargs)fn)args;                    \
00097 }
00098 #endif
00099 
00100 GLFUNCS_MACRO
00101 # undef FOO
00102 # undef X
00103 #else /* defined(_M_IX86) */
00104 # define X(func, ret, typeargs, args, icdidx, tebidx, stack) \
00105 ret WINAPI func typeargs                                     \
00106 {                                                            \
00107     PROC *table;                                             \
00108     PROC fn;                                                 \
00109     if (tebidx >= 0 && 0)                                    \
00110     {                                                        \
00111         table = (PROC *)NtCurrentTeb()->glDispatchTable;     \
00112         fn = table[tebidx];                                  \
00113     }                                                        \
00114     else                                                     \
00115     {                                                        \
00116         table = (PROC *)NtCurrentTeb()->glTable;             \
00117         fn = table[icdidx];                                  \
00118     }                                                        \
00119     return (ret)((ret(*)typeargs)fn)args;                    \
00120 }
00121 
00122 GLFUNCS_MACRO
00123 
00124 # undef X
00125 #endif /* !defined(_M_IX86) */
00126 
00127 /* EOF */

Generated on Sun May 27 2012 04:25:51 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.