[OPENGL32_NEW]

Introduce a new opengl32 implementation, the 3D library with better perspectives (tm), featuring:
 - A new software rendering implementation on top of osmesa.
 - Rendering to bitmaps
 - Thread safety.
 - A try to be really compatible with ICD DLLs (WIP)
 - Other cool stuff, check log for details.
WIP, the SW implementation already works.

svn path=/trunk/; revision=60150
This commit is contained in:
Jérôme Gardou 2013-09-15 20:54:01 +00:00
parent 535a0d655d
commit c4120ef2b8
10 changed files with 6781 additions and 0 deletions

View file

@ -0,0 +1,37 @@
spec2def(opengl32.dll opengl32.spec ADD_IMPORTLIB)
add_definitions(
-D_GDI32_ # prevent gl* being declared __declspec(dllimport) in MS headers
-DBUILD_GL32 # declare gl* as __declspec(dllexport) in Mesa headers
)
# useful to test under windows <> w2k3
set(OPENGL32_USE_TLS TRUE)
if(OPENGL32_USE_TLS)
add_definitions(-DOPENGL32_USE_TLS)
endif()
list(APPEND SOURCE
apistubs.c
dllmain.c
icdload.c
swimpl.c
wgl.c
${CMAKE_CURRENT_BINARY_DIR}/opengl32_stubs.c
${CMAKE_CURRENT_BINARY_DIR}/opengl32.def
)
if((ARCH STREQUAL "i386") AND (NOT OPENGL32_USE_TLS))
# Optimisation: use asm trampolines to ICD provided functions
list(APPEND SOURCE
glapi_x86.s
)
endif()
add_library(opengl32_new SHARED ${SOURCE})
target_link_libraries(opengl32_new wine ${PSEH_LIB})
set_module_type(opengl32_new win32dll)
add_importlibs(opengl32_new gdi32 user32 advapi32 msvcrt kernel32 ntdll)
add_cd_file(TARGET opengl32_new DESTINATION reactos/system32 FOR all)

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,72 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS
* FILE: dll/opengl/opengl32/dllmain.c
* PURPOSE: OpenGL32 DLL
*/
#include "opengl32.h"
#ifdef OPENGL32_USE_TLS
DWORD OglTlsIndex = 0xFFFFFFFF;
#endif
BOOL WINAPI
DllMain(HINSTANCE hInstance, DWORD Reason, LPVOID Reserved)
{
#ifdef OPENGL32_USE_TLS
struct Opengl32_ThreadData* ThreadData;
#endif
switch ( Reason )
{
/* The DLL is loading due to process
* initialization or a call to LoadLibrary.
*/
case DLL_PROCESS_ATTACH:
#ifdef OPENGL32_USE_TLS
OglTlsIndex = TlsAlloc();
if(OglTlsIndex == TLS_OUT_OF_INDEXES)
return FALSE;
#endif
/* Fall through */
case DLL_THREAD_ATTACH:
#ifdef OPENGL32_USE_TLS
ThreadData = HeapAlloc(GetProcessHeap(), 0, sizeof(*ThreadData));
if(!ThreadData)
return FALSE;
TlsSetValue(OglTlsIndex, ThreadData);
ThreadData->ProcTable = &StubTable;
ThreadData->hglrc = NULL;
ThreadData->hdc = NULL;
ThreadData->dc_data = NULL;
#else
NtCurrentTeb()->glTable = &StubTable.glDispatchTable;
#endif // defined(OPENGL32_USE_TLS)
break;
case DLL_THREAD_DETACH:
/* Clean up */
#ifdef OPENGL32_USE_TLS
ThreadData = TlsGetValue(OglTlsIndex);
if(ThreadData)
HeapFree(GetProcessHeap(), 0, ThreadData);
#else
NtCurrentTeb->glTable = NULL;
#endif // defined(OPENGL32_USE_TLS)
break;
case DLL_PROCESS_DETACH:
/* Clean up */
#ifdef OPENGL32_USE_TLS
ThreadData = TlsGetValue(OglTlsIndex);
if(ThreadData)
HeapFree(GetProcessHeap(), 0, ThreadData);
TlsFree(OglTlsIndex);
#else
NtCurrentTeb->glTable = NULL;
#endif // defined(OPENGL32_USE_TLS)
break;
}
return TRUE;
}

View file

@ -0,0 +1,338 @@
/* List of all GL functions exported by opengl32.dll */
USE_GL_FUNC(Accum)
USE_GL_FUNC(AlphaFunc)
USE_GL_FUNC(AreTexturesResident)
USE_GL_FUNC(ArrayElement)
USE_GL_FUNC(Begin)
USE_GL_FUNC(BindTexture)
USE_GL_FUNC(Bitmap)
USE_GL_FUNC(BlendFunc)
USE_GL_FUNC(CallList)
USE_GL_FUNC(CallLists)
USE_GL_FUNC(Clear)
USE_GL_FUNC(ClearAccum)
USE_GL_FUNC(ClearColor)
USE_GL_FUNC(ClearDepth)
USE_GL_FUNC(ClearIndex)
USE_GL_FUNC(ClearStencil)
USE_GL_FUNC(ClipPlane)
USE_GL_FUNC(Color3b)
USE_GL_FUNC(Color3bv)
USE_GL_FUNC(Color3d)
USE_GL_FUNC(Color3dv)
USE_GL_FUNC(Color3f)
USE_GL_FUNC(Color3fv)
USE_GL_FUNC(Color3i)
USE_GL_FUNC(Color3iv)
USE_GL_FUNC(Color3s)
USE_GL_FUNC(Color3sv)
USE_GL_FUNC(Color3ub)
USE_GL_FUNC(Color3ubv)
USE_GL_FUNC(Color3ui)
USE_GL_FUNC(Color3uiv)
USE_GL_FUNC(Color3us)
USE_GL_FUNC(Color3usv)
USE_GL_FUNC(Color4b)
USE_GL_FUNC(Color4bv)
USE_GL_FUNC(Color4d)
USE_GL_FUNC(Color4dv)
USE_GL_FUNC(Color4f)
USE_GL_FUNC(Color4fv)
USE_GL_FUNC(Color4i)
USE_GL_FUNC(Color4iv)
USE_GL_FUNC(Color4s)
USE_GL_FUNC(Color4sv)
USE_GL_FUNC(Color4ub)
USE_GL_FUNC(Color4ubv)
USE_GL_FUNC(Color4ui)
USE_GL_FUNC(Color4uiv)
USE_GL_FUNC(Color4us)
USE_GL_FUNC(Color4usv)
USE_GL_FUNC(ColorMask)
USE_GL_FUNC(ColorMaterial)
USE_GL_FUNC(ColorPointer)
USE_GL_FUNC(CopyPixels)
USE_GL_FUNC(CopyTexImage1D)
USE_GL_FUNC(CopyTexImage2D)
USE_GL_FUNC(CopyTexSubImage1D)
USE_GL_FUNC(CopyTexSubImage2D)
USE_GL_FUNC(CullFace)
USE_GL_FUNC(DeleteLists)
USE_GL_FUNC(DeleteTextures)
USE_GL_FUNC(DepthFunc)
USE_GL_FUNC(DepthMask)
USE_GL_FUNC(DepthRange)
USE_GL_FUNC(Disable)
USE_GL_FUNC(DisableClientState)
USE_GL_FUNC(DrawArrays)
USE_GL_FUNC(DrawBuffer)
USE_GL_FUNC(DrawElements)
USE_GL_FUNC(DrawPixels)
USE_GL_FUNC(EdgeFlag)
USE_GL_FUNC(EdgeFlagPointer)
USE_GL_FUNC(EdgeFlagv)
USE_GL_FUNC(Enable)
USE_GL_FUNC(EnableClientState)
USE_GL_FUNC(End)
USE_GL_FUNC(EndList)
USE_GL_FUNC(EvalCoord1d)
USE_GL_FUNC(EvalCoord1dv)
USE_GL_FUNC(EvalCoord1f)
USE_GL_FUNC(EvalCoord1fv)
USE_GL_FUNC(EvalCoord2d)
USE_GL_FUNC(EvalCoord2dv)
USE_GL_FUNC(EvalCoord2f)
USE_GL_FUNC(EvalCoord2fv)
USE_GL_FUNC(EvalMesh1)
USE_GL_FUNC(EvalMesh2)
USE_GL_FUNC(EvalPoint1)
USE_GL_FUNC(EvalPoint2)
USE_GL_FUNC(FeedbackBuffer)
USE_GL_FUNC(Finish)
USE_GL_FUNC(Flush)
USE_GL_FUNC(Fogf)
USE_GL_FUNC(Fogfv)
USE_GL_FUNC(Fogi)
USE_GL_FUNC(Fogiv)
USE_GL_FUNC(FrontFace)
USE_GL_FUNC(Frustum)
USE_GL_FUNC(GenLists)
USE_GL_FUNC(GenTextures)
USE_GL_FUNC(GetBooleanv)
USE_GL_FUNC(GetClipPlane)
USE_GL_FUNC(GetDoublev)
USE_GL_FUNC(GetError)
USE_GL_FUNC(GetFloatv)
USE_GL_FUNC(GetIntegerv)
USE_GL_FUNC(GetLightfv)
USE_GL_FUNC(GetLightiv)
USE_GL_FUNC(GetMapdv)
USE_GL_FUNC(GetMapfv)
USE_GL_FUNC(GetMapiv)
USE_GL_FUNC(GetMaterialfv)
USE_GL_FUNC(GetMaterialiv)
USE_GL_FUNC(GetPixelMapfv)
USE_GL_FUNC(GetPixelMapuiv)
USE_GL_FUNC(GetPixelMapusv)
USE_GL_FUNC(GetPointerv)
USE_GL_FUNC(GetPolygonStipple)
USE_GL_FUNC(GetString)
USE_GL_FUNC(GetTexEnvfv)
USE_GL_FUNC(GetTexEnviv)
USE_GL_FUNC(GetTexGendv)
USE_GL_FUNC(GetTexGenfv)
USE_GL_FUNC(GetTexGeniv)
USE_GL_FUNC(GetTexImage)
USE_GL_FUNC(GetTexLevelParameterfv)
USE_GL_FUNC(GetTexLevelParameteriv)
USE_GL_FUNC(GetTexParameterfv)
USE_GL_FUNC(GetTexParameteriv)
USE_GL_FUNC(Hint)
USE_GL_FUNC(IndexMask)
USE_GL_FUNC(IndexPointer)
USE_GL_FUNC(Indexd)
USE_GL_FUNC(Indexdv)
USE_GL_FUNC(Indexf)
USE_GL_FUNC(Indexfv)
USE_GL_FUNC(Indexi)
USE_GL_FUNC(Indexiv)
USE_GL_FUNC(Indexs)
USE_GL_FUNC(Indexsv)
USE_GL_FUNC(Indexub)
USE_GL_FUNC(Indexubv)
USE_GL_FUNC(InitNames)
USE_GL_FUNC(InterleavedArrays)
USE_GL_FUNC(IsEnabled)
USE_GL_FUNC(IsList)
USE_GL_FUNC(IsTexture)
USE_GL_FUNC(LightModelf)
USE_GL_FUNC(LightModelfv)
USE_GL_FUNC(LightModeli)
USE_GL_FUNC(LightModeliv)
USE_GL_FUNC(Lightf)
USE_GL_FUNC(Lightfv)
USE_GL_FUNC(Lighti)
USE_GL_FUNC(Lightiv)
USE_GL_FUNC(LineStipple)
USE_GL_FUNC(LineWidth)
USE_GL_FUNC(ListBase)
USE_GL_FUNC(LoadIdentity)
USE_GL_FUNC(LoadMatrixd)
USE_GL_FUNC(LoadMatrixf)
USE_GL_FUNC(LoadName)
USE_GL_FUNC(LogicOp)
USE_GL_FUNC(Map1d)
USE_GL_FUNC(Map1f)
USE_GL_FUNC(Map2d)
USE_GL_FUNC(Map2f)
USE_GL_FUNC(MapGrid1d)
USE_GL_FUNC(MapGrid1f)
USE_GL_FUNC(MapGrid2d)
USE_GL_FUNC(MapGrid2f)
USE_GL_FUNC(Materialf)
USE_GL_FUNC(Materialfv)
USE_GL_FUNC(Materiali)
USE_GL_FUNC(Materialiv)
USE_GL_FUNC(MatrixMode)
USE_GL_FUNC(MultMatrixd)
USE_GL_FUNC(MultMatrixf)
USE_GL_FUNC(NewList)
USE_GL_FUNC(Normal3b)
USE_GL_FUNC(Normal3bv)
USE_GL_FUNC(Normal3d)
USE_GL_FUNC(Normal3dv)
USE_GL_FUNC(Normal3f)
USE_GL_FUNC(Normal3fv)
USE_GL_FUNC(Normal3i)
USE_GL_FUNC(Normal3iv)
USE_GL_FUNC(Normal3s)
USE_GL_FUNC(Normal3sv)
USE_GL_FUNC(NormalPointer)
USE_GL_FUNC(Ortho)
USE_GL_FUNC(PassThrough)
USE_GL_FUNC(PixelMapfv)
USE_GL_FUNC(PixelMapuiv)
USE_GL_FUNC(PixelMapusv)
USE_GL_FUNC(PixelStoref)
USE_GL_FUNC(PixelStorei)
USE_GL_FUNC(PixelTransferf)
USE_GL_FUNC(PixelTransferi)
USE_GL_FUNC(PixelZoom)
USE_GL_FUNC(PointSize)
USE_GL_FUNC(PolygonMode)
USE_GL_FUNC(PolygonOffset)
USE_GL_FUNC(PolygonStipple)
USE_GL_FUNC(PopAttrib)
USE_GL_FUNC(PopClientAttrib)
USE_GL_FUNC(PopMatrix)
USE_GL_FUNC(PopName)
USE_GL_FUNC(PrioritizeTextures)
USE_GL_FUNC(PushAttrib)
USE_GL_FUNC(PushClientAttrib)
USE_GL_FUNC(PushMatrix)
USE_GL_FUNC(PushName)
USE_GL_FUNC(RasterPos2d)
USE_GL_FUNC(RasterPos2dv)
USE_GL_FUNC(RasterPos2f)
USE_GL_FUNC(RasterPos2fv)
USE_GL_FUNC(RasterPos2i)
USE_GL_FUNC(RasterPos2iv)
USE_GL_FUNC(RasterPos2s)
USE_GL_FUNC(RasterPos2sv)
USE_GL_FUNC(RasterPos3d)
USE_GL_FUNC(RasterPos3dv)
USE_GL_FUNC(RasterPos3f)
USE_GL_FUNC(RasterPos3fv)
USE_GL_FUNC(RasterPos3i)
USE_GL_FUNC(RasterPos3iv)
USE_GL_FUNC(RasterPos3s)
USE_GL_FUNC(RasterPos3sv)
USE_GL_FUNC(RasterPos4d)
USE_GL_FUNC(RasterPos4dv)
USE_GL_FUNC(RasterPos4f)
USE_GL_FUNC(RasterPos4fv)
USE_GL_FUNC(RasterPos4i)
USE_GL_FUNC(RasterPos4iv)
USE_GL_FUNC(RasterPos4s)
USE_GL_FUNC(RasterPos4sv)
USE_GL_FUNC(ReadBuffer)
USE_GL_FUNC(ReadPixels)
USE_GL_FUNC(Rectd)
USE_GL_FUNC(Rectdv)
USE_GL_FUNC(Rectf)
USE_GL_FUNC(Rectfv)
USE_GL_FUNC(Recti)
USE_GL_FUNC(Rectiv)
USE_GL_FUNC(Rects)
USE_GL_FUNC(Rectsv)
USE_GL_FUNC(RenderMode)
USE_GL_FUNC(Rotated)
USE_GL_FUNC(Rotatef)
USE_GL_FUNC(Scaled)
USE_GL_FUNC(Scalef)
USE_GL_FUNC(Scissor)
USE_GL_FUNC(SelectBuffer)
USE_GL_FUNC(ShadeModel)
USE_GL_FUNC(StencilFunc)
USE_GL_FUNC(StencilMask)
USE_GL_FUNC(StencilOp)
USE_GL_FUNC(TexCoord1d)
USE_GL_FUNC(TexCoord1dv)
USE_GL_FUNC(TexCoord1f)
USE_GL_FUNC(TexCoord1fv)
USE_GL_FUNC(TexCoord1i)
USE_GL_FUNC(TexCoord1iv)
USE_GL_FUNC(TexCoord1s)
USE_GL_FUNC(TexCoord1sv)
USE_GL_FUNC(TexCoord2d)
USE_GL_FUNC(TexCoord2dv)
USE_GL_FUNC(TexCoord2f)
USE_GL_FUNC(TexCoord2fv)
USE_GL_FUNC(TexCoord2i)
USE_GL_FUNC(TexCoord2iv)
USE_GL_FUNC(TexCoord2s)
USE_GL_FUNC(TexCoord2sv)
USE_GL_FUNC(TexCoord3d)
USE_GL_FUNC(TexCoord3dv)
USE_GL_FUNC(TexCoord3f)
USE_GL_FUNC(TexCoord3fv)
USE_GL_FUNC(TexCoord3i)
USE_GL_FUNC(TexCoord3iv)
USE_GL_FUNC(TexCoord3s)
USE_GL_FUNC(TexCoord3sv)
USE_GL_FUNC(TexCoord4d)
USE_GL_FUNC(TexCoord4dv)
USE_GL_FUNC(TexCoord4f)
USE_GL_FUNC(TexCoord4fv)
USE_GL_FUNC(TexCoord4i)
USE_GL_FUNC(TexCoord4iv)
USE_GL_FUNC(TexCoord4s)
USE_GL_FUNC(TexCoord4sv)
USE_GL_FUNC(TexCoordPointer)
USE_GL_FUNC(TexEnvf)
USE_GL_FUNC(TexEnvfv)
USE_GL_FUNC(TexEnvi)
USE_GL_FUNC(TexEnviv)
USE_GL_FUNC(TexGend)
USE_GL_FUNC(TexGendv)
USE_GL_FUNC(TexGenf)
USE_GL_FUNC(TexGenfv)
USE_GL_FUNC(TexGeni)
USE_GL_FUNC(TexGeniv)
USE_GL_FUNC(TexImage1D)
USE_GL_FUNC(TexImage2D)
USE_GL_FUNC(TexParameterf)
USE_GL_FUNC(TexParameterfv)
USE_GL_FUNC(TexParameteri)
USE_GL_FUNC(TexParameteriv)
USE_GL_FUNC(TexSubImage1D)
USE_GL_FUNC(TexSubImage2D)
USE_GL_FUNC(Translated)
USE_GL_FUNC(Translatef)
USE_GL_FUNC(Vertex2d)
USE_GL_FUNC(Vertex2dv)
USE_GL_FUNC(Vertex2f)
USE_GL_FUNC(Vertex2fv)
USE_GL_FUNC(Vertex2i)
USE_GL_FUNC(Vertex2iv)
USE_GL_FUNC(Vertex2s)
USE_GL_FUNC(Vertex2sv)
USE_GL_FUNC(Vertex3d)
USE_GL_FUNC(Vertex3dv)
USE_GL_FUNC(Vertex3f)
USE_GL_FUNC(Vertex3fv)
USE_GL_FUNC(Vertex3i)
USE_GL_FUNC(Vertex3iv)
USE_GL_FUNC(Vertex3s)
USE_GL_FUNC(Vertex3sv)
USE_GL_FUNC(Vertex4d)
USE_GL_FUNC(Vertex4dv)
USE_GL_FUNC(Vertex4f)
USE_GL_FUNC(Vertex4fv)
USE_GL_FUNC(Vertex4i)
USE_GL_FUNC(Vertex4iv)
USE_GL_FUNC(Vertex4s)
USE_GL_FUNC(Vertex4sv)
USE_GL_FUNC(VertexPointer)
USE_GL_FUNC(Viewport)

