2008-07-17 11:37:49 +00:00
|
|
|
/*
|
2004-02-01 07:11:06 +00:00
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS kernel
|
2013-09-21 14:17:59 +00:00
|
|
|
* FILE: lib/opengl32/opengl.h
|
|
|
|
* PURPOSE: OpenGL32 lib, general header
|
2004-02-01 07:11:06 +00:00
|
|
|
*/
|
|
|
|
|
2014-02-07 18:02:02 +00:00
|
|
|
#ifndef _OPENGL32_PCH_
|
|
|
|
#define _OPENGL32_PCH_
|
2008-07-17 11:37:49 +00:00
|
|
|
|
|
|
|
#define WIN32_NO_STATUS
|
2013-09-21 14:17:59 +00:00
|
|
|
#include <stdarg.h>
|
2013-01-24 23:00:42 +00:00
|
|
|
#include <windef.h>
|
|
|
|
#include <winbase.h>
|
|
|
|
#include <winuser.h>
|
2013-09-21 14:17:59 +00:00
|
|
|
#include <wingdi.h>
|
2013-01-24 23:00:42 +00:00
|
|
|
#include <winddi.h>
|
2013-09-21 14:17:59 +00:00
|
|
|
#include <GL/gl.h>
|
2008-07-17 11:37:49 +00:00
|
|
|
|
2017-11-18 12:49:37 +00:00
|
|
|
#ifndef OPENGL32_USE_TLS
|
|
|
|
#include <pstypes.h>
|
|
|
|
#endif
|
|
|
|
|
2014-01-20 13:07:26 +00:00
|
|
|
#include <wine/debug.h>
|
|
|
|
|
2013-09-21 14:17:59 +00:00
|
|
|
#include "icd.h"
|
2004-02-05 04:28:11 +00:00
|
|
|
|
2014-07-28 13:03:10 +00:00
|
|
|
/* *$%$£^§! headers inclusion */
|
|
|
|
static __inline
|
|
|
|
BOOLEAN
|
|
|
|
RemoveEntryList(
|
|
|
|
_In_ PLIST_ENTRY Entry)
|
|
|
|
{
|
|
|
|
PLIST_ENTRY OldFlink;
|
|
|
|
PLIST_ENTRY OldBlink;
|
|
|
|
|
|
|
|
OldFlink = Entry->Flink;
|
|
|
|
OldBlink = Entry->Blink;
|
|
|
|
OldFlink->Blink = OldBlink;
|
|
|
|
OldBlink->Flink = OldFlink;
|
|
|
|
return (OldFlink == OldBlink);
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline
|
|
|
|
VOID
|
|
|
|
InsertTailList(
|
|
|
|
_In_ PLIST_ENTRY ListHead,
|
|
|
|
_In_ PLIST_ENTRY Entry
|
|
|
|
)
|
|
|
|
{
|
|
|
|
PLIST_ENTRY OldBlink;
|
|
|
|
OldBlink = ListHead->Blink;
|
|
|
|
Entry->Flink = ListHead;
|
|
|
|
Entry->Blink = OldBlink;
|
|
|
|
OldBlink->Flink = Entry;
|
|
|
|
ListHead->Blink = Entry;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static __inline
|
|
|
|
VOID
|
|
|
|
InitializeListHead(
|
|
|
|
_Inout_ PLIST_ENTRY ListHead
|
|
|
|
)
|
|
|
|
{
|
|
|
|
ListHead->Flink = ListHead->Blink = ListHead;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern LIST_ENTRY ContextListHead;
|
|
|
|
|
2013-09-21 14:17:59 +00:00
|
|
|
struct wgl_context
|
|
|
|
{
|
|
|
|
DWORD magic;
|
|
|
|
volatile LONG lock;
|
|
|
|
|
2014-07-28 13:03:10 +00:00
|
|
|
LIST_ENTRY ListEntry;
|
|
|
|
|
2013-09-21 14:17:59 +00:00
|
|
|
DHGLRC dhglrc;
|
|
|
|
struct ICD_Data* icd_data;
|
|
|
|
INT pixelformat;
|
|
|
|
volatile LONG thread_id;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define WGL_DC_OBJ_DC 0x1
|
|
|
|
struct wgl_dc_data
|
2004-02-02 05:36:37 +00:00
|
|
|
{
|
2013-09-21 14:17:59 +00:00
|
|
|
/* Header */
|
|
|
|
union
|
|
|
|
{
|
|
|
|
HWND hwnd;
|
|
|
|
HDC hdc;
|
|
|
|
HANDLE u;
|
|
|
|
} owner;
|
|
|
|
ULONG flags;
|
|
|
|
|
|
|
|
/* Pixel format */
|
|
|
|
INT pixelformat;
|
|
|
|
|
|
|
|
/* ICD */
|
|
|
|
struct ICD_Data* icd_data;
|
|
|
|
INT nb_icd_formats;
|
|
|
|
|
|
|
|
/* Software implementation */
|
|
|
|
INT nb_sw_formats;
|
|
|
|
void* sw_data;
|
|
|
|
|
|
|
|
/* Linked list */
|
|
|
|
struct wgl_dc_data* next;
|
|
|
|
};
|
|
|
|
|
2014-07-28 13:03:10 +00:00
|
|
|
/* Clean up functions */
|
|
|
|
void IntDeleteAllContexts(void);
|
|
|
|
void IntDeleteAllICDs(void);
|
|
|
|
|
2017-11-18 12:49:37 +00:00
|
|
|
FORCEINLINE
|
2013-09-21 14:17:59 +00:00
|
|
|
const GLDISPATCHTABLE*
|
|
|
|
IntGetCurrentDispatchTable(void)
|
2004-02-01 17:07:16 +00:00
|
|
|
{
|
2013-09-21 14:17:59 +00:00
|
|
|
return (GLDISPATCHTABLE*)NtCurrentTeb()->glTable;
|
|
|
|
}
|
2017-11-18 12:49:37 +00:00
|
|
|
|
|
|
|
FORCEINLINE
|
|
|
|
void
|
|
|
|
IntSetCurrentDispatchTable(const GLDISPATCHTABLE* table)
|
|
|
|
{
|
|
|
|
NtCurrentTeb()->glTable = (void*)table;
|
|
|
|
}
|
|
|
|
|
|
|
|
FORCEINLINE
|
|
|
|
void
|
|
|
|
IntMakeCurrent(HGLRC hglrc, HDC hdc, struct wgl_dc_data* dc_data)
|
|
|
|
{
|
|
|
|
TEB* CurrentTeb = NtCurrentTeb();
|
|
|
|
|
|
|
|
CurrentTeb->glCurrentRC = hglrc;
|
|
|
|
CurrentTeb->glReserved2 = hdc;
|
|
|
|
CurrentTeb->glContext = dc_data;
|
|
|
|
}
|
|
|
|
|
|
|
|
FORCEINLINE
|
|
|
|
HGLRC
|
|
|
|
IntGetCurrentRC(void)
|
|
|
|
{
|
|
|
|
return NtCurrentTeb()->glCurrentRC;
|
|
|
|
}
|
|
|
|
|
|
|
|
FORCEINLINE
|
|
|
|
HDC
|
|
|
|
IntGetCurrentDC(void)
|
|
|
|
{
|
|
|
|
return NtCurrentTeb()->glReserved2;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline
|
|
|
|
struct wgl_dc_data*
|
|
|
|
IntGetCurrentDcData(void)
|
|
|
|
{
|
|
|
|
return NtCurrentTeb()->glContext;
|
|
|
|
}
|
|
|
|
|
|
|
|
FORCEINLINE
|
|
|
|
void
|
|
|
|
IntSetCurrentICDPrivate(void* value)
|
|
|
|
{
|
|
|
|
NtCurrentTeb()->glReserved1[0] = (ULONG_PTR)value;
|
|
|
|
}
|
|
|
|
|
|
|
|
FORCEINLINE
|
|
|
|
void*
|
|
|
|
IntGetCurrentICDPrivate(void)
|
|
|
|
{
|
|
|
|
return (void*)NtCurrentTeb()->glReserved1[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
FORCEINLINE
|
|
|
|
DHGLRC
|
|
|
|
IntGetCurrentDHGLRC(void)
|
|
|
|
{
|
|
|
|
struct wgl_context* ctx = (struct wgl_context*)IntGetCurrentRC();
|
|
|
|
if(!ctx) return NULL;
|
|
|
|
return ctx->dhglrc;
|
|
|
|
}
|
|
|
|
|
2013-09-21 14:17:59 +00:00
|
|
|
/* Software implementation functions */
|
|
|
|
INT sw_DescribePixelFormat(HDC hdc, INT format, UINT size, PIXELFORMATDESCRIPTOR* descr);
|
|
|
|
BOOL sw_SetPixelFormat(HDC hdc, struct wgl_dc_data*, INT format);
|
|
|
|
DHGLRC sw_CreateContext(struct wgl_dc_data*);
|
|
|
|
BOOL sw_DeleteContext(DHGLRC dhglrc);
|
|
|
|
BOOL sw_SetContext(struct wgl_dc_data* dc_data, DHGLRC dhglrc);
|
|
|
|
void sw_ReleaseContext(DHGLRC hglrc);
|
|
|
|
PROC sw_GetProcAddress(LPCSTR name);
|
|
|
|
BOOL sw_CopyContext(DHGLRC dhglrcSrc, DHGLRC dhglrcDst, UINT mask);
|
|
|
|
BOOL sw_ShareLists(DHGLRC dhglrcSrc, DHGLRC dhglrcDst);
|
|
|
|
BOOL sw_SwapBuffers(HDC hdc, struct wgl_dc_data* dc_data);
|
2014-02-07 18:02:02 +00:00
|
|
|
|
|
|
|
#endif /* _OPENGL32_PCH_ */
|