"save your files before committing them!" -> good
[reactos.git] / reactos / dll / win32 / opengl32 / gl.c
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * FILE: lib/opengl32/gl.c
5 * PURPOSE: OpenGL32 lib, glXXX functions
6 * PROGRAMMER: Anich Gregor (blight)
7 * UPDATE HISTORY:
8 * Feb 2, 2004: Created
9 */
10
11 /* On a x86 we call the ICD functions in a special-way:
12 *
13 * For every glXXX function we export a glXXX entry-point which loads the
14 * matching "real" function pointer from the NtCurrentTeb()->glDispatchTable
15 * for gl functions in teblist.h and for others it gets the pointer from
16 * NtCurrentTeb()->glTable and jmps to the address, leaving the stack alone and
17 * letting the "real" function return for us.
18 * Royce has implemented this in NASM =D
19 *
20 * On other machines we use C to forward the calls (slow...)
21 */
22
23 #include "opengl32.h"
24
25 #if defined(_M_IX86)
26 C_ASSERT(FIELD_OFFSET(TEB, glTable) == 0xbe8);
27 #endif
28
29 int STDCALL glEmptyFunc0() { return 0; }
30 int STDCALL glEmptyFunc4( long l1 ) { return 0; }
31 int STDCALL glEmptyFunc8( long l1, long l2 ) { return 0; }
32 int STDCALL glEmptyFunc12( long l1, long l2, long l3 ) { return 0; }
33 int STDCALL glEmptyFunc16( long l1, long l2, long l3, long l4 ) { return 0; }
34 int STDCALL glEmptyFunc20( long l1, long l2, long l3, long l4, long l5 )
35 { return 0; }
36 int STDCALL glEmptyFunc24( long l1, long l2, long l3, long l4, long l5,
37 long l6 ) { return 0; }
38 int STDCALL glEmptyFunc28( long l1, long l2, long l3, long l4, long l5,
39 long l6, long l7 ) { return 0; }
40 int STDCALL glEmptyFunc32( long l1, long l2, long l3, long l4, long l5,
41 long l6, long l7, long l8 ) { return 0; }
42 int STDCALL glEmptyFunc36( long l1, long l2, long l3, long l4, long l5,
43 long l6, long l7, long l8, long l9 ) { return 0; }
44 int STDCALL glEmptyFunc40( long l1, long l2, long l3, long l4, long l5,
45 long l6, long l7, long l8, long l9, long l10 )
46 { return 0; }
47 int STDCALL glEmptyFunc44( long l1, long l2, long l3, long l4, long l5,
48 long l6, long l7, long l8, long l9, long l10,
49 long l11 ) { return 0; }
50 int STDCALL glEmptyFunc48( long l1, long l2, long l3, long l4, long l5,
51 long l6, long l7, long l8, long l9, long l10,
52 long l11, long l12 ) { return 0; }
53 int STDCALL glEmptyFunc52( long l1, long l2, long l3, long l4, long l5,
54 long l6, long l7, long l8, long l9, long l10,
55 long l11, long l12, long l13 ) { return 0; }
56 int STDCALL glEmptyFunc56( long l1, long l2, long l3, long l4, long l5,
57 long l6, long l7, long l8, long l9, long l10,
58 long l11, long l12, long l13, long l14 )
59 { return 0; }
60
61 #if defined(_M_IX86)
62 # define FOO(x) #x
63
64 #if __MINGW32__
65 # define X(func, ret, typeargs, args, icdidx, tebidx, stack) \
66 __asm__(".align 4" "\n\t" \
67 ".globl _"#func"@"#stack "\n\t" \
68 "_"#func"@"#stack":" "\n\t" \
69 " movl %fs:0x18, %eax" "\n\t" \
70 " movl 0xbe8(%eax), %eax" "\n\t" \
71 " jmp *"FOO((icdidx*4))"(%eax)" "\n\t");
72 #else
73 # define X(func, ret, typeargs, args, icdidx, tebidx, stack) \
74 ret STDCALL func typeargs \
75 { \
76 PROC *table; \
77 PROC fn; \
78 if (tebidx >= 0 && 0) \
79 { \
80 table = (PROC *)NtCurrentTeb()->glDispatchTable; \
81 fn = table[tebidx]; \
82 } \
83 else \
84 { \
85 table = (PROC *)NtCurrentTeb()->glTable; \
86 fn = table[icdidx]; \
87 } \
88 return (ret)((ret(*)typeargs)fn)args; \
89 }
90 #endif
91
92 GLFUNCS_MACRO
93 # undef FOO
94 # undef X
95 #else /* defined(_M_IX86) */
96 # define X(func, ret, typeargs, args, icdidx, tebidx, stack) \
97 ret STDCALL func typeargs \
98 { \
99 PROC *table; \
100 PROC fn; \
101 if (tebidx >= 0 && 0) \
102 { \
103 table = (PROC *)NtCurrentTeb()->glDispatchTable; \
104 fn = table[tebidx]; \
105 } \
106 else \
107 { \
108 table = (PROC *)NtCurrentTeb()->glTable; \
109 fn = table[icdidx]; \
110 } \
111 return (ret)((ret(*)typeargs)fn)args; \
112 }
113
114 GLFUNCS_MACRO
115
116 # undef X
117 #endif /* !defined(_M_IX86) */
118
119 /* EOF */