[OPENGL32]
[reactos.git] / dll / opengl / opengl32 / glapi_x86.s
index 2bfb61e..017dc7e 100644 (file)
@@ -7,19 +7,48 @@
 
 /* X86 opengl API entry points, fast forward to the current thread's dispatch table */
 #include <asm.inc>
+#include <ks386.inc>
+
+.data
+ASSUME nothing
+
+.align 16
 
 .code
 
+#ifdef OPENG32_USE_TLS
 EXTERN _OglTlsIndex:DWORD
 EXTERN _TlsGetValue@4:PROC
+#endif
 
 MACRO(USE_GL_FUNC, name, offset, stack)
 PUBLIC _gl&name&@&stack
 .PROC _gl&name&@&stack
+
+FPO 0, 0, 0, 0, 0, FRAME_FPO
+
+#ifdef OPENG32_USE_TLS
     push _OglTlsIndex
     call _TlsGetValue@4
+    /* If we don't have a thread data, this is a nop */
+    test eax, eax
+    jz name&_fast_ret
+    /* Get the GL table */
     mov eax, [eax]
+#else
+    /* Get the TEB */
+    mov eax, fs:[TEB_SELF]
+    /* Get the GL table */
+    mov eax, [eax + TEB_GL_TABLE]
+#endif
+
+    /* If we don't have a dispatch table, this is a nop */
+    test eax, eax
+    jz name&_fast_ret
+    /* Jump into the ICD */
     jmp dword ptr [eax+4*VAL(offset)]
+name&_fast_ret:
+    ret VAL(stack)
 .ENDP
 ENDM
 
@@ -360,4 +389,4 @@ USE_GL_FUNC Vertex4sv, 149, 4
 USE_GL_FUNC VertexPointer, 321, 16
 USE_GL_FUNC Viewport, 305, 16
 
-END
\ No newline at end of file
+END