View file

@ -0,0 +1,398 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: lib/opengl32/icd.h
* PURPOSE: OpenGL32 lib, ICD specific definitions
*/
#pragma once
#define OPENGL_VERSION_110_ENTRIES 336
struct __GLdispatchTableRec
{
void (GLAPIENTRY * NewList)(GLuint, GLenum);
void (GLAPIENTRY * EndList)(void);
void (GLAPIENTRY * CallList)(GLuint);
void (GLAPIENTRY * CallLists)(GLsizei, GLenum, const GLvoid *);
void (GLAPIENTRY * DeleteLists)(GLuint, GLsizei);
GLuint (GLAPIENTRY * GenLists)(GLsizei);
void (GLAPIENTRY * ListBase)(GLuint);
void (GLAPIENTRY * Begin)(GLenum);
void (GLAPIENTRY * Bitmap)(GLsizei, GLsizei, GLfloat, GLfloat, GLfloat, GLfloat, const GLubyte *);
void (GLAPIENTRY * Color3b)(GLbyte, GLbyte, GLbyte);
void (GLAPIENTRY * Color3bv)(const GLbyte *);
void (GLAPIENTRY * Color3d)(GLdouble, GLdouble, GLdouble);
void (GLAPIENTRY * Color3dv)(const GLdouble *);
void (GLAPIENTRY * Color3f)(GLfloat, GLfloat, GLfloat);
void (GLAPIENTRY * Color3fv)(const GLfloat *);
void (GLAPIENTRY * Color3i)(GLint, GLint, GLint);
void (GLAPIENTRY * Color3iv)(const GLint *);
void (GLAPIENTRY * Color3s)(GLshort, GLshort, GLshort);
void (GLAPIENTRY * Color3sv)(const GLshort *);
void (GLAPIENTRY * Color3ub)(GLubyte, GLubyte, GLubyte);
void (GLAPIENTRY * Color3ubv)(const GLubyte *);
void (GLAPIENTRY * Color3ui)(GLuint, GLuint, GLuint);
void (GLAPIENTRY * Color3uiv)(const GLuint *);
void (GLAPIENTRY * Color3us)(GLushort, GLushort, GLushort);
void (GLAPIENTRY * Color3usv)(const GLushort *);
void (GLAPIENTRY * Color4b)(GLbyte, GLbyte, GLbyte, GLbyte);
void (GLAPIENTRY * Color4bv)(const GLbyte *);
void (GLAPIENTRY * Color4d)(GLdouble, GLdouble, GLdouble, GLdouble);
void (GLAPIENTRY * Color4dv)(const GLdouble *);
void (GLAPIENTRY * Color4f)(GLfloat, GLfloat, GLfloat, GLfloat);
void (GLAPIENTRY * Color4fv)(const GLfloat *);
void (GLAPIENTRY * Color4i)(GLint, GLint, GLint, GLint);
void (GLAPIENTRY * Color4iv)(const GLint *);
void (GLAPIENTRY * Color4s)(GLshort, GLshort, GLshort, GLshort);
void (GLAPIENTRY * Color4sv)(const GLshort *);
void (GLAPIENTRY * Color4ub)(GLubyte, GLubyte, GLubyte, GLubyte);
void (GLAPIENTRY * Color4ubv)(const GLubyte *);
void (GLAPIENTRY * Color4ui)(GLuint, GLuint, GLuint, GLuint);
void (GLAPIENTRY * Color4uiv)(const GLuint *);
void (GLAPIENTRY * Color4us)(GLushort, GLushort, GLushort, GLushort);
void (GLAPIENTRY * Color4usv)(const GLushort *);
void (GLAPIENTRY * EdgeFlag)(GLboolean);
void (GLAPIENTRY * EdgeFlagv)(const GLboolean *);
void (GLAPIENTRY * End)(void);
void (GLAPIENTRY * Indexd)(GLdouble);
void (GLAPIENTRY * Indexdv)(const GLdouble *);
void (GLAPIENTRY * Indexf)(GLfloat);
void (GLAPIENTRY * Indexfv)(const GLfloat *);
void (GLAPIENTRY * Indexi)(GLint);
void (GLAPIENTRY * Indexiv)(const GLint *);
void (GLAPIENTRY * Indexs)(GLshort);
void (GLAPIENTRY * Indexsv)(const GLshort *);
void (GLAPIENTRY * Normal3b)(GLbyte, GLbyte, GLbyte);
void (GLAPIENTRY * Normal3bv)(const GLbyte *);
void (GLAPIENTRY * Normal3d)(GLdouble, GLdouble, GLdouble);
void (GLAPIENTRY * Normal3dv)(const GLdouble *);
void (GLAPIENTRY * Normal3f)(GLfloat, GLfloat, GLfloat);
void (GLAPIENTRY * Normal3fv)(const GLfloat *);
void (GLAPIENTRY * Normal3i)(GLint, GLint, GLint);
void (GLAPIENTRY * Normal3iv)(const GLint *);
void (GLAPIENTRY * Normal3s)(GLshort, GLshort, GLshort);
void (GLAPIENTRY * Normal3sv)(const GLshort *);
void (GLAPIENTRY * RasterPos2d)(GLdouble, GLdouble);
void (GLAPIENTRY * RasterPos2dv)(const GLdouble *);
void (GLAPIENTRY * RasterPos2f)(GLfloat, GLfloat);
void (GLAPIENTRY * RasterPos2fv)(const GLfloat *);
void (GLAPIENTRY * RasterPos2i)(GLint, GLint);
void (GLAPIENTRY * RasterPos2iv)(const GLint *);
void (GLAPIENTRY * RasterPos2s)(GLshort, GLshort);
void (GLAPIENTRY * RasterPos2sv)(const GLshort *);
void (GLAPIENTRY * RasterPos3d)(GLdouble, GLdouble, GLdouble);
void (GLAPIENTRY * RasterPos3dv)(const GLdouble *);
void (GLAPIENTRY * RasterPos3f)(GLfloat, GLfloat, GLfloat);
void (GLAPIENTRY * RasterPos3fv)(const GLfloat *);
void (GLAPIENTRY * RasterPos3i)(GLint, GLint, GLint);
void (GLAPIENTRY * RasterPos3iv)(const GLint *);
void (GLAPIENTRY * RasterPos3s)(GLshort, GLshort, GLshort);
void (GLAPIENTRY * RasterPos3sv)(const GLshort *);
void (GLAPIENTRY * RasterPos4d)(GLdouble, GLdouble, GLdouble, GLdouble);
void (GLAPIENTRY * RasterPos4dv)(const GLdouble *);
void (GLAPIENTRY * RasterPos4f)(GLfloat, GLfloat, GLfloat, GLfloat);
void (GLAPIENTRY * RasterPos4fv)(const GLfloat *);
void (GLAPIENTRY * RasterPos4i)(GLint, GLint, GLint, GLint);
void (GLAPIENTRY * RasterPos4iv)(const GLint *);
void (GLAPIENTRY * RasterPos4s)(GLshort, GLshort, GLshort, GLshort);
void (GLAPIENTRY * RasterPos4sv)(const GLshort *);
void (GLAPIENTRY * Rectd)(GLdouble, GLdouble, GLdouble, GLdouble);
void (GLAPIENTRY * Rectdv)(const GLdouble *, const GLdouble *);
void (GLAPIENTRY * Rectf)(GLfloat, GLfloat, GLfloat, GLfloat);
void (GLAPIENTRY * Rectfv)(const GLfloat *, const GLfloat *);
void (GLAPIENTRY * Recti)(GLint, GLint, GLint, GLint);
void (GLAPIENTRY * Rectiv)(const GLint *, const GLint *);
void (GLAPIENTRY * Rects)(GLshort, GLshort, GLshort, GLshort);
void (GLAPIENTRY * Rectsv)(const GLshort *, const GLshort *);
void (GLAPIENTRY * TexCoord1d)(GLdouble);
void (GLAPIENTRY * TexCoord1dv)(const GLdouble *);
void (GLAPIENTRY * TexCoord1f)(GLfloat);
void (GLAPIENTRY * TexCoord1fv)(const GLfloat *);
void (GLAPIENTRY * TexCoord1i)(GLint);
void (GLAPIENTRY * TexCoord1iv)(const GLint *);
void (GLAPIENTRY * TexCoord1s)(GLshort);
void (GLAPIENTRY * TexCoord1sv)(const GLshort *);
void (GLAPIENTRY * TexCoord2d)(GLdouble, GLdouble);
void (GLAPIENTRY * TexCoord2dv)(const GLdouble *);
void (GLAPIENTRY * TexCoord2f)(GLfloat, GLfloat);
void (GLAPIENTRY * TexCoord2fv)(const GLfloat *);
void (GLAPIENTRY * TexCoord2i)(GLint, GLint);
void (GLAPIENTRY * TexCoord2iv)(const GLint *);
void (GLAPIENTRY * TexCoord2s)(GLshort, GLshort);
void (GLAPIENTRY * TexCoord2sv)(const GLshort *);
void (GLAPIENTRY * TexCoord3d)(GLdouble, GLdouble, GLdouble);
void (GLAPIENTRY * TexCoord3dv)(const GLdouble *);
void (GLAPIENTRY * TexCoord3f)(GLfloat, GLfloat, GLfloat);
void (GLAPIENTRY * TexCoord3fv)(const GLfloat *);
void (GLAPIENTRY * TexCoord3i)(GLint, GLint, GLint);
void (GLAPIENTRY * TexCoord3iv)(const GLint *);
void (GLAPIENTRY * TexCoord3s)(GLshort, GLshort, GLshort);
void (GLAPIENTRY * TexCoord3sv)(const GLshort *);
void (GLAPIENTRY * TexCoord4d)(GLdouble, GLdouble, GLdouble, GLdouble);
void (GLAPIENTRY * TexCoord4dv)(const GLdouble *);
void (GLAPIENTRY * TexCoord4f)(GLfloat, GLfloat, GLfloat, GLfloat);
void (GLAPIENTRY * TexCoord4fv)(const GLfloat *);
void (GLAPIENTRY * TexCoord4i)(GLint, GLint, GLint, GLint);
void (GLAPIENTRY * TexCoord4iv)(const GLint *);
void (GLAPIENTRY * TexCoord4s)(GLshort, GLshort, GLshort, GLshort);
void (GLAPIENTRY * TexCoord4sv)(const GLshort *);
void (GLAPIENTRY * Vertex2d)(GLdouble, GLdouble);
void (GLAPIENTRY * Vertex2dv)(const GLdouble *);
void (GLAPIENTRY * Vertex2f)(GLfloat, GLfloat);
void (GLAPIENTRY * Vertex2fv)(const GLfloat *);
void (GLAPIENTRY * Vertex2i)(GLint, GLint);
void (GLAPIENTRY * Vertex2iv)(const GLint *);
void (GLAPIENTRY * Vertex2s)(GLshort, GLshort);
void (GLAPIENTRY * Vertex2sv)(const GLshort *);
void (GLAPIENTRY * Vertex3d)(GLdouble, GLdouble, GLdouble);
void (GLAPIENTRY * Vertex3dv)(const GLdouble *);
void (GLAPIENTRY * Vertex3f)(GLfloat, GLfloat, GLfloat);
void (GLAPIENTRY * Vertex3fv)(const GLfloat *);
void (GLAPIENTRY * Vertex3i)(GLint, GLint, GLint);
void (GLAPIENTRY * Vertex3iv)(const GLint *);
void (GLAPIENTRY * Vertex3s)(GLshort, GLshort, GLshort);
void (GLAPIENTRY * Vertex3sv)(const GLshort *);
void (GLAPIENTRY * Vertex4d)(GLdouble, GLdouble, GLdouble, GLdouble);
void (GLAPIENTRY * Vertex4dv)(const GLdouble *);
void (GLAPIENTRY * Vertex4f)(GLfloat, GLfloat, GLfloat, GLfloat);
void (GLAPIENTRY * Vertex4fv)(const GLfloat *);
void (GLAPIENTRY * Vertex4i)(GLint, GLint, GLint, GLint);
void (GLAPIENTRY * Vertex4iv)(const GLint *);
void (GLAPIENTRY * Vertex4s)(GLshort, GLshort, GLshort, GLshort);
void (GLAPIENTRY * Vertex4sv)(const GLshort *);
void (GLAPIENTRY * ClipPlane)(GLenum, const GLdouble *);
void (GLAPIENTRY * ColorMaterial)(GLenum, GLenum);
void (GLAPIENTRY * CullFace)(GLenum);
void (GLAPIENTRY * Fogf)(GLenum, GLfloat);
void (GLAPIENTRY * Fogfv)(GLenum, const GLfloat *);
void (GLAPIENTRY * Fogi)(GLenum, GLint);
void (GLAPIENTRY * Fogiv)(GLenum, const GLint *);
void (GLAPIENTRY * FrontFace)(GLenum);
void (GLAPIENTRY * Hint)(GLenum, GLenum);
void (GLAPIENTRY * Lightf)(GLenum, GLenum, GLfloat);
void (GLAPIENTRY * Lightfv)(GLenum, GLenum, const GLfloat *);
void (GLAPIENTRY * Lighti)(GLenum, GLenum, GLint);
void (GLAPIENTRY * Lightiv)(GLenum, GLenum, const GLint *);
void (GLAPIENTRY * LightModelf)(GLenum, GLfloat);
void (GLAPIENTRY * LightModelfv)(GLenum, const GLfloat *);
void (GLAPIENTRY * LightModeli)(GLenum, GLint);
void (GLAPIENTRY * LightModeliv)(GLenum, const GLint *);
void (GLAPIENTRY * LineStipple)(GLint, GLushort);
void (GLAPIENTRY * LineWidth)(GLfloat);
void (GLAPIENTRY * Materialf)(GLenum, GLenum, GLfloat);
void (GLAPIENTRY * Materialfv)(GLenum, GLenum, const GLfloat *);
void (GLAPIENTRY * Materiali)(GLenum, GLenum, GLint);
void (GLAPIENTRY * Materialiv)(GLenum, GLenum, const GLint *);
void (GLAPIENTRY * PointSize)(GLfloat);
void (GLAPIENTRY * PolygonMode)(GLenum, GLenum);
void (GLAPIENTRY * PolygonStipple)(const GLubyte *);
void (GLAPIENTRY * Scissor)(GLint, GLint, GLsizei, GLsizei);
void (GLAPIENTRY * ShadeModel)(GLenum);
void (GLAPIENTRY * TexParameterf)(GLenum, GLenum, GLfloat);
void (GLAPIENTRY * TexParameterfv)(GLenum, GLenum, const GLfloat *);
void (GLAPIENTRY * TexParameteri)(GLenum, GLenum, GLint);
void (GLAPIENTRY * TexParameteriv)(GLenum, GLenum, const GLint *);
void (GLAPIENTRY * TexImage1D)(GLenum, GLint, GLint, GLsizei, GLint, GLenum, GLenum, const GLvoid *);
void (GLAPIENTRY * TexImage2D)(GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *);
void (GLAPIENTRY * TexEnvf)(GLenum, GLenum, GLfloat);
void (GLAPIENTRY * TexEnvfv)(GLenum, GLenum, const GLfloat *);
void (GLAPIENTRY * TexEnvi)(GLenum, GLenum, GLint);
void (GLAPIENTRY * TexEnviv)(GLenum, GLenum, const GLint *);
void (GLAPIENTRY * TexGend)(GLenum, GLenum, GLdouble);
void (GLAPIENTRY * TexGendv)(GLenum, GLenum, const GLdouble *);
void (GLAPIENTRY * TexGenf)(GLenum, GLenum, GLfloat);
void (GLAPIENTRY * TexGenfv)(GLenum, GLenum, const GLfloat *);
void (GLAPIENTRY * TexGeni)(GLenum, GLenum, GLint);
void (GLAPIENTRY * TexGeniv)(GLenum, GLenum, const GLint *);
void (GLAPIENTRY * FeedbackBuffer)(GLsizei, GLenum, GLfloat *);
void (GLAPIENTRY * SelectBuffer)(GLsizei, GLuint *);
GLint (GLAPIENTRY * RenderMode)(GLenum);
void (GLAPIENTRY * InitNames)(void);
void (GLAPIENTRY * LoadName)(GLuint);
void (GLAPIENTRY * PassThrough)(GLfloat);
void (GLAPIENTRY * PopName)(void);
void (GLAPIENTRY * PushName)(GLuint);
void (GLAPIENTRY * DrawBuffer)(GLenum);
void (GLAPIENTRY * Clear)(GLbitfield);
void (GLAPIENTRY * ClearAccum)(GLfloat, GLfloat, GLfloat, GLfloat);
void (GLAPIENTRY * ClearIndex)(GLfloat);
void (GLAPIENTRY * ClearColor)(GLclampf, GLclampf, GLclampf, GLclampf);
void (GLAPIENTRY * ClearStencil)(GLint);
void (GLAPIENTRY * ClearDepth)(GLclampd);
void (GLAPIENTRY * StencilMask)(GLuint);
void (GLAPIENTRY * ColorMask)(GLboolean, GLboolean, GLboolean, GLboolean);
void (GLAPIENTRY * DepthMask)(GLboolean);
void (GLAPIENTRY * IndexMask)(GLuint);
void (GLAPIENTRY * Accum)(GLenum, GLfloat);
void (GLAPIENTRY * Disable)(GLenum);
void (GLAPIENTRY * Enable)(GLenum);
void (GLAPIENTRY * Finish)(void);
void (GLAPIENTRY * Flush)(void);
void (GLAPIENTRY * PopAttrib)(void);
void (GLAPIENTRY * PushAttrib)(GLbitfield);
void (GLAPIENTRY * Map1d)(GLenum, GLdouble, GLdouble, GLint, GLint, const GLdouble *);
void (GLAPIENTRY * Map1f)(GLenum, GLfloat, GLfloat, GLint, GLint, const GLfloat *);
void (GLAPIENTRY * Map2d)(GLenum, GLdouble, GLdouble, GLint, GLint, GLdouble, GLdouble, GLint, GLint, const GLdouble *);
void (GLAPIENTRY * Map2f)(GLenum, GLfloat, GLfloat, GLint, GLint, GLfloat, GLfloat, GLint, GLint, const GLfloat *);
void (GLAPIENTRY * MapGrid1d)(GLint, GLdouble, GLdouble);
void (GLAPIENTRY * MapGrid1f)(GLint, GLfloat, GLfloat);
void (GLAPIENTRY * MapGrid2d)(GLint, GLdouble, GLdouble, GLint, GLdouble, GLdouble);
void (GLAPIENTRY * MapGrid2f)(GLint, GLfloat, GLfloat, GLint, GLfloat, GLfloat);
void (GLAPIENTRY * EvalCoord1d)(GLdouble);
void (GLAPIENTRY * EvalCoord1dv)(const GLdouble *);
void (GLAPIENTRY * EvalCoord1f)(GLfloat);
void (GLAPIENTRY * EvalCoord1fv)(const GLfloat *);
void (GLAPIENTRY * EvalCoord2d)(GLdouble, GLdouble);
void (GLAPIENTRY * EvalCoord2dv)(const GLdouble *);
void (GLAPIENTRY * EvalCoord2f)(GLfloat, GLfloat);
void (GLAPIENTRY * EvalCoord2fv)(const GLfloat *);
void (GLAPIENTRY * EvalMesh1)(GLenum, GLint, GLint);
void (GLAPIENTRY * EvalPoint1)(GLint);
void (GLAPIENTRY * EvalMesh2)(GLenum, GLint, GLint, GLint, GLint);
void (GLAPIENTRY * EvalPoint2)(GLint, GLint);
void (GLAPIENTRY * AlphaFunc)(GLenum, GLclampf);
void (GLAPIENTRY * BlendFunc)(GLenum, GLenum);
void (GLAPIENTRY * LogicOp)(GLenum);
void (GLAPIENTRY * StencilFunc)(GLenum, GLint, GLuint);
void (GLAPIENTRY * StencilOp)(GLenum, GLenum, GLenum);
void (GLAPIENTRY * DepthFunc)(GLenum);
void (GLAPIENTRY * PixelZoom)(GLfloat, GLfloat);
void (GLAPIENTRY * PixelTransferf)(GLenum, GLfloat);
void (GLAPIENTRY * PixelTransferi)(GLenum, GLint);
void (GLAPIENTRY * PixelStoref)(GLenum, GLfloat);
void (GLAPIENTRY * PixelStorei)(GLenum, GLint);
void (GLAPIENTRY * PixelMapfv)(GLenum, GLint, const GLfloat *);
void (GLAPIENTRY * PixelMapuiv)(GLenum, GLint, const GLuint *);
void (GLAPIENTRY * PixelMapusv)(GLenum, GLint, const GLushort *);
void (GLAPIENTRY * ReadBuffer)(GLenum);
void (GLAPIENTRY * CopyPixels)(GLint, GLint, GLsizei, GLsizei, GLenum);
void (GLAPIENTRY * ReadPixels)(GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid *);
void (GLAPIENTRY * DrawPixels)(GLsizei, GLsizei, GLenum, GLenum, const GLvoid *);
void (GLAPIENTRY * GetBooleanv)(GLenum, GLboolean *);
void (GLAPIENTRY * GetClipPlane)(GLenum, GLdouble *);
void (GLAPIENTRY * GetDoublev)(GLenum, GLdouble *);
GLenum (GLAPIENTRY * GetError)(void);
void (GLAPIENTRY * GetFloatv)(GLenum, GLfloat *);
void (GLAPIENTRY * GetIntegerv)(GLenum, GLint *);
void (GLAPIENTRY * GetLightfv)(GLenum, GLenum, GLfloat *);
void (GLAPIENTRY * GetLightiv)(GLenum, GLenum, GLint *);
void (GLAPIENTRY * GetMapdv)(GLenum, GLenum, GLdouble *);
void (GLAPIENTRY * GetMapfv)(GLenum, GLenum, GLfloat *);
void (GLAPIENTRY * GetMapiv)(GLenum, GLenum, GLint *);
void (GLAPIENTRY * GetMaterialfv)(GLenum, GLenum, GLfloat *);
void (GLAPIENTRY * GetMaterialiv)(GLenum, GLenum, GLint *);
void (GLAPIENTRY * GetPixelMapfv)(GLenum, GLfloat *);
void (GLAPIENTRY * GetPixelMapuiv)(GLenum, GLuint *);
void (GLAPIENTRY * GetPixelMapusv)(GLenum, GLushort *);
void (GLAPIENTRY * GetPolygonStipple)(GLubyte *);
const GLubyte * (GLAPIENTRY * GetString)(GLenum);
void (GLAPIENTRY * GetTexEnvfv)(GLenum, GLenum, GLfloat *);
void (GLAPIENTRY * GetTexEnviv)(GLenum, GLenum, GLint *);
void (GLAPIENTRY * GetTexGendv)(GLenum, GLenum, GLdouble *);
void (GLAPIENTRY * GetTexGenfv)(GLenum, GLenum, GLfloat *);
void (GLAPIENTRY * GetTexGeniv)(GLenum, GLenum, GLint *);
void (GLAPIENTRY * GetTexImage)(GLenum, GLint, GLenum, GLenum, GLvoid *);
void (GLAPIENTRY * GetTexParameterfv)(GLenum, GLenum, GLfloat *);
void (GLAPIENTRY * GetTexParameteriv)(GLenum, GLenum, GLint *);
void (GLAPIENTRY * GetTexLevelParameterfv)(GLenum, GLint, GLenum, GLfloat *);
void (GLAPIENTRY * GetTexLevelParameteriv)(GLenum, GLint, GLenum, GLint *);
GLboolean (GLAPIENTRY * IsEnabled)(GLenum);
GLboolean (GLAPIENTRY * IsList)(GLuint);
void (GLAPIENTRY * DepthRange)(GLclampd, GLclampd);
void (GLAPIENTRY * Frustum)(GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble);
void (GLAPIENTRY * LoadIdentity)(void);
void (GLAPIENTRY * LoadMatrixf)(const GLfloat *);
void (GLAPIENTRY * LoadMatrixd)(const GLdouble *);
void (GLAPIENTRY * MatrixMode)(GLenum);
void (GLAPIENTRY * MultMatrixf)(const GLfloat *);
void (GLAPIENTRY * MultMatrixd)(const GLdouble *);
void (GLAPIENTRY * Ortho)(GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble);
void (GLAPIENTRY * PopMatrix)(void);
void (GLAPIENTRY * PushMatrix)(void);
void (GLAPIENTRY * Rotated)(GLdouble, GLdouble, GLdouble, GLdouble);
void (GLAPIENTRY * Rotatef)(GLfloat, GLfloat, GLfloat, GLfloat);
void (GLAPIENTRY * Scaled)(GLdouble, GLdouble, GLdouble);
void (GLAPIENTRY * Scalef)(GLfloat, GLfloat, GLfloat);
void (GLAPIENTRY * Translated)(GLdouble, GLdouble, GLdouble);
void (GLAPIENTRY * Translatef)(GLfloat, GLfloat, GLfloat);
void (GLAPIENTRY * Viewport)(GLint, GLint, GLsizei, GLsizei);
void (GLAPIENTRY * ArrayElement)(GLint);
void (GLAPIENTRY * BindTexture)(GLenum, GLuint);
void (GLAPIENTRY * ColorPointer)(GLint, GLenum, GLsizei, const GLvoid *);
void (GLAPIENTRY * DisableClientState)(GLenum);
void (GLAPIENTRY * DrawArrays)(GLenum, GLint, GLsizei);
void (GLAPIENTRY * DrawElements)(GLenum, GLsizei, GLenum, const GLvoid *);
void (GLAPIENTRY * EdgeFlagPointer)(GLsizei, const GLvoid *);
void (GLAPIENTRY * EnableClientState)(GLenum);
void (GLAPIENTRY * IndexPointer)(GLenum, GLsizei, const GLvoid *);
void (GLAPIENTRY * Indexub)(GLubyte);
void (GLAPIENTRY * Indexubv)(const GLubyte *);
void (GLAPIENTRY * InterleavedArrays)(GLenum, GLsizei, const GLvoid *);
void (GLAPIENTRY * NormalPointer)(GLenum, GLsizei, const GLvoid *);
void (GLAPIENTRY * PolygonOffset)(GLfloat, GLfloat);
void (GLAPIENTRY * TexCoordPointer)(GLint, GLenum, GLsizei, const GLvoid *);
void (GLAPIENTRY * VertexPointer)(GLint, GLenum, GLsizei, const GLvoid *);
GLboolean (GLAPIENTRY * AreTexturesResident)(GLsizei, const GLuint *, GLboolean *);
void (GLAPIENTRY * CopyTexImage1D)(GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLint);
void (GLAPIENTRY * CopyTexImage2D)(GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint);
void (GLAPIENTRY * CopyTexSubImage1D)(GLenum, GLint, GLint, GLint, GLint, GLsizei);
void (GLAPIENTRY * CopyTexSubImage2D)(GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei);
void (GLAPIENTRY * DeleteTextures)(GLsizei, const GLuint *);
void (GLAPIENTRY * GenTextures)(GLsizei, GLuint *);
void (GLAPIENTRY * GetPointerv)(GLenum, GLvoid **);
GLboolean (GLAPIENTRY * IsTexture)(GLuint);
void (GLAPIENTRY * PrioritizeTextures)(GLsizei, const GLuint *, const GLclampf *);
void (GLAPIENTRY * TexSubImage1D)(GLenum, GLint, GLint, GLsizei, GLenum, GLenum, const GLvoid *);
void (GLAPIENTRY * TexSubImage2D)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *);
void (GLAPIENTRY * PopClientAttrib)(void);
void (GLAPIENTRY * PushClientAttrib)(GLbitfield);
};
typedef struct __GLdispatchTableRec GLDISPATCHTABLE;
typedef struct _GLCLTPROCTABLE
{
int cEntries;
GLDISPATCHTABLE glDispatchTable;
} GLCLTPROCTABLE, * PGLCLTPROCTABLE;
typedef VOID (APIENTRY * PFN_SETPROCTABLE)(const GLCLTPROCTABLE*);
/* Those functions are there in case GL calls are made without a context */
extern const GLCLTPROCTABLE StubTable;
/* This doesn't seem to be anywhere in ddk or psdk */
DECLARE_HANDLE(DHGLRC);
struct ICD_Data
{
/* The Name returned with OPENGL_GETINFO escape code */
WCHAR DriverName[256];
/* The DLL handle */
HMODULE hModule;
/* The ICD DLL exports */
BOOL (WINAPI *DrvCopyContext)( DHGLRC, DHGLRC, UINT );
DHGLRC (WINAPI *DrvCreateContext)( HDC );
DHGLRC (WINAPI *DrvCreateLayerContext)( HDC, int );
BOOL (WINAPI *DrvDeleteContext)( DHGLRC );
BOOL (WINAPI *DrvDescribeLayerPlane)( HDC, int, int, UINT, LPLAYERPLANEDESCRIPTOR );
int (WINAPI *DrvDescribePixelFormat)( IN HDC, IN int, IN UINT, OUT LPPIXELFORMATDESCRIPTOR );
int (WINAPI *DrvGetLayerPaletteEntries)( HDC, int, int, int, COLORREF * );
PROC (WINAPI *DrvGetProcAddress)( LPCSTR lpProcName );
void (WINAPI *DrvReleaseContext)( DHGLRC hglrc ); /* maybe returns BOOL? */
BOOL (WINAPI *DrvRealizeLayerPalette)( HDC, int, BOOL );
const GLCLTPROCTABLE* (WINAPI *DrvSetContext)( HDC hdc, DHGLRC hglrc, PFN_SETPROCTABLE callback );
int (WINAPI *DrvSetLayerPaletteEntries)( HDC, int, int, int, CONST COLORREF * );
BOOL (WINAPI *DrvSetPixelFormat)( IN HDC, IN int);
BOOL (WINAPI *DrvShareLists)( DHGLRC, DHGLRC );
BOOL (WINAPI *DrvSwapBuffers)( HDC );
BOOL (WINAPI *DrvSwapLayerBuffers)( HDC, UINT );
/* Make this a linked list */
struct ICD_Data* next;
};
struct ICD_Data* IntGetIcdData(HDC hdc);

