-/* $Id: opengl32.c,v 1.1 2004/02/01 07:11:06 royce Exp $
+/* $Id: opengl32.c,v 1.2 2004/02/01 17:07:16 royce Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
#define EXPORT __declspec(dllexport)
+static void OPENGL32_ThreadDetach()
+{
+ /* FIXME - do we need to release some HDC or something? */
+ lpvData = (OPENGL32_ThreadData*)TlsGetValue ( OPENGL32_tls );
+ if ( lpvData != NULL )
+ LocalFree((HLOCAL) lpvData );
+}
+
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD Reason, LPVOID Reserved)
{
+ GLTHREADDATA* lpData = NULL;
printf("OpenGL32.DLL DllMain called!\n");
switch ( Reason )
{
+ /* The DLL is loading due to process
+ * initialization or a call to LoadLibrary.
+ */
case DLL_PROCESS_ATTACH:
- /* FIXME - setup TLS */
- break;
+ OPENGL32_tls = TlsAlloc();
+ if ( 0xFFFFFFFF == OPENGL32_tls )
+ return FALSE;
+ OPENGL32_processdata.funclist_count = 1;
+ OPENGL32_processdata.list = malloc ( sizeof(GLFUNCLIST*) * OPENGL32_processdata.funclist_count );
+ OPENGL32_processdata.list[0] = malloc ( sizeof(GLFUNCLIST) );
+ memset ( OPENGL32_processdata.list[0], 0, sizeof(GLFUNCLIST) );
+ /* FIXME - load mesa32 into first funclist */
+ /* FIXME - get list of ICDs from registry */
+ // No break: Initialize the index for first thread.
+
+ /* The attached process creates a new thread. */
case DLL_THREAD_ATTACH:
+ lpData = (GLTHREADDATA*)LocalAlloc(LPTR, sizeof(GLTHREADDATA));
+ if ( lpData != NULL )
+ {
+ memset ( lpData, 0, sizeof(GLTHREADDATA) );
+ (void)TlsSetValue ( OPENGL32_tls, lpData );
+ }
+ lpData->hdc = NULL;
+ /* FIXME - defaulting to mesa3d, but shouldn't */
+ lpData->list = OPENGL32_processdata.list[0];
break;
+
+ /* The thread of the attached process terminates. */
case DLL_THREAD_DETACH:
+ /* Release the allocated memory for this thread.*/
+ OPENGL32_ThreadDetach();
break;
+
+ /* DLL unload due to process termination or FreeLibrary. */
case DLL_PROCESS_DETACH:
+ OPENGL32_ThreadDetach();
+ TlsFree(OPENGL32_tls);
break;
}
return TRUE;
-; $Id: opengl32.edf,v 1.1 2004/02/01 07:11:06 royce Exp $
+; $Id: opengl32.edf,v 1.2 2004/02/01 17:07:16 royce Exp $
;
; opengl32.edf
;
glAlphaFunc=glAlphaFunc@8
glAreTexturesResident=glAreTexturesResident@12
glArrayElement=glArrayElement@4
-glBegin=glBegin@0
+glBegin=glBegin@4
glBindTexture=glBindTexture@8
glBitmap=glBitmap@28
glBlendFunc=glBlendFunc@8
-/* $Id: opengl32.h,v 1.1 2004/02/01 07:11:06 royce Exp $
+/* $Id: opengl32.h,v 1.2 2004/02/01 17:07:16 royce Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
PGLEND glEnd;
} GLFUNCLIST;
+typedef struct tagGLPROCESSDATA
+{
+ int funclist_count;
+ GLFUNCLIST* lists; // array of GLFUNCLIST pointers
+} GLPROCESSDATA;
+
+typedef struct tagGLTHREADDATA
+{
+ HDC hdc; // current HDC
+ GLFUNCLIST* list; // *current* func list
+ /* FIXME - what else do we need here? */
+}; GLTHREADDATA;
+
+extern DWORD OPENGL32_tls;
+extern GLPROCESSDATA OPENGL32_processdata;
+
#endif//OPENGL32_PRIVATE_H
-/* $Id: stubs.c,v 1.1 2004/02/01 07:11:06 royce Exp $
+/* $Id: stubs.c,v 1.2 2004/02/01 17:07:16 royce Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
OPENGL32_GetFuncList(); // see bottom of this file...
/*
- * @unimplemented
+ * @implemented
*/
void
WINAPI
GLenum op,
GLfloat value )
{
- UNIMPLEMENTED; /* FIXME */
+ GLFUNCLIST* list = OPENGL32_GetFuncList();
+ /* FIXME - jump directly to target... */
+ if ( list )
+ (*list->glAccum)(op,value);
}
/*
- * @unimplemented
+ * @implemented
*/
static // not exported, except via wglGetProcAddress
void
GLsizei width,
GLsizei height )
{
- UNIMPLEMENTED; /* FIXME */
+ (*OPENGL32_GetFuncList()->glAddSwapHintRectWIN)(x,y,width,height);
}
/*
- * @unimplemented
+ * @implemented
*/
void
WINAPI
GLenum func,
GLclampf ref )
{
- UNIMPLEMENTED; /* FIXME */
+ (*OPENGL32_GetFuncList()->glAlphaFunc)(func,ref);
}
/*
GLFUNCLIST*
OPENGL32_GetFuncList()
{
- /* FIXME - this is sooooo not right, but it's close... */
- static GLFUNCLIST* list = NULL;
- if ( !list )
- {
- list = malloc ( sizeof(GLFUNCLIST) );
- memset ( list, 0, sizeof(GLFUNCLIST) );
- list->glAccum = glAccum;
- list->glAddSwapHintRectWIN = glAddSwapHintRectWIN;
- list->glArrayElement = glArrayElement;
- list->glBegin = glBegin;
- list->glBindTexture = glBindTexture;
- list->glEnd = glEnd;
- /* FIXME - add more */
- /* FIXME - query registry looking for drivers, we actually
- need multiple GLFUNCLIST objects depending on which driver
- the end-user is currently interacting with
- */
- }
- return list;
+ threaddata = (OPENGL32_ThreadData*)TlsGetValue ( OPENGL32_tls );
+ ASSERT(threaddata);
+ return threaddata->list;
}