View file

@ -0,0 +1,241 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: lib/opengl32/icdload.c
* PURPOSE: OpenGL32 lib, ICD dll loader
*/
#include "opengl32.h"
#include <winreg.h>
#include <wine/debug.h>
WINE_DEFAULT_DEBUG_CHANNEL(opengl32);
struct Drv_Opengl_Info
{
DWORD Version; /*!< Driver interface version */
DWORD DriverVersion; /*!< Driver version */
WCHAR DriverName[256]; /*!< Driver name */
};
static CRITICAL_SECTION icdload_cs = {NULL, -1, 0, 0, 0, 0};
static struct ICD_Data* ICD_Data_List = NULL;
static const WCHAR OpenGLDrivers_Key[] = L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\OpenGLDrivers";
/* Retrieves the ICD data (driver version + relevant DLL entry points) for a device context */
struct ICD_Data* IntGetIcdData(HDC hdc)
{
int ret;
DWORD dwInput, dwValueType, Version, DriverVersion, Flags;
struct Drv_Opengl_Info DrvInfo;
struct ICD_Data* data;
HKEY OglKey, DrvKey;
WCHAR DllName[MAX_PATH];
BOOL (WINAPI *DrvValidateVersion)(DWORD);
/* First, see if the driver supports this */
dwInput = OPENGL_GETINFO;
ret = ExtEscape(hdc,
QUERYESCSUPPORT,
sizeof(DWORD),
(LPCSTR)&dwInput,
0,
NULL);
if(ret <= 0)
{
/* Driver doesn't support opengl */
return NULL;
}
/* Query for the ICD DLL name and version */
dwInput = 0;
ret = ExtEscape(hdc,
OPENGL_GETINFO,
sizeof(DWORD),
(LPCSTR)&dwInput,
sizeof(DrvInfo),
(LPSTR)&DrvInfo);
if(ret <= 0)
{
ERR("Driver claims to support OPENGL_GETINFO escape code, but doesn't.\n");
return NULL;
}
/* Protect the list while we are loading*/
EnterCriticalSection(&icdload_cs);
/* Search for it in the list of already loaded modules */
data = ICD_Data_List;
while(data)
{
if(!_wcsicmp(data->DriverName, DrvInfo.DriverName))
{
/* Found it */
TRACE("Found already loaded %p.\n", data);
LeaveCriticalSection(&icdload_cs);
return data;
}
data = data->next;
}
/* It was still not loaded, look for it in the registry */
ret = RegOpenKeyExW(HKEY_LOCAL_MACHINE, OpenGLDrivers_Key, 0, KEY_READ, &OglKey);
if(ret != ERROR_SUCCESS)
{
ERR("Failed to open the OpenGLDrivers key.\n");
goto end;
}
ret = RegOpenKeyExW(OglKey, DrvInfo.DriverName, 0, KEY_READ, &DrvKey);
if(ret != ERROR_SUCCESS)
{
/* Some driver installer just provide the DLL name, like the Matrox G400 */
TRACE("No driver subkey for %S, trying to get DLL name directly.\n", DrvInfo.DriverName);
dwInput = sizeof(DllName);
ret = RegQueryValueExW(OglKey, DrvInfo.DriverName, 0, &dwValueType, (LPBYTE)DllName, &dwInput);
if((ret != ERROR_SUCCESS) || (dwValueType != REG_SZ))
{
ERR("Unable to get ICD DLL name!.\n");
RegCloseKey(OglKey);
goto end;
}
Version = DriverVersion = Flags = 0;
TRACE("DLL name is %S.\n", DllName);
}
else
{
/* The driver have a subkey for the ICD */
TRACE("Querying details from registry for %S.\n", DrvInfo.DriverName);
dwInput = sizeof(DllName);
ret = RegQueryValueExW(DrvKey, L"Dll", 0, &dwValueType, (LPBYTE)DllName, &dwInput);
if((ret != ERROR_SUCCESS) || (dwValueType != REG_SZ))
{
ERR("Unable to get ICD DLL name!.\n");
RegCloseKey(DrvKey);
RegCloseKey(OglKey);
goto end;
}
dwInput = sizeof(Version);
ret = RegQueryValueExW(DrvKey, L"Version", 0, &dwValueType, (LPBYTE)&Version, &dwInput);
if((ret != ERROR_SUCCESS) || (dwValueType != REG_DWORD))
{
WARN("No version in driver subkey\n");
}
else if(Version != DrvInfo.Version)
{
ERR("Version mismatch between registry (%lu) and display driver (%lu).\n", Version, DrvInfo.Version);
RegCloseKey(DrvKey);
RegCloseKey(OglKey);
goto end;
}
dwInput = sizeof(DriverVersion);
ret = RegQueryValueExW(DrvKey, L"DriverVersion", 0, &dwValueType, (LPBYTE)&DriverVersion, &dwInput);
if((ret != ERROR_SUCCESS) || (dwValueType != REG_DWORD))
{
WARN("No driver version in driver subkey\n");
}
else if(DriverVersion != DrvInfo.DriverVersion)
{
ERR("Driver version mismatch between registry (%lu) and display driver (%lu).\n", DriverVersion, DrvInfo.DriverVersion);
RegCloseKey(DrvKey);
RegCloseKey(OglKey);
goto end;
}
dwInput = sizeof(Flags);
ret = RegQueryValueExW(DrvKey, L"Flags", 0, &dwValueType, (LPBYTE)&Flags, &dwInput);
if((ret != ERROR_SUCCESS) || (dwValueType != REG_DWORD))
{
WARN("No driver version in driver subkey\n");
Flags = 0;
}
/* We're done */
RegCloseKey(DrvKey);
TRACE("DLL name is %S, Version %lx, DriverVersion %lx, Flags %lx.\n", DllName, Version, DriverVersion, Flags);
}
/* No need for this anymore */
RegCloseKey(OglKey);
/* So far so good, allocate data */
data = HeapAlloc(GetProcessHeap(), 0, sizeof(*data));
if(!data)
{
ERR("Unable to allocate ICD data!\n");
goto end;
}
/* Load the library */
data->hModule = LoadLibraryW(DllName);
if(!data->hModule)
{
ERR("Could not load the ICD DLL: %S.\n", DllName);
HeapFree(GetProcessHeap(), 0, data);
data = NULL;
goto end;
}
/*
* Validate version, if needed.
* Some drivers (at least VBOX), initialize stuff upon this call.
*/
DrvValidateVersion = (void*)GetProcAddress(data->hModule, "DrvValidateVersion");
if(DrvValidateVersion)
{
if(!DrvValidateVersion(DrvInfo.DriverVersion))
{
ERR("DrvValidateVersion failed!.\n");
goto fail;
}
}
/* Get the DLL exports */
#define DRV_LOAD(x) do \
{ \
data->x = (void*)GetProcAddress(data->hModule, #x); \
if(!data->x) { \
ERR("%S lacks " #x "!\n", DllName); \
goto fail; \
} \
} while(0)
DRV_LOAD(DrvCopyContext);
DRV_LOAD(DrvCreateContext);
DRV_LOAD(DrvCreateLayerContext);
DRV_LOAD(DrvDeleteContext);
DRV_LOAD(DrvDescribeLayerPlane);
DRV_LOAD(DrvDescribePixelFormat);
DRV_LOAD(DrvGetLayerPaletteEntries);
DRV_LOAD(DrvGetProcAddress);
DRV_LOAD(DrvReleaseContext);
DRV_LOAD(DrvRealizeLayerPalette);
DRV_LOAD(DrvSetContext);
DRV_LOAD(DrvSetLayerPaletteEntries);
DRV_LOAD(DrvSetPixelFormat);
DRV_LOAD(DrvShareLists);
DRV_LOAD(DrvSwapBuffers);
DRV_LOAD(DrvSwapLayerBuffers);
#undef DRV_LOAD
/* Copy the DriverName */
wcscpy(data->DriverName, DrvInfo.DriverName);
/* Push the list */
data->next = ICD_Data_List;
ICD_Data_List = data;
TRACE("Returning %p.\n", data);
end:
/* Unlock and return */
LeaveCriticalSection(&icdload_cs);
return data;
fail:
LeaveCriticalSection(&icdload_cs);
FreeLibrary(data->hModule);
HeapFree(GetProcessHeap(), 0, data);
return NULL;
}

View file

@ -0,0 +1,130 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: lib/opengl32/opengl.h
* PURPOSE: OpenGL32 lib, general header
*/
#pragma once
#define WIN32_NO_STATUS
#include <stdarg.h>
#include <windef.h>
#include <winbase.h>
#include <winuser.h>
#include <wingdi.h>
#include <winddi.h>
#include <GL/gl.h>
#include "icd.h"
struct wgl_context
{
DWORD magic;
volatile LONG lock;
DHGLRC dhglrc;
struct ICD_Data* icd_data;
INT pixelformat;
volatile LONG thread_id;
};
#define WGL_DC_OBJ_DC 0x1
struct wgl_dc_data
{
/* 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;
};
#ifdef OPENGL32_USE_TLS
extern DWORD OglTlsIndex;
struct Opengl32_ThreadData
{
const GLCLTPROCTABLE* ProcTable;
HGLRC hglrc;
HDC hdc;
struct wgl_dc_data* dc_data;
};
static inline
HGLRC
IntGetCurrentRC(void)
{
struct Opengl32_ThreadData* data = TlsGetValue(OglTlsIndex);
return data->hglrc;
}
static inline
DHGLRC
IntGetCurrentDHGLRC(void)
{
struct wgl_context* ctx = (struct wgl_context*)IntGetCurrentRC();
if(!ctx) return NULL;
return ctx->dhglrc;
}
static inline
HDC
IntGetCurrentDC(void)
{
struct Opengl32_ThreadData* data = TlsGetValue(OglTlsIndex);
return data->hdc;
}
static inline
struct wgl_dc_data*
IntGetCurrentDcData(void)
{
struct Opengl32_ThreadData* data = TlsGetValue(OglTlsIndex);
return data->dc_data;
}
static inline
const GLDISPATCHTABLE *
IntGetCurrentDispatchTable(void)
{
struct Opengl32_ThreadData* data = TlsGetValue(OglTlsIndex);
return &data->ProcTable->glDispatchTable;
}
#else
static inline
const GLDISPATCHTABLE*
IntGetCurrentDispatchTable(void)
{
return (GLDISPATCHTABLE*)NtCurrentTeb()->glTable;
}
#endif // defined(OPENGL32_USE_TLS)
/* Software implementation functions */
INT sw_DescribePixelFormat(HDC hdc, INT format, UINT size, PIXELFORMATDESCRIPTOR* descr);
BOOL sw_SetPixelFormat(struct wgl_dc_data*, INT format);
DHGLRC sw_CreateContext(struct wgl_dc_data*);
BOOL sw_DeleteContext(DHGLRC dhglrc);
const GLCLTPROCTABLE* 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);

View file

@ -0,0 +1,369 @@
@ stub GlmfBeginGlsBlock
@ stub GlmfCloseMetaFile
@ stub GlmfEndGlsBlock
@ stub GlmfEndPlayback
@ stub GlmfInitPlayback
@ stub GlmfPlayGlsRecord
@ stdcall glAccum( long long )
@ stdcall glAlphaFunc( long long )
@ stdcall glAreTexturesResident( long ptr ptr )
@ stdcall glArrayElement( long )
@ stdcall glBegin( long )
@ stdcall glBindTexture( long long )
@ stdcall glBitmap( long long long long long long ptr )
@ stdcall glBlendFunc( long long )
@ stdcall glCallList( long )
@ stdcall glCallLists( long long ptr )
@ stdcall glClear( long )
@ stdcall glClearAccum( long long long long )
@ stdcall glClearColor( long long long long )
@ stdcall glClearDepth( double )
@ stdcall glClearIndex( long )
@ stdcall glClearStencil( long )
@ stdcall glClipPlane( long ptr )
@ stdcall glColor3b( long long long )
@ stdcall glColor3bv( ptr )
@ stdcall glColor3d( double double double )
@ stdcall glColor3dv( ptr )
@ stdcall glColor3f( long long long )
@ stdcall glColor3fv( ptr )
@ stdcall glColor3i( long long long )
@ stdcall glColor3iv( ptr )
@ stdcall glColor3s( long long long )
@ stdcall glColor3sv( ptr )
@ stdcall glColor3ub( long long long )
@ stdcall glColor3ubv( ptr )
@ stdcall glColor3ui( long long long )
@ stdcall glColor3uiv( ptr )
@ stdcall glColor3us( long long long )
@ stdcall glColor3usv( ptr )
@ stdcall glColor4b( long long long long )
@ stdcall glColor4bv( ptr )
@ stdcall glColor4d( double double double double )
@ stdcall glColor4dv( ptr )
@ stdcall glColor4f( long long long long )
@ stdcall glColor4fv( ptr )
@ stdcall glColor4i( long long long long )
@ stdcall glColor4iv( ptr )
@ stdcall glColor4s( long long long long )
@ stdcall glColor4sv( ptr )
@ stdcall glColor4ub( long long long long )
@ stdcall glColor4ubv( ptr )
@ stdcall glColor4ui( long long long long )
@ stdcall glColor4uiv( ptr )
@ stdcall glColor4us( long long long long )
@ stdcall glColor4usv( ptr )
@ stdcall glColorMask( long long long long )
@ stdcall glColorMaterial( long long )
@ stdcall glColorPointer( long long long ptr )
@ stdcall glCopyPixels( long long long long long )
@ stdcall glCopyTexImage1D( long long long long long long long )
@ stdcall glCopyTexImage2D( long long long long long long long long )
@ stdcall glCopyTexSubImage1D( long long long long long long )
@ stdcall glCopyTexSubImage2D( long long long long long long long long )
@ stdcall glCullFace( long )
@ stdcall glDebugEntry(long long)
@ stdcall glDeleteLists( long long )
@ stdcall glDeleteTextures( long ptr )
@ stdcall glDepthFunc( long )
@ stdcall glDepthMask( long )
@ stdcall glDepthRange( double double )
@ stdcall glDisable( long )
@ stdcall glDisableClientState( long )
@ stdcall glDrawArrays( long long long )
@ stdcall glDrawBuffer( long )
@ stdcall glDrawElements( long long long ptr )
@ stdcall glDrawPixels( long long long long ptr )
@ stdcall glEdgeFlag( long )
@ stdcall glEdgeFlagPointer( long ptr )
@ stdcall glEdgeFlagv( ptr )
@ stdcall glEnable( long )
@ stdcall glEnableClientState( long )
@ stdcall glEnd( )
@ stdcall glEndList( )
@ stdcall glEvalCoord1d( double )
@ stdcall glEvalCoord1dv( ptr )
@ stdcall glEvalCoord1f( long )
@ stdcall glEvalCoord1fv( ptr )
@ stdcall glEvalCoord2d( double double )
@ stdcall glEvalCoord2dv( ptr )
@ stdcall glEvalCoord2f( long long )
@ stdcall glEvalCoord2fv( ptr )
@ stdcall glEvalMesh1( long long long )
@ stdcall glEvalMesh2( long long long long long )
@ stdcall glEvalPoint1( long )
@ stdcall glEvalPoint2( long long )
@ stdcall glFeedbackBuffer( long long ptr )
@ stdcall glFinish( )
@ stdcall glFlush( )
@ stdcall glFogf( long long )
@ stdcall glFogfv( long ptr )
@ stdcall glFogi( long long )
@ stdcall glFogiv( long ptr )
@ stdcall glFrontFace( long )
@ stdcall glFrustum( double double double double double double )
@ stdcall glGenLists( long )
@ stdcall glGenTextures( long ptr )
@ stdcall glGetBooleanv( long ptr )
@ stdcall glGetClipPlane( long ptr )
@ stdcall glGetDoublev( long ptr )
@ stdcall glGetError( )
@ stdcall glGetFloatv( long ptr )
@ stdcall glGetIntegerv( long ptr )
@ stdcall glGetLightfv( long long ptr )
@ stdcall glGetLightiv( long long ptr )
@ stdcall glGetMapdv( long long ptr )
@ stdcall glGetMapfv( long long ptr )
@ stdcall glGetMapiv( long long ptr )
@ stdcall glGetMaterialfv( long long ptr )
@ stdcall glGetMaterialiv( long long ptr )
@ stdcall glGetPixelMapfv( long ptr )
@ stdcall glGetPixelMapuiv( long ptr )
@ stdcall glGetPixelMapusv( long ptr )
@ stdcall glGetPointerv( long ptr )
@ stdcall glGetPolygonStipple( ptr )
@ stdcall glGetString( long )
@ stdcall glGetTexEnvfv( long long ptr )
@ stdcall glGetTexEnviv( long long ptr )
@ stdcall glGetTexGendv( long long ptr )
@ stdcall glGetTexGenfv( long long ptr )
@ stdcall glGetTexGeniv( long long ptr )
@ stdcall glGetTexImage( long long long long ptr )
@ stdcall glGetTexLevelParameterfv( long long long ptr )
@ stdcall glGetTexLevelParameteriv( long long long ptr )
@ stdcall glGetTexParameterfv( long long ptr )
@ stdcall glGetTexParameteriv( long long ptr )
@ stdcall glHint( long long )
@ stdcall glIndexMask( long )
@ stdcall glIndexPointer( long long ptr )
@ stdcall glIndexd( double )
@ stdcall glIndexdv( ptr )
@ stdcall glIndexf( long )
@ stdcall glIndexfv( ptr )
@ stdcall glIndexi( long )
@ stdcall glIndexiv( ptr )
@ stdcall glIndexs( long )
@ stdcall glIndexsv( ptr )
@ stdcall glIndexub( long )
@ stdcall glIndexubv( ptr )
@ stdcall glInitNames( )
@ stdcall glInterleavedArrays( long long ptr )
@ stdcall glIsEnabled( long )
@ stdcall glIsList( long )
@ stdcall glIsTexture( long )
@ stdcall glLightModelf( long long )
@ stdcall glLightModelfv( long ptr )
@ stdcall glLightModeli( long long )
@ stdcall glLightModeliv( long ptr )
@ stdcall glLightf( long long long )
@ stdcall glLightfv( long long ptr )
@ stdcall glLighti( long long long )
@ stdcall glLightiv( long long ptr )
@ stdcall glLineStipple( long long )
@ stdcall glLineWidth( long )
@ stdcall glListBase( long )
@ stdcall glLoadIdentity( )
@ stdcall glLoadMatrixd( ptr )
@ stdcall glLoadMatrixf( ptr )
@ stdcall glLoadName( long )
@ stdcall glLogicOp( long )
@ stdcall glMap1d( long double double long long ptr )
@ stdcall glMap1f( long long long long long ptr )
@ stdcall glMap2d( long double double long long double double long long ptr )
@ stdcall glMap2f( long long long long long long long long long ptr )
@ stdcall glMapGrid1d( long double double )
@ stdcall glMapGrid1f( long long long )
@ stdcall glMapGrid2d( long double double long double double )
@ stdcall glMapGrid2f( long long long long long long )
@ stdcall glMaterialf( long long long )
@ stdcall glMaterialfv( long long ptr )
@ stdcall glMateriali( long long long )
@ stdcall glMaterialiv( long long ptr )
@ stdcall glMatrixMode( long )
@ stdcall glMultMatrixd( ptr )
@ stdcall glMultMatrixf( ptr )
@ stdcall glNewList( long long )
@ stdcall glNormal3b( long long long )
@ stdcall glNormal3bv( ptr )
@ stdcall glNormal3d( double double double )
@ stdcall glNormal3dv( ptr )
@ stdcall glNormal3f( long long long )
@ stdcall glNormal3fv( ptr )
@ stdcall glNormal3i( long long long )
@ stdcall glNormal3iv( ptr )
@ stdcall glNormal3s( long long long )
@ stdcall glNormal3sv( ptr )
@ stdcall glNormalPointer( long long ptr )
@ stdcall glOrtho( double double double double double double )
@ stdcall glPassThrough( long )
@ stdcall glPixelMapfv( long long ptr )
@ stdcall glPixelMapuiv( long long ptr )
@ stdcall glPixelMapusv( long long ptr )
@ stdcall glPixelStoref( long long )
@ stdcall glPixelStorei( long long )
@ stdcall glPixelTransferf( long long )
@ stdcall glPixelTransferi( long long )
@ stdcall glPixelZoom( long long )
@ stdcall glPointSize( long )
@ stdcall glPolygonMode( long long )
@ stdcall glPolygonOffset( long long )
@ stdcall glPolygonStipple( ptr )
@ stdcall glPopAttrib( )
@ stdcall glPopClientAttrib( )
@ stdcall glPopMatrix( )
@ stdcall glPopName( )
@ stdcall glPrioritizeTextures( long ptr ptr )
@ stdcall glPushAttrib( long )
@ stdcall glPushClientAttrib( long )
@ stdcall glPushMatrix( )
@ stdcall glPushName( long )
@ stdcall glRasterPos2d( double double )
@ stdcall glRasterPos2dv( ptr )
@ stdcall glRasterPos2f( long long )
@ stdcall glRasterPos2fv( ptr )
@ stdcall glRasterPos2i( long long )
@ stdcall glRasterPos2iv( ptr )
@ stdcall glRasterPos2s( long long )
@ stdcall glRasterPos2sv( ptr )
@ stdcall glRasterPos3d( double double double )
@ stdcall glRasterPos3dv( ptr )
@ stdcall glRasterPos3f( long long long )
@ stdcall glRasterPos3fv( ptr )
@ stdcall glRasterPos3i( long long long )
@ stdcall glRasterPos3iv( ptr )
@ stdcall glRasterPos3s( long long long )
@ stdcall glRasterPos3sv( ptr )
@ stdcall glRasterPos4d( double double double double )
@ stdcall glRasterPos4dv( ptr )
@ stdcall glRasterPos4f( long long long long )
@ stdcall glRasterPos4fv( ptr )
@ stdcall glRasterPos4i( long long long long )
@ stdcall glRasterPos4iv( ptr )
@ stdcall glRasterPos4s( long long long long )
@ stdcall glRasterPos4sv( ptr )
@ stdcall glReadBuffer( long )
@ stdcall glReadPixels( long long long long long long ptr )
@ stdcall glRectd( double double double double )
@ stdcall glRectdv( ptr ptr )
@ stdcall glRectf( long long long long )
@ stdcall glRectfv( ptr ptr )
@ stdcall glRecti( long long long long )
@ stdcall glRectiv( ptr ptr )
@ stdcall glRects( long long long long )
@ stdcall glRectsv( ptr ptr )
@ stdcall glRenderMode( long )
@ stdcall glRotated( double double double double )
@ stdcall glRotatef( long long long long )
@ stdcall glScaled( double double double )
@ stdcall glScalef( long long long )
@ stdcall glScissor( long long long long )
@ stdcall glSelectBuffer( long ptr )
@ stdcall glShadeModel( long )
@ stdcall glStencilFunc( long long long )
@ stdcall glStencilMask( long )
@ stdcall glStencilOp( long long long )
@ stdcall glTexCoord1d( double )
@ stdcall glTexCoord1dv( ptr )
@ stdcall glTexCoord1f( long )
@ stdcall glTexCoord1fv( ptr )
@ stdcall glTexCoord1i( long )
@ stdcall glTexCoord1iv( ptr )
@ stdcall glTexCoord1s( long )
@ stdcall glTexCoord1sv( ptr )
@ stdcall glTexCoord2d( double double )
@ stdcall glTexCoord2dv( ptr )
@ stdcall glTexCoord2f( long long )
@ stdcall glTexCoord2fv( ptr )
@ stdcall glTexCoord2i( long long )
@ stdcall glTexCoord2iv( ptr )
@ stdcall glTexCoord2s( long long )
@ stdcall glTexCoord2sv( ptr )
@ stdcall glTexCoord3d( double double double )
@ stdcall glTexCoord3dv( ptr )
@ stdcall glTexCoord3f( long long long )
@ stdcall glTexCoord3fv( ptr )
@ stdcall glTexCoord3i( long long long )
@ stdcall glTexCoord3iv( ptr )
@ stdcall glTexCoord3s( long long long )
@ stdcall glTexCoord3sv( ptr )
@ stdcall glTexCoord4d( double double double double )
@ stdcall glTexCoord4dv( ptr )
@ stdcall glTexCoord4f( long long long long )
@ stdcall glTexCoord4fv( ptr )
@ stdcall glTexCoord4i( long long long long )
@ stdcall glTexCoord4iv( ptr )
@ stdcall glTexCoord4s( long long long long )
@ stdcall glTexCoord4sv( ptr )
@ stdcall glTexCoordPointer( long long long ptr )
@ stdcall glTexEnvf( long long long )
@ stdcall glTexEnvfv( long long ptr )
@ stdcall glTexEnvi( long long long )
@ stdcall glTexEnviv( long long ptr )
@ stdcall glTexGend( long long double )
@ stdcall glTexGendv( long long ptr )
@ stdcall glTexGenf( long long long )
@ stdcall glTexGenfv( long long ptr )
@ stdcall glTexGeni( long long long )
@ stdcall glTexGeniv( long long ptr )
@ stdcall glTexImage1D( long long long long long long long ptr )
@ stdcall glTexImage2D( long long long long long long long long ptr )
@ stdcall glTexParameterf( long long long )
@ stdcall glTexParameterfv( long long ptr )
@ stdcall glTexParameteri( long long long )
@ stdcall glTexParameteriv( long long ptr )
@ stdcall glTexSubImage1D( long long long long long long ptr )
@ stdcall glTexSubImage2D( long long long long long long long long ptr )
@ stdcall glTranslated( double double double )
@ stdcall glTranslatef( long long long )
@ stdcall glVertex2d( double double )
@ stdcall glVertex2dv( ptr )
@ stdcall glVertex2f( long long )
@ stdcall glVertex2fv( ptr )
@ stdcall glVertex2i( long long )
@ stdcall glVertex2iv( ptr )
@ stdcall glVertex2s( long long )
@ stdcall glVertex2sv( ptr )
@ stdcall glVertex3d( double double double )
@ stdcall glVertex3dv( ptr )
@ stdcall glVertex3f( long long long )
@ stdcall glVertex3fv( ptr )
@ stdcall glVertex3i( long long long )
@ stdcall glVertex3iv( ptr )
@ stdcall glVertex3s( long long long )
@ stdcall glVertex3sv( ptr )
@ stdcall glVertex4d( double double double double )
@ stdcall glVertex4dv( ptr )
@ stdcall glVertex4f( long long long long )
@ stdcall glVertex4fv( ptr )
@ stdcall glVertex4i( long long long long )
@ stdcall glVertex4iv( ptr )
@ stdcall glVertex4s( long long long long )
@ stdcall glVertex4sv( ptr )
@ stdcall glVertexPointer( long long long ptr )
@ stdcall glViewport( long long long long )
@ stdcall wglChoosePixelFormat(long ptr)
@ stdcall wglCopyContext(long long long)
@ stdcall wglCreateContext(long)
@ stdcall wglCreateLayerContext(long long)
@ stdcall wglDeleteContext(long)
@ stdcall wglDescribeLayerPlane(long long long long ptr)
@ stdcall wglDescribePixelFormat(long long long ptr)
@ stdcall wglGetCurrentContext()
@ stdcall wglGetCurrentDC()
@ stdcall wglGetDefaultProcAddress(str)
@ stdcall wglGetLayerPaletteEntries(long long long long ptr)
@ stdcall wglGetPixelFormat(long)
@ stdcall wglGetProcAddress(str)
@ stdcall wglMakeCurrent(long long)
@ stdcall wglRealizeLayerPalette(long long long)
@ stdcall wglSetLayerPaletteEntries(long long long long ptr)
@ stdcall wglSetPixelFormat(long long ptr)
@ stdcall wglShareLists(long long)
@ stdcall wglSwapBuffers(long)
@ stdcall wglSwapLayerBuffers(long long)
@ stdcall wglSwapMultipleBuffers(long ptr)
@ stdcall wglUseFontBitmapsA(long long long long)
@ stdcall wglUseFontBitmapsW(long long long long)
@ stdcall wglUseFontOutlinesA(long long long long long long long ptr)
@ stdcall wglUseFontOutlinesW(long long long long long long long ptr)

View file

@ -0,0 +1,577 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS
* FILE: dll/opengl/opengl32/wgl.c
* PURPOSE: OpenGL32 DLL, opengl software implementation
*/
#include "opengl32.h"
#include <GL/osmesa.h>
#include <assert.h>
#include <wine/debug.h>
WINE_DEFAULT_DEBUG_CHANNEL(opengl32);
/* OSMesa stuff */
static HMODULE hMesaDll = NULL;
static OSMesaContext (GLAPIENTRY *pOSMesaCreateContextExt)(GLenum format, GLint depthBits, GLint stencilBits,
GLint accumBits, OSMesaContext sharelist);
static void (GLAPIENTRY *pOSMesaDestroyContext)(OSMesaContext ctx);
static GLboolean (GLAPIENTRY *pOSMesaMakeCurrent)( OSMesaContext ctx, void *buffer, GLenum type,
GLsizei width, GLsizei height );
static void (GLAPIENTRY *pOSMesaPixelStore)( GLint pname, GLint value );
static OSMESAproc (GLAPIENTRY *pOSMesaGetProcAddress)(const char *funcName);
struct sw_context
{
OSMesaContext mesa_ctx;
HHOOK hook;
struct sw_framebuffer* framebuffer;
};
#define SW_FB_DOUBLEBUFFERED 0x1
#define SW_FB_DIBSECTION 0x2
#define SW_FB_FREE_BITS 0x4
struct sw_framebuffer
{
INT sw_format;
UINT format_index;
void* bits;
DWORD flags;
BITMAPINFO bmi;
};
/* For our special SB glFinish implementation */
static void (GLAPIENTRY * pFinish)(void);
/* Single buffered API table */
static GLCLTPROCTABLE sw_table_sb;
/* Double buffered API table */
static GLCLTPROCTABLE sw_table_db;
static const struct
{
UINT mesa;
BYTE color_bits;
BYTE red_bits, red_shift;
BYTE green_bits, green_shift;
BYTE blue_bits, blue_shift;
BYTE alpha_bits, alpha_shift;
BYTE accum_bits;
BYTE depth_bits;
BYTE stencil_bits;
} pixel_formats[] =
{
{ OSMESA_BGRA, 32, 8, 16, 8, 8, 8, 0, 8, 24, 16, 32, 8 },
{ OSMESA_BGRA, 32, 8, 16, 8, 8, 8, 0, 8, 24, 16, 16, 8 },
{ OSMESA_RGBA, 32, 8, 0, 8, 8, 8, 16, 8, 24, 16, 32, 8 },
{ OSMESA_RGBA, 32, 8, 0, 8, 8, 8, 16, 8, 24, 16, 16, 8 },
{ OSMESA_ARGB, 32, 8, 8, 8, 16, 8, 24, 8, 0, 16, 32, 8 },
{ OSMESA_ARGB, 32, 8, 8, 8, 16, 8, 24, 8, 0, 16, 16, 8 },
{ OSMESA_RGB, 24, 8, 0, 8, 8, 8, 16, 0, 0, 16, 32, 8 },
{ OSMESA_RGB, 24, 8, 0, 8, 8, 8, 16, 0, 0, 16, 16, 8 },
{ OSMESA_BGR, 24, 8, 16, 8, 8, 8, 0, 0, 0, 16, 32, 8 },
{ OSMESA_BGR, 24, 8, 16, 8, 8, 8, 0, 0, 0, 16, 16, 8 },
{ OSMESA_RGB_565, 16, 5, 0, 6, 5, 5, 11, 0, 0, 16, 32, 8 },
{ OSMESA_RGB_565, 16, 5, 0, 6, 5, 5, 11, 0, 0, 16, 16, 8 },
};
/* glFinish for single-buffered pixel formats */
static void GLAPIENTRY sw_sb_Finish(void)
{
struct wgl_dc_data* dc_data = IntGetCurrentDcData();
struct sw_framebuffer* fb;
HDC hdc;
/* Call osmesa */
pFinish();
assert(dc_data != NULL);
fb = dc_data->sw_data;
assert(fb != NULL);
if(fb->flags & SW_FB_DIBSECTION)
return;
if(dc_data->flags & WGL_DC_OBJ_DC)
hdc = GetDC(dc_data->owner.hwnd);
else
hdc = dc_data->owner.hdc;
/* Upload the data to the device */
SetDIBitsToDevice(hdc,
0,
0,
fb->bmi.bmiHeader.biWidth,
fb->bmi.bmiHeader.biHeight,
0,
0,
0,
fb->bmi.bmiHeader.biWidth,
fb->bits,
&fb->bmi,
DIB_RGB_COLORS);
if(dc_data->flags & WGL_DC_OBJ_DC)
ReleaseDC(dc_data->owner.hwnd, hdc);
}
static UINT index_from_format(struct wgl_dc_data* dc_data, INT format, BOOL* doubleBuffered)
{
UINT index, nb_win_compat = 0, start_win_compat = 0;
HDC hdc;
INT bpp;
*doubleBuffered = FALSE;
if(!(dc_data->flags & WGL_DC_OBJ_DC))
return format - 1; /* OBJ_MEMDC, not double buffered */
hdc = GetDC(dc_data->owner.hwnd);
/* Find the window compatible formats */
bpp = GetDeviceCaps(hdc, BITSPIXEL);
for(index = 0; index<sizeof(pixel_formats)/sizeof(pixel_formats[0]); index++)
{
if(pixel_formats[index].color_bits == bpp)
{
if(!start_win_compat)
start_win_compat = index+1;
nb_win_compat++;
}
}
ReleaseDC(dc_data->owner.hwnd, hdc);
/* Double buffered format */
if(format < (start_win_compat + nb_win_compat))
{
if(format >= start_win_compat)
*doubleBuffered = TRUE;
return format-1;
}
/* Shift */
return format - nb_win_compat - 1;
}
INT sw_DescribePixelFormat(HDC hdc, INT format, UINT size, PIXELFORMATDESCRIPTOR* descr)
{
UINT index, nb_win_compat = 0, start_win_compat = 0;
INT ret = sizeof(pixel_formats)/sizeof(pixel_formats[0]);
if(GetObjectType(hdc) == OBJ_DC)
{
/* Find the window compatible formats */
INT bpp = GetDeviceCaps(hdc, BITSPIXEL);
for(index = 0; index<sizeof(pixel_formats)/sizeof(pixel_formats[0]); index++)
{
if(pixel_formats[index].color_bits == bpp)
{
if(!start_win_compat)
start_win_compat = index+1;
nb_win_compat++;
}
}
/* Add the double buffered formats */
ret += nb_win_compat;
}
index = (UINT)format - 1;
if(!descr)
return ret;
if((format > ret) || (size != sizeof(*descr)))
return 0;
/* Set flags */
descr->dwFlags = PFD_SUPPORT_GDI | PFD_SUPPORT_OPENGL | PFD_DRAW_TO_BITMAP | PFD_GENERIC_FORMAT;
/* See if this is a format compatible with the window */
if(format >= start_win_compat && format < (start_win_compat + nb_win_compat*2) )
{
/* It is */
descr->dwFlags |= PFD_DRAW_TO_WINDOW;
/* See if this should be double buffered */
if(format < (start_win_compat + nb_win_compat))
{
/* No GDI, no bitmap */
descr->dwFlags &= ~(PFD_SUPPORT_GDI | PFD_DRAW_TO_BITMAP);
descr->dwFlags |= PFD_DOUBLEBUFFER;
}
}
/* Normalize the index */
if(format >= start_win_compat + nb_win_compat)
index -= nb_win_compat;
/* Fill the rest of the structure */
descr->nSize = sizeof(*descr);
descr->nVersion = 1;
descr->iPixelType = PFD_TYPE_RGBA;
descr->cColorBits = pixel_formats[index].color_bits;
descr->cRedBits = pixel_formats[index].red_bits;
descr->cRedShift = pixel_formats[index].red_shift;
descr->cGreenBits = pixel_formats[index].green_bits;
descr->cGreenShift = pixel_formats[index].green_shift;
descr->cBlueBits = pixel_formats[index].blue_bits;
descr->cBlueShift = pixel_formats[index].blue_shift;
descr->cAlphaBits = pixel_formats[index].alpha_bits;
descr->cAlphaShift = pixel_formats[index].alpha_shift;
descr->cAccumBits = pixel_formats[index].accum_bits;
descr->cAccumRedBits = pixel_formats[index].accum_bits / 4;
descr->cAccumGreenBits = pixel_formats[index].accum_bits / 4;
descr->cAccumBlueBits = pixel_formats[index].accum_bits / 4;
descr->cAccumAlphaBits = pixel_formats[index].accum_bits / 4;
descr->cDepthBits = pixel_formats[index].depth_bits;
descr->cStencilBits = pixel_formats[index].stencil_bits;
descr->cAuxBuffers = 0;
descr->iLayerType = PFD_MAIN_PLANE;
return ret;
}
BOOL sw_SetPixelFormat(struct wgl_dc_data* dc_data, INT format)
{
struct sw_framebuffer* fb;
BOOL doubleBuffered;
/* NOTE: we let the wgl implementation tracking the pixel format for us */
if(hMesaDll != NULL)
goto osmesa_loaded;
/* So, someone is crazy enough to ask for sw implementation. Load it. */
TRACE("OpenGL software implementation START!\n");
hMesaDll = LoadLibrary("osmesa.dll");
if(!hMesaDll)
{
ERR("Failed loading osmesa.dll.\n");
return FALSE;
}
#define LOAD_PROC(x) do \
{ \
p## x = (void*)GetProcAddress(hMesaDll, #x); \
if(!p##x) \
{ \
ERR("Failed loading " #x " from osmesa.dll.\n"); \
FreeLibrary(hMesaDll); \
hMesaDll = NULL; \
return FALSE; \
} \
} while(0)
LOAD_PROC(OSMesaCreateContextExt);
LOAD_PROC(OSMesaDestroyContext);
LOAD_PROC(OSMesaMakeCurrent);
LOAD_PROC(OSMesaPixelStore);
LOAD_PROC(OSMesaGetProcAddress);
#undef LOAD_PROC
/* Load the GL api entries */
#define USE_GL_FUNC(x) do \
{ \
sw_table_db.glDispatchTable.x = (void*)GetProcAddress(hMesaDll, "gl" #x); \
if(!sw_table_db.glDispatchTable.x) \
{ \
ERR("Failed loading gl" #x " from osmesa.dll.\n"); \
FreeLibrary(hMesaDll); \
hMesaDll = NULL; \
return FALSE; \
} \
sw_table_sb.glDispatchTable.x = sw_table_db.glDispatchTable.x; \
} while(0);
#include "glfuncs.h"
#undef USE_GL_FUNC
/* For completeness */
sw_table_db.cEntries = sw_table_sb.cEntries = OPENGL_VERSION_110_ENTRIES;
/* We are not really single buffered, but this trick fits the bill */
pFinish = sw_table_sb.glDispatchTable.Finish;
sw_table_sb.glDispatchTable.Finish = sw_sb_Finish;
osmesa_loaded:
/* Now allocate our structure */
fb = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*fb));
if(!fb)
return FALSE;
/* Get the format index */
fb->format_index = index_from_format(dc_data, format, &doubleBuffered);
fb->flags = doubleBuffered ? SW_FB_DOUBLEBUFFERED : 0;
/* Everything went fine */
dc_data->sw_data = fb;
return TRUE;
}
DHGLRC sw_CreateContext(struct wgl_dc_data* dc_data)
{
struct sw_context *context;
struct sw_framebuffer* fb = dc_data->sw_data;
context = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*context));
if(!context)
return NULL;
context->mesa_ctx = pOSMesaCreateContextExt(pixel_formats[fb->format_index].mesa,
pixel_formats[fb->format_index].depth_bits,
pixel_formats[fb->format_index].stencil_bits,
pixel_formats[fb->format_index].accum_bits, 0 );
if(!context->mesa_ctx)
{
HeapFree( GetProcessHeap(), 0, context );
return NULL;
}
context->hook = NULL;
return (DHGLRC)context;
}
BOOL sw_DeleteContext(DHGLRC dhglrc)
{
struct sw_context* context = (struct sw_context*)dhglrc;
pOSMesaDestroyContext( context->mesa_ctx );
HeapFree( GetProcessHeap(), 0, context );
return TRUE;
}
void sw_ReleaseContext(DHGLRC dhglrc)
{
struct sw_context* context = (struct sw_context*)dhglrc;
/* Pass to osmesa the fact that there is no active context anymore */
pOSMesaMakeCurrent( NULL, NULL, GL_UNSIGNED_BYTE, 0, 0 );
/* Un-own */
context->framebuffer = NULL;
/* Unhook */
if(context->hook)
{
UnhookWindowsHookEx(context->hook);
context->hook = NULL;
}
}
#define WIDTH_BYTES_ALIGN32(cx, bpp) ((((cx) * (bpp) + 31) & ~31) >> 3)
static
LRESULT CALLBACK
sw_call_window_proc(
int nCode,
WPARAM wParam,
LPARAM lParam )
{
struct wgl_dc_data* dc_data = IntGetCurrentDcData();
struct sw_context* ctx = (struct sw_context*)IntGetCurrentDHGLRC();
struct sw_framebuffer* fb;
PCWPSTRUCT pParams = (PCWPSTRUCT)lParam;
if((!dc_data) || (!ctx))
return 0;
if(!(dc_data->flags & WGL_DC_OBJ_DC))
return 0;
if((nCode < 0) || (dc_data->owner.hwnd != pParams->hwnd) || (dc_data->sw_data == NULL))
return CallNextHookEx(ctx->hook, nCode, wParam, lParam);
fb = dc_data->sw_data;
if (pParams->message == WM_WINDOWPOSCHANGED)
{
/* We handle WM_WINDOWPOSCHANGED instead of WM_SIZE because according to
* http://blogs.msdn.com/oldnewthing/archive/2008/01/15/7113860.aspx
* WM_SIZE is generated from WM_WINDOWPOSCHANGED by DefWindowProc so it
* can be masked out by the application. */
LPWINDOWPOS lpWindowPos = (LPWINDOWPOS)pParams->lParam;
if((lpWindowPos->flags & SWP_SHOWWINDOW) ||
!(lpWindowPos->flags & SWP_NOMOVE) ||
!(lpWindowPos->flags & SWP_NOSIZE))
{
/* Size in WINDOWPOS includes the window frame, so get the size
* of the client area via GetClientRect. */
RECT client_rect;
UINT width, height, widthBytes;
GetClientRect(pParams->hwnd, &client_rect);
width = client_rect.right - client_rect.left;
height = client_rect.bottom - client_rect.top;
/* Do not reallocate for minimized windows */
if(width <= 0 || height <= 0)
goto end;
/* Temporarily disable osmesa */
pOSMesaMakeCurrent(NULL, NULL, GL_UNSIGNED_BYTE, 0, 0);
/* Resize the buffer accordingly */
widthBytes = WIDTH_BYTES_ALIGN32(width, pixel_formats[fb->format_index].color_bits);
fb->bits = HeapReAlloc(GetProcessHeap(), 0, fb->bits, widthBytes * height);
/* Update this */
fb->bmi.bmiHeader.biWidth = width;
fb->bmi.bmiHeader.biHeight = height;
/* Re-enable osmesa */
pOSMesaMakeCurrent(ctx->mesa_ctx, fb->bits, GL_UNSIGNED_BYTE, width, height);
pOSMesaPixelStore(OSMESA_ROW_LENGTH, widthBytes * 8 / pixel_formats[fb->format_index].color_bits);
}
}
end:
return CallNextHookEx(ctx->hook, nCode, wParam, lParam);
}
const GLCLTPROCTABLE* sw_SetContext(struct wgl_dc_data* dc_data, DHGLRC dhglrc)
{
struct sw_context* context = (struct sw_context*)dhglrc;
struct sw_framebuffer* fb = dc_data->sw_data;
UINT width, height, widthBytes;
void* bits = NULL;
if(dc_data->flags & WGL_DC_OBJ_DC)
{
HWND hwnd = dc_data->owner.hwnd;
RECT client_rect;
if(!hwnd)
{
ERR("Physical DC without a window!\n");
return NULL;
}
if(!GetClientRect(hwnd, &client_rect))
{
ERR("GetClientRect failed!\n");
return NULL;
}
/* This is a physical DC. Setup the hook */
context->hook = SetWindowsHookEx(WH_CALLWNDPROC,
sw_call_window_proc,
NULL,
GetCurrentThreadId());
/* Calculate width & height */
width = client_rect.right - client_rect.left;
height = client_rect.bottom - client_rect.top;
}
else /* OBJ_MEMDC */
{
BITMAP bm;
HBITMAP hbmp;
HDC hdc = dc_data->owner.hdc;
if(fb->flags & SW_FB_DOUBLEBUFFERED)
{
ERR("Memory DC called with a double buffered format.\n");
return FALSE;
}
hbmp = GetCurrentObject( hdc, OBJ_BITMAP );
if(!hbmp)
{
ERR("No Bitmap!\n");
return NULL;
}
if(GetObject(hbmp, sizeof(bm), &bm) == 0)
{
ERR("GetObject failed!\n");
return NULL;
}
widthBytes = bm.bmWidthBytes;
width = bm.bmWidth;
height = bm.bmHeight;
bits = bm.bmBits;
}
if(!width) width = 1;
if(!height) height = 1;
if(bits)
{
if(fb->flags & SW_FB_FREE_BITS)
{
fb->flags ^= SW_FB_FREE_BITS;
HeapFree(GetProcessHeap(), 0, fb->bits);
}
fb->flags |= SW_FB_DIBSECTION;
fb->bits = bits;
}
else
{
widthBytes = WIDTH_BYTES_ALIGN32(width, pixel_formats[fb->format_index].color_bits);
if(fb->flags & SW_FB_FREE_BITS)
fb->bits = HeapReAlloc(GetProcessHeap(), 0, fb->bits, widthBytes * height);
else
fb->bits = HeapAlloc(GetProcessHeap(), 0, widthBytes * height);
fb->flags |= SW_FB_FREE_BITS;
fb->flags &= ~SW_FB_DIBSECTION;
}
/* Set details up */
fb->bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
fb->bmi.bmiHeader.biWidth = width;
fb->bmi.bmiHeader.biHeight = height;
fb->bmi.bmiHeader.biPlanes = 1;
fb->bmi.bmiHeader.biBitCount = pixel_formats[fb->format_index].color_bits;
fb->bmi.bmiHeader.biCompression = BI_RGB;
fb->bmi.bmiHeader.biSizeImage = 0;
fb->bmi.bmiHeader.biXPelsPerMeter = 0;
fb->bmi.bmiHeader.biYPelsPerMeter = 0;
fb->bmi.bmiHeader.biClrUsed = 0;
fb->bmi.bmiHeader.biClrImportant = 0;
if(!pOSMesaMakeCurrent(context->mesa_ctx, fb->bits, GL_UNSIGNED_BYTE, width, height))
{
ERR("OSMesaMakeCurrent failed!\n");
/* Damn! Free everything */
if(fb->flags & SW_FB_FREE_BITS)
HeapFree(GetProcessHeap(), 0, fb->bits);
fb->flags &= ~SW_FB_FREE_BITS;
fb->bits = NULL;
/* Unhook */
if(context->hook)
{
UnhookWindowsHookEx(context->hook);
context->hook = NULL;
}
return NULL;
}
/* Don't forget to tell mesa how our image is organized */
pOSMesaPixelStore(OSMESA_ROW_LENGTH, widthBytes * 8 / pixel_formats[fb->format_index].color_bits);
/* Own the context */
context->framebuffer = fb;
return (fb->flags & SW_FB_DOUBLEBUFFERED) ? &sw_table_db : &sw_table_sb;
}
PROC sw_GetProcAddress(LPCSTR name)
{
return (PROC)pOSMesaGetProcAddress(name);
}
BOOL sw_CopyContext(DHGLRC dhglrcSrc, DHGLRC dhglrcDst, UINT mask)
{
FIXME("Software wglCopyContext is UNIMPLEMENTED, mask %lx.\n", mask);
return FALSE;
}
BOOL sw_ShareLists(DHGLRC dhglrcSrc, DHGLRC dhglrcDst)
{
FIXME("Software wglShareLists is UNIMPLEMENTED.\n");
return FALSE;
}
BOOL sw_SwapBuffers(HDC hdc, struct wgl_dc_data* dc_data)
{
struct sw_framebuffer* fb = dc_data->sw_data;
if(!(fb->flags & SW_FB_DOUBLEBUFFERED))
return TRUE;
if(!(fb->bits))
return TRUE;
return (SetDIBitsToDevice(hdc,
0,
0,
fb->bmi.bmiHeader.biWidth,
fb->bmi.bmiHeader.biHeight,
0,
0,
0,
fb->bmi.bmiHeader.biWidth,
fb->bits,
&fb->bmi,
DIB_RGB_COLORS) != 0);
}

View file

@ -0,0 +1,906 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS
* FILE: dll/opengl/opengl32/wgl.c
* PURPOSE: OpenGL32 DLL, WGL functions
*/
#include "opengl32.h"
#include <pseh/pseh2.h>
#include <wine/debug.h>
WINE_DEFAULT_DEBUG_CHANNEL(wgl);
static CRITICAL_SECTION dc_data_cs = {NULL, -1, 0, 0, 0, 0};
static struct wgl_dc_data* dc_data_list = NULL;
/* FIXME: suboptimal */
static
struct wgl_dc_data*
get_dc_data(HDC hdc)
{
HWND hwnd = NULL;
struct wgl_dc_data* data;
DWORD objType = GetObjectType(hdc);
ULONG flags = 0;
union
{
HWND hwnd;
HDC hdc;
HANDLE u;
} id;
/* Look for the right data identifier */
if(objType == OBJ_DC)
{
hwnd = WindowFromDC(hdc);
if(!hwnd)
return NULL;
id.hwnd = hwnd;
flags = WGL_DC_OBJ_DC;
}
else if(objType == OBJ_MEMDC)
{
id.hdc = hdc;
}
else
{
return NULL;
}
EnterCriticalSection(&dc_data_cs);
data = dc_data_list;
while(data)
{
if(data->owner.u == id.u)
{
LeaveCriticalSection(&dc_data_cs);
return data;
}
data = data->next;
}
data= HeapAlloc(GetProcessHeap(), 0, sizeof(*data));
if(!data)
{
LeaveCriticalSection(&dc_data_cs);
return NULL;
}
/* initialize the structure */
data->owner.u = id.u;
data->flags = flags;
data->pixelformat = 0;
/* Load the driver */
data->icd_data = IntGetIcdData(hdc);
/* Get the number of available formats for this DC once and for all */
if(data->icd_data)
data->nb_icd_formats = data->icd_data->DrvDescribePixelFormat(hdc, 0, 0, NULL);
else
data->nb_icd_formats = 0;
data->nb_sw_formats = sw_DescribePixelFormat(hdc, 0, 0, NULL);
data->next = dc_data_list;
dc_data_list = data;
LeaveCriticalSection(&dc_data_cs);
return data;
}
void release_dc_data(struct wgl_dc_data* dc_data)
{
(void)dc_data;
}
struct wgl_context* get_context(HGLRC hglrc)
{
struct wgl_context* context = (struct wgl_context*)hglrc;
if(!hglrc)
return NULL;
_SEH2_TRY
{
if(context->magic != 'GLRC')
context = NULL;
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
context = NULL;
}
_SEH2_END;
return context;
}
INT WINAPI wglDescribePixelFormat(HDC hdc, INT format, UINT size, PIXELFORMATDESCRIPTOR *descr )
{
struct wgl_dc_data* dc_data = get_dc_data(hdc);
INT ret;
if(!dc_data)
{
SetLastError(ERROR_INVALID_HANDLE);
return 0;
}
ret = dc_data->nb_icd_formats + dc_data->nb_sw_formats;
if(!descr)
{
release_dc_data(dc_data);
return ret;
}
if((format == 0) || (format > ret) || (size != sizeof(*descr)))
{
release_dc_data(dc_data);
SetLastError(ERROR_INVALID_PARAMETER);
return 0;
}
/* Query ICD if needed */
if(format <= dc_data->nb_icd_formats)
{
if(!dc_data->icd_data->DrvDescribePixelFormat(hdc, format, size, descr))
{
ret = 0;
}
}
else
{
/* This is a software format */
format -= dc_data->nb_icd_formats;
if(!sw_DescribePixelFormat(hdc, format, size, descr))
{
ret = 0;
}
}
release_dc_data(dc_data);
return ret;
}
INT WINAPI wglChoosePixelFormat(HDC hdc, const PIXELFORMATDESCRIPTOR* ppfd)
{
PIXELFORMATDESCRIPTOR format, best;
int i, count, best_format;
int bestDBuffer = -1, bestStereo = -1;
TRACE_(wgl)( "%p %p: size %u version %u flags %u type %u color %u %u,%u,%u,%u "
"accum %u depth %u stencil %u aux %u\n",
hdc, ppfd, ppfd->nSize, ppfd->nVersion, ppfd->dwFlags, ppfd->iPixelType,
ppfd->cColorBits, ppfd->cRedBits, ppfd->cGreenBits, ppfd->cBlueBits, ppfd->cAlphaBits,
ppfd->cAccumBits, ppfd->cDepthBits, ppfd->cStencilBits, ppfd->cAuxBuffers );
count = wglDescribePixelFormat( hdc, 0, 0, NULL );
if (!count) return 0;
best_format = 0;
best.dwFlags = 0;
best.cAlphaBits = -1;
best.cColorBits = -1;
best.cDepthBits = -1;
best.cStencilBits = -1;
best.cAuxBuffers = -1;
for (i = 1; i <= count; i++)
{
if (!wglDescribePixelFormat( hdc, i, sizeof(format), &format )) continue;
if (ppfd->iPixelType != format.iPixelType)
{
TRACE( "pixel type mismatch for iPixelFormat=%d\n", i );
continue;
}
/* only use bitmap capable for formats for bitmap rendering */
if( (ppfd->dwFlags & PFD_DRAW_TO_BITMAP) != (format.dwFlags & PFD_DRAW_TO_BITMAP))
{
TRACE( "PFD_DRAW_TO_BITMAP mismatch for iPixelFormat=%d\n", i );
continue;
}
/* The behavior of PDF_STEREO/PFD_STEREO_DONTCARE and PFD_DOUBLEBUFFER / PFD_DOUBLEBUFFER_DONTCARE
* is not very clear on MSDN. They specify that ChoosePixelFormat tries to match pixel formats
* with the flag (PFD_STEREO / PFD_DOUBLEBUFFERING) set. Otherwise it says that it tries to match
* formats without the given flag set.
* A test on Windows using a Radeon 9500pro on WinXP (the driver doesn't support Stereo)
* has indicated that a format without stereo is returned when stereo is unavailable.
* So in case PFD_STEREO is set, formats that support it should have priority above formats
* without. In case PFD_STEREO_DONTCARE is set, stereo is ignored.
*
* To summarize the following is most likely the correct behavior:
* stereo not set -> prefer non-stereo formats, but also accept stereo formats
* stereo set -> prefer stereo formats, but also accept non-stereo formats
* stereo don't care -> it doesn't matter whether we get stereo or not
*
* In Wine we will treat non-stereo the same way as don't care because it makes
* format selection even more complicated and second drivers with Stereo advertise
* each format twice anyway.
*/
/* Doublebuffer, see the comments above */
if (!(ppfd->dwFlags & PFD_DOUBLEBUFFER_DONTCARE))
{
if (((ppfd->dwFlags & PFD_DOUBLEBUFFER) != bestDBuffer) &&
((format.dwFlags & PFD_DOUBLEBUFFER) == (ppfd->dwFlags & PFD_DOUBLEBUFFER)))
goto found;
if (bestDBuffer != -1 && (format.dwFlags & PFD_DOUBLEBUFFER) != bestDBuffer) continue;
}
/* Stereo, see the comments above. */
if (!(ppfd->dwFlags & PFD_STEREO_DONTCARE))
{
if (((ppfd->dwFlags & PFD_STEREO) != bestStereo) &&
((format.dwFlags & PFD_STEREO) == (ppfd->dwFlags & PFD_STEREO)))
goto found;
if (bestStereo != -1 && (format.dwFlags & PFD_STEREO) != bestStereo) continue;
}
/* Below we will do a number of checks to select the 'best' pixelformat.
* We assume the precedence cColorBits > cAlphaBits > cDepthBits > cStencilBits -> cAuxBuffers.
* The code works by trying to match the most important options as close as possible.
* When a reasonable format is found, we will try to match more options.
* It appears (see the opengl32 test) that Windows opengl drivers ignore options
* like cColorBits, cAlphaBits and friends if they are set to 0, so they are considered
* as DONTCARE. At least Serious Sam TSE relies on this behavior. */
if (ppfd->cColorBits)
{
if (((ppfd->cColorBits > best.cColorBits) && (format.cColorBits > best.cColorBits)) ||
((format.cColorBits >= ppfd->cColorBits) && (format.cColorBits < best.cColorBits)))
goto found;
if (best.cColorBits != format.cColorBits) /* Do further checks if the format is compatible */
{
TRACE( "color mismatch for iPixelFormat=%d\n", i );
continue;
}
}
if (ppfd->cAlphaBits)
{
if (((ppfd->cAlphaBits > best.cAlphaBits) && (format.cAlphaBits > best.cAlphaBits)) ||
((format.cAlphaBits >= ppfd->cAlphaBits) && (format.cAlphaBits < best.cAlphaBits)))
goto found;
if (best.cAlphaBits != format.cAlphaBits)
{
TRACE( "alpha mismatch for iPixelFormat=%d\n", i );
continue;
}
}
if (ppfd->cDepthBits)
{
if (((ppfd->cDepthBits > best.cDepthBits) && (format.cDepthBits > best.cDepthBits)) ||
((format.cDepthBits >= ppfd->cDepthBits) && (format.cDepthBits < best.cDepthBits)))
goto found;
if (best.cDepthBits != format.cDepthBits)
{
TRACE( "depth mismatch for iPixelFormat=%d\n", i );
continue;
}
}
if (ppfd->cStencilBits)
{
if (((ppfd->cStencilBits > best.cStencilBits) && (format.cStencilBits > best.cStencilBits)) ||
((format.cStencilBits >= ppfd->cStencilBits) && (format.cStencilBits < best.cStencilBits)))
goto found;
if (best.cStencilBits != format.cStencilBits)
{
TRACE( "stencil mismatch for iPixelFormat=%d\n", i );
continue;
}
}
if (ppfd->cAuxBuffers)
{
if (((ppfd->cAuxBuffers > best.cAuxBuffers) && (format.cAuxBuffers > best.cAuxBuffers)) ||
((format.cAuxBuffers >= ppfd->cAuxBuffers) && (format.cAuxBuffers < best.cAuxBuffers)))
goto found;
if (best.cAuxBuffers != format.cAuxBuffers)
{
TRACE( "aux mismatch for iPixelFormat=%d\n", i );
continue;
}
}
continue;
found:
best_format = i;
best = format;
bestDBuffer = format.dwFlags & PFD_DOUBLEBUFFER;
bestStereo = format.dwFlags & PFD_STEREO;
}
TRACE( "returning %u\n", best_format );
return best_format;
}
BOOL WINAPI wglCopyContext(HGLRC hglrcSrc, HGLRC hglrcDst, UINT mask)
{
struct wgl_context* ctx_src = get_context(hglrcSrc);
struct wgl_context* ctx_dst = get_context(hglrcDst);
if(!ctx_src || !ctx_dst)
{
SetLastError(ERROR_INVALID_HANDLE);
return FALSE;
}
/* Check this is the same pixel format */
if((ctx_dst->icd_data != ctx_src->icd_data) ||
(ctx_dst->pixelformat != ctx_src->pixelformat))
{
SetLastError(ERROR_INVALID_PIXEL_FORMAT);
return FALSE;
}
if(ctx_src->icd_data)
return ctx_src->icd_data->DrvCopyContext(ctx_src->dhglrc, ctx_dst->dhglrc, mask);
return sw_CopyContext(ctx_src->dhglrc, ctx_dst->dhglrc, mask);
}
HGLRC WINAPI wglCreateContext(HDC hdc)
{
struct wgl_dc_data* dc_data = get_dc_data(hdc);
struct wgl_context* context;
DHGLRC dhglrc;
if(!dc_data)
{
SetLastError(ERROR_INVALID_HANDLE);
return NULL;
}
if(!dc_data->pixelformat)
{
release_dc_data(dc_data);
SetLastError(ERROR_INVALID_PIXEL_FORMAT);
return NULL;
}
if(!dc_data->icd_data)
dhglrc = sw_CreateContext(dc_data);
else
dhglrc = dc_data->icd_data->DrvCreateContext(hdc);
if(!dhglrc)
{
release_dc_data(dc_data);
SetLastError(ERROR_INVALID_PIXEL_FORMAT);
return NULL;
}
context = HeapAlloc(GetProcessHeap(), 0, sizeof(*context));
if(!context)
{
if(!dc_data->icd_data)
sw_DeleteContext(dhglrc);
else
dc_data->icd_data->DrvDeleteContext(dhglrc);
release_dc_data(dc_data);
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return NULL;
}
/* Copy info from the DC data */
context->dhglrc = dhglrc;
context->icd_data = dc_data->icd_data;
context->pixelformat = dc_data->pixelformat;
context->thread_id = 0;
context->magic = 'GLRC';
release_dc_data(dc_data);
return (HGLRC)context;
}
HGLRC WINAPI wglCreateLayerContext(HDC hdc, int iLayerPlane)
{
struct wgl_dc_data* dc_data = get_dc_data(hdc);
struct wgl_context* context;
DHGLRC dhglrc;
if(!dc_data)
{
SetLastError(ERROR_INVALID_HANDLE);
return NULL;
}
if(!dc_data->pixelformat)
{
release_dc_data(dc_data);
SetLastError(ERROR_INVALID_PIXEL_FORMAT);
return NULL;
}
if(!dc_data->icd_data)
{
if(iLayerPlane != 0)
{
/* Not supported in SW implementation */
release_dc_data(dc_data);
SetLastError(ERROR_INVALID_PIXEL_FORMAT);
return NULL;
}
dhglrc = sw_CreateContext(dc_data);
}
else
{
dhglrc = dc_data->icd_data->DrvCreateLayerContext(hdc, iLayerPlane);
}
if(!dhglrc)
{
release_dc_data(dc_data);
SetLastError(ERROR_INVALID_PIXEL_FORMAT);
return NULL;
}
context = HeapAlloc(GetProcessHeap(), 0, sizeof(*context));
if(!context)
{
if(!dc_data->icd_data)
sw_DeleteContext(dhglrc);
else
dc_data->icd_data->DrvDeleteContext(dhglrc);
release_dc_data(dc_data);
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return NULL;
}
/* Copy info from the DC data */
context->dhglrc = dhglrc;
context->icd_data = dc_data->icd_data;
context->pixelformat = dc_data->pixelformat;
context->thread_id = 0;
context->magic = 'GLRC';
release_dc_data(dc_data);
return (HGLRC)context;
}
BOOL WINAPI wglDeleteContext(HGLRC hglrc)
{
struct wgl_context* context = get_context(hglrc);
LONG thread_id = GetCurrentThreadId();
if(!context)
{
SetLastError(ERROR_INVALID_HANDLE);
return FALSE;
}
/* Own this context before touching it */
if(InterlockedCompareExchange(&context->thread_id, thread_id, 0) != 0)
{
/* We can't delete a context current to another thread */
if(context->thread_id != thread_id)
{
SetLastError(ERROR_BUSY);
return FALSE;
}
/* This is in our thread. Release and try again */
if(!wglMakeCurrent(NULL, NULL))
return FALSE;
return wglDeleteContext(hglrc);
}
if(context->icd_data)
context->icd_data->DrvDeleteContext(context->dhglrc);
else
sw_DeleteContext(context->dhglrc);
context->magic = 0;
HeapFree(GetProcessHeap(), 0, context);
return TRUE;
}
BOOL WINAPI wglDescribeLayerPlane(HDC hdc,
int iPixelFormat,
int iLayerPlane,
UINT nBytes,
LPLAYERPLANEDESCRIPTOR plpd)
{
struct wgl_dc_data* dc_data = get_dc_data(hdc);
if(!dc_data)
{
SetLastError(ERROR_INVALID_HANDLE);
return FALSE;
}
if(iPixelFormat <= dc_data->nb_icd_formats)
return dc_data->icd_data->DrvDescribeLayerPlane(hdc, iPixelFormat, iLayerPlane, nBytes, plpd);
/* SW implementation doesn't support this */
return FALSE;
}
HGLRC WINAPI wglGetCurrentContext(void)
{
return IntGetCurrentRC();
}
HDC WINAPI wglGetCurrentDC(void)
{
return IntGetCurrentDC();
}
PROC WINAPI wglGetDefaultProcAddress(LPCSTR lpszProc)
{
/* undocumented... */
return NULL;
}
int WINAPI wglGetLayerPaletteEntries(HDC hdc, int iLayerPlane, int iStart, int cEntries, COLORREF* pcr )
{
struct wgl_dc_data* dc_data = get_dc_data(hdc);
if(!dc_data)
{
SetLastError(ERROR_INVALID_HANDLE);
return 0;
}
if(!dc_data->pixelformat)
{
SetLastError(ERROR_INVALID_PIXEL_FORMAT);
return 0;
}
if(dc_data->icd_data)
return dc_data->icd_data->DrvGetLayerPaletteEntries(hdc, iLayerPlane, iStart, cEntries, pcr);
/* SW implementation doesn't support this */
return 0;
}
INT WINAPI wglGetPixelFormat(HDC hdc)
{
INT ret;
struct wgl_dc_data* dc_data = get_dc_data(hdc);
if(!dc_data)
{
SetLastError(ERROR_INVALID_HANDLE);
return 0;
}
ret = dc_data->pixelformat;
release_dc_data(dc_data);
return ret;
}
PROC WINAPI wglGetProcAddress(LPCSTR name)
{
struct wgl_context* context = get_context(IntGetCurrentRC());
if(!context)
return NULL;
/* This shall fail for opengl 1.1 functions */
#define USE_GL_FUNC(x) if(!strcmp(name, "gl" #x)) return NULL;
#include "glfuncs.h"
#undef USE_GL_FUNCS
/* Forward */
if(context->icd_data)
return context->icd_data->DrvGetProcAddress(name);
return sw_GetProcAddress(name);
}
void APIENTRY set_api_table(const GLCLTPROCTABLE* table)
{
#ifdef OPENGL32_USE_TLS
struct Opengl32_ThreadData* data = TlsGetValue(OglTlsIndex);
data->ProcTable = table;
#else
NtCurrentTeb()->glTable = &table->glDispatchTable;
#endif
}
BOOL WINAPI wglMakeCurrent(HDC hdc, HGLRC hglrc)
{
struct wgl_context* ctx = get_context(hglrc);
struct wgl_context* old_ctx = get_context(IntGetCurrentRC());
const GLCLTPROCTABLE* apiTable;
LONG thread_id = (LONG)GetCurrentThreadId();
if(ctx)
{
struct wgl_dc_data* dc_data = get_dc_data(hdc);
if(!dc_data)
{
ERR("wglMakeCurrent was passed an invalid DC handle.\n");
SetLastError(ERROR_INVALID_HANDLE);
return FALSE;
}
/* Check compatibility */
if((ctx->icd_data != dc_data->icd_data) || (ctx->pixelformat != dc_data->pixelformat))
{
/* That's bad, man */
ERR("HGLRC %p and HDC %p are not compatible.\n", hglrc, hdc);
release_dc_data(dc_data);
SetLastError(ERROR_INVALID_HANDLE);
return FALSE;
}
/* Set the thread ID */
if(InterlockedCompareExchange(&ctx->thread_id, thread_id, 0) != 0)
{
/* Already current for a thread. Maybe it's us ? */
release_dc_data(dc_data);
if(ctx->thread_id != thread_id)
SetLastError(ERROR_BUSY);
return (ctx->thread_id == thread_id);
}
if(old_ctx)
{
/* Unset it */
if(old_ctx->icd_data)
old_ctx->icd_data->DrvReleaseContext(old_ctx->dhglrc);
else
sw_ReleaseContext(old_ctx->dhglrc);
InterlockedExchange(&old_ctx->thread_id, 0);
}
/* Call the ICD or SW implementation */
if(ctx->icd_data)
apiTable = ctx->icd_data->DrvSetContext(hdc, ctx->dhglrc, set_api_table);
else
apiTable = sw_SetContext(dc_data, ctx->dhglrc);
if(!apiTable)
{
ERR("DrvSetContext failed!\n");
/* revert */
InterlockedExchange(&ctx->thread_id, 0);
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
set_api_table(apiTable);
/* Make it current */
#ifdef OPENGL32_USE_TLS
{
struct Opengl32_ThreadData* thread_data = TlsGetValue(OglTlsIndex);
thread_data->hglrc = hglrc;
thread_data->hdc = hdc;
thread_data->dc_data = dc_data;
}
#endif
}
else if(old_ctx)
{
/* Unset it */
if(old_ctx->icd_data)
old_ctx->icd_data->DrvReleaseContext(old_ctx->dhglrc);
else
sw_ReleaseContext(old_ctx->dhglrc);
InterlockedExchange(&old_ctx->thread_id, 0);
#ifdef OPENGL32_USE_TLS
{
struct Opengl32_ThreadData* thread_data = TlsGetValue(OglTlsIndex);
thread_data->hglrc = NULL;
thread_data->hdc = NULL;
thread_data->dc_data = NULL;
}
#endif
/* Reset the no-op table */
set_api_table(&StubTable);
/* Test conformance (extreme cases) */
return hglrc == NULL;
}
else
{
/* Winetest conformance */
if (GetObjectType( hdc ) != OBJ_DC && GetObjectType( hdc ) != OBJ_MEMDC)
{
ERR( "Error: hdc is not a DC handle!\n");
SetLastError( ERROR_INVALID_HANDLE );
return FALSE;
}
}
return TRUE;
}
BOOL WINAPI wglRealizeLayerPalette(HDC hdc,
int iLayerPlane,
BOOL bRealize)
{
struct wgl_dc_data* dc_data = get_dc_data(hdc);
if(!dc_data)
{
SetLastError(ERROR_INVALID_HANDLE);
return FALSE;
}
if(!dc_data->pixelformat)
{
SetLastError(ERROR_INVALID_PIXEL_FORMAT);
return FALSE;
}
if(dc_data->icd_data)
return dc_data->icd_data->DrvRealizeLayerPalette(hdc, iLayerPlane, bRealize);
/* SW implementation doesn't support this */
return FALSE;
}
int WINAPI wglSetLayerPaletteEntries(HDC hdc,
int iLayerPlane,
int iStart,
int cEntries,
const COLORREF *pcr)
{
struct wgl_dc_data* dc_data = get_dc_data(hdc);
if(!dc_data)
{
SetLastError(ERROR_INVALID_HANDLE);
return 0;
}
if(!dc_data->pixelformat)
{
SetLastError(ERROR_INVALID_PIXEL_FORMAT);
return 0;
}
if(dc_data->icd_data)
return dc_data->icd_data->DrvSetLayerPaletteEntries(hdc, iLayerPlane, iStart, cEntries, pcr);
/* SW implementation doesn't support this */
return 0;
}
BOOL WINAPI wglSetPixelFormat(HDC hdc, INT format, const PIXELFORMATDESCRIPTOR *descr)
{
struct wgl_dc_data* dc_data = get_dc_data(hdc);
INT sw_format;
BOOL ret;
if(!dc_data)
{
SetLastError(ERROR_INVALID_HANDLE);
return FALSE;
}
if(!format)
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
if(dc_data->pixelformat)
{
return (format == dc_data->pixelformat);
}
if(format <= dc_data->nb_icd_formats)
{
ret = dc_data->icd_data->DrvSetPixelFormat(hdc, format);
if(ret)
{
dc_data->pixelformat = format;
return TRUE;
}
}
sw_format = format - dc_data->nb_icd_formats;
if(sw_format <= dc_data->nb_sw_formats)
{
ret = sw_SetPixelFormat(dc_data, sw_format);
if(ret)
{
/* This is now officially a software-only HDC */
dc_data->icd_data = NULL;
dc_data->pixelformat = format;
return TRUE;
}
}
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
BOOL WINAPI wglShareLists(HGLRC hglrcSrc, HGLRC hglrcDst)
{
struct wgl_context* ctx_src = get_context(hglrcSrc);
struct wgl_context* ctx_dst = get_context(hglrcDst);
if(!ctx_src || !ctx_dst)
{
SetLastError(ERROR_INVALID_HANDLE);
return FALSE;
}
/* Check this is the same pixel format */
if((ctx_dst->icd_data != ctx_src->icd_data) ||
(ctx_dst->pixelformat != ctx_src->pixelformat))
{
SetLastError(ERROR_INVALID_PIXEL_FORMAT);
return FALSE;
}
if(ctx_src->icd_data)
return ctx_src->icd_data->DrvShareLists(ctx_src->dhglrc, ctx_dst->dhglrc);
return sw_ShareLists(ctx_src->dhglrc, ctx_dst->dhglrc);
}
BOOL WINAPI wglSwapBuffers(HDC hdc)
{
struct wgl_dc_data* dc_data = get_dc_data(hdc);
if(!dc_data)
{
SetLastError(ERROR_INVALID_HANDLE);
return FALSE;
}
if(!dc_data->pixelformat)
{
SetLastError(ERROR_INVALID_PIXEL_FORMAT);
return FALSE;
}
if(dc_data->icd_data)
return dc_data->icd_data->DrvSwapBuffers(hdc);
return sw_SwapBuffers(hdc, dc_data);
}
BOOL WINAPI wglSwapLayerBuffers(HDC hdc, UINT fuPlanes)
{
return FALSE;
}
DWORD WINAPI wglSwapMultipleBuffers(UINT count, CONST WGLSWAP * toSwap)
{
return 0;
}
BOOL WINAPI wglUseFontBitmapsA(HDC hdc, DWORD first, DWORD count, DWORD listBase)
{
FIXME("stub.\n");
return FALSE;
}
BOOL WINAPI wglUseFontBitmapsW(HDC hdc, DWORD first, DWORD count, DWORD listBase)
{
FIXME("stub.\n");
return FALSE;
}
BOOL WINAPI wglUseFontOutlinesA(HDC hdc,
DWORD first,
DWORD count,
DWORD listBase,
FLOAT deviation,
FLOAT extrusion,
int format,
LPGLYPHMETRICSFLOAT lpgmf)
{
return FALSE;
}
BOOL WINAPI wglUseFontOutlinesW(HDC hdc,
DWORD first,
DWORD count,
DWORD listBase,
FLOAT deviation,
FLOAT extrusion,
int format,
LPGLYPHMETRICSFLOAT lpgmf)
{
return FALSE;
}