diff --git a/reactos/dll/opengl/CMakeLists.txt b/reactos/dll/opengl/CMakeLists.txt index 292b7bbf8b2..21afb30de8a 100644 --- a/reactos/dll/opengl/CMakeLists.txt +++ b/reactos/dll/opengl/CMakeLists.txt @@ -1,6 +1,4 @@ -include_directories(mesa/include) add_subdirectory(glu32) add_subdirectory(mesa) add_subdirectory(opengl32) -add_subdirectory(opengl32_new) diff --git a/reactos/dll/opengl/opengl32/CMakeLists.txt b/reactos/dll/opengl/opengl32/CMakeLists.txt index 4fb60910f8b..2ee6be2d90d 100644 --- a/reactos/dll/opengl/opengl32/CMakeLists.txt +++ b/reactos/dll/opengl/opengl32/CMakeLists.txt @@ -1,22 +1,65 @@ spec2def(opengl32.dll opengl32.spec ADD_IMPORTLIB) +set_cpp(WITH_STL) + +include_directories( + ../mesa/src/mesa + ../mesa/src/mapi) + add_definitions( -D_GDI32_ # prevent gl* being declared __declspec(dllimport) in MS headers -DBUILD_GL32 # declare gl* as __declspec(dllexport) in Mesa headers + -D_GLAPI_NO_EXPORTS # prevent _glapi_* from being declared __declspec(dllimport) ) +# useful to test under windows <> w2k3 +set(OPENGL32_USE_TLS TRUE) + +if(OPENGL32_USE_TLS) + add_definitions(-DOPENGL32_USE_TLS) +endif() + list(APPEND SOURCE - font.c - gl.c - opengl32.c + apistubs.c + dllmain.c + icdload.c + swimpl.c wgl.c + wgl_font.c ${CMAKE_CURRENT_BINARY_DIR}/opengl32_stubs.c - ${CMAKE_CURRENT_BINARY_DIR}/opengl32.def) + ${CMAKE_CURRENT_BINARY_DIR}/opengl32.def +) + +set_source_files_properties(gcrt0.o libgmon.a PROPERTIES EXTERNAL_OBJECT TRUE) + +if(ARCH STREQUAL "i386") + # Optimisation: use asm trampolines to ICD provided functions + list(APPEND SOURCE + glapi_x86.s + ) +endif() add_library(opengl32 SHARED ${SOURCE}) -target_link_libraries(opengl32 wine) -set_module_type(opengl32 win32dll UNICODE) +target_link_libraries(opengl32 + wine + ${PSEH_LIB} + mesa_drv_common + mesa_swrast + mesa_swrast_setup + mesa_tnl + mesa_main + mesa_vbo + mesa_program + mesa_math + mesa_glsl +) + +if((ARCH STREQUAL "i386") AND (NOT MSVC)) + target_link_libraries(opengl32 mesa_x86) +endif() + +set_module_type(opengl32 win32dll) + add_importlibs(opengl32 gdi32 user32 advapi32 msvcrt kernel32 ntdll) -add_pch(opengl32 opengl32.h) -add_cd_file(TARGET opengl32 DESTINATION reactos/system32 FOR all) +add_cd_file(TARGET opengl32 DESTINATION reactos/system32 FOR all) \ No newline at end of file diff --git a/reactos/dll/opengl/opengl32_new/apistubs.c b/reactos/dll/opengl/opengl32/apistubs.c similarity index 99% rename from reactos/dll/opengl/opengl32_new/apistubs.c rename to reactos/dll/opengl/opengl32/apistubs.c index 6b6feb8e8af..08276e142ed 100644 --- a/reactos/dll/opengl/opengl32_new/apistubs.c +++ b/reactos/dll/opengl/opengl32/apistubs.c @@ -2026,6 +2026,8 @@ const GLCLTPROCTABLE StubTable = } }; + +#ifndef __i386__ void GLAPIENTRY glNewList(GLuint list, GLenum mode) { IntGetCurrentDispatchTable()->NewList(list, mode); @@ -3705,6 +3707,7 @@ void GLAPIENTRY glPushClientAttrib(GLbitfield mask) { IntGetCurrentDispatchTable()->PushClientAttrib(mask); } +#endif //__i386__ /* Unknown debug function */ GLint GLAPIENTRY glDebugEntry(GLint unknown1, GLint unknown2) diff --git a/reactos/dll/opengl/opengl32_new/dllmain.c b/reactos/dll/opengl/opengl32/dllmain.c similarity index 92% rename from reactos/dll/opengl/opengl32_new/dllmain.c rename to reactos/dll/opengl/opengl32/dllmain.c index 6865640c807..9d8f9dfe5a3 100644 --- a/reactos/dll/opengl/opengl32_new/dllmain.c +++ b/reactos/dll/opengl/opengl32/dllmain.c @@ -31,11 +31,11 @@ DllMain(HINSTANCE hInstance, DWORD Reason, LPVOID Reserved) /* Fall through */ case DLL_THREAD_ATTACH: #ifdef OPENGL32_USE_TLS - ThreadData = HeapAlloc(GetProcessHeap(), 0, sizeof(*ThreadData)); + ThreadData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ThreadData)); if(!ThreadData) return FALSE; TlsSetValue(OglTlsIndex, ThreadData); - ThreadData->ProcTable = &StubTable; + ThreadData->glDispatchTable = &StubTable.glDispatchTable; ThreadData->hglrc = NULL; ThreadData->hdc = NULL; ThreadData->dc_data = NULL; diff --git a/reactos/dll/opengl/opengl32/glapi_x86.s b/reactos/dll/opengl/opengl32/glapi_x86.s new file mode 100644 index 00000000000..2bfb61e7f7a --- /dev/null +++ b/reactos/dll/opengl/opengl32/glapi_x86.s @@ -0,0 +1,363 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS + * FILE: dll/opengl/opengl32/glapi_x86.s + * PURPOSE: OpenGL32 DLL + */ + +/* X86 opengl API entry points, fast forward to the current thread's dispatch table */ +#include + +.code + +EXTERN _OglTlsIndex:DWORD +EXTERN _TlsGetValue@4:PROC + +MACRO(USE_GL_FUNC, name, offset, stack) +PUBLIC _gl&name&@&stack +.PROC _gl&name&@&stack + push _OglTlsIndex + call _TlsGetValue@4 + mov eax, [eax] + jmp dword ptr [eax+4*VAL(offset)] +.ENDP +ENDM + +USE_GL_FUNC Accum, 213, 8 +USE_GL_FUNC AlphaFunc, 240, 8 +USE_GL_FUNC AreTexturesResident, 322, 12 +USE_GL_FUNC ArrayElement, 306, 4 +USE_GL_FUNC Begin, 7, 4 +USE_GL_FUNC BindTexture, 307, 8 +USE_GL_FUNC Bitmap, 8, 28 +USE_GL_FUNC BlendFunc, 241, 8 +USE_GL_FUNC CallList, 2, 4 +USE_GL_FUNC CallLists, 3, 12 +USE_GL_FUNC Clear, 203, 4 +USE_GL_FUNC ClearAccum, 204, 16 +USE_GL_FUNC ClearColor, 206, 16 +USE_GL_FUNC ClearDepth, 208, 8 +USE_GL_FUNC ClearIndex, 205, 4 +USE_GL_FUNC ClearStencil, 207, 4 +USE_GL_FUNC ClipPlane, 150, 8 +USE_GL_FUNC Color3b, 9, 12 +USE_GL_FUNC Color3bv, 10, 4 +USE_GL_FUNC Color3d, 11, 24 +USE_GL_FUNC Color3dv, 12, 4 +USE_GL_FUNC Color3f, 13, 12 +USE_GL_FUNC Color3fv, 14, 4 +USE_GL_FUNC Color3i, 15, 12 +USE_GL_FUNC Color3iv, 16, 4 +USE_GL_FUNC Color3s, 17, 12 +USE_GL_FUNC Color3sv, 18, 4 +USE_GL_FUNC Color3ub, 19, 12 +USE_GL_FUNC Color3ubv, 20, 4 +USE_GL_FUNC Color3ui, 21, 12 +USE_GL_FUNC Color3uiv, 22, 4 +USE_GL_FUNC Color3us, 23, 12 +USE_GL_FUNC Color3usv, 24, 4 +USE_GL_FUNC Color4b, 25, 16 +USE_GL_FUNC Color4bv, 26, 4 +USE_GL_FUNC Color4d, 27, 32 +USE_GL_FUNC Color4dv, 28, 4 +USE_GL_FUNC Color4f, 29, 16 +USE_GL_FUNC Color4fv, 30, 4 +USE_GL_FUNC Color4i, 31, 16 +USE_GL_FUNC Color4iv, 32, 4 +USE_GL_FUNC Color4s, 33, 16 +USE_GL_FUNC Color4sv, 34, 4 +USE_GL_FUNC Color4ub, 35, 16 +USE_GL_FUNC Color4ubv, 36, 4 +USE_GL_FUNC Color4ui, 37, 16 +USE_GL_FUNC Color4uiv, 38, 4 +USE_GL_FUNC Color4us, 39, 16 +USE_GL_FUNC Color4usv, 40, 4 +USE_GL_FUNC ColorMask, 210, 16 +USE_GL_FUNC ColorMaterial, 151, 8 +USE_GL_FUNC ColorPointer, 308, 16 +USE_GL_FUNC CopyPixels, 255, 20 +USE_GL_FUNC CopyTexImage1D, 323, 28 +USE_GL_FUNC CopyTexImage2D, 324, 32 +USE_GL_FUNC CopyTexSubImage1D, 325, 24 +USE_GL_FUNC CopyTexSubImage2D, 326, 32 +USE_GL_FUNC CullFace, 152, 4 +USE_GL_FUNC DeleteLists, 4, 8 +USE_GL_FUNC DeleteTextures, 327, 8 +USE_GL_FUNC DepthFunc, 245, 4 +USE_GL_FUNC DepthMask, 211, 4 +USE_GL_FUNC DepthRange, 288, 16 +USE_GL_FUNC Disable, 214, 4 +USE_GL_FUNC DisableClientState, 309, 4 +USE_GL_FUNC DrawArrays, 310, 12 +USE_GL_FUNC DrawBuffer, 202, 4 +USE_GL_FUNC DrawElements, 311, 16 +USE_GL_FUNC DrawPixels, 257, 20 +USE_GL_FUNC EdgeFlag, 41, 4 +USE_GL_FUNC EdgeFlagPointer, 312, 8 +USE_GL_FUNC EdgeFlagv, 42, 4 +USE_GL_FUNC Enable, 215, 4 +USE_GL_FUNC EnableClientState, 313, 4 +USE_GL_FUNC End, 43, 0 +USE_GL_FUNC EndList, 1, 0 +USE_GL_FUNC EvalCoord1d, 228, 8 +USE_GL_FUNC EvalCoord1dv, 229, 4 +USE_GL_FUNC EvalCoord1f, 230, 4 +USE_GL_FUNC EvalCoord1fv, 231, 4 +USE_GL_FUNC EvalCoord2d, 232, 16 +USE_GL_FUNC EvalCoord2dv, 233, 4 +USE_GL_FUNC EvalCoord2f, 234, 8 +USE_GL_FUNC EvalCoord2fv, 235, 4 +USE_GL_FUNC EvalMesh1, 236, 12 +USE_GL_FUNC EvalMesh2, 238, 20 +USE_GL_FUNC EvalPoint1, 237, 4 +USE_GL_FUNC EvalPoint2, 239, 8 +USE_GL_FUNC FeedbackBuffer, 194, 12 +USE_GL_FUNC Finish, 216, 0 +USE_GL_FUNC Flush, 217, 0 +USE_GL_FUNC Fogf, 153, 8 +USE_GL_FUNC Fogfv, 154, 8 +USE_GL_FUNC Fogi, 155, 8 +USE_GL_FUNC Fogiv, 156, 8 +USE_GL_FUNC FrontFace, 157, 4 +USE_GL_FUNC Frustum, 289, 48 +USE_GL_FUNC GenLists, 5, 4 +USE_GL_FUNC GenTextures, 328, 8 +USE_GL_FUNC GetBooleanv, 258, 8 +USE_GL_FUNC GetClipPlane, 259, 8 +USE_GL_FUNC GetDoublev, 260, 8 +USE_GL_FUNC GetError, 261, 0 +USE_GL_FUNC GetFloatv, 262, 8 +USE_GL_FUNC GetIntegerv, 263, 8 +USE_GL_FUNC GetLightfv, 264, 12 +USE_GL_FUNC GetLightiv, 265, 12 +USE_GL_FUNC GetMapdv, 266, 12 +USE_GL_FUNC GetMapfv, 267, 12 +USE_GL_FUNC GetMapiv, 268, 12 +USE_GL_FUNC GetMaterialfv, 269, 12 +USE_GL_FUNC GetMaterialiv, 270, 12 +USE_GL_FUNC GetPixelMapfv, 271, 8 +USE_GL_FUNC GetPixelMapuiv, 272, 8 +USE_GL_FUNC GetPixelMapusv, 273, 8 +USE_GL_FUNC GetPointerv, 329, 8 +USE_GL_FUNC GetPolygonStipple, 274, 4 +USE_GL_FUNC GetString, 275, 4 +USE_GL_FUNC GetTexEnvfv, 276, 12 +USE_GL_FUNC GetTexEnviv, 277, 12 +USE_GL_FUNC GetTexGendv, 278, 12 +USE_GL_FUNC GetTexGenfv, 279, 12 +USE_GL_FUNC GetTexGeniv, 280, 12 +USE_GL_FUNC GetTexImage, 281, 20 +USE_GL_FUNC GetTexLevelParameterfv, 284, 16 +USE_GL_FUNC GetTexLevelParameteriv, 285, 16 +USE_GL_FUNC GetTexParameterfv, 282, 12 +USE_GL_FUNC GetTexParameteriv, 283, 12 +USE_GL_FUNC Hint, 158, 8 +USE_GL_FUNC IndexMask, 212, 4 +USE_GL_FUNC IndexPointer, 314, 12 +USE_GL_FUNC Indexd, 44, 8 +USE_GL_FUNC Indexdv, 45, 4 +USE_GL_FUNC Indexf, 46, 4 +USE_GL_FUNC Indexfv, 47, 4 +USE_GL_FUNC Indexi, 48, 4 +USE_GL_FUNC Indexiv, 49, 4 +USE_GL_FUNC Indexs, 50, 4 +USE_GL_FUNC Indexsv, 51, 4 +USE_GL_FUNC Indexub, 315, 4 +USE_GL_FUNC Indexubv, 316, 4 +USE_GL_FUNC InitNames, 197, 0 +USE_GL_FUNC InterleavedArrays, 317, 12 +USE_GL_FUNC IsEnabled, 286, 4 +USE_GL_FUNC IsList, 287, 4 +USE_GL_FUNC IsTexture, 330, 4 +USE_GL_FUNC LightModelf, 163, 8 +USE_GL_FUNC LightModelfv, 164, 8 +USE_GL_FUNC LightModeli, 165, 8 +USE_GL_FUNC LightModeliv, 166, 8 +USE_GL_FUNC Lightf, 159, 12 +USE_GL_FUNC Lightfv, 160, 12 +USE_GL_FUNC Lighti, 161, 12 +USE_GL_FUNC Lightiv, 162, 12 +USE_GL_FUNC LineStipple, 167, 8 +USE_GL_FUNC LineWidth, 168, 4 +USE_GL_FUNC ListBase, 6, 4 +USE_GL_FUNC LoadIdentity, 290, 0 +USE_GL_FUNC LoadMatrixd, 292, 4 +USE_GL_FUNC LoadMatrixf, 291, 4 +USE_GL_FUNC LoadName, 198, 4 +USE_GL_FUNC LogicOp, 242, 4 +USE_GL_FUNC Map1d, 220, 32 +USE_GL_FUNC Map1f, 221, 24 +USE_GL_FUNC Map2d, 222, 56 +USE_GL_FUNC Map2f, 223, 40 +USE_GL_FUNC MapGrid1d, 224, 20 +USE_GL_FUNC MapGrid1f, 225, 12 +USE_GL_FUNC MapGrid2d, 226, 40 +USE_GL_FUNC MapGrid2f, 227, 24 +USE_GL_FUNC Materialf, 169, 12 +USE_GL_FUNC Materialfv, 170, 12 +USE_GL_FUNC Materiali, 171, 12 +USE_GL_FUNC Materialiv, 172, 12 +USE_GL_FUNC MatrixMode, 293, 4 +USE_GL_FUNC MultMatrixd, 295, 4 +USE_GL_FUNC MultMatrixf, 294, 4 +USE_GL_FUNC NewList, 0, 8 +USE_GL_FUNC Normal3b, 52, 12 +USE_GL_FUNC Normal3bv, 53, 4 +USE_GL_FUNC Normal3d, 54, 24 +USE_GL_FUNC Normal3dv, 55, 4 +USE_GL_FUNC Normal3f, 56, 12 +USE_GL_FUNC Normal3fv, 57, 4 +USE_GL_FUNC Normal3i, 58, 12 +USE_GL_FUNC Normal3iv, 59, 4 +USE_GL_FUNC Normal3s, 60, 12 +USE_GL_FUNC Normal3sv, 61, 4 +USE_GL_FUNC NormalPointer, 318, 12 +USE_GL_FUNC Ortho, 296, 48 +USE_GL_FUNC PassThrough, 199, 4 +USE_GL_FUNC PixelMapfv, 251, 12 +USE_GL_FUNC PixelMapuiv, 252, 12 +USE_GL_FUNC PixelMapusv, 253, 12 +USE_GL_FUNC PixelStoref, 249, 8 +USE_GL_FUNC PixelStorei, 250, 8 +USE_GL_FUNC PixelTransferf, 247, 8 +USE_GL_FUNC PixelTransferi, 248, 8 +USE_GL_FUNC PixelZoom, 246, 8 +USE_GL_FUNC PointSize, 173, 4 +USE_GL_FUNC PolygonMode, 174, 8 +USE_GL_FUNC PolygonOffset, 319, 8 +USE_GL_FUNC PolygonStipple, 175, 4 +USE_GL_FUNC PopAttrib, 218, 0 +USE_GL_FUNC PopClientAttrib, 334, 0 +USE_GL_FUNC PopMatrix, 297, 0 +USE_GL_FUNC PopName, 200, 0 +USE_GL_FUNC PrioritizeTextures, 331, 12 +USE_GL_FUNC PushAttrib, 219, 4 +USE_GL_FUNC PushClientAttrib, 335, 4 +USE_GL_FUNC PushMatrix, 298, 0 +USE_GL_FUNC PushName, 201, 4 +USE_GL_FUNC RasterPos2d, 62, 16 +USE_GL_FUNC RasterPos2dv, 63, 4 +USE_GL_FUNC RasterPos2f, 64, 8 +USE_GL_FUNC RasterPos2fv, 65, 4 +USE_GL_FUNC RasterPos2i, 66, 8 +USE_GL_FUNC RasterPos2iv, 67, 4 +USE_GL_FUNC RasterPos2s, 68, 8 +USE_GL_FUNC RasterPos2sv, 69, 4 +USE_GL_FUNC RasterPos3d, 70, 24 +USE_GL_FUNC RasterPos3dv, 71, 4 +USE_GL_FUNC RasterPos3f, 72, 12 +USE_GL_FUNC RasterPos3fv, 73, 4 +USE_GL_FUNC RasterPos3i, 74, 12 +USE_GL_FUNC RasterPos3iv, 75, 4 +USE_GL_FUNC RasterPos3s, 76, 12 +USE_GL_FUNC RasterPos3sv, 77, 4 +USE_GL_FUNC RasterPos4d, 78, 32 +USE_GL_FUNC RasterPos4dv, 79, 4 +USE_GL_FUNC RasterPos4f, 80, 16 +USE_GL_FUNC RasterPos4fv, 81, 4 +USE_GL_FUNC RasterPos4i, 82, 16 +USE_GL_FUNC RasterPos4iv, 83, 4 +USE_GL_FUNC RasterPos4s, 84, 16 +USE_GL_FUNC RasterPos4sv, 85, 4 +USE_GL_FUNC ReadBuffer, 254, 4 +USE_GL_FUNC ReadPixels, 256, 28 +USE_GL_FUNC Rectd, 86, 32 +USE_GL_FUNC Rectdv, 87, 8 +USE_GL_FUNC Rectf, 88, 16 +USE_GL_FUNC Rectfv, 89, 8 +USE_GL_FUNC Recti, 90, 16 +USE_GL_FUNC Rectiv, 91, 8 +USE_GL_FUNC Rects, 92, 16 +USE_GL_FUNC Rectsv, 93, 8 +USE_GL_FUNC RenderMode, 196, 4 +USE_GL_FUNC Rotated, 299, 32 +USE_GL_FUNC Rotatef, 300, 16 +USE_GL_FUNC Scaled, 301, 24 +USE_GL_FUNC Scalef, 302, 12 +USE_GL_FUNC Scissor, 176, 16 +USE_GL_FUNC SelectBuffer, 195, 8 +USE_GL_FUNC ShadeModel, 177, 4 +USE_GL_FUNC StencilFunc, 243, 12 +USE_GL_FUNC StencilMask, 209, 4 +USE_GL_FUNC StencilOp, 244, 12 +USE_GL_FUNC TexCoord1d, 94, 8 +USE_GL_FUNC TexCoord1dv, 95, 4 +USE_GL_FUNC TexCoord1f, 96, 4 +USE_GL_FUNC TexCoord1fv, 97, 4 +USE_GL_FUNC TexCoord1i, 98, 4 +USE_GL_FUNC TexCoord1iv, 99, 4 +USE_GL_FUNC TexCoord1s, 100, 4 +USE_GL_FUNC TexCoord1sv, 101, 4 +USE_GL_FUNC TexCoord2d, 102, 16 +USE_GL_FUNC TexCoord2dv, 103, 4 +USE_GL_FUNC TexCoord2f, 104, 8 +USE_GL_FUNC TexCoord2fv, 105, 4 +USE_GL_FUNC TexCoord2i, 106, 8 +USE_GL_FUNC TexCoord2iv, 107, 4 +USE_GL_FUNC TexCoord2s, 108, 8 +USE_GL_FUNC TexCoord2sv, 109, 4 +USE_GL_FUNC TexCoord3d, 110, 24 +USE_GL_FUNC TexCoord3dv, 111, 4 +USE_GL_FUNC TexCoord3f, 112, 12 +USE_GL_FUNC TexCoord3fv, 113, 4 +USE_GL_FUNC TexCoord3i, 114, 12 +USE_GL_FUNC TexCoord3iv, 115, 4 +USE_GL_FUNC TexCoord3s, 116, 12 +USE_GL_FUNC TexCoord3sv, 117, 4 +USE_GL_FUNC TexCoord4d, 118, 32 +USE_GL_FUNC TexCoord4dv, 119, 4 +USE_GL_FUNC TexCoord4f, 120, 16 +USE_GL_FUNC TexCoord4fv, 121, 4 +USE_GL_FUNC TexCoord4i, 122, 16 +USE_GL_FUNC TexCoord4iv, 123, 4 +USE_GL_FUNC TexCoord4s, 124, 16 +USE_GL_FUNC TexCoord4sv, 125, 4 +USE_GL_FUNC TexCoordPointer, 320, 16 +USE_GL_FUNC TexEnvf, 184, 12 +USE_GL_FUNC TexEnvfv, 185, 12 +USE_GL_FUNC TexEnvi, 186, 12 +USE_GL_FUNC TexEnviv, 187, 12 +USE_GL_FUNC TexGend, 188, 16 +USE_GL_FUNC TexGendv, 189, 12 +USE_GL_FUNC TexGenf, 190, 12 +USE_GL_FUNC TexGenfv, 191, 12 +USE_GL_FUNC TexGeni, 192, 12 +USE_GL_FUNC TexGeniv, 193, 12 +USE_GL_FUNC TexImage1D, 182, 32 +USE_GL_FUNC TexImage2D, 183, 36 +USE_GL_FUNC TexParameterf, 178, 12 +USE_GL_FUNC TexParameterfv, 179, 12 +USE_GL_FUNC TexParameteri, 180, 12 +USE_GL_FUNC TexParameteriv, 181, 12 +USE_GL_FUNC TexSubImage1D, 332, 28 +USE_GL_FUNC TexSubImage2D, 333, 36 +USE_GL_FUNC Translated, 303, 24 +USE_GL_FUNC Translatef, 304, 12 +USE_GL_FUNC Vertex2d, 126, 16 +USE_GL_FUNC Vertex2dv, 127, 4 +USE_GL_FUNC Vertex2f, 128, 8 +USE_GL_FUNC Vertex2fv, 129, 4 +USE_GL_FUNC Vertex2i, 130, 8 +USE_GL_FUNC Vertex2iv, 131, 4 +USE_GL_FUNC Vertex2s, 132, 8 +USE_GL_FUNC Vertex2sv, 133, 4 +USE_GL_FUNC Vertex3d, 134, 24 +USE_GL_FUNC Vertex3dv, 135, 4 +USE_GL_FUNC Vertex3f, 136, 12 +USE_GL_FUNC Vertex3fv, 137, 4 +USE_GL_FUNC Vertex3i, 138, 12 +USE_GL_FUNC Vertex3iv, 139, 4 +USE_GL_FUNC Vertex3s, 140, 12 +USE_GL_FUNC Vertex3sv, 141, 4 +USE_GL_FUNC Vertex4d, 142, 32 +USE_GL_FUNC Vertex4dv, 143, 4 +USE_GL_FUNC Vertex4f, 144, 16 +USE_GL_FUNC Vertex4fv, 145, 4 +USE_GL_FUNC Vertex4i, 146, 16 +USE_GL_FUNC Vertex4iv, 147, 4 +USE_GL_FUNC Vertex4s, 148, 16 +USE_GL_FUNC Vertex4sv, 149, 4 +USE_GL_FUNC VertexPointer, 321, 16 +USE_GL_FUNC Viewport, 305, 16 + +END \ No newline at end of file diff --git a/reactos/dll/opengl/opengl32/glfuncs.h b/reactos/dll/opengl/opengl32/glfuncs.h index a843c972a83..437cd2a4c0f 100644 --- a/reactos/dll/opengl/opengl32/glfuncs.h +++ b/reactos/dll/opengl/opengl32/glfuncs.h @@ -1,357 +1,349 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS kernel - * FILE: lib/opengl32/glfuncs.h - * PURPOSE: OpenGL32 lib, GLFUNCS_MACRO - * PROGRAMMER: gen_glfuncs_macro.sh - * UPDATE HISTORY: - * !!! AUTOMATICALLY CREATED FROM glfuncs.csv !!! +/* + * List of all GL functions exported by opengl32.dll. + * Usage: USE_GL_FUNC(name, return type, prototype arguments, call arguments, icd offset, x86 stack size) */ -/* To use this macro define a macro X(name, ret, typeargs, args, icdidx, tebidx, stack). - * It gets called for every glXXX function. i.e. glVertex3f: name = "glVertex3f", - * ret = "void", typeargs = "(GLfloat x, GLfloat y, GLfloat z)", args = "(x,y,z)", - * icdidx = "136", tebidx = "98" and stack = "12". - * Don't forget to undefine X ;-) - */ +#ifndef USE_GL_FUNC_RET +#define USE_GL_FUNC_RET(name, ret_type, proto_args, call_args, offset, stack) \ + USE_GL_FUNC(name, proto_args, call_args, offset, stack) +#endif -#define GLFUNCS_MACRO \ - X(glAccum, void, (GLenum op, GLfloat value), (op,value), 213, -1, 8) \ - X(glAlphaFunc, void, (GLenum func, GLclampf ref), (func,ref), 240, -1, 8) \ - X(glAreTexturesResident, GLboolean, (GLsizei n, const GLuint *textures, GLboolean *residences), (n,textures,residences), 322, -1, 12) \ - X(glArrayElement, void, (GLint i), (i), 306, 144, 4) \ - X(glBegin, void, (GLenum mode), (mode), 7, 2, 4) \ - X(glBindTexture, void, (GLenum target, GLuint texture), (target,texture), 307, 145, 8) \ - X(glBitmap, void, (GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap), (width,height,xorig,yorig,xmove,ymove,bitmap), 8, -1, 28) \ - X(glBlendFunc, void, (GLenum sfactor, GLenum dfactor), (sfactor,dfactor), 241, -1, 8) \ - X(glCallList, void, (GLuint list), (list), 2, 0, 4) \ - X(glCallLists, void, (GLsizei n, GLenum type, const GLvoid *lists), (n,type,lists), 3, 1, 12) \ - X(glClear, void, (GLbitfield mask), (mask), 203, -1, 4) \ - X(glClearAccum, void, (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha), (red,green,blue,alpha), 204, -1, 16) \ - X(glClearColor, void, (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha), (red,green,blue,alpha), 206, -1, 16) \ - X(glClearDepth, void, (GLclampd depth), (depth), 208, -1, 8) \ - X(glClearIndex, void, (GLfloat c), (c), 205, -1, 4) \ - X(glClearStencil, void, (GLint s), (s), 207, -1, 4) \ - X(glClipPlane, void, (GLenum plane, const GLdouble *equation), (plane,equation), 150, -1, 8) \ - X(glColor3b, void, (GLbyte red, GLbyte green, GLbyte blue), (red,green,blue), 9, 3, 12) \ - X(glColor3bv, void, (const GLbyte *v), (v), 10, 4, 4) \ - X(glColor3d, void, (GLdouble red, GLdouble green, GLdouble blue), (red,green,blue), 11, 5, 24) \ - X(glColor3dv, void, (const GLdouble *v), (v), 12, 6, 4) \ - X(glColor3f, void, (GLfloat red, GLfloat green, GLfloat blue), (red,green,blue), 13, 7, 12) \ - X(glColor3fv, void, (const GLfloat *v), (v), 14, 8, 4) \ - X(glColor3i, void, (GLint red, GLint green, GLint blue), (red,green,blue), 15, 9, 12) \ - X(glColor3iv, void, (const GLint *v), (v), 16, 10, 4) \ - X(glColor3s, void, (GLshort red, GLshort green, GLshort blue), (red,green,blue), 17, 11, 12) \ - X(glColor3sv, void, (const GLshort *v), (v), 18, 12, 4) \ - X(glColor3ub, void, (GLubyte red, GLubyte green, GLubyte blue), (red,green,blue), 19, 13, 12) \ - X(glColor3ubv, void, (const GLubyte *v), (v), 20, 14, 4) \ - X(glColor3ui, void, (GLuint red, GLuint green, GLuint blue), (red,green,blue), 21, 15, 12) \ - X(glColor3uiv, void, (const GLuint *v), (v), 22, 16, 4) \ - X(glColor3us, void, (GLushort red, GLushort green, GLushort blue), (red,green,blue), 23, 17, 12) \ - X(glColor3usv, void, (const GLushort *v), (v), 24, 18, 4) \ - X(glColor4b, void, (GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha), (red,green,blue,alpha), 25, 19, 16) \ - X(glColor4bv, void, (const GLbyte *v), (v), 26, 20, 4) \ - X(glColor4d, void, (GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha), (red,green,blue,alpha), 27, 21, 32) \ - X(glColor4dv, void, (const GLdouble *v), (v), 28, 22, 4) \ - X(glColor4f, void, (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha), (red,green,blue,alpha), 29, 23, 16) \ - X(glColor4fv, void, (const GLfloat *v), (v), 30, 24, 4) \ - X(glColor4i, void, (GLint red, GLint green, GLint blue, GLint alpha), (red,green,blue,alpha), 31, 25, 16) \ - X(glColor4iv, void, (const GLint *v), (v), 32, 26, 4) \ - X(glColor4s, void, (GLshort red, GLshort green, GLshort blue, GLshort alpha), (red,green,blue,alpha), 33, 27, 16) \ - X(glColor4sv, void, (const GLshort *v), (v), 34, 28, 4) \ - X(glColor4ub, void, (GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha), (red,green,blue,alpha), 35, 29, 16) \ - X(glColor4ubv, void, (const GLubyte *v), (v), 36, 30, 4) \ - X(glColor4ui, void, (GLuint red, GLuint green, GLuint blue, GLuint alpha), (red,green,blue,alpha), 37, 31, 16) \ - X(glColor4uiv, void, (const GLuint *v), (v), 38, 32, 4) \ - X(glColor4us, void, (GLushort red, GLushort green, GLushort blue, GLushort alpha), (red,green,blue,alpha), 39, 33, 16) \ - X(glColor4usv, void, (const GLushort *v), (v), 40, 34, 4) \ - X(glColorMask, void, (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha), (red,green,blue,alpha), 210, -1, 16) \ - X(glColorMaterial, void, (GLenum face, GLenum mode), (face,mode), 151, -1, 8) \ - X(glColorPointer, void, (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer), (size,type,stride,pointer), 308, 146, 16) \ - X(glCopyPixels, void, (GLint x, GLint y, GLsizei width, GLsizei height, GLenum type), (x,y,width,height,type), 255, -1, 20) \ - X(glCopyTexImage1D, void, (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border), (target,level,internalformat,x,y,width,border), 323, -1, 28) \ - X(glCopyTexImage2D, void, (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border), (target,level,internalformat,x,y,width,height,border), 324, -1, 32) \ - X(glCopyTexSubImage1D, void, (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width), (target,level,xoffset,x,y,width), 325, -1, 24) \ - X(glCopyTexSubImage2D, void, (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height), (target,level,xoffset,yoffset,x,y,width,height), 326, -1, 32) \ - X(glCullFace, void, (GLenum mode), (mode), 152, -1, 4) \ - X(glDeleteLists, void, (GLuint list, GLsizei range), (list,range), 4, -1, 8) \ - X(glDeleteTextures, void, (GLsizei n, const GLuint *textures), (n,textures), 327, -1, 8) \ - X(glDepthFunc, void, (GLenum func), (func), 245, -1, 4) \ - X(glDepthMask, void, (GLboolean flag), (flag), 211, -1, 4) \ - X(glDepthRange, void, (GLclampd zNear, GLclampd zFar), (zNear,zFar), 288, -1, 16) \ - X(glDisable, void, (GLenum cap), (cap), 214, 116, 4) \ - X(glDisableClientState, void, (GLenum array), (array), 309, 147, 4) \ - X(glDrawArrays, void, (GLenum mode, GLint first, GLsizei count), (mode,first,count), 310, 148, 12) \ - X(glDrawBuffer, void, (GLenum mode), (mode), 202, -1, 4) \ - X(glDrawElements, void, (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices), (mode,count,type,indices), 311, 149, 16) \ - X(glDrawPixels, void, (GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels), (width,height,format,type,pixels), 257, -1, 20) \ - X(glEdgeFlag, void, (GLboolean flag), (flag), 41, 35, 4) \ - X(glEdgeFlagPointer, void, (GLsizei stride, const GLvoid *pointer), (stride,pointer), 312, 150, 8) \ - X(glEdgeFlagv, void, (const GLboolean *flag), (flag), 42, 36, 4) \ - X(glEnable, void, (GLenum cap), (cap), 215, 117, 4) \ - X(glEnableClientState, void, (GLenum array), (array), 313, 151, 4) \ - X(glEnd, void, (void), (), 43, 37, 0) \ - X(glEndList, void, (void), (), 1, -1, 0) \ - X(glEvalCoord1d, void, (GLdouble u), (u), 228, 120, 8) \ - X(glEvalCoord1dv, void, (const GLdouble *u), (u), 229, 121, 4) \ - X(glEvalCoord1f, void, (GLfloat u), (u), 230, 122, 4) \ - X(glEvalCoord1fv, void, (const GLfloat *u), (u), 231, 123, 4) \ - X(glEvalCoord2d, void, (GLdouble u, GLdouble v), (u,v), 232, 124, 16) \ - X(glEvalCoord2dv, void, (const GLdouble *u), (u), 233, 125, 4) \ - X(glEvalCoord2f, void, (GLfloat u, GLfloat v), (u,v), 234, 126, 8) \ - X(glEvalCoord2fv, void, (const GLfloat *u), (u), 235, 127, 4) \ - X(glEvalMesh1, void, (GLenum mode, GLint i1, GLint i2), (mode,i1,i2), 236, -1, 12) \ - X(glEvalMesh2, void, (GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2), (mode,i1,i2,j1,j2), 238, -1, 20) \ - X(glEvalPoint1, void, (GLint i), (i), 237, 128, 4) \ - X(glEvalPoint2, void, (GLint i, GLint j), (i,j), 239, 129, 8) \ - X(glFeedbackBuffer, void, (GLsizei size, GLenum type, GLfloat *buffer), (size,type,buffer), 194, -1, 12) \ - X(glFinish, void, (void), (), 216, -1, 0) \ - X(glFlush, void, (void), (), 217, -1, 0) \ - X(glFogf, void, (GLenum pname, GLfloat param), (pname,param), 153, -1, 8) \ - X(glFogfv, void, (GLenum pname, const GLfloat *params), (pname,params), 154, -1, 8) \ - X(glFogi, void, (GLenum pname, GLint param), (pname,param), 155, -1, 8) \ - X(glFogiv, void, (GLenum pname, const GLint *params), (pname,params), 156, -1, 8) \ - X(glFrontFace, void, (GLenum mode), (mode), 157, -1, 4) \ - X(glFrustum, void, (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar), (left,right,bottom,top,zNear,zFar), 289, -1, 48) \ - X(glGenLists, GLuint, (GLsizei range), (range), 5, -1, 4) \ - X(glGenTextures, void, (GLsizei n, GLuint *textures), (n,textures), 328, -1, 8) \ - X(glGetBooleanv, void, (GLenum pname, GLboolean *params), (pname,params), 258, -1, 8) \ - X(glGetClipPlane, void, (GLenum plane, GLdouble *equation), (plane,equation), 259, -1, 8) \ - X(glGetDoublev, void, (GLenum pname, GLdouble *params), (pname,params), 260, -1, 8) \ - X(glGetError, GLenum, (void), (), 261, -1, 0) \ - X(glGetFloatv, void, (GLenum pname, GLfloat *params), (pname,params), 262, -1, 8) \ - X(glGetIntegerv, void, (GLenum pname, GLint *params), (pname,params), 263, -1, 8) \ - X(glGetLightfv, void, (GLenum light, GLenum pname, GLfloat *params), (light,pname,params), 264, -1, 12) \ - X(glGetLightiv, void, (GLenum light, GLenum pname, GLint *params), (light,pname,params), 265, -1, 12) \ - X(glGetMapdv, void, (GLenum target, GLenum query, GLdouble *v), (target,query,v), 266, -1, 12) \ - X(glGetMapfv, void, (GLenum target, GLenum query, GLfloat *v), (target,query,v), 267, -1, 12) \ - X(glGetMapiv, void, (GLenum target, GLenum query, GLint *v), (target,query,v), 268, -1, 12) \ - X(glGetMaterialfv, void, (GLenum face, GLenum pname, GLfloat *params), (face,pname,params), 269, -1, 12) \ - X(glGetMaterialiv, void, (GLenum face, GLenum pname, GLint *params), (face,pname,params), 270, -1, 12) \ - X(glGetPixelMapfv, void, (GLenum map, GLfloat *values), (map,values), 271, -1, 8) \ - X(glGetPixelMapuiv, void, (GLenum map, GLuint *values), (map,values), 272, -1, 8) \ - X(glGetPixelMapusv, void, (GLenum map, GLushort *values), (map,values), 273, -1, 8) \ - X(glGetPointerv, void, (GLenum pname, GLvoid* *params), (pname,params), 329, 160, 8) \ - X(glGetPolygonStipple, void, (GLubyte *mask), (mask), 274, -1, 4) \ - X(glGetString, const GLubyte *, (GLenum name), (name), 275, -1, 4) \ - X(glGetTexEnvfv, void, (GLenum target, GLenum pname, GLfloat *params), (target,pname,params), 276, -1, 12) \ - X(glGetTexEnviv, void, (GLenum target, GLenum pname, GLint *params), (target,pname,params), 277, -1, 12) \ - X(glGetTexGendv, void, (GLenum coord, GLenum pname, GLdouble *params), (coord,pname,params), 278, -1, 12) \ - X(glGetTexGenfv, void, (GLenum coord, GLenum pname, GLfloat *params), (coord,pname,params), 279, -1, 12) \ - X(glGetTexGeniv, void, (GLenum coord, GLenum pname, GLint *params), (coord,pname,params), 280, -1, 12) \ - X(glGetTexImage, void, (GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels), (target,level,format,type,pixels), 281, -1, 20) \ - X(glGetTexLevelParameterfv, void, (GLenum target, GLint level, GLenum pname, GLfloat *params), (target,level,pname,params), 284, -1, 16) \ - X(glGetTexLevelParameteriv, void, (GLenum target, GLint level, GLenum pname, GLint *params), (target,level,pname,params), 285, -1, 16) \ - X(glGetTexParameterfv, void, (GLenum target, GLenum pname, GLfloat *params), (target,pname,params), 282, -1, 12) \ - X(glGetTexParameteriv, void, (GLenum target, GLenum pname, GLint *params), (target,pname,params), 283, -1, 12) \ - X(glHint, void, (GLenum target, GLenum mode), (target,mode), 158, -1, 8) \ - X(glIndexMask, void, (GLuint mask), (mask), 212, -1, 4) \ - X(glIndexPointer, void, (GLenum type, GLsizei stride, const GLvoid *pointer), (type,stride,pointer), 314, 152, 12) \ - X(glIndexd, void, (GLdouble c), (c), 44, 38, 8) \ - X(glIndexdv, void, (const GLdouble *c), (c), 45, 39, 4) \ - X(glIndexf, void, (GLfloat c), (c), 46, 40, 4) \ - X(glIndexfv, void, (const GLfloat *c), (c), 47, 41, 4) \ - X(glIndexi, void, (GLint c), (c), 48, 42, 4) \ - X(glIndexiv, void, (const GLint *c), (c), 49, 43, 4) \ - X(glIndexs, void, (GLshort c), (c), 50, 44, 4) \ - X(glIndexsv, void, (const GLshort *c), (c), 51, 45, 4) \ - X(glIndexub, void, (GLubyte c), (c), 315, 153, 4) \ - X(glIndexubv, void, (const GLubyte *c), (c), 316, 154, 4) \ - X(glInitNames, void, (void), (), 197, -1, 0) \ - X(glInterleavedArrays, void, (GLenum format, GLsizei stride, const GLvoid *pointer), (format,stride,pointer), 317, 155, 12) \ - X(glIsEnabled, GLboolean, (GLenum cap), (cap), 286, -1, 4) \ - X(glIsList, GLboolean, (GLuint list), (list), 287, -1, 4) \ - X(glIsTexture, GLboolean, (GLuint texture), (texture), 330, -1, 4) \ - X(glLightModelf, void, (GLenum pname, GLfloat param), (pname,param), 163, -1, 8) \ - X(glLightModelfv, void, (GLenum pname, const GLfloat *params), (pname,params), 164, -1, 8) \ - X(glLightModeli, void, (GLenum pname, GLint param), (pname,param), 165, -1, 8) \ - X(glLightModeliv, void, (GLenum pname, const GLint *params), (pname,params), 166, -1, 8) \ - X(glLightf, void, (GLenum light, GLenum pname, GLfloat param), (light,pname,param), 159, -1, 12) \ - X(glLightfv, void, (GLenum light, GLenum pname, const GLfloat *params), (light,pname,params), 160, -1, 12) \ - X(glLighti, void, (GLenum light, GLenum pname, GLint param), (light,pname,param), 161, -1, 12) \ - X(glLightiv, void, (GLenum light, GLenum pname, const GLint *params), (light,pname,params), 162, -1, 12) \ - X(glLineStipple, void, (GLint factor, GLushort pattern), (factor,pattern), 167, -1, 8) \ - X(glLineWidth, void, (GLfloat width), (width), 168, -1, 4) \ - X(glListBase, void, (GLuint base), (base), 6, -1, 4) \ - X(glLoadIdentity, void, (void), (), 290, 130, 0) \ - X(glLoadMatrixd, void, (const GLdouble *m), (m), 292, 132, 4) \ - X(glLoadMatrixf, void, (const GLfloat *m), (m), 291, 131, 4) \ - X(glLoadName, void, (GLuint name), (name), 198, -1, 4) \ - X(glLogicOp, void, (GLenum opcode), (opcode), 242, -1, 4) \ - X(glMap1d, void, (GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points), (target,u1,u2,stride,order,points), 220, -1, 32) \ - X(glMap1f, void, (GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points), (target,u1,u2,stride,order,points), 221, -1, 24) \ - X(glMap2d, void, (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points), (target,u1,u2,ustride,uorder,v1,v2,vstride,vorder,points), 222, -1, 56) \ - X(glMap2f, void, (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points), (target,u1,u2,ustride,uorder,v1,v2,vstride,vorder,points), 223, -1, 40) \ - X(glMapGrid1d, void, (GLint un, GLdouble u1, GLdouble u2), (un,u1,u2), 224, -1, 20) \ - X(glMapGrid1f, void, (GLint un, GLfloat u1, GLfloat u2), (un,u1,u2), 225, -1, 12) \ - X(glMapGrid2d, void, (GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2), (un,u1,u2,vn,v1,v2), 226, -1, 40) \ - X(glMapGrid2f, void, (GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2), (un,u1,u2,vn,v1,v2), 227, -1, 24) \ - X(glMaterialf, void, (GLenum face, GLenum pname, GLfloat param), (face,pname,param), 169, 112, 12) \ - X(glMaterialfv, void, (GLenum face, GLenum pname, const GLfloat *params), (face,pname,params), 170, 113, 12) \ - X(glMateriali, void, (GLenum face, GLenum pname, GLint param), (face,pname,param), 171, 114, 12) \ - X(glMaterialiv, void, (GLenum face, GLenum pname, const GLint *params), (face,pname,params), 172, 115, 12) \ - X(glMatrixMode, void, (GLenum mode), (mode), 293, 133, 4) \ - X(glMultMatrixd, void, (const GLdouble *m), (m), 295, 135, 4) \ - X(glMultMatrixf, void, (const GLfloat *m), (m), 294, 134, 4) \ - X(glNewList, void, (GLuint list, GLenum mode), (list,mode), 0, -1, 8) \ - X(glNormal3b, void, (GLbyte nx, GLbyte ny, GLbyte nz), (nx,ny,nz), 52, 46, 12) \ - X(glNormal3bv, void, (const GLbyte *v), (v), 53, 47, 4) \ - X(glNormal3d, void, (GLdouble nx, GLdouble ny, GLdouble nz), (nx,ny,nz), 54, 48, 24) \ - X(glNormal3dv, void, (const GLdouble *v), (v), 55, 49, 4) \ - X(glNormal3f, void, (GLfloat nx, GLfloat ny, GLfloat nz), (nx,ny,nz), 56, 50, 12) \ - X(glNormal3fv, void, (const GLfloat *v), (v), 57, 51, 4) \ - X(glNormal3i, void, (GLint nx, GLint ny, GLint nz), (nx,ny,nz), 58, 52, 12) \ - X(glNormal3iv, void, (const GLint *v), (v), 59, 53, 4) \ - X(glNormal3s, void, (GLshort nx, GLshort ny, GLshort nz), (nx,ny,nz), 60, 54, 12) \ - X(glNormal3sv, void, (const GLshort *v), (v), 61, 55, 4) \ - X(glNormalPointer, void, (GLenum type, GLsizei stride, const GLvoid *pointer), (type,stride,pointer), 318, 156, 12) \ - X(glOrtho, void, (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar), (left,right,bottom,top,zNear,zFar), 296, -1, 48) \ - X(glPassThrough, void, (GLfloat token), (token), 199, -1, 4) \ - X(glPixelMapfv, void, (GLenum map, GLint mapsize, const GLfloat *values), (map,mapsize,values), 251, -1, 12) \ - X(glPixelMapuiv, void, (GLenum map, GLint mapsize, const GLuint *values), (map,mapsize,values), 252, -1, 12) \ - X(glPixelMapusv, void, (GLenum map, GLint mapsize, const GLushort *values), (map,mapsize,values), 253, -1, 12) \ - X(glPixelStoref, void, (GLenum pname, GLfloat param), (pname,param), 249, -1, 8) \ - X(glPixelStorei, void, (GLenum pname, GLint param), (pname,param), 250, -1, 8) \ - X(glPixelTransferf, void, (GLenum pname, GLfloat param), (pname,param), 247, -1, 8) \ - X(glPixelTransferi, void, (GLenum pname, GLint param), (pname,param), 248, -1, 8) \ - X(glPixelZoom, void, (GLfloat xfactor, GLfloat yfactor), (xfactor,yfactor), 246, -1, 8) \ - X(glPointSize, void, (GLfloat size), (size), 173, -1, 4) \ - X(glPolygonMode, void, (GLenum face, GLenum mode), (face,mode), 174, -1, 8) \ - X(glPolygonOffset, void, (GLfloat factor, GLfloat units), (factor,units), 319, 157, 8) \ - X(glPolygonStipple, void, (const GLubyte *mask), (mask), 175, -1, 4) \ - X(glPopAttrib, void, (void), (), 218, 118, 0) \ - X(glPopClientAttrib, void, (void), (), 334, 161, 0) \ - X(glPopMatrix, void, (void), (), 297, 136, 0) \ - X(glPopName, void, (void), (), 200, -1, 0) \ - X(glPrioritizeTextures, void, (GLsizei n, const GLuint *textures, const GLclampf *priorities), (n,textures,priorities), 331, -1, 12) \ - X(glPushAttrib, void, (GLbitfield mask), (mask), 219, 119, 4) \ - X(glPushClientAttrib, void, (GLbitfield mask), (mask), 335, 162, 4) \ - X(glPushMatrix, void, (void), (), 298, 137, 0) \ - X(glPushName, void, (GLuint name), (name), 201, -1, 4) \ - X(glRasterPos2d, void, (GLdouble x, GLdouble y), (x,y), 62, -1, 16) \ - X(glRasterPos2dv, void, (const GLdouble *v), (v), 63, -1, 4) \ - X(glRasterPos2f, void, (GLfloat x, GLfloat y), (x,y), 64, -1, 8) \ - X(glRasterPos2fv, void, (const GLfloat *v), (v), 65, -1, 4) \ - X(glRasterPos2i, void, (GLint x, GLint y), (x,y), 66, -1, 8) \ - X(glRasterPos2iv, void, (const GLint *v), (v), 67, -1, 4) \ - X(glRasterPos2s, void, (GLshort x, GLshort y), (x,y), 68, -1, 8) \ - X(glRasterPos2sv, void, (const GLshort *v), (v), 69, -1, 4) \ - X(glRasterPos3d, void, (GLdouble x, GLdouble y, GLdouble z), (x,y,z), 70, -1, 24) \ - X(glRasterPos3dv, void, (const GLdouble *v), (v), 71, -1, 4) \ - X(glRasterPos3f, void, (GLfloat x, GLfloat y, GLfloat z), (x,y,z), 72, -1, 12) \ - X(glRasterPos3fv, void, (const GLfloat *v), (v), 73, -1, 4) \ - X(glRasterPos3i, void, (GLint x, GLint y, GLint z), (x,y,z), 74, -1, 12) \ - X(glRasterPos3iv, void, (const GLint *v), (v), 75, -1, 4) \ - X(glRasterPos3s, void, (GLshort x, GLshort y, GLshort z), (x,y,z), 76, -1, 12) \ - X(glRasterPos3sv, void, (const GLshort *v), (v), 77, -1, 4) \ - X(glRasterPos4d, void, (GLdouble x, GLdouble y, GLdouble z, GLdouble w), (x,y,z,w), 78, -1, 32) \ - X(glRasterPos4dv, void, (const GLdouble *v), (v), 79, -1, 4) \ - X(glRasterPos4f, void, (GLfloat x, GLfloat y, GLfloat z, GLfloat w), (x,y,z,w), 80, -1, 16) \ - X(glRasterPos4fv, void, (const GLfloat *v), (v), 81, -1, 4) \ - X(glRasterPos4i, void, (GLint x, GLint y, GLint z, GLint w), (x,y,z,w), 82, -1, 16) \ - X(glRasterPos4iv, void, (const GLint *v), (v), 83, -1, 4) \ - X(glRasterPos4s, void, (GLshort x, GLshort y, GLshort z, GLshort w), (x,y,z,w), 84, -1, 16) \ - X(glRasterPos4sv, void, (const GLshort *v), (v), 85, -1, 4) \ - X(glReadBuffer, void, (GLenum mode), (mode), 254, -1, 4) \ - X(glReadPixels, void, (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels), (x,y,width,height,format,type,pixels), 256, -1, 28) \ - X(glRectd, void, (GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2), (x1,y1,x2,y2), 86, -1, 32) \ - X(glRectdv, void, (const GLdouble *v1, const GLdouble *v2), (v1,v2), 87, -1, 8) \ - X(glRectf, void, (GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2), (x1,y1,x2,y2), 88, -1, 16) \ - X(glRectfv, void, (const GLfloat *v1, const GLfloat *v2), (v1,v2), 89, -1, 8) \ - X(glRecti, void, (GLint x1, GLint y1, GLint x2, GLint y2), (x1,y1,x2,y2), 90, -1, 16) \ - X(glRectiv, void, (const GLint *v1, const GLint *v2), (v1,v2), 91, -1, 8) \ - X(glRects, void, (GLshort x1, GLshort y1, GLshort x2, GLshort y2), (x1,y1,x2,y2), 92, -1, 16) \ - X(glRectsv, void, (const GLshort *v1, const GLshort *v2), (v1,v2), 93, -1, 8) \ - X(glRenderMode, GLint, (GLenum mode), (mode), 196, -1, 4) \ - X(glRotated, void, (GLdouble angle, GLdouble x, GLdouble y, GLdouble z), (angle,x,y,z), 299, 138, 32) \ - X(glRotatef, void, (GLfloat angle, GLfloat x, GLfloat y, GLfloat z), (angle,x,y,z), 300, 139, 16) \ - X(glScaled, void, (GLdouble x, GLdouble y, GLdouble z), (x,y,z), 301, 140, 24) \ - X(glScalef, void, (GLfloat x, GLfloat y, GLfloat z), (x,y,z), 302, 141, 12) \ - X(glScissor, void, (GLint x, GLint y, GLsizei width, GLsizei height), (x,y,width,height), 176, -1, 16) \ - X(glSelectBuffer, void, (GLsizei size, GLuint *buffer), (size,buffer), 195, -1, 8) \ - X(glShadeModel, void, (GLenum mode), (mode), 177, -1, 4) \ - X(glStencilFunc, void, (GLenum func, GLint ref, GLuint mask), (func,ref,mask), 243, -1, 12) \ - X(glStencilMask, void, (GLuint mask), (mask), 209, -1, 4) \ - X(glStencilOp, void, (GLenum fail, GLenum zfail, GLenum zpass), (fail,zfail,zpass), 244, -1, 12) \ - X(glTexCoord1d, void, (GLdouble s), (s), 94, 56, 8) \ - X(glTexCoord1dv, void, (const GLdouble *v), (v), 95, 57, 4) \ - X(glTexCoord1f, void, (GLfloat s), (s), 96, 58, 4) \ - X(glTexCoord1fv, void, (const GLfloat *v), (v), 97, 59, 4) \ - X(glTexCoord1i, void, (GLint s), (s), 98, 60, 4) \ - X(glTexCoord1iv, void, (const GLint *v), (v), 99, 61, 4) \ - X(glTexCoord1s, void, (GLshort s), (s), 100, 62, 4) \ - X(glTexCoord1sv, void, (const GLshort *v), (v), 101, 63, 4) \ - X(glTexCoord2d, void, (GLdouble s, GLdouble t), (s,t), 102, 64, 16) \ - X(glTexCoord2dv, void, (const GLdouble *v), (v), 103, 65, 4) \ - X(glTexCoord2f, void, (GLfloat s, GLfloat t), (s,t), 104, 66, 8) \ - X(glTexCoord2fv, void, (const GLfloat *v), (v), 105, 67, 4) \ - X(glTexCoord2i, void, (GLint s, GLint t), (s,t), 106, 68, 8) \ - X(glTexCoord2iv, void, (const GLint *v), (v), 107, 69, 4) \ - X(glTexCoord2s, void, (GLshort s, GLshort t), (s,t), 108, 70, 8) \ - X(glTexCoord2sv, void, (const GLshort *v), (v), 109, 71, 4) \ - X(glTexCoord3d, void, (GLdouble s, GLdouble t, GLdouble r), (s,t,r), 110, 72, 24) \ - X(glTexCoord3dv, void, (const GLdouble *v), (v), 111, 73, 4) \ - X(glTexCoord3f, void, (GLfloat s, GLfloat t, GLfloat r), (s,t,r), 112, 74, 12) \ - X(glTexCoord3fv, void, (const GLfloat *v), (v), 113, 75, 4) \ - X(glTexCoord3i, void, (GLint s, GLint t, GLint r), (s,t,r), 114, 76, 12) \ - X(glTexCoord3iv, void, (const GLint *v), (v), 115, 77, 4) \ - X(glTexCoord3s, void, (GLshort s, GLshort t, GLshort r), (s,t,r), 116, 78, 12) \ - X(glTexCoord3sv, void, (const GLshort *v), (v), 117, 79, 4) \ - X(glTexCoord4d, void, (GLdouble s, GLdouble t, GLdouble r, GLdouble q), (s,t,r,q), 118, 80, 32) \ - X(glTexCoord4dv, void, (const GLdouble *v), (v), 119, 81, 4) \ - X(glTexCoord4f, void, (GLfloat s, GLfloat t, GLfloat r, GLfloat q), (s,t,r,q), 120, 82, 16) \ - X(glTexCoord4fv, void, (const GLfloat *v), (v), 121, 83, 4) \ - X(glTexCoord4i, void, (GLint s, GLint t, GLint r, GLint q), (s,t,r,q), 122, 84, 16) \ - X(glTexCoord4iv, void, (const GLint *v), (v), 123, 85, 4) \ - X(glTexCoord4s, void, (GLshort s, GLshort t, GLshort r, GLshort q), (s,t,r,q), 124, 86, 16) \ - X(glTexCoord4sv, void, (const GLshort *v), (v), 125, 87, 4) \ - X(glTexCoordPointer, void, (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer), (size,type,stride,pointer), 320, 158, 16) \ - X(glTexEnvf, void, (GLenum target, GLenum pname, GLfloat param), (target,pname,param), 184, -1, 12) \ - X(glTexEnvfv, void, (GLenum target, GLenum pname, const GLfloat *params), (target,pname,params), 185, -1, 12) \ - X(glTexEnvi, void, (GLenum target, GLenum pname, GLint param), (target,pname,param), 186, -1, 12) \ - X(glTexEnviv, void, (GLenum target, GLenum pname, const GLint *params), (target,pname,params), 187, -1, 12) \ - X(glTexGend, void, (GLenum coord, GLenum pname, GLdouble param), (coord,pname,param), 188, -1, 16) \ - X(glTexGendv, void, (GLenum coord, GLenum pname, const GLdouble *params), (coord,pname,params), 189, -1, 12) \ - X(glTexGenf, void, (GLenum coord, GLenum pname, GLfloat param), (coord,pname,param), 190, -1, 12) \ - X(glTexGenfv, void, (GLenum coord, GLenum pname, const GLfloat *params), (coord,pname,params), 191, -1, 12) \ - X(glTexGeni, void, (GLenum coord, GLenum pname, GLint param), (coord,pname,param), 192, -1, 12) \ - X(glTexGeniv, void, (GLenum coord, GLenum pname, const GLint *params), (coord,pname,params), 193, -1, 12) \ - X(glTexImage1D, void, (GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels), (target,level,internalformat,width,border,format,type,pixels), 182, -1, 32) \ - X(glTexImage2D, void, (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels), (target,level,internalformat,width,height,border,format,type,pixels), 183, -1, 36) \ - X(glTexParameterf, void, (GLenum target, GLenum pname, GLfloat param), (target,pname,param), 178, -1, 12) \ - X(glTexParameterfv, void, (GLenum target, GLenum pname, const GLfloat *params), (target,pname,params), 179, -1, 12) \ - X(glTexParameteri, void, (GLenum target, GLenum pname, GLint param), (target,pname,param), 180, -1, 12) \ - X(glTexParameteriv, void, (GLenum target, GLenum pname, const GLint *params), (target,pname,params), 181, -1, 12) \ - X(glTexSubImage1D, void, (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels), (target,level,xoffset,width,format,type,pixels), 332, -1, 28) \ - X(glTexSubImage2D, void, (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels), (target,level,xoffset,yoffset,width,height,format,type,pixels), 333, -1, 36) \ - X(glTranslated, void, (GLdouble x, GLdouble y, GLdouble z), (x,y,z), 303, 142, 24) \ - X(glTranslatef, void, (GLfloat x, GLfloat y, GLfloat z), (x,y,z), 304, 143, 12) \ - X(glVertex2d, void, (GLdouble x, GLdouble y), (x,y), 126, 88, 16) \ - X(glVertex2dv, void, (const GLdouble *v), (v), 127, 89, 4) \ - X(glVertex2f, void, (GLfloat x, GLfloat y), (x,y), 128, 90, 8) \ - X(glVertex2fv, void, (const GLfloat *v), (v), 129, 91, 4) \ - X(glVertex2i, void, (GLint x, GLint y), (x,y), 130, 92, 8) \ - X(glVertex2iv, void, (const GLint *v), (v), 131, 93, 4) \ - X(glVertex2s, void, (GLshort x, GLshort y), (x,y), 132, 94, 8) \ - X(glVertex2sv, void, (const GLshort *v), (v), 133, 95, 4) \ - X(glVertex3d, void, (GLdouble x, GLdouble y, GLdouble z), (x,y,z), 134, 96, 24) \ - X(glVertex3dv, void, (const GLdouble *v), (v), 135, 97, 4) \ - X(glVertex3f, void, (GLfloat x, GLfloat y, GLfloat z), (x,y,z), 136, 98, 12) \ - X(glVertex3fv, void, (const GLfloat *v), (v), 137, 99, 4) \ - X(glVertex3i, void, (GLint x, GLint y, GLint z), (x,y,z), 138, 100, 12) \ - X(glVertex3iv, void, (const GLint *v), (v), 139, 101, 4) \ - X(glVertex3s, void, (GLshort x, GLshort y, GLshort z), (x,y,z), 140, 102, 12) \ - X(glVertex3sv, void, (const GLshort *v), (v), 141, 103, 4) \ - X(glVertex4d, void, (GLdouble x, GLdouble y, GLdouble z, GLdouble w), (x,y,z,w), 142, 104, 32) \ - X(glVertex4dv, void, (const GLdouble *v), (v), 143, 105, 4) \ - X(glVertex4f, void, (GLfloat x, GLfloat y, GLfloat z, GLfloat w), (x,y,z,w), 144, 106, 16) \ - X(glVertex4fv, void, (const GLfloat *v), (v), 145, 107, 4) \ - X(glVertex4i, void, (GLint x, GLint y, GLint z, GLint w), (x,y,z,w), 146, 108, 16) \ - X(glVertex4iv, void, (const GLint *v), (v), 147, 109, 4) \ - X(glVertex4s, void, (GLshort x, GLshort y, GLshort z, GLshort w), (x,y,z,w), 148, 110, 16) \ - X(glVertex4sv, void, (const GLshort *v), (v), 149, 111, 4) \ - X(glVertexPointer, void, (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer), (size,type,stride,pointer), 321, 159, 16) \ - X(glViewport, void, (GLint x, GLint y, GLsizei width, GLsizei height), (x,y,width,height), 305, -1, 16) \ +USE_GL_FUNC(Accum, (GLenum op, GLfloat value), (op,value), 213, 8) +USE_GL_FUNC(AlphaFunc, (GLenum func, GLclampf ref), (func,ref), 240, 8) +USE_GL_FUNC_RET(AreTexturesResident, GLboolean, (GLsizei n, const GLuint *textures, GLboolean *residences), (n,textures,residences), 322, 12) +USE_GL_FUNC(ArrayElement, (GLint i), (i), 306, 4) +USE_GL_FUNC(Begin, (GLenum mode), (mode), 7, 4) +USE_GL_FUNC(BindTexture, (GLenum target, GLuint texture), (target,texture), 307, 8) +USE_GL_FUNC(Bitmap, (GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap), (width,height,xorig,yorig,xmove,ymove,bitmap), 8, 28) +USE_GL_FUNC(BlendFunc, (GLenum sfactor, GLenum dfactor), (sfactor,dfactor), 241, 8) +USE_GL_FUNC(CallList, (GLuint list), (list), 2, 4) +USE_GL_FUNC(CallLists, (GLsizei n, GLenum type, const GLvoid *lists), (n,type,lists), 3, 12) +USE_GL_FUNC(Clear, (GLbitfield mask), (mask), 203, 4) +USE_GL_FUNC(ClearAccum, (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha), (red,green,blue,alpha), 204, 16) +USE_GL_FUNC(ClearColor, (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha), (red,green,blue,alpha), 206, 16) +USE_GL_FUNC(ClearDepth, (GLclampd depth), (depth), 208, 8) +USE_GL_FUNC(ClearIndex, (GLfloat c), (c), 205, 4) +USE_GL_FUNC(ClearStencil, (GLint s), (s), 207, 4) +USE_GL_FUNC(ClipPlane, (GLenum plane, const GLdouble *equation), (plane,equation), 150, 8) +USE_GL_FUNC(Color3b, (GLbyte red, GLbyte green, GLbyte blue), (red,green,blue), 9, 12) +USE_GL_FUNC(Color3bv, (const GLbyte *v), (v), 10, 4) +USE_GL_FUNC(Color3d, (GLdouble red, GLdouble green, GLdouble blue), (red,green,blue), 11, 24) +USE_GL_FUNC(Color3dv, (const GLdouble *v), (v), 12, 4) +USE_GL_FUNC(Color3f, (GLfloat red, GLfloat green, GLfloat blue), (red,green,blue), 13, 12) +USE_GL_FUNC(Color3fv, (const GLfloat *v), (v), 14, 4) +USE_GL_FUNC(Color3i, (GLint red, GLint green, GLint blue), (red,green,blue), 15, 12) +USE_GL_FUNC(Color3iv, (const GLint *v), (v), 16, 4) +USE_GL_FUNC(Color3s, (GLshort red, GLshort green, GLshort blue), (red,green,blue), 17, 12) +USE_GL_FUNC(Color3sv, (const GLshort *v), (v), 18, 4) +USE_GL_FUNC(Color3ub, (GLubyte red, GLubyte green, GLubyte blue), (red,green,blue), 19, 12) +USE_GL_FUNC(Color3ubv, (const GLubyte *v), (v), 20, 4) +USE_GL_FUNC(Color3ui, (GLuint red, GLuint green, GLuint blue), (red,green,blue), 21, 12) +USE_GL_FUNC(Color3uiv, (const GLuint *v), (v), 22, 4) +USE_GL_FUNC(Color3us, (GLushort red, GLushort green, GLushort blue), (red,green,blue), 23, 12) +USE_GL_FUNC(Color3usv, (const GLushort *v), (v), 24, 4) +USE_GL_FUNC(Color4b, (GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha), (red,green,blue,alpha), 25, 16) +USE_GL_FUNC(Color4bv, (const GLbyte *v), (v), 26, 4) +USE_GL_FUNC(Color4d, (GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha), (red,green,blue,alpha), 27, 32) +USE_GL_FUNC(Color4dv, (const GLdouble *v), (v), 28, 4) +USE_GL_FUNC(Color4f, (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha), (red,green,blue,alpha), 29, 16) +USE_GL_FUNC(Color4fv, (const GLfloat *v), (v), 30, 4) +USE_GL_FUNC(Color4i, (GLint red, GLint green, GLint blue, GLint alpha), (red,green,blue,alpha), 31, 16) +USE_GL_FUNC(Color4iv, (const GLint *v), (v), 32, 4) +USE_GL_FUNC(Color4s, (GLshort red, GLshort green, GLshort blue, GLshort alpha), (red,green,blue,alpha), 33, 16) +USE_GL_FUNC(Color4sv, (const GLshort *v), (v), 34, 4) +USE_GL_FUNC(Color4ub, (GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha), (red,green,blue,alpha), 35, 16) +USE_GL_FUNC(Color4ubv, (const GLubyte *v), (v), 36, 4) +USE_GL_FUNC(Color4ui, (GLuint red, GLuint green, GLuint blue, GLuint alpha), (red,green,blue,alpha), 37, 16) +USE_GL_FUNC(Color4uiv, (const GLuint *v), (v), 38, 4) +USE_GL_FUNC(Color4us, (GLushort red, GLushort green, GLushort blue, GLushort alpha), (red,green,blue,alpha), 39, 16) +USE_GL_FUNC(Color4usv, (const GLushort *v), (v), 40, 4) +USE_GL_FUNC(ColorMask, (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha), (red,green,blue,alpha), 210, 16) +USE_GL_FUNC(ColorMaterial, (GLenum face, GLenum mode), (face,mode), 151, 8) +USE_GL_FUNC(ColorPointer, (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer), (size,type,stride,pointer), 308, 16) +USE_GL_FUNC(CopyPixels, (GLint x, GLint y, GLsizei width, GLsizei height, GLenum type), (x,y,width,height,type), 255, 20) +USE_GL_FUNC(CopyTexImage1D, (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border), (target,level,internalformat,x,y,width,border), 323, 28) +USE_GL_FUNC(CopyTexImage2D, (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border), (target,level,internalformat,x,y,width,height,border), 324, 32) +USE_GL_FUNC(CopyTexSubImage1D, (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width), (target,level,xoffset,x,y,width), 325, 24) +USE_GL_FUNC(CopyTexSubImage2D, (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height), (target,level,xoffset,yoffset,x,y,width,height), 326, 32) +USE_GL_FUNC(CullFace, (GLenum mode), (mode), 152, 4) +USE_GL_FUNC(DeleteLists, (GLuint list, GLsizei range), (list,range), 4, 8) +USE_GL_FUNC(DeleteTextures, (GLsizei n, const GLuint *textures), (n,textures), 327, 8) +USE_GL_FUNC(DepthFunc, (GLenum func), (func), 245, 4) +USE_GL_FUNC(DepthMask, (GLboolean flag), (flag), 211, 4) +USE_GL_FUNC(DepthRange, (GLclampd zNear, GLclampd zFar), (zNear,zFar), 288, 16) +USE_GL_FUNC(Disable, (GLenum cap), (cap), 214, 4) +USE_GL_FUNC(DisableClientState, (GLenum array), (array), 309, 4) +USE_GL_FUNC(DrawArrays, (GLenum mode, GLint first, GLsizei count), (mode,first,count), 310, 12) +USE_GL_FUNC(DrawBuffer, (GLenum mode), (mode), 202, 4) +USE_GL_FUNC(DrawElements, (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices), (mode,count,type,indices), 311, 16) +USE_GL_FUNC(DrawPixels, (GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels), (width,height,format,type,pixels), 257, 20) +USE_GL_FUNC(EdgeFlag, (GLboolean flag), (flag), 41, 4) +USE_GL_FUNC(EdgeFlagPointer, (GLsizei stride, const GLvoid *pointer), (stride,pointer), 312, 8) +USE_GL_FUNC(EdgeFlagv, (const GLboolean *flag), (flag), 42, 4) +USE_GL_FUNC(Enable, (GLenum cap), (cap), 215, 4) +USE_GL_FUNC(EnableClientState, (GLenum array), (array), 313, 4) +USE_GL_FUNC(End, (void), (), 43, 0) +USE_GL_FUNC(EndList, (void), (), 1, 0) +USE_GL_FUNC(EvalCoord1d, (GLdouble u), (u), 228, 8) +USE_GL_FUNC(EvalCoord1dv, (const GLdouble *u), (u), 229, 4) +USE_GL_FUNC(EvalCoord1f, (GLfloat u), (u), 230, 4) +USE_GL_FUNC(EvalCoord1fv, (const GLfloat *u), (u), 231, 4) +USE_GL_FUNC(EvalCoord2d, (GLdouble u, GLdouble v), (u,v), 232, 16) +USE_GL_FUNC(EvalCoord2dv, (const GLdouble *u), (u), 233, 4) +USE_GL_FUNC(EvalCoord2f, (GLfloat u, GLfloat v), (u,v), 234, 8) +USE_GL_FUNC(EvalCoord2fv, (const GLfloat *u), (u), 235, 4) +USE_GL_FUNC(EvalMesh1, (GLenum mode, GLint i1, GLint i2), (mode,i1,i2), 236, 12) +USE_GL_FUNC(EvalMesh2, (GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2), (mode,i1,i2,j1,j2), 238, 20) +USE_GL_FUNC(EvalPoint1, (GLint i), (i), 237, 4) +USE_GL_FUNC(EvalPoint2, (GLint i, GLint j), (i,j), 239, 8) +USE_GL_FUNC(FeedbackBuffer, (GLsizei size, GLenum type, GLfloat *buffer), (size,type,buffer), 194, 12) +USE_GL_FUNC(Finish, (void), (), 216, 0) +USE_GL_FUNC(Flush, (void), (), 217, 0) +USE_GL_FUNC(Fogf, (GLenum pname, GLfloat param), (pname,param), 153, 8) +USE_GL_FUNC(Fogfv, (GLenum pname, const GLfloat *params), (pname,params), 154, 8) +USE_GL_FUNC(Fogi, (GLenum pname, GLint param), (pname,param), 155, 8) +USE_GL_FUNC(Fogiv, (GLenum pname, const GLint *params), (pname,params), 156, 8) +USE_GL_FUNC(FrontFace, (GLenum mode), (mode), 157, 4) +USE_GL_FUNC(Frustum, (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar), (left,right,bottom,top,zNear,zFar), 289, 48) +USE_GL_FUNC_RET(GenLists, GLuint, (GLsizei range), (range), 5, 4) +USE_GL_FUNC(GenTextures, (GLsizei n, GLuint *textures), (n,textures), 328, 8) +USE_GL_FUNC(GetBooleanv, (GLenum pname, GLboolean *params), (pname,params), 258, 8) +USE_GL_FUNC(GetClipPlane, (GLenum plane, GLdouble *equation), (plane,equation), 259, 8) +USE_GL_FUNC(GetDoublev, (GLenum pname, GLdouble *params), (pname,params), 260, 8) +USE_GL_FUNC_RET(GetError, GLenum, (void), (), 261, 0) +USE_GL_FUNC(GetFloatv, (GLenum pname, GLfloat *params), (pname,params), 262, 8) +USE_GL_FUNC(GetIntegerv, (GLenum pname, GLint *params), (pname,params), 263, 8) +USE_GL_FUNC(GetLightfv, (GLenum light, GLenum pname, GLfloat *params), (light,pname,params), 264, 12) +USE_GL_FUNC(GetLightiv, (GLenum light, GLenum pname, GLint *params), (light,pname,params), 265, 12) +USE_GL_FUNC(GetMapdv, (GLenum target, GLenum query, GLdouble *v), (target,query,v), 266, 12) +USE_GL_FUNC(GetMapfv, (GLenum target, GLenum query, GLfloat *v), (target,query,v), 267, 12) +USE_GL_FUNC(GetMapiv, (GLenum target, GLenum query, GLint *v), (target,query,v), 268, 12) +USE_GL_FUNC(GetMaterialfv, (GLenum face, GLenum pname, GLfloat *params), (face,pname,params), 269, 12) +USE_GL_FUNC(GetMaterialiv, (GLenum face, GLenum pname, GLint *params), (face,pname,params), 270, 12) +USE_GL_FUNC(GetPixelMapfv, (GLenum map, GLfloat *values), (map,values), 271, 8) +USE_GL_FUNC(GetPixelMapuiv, (GLenum map, GLuint *values), (map,values), 272, 8) +USE_GL_FUNC(GetPixelMapusv, (GLenum map, GLushort *values), (map,values), 273, 8) +USE_GL_FUNC(GetPointerv, (GLenum pname, GLvoid* *params), (pname,params), 329, 8) +USE_GL_FUNC(GetPolygonStipple, (GLubyte *mask), (mask), 274, 4) +USE_GL_FUNC_RET(GetString, const GLubyte *, (GLenum name), (name), 275, 4) +USE_GL_FUNC(GetTexEnvfv, (GLenum target, GLenum pname, GLfloat *params), (target,pname,params), 276, 12) +USE_GL_FUNC(GetTexEnviv, (GLenum target, GLenum pname, GLint *params), (target,pname,params), 277, 12) +USE_GL_FUNC(GetTexGendv, (GLenum coord, GLenum pname, GLdouble *params), (coord,pname,params), 278, 12) +USE_GL_FUNC(GetTexGenfv, (GLenum coord, GLenum pname, GLfloat *params), (coord,pname,params), 279, 12) +USE_GL_FUNC(GetTexGeniv, (GLenum coord, GLenum pname, GLint *params), (coord,pname,params), 280, 12) +USE_GL_FUNC(GetTexImage, (GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels), (target,level,format,type,pixels), 281, 20) +USE_GL_FUNC(GetTexLevelParameterfv, (GLenum target, GLint level, GLenum pname, GLfloat *params), (target,level,pname,params), 284, 16) +USE_GL_FUNC(GetTexLevelParameteriv, (GLenum target, GLint level, GLenum pname, GLint *params), (target,level,pname,params), 285, 16) +USE_GL_FUNC(GetTexParameterfv, (GLenum target, GLenum pname, GLfloat *params), (target,pname,params), 282, 12) +USE_GL_FUNC(GetTexParameteriv, (GLenum target, GLenum pname, GLint *params), (target,pname,params), 283, 12) +USE_GL_FUNC(Hint, (GLenum target, GLenum mode), (target,mode), 158, 8) +USE_GL_FUNC(IndexMask, (GLuint mask), (mask), 212, 4) +USE_GL_FUNC(IndexPointer, (GLenum type, GLsizei stride, const GLvoid *pointer), (type,stride,pointer), 314, 12) +USE_GL_FUNC(Indexd, (GLdouble c), (c), 44, 8) +USE_GL_FUNC(Indexdv, (const GLdouble *c), (c), 45, 4) +USE_GL_FUNC(Indexf, (GLfloat c), (c), 46, 4) +USE_GL_FUNC(Indexfv, (const GLfloat *c), (c), 47, 4) +USE_GL_FUNC(Indexi, (GLint c), (c), 48, 4) +USE_GL_FUNC(Indexiv, (const GLint *c), (c), 49, 4) +USE_GL_FUNC(Indexs, (GLshort c), (c), 50, 4) +USE_GL_FUNC(Indexsv, (const GLshort *c), (c), 51, 4) +USE_GL_FUNC(Indexub, (GLubyte c), (c), 315, 4) +USE_GL_FUNC(Indexubv, (const GLubyte *c), (c), 316, 4) +USE_GL_FUNC(InitNames, (void), (), 197, 0) +USE_GL_FUNC(InterleavedArrays, (GLenum format, GLsizei stride, const GLvoid *pointer), (format,stride,pointer), 317, 12) +USE_GL_FUNC_RET(IsEnabled, GLboolean, (GLenum cap), (cap), 286, 4) +USE_GL_FUNC_RET(IsList, GLboolean, (GLuint list), (list), 287, 4) +USE_GL_FUNC_RET(IsTexture, GLboolean, (GLuint texture), (texture), 330, 4) +USE_GL_FUNC(LightModelf, (GLenum pname, GLfloat param), (pname,param), 163, 8) +USE_GL_FUNC(LightModelfv, (GLenum pname, const GLfloat *params), (pname,params), 164, 8) +USE_GL_FUNC(LightModeli, (GLenum pname, GLint param), (pname,param), 165, 8) +USE_GL_FUNC(LightModeliv, (GLenum pname, const GLint *params), (pname,params), 166, 8) +USE_GL_FUNC(Lightf, (GLenum light, GLenum pname, GLfloat param), (light,pname,param), 159, 12) +USE_GL_FUNC(Lightfv, (GLenum light, GLenum pname, const GLfloat *params), (light,pname,params), 160, 12) +USE_GL_FUNC(Lighti, (GLenum light, GLenum pname, GLint param), (light,pname,param), 161, 12) +USE_GL_FUNC(Lightiv, (GLenum light, GLenum pname, const GLint *params), (light,pname,params), 162, 12) +USE_GL_FUNC(LineStipple, (GLint factor, GLushort pattern), (factor,pattern), 167, 8) +USE_GL_FUNC(LineWidth, (GLfloat width), (width), 168, 4) +USE_GL_FUNC(ListBase, (GLuint base), (base), 6, 4) +USE_GL_FUNC(LoadIdentity, (void), (), 290, 0) +USE_GL_FUNC(LoadMatrixd, (const GLdouble *m), (m), 292, 4) +USE_GL_FUNC(LoadMatrixf, (const GLfloat *m), (m), 291, 4) +USE_GL_FUNC(LoadName, (GLuint name), (name), 198, 4) +USE_GL_FUNC(LogicOp, (GLenum opcode), (opcode), 242, 4) +USE_GL_FUNC(Map1d, (GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points), (target,u1,u2,stride,order,points), 220, 32) +USE_GL_FUNC(Map1f, (GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points), (target,u1,u2,stride,order,points), 221, 24) +USE_GL_FUNC(Map2d, (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points), (target,u1,u2,ustride,uorder,v1,v2,vstride,vorder,points), 222, 56) +USE_GL_FUNC(Map2f, (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points), (target,u1,u2,ustride,uorder,v1,v2,vstride,vorder,points), 223, 40) +USE_GL_FUNC(MapGrid1d, (GLint un, GLdouble u1, GLdouble u2), (un,u1,u2), 224, 20) +USE_GL_FUNC(MapGrid1f, (GLint un, GLfloat u1, GLfloat u2), (un,u1,u2), 225, 12) +USE_GL_FUNC(MapGrid2d, (GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2), (un,u1,u2,vn,v1,v2), 226, 40) +USE_GL_FUNC(MapGrid2f, (GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2), (un,u1,u2,vn,v1,v2), 227, 24) +USE_GL_FUNC(Materialf, (GLenum face, GLenum pname, GLfloat param), (face,pname,param), 169, 12) +USE_GL_FUNC(Materialfv, (GLenum face, GLenum pname, const GLfloat *params), (face,pname,params), 170, 12) +USE_GL_FUNC(Materiali, (GLenum face, GLenum pname, GLint param), (face,pname,param), 171, 12) +USE_GL_FUNC(Materialiv, (GLenum face, GLenum pname, const GLint *params), (face,pname,params), 172, 12) +USE_GL_FUNC(MatrixMode, (GLenum mode), (mode), 293, 4) +USE_GL_FUNC(MultMatrixd, (const GLdouble *m), (m), 295, 4) +USE_GL_FUNC(MultMatrixf, (const GLfloat *m), (m), 294, 4) +USE_GL_FUNC(NewList, (GLuint list, GLenum mode), (list,mode), 0, 8) +USE_GL_FUNC(Normal3b, (GLbyte nx, GLbyte ny, GLbyte nz), (nx,ny,nz), 52, 12) +USE_GL_FUNC(Normal3bv, (const GLbyte *v), (v), 53, 4) +USE_GL_FUNC(Normal3d, (GLdouble nx, GLdouble ny, GLdouble nz), (nx,ny,nz), 54, 24) +USE_GL_FUNC(Normal3dv, (const GLdouble *v), (v), 55, 4) +USE_GL_FUNC(Normal3f, (GLfloat nx, GLfloat ny, GLfloat nz), (nx,ny,nz), 56, 12) +USE_GL_FUNC(Normal3fv, (const GLfloat *v), (v), 57, 4) +USE_GL_FUNC(Normal3i, (GLint nx, GLint ny, GLint nz), (nx,ny,nz), 58, 12) +USE_GL_FUNC(Normal3iv, (const GLint *v), (v), 59, 4) +USE_GL_FUNC(Normal3s, (GLshort nx, GLshort ny, GLshort nz), (nx,ny,nz), 60, 12) +USE_GL_FUNC(Normal3sv, (const GLshort *v), (v), 61, 4) +USE_GL_FUNC(NormalPointer, (GLenum type, GLsizei stride, const GLvoid *pointer), (type,stride,pointer), 318, 12) +USE_GL_FUNC(Ortho, (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar), (left,right,bottom,top,zNear,zFar), 296, 48) +USE_GL_FUNC(PassThrough, (GLfloat token), (token), 199, 4) +USE_GL_FUNC(PixelMapfv, (GLenum map, GLint mapsize, const GLfloat *values), (map,mapsize,values), 251, 12) +USE_GL_FUNC(PixelMapuiv, (GLenum map, GLint mapsize, const GLuint *values), (map,mapsize,values), 252, 12) +USE_GL_FUNC(PixelMapusv, (GLenum map, GLint mapsize, const GLushort *values), (map,mapsize,values), 253, 12) +USE_GL_FUNC(PixelStoref, (GLenum pname, GLfloat param), (pname,param), 249, 8) +USE_GL_FUNC(PixelStorei, (GLenum pname, GLint param), (pname,param), 250, 8) +USE_GL_FUNC(PixelTransferf, (GLenum pname, GLfloat param), (pname,param), 247, 8) +USE_GL_FUNC(PixelTransferi, (GLenum pname, GLint param), (pname,param), 248, 8) +USE_GL_FUNC(PixelZoom, (GLfloat xfactor, GLfloat yfactor), (xfactor,yfactor), 246, 8) +USE_GL_FUNC(PointSize, (GLfloat size), (size), 173, 4) +USE_GL_FUNC(PolygonMode, (GLenum face, GLenum mode), (face,mode), 174, 8) +USE_GL_FUNC(PolygonOffset, (GLfloat factor, GLfloat units), (factor,units), 319, 8) +USE_GL_FUNC(PolygonStipple, (const GLubyte *mask), (mask), 175, 4) +USE_GL_FUNC(PopAttrib, (void), (), 218, 0) +USE_GL_FUNC(PopClientAttrib, (void), (), 334, 0) +USE_GL_FUNC(PopMatrix, (void), (), 297, 0) +USE_GL_FUNC(PopName, (void), (), 200, 0) +USE_GL_FUNC(PrioritizeTextures, (GLsizei n, const GLuint *textures, const GLclampf *priorities), (n,textures,priorities), 331, 12) +USE_GL_FUNC(PushAttrib, (GLbitfield mask), (mask), 219, 4) +USE_GL_FUNC(PushClientAttrib, (GLbitfield mask), (mask), 335, 4) +USE_GL_FUNC(PushMatrix, (void), (), 298, 0) +USE_GL_FUNC(PushName, (GLuint name), (name), 201, 4) +USE_GL_FUNC(RasterPos2d, (GLdouble x, GLdouble y), (x,y), 62, 16) +USE_GL_FUNC(RasterPos2dv, (const GLdouble *v), (v), 63, 4) +USE_GL_FUNC(RasterPos2f, (GLfloat x, GLfloat y), (x,y), 64, 8) +USE_GL_FUNC(RasterPos2fv, (const GLfloat *v), (v), 65, 4) +USE_GL_FUNC(RasterPos2i, (GLint x, GLint y), (x,y), 66, 8) +USE_GL_FUNC(RasterPos2iv, (const GLint *v), (v), 67, 4) +USE_GL_FUNC(RasterPos2s, (GLshort x, GLshort y), (x,y), 68, 8) +USE_GL_FUNC(RasterPos2sv, (const GLshort *v), (v), 69, 4) +USE_GL_FUNC(RasterPos3d, (GLdouble x, GLdouble y, GLdouble z), (x,y,z), 70, 24) +USE_GL_FUNC(RasterPos3dv, (const GLdouble *v), (v), 71, 4) +USE_GL_FUNC(RasterPos3f, (GLfloat x, GLfloat y, GLfloat z), (x,y,z), 72, 12) +USE_GL_FUNC(RasterPos3fv, (const GLfloat *v), (v), 73, 4) +USE_GL_FUNC(RasterPos3i, (GLint x, GLint y, GLint z), (x,y,z), 74, 12) +USE_GL_FUNC(RasterPos3iv, (const GLint *v), (v), 75, 4) +USE_GL_FUNC(RasterPos3s, (GLshort x, GLshort y, GLshort z), (x,y,z), 76, 12) +USE_GL_FUNC(RasterPos3sv, (const GLshort *v), (v), 77, 4) +USE_GL_FUNC(RasterPos4d, (GLdouble x, GLdouble y, GLdouble z, GLdouble w), (x,y,z,w), 78, 32) +USE_GL_FUNC(RasterPos4dv, (const GLdouble *v), (v), 79, 4) +USE_GL_FUNC(RasterPos4f, (GLfloat x, GLfloat y, GLfloat z, GLfloat w), (x,y,z,w), 80, 16) +USE_GL_FUNC(RasterPos4fv, (const GLfloat *v), (v), 81, 4) +USE_GL_FUNC(RasterPos4i, (GLint x, GLint y, GLint z, GLint w), (x,y,z,w), 82, 16) +USE_GL_FUNC(RasterPos4iv, (const GLint *v), (v), 83, 4) +USE_GL_FUNC(RasterPos4s, (GLshort x, GLshort y, GLshort z, GLshort w), (x,y,z,w), 84, 16) +USE_GL_FUNC(RasterPos4sv, (const GLshort *v), (v), 85, 4) +USE_GL_FUNC(ReadBuffer, (GLenum mode), (mode), 254, 4) +USE_GL_FUNC(ReadPixels, (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels), (x,y,width,height,format,type,pixels), 256, 28) +USE_GL_FUNC(Rectd, (GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2), (x1,y1,x2,y2), 86, 32) +USE_GL_FUNC(Rectdv, (const GLdouble *v1, const GLdouble *v2), (v1,v2), 87, 8) +USE_GL_FUNC(Rectf, (GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2), (x1,y1,x2,y2), 88, 16) +USE_GL_FUNC(Rectfv, (const GLfloat *v1, const GLfloat *v2), (v1,v2), 89, 8) +USE_GL_FUNC(Recti, (GLint x1, GLint y1, GLint x2, GLint y2), (x1,y1,x2,y2), 90, 16) +USE_GL_FUNC(Rectiv, (const GLint *v1, const GLint *v2), (v1,v2), 91, 8) +USE_GL_FUNC(Rects, (GLshort x1, GLshort y1, GLshort x2, GLshort y2), (x1,y1,x2,y2), 92, 16) +USE_GL_FUNC(Rectsv, (const GLshort *v1, const GLshort *v2), (v1,v2), 93, 8) +USE_GL_FUNC_RET(RenderMode, GLint, (GLenum mode), (mode), 196, 4) +USE_GL_FUNC(Rotated, (GLdouble angle, GLdouble x, GLdouble y, GLdouble z), (angle,x,y,z), 299, 32) +USE_GL_FUNC(Rotatef, (GLfloat angle, GLfloat x, GLfloat y, GLfloat z), (angle,x,y,z), 300, 16) +USE_GL_FUNC(Scaled, (GLdouble x, GLdouble y, GLdouble z), (x,y,z), 301, 24) +USE_GL_FUNC(Scalef, (GLfloat x, GLfloat y, GLfloat z), (x,y,z), 302, 12) +USE_GL_FUNC(Scissor, (GLint x, GLint y, GLsizei width, GLsizei height), (x,y,width,height), 176, 16) +USE_GL_FUNC(SelectBuffer, (GLsizei size, GLuint *buffer), (size,buffer), 195, 8) +USE_GL_FUNC(ShadeModel, (GLenum mode), (mode), 177, 4) +USE_GL_FUNC(StencilFunc, (GLenum func, GLint ref, GLuint mask), (func,ref,mask), 243, 12) +USE_GL_FUNC(StencilMask, (GLuint mask), (mask), 209, 4) +USE_GL_FUNC(StencilOp, (GLenum fail, GLenum zfail, GLenum zpass), (fail,zfail,zpass), 244, 12) +USE_GL_FUNC(TexCoord1d, (GLdouble s), (s), 94, 8) +USE_GL_FUNC(TexCoord1dv, (const GLdouble *v), (v), 95, 4) +USE_GL_FUNC(TexCoord1f, (GLfloat s), (s), 96, 4) +USE_GL_FUNC(TexCoord1fv, (const GLfloat *v), (v), 97, 4) +USE_GL_FUNC(TexCoord1i, (GLint s), (s), 98, 4) +USE_GL_FUNC(TexCoord1iv, (const GLint *v), (v), 99, 4) +USE_GL_FUNC(TexCoord1s, (GLshort s), (s), 100, 4) +USE_GL_FUNC(TexCoord1sv, (const GLshort *v), (v), 101, 4) +USE_GL_FUNC(TexCoord2d, (GLdouble s, GLdouble t), (s,t), 102, 16) +USE_GL_FUNC(TexCoord2dv, (const GLdouble *v), (v), 103, 4) +USE_GL_FUNC(TexCoord2f, (GLfloat s, GLfloat t), (s,t), 104, 8) +USE_GL_FUNC(TexCoord2fv, (const GLfloat *v), (v), 105, 4) +USE_GL_FUNC(TexCoord2i, (GLint s, GLint t), (s,t), 106, 8) +USE_GL_FUNC(TexCoord2iv, (const GLint *v), (v), 107, 4) +USE_GL_FUNC(TexCoord2s, (GLshort s, GLshort t), (s,t), 108, 8) +USE_GL_FUNC(TexCoord2sv, (const GLshort *v), (v), 109, 4) +USE_GL_FUNC(TexCoord3d, (GLdouble s, GLdouble t, GLdouble r), (s,t,r), 110, 24) +USE_GL_FUNC(TexCoord3dv, (const GLdouble *v), (v), 111, 4) +USE_GL_FUNC(TexCoord3f, (GLfloat s, GLfloat t, GLfloat r), (s,t,r), 112, 12) +USE_GL_FUNC(TexCoord3fv, (const GLfloat *v), (v), 113, 4) +USE_GL_FUNC(TexCoord3i, (GLint s, GLint t, GLint r), (s,t,r), 114, 12) +USE_GL_FUNC(TexCoord3iv, (const GLint *v), (v), 115, 4) +USE_GL_FUNC(TexCoord3s, (GLshort s, GLshort t, GLshort r), (s,t,r), 116, 12) +USE_GL_FUNC(TexCoord3sv, (const GLshort *v), (v), 117, 4) +USE_GL_FUNC(TexCoord4d, (GLdouble s, GLdouble t, GLdouble r, GLdouble q), (s,t,r,q), 118, 32) +USE_GL_FUNC(TexCoord4dv, (const GLdouble *v), (v), 119, 4) +USE_GL_FUNC(TexCoord4f, (GLfloat s, GLfloat t, GLfloat r, GLfloat q), (s,t,r,q), 120, 16) +USE_GL_FUNC(TexCoord4fv, (const GLfloat *v), (v), 121, 4) +USE_GL_FUNC(TexCoord4i, (GLint s, GLint t, GLint r, GLint q), (s,t,r,q), 122, 16) +USE_GL_FUNC(TexCoord4iv, (const GLint *v), (v), 123, 4) +USE_GL_FUNC(TexCoord4s, (GLshort s, GLshort t, GLshort r, GLshort q), (s,t,r,q), 124, 16) +USE_GL_FUNC(TexCoord4sv, (const GLshort *v), (v), 125, 4) +USE_GL_FUNC(TexCoordPointer, (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer), (size,type,stride,pointer), 320, 16) +USE_GL_FUNC(TexEnvf, (GLenum target, GLenum pname, GLfloat param), (target,pname,param), 184, 12) +USE_GL_FUNC(TexEnvfv, (GLenum target, GLenum pname, const GLfloat *params), (target,pname,params), 185, 12) +USE_GL_FUNC(TexEnvi, (GLenum target, GLenum pname, GLint param), (target,pname,param), 186, 12) +USE_GL_FUNC(TexEnviv, (GLenum target, GLenum pname, const GLint *params), (target,pname,params), 187, 12) +USE_GL_FUNC(TexGend, (GLenum coord, GLenum pname, GLdouble param), (coord,pname,param), 188, 16) +USE_GL_FUNC(TexGendv, (GLenum coord, GLenum pname, const GLdouble *params), (coord,pname,params), 189, 12) +USE_GL_FUNC(TexGenf, (GLenum coord, GLenum pname, GLfloat param), (coord,pname,param), 190, 12) +USE_GL_FUNC(TexGenfv, (GLenum coord, GLenum pname, const GLfloat *params), (coord,pname,params), 191, 12) +USE_GL_FUNC(TexGeni, (GLenum coord, GLenum pname, GLint param), (coord,pname,param), 192, 12) +USE_GL_FUNC(TexGeniv, (GLenum coord, GLenum pname, const GLint *params), (coord,pname,params), 193, 12) +USE_GL_FUNC(TexImage1D, (GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels), (target,level,internalformat,width,border,format,type,pixels), 182, 32) +USE_GL_FUNC(TexImage2D, (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels), (target,level,internalformat,width,height,border,format,type,pixels), 183, 36) +USE_GL_FUNC(TexParameterf, (GLenum target, GLenum pname, GLfloat param), (target,pname,param), 178, 12) +USE_GL_FUNC(TexParameterfv, (GLenum target, GLenum pname, const GLfloat *params), (target,pname,params), 179, 12) +USE_GL_FUNC(TexParameteri, (GLenum target, GLenum pname, GLint param), (target,pname,param), 180, 12) +USE_GL_FUNC(TexParameteriv, (GLenum target, GLenum pname, const GLint *params), (target,pname,params), 181, 12) +USE_GL_FUNC(TexSubImage1D, (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels), (target,level,xoffset,width,format,type,pixels), 332, 28) +USE_GL_FUNC(TexSubImage2D, (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels), (target,level,xoffset,yoffset,width,height,format,type,pixels), 333, 36) +USE_GL_FUNC(Translated, (GLdouble x, GLdouble y, GLdouble z), (x,y,z), 303, 24) +USE_GL_FUNC(Translatef, (GLfloat x, GLfloat y, GLfloat z), (x,y,z), 304, 12) +USE_GL_FUNC(Vertex2d, (GLdouble x, GLdouble y), (x,y), 126, 16) +USE_GL_FUNC(Vertex2dv, (const GLdouble *v), (v), 127, 4) +USE_GL_FUNC(Vertex2f, (GLfloat x, GLfloat y), (x,y), 128, 8) +USE_GL_FUNC(Vertex2fv, (const GLfloat *v), (v), 129, 4) +USE_GL_FUNC(Vertex2i, (GLint x, GLint y), (x,y), 130, 8) +USE_GL_FUNC(Vertex2iv, (const GLint *v), (v), 131, 4) +USE_GL_FUNC(Vertex2s, (GLshort x, GLshort y), (x,y), 132, 8) +USE_GL_FUNC(Vertex2sv, (const GLshort *v), (v), 133, 4) +USE_GL_FUNC(Vertex3d, (GLdouble x, GLdouble y, GLdouble z), (x,y,z), 134, 24) +USE_GL_FUNC(Vertex3dv, (const GLdouble *v), (v), 135, 4) +USE_GL_FUNC(Vertex3f, (GLfloat x, GLfloat y, GLfloat z), (x,y,z), 136, 12) +USE_GL_FUNC(Vertex3fv, (const GLfloat *v), (v), 137, 4) +USE_GL_FUNC(Vertex3i, (GLint x, GLint y, GLint z), (x,y,z), 138, 12) +USE_GL_FUNC(Vertex3iv, (const GLint *v), (v), 139, 4) +USE_GL_FUNC(Vertex3s, (GLshort x, GLshort y, GLshort z), (x,y,z), 140, 12) +USE_GL_FUNC(Vertex3sv, (const GLshort *v), (v), 141, 4) +USE_GL_FUNC(Vertex4d, (GLdouble x, GLdouble y, GLdouble z, GLdouble w), (x,y,z,w), 142, 32) +USE_GL_FUNC(Vertex4dv, (const GLdouble *v), (v), 143, 4) +USE_GL_FUNC(Vertex4f, (GLfloat x, GLfloat y, GLfloat z, GLfloat w), (x,y,z,w), 144, 16) +USE_GL_FUNC(Vertex4fv, (const GLfloat *v), (v), 145, 4) +USE_GL_FUNC(Vertex4i, (GLint x, GLint y, GLint z, GLint w), (x,y,z,w), 146, 16) +USE_GL_FUNC(Vertex4iv, (const GLint *v), (v), 147, 4) +USE_GL_FUNC(Vertex4s, (GLshort x, GLshort y, GLshort z, GLshort w), (x,y,z,w), 148, 16) +USE_GL_FUNC(Vertex4sv, (const GLshort *v), (v), 149, 4) +USE_GL_FUNC(VertexPointer, (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer), (size,type,stride,pointer), 321, 16) +USE_GL_FUNC(Viewport, (GLint x, GLint y, GLsizei width, GLsizei height), (x,y,width,height), 305, 16) - -/* EOF */ +#undef USE_GL_FUNC +#undef USE_GL_FUNC_RET diff --git a/reactos/dll/opengl/opengl32_new/icd.h b/reactos/dll/opengl/opengl32/icd.h similarity index 100% rename from reactos/dll/opengl/opengl32_new/icd.h rename to reactos/dll/opengl/opengl32/icd.h diff --git a/reactos/dll/opengl/opengl32_new/icdload.c b/reactos/dll/opengl/opengl32/icdload.c similarity index 96% rename from reactos/dll/opengl/opengl32_new/icdload.c rename to reactos/dll/opengl/opengl32/icdload.c index 61f60cd236f..1cd1e19edc7 100644 --- a/reactos/dll/opengl/opengl32_new/icdload.c +++ b/reactos/dll/opengl/opengl32/icdload.c @@ -24,22 +24,12 @@ static const WCHAR OpenGLDrivers_Key[] = L"SOFTWARE\\Microsoft\\Windows NT\\Curr static void APIENTRY wglSetCurrentValue(PVOID value) { -#ifdef OPENGL32_USE_TLS - struct Opengl32_ThreadData* data = TlsGetValue(OglTlsIndex); - data->icdData = value; -#else - NtCurrentTeb()->glReserved2 = value; -#endif + IntSetCurrentICDPrivate(value); } static PVOID APIENTRY wglGetCurrentValue() { -#ifdef OPENGL32_USE_TLS - struct Opengl32_ThreadData* data = TlsGetValue(OglTlsIndex); - return data->icdData; -#else - return NtCurrentTeb()->glReserved2; -#endif + return IntGetCurrentICDPrivate(); } static DHGLRC wglGetDHGLRC(struct wgl_context* context) diff --git a/reactos/dll/opengl/opengl32/opengl32.h b/reactos/dll/opengl/opengl32/opengl32.h index 24e1cec6545..c2109979811 100644 --- a/reactos/dll/opengl/opengl32/opengl32.h +++ b/reactos/dll/opengl/opengl32/opengl32.h @@ -1,234 +1,168 @@ /* * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel - * FILE: lib/opengl32/opengl32.h - * PURPOSE: OpenGL32 lib - * PROGRAMMER: Royce Mitchell III, Anich Gregor (blight) - * UPDATE HISTORY: - * Feb 1, 2004: Created + * FILE: lib/opengl32/opengl.h + * PURPOSE: OpenGL32 lib, general header */ -#ifndef OPENGL32_PRIVATE_H -#define OPENGL32_PRIVATE_H - -#define snwprintf _snwprintf - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#define NDEBUG - -#ifndef PFD_GENERIC_ACCELERATED -# define PFD_GENERIC_ACCELERATED 0x00001000 -#endif - -#define OPENGL_DRIVERS_SUBKEY L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\OpenGLDrivers" -#define OPENGL_DRIVERS_SUBKEY2 L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\OpenGLDrivers\\" - -#include -#include -//#include +#pragma once #define WIN32_NO_STATUS +#include #include #include -#include -#include #include +#include #include +#include -#define NTOS_MODE_USER -#include +#include "icd.h" -//#include -#include +struct wgl_context +{ + DWORD magic; + volatile LONG lock; -/* gl function list */ -#include "glfuncs.h" + DHGLRC dhglrc; + struct ICD_Data* icd_data; + INT pixelformat; + volatile LONG thread_id; +}; -/* ICD index list/types */ -#include "icdtable.h" +#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; +}; -/* debug flags */ -#if !defined(NDEBUG) -# define DEBUG_OPENGL32 -/* enable breakpoints */ -/*# define DEBUG_OPENGL32_BRKPTS*/ -/* dumps the list of (un)supported glXXX functions when an ICD is loaded. */ -# define DEBUG_OPENGL32_ICD_EXPORTS -/* prints much information about whats going on */ -# define DEBUG_OPENGL32_TRACE -#endif /* !NDEBUG */ +#ifdef OPENGL32_USE_TLS +extern DWORD OglTlsIndex; -/* debug macros */ -# ifdef DEBUG_OPENGL32 -# include -# define DBGPRINT( fmt, args... ) \ - DPRINT( "OpenGL32.DLL: %s: "fmt"\n", __FUNCTION__, ##args ) -# endif +struct Opengl32_ThreadData +{ + const GLDISPATCHTABLE* glDispatchTable; + HGLRC hglrc; + HDC hdc; + struct wgl_dc_data* dc_data; + PVOID* icdData; +}; +C_ASSERT(FIELD_OFFSET(struct Opengl32_ThreadData, glDispatchTable) == 0); + +static inline +void +IntMakeCurrent(HGLRC hglrc, HDC hdc, struct wgl_dc_data* dc_data) +{ + struct Opengl32_ThreadData* thread_data = TlsGetValue(OglTlsIndex); + + thread_data->hglrc = hglrc; + thread_data->hdc = hdc; + thread_data->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->glDispatchTable; +} + +static inline +void +IntSetCurrentDispatchTable(const GLDISPATCHTABLE* table) +{ + struct Opengl32_ThreadData* data = TlsGetValue(OglTlsIndex); + data->glDispatchTable = table; +} + +static inline +void +IntSetCurrentICDPrivate(void* value) +{ + struct Opengl32_ThreadData* data = TlsGetValue(OglTlsIndex); + data->icdData = value; +} + +static inline +void* +IntGetCurrentICDPrivate(void) +{ + struct Opengl32_ThreadData* data = TlsGetValue(OglTlsIndex); + return data->icdData; +} -#ifndef DBGPRINT -# define DBGPRINT( ... ) do {} while (0) -#endif -#ifdef DEBUG_OPENGL32_BRKPTS -# if defined(__GNUC__) -# define DBGBREAK() __asm__( "int $3" ); -# elif defined(_MSC_VER) -# define DBGBREAK() __asm { int 3 } -# else -# error Unsupported compiler! -# endif #else -# define DBGBREAK() do {} while (0) -#endif - -#ifdef DEBUG_OPENGL32_TRACE -# define DBGTRACE( args... ) DBGPRINT( args ) -#else -# define DBGTRACE( ... ) do {} while (0) -#endif - -/* function/data attributes */ -#define EXPORT __declspec(dllexport) -#ifdef _MSC_VER -# define NAKED __declspec(naked) -# define SHARED -# ifndef WINAPI -# define WINAPI __stdcall -# endif /* WINAPI */ -#else /* GCC */ -# define NAKED __attribute__((naked)) -# define SHARED __attribute__((section("shared"), shared)) -#endif - -#ifdef APIENTRY -#undef APIENTRY -#endif /* APIENTRY */ -#define APIENTRY __stdcall - -/* Called by the driver to set the dispatch table */ -typedef DWORD (WINAPI *SetContextCallBack)( const ICDTable * ); - -/* OpenGL ICD data */ -typedef struct tagGLDRIVERDATA +static inline +const GLDISPATCHTABLE* +IntGetCurrentDispatchTable(void) { - HMODULE handle; /*!< DLL handle */ - UINT refcount; /*!< Number of references to this ICD */ - WCHAR driver_name[256]; /*!< Name of ICD driver */ + return (GLDISPATCHTABLE*)NtCurrentTeb()->glTable; +} +#endif // defined(OPENGL32_USE_TLS) - WCHAR dll[256]; /*!< Dll filename from registry */ - DWORD version; /*!< Version value from registry */ - DWORD driver_version; /*!< DriverVersion value from registry */ - DWORD flags; /*!< Flags value from registry */ - - BOOL (WINAPI *DrvCopyContext)( HGLRC, HGLRC, UINT ); - HGLRC (WINAPI *DrvCreateContext)( HDC ); - HGLRC (WINAPI *DrvCreateLayerContext)( HDC, int ); - BOOL (WINAPI *DrvDeleteContext)( HGLRC ); - 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)( HGLRC hglrc ); /* maybe returns BOOL? */ - BOOL (WINAPI *DrvRealizeLayerPalette)( HDC, int, BOOL ); - PICDTable (WINAPI *DrvSetContext)( HDC hdc, HGLRC hglrc, SetContextCallBack callback ); - int (WINAPI *DrvSetLayerPaletteEntries)( HDC, int, int, int, CONST COLORREF * ); - BOOL (WINAPI *DrvSetPixelFormat)( IN HDC, IN int, const PIXELFORMATDESCRIPTOR * ); - BOOL (WINAPI *DrvShareLists)( HGLRC, HGLRC ); - BOOL (WINAPI *DrvSwapBuffers)( HDC ); - BOOL (WINAPI *DrvSwapLayerBuffers)( HDC, UINT ); - BOOL (WINAPI *DrvValidateVersion)( DWORD ); - - struct tagGLDRIVERDATA *next; /* next ICD -- linked list */ -} GLDRIVERDATA; - -/* Our private OpenGL context (stored in TLS) */ -typedef struct tagGLRC -{ - GLDRIVERDATA *icd; /*!< driver used for this context */ - HDC hdc; /*!< DC handle */ - BOOL is_current; /*!< Wether this context is current for some DC */ - DWORD thread_id; /*!< Thread holding this context */ - - HGLRC hglrc; /*!< GLRC from DrvCreateContext (ICD internal) */ - - struct tagGLRC *next; /* linked list */ -} GLRC; - -/* OpenGL private device context data */ -typedef struct tagGLDCDATA -{ - HANDLE handle; /*!< Handle for which this data is (HWND for device, HDC for memory context) */ - GLDRIVERDATA *icd; /*!< Driver used for this DC */ - int pixel_format; /*!< Selected pixel format */ - - struct tagGLDCDATA *next; /* linked list */ -} GLDCDATA; - - -/* Process data */ -typedef struct tagGLPROCESSDATA -{ - GLDRIVERDATA *driver_list; /*!< List of loaded drivers */ - HANDLE driver_mutex; /*!< Mutex to protect driver list */ - GLRC *glrc_list; /*!< List of GL rendering contexts */ - HANDLE glrc_mutex; /*!< Mutex to protect glrc list */ - GLDCDATA *dcdata_list; /*!< List of GL private DC data */ - HANDLE dcdata_mutex; /*!< Mutex to protect glrc list */ -} GLPROCESSDATA; - -extern GLPROCESSDATA OPENGL32_processdata; - -/* function prototypes */ -GLDRIVERDATA *OPENGL32_LoadICD( LPCWSTR driver ); -BOOL OPENGL32_UnloadICD( GLDRIVERDATA *icd ); -BOOL APIENTRY rosglMakeCurrent( HDC hdc, HGLRC hglrc ); -BOOL APIENTRY IntUseFontBitmapsA( HDC hDC, DWORD first, DWORD count, DWORD listBase ); -BOOL APIENTRY IntUseFontBitmapsW( HDC hDC, DWORD first, DWORD count, DWORD listBase ); -BOOL APIENTRY IntUseFontOutlinesA( HDC hDC, DWORD first, DWORD count, DWORD listBase, - FLOAT chordalDeviation, FLOAT extrusion, INT format, - GLYPHMETRICSFLOAT *glyphMetricsFloatArray ); -BOOL APIENTRY IntUseFontOutlinesW( HDC hDC, DWORD first, DWORD count, DWORD listBase, - FLOAT chordalDeviation, FLOAT extrusion, INT format, - GLYPHMETRICSFLOAT *glyphMetricsFloatArray ); - -/* empty gl functions from gl.c */ -int WINAPI glEmptyFunc0( void ); -int WINAPI glEmptyFunc4( long ); -int WINAPI glEmptyFunc8( long, long ); -int WINAPI glEmptyFunc12( long, long, long ); -int WINAPI glEmptyFunc16( long, long, long, long ); -int WINAPI glEmptyFunc20( long, long, long, long, long ); -int WINAPI glEmptyFunc24( long, long, long, long, long, long ); -int WINAPI glEmptyFunc28( long, long, long, long, long, long, long ); -int WINAPI glEmptyFunc32( long, long, long, long, long, long, long, long ); -int WINAPI glEmptyFunc36( long, long, long, long, long, long, long, long, - long ); -int WINAPI glEmptyFunc40( long, long, long, long, long, long, long, long, - long, long ); -int WINAPI glEmptyFunc44( long, long, long, long, long, long, long, long, - long, long, long ); -int WINAPI glEmptyFunc48( long, long, long, long, long, long, long, long, - long, long, long, long ); -int WINAPI glEmptyFunc52( long, long, long, long, long, long, long, long, - long, long, long, long, long ); -int WINAPI glEmptyFunc56( long, long, long, long, long, long, long, long, - long, long, long, long, long, long ); - -#ifdef OPENGL32_GL_FUNC_PROTOTYPES - -#define X(func,ret,typeargs,args,icdidx,tebidx,stack) ret WINAPI func typeargs; -GLFUNCS_MACRO -#undef X - -#endif /* OPENGL32_GL_FUNC_PROTOTYPES */ - -#ifdef __cplusplus -}; /* extern "C" */ -#endif /* __cplusplus */ - -#endif /* OPENGL32_PRIVATE_H */ - -/* EOF */ +/* 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); diff --git a/reactos/dll/opengl/opengl32/opengl32.spec b/reactos/dll/opengl/opengl32/opengl32.spec index 0547d89857c..8e393c9c292 100644 --- a/reactos/dll/opengl/opengl32/opengl32.spec +++ b/reactos/dll/opengl/opengl32/opengl32.spec @@ -4,366 +4,366 @@ @ 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 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) rosglChoosePixelFormat -@ stdcall wglCopyContext(long long long) rosglCopyContext -@ stdcall wglCreateContext(long) rosglCreateContext -@ stdcall wglCreateLayerContext(long long) rosglCreateLayerContext -@ stdcall wglDeleteContext(long) rosglDeleteContext -@ stdcall wglDescribeLayerPlane(long long long long ptr) rosglDescribeLayerPlane -@ stdcall wglDescribePixelFormat(long long long ptr) rosglDescribePixelFormat -@ stdcall wglGetCurrentContext() rosglGetCurrentContext -@ stdcall wglGetCurrentDC() rosglGetCurrentDC -@ stdcall wglGetDefaultProcAddress(ptr) rosglGetDefaultProcAddress -@ stdcall wglGetLayerPaletteEntries(long long long long ptr) rosglGetLayerPaletteEntries -@ stdcall wglGetPixelFormat(long) rosglGetPixelFormat -@ stdcall wglGetProcAddress(str) rosglGetProcAddress -@ stdcall wglMakeCurrent(long long) rosglMakeCurrent -@ stdcall wglRealizeLayerPalette(long long long) rosglRealizeLayerPalette -@ stdcall wglSetLayerPaletteEntries(long long long long ptr) rosglSetLayerPaletteEntries -@ stdcall wglSetPixelFormat(long long ptr) rosglSetPixelFormat -@ stdcall wglShareLists(long long) rosglShareLists -@ stdcall wglSwapBuffers(long) rosglSwapBuffers -@ stdcall wglSwapLayerBuffers(long long) rosglSwapLayerBuffers -@ stub wglSwapMultipleBuffers -@ 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) +@ 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) diff --git a/reactos/dll/opengl/opengl32/swimpl.c b/reactos/dll/opengl/opengl32/swimpl.c new file mode 100644 index 00000000000..c95fea07fed --- /dev/null +++ b/reactos/dll/opengl/opengl32/swimpl.c @@ -0,0 +1,835 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS + * FILE: dll/opengl/opengl32/swimpl.c + * PURPOSE: OpenGL32 DLL, opengl software implementation + */ + +#include "opengl32.h" + +/* MESA includes */ +#include
+#include
+#include
+#include
+#include
+#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +WINE_DEFAULT_DEBUG_CHANNEL(opengl32); + +#define WIDTH_BYTES_ALIGN32(cx, bpp) ((((cx) * (bpp) + 31) & ~31) >> 3) + +static const struct +{ + gl_format mesa; + BYTE color_bits; + BYTE red_bits, red_shift; DWORD red_mask; + BYTE green_bits, green_shift; DWORD green_mask; + BYTE blue_bits, blue_shift; DWORD blue_mask; + BYTE alpha_bits, alpha_shift; DWORD alpha_mask; + BYTE accum_bits; + BYTE depth_bits; + BYTE stencil_bits; + DWORD bmp_compression; +} pixel_formats[] = +{ + { MESA_FORMAT_ARGB8888, 32, 8, 8, 0x00FF0000, 8, 16, 0x0000FF00, 8, 24, 0x000000FF, 8, 0, 0xFF000000, 16, 32, 8, BI_BITFIELDS }, + { MESA_FORMAT_ARGB8888, 32, 8, 8, 0x00FF0000, 8, 16, 0x0000FF00, 8, 24, 0x000000FF, 8, 0, 0xFF000000, 16, 16, 8, BI_BITFIELDS }, + { MESA_FORMAT_RGBA8888_REV, 32, 8, 8, 0x000000FF, 8, 16, 0x0000FF00, 8, 24, 0x00FF0000, 8, 0, 0xFF000000, 16, 32, 8, BI_BITFIELDS }, + { MESA_FORMAT_RGBA8888_REV, 32, 8, 8, 0x000000FF, 8, 16, 0x0000FF00, 8, 24, 0x00FF0000, 8, 0, 0xFF000000, 16, 16, 8, BI_BITFIELDS }, + { MESA_FORMAT_RGBA8888, 32, 8, 0, 0xFF000000, 8, 8, 0x00FF0000, 8, 16, 0x0000FF00, 8, 24, 0x000000FF, 16, 32, 8, BI_BITFIELDS }, + { MESA_FORMAT_RGBA8888, 32, 8, 0, 0xFF000000, 8, 8, 0x00FF0000, 8, 16, 0x0000FF00, 8, 24, 0x000000FF, 16, 16, 8, BI_BITFIELDS }, + { MESA_FORMAT_ARGB8888_REV, 32, 8, 16, 0x0000FF00, 8, 8, 0x00FF0000, 8, 0, 0xFF000000, 8, 24, 0x000000FF, 16, 32, 8, BI_BITFIELDS }, + { MESA_FORMAT_ARGB8888_REV, 32, 8, 16, 0x0000FF00, 8, 8, 0x00FF0000, 8, 0, 0xFF000000, 8, 24, 0x000000FF, 16, 16, 8, BI_BITFIELDS }, + { MESA_FORMAT_RGB888, 24, 8, 0, 0x00000000, 8, 8, 0x00000000, 8, 16, 0x00000000, 0, 0, 0x00000000, 16, 32, 8, BI_RGB }, + { MESA_FORMAT_RGB888, 24, 8, 0, 0x00000000, 8, 8, 0x00000000, 8, 16, 0x00000000, 0, 0, 0x00000000, 16, 16, 8, BI_RGB }, + // { MESA_FORMAT_BGR888, 24, 8, 16, 8, 8, 8, 0, 0, 0, 16, 32, 8 }, + // { MESA_FORMAT_BGR888, 24, 8, 16, 8, 8, 8, 0, 0, 0, 16, 16, 8 }, + { MESA_FORMAT_RGB565, 16, 5, 0, 0x00000000, 6, 5, 0x00000000, 5, 11, 0x00000000, 0, 0, 0x00000000, 16, 32, 8, BI_BITFIELDS }, + { MESA_FORMAT_RGB565, 16, 5, 0, 0x0000F800, 6, 5, 0x000007E0, 5, 11, 0x0000001F, 0, 0, 0x00000000, 16, 16, 8, BI_BITFIELDS }, +}; + +#define SW_BACK_RENDERBUFFER_CLASS 0x8911 +#define SW_FRONT_RENDERBUFFER_CLASS 0x8910 +struct sw_front_renderbuffer +{ + struct swrast_renderbuffer swrast; + + HDC hdcmem; + GLuint x, y, w, h; + HBITMAP hbmp; + BOOL write; +}; + +#define SW_FB_DOUBLEBUFFERED 0x1 +#define SW_FB_DIRTY_SIZE 0x2 +struct sw_framebuffer +{ + HDC hdc; + INT sw_format; + UINT format_index; + DWORD flags; + /* The mesa objects */ + struct gl_config *gl_visual; /* Describes the buffers */ + struct gl_framebuffer *gl_buffer; /* The mesa representation of frame buffer */ + struct sw_front_renderbuffer frontbuffer; + struct swrast_renderbuffer backbuffer; + /* The bitmapi info we will use for rendering to display */ + BITMAPINFO bmi; +}; + +struct sw_context +{ + struct gl_context mesa; /* Base class - this must be first */ + /* This is to keep track of the size of the front buffer */ + HHOOK hook; + /* Framebuffer currently owning the context */ + struct sw_framebuffer framebuffer; +}; + +/* mesa opengl32 "driver" specific */ +static const GLubyte * +sw_get_string( struct gl_context *ctx, GLenum name ) +{ + (void) ctx; + if(name == GL_RENDERER) + return (const GLubyte *) "ReactOS Software Implementation"; + + return NULL; +} + +static void +sw_update_state( struct gl_context *ctx, GLuint new_state ) +{ + /* easy - just propogate */ + _swrast_InvalidateState( ctx, new_state ); + _swsetup_InvalidateState( ctx, new_state ); + _tnl_InvalidateState( ctx, new_state ); + _vbo_InvalidateState( ctx, new_state ); +} + +/* Renderbuffer routines */ +static GLboolean +sw_bb_renderbuffer_storage(struct gl_context* ctx, struct gl_renderbuffer *rb, + GLenum internalFormat, + GLuint width, GLuint height) +{ + struct swrast_renderbuffer *srb = swrast_renderbuffer(rb); + struct sw_framebuffer* fb = CONTAINING_RECORD(srb, struct sw_framebuffer, backbuffer); + UINT widthBytes = WIDTH_BYTES_ALIGN32(width, pixel_formats[fb->format_index].color_bits); + srb->Base.Format = pixel_formats[fb->format_index].mesa; + + if(srb->Buffer) + srb->Buffer = HeapReAlloc(GetProcessHeap(), 0, srb->Buffer, widthBytes*height); + else + srb->Buffer = HeapAlloc(GetProcessHeap(), 0, widthBytes*height); + if(!srb->Buffer) + { + srb->Base.Format = MESA_FORMAT_NONE; + return GL_FALSE; + } + srb->Base.Width = width; + srb->Base.Height = height; + srb->RowStride = widthBytes; + return GL_TRUE; +} + +static void +sw_bb_renderbuffer_delete(struct gl_renderbuffer *rb) +{ + struct swrast_renderbuffer *srb = swrast_renderbuffer(rb); + + if (srb->Buffer) + { + HeapFree(GetProcessHeap(), 0, srb->Buffer); + srb->Buffer = NULL; + } +} + +static void +sw_fb_renderbuffer_delete(struct gl_renderbuffer *rb) +{ + struct sw_front_renderbuffer* srb = (struct sw_front_renderbuffer*)rb; + + if (srb->hbmp) + { + srb->hbmp = SelectObject(srb->hdcmem, srb->hbmp); + DeleteDC(srb->hdcmem); + DeleteObject(srb->hbmp); + srb->hdcmem = NULL; + srb->hbmp = NULL; + srb->swrast.Buffer = NULL; + } +} + +static GLboolean +sw_fb_renderbuffer_storage(struct gl_context *ctx, struct gl_renderbuffer *rb, + GLenum internalFormat, + GLuint width, GLuint height) +{ + struct sw_front_renderbuffer* srb = (struct sw_front_renderbuffer*)rb; + struct sw_framebuffer* fb = CONTAINING_RECORD(srb, struct sw_framebuffer, frontbuffer); + HDC hdc = IntGetCurrentDC(); + + /* Don't bother if the size doesn't change */ + if(rb->Width == width && rb->Height == height) + return GL_TRUE; + + /* Delete every objects which could have been used before */ + sw_fb_renderbuffer_delete(&srb->swrast.Base); + + /* So the app wants to use the frontbuffer, allocate a DIB for it */ + srb->hbmp = CreateDIBSection( + hdc, + &fb->bmi, + DIB_RGB_COLORS, + (void**)&srb->swrast.Buffer, + NULL, 0); + assert(srb->hbmp); + if(!srb->hbmp) + { + ERR("Failed to create the DIB section for the front buffer, %lu.\n", GetLastError()); + return GL_FALSE; + } + /* Create the DC and attach the DIB section to it */ + srb->hdcmem = CreateCompatibleDC(hdc); + assert(srb->hdcmem != NULL); + srb->hbmp = SelectObject(srb->hdcmem, srb->hbmp); + assert(srb->hbmp != NULL); + /* Set formats, width and height */ + srb->swrast.Base.Format = pixel_formats[fb->format_index].mesa; + srb->swrast.Base.Width = width; + srb->swrast.Base.Height = height; + return GL_TRUE; +} + +static +void +sw_init_renderbuffers(struct sw_framebuffer *fb) +{ + _mesa_init_renderbuffer(&fb->frontbuffer.swrast.Base, 0); + fb->frontbuffer.swrast.Base.ClassID = SW_FRONT_RENDERBUFFER_CLASS; + fb->frontbuffer.swrast.Base.AllocStorage = sw_fb_renderbuffer_storage; + fb->frontbuffer.swrast.Base.Delete = sw_fb_renderbuffer_delete; + fb->frontbuffer.swrast.Base.InternalFormat = GL_RGBA; + fb->frontbuffer.swrast.Base._BaseFormat = GL_RGBA; + _mesa_remove_renderbuffer(fb->gl_buffer, BUFFER_FRONT_LEFT); + _mesa_add_renderbuffer(fb->gl_buffer, BUFFER_FRONT_LEFT, &fb->frontbuffer.swrast.Base); + + if(fb->flags & SW_FB_DOUBLEBUFFERED) + { + _mesa_init_renderbuffer(&fb->backbuffer.Base, 0); + fb->backbuffer.Base.ClassID = SW_BACK_RENDERBUFFER_CLASS; + fb->backbuffer.Base.AllocStorage = sw_bb_renderbuffer_storage; + fb->backbuffer.Base.Delete = sw_bb_renderbuffer_delete; + fb->backbuffer.Base.InternalFormat = GL_RGBA; + fb->backbuffer.Base._BaseFormat = GL_RGBA; + _mesa_remove_renderbuffer(fb->gl_buffer, BUFFER_BACK_LEFT); + _mesa_add_renderbuffer(fb->gl_buffer, BUFFER_BACK_LEFT, &fb->backbuffer.Base); + } + + +} + +static void +sw_MapRenderbuffer(struct gl_context *ctx, + struct gl_renderbuffer *rb, + GLuint x, GLuint y, GLuint w, GLuint h, + GLbitfield mode, + GLubyte **mapOut, GLint *rowStrideOut) +{ + if(rb->ClassID == SW_FRONT_RENDERBUFFER_CLASS) + { + /* This is our front buffer */ + struct sw_front_renderbuffer* srb = (struct sw_front_renderbuffer*)rb; + struct sw_framebuffer* fb = CONTAINING_RECORD(srb, struct sw_framebuffer, frontbuffer); + /* Set the stride */ + *rowStrideOut = WIDTH_BYTES_ALIGN32(rb->Width, pixel_formats[fb->format_index].color_bits); + /* Remember where we "mapped" */ + srb->x = x; srb->y = y; srb->w = w; srb->h = h; + /* Remember if we should write it later */ + srb->write = !!(mode & GL_MAP_WRITE_BIT); + /* Get the bits, if needed */ + if(mode & GL_MAP_READ_BIT) + { + BitBlt(srb->hdcmem, srb->x, srb->y, srb->w, srb->h, + IntGetCurrentDC(), srb->x, srb->y, SRCCOPY); + } + /* And return it */ + *mapOut = (BYTE*)srb->swrast.Buffer + *rowStrideOut*y + x*pixel_formats[fb->format_index].color_bits/8; + return; + } + + if(rb->ClassID == SW_BACK_RENDERBUFFER_CLASS) + { + /* This is our front buffer */ + struct swrast_renderbuffer* srb = (struct swrast_renderbuffer*)rb; + const GLuint bpp = _mesa_get_format_bytes(rb->Format); + /* Set the stride */ + *rowStrideOut = srb->RowStride; + *mapOut = (BYTE*)srb->Buffer + srb->RowStride*y + x*bpp; + return; + } + + /* Let mesa rasterizer take care of this */ + _swrast_map_soft_renderbuffer(ctx, rb, x, y, w, h, mode, + mapOut, rowStrideOut); +} + +static void +sw_UnmapRenderbuffer(struct gl_context *ctx, struct gl_renderbuffer *rb) +{ + if (rb->ClassID== SW_FRONT_RENDERBUFFER_CLASS) + { + /* This is our front buffer */ + struct sw_front_renderbuffer* srb = (struct sw_front_renderbuffer*)rb; + if(srb->write) + { + /* Copy the bits to our display */ + BitBlt(IntGetCurrentDC(), + srb->x, srb->y, srb->w, srb->h, + srb->hdcmem, srb->x, srb->y, SRCCOPY); + srb->write = FALSE; + } + return; + } + + if(rb->ClassID == SW_BACK_RENDERBUFFER_CLASS) + return; /* nothing to do */ + + /* Let mesa rasterizer take care of this */ + _swrast_unmap_soft_renderbuffer(ctx, rb); +} + +/* WGL <-> mesa glue */ +static UINT index_from_format(struct wgl_dc_data* dc_data, INT format, BOOL* doubleBuffered) +{ + UINT index; + INT 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; indexowner.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; + INT 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 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(HDC hdc, struct wgl_dc_data* dc_data, INT format) +{ + struct sw_framebuffer* fb; + BOOL doubleBuffered; + + assert(dc_data->sw_data == NULL); + + /* So, someone is crazy enough to ask for sw implementation. Announce it. */ + TRACE("OpenGL software implementation START!\n"); + + /* allocate our structure */ + fb = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, FIELD_OFFSET(struct sw_framebuffer, bmi.bmiColors[2])); + 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; + /* Set the bitmap info describing the framebuffer */ + fb->bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + fb->bmi.bmiHeader.biPlanes = 1; + fb->bmi.bmiHeader.biBitCount = pixel_formats[fb->format_index].color_bits; + fb->bmi.bmiHeader.biCompression = pixel_formats[fb->format_index].bmp_compression; + 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; + *((DWORD*)&fb->bmi.bmiColors[0]) = pixel_formats[fb->format_index].red_mask; + *((DWORD*)&fb->bmi.bmiColors[1]) = pixel_formats[fb->format_index].green_mask; + *((DWORD*)&fb->bmi.bmiColors[2]) = pixel_formats[fb->format_index].blue_mask; + /* Save the HDC */ + fb->hdc = hdc; + + /* Allocate the visual structure describing the format */ + fb->gl_visual = _mesa_create_visual( + !!(fb->flags & SW_FB_DOUBLEBUFFERED), + GL_FALSE, /* No stereoscopic support */ + pixel_formats[fb->format_index].red_bits, + pixel_formats[fb->format_index].green_bits, + pixel_formats[fb->format_index].blue_bits, + pixel_formats[fb->format_index].alpha_bits, + pixel_formats[fb->format_index].depth_bits, + pixel_formats[fb->format_index].stencil_bits, + pixel_formats[fb->format_index].accum_bits, + pixel_formats[fb->format_index].accum_bits, + pixel_formats[fb->format_index].accum_bits, + pixel_formats[fb->format_index].alpha_bits ? + pixel_formats[fb->format_index].accum_bits : 0, + 1 /* One sampling level */); + + if(!fb->gl_visual) + { + ERR("Failed to allocate a GL visual.\n"); + HeapFree(GetProcessHeap(), 0, fb); + return FALSE; + } + + /* Allocate the framebuffer structure */ + fb->gl_buffer = _mesa_create_framebuffer(fb->gl_visual); + if (!fb->gl_buffer) { + ERR("Failed to allocate the mesa framebuffer structure.\n"); + _mesa_destroy_visual( fb->gl_visual ); + HeapFree(GetProcessHeap(), 0, fb); + return FALSE; + } + + /* Add the depth/stencil/accum buffers */ + _swrast_add_soft_renderbuffers(fb->gl_buffer, + GL_FALSE, /* color */ + fb->gl_visual->haveDepthBuffer, + fb->gl_visual->haveStencilBuffer, + fb->gl_visual->haveAccumBuffer, + GL_FALSE, /* alpha */ + GL_FALSE /* aux */ ); + + /* Initialize our render buffers */ + sw_init_renderbuffers(fb); + + /* Everything went fine */ + dc_data->sw_data = fb; + return TRUE; +} + +DHGLRC sw_CreateContext(struct wgl_dc_data* dc_data) +{ + struct sw_context* sw_ctx; + struct sw_framebuffer* fb = dc_data->sw_data; + struct dd_function_table mesa_drv_functions; + TNLcontext *tnl; + + /* We use the mesa memory routines for this function */ + sw_ctx = CALLOC_STRUCT(sw_context); + if(!sw_ctx) + return NULL; + + /* Set mesa default functions */ + _mesa_init_driver_functions(&mesa_drv_functions); + /* Override */ + mesa_drv_functions.GetString = sw_get_string; + mesa_drv_functions.UpdateState = sw_update_state; + mesa_drv_functions.GetBufferSize = NULL; + + /* Initialize the context */ + if(!_mesa_initialize_context(&sw_ctx->mesa, + API_OPENGL, + fb->gl_visual, + NULL, + &mesa_drv_functions, + (void *) sw_ctx)) + { + ERR("Failed to initialize the mesa context.\n"); + free(sw_ctx); + return NULL; + } + + /* Initialize the "meta driver" */ + _mesa_meta_init(&sw_ctx->mesa); + + /* Initialize helpers */ + if(!_swrast_CreateContext(&sw_ctx->mesa) || + !_vbo_CreateContext(&sw_ctx->mesa) || + !_tnl_CreateContext(&sw_ctx->mesa) || + !_swsetup_CreateContext(&sw_ctx->mesa)) + { + _mesa_free_context_data(&sw_ctx->mesa); + free(sw_ctx); + return NULL; + } + + /* Wake up! */ + _swsetup_Wakeup(&sw_ctx->mesa); + + /* Use TnL defaults */ + tnl = TNL_CONTEXT(&sw_ctx->mesa); + tnl->Driver.RunPipeline = _tnl_run_pipeline; + + /* To map the display into user memory */ + sw_ctx->mesa.Driver.MapRenderbuffer = sw_MapRenderbuffer; + sw_ctx->mesa.Driver.UnmapRenderbuffer = sw_UnmapRenderbuffer; + + return (DHGLRC)sw_ctx; +} + +BOOL sw_DeleteContext(DHGLRC dhglrc) +{ + struct sw_context* sw_ctx = (struct sw_context*)dhglrc; + /* Those get clobbered by _mesa_free_context_data via _glapi_set{context,dispath_table} */ + void* icd_save = IntGetCurrentICDPrivate(); + const GLDISPATCHTABLE* table_save = IntGetCurrentDispatchTable(); + + /* Destroy everything */ + _mesa_meta_free( &sw_ctx->mesa ); + + _swsetup_DestroyContext( &sw_ctx->mesa ); + _tnl_DestroyContext( &sw_ctx->mesa ); + _vbo_DestroyContext( &sw_ctx->mesa ); + _swrast_DestroyContext( &sw_ctx->mesa ); + + _mesa_free_context_data( &sw_ctx->mesa ); + free( sw_ctx ); + + /* Restore this */ + IntSetCurrentDispatchTable(table_save); + IntSetCurrentICDPrivate(icd_save); + + return TRUE; +} + +PROC sw_GetProcAddress(LPCSTR name) +{ + /* We don't support any extensions */ + assert(FALSE); + return NULL; +} + +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) +{ + struct sw_context* sw_ctx_src = (struct sw_context*)dhglrcSrc; + struct sw_context* sw_ctx_dst = (struct sw_context*)dhglrcDst; + + /* See if it was already shared */ + if(sw_ctx_dst->mesa.Shared->RefCount > 1) + return FALSE; + + /* Unreference the old, share the new */ + _mesa_reference_shared_state(&sw_ctx_dst->mesa, + &sw_ctx_dst->mesa.Shared, + sw_ctx_src->mesa.Shared); + + return TRUE; +} + +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; + 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; + /* Update framebuffer size */ + fb->bmi.bmiHeader.biWidth = width; + fb->bmi.bmiHeader.biHeight = height; + /* Propagate to mesa */ + _mesa_resize_framebuffer(&ctx->mesa, fb->gl_buffer, width, height); + } + } + +end: + return CallNextHookEx(ctx->hook, nCode, wParam, lParam); +} + +BOOL sw_SetContext(struct wgl_dc_data* dc_data, DHGLRC dhglrc) +{ + struct sw_context* sw_ctx = (struct sw_context*)dhglrc; + struct sw_framebuffer* fb = dc_data->sw_data; + UINT width, height; + + /* Update state */ + sw_update_state(&sw_ctx->mesa, 0); + + /* Get framebuffer size */ + 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 FALSE; + } + if(!GetClientRect(hwnd, &client_rect)) + { + ERR("GetClientRect failed!\n"); + return FALSE; + } + /* This is a physical DC. Setup the hook */ + sw_ctx->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 FALSE; + } + if(GetObject(hbmp, sizeof(bm), &bm) == 0) + { + ERR("GetObject failed!\n"); + return FALSE; + } + width = bm.bmWidth; + height = bm.bmHeight; + } + + if(!width) width = 1; + if(!height) height = 1; + + fb->bmi.bmiHeader.biWidth = width; + fb->bmi.bmiHeader.biHeight = height; + + /* Also make the mesa context current to mesa */ + if(!_mesa_make_current(&sw_ctx->mesa, fb->gl_buffer, fb->gl_buffer)) + { + ERR("_mesa_make_current filaed!\n"); + return FALSE; + } + + /* update the framebuffer size */ + _mesa_resize_framebuffer(&sw_ctx->mesa, fb->gl_buffer, width, height); + + /* We're good */ + return TRUE; +} + +void sw_ReleaseContext(DHGLRC dhglrc) +{ + struct sw_context* sw_ctx = (struct sw_context*)dhglrc; + + /* Forward to mesa */ + _mesa_make_current(NULL, NULL, NULL); + + /* Unhook */ + if(sw_ctx->hook) + { + UnhookWindowsHookEx(sw_ctx->hook); + sw_ctx->hook = NULL; + } +} + +BOOL sw_SwapBuffers(HDC hdc, struct wgl_dc_data* dc_data) +{ + struct sw_framebuffer* fb = dc_data->sw_data; + struct sw_context* sw_ctx = (struct sw_context*)IntGetCurrentDHGLRC(); + + /* Notify mesa */ + if(sw_ctx) + _mesa_notifySwapBuffers(&sw_ctx->mesa); + + if(!(fb->flags & SW_FB_DOUBLEBUFFERED)) + return TRUE; + + /* Upload to the display */ + return (SetDIBitsToDevice(hdc, + 0, + 0, + fb->bmi.bmiHeader.biWidth, + fb->bmi.bmiHeader.biHeight, + 0, + 0, + 0, + fb->bmi.bmiHeader.biWidth, + fb->backbuffer.Buffer, + &fb->bmi, + DIB_RGB_COLORS) != 0); +} + +/* mesa threading glue */ +void* _glapi_Context = NULL; +struct _glapi_table *_glapi_Dispatch = NULL; + +void* _glapi_get_context() +{ + return IntGetCurrentICDPrivate(); +} + +struct _glapi_table * +_glapi_get_dispatch(void) +{ + return (struct _glapi_table *)IntGetCurrentDispatchTable(); +} + +void _glapi_set_dispatch(struct _glapi_table * table) +{ + IntSetCurrentDispatchTable((const GLDISPATCHTABLE*)table); +} + +unsigned int +_glapi_get_dispatch_table_size(void) +{ + return OPENGL_VERSION_110_ENTRIES; +} + +void +_glapi_set_context(void *context) +{ + /* + * It happens that mesa changes the context, most notably on context deletion. + * Use the space reserved to the ICD for this. + */ + IntSetCurrentICDPrivate(context); +} diff --git a/reactos/dll/opengl/opengl32/wgl.c b/reactos/dll/opengl/opengl32/wgl.c index fe4942e0601..7cd0e3e3bf5 100644 --- a/reactos/dll/opengl/opengl32/wgl.c +++ b/reactos/dll/opengl/opengl32/wgl.c @@ -1,1248 +1,883 @@ /* * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS kernel - * FILE: lib/opengl32/wgl.c - * PURPOSE: OpenGL32 lib, rosglXXX functions - * PROGRAMMER: Anich Gregor (blight) - * UPDATE HISTORY: - * Feb 2, 2004: Created + * PROJECT: ReactOS + * FILE: dll/opengl/opengl32/wgl.c + * PURPOSE: OpenGL32 DLL, WGL functions */ -#define OPENGL32_GL_FUNC_PROTOTYPES #include "opengl32.h" -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ +#include -#if !defined(UNIMPLEMENTED) -# define UNIMPLEMENTED DBGPRINT( "UNIMPLEMENTED" ) -#endif +#include +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; -typedef struct _OPENGL_INFO -{ - DWORD Version; /*!< Driver interface version */ - DWORD DriverVersion; /*!< Driver version */ - WCHAR DriverName[256]; /*!< Driver name */ -} OPENGL_INFO, *POPENGL_INFO; - -/*! \brief Append OpenGL Rendering Context (GLRC) to list - * - * \param glrc [IN] Pointer to GLRC to append to list - */ +/* FIXME: suboptimal */ static -void -ROSGL_AppendContext( GLRC *glrc ) +struct wgl_dc_data* +get_dc_data(HDC hdc) { - /* synchronize */ - if (WaitForSingleObject( OPENGL32_processdata.glrc_mutex, INFINITE ) == - WAIT_FAILED) + HWND hwnd = NULL; + struct wgl_dc_data* data; + DWORD objType = GetObjectType(hdc); + ULONG flags = 0; + union { - DBGPRINT( "Error: WaitForSingleObject() failed (%d)", GetLastError() ); - return; /* FIXME: do we have to expect such an error and handle it? */ - } - - if (OPENGL32_processdata.glrc_list == NULL) - OPENGL32_processdata.glrc_list = glrc; - else - { - GLRC *p = OPENGL32_processdata.glrc_list; - while (p->next != NULL) - p = p->next; - p->next = glrc; - } - - /* release mutex */ - if (!ReleaseMutex( OPENGL32_processdata.glrc_mutex )) - DBGPRINT( "Error: ReleaseMutex() failed (%d)", GetLastError() ); -} - - -/*! \brief Remove OpenGL Rendering Context (GLRC) from list - * - * \param glrc [IN] Pointer to GLRC to remove from list - */ -static -void -ROSGL_RemoveContext( GLRC *glrc ) -{ - /* synchronize */ - if (WaitForSingleObject( OPENGL32_processdata.glrc_mutex, INFINITE ) == - WAIT_FAILED) - { - DBGPRINT( "Error: WaitForSingleObject() failed (%d)", GetLastError() ); - return; /* FIXME: do we have to expect such an error and handle it? */ - } - - if (glrc == OPENGL32_processdata.glrc_list) - OPENGL32_processdata.glrc_list = glrc->next; - else - { - GLRC *p = OPENGL32_processdata.glrc_list; - while (p != NULL) - { - if (p->next == glrc) - { - p->next = glrc->next; - break; - } - p = p->next; - } - if (p == NULL) - DBGPRINT( "Error: GLRC 0x%08x not found in list!", glrc ); - } - - /* release mutex */ - if (!ReleaseMutex( OPENGL32_processdata.glrc_mutex )) - DBGPRINT( "Error: ReleaseMutex() failed (%d)", GetLastError() ); -} - - -/*! \brief Create a new GL Context (GLRC) and append it to the list - * - * \return Pointer to new GLRC on success - * \retval NULL Returned on failure (i.e. Out of memory) - */ -static -GLRC * -ROSGL_NewContext(void) -{ - GLRC *glrc; - - /* allocate GLRC */ - glrc = (GLRC*)HeapAlloc( GetProcessHeap(), - HEAP_ZERO_MEMORY | HEAP_GENERATE_EXCEPTIONS, sizeof (GLRC) ); - - /* append to list */ - ROSGL_AppendContext( glrc ); - - return glrc; -} - -/*! \brief Delete all GLDCDATA with this IDC - * - * \param icd [IN] Pointer to a ICD - */ -static -VOID -ROSGL_DeleteDCDataForICD( GLDRIVERDATA *icd ) -{ - GLDCDATA *p, **pptr; + HWND hwnd; + HDC hdc; + HANDLE u; + } id; - return; - - /* synchronize */ - if (WaitForSingleObject( OPENGL32_processdata.dcdata_mutex, INFINITE ) == - WAIT_FAILED) + /* Look for the right data identifier */ + if(objType == OBJ_DC) { - DBGPRINT( "Error: WaitForSingleObject() failed (%d)", GetLastError() ); - return; + 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; } - p = OPENGL32_processdata.dcdata_list; - pptr = &OPENGL32_processdata.dcdata_list; - while (p != NULL) + EnterCriticalSection(&dc_data_cs); + data = dc_data_list; + while(data) { - if (p->icd == icd) + if(data->owner.u == id.u) { - *pptr = p->next; - OPENGL32_UnloadICD( p->icd ); - - if (!HeapFree( GetProcessHeap(), 0, p )) - DBGPRINT( "Warning: HeapFree() on GLDCDATA failed (%d)", - GetLastError() ); - - p = *pptr; + LeaveCriticalSection(&dc_data_cs); + return data; } - else - { - pptr = &p->next; - p = p->next; - } - } - - /* release mutex */ - if (!ReleaseMutex( OPENGL32_processdata.dcdata_mutex )) - DBGPRINT( "Error: ReleaseMutex() failed (%d)", GetLastError() ); -} - - -/*! \brief Delete a GL Context (GLRC) and remove it from the list - * - * \param glrc [IN] Pointer to GLRC to delete - * - * \retval TRUE Success - * \retval FALSE Failure - */ -static -BOOL -ROSGL_DeleteContext( GLRC *glrc ) -{ - /* unload icd */ - if ((glrc->icd != NULL) && (!InterlockedDecrement((LONG*)&glrc->icd->refcount))) - { - /* This is the last context, remove the ICD*/ - ROSGL_DeleteDCDataForICD( glrc->icd ); - } - - /* remove from list */ - ROSGL_RemoveContext( glrc ); - - /* free memory */ - HeapFree( GetProcessHeap(), 0, glrc ); - - return TRUE; -} - - -/*! \brief Check wether a GLRC is in the list - * - * \param glrc [IN] Pointer to GLRC to look for in the list - * - * \retval TRUE GLRC was found - * \retval FALSE GLRC was not found - */ -static -BOOL -ROSGL_ContainsContext( GLRC *glrc ) -{ - GLRC *p; - BOOL found = FALSE; - - /* synchronize */ - if (WaitForSingleObject( OPENGL32_processdata.glrc_mutex, INFINITE ) == - WAIT_FAILED) - { - DBGPRINT( "Error: WaitForSingleObject() failed (%d)", GetLastError() ); - return FALSE; /* FIXME: do we have to expect such an error and handle it? */ - } - - p = OPENGL32_processdata.glrc_list; - while (p != NULL) - { - if (p == glrc) - { - found = TRUE; - break; - } - p = p->next; - } - - /* release mutex */ - if (!ReleaseMutex( OPENGL32_processdata.glrc_mutex )) - DBGPRINT( "Error: ReleaseMutex() failed (%d)", GetLastError() ); - - return found; -} - - -/*! \brief Get GL private DC data. - * - * This function adds an empty GLDCDATA to the list if there is no data for the - * given DC yet. - * - * \param hdc [IN] Handle to a Device Context for which to get the data - * - * \return Pointer to GLDCDATA on success - * \retval NULL on failure - */ -static -GLDCDATA * -ROSGL_GetPrivateDCData( HDC hdc ) -{ - GLDCDATA *data; - HANDLE handle; - - /* check hdc */ - if (GetObjectType( hdc ) != OBJ_DC && GetObjectType( hdc ) != OBJ_MEMDC) - { - DBGPRINT( "Error: hdc is not a DC handle!" ); - SetLastError( ERROR_INVALID_HANDLE ); - return FALSE; - } - - /* synchronize */ - if (WaitForSingleObject( OPENGL32_processdata.dcdata_mutex, INFINITE ) == - WAIT_FAILED) - { - DBGPRINT( "Error: WaitForSingleObject() failed (%d)", GetLastError() ); - return NULL; /* FIXME: do we have to expect such an error and handle it? */ - } - - /* We must use the window to identify our data, as pixel format is - * specific to a window for device context */ - handle = WindowFromDC(hdc); - if(!handle) - handle = hdc; - - /* look for data in list */ - data = OPENGL32_processdata.dcdata_list; - while (data != NULL) - { - if (data->handle == handle) /* found */ - break; data = data->next; } - - /* allocate new data if not found in list */ - if (data == NULL) + data= HeapAlloc(GetProcessHeap(), 0, sizeof(*data)); + if(!data) { - data = HeapAlloc( GetProcessHeap(), - HEAP_ZERO_MEMORY | HEAP_GENERATE_EXCEPTIONS, - sizeof (GLDCDATA) ); - if (data == NULL) - { - DBGPRINT( "Error: HeapAlloc() failed (%d)", GetLastError() ); - } - else - { - data->handle = handle; - - /* append data to list */ - if (OPENGL32_processdata.dcdata_list == NULL) - OPENGL32_processdata.dcdata_list = data; - else - { - GLDCDATA *p = OPENGL32_processdata.dcdata_list; - while (p->next != NULL) - p = p->next; - p->next = data; - } - } + LeaveCriticalSection(&dc_data_cs); + return NULL; } - - /* release mutex */ - if (!ReleaseMutex( OPENGL32_processdata.dcdata_mutex )) - DBGPRINT( "Error: ReleaseMutex() failed (%d)", GetLastError() ); - + /* initialize the structure */ + data->owner.u = id.u; + data->flags = flags; + data->pixelformat = 0; + data->sw_data = NULL; + /* 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; } - -/*! \brief Get ICD from HDC. - * - * This function asks the display driver which OpenGL ICD to load for the given - * HDC, loads it and returns a pointer to a GLDRIVERDATA struct on success. - * - * \param hdc [IN] Handle for DC for which to load/get the ICD - * - * \return Pointer to GLDRIVERDATA - * \retval NULL Failure. - */ -static -GLDRIVERDATA * -ROSGL_ICDForHDC( HDC hdc ) +void release_dc_data(struct wgl_dc_data* dc_data) { - GLDCDATA *dcdata; - GLDRIVERDATA *drvdata; - - dcdata = ROSGL_GetPrivateDCData( hdc ); - if (dcdata == NULL) - return NULL; - - if (dcdata->icd == NULL) - { - LPCWSTR driverName; - OPENGL_INFO info; - - /* NOTE: This might be done by multiple threads simultaneously, but only the fastest - actually gets to set the ICD! */ - - driverName = _wgetenv( L"OPENGL32_DRIVER" ); - if (driverName == NULL) - { - DWORD dwInput; - LONG ret; - - /* get driver name */ - dwInput = OPENGL_GETINFO; - ret = ExtEscape( hdc, QUERYESCSUPPORT, sizeof (dwInput), (LPCSTR)&dwInput, 0, NULL ); - if (ret > 0) - { - dwInput = 0; - ret = ExtEscape( hdc, OPENGL_GETINFO, sizeof (dwInput), - (LPCSTR)&dwInput, sizeof (OPENGL_INFO), - (LPSTR)&info ); - } - if (ret <= 0) - { - HKEY hKey; - DWORD type, size; - - if (ret < 0) - { - DBGPRINT( "Warning: ExtEscape to get the drivername failed! (%d)", GetLastError() ); - if (MessageBox( WindowFromDC( hdc ), L"Couldn't get installable client driver name!\nUsing default driver.", - L"OPENGL32.dll: Warning", MB_OKCANCEL | MB_ICONWARNING ) == IDCANCEL) - { - return NULL; - } - } - - /* open registry key */ - ret = RegOpenKeyExW( HKEY_LOCAL_MACHINE, OPENGL_DRIVERS_SUBKEY, 0, KEY_QUERY_VALUE, &hKey ); - if (ret != ERROR_SUCCESS) - { - DBGPRINT( "Error: Couldn't open registry key '%ws'", OPENGL_DRIVERS_SUBKEY ); - SetLastError( ret ); - return NULL; - } - - /* query value */ - size = sizeof (info.DriverName); - ret = RegQueryValueExW( hKey, L"DefaultDriver", 0, &type, (LPBYTE)info.DriverName, &size ); - RegCloseKey( hKey ); - if (ret != ERROR_SUCCESS || type != REG_SZ) - { - DBGPRINT( "Error: Couldn't query DefaultDriver value or not a string" ); - SetLastError( ret ); - return NULL; - } - } - } - else - { - wcsncpy( info.DriverName, driverName, sizeof (info.DriverName) / sizeof (info.DriverName[0]) ); - } - /* load driver (or get a reference) */ - drvdata = OPENGL32_LoadICD( info.DriverName ); - if (drvdata == NULL) - { - WCHAR Buffer[256]; - snwprintf(Buffer, sizeof(Buffer)/sizeof(WCHAR), - L"Couldn't load driver \"%s\".", info.DriverName); - MessageBox(WindowFromDC( hdc ), Buffer, - L"OPENGL32.dll: Warning", - MB_OK | MB_ICONWARNING); - } - else - { - /* Atomically set the ICD!!! */ - if (InterlockedCompareExchangePointer((PVOID*)&dcdata->icd, - (PVOID)drvdata, - NULL) != NULL) - { - /* Too bad, somebody else was faster... */ - DBGTRACE("ICD is already set!\n"); - } - } - } - - return dcdata->icd; + (void)dc_data; } - -/*! \brief SetContextCallBack passed to DrvSetContext. - * - * This function gets called by the OpenGL driver whenever the current GL - * context (dispatch table) is to be changed. - * - * \param table [IN] Function pointer table (first DWORD is number of functions) - * - * \return unkown (maybe void? ERROR_SUCCESS at the moment) - */ -DWORD -CALLBACK -ROSGL_SetContextCallBack( const ICDTable *table ) +struct wgl_context* get_context(HGLRC hglrc) { - TEB *teb; - PROC *tebTable, *tebDispatchTable; - INT size; - - teb = NtCurrentTeb(); - tebTable = (PROC *)teb->glTable; - tebDispatchTable = (PROC *)teb->glDispatchTable; - - DBGTRACE( "Called!" ); - - if (table != NULL) + struct wgl_context* context = (struct wgl_context*)hglrc; + + if(!hglrc) + return NULL; + + _SEH2_TRY { - DBGPRINT( "Function count: %d\n", table->num_funcs ); + if(context->magic != 'GLRC') + context = NULL; + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + context = NULL; + } + _SEH2_END; + + return context; +} - /* save table */ - size = sizeof (PROC) * table->num_funcs; - memcpy( tebTable, table->dispatch_table, size ); - memset( tebTable + table->num_funcs, 0, DISPATCH_TABLE_SIZE - size ); +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 { - DBGPRINT( "Unsetting current context" ); - memset( tebTable, 0, DISPATCH_TABLE_SIZE ); - } - - /* put in empty functions as long as we dont have a fallback */ - #define X(func, ret, typeargs, args, icdidx, tebidx, stack) \ - if (tebTable[icdidx] == NULL) \ - { \ - if (table != NULL) \ - DBGPRINT( "Warning: GL proc '%s' is NULL", #func ); \ - tebTable[icdidx] = (PROC)glEmptyFunc##stack; \ + /* This is a software format */ + format -= dc_data->nb_icd_formats; + if(!sw_DescribePixelFormat(hdc, format, size, descr)) + { + ret = 0; } - GLFUNCS_MACRO -#undef X - - /* fill teb->glDispatchTable for fast calls */ -#define X(func, ret, typeargs, args, icdidx, tebidx, stack) \ - if (tebidx >= 0) \ - tebDispatchTable[tebidx] = tebTable[icdidx]; - GLFUNCS_MACRO -#undef X - - DBGPRINT( "Done." ); - - return ERROR_SUCCESS; + } + + release_dc_data(dc_data); + return ret; } - -/*! \brief Returns the current pixelformat. - * - * \param hdc [IN] Handle to DC to get the pixelformat from - * - * \return Pixelformat index - * \retval 0 Failure - */ -int -WINAPI -rosglGetPixelFormat( HDC hdc ) +INT WINAPI wglChoosePixelFormat(HDC hdc, const PIXELFORMATDESCRIPTOR* ppfd) { - GLDCDATA *dcdata; + PIXELFORMATDESCRIPTOR format, best; + int i, count, best_format; + int bestDBuffer = -1, bestStereo = -1; - DBGTRACE( "Called!" ); + 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 ); - dcdata = ROSGL_GetPrivateDCData( hdc ); - if (dcdata == NULL) + 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++) { - DBGPRINT( "Error: ROSGL_GetPrivateDCData failed!" ); - return 0; - } + if (!wglDescribePixelFormat( hdc, i, sizeof(format), &format )) continue; - return dcdata->pixel_format; -} - - -/*! \brief Attempts to find the best matching pixel format for HDC - * - * This function is comparing each available format with the preferred one - * and returns the one which is closest to it. - * If PFD_DOUBLEBUFFER, PFD_STEREO or one of PFD_DRAW_TO_WINDOW, - * PFD_DRAW_TO_BITMAP, PFD_SUPPORT_GDI and PDF_SUPPORT_OPENGL is given then - * only formats which also support those will be enumerated (unless - * PFD_DOUBLEBUFFER_DONTCARE or PFD_STEREO_DONTCARE is also set) - * - * \param hdc [IN] Handle to DC for which to get a pixel format index - * \param pfd [IN] PFD describing what kind of format you want - * - * \return Pixel format index - * \retval 0 Failed to find a suitable format - */ -#define BUFFERDEPTH_SCORE(want, have) \ - ((want == 0) ? (0) : ((want < have) ? (1) : ((want > have) ? (3) : (0)))) - -/* Score if we want and not have it */ -#define FLAG_SCORE(want, have, flag) \ - (((want & ~have) & flag) ? (1) : (0)) - -/* Score if what we want is different than what we have, except when - _DONTCARE was set */ -#define FLAG_SCORE_DONTCARE(want, have, flag) \ - ((!(have & flag ## _DONTCARE)) && ((want & flag) != (have & flag)) ? (1) : (0)) - -int -APIENTRY -rosglChoosePixelFormat( HDC hdc, CONST PIXELFORMATDESCRIPTOR *pfd ) -{ - GLDRIVERDATA *icd; - PIXELFORMATDESCRIPTOR icdPfd; - int i; - int best = 0; - int score, bestScore = 0x7fff; /* used to choose a pfd if no exact match */ - int icdNumFormats; - - DBGTRACE( "Called!" ); - - /* load ICD */ - icd = ROSGL_ICDForHDC( hdc ); - if (icd == NULL) - return 0; - - /* check input */ - if (pfd->nSize != sizeof (PIXELFORMATDESCRIPTOR) || pfd->nVersion != 1) - { - SetLastError( ERROR_INVALID_PARAMETER ); - return 0; - } - - /* get number of formats */ - icdNumFormats = icd->DrvDescribePixelFormat( hdc, 1, - sizeof (PIXELFORMATDESCRIPTOR), &icdPfd ); - if (icdNumFormats == 0) - { - DBGPRINT( "Error: DrvDescribePixelFormat failed (%d)", GetLastError() ); - return 0; - } - DBGPRINT( "Info: Enumerating %d pixelformats", icdNumFormats ); - - /* try to find best format */ - for (i = 0; i < icdNumFormats; i++) - { - if (icd->DrvDescribePixelFormat( hdc, i + 1, - sizeof (PIXELFORMATDESCRIPTOR), &icdPfd ) == 0) - { - DBGPRINT( "Warning: DrvDescribePixelFormat failed (%d)", - GetLastError() ); - break; - } - - if ((pfd->dwFlags & PFD_GENERIC_ACCELERATED) != 0) /* we do not support such kind of drivers */ + if (ppfd->iPixelType != format.iPixelType) { + TRACE( "pixel type mismatch for iPixelFormat=%d\n", i ); continue; } - score = 0; /* higher is worse */ - - /* compare flags */ - score += FLAG_SCORE(pfd->dwFlags, icdPfd.dwFlags, PFD_DRAW_TO_WINDOW); - score += FLAG_SCORE(pfd->dwFlags, icdPfd.dwFlags, PFD_DRAW_TO_BITMAP); - score += FLAG_SCORE(pfd->dwFlags, icdPfd.dwFlags, PFD_SUPPORT_GDI); - score += FLAG_SCORE(pfd->dwFlags, icdPfd.dwFlags, PFD_SUPPORT_OPENGL); - score += FLAG_SCORE_DONTCARE(pfd->dwFlags, icdPfd.dwFlags, PFD_DOUBLEBUFFER); - score += FLAG_SCORE_DONTCARE(pfd->dwFlags, icdPfd.dwFlags, PFD_STEREO); - - /* check other attribs */ - if (pfd->iPixelType != icdPfd.iPixelType) - score += 5; /* this is really bad i think */ - if (pfd->iLayerType != icdPfd.iLayerType) - score += 15; /* this is very very bad ;) */ - - score += BUFFERDEPTH_SCORE(pfd->cAlphaBits, icdPfd.cAlphaBits); - score += BUFFERDEPTH_SCORE(pfd->cAccumBits, icdPfd.cAccumBits); - score += BUFFERDEPTH_SCORE(pfd->cDepthBits, icdPfd.cDepthBits); - score += BUFFERDEPTH_SCORE(pfd->cStencilBits, icdPfd.cStencilBits); - score += BUFFERDEPTH_SCORE(pfd->cAuxBuffers, icdPfd.cAuxBuffers); - - /* check score */ - if (score < bestScore) + /* only use bitmap capable for formats for bitmap rendering */ + if( (ppfd->dwFlags & PFD_DRAW_TO_BITMAP) != (format.dwFlags & PFD_DRAW_TO_BITMAP)) { - bestScore = score; - best = i + 1; - if (bestScore == 0) - break; + 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; } - if (best == 0) - SetLastError( 0 ); /* FIXME: set appropriate error */ - - DBGPRINT( "Info: Suggesting pixelformat %d", best ); - return best; + TRACE( "returning %u\n", best_format ); + return best_format; } - -/*! \brief Copy data specified by mask from one GLRC to another. - * - * \param src [IN] Source GLRC - * \param src [OUT] Destination GLRC - * \param mask [IN] Bitfield like given to glPushAttrib() - * - * \retval TRUE Success - * \retval FALSE Failure - */ -BOOL -APIENTRY -rosglCopyContext( HGLRC hsrc, HGLRC hdst, UINT mask ) +BOOL WINAPI wglCopyContext(HGLRC hglrcSrc, HGLRC hglrcDst, UINT mask) { - GLRC *src = (GLRC *)hsrc; - GLRC *dst = (GLRC *)hdst; - - /* check glrcs */ - if (!ROSGL_ContainsContext( src )) + struct wgl_context* ctx_src = get_context(hglrcSrc); + struct wgl_context* ctx_dst = get_context(hglrcDst); + + if(!ctx_src || !ctx_dst) { - DBGPRINT( "Error: src GLRC not found!" ); - SetLastError( ERROR_INVALID_HANDLE ); + SetLastError(ERROR_INVALID_HANDLE); return FALSE; } - if (!ROSGL_ContainsContext( dst )) + + /* Check this is the same pixel format */ + if((ctx_dst->icd_data != ctx_src->icd_data) || + (ctx_dst->pixelformat != ctx_src->pixelformat)) { - DBGPRINT( "Error: dst GLRC not found!" ); - SetLastError( ERROR_INVALID_HANDLE ); + SetLastError(ERROR_INVALID_PIXEL_FORMAT); return FALSE; } - - /* I think this is only possible within one ICD */ - if (src->icd != dst->icd) - { - DBGPRINT( "Error: src and dst GLRC use different ICDs!" ); - SetLastError( ERROR_INVALID_HANDLE ); - return FALSE; - } - - /* copy data (call ICD) */ - return src->icd->DrvCopyContext( src->hglrc, dst->hglrc, mask ); + + 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); } - -/*! \brief Create a new GL Rendering Context. - * - * This function can create over- or underlay surfaces. - * - * \param hdc [IN] Handle for DC for which to create context - * \param layer [IN] Layer number to bind (draw?) to - * - * \return Handle for the created GLRC - * \retval NULL Failure - */ -HGLRC -APIENTRY -rosglCreateLayerContext( HDC hdc, int layer ) +HGLRC WINAPI wglCreateContext(HDC hdc) { - GLDRIVERDATA *icd = NULL; - GLRC *glrc; - HGLRC drvHglrc = NULL; - - DBGTRACE( "Called!" ); - -/* if (GetObjectType( hdc ) != OBJ_DC) + struct wgl_dc_data* dc_data = get_dc_data(hdc); + struct wgl_context* context; + DHGLRC dhglrc; + + TRACE("Creating context for %p, format %i\n", hdc); + + if(!dc_data) { - DBGPRINT( "Error: hdc is not a DC handle!" ); + WARN("Not a DC handle!\n"); + SetLastError(ERROR_INVALID_HANDLE); return NULL; } -*/ - - /* load ICD */ - icd = ROSGL_ICDForHDC( hdc ); - if (icd == NULL) + + if(!dc_data->pixelformat) { - DBGPRINT( "Couldn't get ICD by HDC :-(" ); - /* FIXME: fallback? */ - return NULL; - } - - /* create new GLRC */ - glrc = ROSGL_NewContext(); - if (glrc == NULL) - return NULL; - - /* Don't forget to refcount it, icd will be released when last context is deleted */ - InterlockedIncrement((LONG*)&icd->refcount); - - /* You can't create a context without first setting a valid pixel format */ - if(rosglGetPixelFormat(hdc) == 0) - { - ROSGL_DeleteContext( glrc ); + WARN("Pixel format not set!\n"); SetLastError(ERROR_INVALID_PIXEL_FORMAT); return NULL; } - - - /* create context */ - if (icd->DrvCreateLayerContext != NULL) - drvHglrc = icd->DrvCreateLayerContext( hdc, layer ); - if (drvHglrc == NULL) + + if(!dc_data->icd_data) { - if (layer == 0 && icd->DrvCreateContext != NULL) - drvHglrc = icd->DrvCreateContext( hdc ); - else - DBGPRINT( "Warning: CreateLayerContext not supported by ICD!" ); - } - - if (drvHglrc == NULL) - { - /* FIXME: fallback to mesa? */ - DBGPRINT( "Error: DrvCreate[Layer]Context failed! (%d)", GetLastError() ); - ROSGL_DeleteContext( glrc ); - return NULL; - } - - /* we have our GLRC in glrc and the ICD's GLRC in drvHglrc */ - glrc->hglrc = drvHglrc; - glrc->icd = icd; - - return (HGLRC)glrc; -} - - -/*! \brief Create a new GL Rendering Context. - * - * \param hdc [IN] Handle for DC for which to create context - * - * \return Handle for the created GLRC - * \retval NULL Failure - */ -HGLRC -APIENTRY -rosglCreateContext( HDC hdc ) -{ - return rosglCreateLayerContext( hdc, 0 ); -} - - -/*! \brief Delete an OpenGL context - * - * \param hglrc [IN] Handle to GLRC to delete; - * - * \retval TRUE Success - * \retval FALSE Failure (i.e. GLRC is current for a thread) - */ -BOOL -APIENTRY -rosglDeleteContext( HGLRC hglrc ) -{ - GLRC *glrc = (GLRC *)hglrc; - - /* check if we know about this context */ - if (!ROSGL_ContainsContext( glrc )) - { - DBGPRINT( "Error: hglrc not found!" ); - SetLastError( ERROR_INVALID_HANDLE ); - return FALSE; - } - - /* On windows, this is allowed to delete a context which is current */ - if (glrc->is_current) - { - /* But only for its own thread */ - if(glrc->thread_id != GetCurrentThreadId()) - { - DBGPRINT( "Error: GLRC is current for DC 0x%08x", glrc->hdc ); - SetLastError( ERROR_INVALID_FUNCTION ); - return FALSE; - } - /* Unset it before going further */ - rosglMakeCurrent(NULL, NULL); - } - - /* release ICD's context */ - if (glrc->hglrc != NULL) - { - if (!glrc->icd->DrvDeleteContext( glrc->hglrc )) - { - DBGPRINT( "Warning: DrvDeleteContext() failed (%d)", GetLastError() ); - return FALSE; - } - } - - /* free resources */ - return ROSGL_DeleteContext( glrc ); -} - - -BOOL -APIENTRY -rosglDescribeLayerPlane( HDC hdc, int iPixelFormat, int iLayerPlane, - UINT nBytes, LPLAYERPLANEDESCRIPTOR plpd ) -{ - UNIMPLEMENTED; - SetLastError( ERROR_CALL_NOT_IMPLEMENTED ); - return FALSE; -} - - -/*! \brief Gets information about a pixelformat. - * - * \param hdc [IN] Handle to DC - * \param iFormat [IN] Pixelformat index - * \param nBytes [IN] sizeof (pfd) - at most nBytes are copied into pfd - * \param pfd [OUT] Pointer to a PIXELFORMATDESCRIPTOR - * - * \return Maximum pixelformat index/number of formats - * \retval 0 Failure - */ -int -APIENTRY -rosglDescribePixelFormat( HDC hdc, int iFormat, UINT nBytes, - LPPIXELFORMATDESCRIPTOR pfd ) -{ - int ret = 0; - GLDRIVERDATA *icd = ROSGL_ICDForHDC( hdc ); - - if (icd != NULL) - { - ret = icd->DrvDescribePixelFormat( hdc, iFormat, nBytes, pfd ); - if (ret == 0) - DBGPRINT( "Error: DrvDescribePixelFormat(format=%d) failed (%d)", iFormat, GetLastError() ); + TRACE("Calling SW implementation.\n"); + dhglrc = sw_CreateContext(dc_data); + TRACE("done\n"); } else { - SetLastError( ERROR_INVALID_FUNCTION ); + TRACE("Calling ICD.\n"); + dhglrc = dc_data->icd_data->DrvCreateContext(hdc); } - - return ret; + + if(!dhglrc) + { + WARN("Failed!\n"); + SetLastError(ERROR_INVALID_PIXEL_FORMAT); + return NULL; + } + + context = HeapAlloc(GetProcessHeap(), 0, sizeof(*context)); + if(!context) + { + WARN("Failed to allocate a context!\n"); + if(!dc_data->icd_data) + sw_DeleteContext(dhglrc); + else + dc_data->icd_data->DrvDeleteContext(dhglrc); + 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'; + TRACE("Success!\n"); + return (HGLRC)context; } - -/*! \brief Return the thread's current GLRC - * - * \return Handle for thread's current GLRC - * \retval NULL No current GLRC set - */ -HGLRC -APIENTRY -rosglGetCurrentContext() +HGLRC WINAPI wglCreateLayerContext(HDC hdc, int iLayerPlane) { - return NtCurrentTeb()->glCurrentRC; + 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; } - -/*! \brief Return the thread's current DC - * - * \return Handle for thread's current DC - * \retval NULL No current DC/GLRC set - */ -HDC -APIENTRY -rosglGetCurrentDC() +BOOL WINAPI wglDeleteContext(HGLRC hglrc) { - GLRC* glrc = (GLRC*)NtCurrentTeb()->glCurrentRC; - if(glrc) return glrc->hdc; + 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 -APIENTRY -rosglGetLayerPaletteEntries( HDC hdc, int iLayerPlane, int iStart, - int cEntries, COLORREF *pcr ) +int WINAPI wglGetLayerPaletteEntries(HDC hdc, int iLayerPlane, int iStart, int cEntries, COLORREF* pcr ) { - UNIMPLEMENTED; - SetLastError( ERROR_CALL_NOT_IMPLEMENTED ); + 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; } - -/*! \brief Get the address for an OpenGL extension function. - * - * The addresses this function returns are only valid within the same thread - * which it was called from. - * - * \param proc [IN] Name of the function to look for - * - * \return The address of the proc - * \retval NULL Failure - */ -PROC -APIENTRY -rosglGetProcAddress( LPCSTR proc ) +INT WINAPI wglGetPixelFormat(HDC hdc) { - PROC func; - GLRC* glrc = (GLRC*)NtCurrentTeb()->glCurrentRC; - - /* FIXME we should Flush the gl here */ - - if (glrc == NULL) + INT ret; + struct wgl_dc_data* dc_data = get_dc_data(hdc); + + if(!dc_data) { - DBGPRINT( "Error: No current GLRC!" ); - SetLastError( ERROR_INVALID_FUNCTION ); - return NULL; + SetLastError(ERROR_INVALID_HANDLE); + return 0; } - - func = glrc->icd->DrvGetProcAddress( proc ); - if (func != NULL) - { - DBGPRINT( "Info: Proc \"%s\" loaded from ICD.", proc ); - return func; - } - - /* FIXME: Should we return wgl/gl 1.1 functions? */ - SetLastError( ERROR_PROC_NOT_FOUND ); - return NULL; + + ret = dc_data->pixelformat; + release_dc_data(dc_data); + return ret; } -PROC -APIENTRY -rosglGetDefaultProcAddress( LPCSTR proc ) +PROC WINAPI wglGetProcAddress(LPCSTR name) { - PROC func; - GLRC* glrc = (GLRC*)NtCurrentTeb()->glCurrentRC; - - /* wglGetDefaultProcAddress does not flush the gl */ - - if (glrc == NULL) - { - DBGPRINT( "Error: No current GLRC!" ); - SetLastError( ERROR_INVALID_FUNCTION ); + struct wgl_context* context = get_context(IntGetCurrentRC()); + if(!context) return NULL; - } - - func = glrc->icd->DrvGetProcAddress( proc ); - if (func != NULL) - { - DBGPRINT( "Info: Proc \"%s\" loaded from ICD.", proc ); - return func; - } - - /* FIXME: Should we return wgl/gl 1.1 functions? */ - SetLastError( ERROR_PROC_NOT_FOUND ); - return NULL; + + /* This shall fail for opengl 1.1 functions */ +#define USE_GL_FUNC(func, w, x, y, z) if(!strcmp(name, "gl" #func)) return NULL; +#include "glfuncs.h" + + /* Forward */ + if(context->icd_data) + return context->icd_data->DrvGetProcAddress(name); + return sw_GetProcAddress(name); } - -/*! \brief Make the given GLRC the threads current GLRC for hdc - * - * \param hdc [IN] Handle for a DC to be drawn on - * \param hglrc [IN] Handle for a GLRC to make current - * - * \retval TRUE Success - * \retval FALSE Failure - */ -BOOL -APIENTRY -rosglMakeCurrent( HDC hdc, HGLRC hglrc ) +void APIENTRY set_api_table(const GLCLTPROCTABLE* table) { - GLRC *glrc = (GLRC *)hglrc; - ICDTable *icdTable = NULL; - - DBGTRACE( "Called!" ); - - /* Is t a new context ? */ - if (glrc != NULL) + IntSetCurrentDispatchTable(&table->glDispatchTable); +} + +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) { - /* check hdc */ - if (GetObjectType( hdc ) != OBJ_DC && GetObjectType( hdc ) != OBJ_MEMDC) + struct wgl_dc_data* dc_data = get_dc_data(hdc); + if(!dc_data) { - DBGPRINT( "Error: hdc is not a DC handle!" ); - SetLastError( ERROR_INVALID_HANDLE ); + ERR("wglMakeCurrent was passed an invalid DC handle.\n"); + SetLastError(ERROR_INVALID_HANDLE); return FALSE; } - - /* check if we know about this glrc */ - if (!ROSGL_ContainsContext( glrc )) + + /* Check compatibility */ + if((ctx->icd_data != dc_data->icd_data) || (ctx->pixelformat != dc_data->pixelformat)) { - DBGPRINT( "Error: hglrc not found!" ); - SetLastError( ERROR_INVALID_HANDLE ); + /* 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; } - - /* check if it is available */ - if (glrc->is_current && glrc->thread_id != GetCurrentThreadId()) /* used by another thread */ + + /* Set the thread ID */ + if(InterlockedCompareExchange(&ctx->thread_id, thread_id, 0) != 0) { - DBGPRINT( "Error: hglrc is current for thread 0x%08x", glrc->thread_id ); - SetLastError( ERROR_INVALID_HANDLE ); - return FALSE; + /* 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); } - - /* Unset previous one */ - if (NtCurrentTeb()->glCurrentRC != NULL) + + if(old_ctx) { - GLRC *oldglrc = (GLRC*)NtCurrentTeb()->glCurrentRC; - oldglrc->is_current = FALSE; - oldglrc->thread_id = 0; - oldglrc->hdc = NULL; - oldglrc->icd->DrvReleaseContext(oldglrc->hglrc); + /* 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 */ - if (glrc->hglrc != NULL) + + /* Call the ICD or SW implementation */ + if(ctx->icd_data) { - DBGPRINT( "Info: Calling DrvSetContext!" ); - SetLastError( ERROR_SUCCESS ); - icdTable = glrc->icd->DrvSetContext( hdc, glrc->hglrc, - (void *)ROSGL_SetContextCallBack ); - if (icdTable == NULL) + apiTable = ctx->icd_data->DrvSetContext(hdc, ctx->dhglrc, set_api_table); + if(!apiTable) { - DBGPRINT( "Error: DrvSetContext failed (%d)\n", GetLastError() ); - NtCurrentTeb()->glCurrentRC = NULL; + ERR("DrvSetContext failed!\n"); + /* revert */ + InterlockedExchange(&ctx->thread_id, 0); + IntSetCurrentDispatchTable(&StubTable.glDispatchTable); + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + set_api_table(apiTable); + /* Make it current */ + IntMakeCurrent(hglrc, hdc, dc_data); + } + else + { + /* We must set current before, SW implementation relies on it */ + IntMakeCurrent(hglrc, hdc, dc_data); + if(!sw_SetContext(dc_data, ctx->dhglrc)) + { + ERR("sw_SetContext failed!\n"); + /* revert */ + IntMakeCurrent(NULL, NULL, NULL); + InterlockedExchange(&ctx->thread_id, 0); + SetLastError(ERROR_INVALID_PARAMETER); return FALSE; } - DBGPRINT( "Info: DrvSetContext succeeded!" ); } - - /* make it current */ - glrc->is_current = TRUE; - glrc->thread_id = GetCurrentThreadId(); - glrc->hdc = hdc; - NtCurrentTeb()->glCurrentRC = (HGLRC)glrc; } - else if(NtCurrentTeb()->glCurrentRC) + else if(old_ctx) { - /* This is a call to unset the context */ - GLRC *oldglrc = (GLRC*)NtCurrentTeb()->glCurrentRC; - oldglrc->is_current = FALSE; - oldglrc->thread_id = 0; - oldglrc->hdc = NULL; - oldglrc->icd->DrvReleaseContext(oldglrc->hglrc); - NtCurrentTeb()->glCurrentRC = NULL; + 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); + /* Unset it */ + IntMakeCurrent(NULL, NULL, NULL); + /* Reset the no-op table */ + set_api_table(&StubTable); + /* Test conformance (extreme cases) */ + return hglrc == NULL; } else { - /* - * To make wine tests happy. - * Now, who cares if MakeCurrentContext(NULL, NULL) fails when current context is already NULL - */ + /* Winetest conformance */ if (GetObjectType( hdc ) != OBJ_DC && GetObjectType( hdc ) != OBJ_MEMDC) { - DBGPRINT( "Error: hdc is not a DC handle!" ); + ERR( "Error: hdc is not a DC handle!\n"); SetLastError( ERROR_INVALID_HANDLE ); return FALSE; } } - if (ROSGL_SetContextCallBack( icdTable ) != ERROR_SUCCESS && icdTable == NULL) - { - DBGPRINT( "Warning: ROSGL_SetContextCallBack failed!" ); - } - return TRUE; } - -BOOL -APIENTRY -rosglRealizeLayerPalette( HDC hdc, int iLayerPlane, BOOL bRealize ) +BOOL WINAPI wglRealizeLayerPalette(HDC hdc, + int iLayerPlane, + BOOL bRealize) { - UNIMPLEMENTED; - SetLastError( ERROR_CALL_NOT_IMPLEMENTED ); + 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 -APIENTRY -rosglSetLayerPaletteEntries( HDC hdc, int iLayerPlane, int iStart, - int cEntries, CONST COLORREF *pcr ) +int WINAPI wglSetLayerPaletteEntries(HDC hdc, + int iLayerPlane, + int iStart, + int cEntries, + const COLORREF *pcr) { - UNIMPLEMENTED; - SetLastError( ERROR_CALL_NOT_IMPLEMENTED ); + 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; } - -/*! \brief Set a DCs pixelformat - * - * \param hdc [IN] Handle to DC for which to set the format - * \param iFormat [IN] Index of the pixelformat to set - * \param pfd [IN] Not sure what this is for - * - * \retval TRUE Success - * \retval FALSE Failure - */ -BOOL -WINAPI -rosglSetPixelFormat( HDC hdc, int iFormat, CONST PIXELFORMATDESCRIPTOR *pfd ) +BOOL WINAPI wglSetPixelFormat(HDC hdc, INT format, const PIXELFORMATDESCRIPTOR *descr) { - GLDCDATA *dcdata; - GLDRIVERDATA* icd; - - DBGTRACE( "Called!" ); - - /* Get private DC data */ - dcdata = ROSGL_GetPrivateDCData( hdc ); - if (dcdata == NULL) + struct wgl_dc_data* dc_data = get_dc_data(hdc); + INT sw_format; + BOOL ret; + + TRACE("HDC %p, format %i.\n", hdc, format); + + if(!dc_data) { - DBGPRINT( "Error: ROSGL_GetPrivateDCData() failed!" ); + WARN("Not a valid DC!.\n"); + SetLastError(ERROR_INVALID_HANDLE); return FALSE; } - /* you can set the same pixel format twice, but you can't modify it */ - if(dcdata->pixel_format) return dcdata->pixel_format == iFormat; - - icd = ROSGL_ICDForHDC(hdc); - if(icd == NULL) - return 0; - - /* Call ICD function */ - if (!icd->DrvSetPixelFormat( hdc, iFormat, pfd )) + + if(!format) { - DBGPRINT( "Warning: DrvSetPixelFormat(format=%d) failed (%d)", - iFormat, GetLastError() ); - return FALSE; - } - dcdata->pixel_format = iFormat; - - return TRUE; -} - - -/*! \brief Enable display-list sharing between multiple GLRCs - * - * This will only work if both GLRCs are from the same driver. - * - * \param hglrc1 [IN] GLRC number 1 - * \param hglrc2 [IN] GLRC number 2 - * - * \retval TRUE Success - * \retval FALSE Failure - */ -BOOL -APIENTRY -rosglShareLists( HGLRC hglrc1, HGLRC hglrc2 ) -{ - GLRC *glrc1 = (GLRC *)hglrc1; - GLRC *glrc2 = (GLRC *)hglrc2; - - /* check glrcs */ - if (!ROSGL_ContainsContext( glrc1 )) - { - DBGPRINT( "Error: hglrc1 not found!" ); - SetLastError( ERROR_INVALID_HANDLE ); - return FALSE; - } - if (!ROSGL_ContainsContext( glrc2 )) - { - DBGPRINT( "Error: hglrc2 not found!" ); - SetLastError( ERROR_INVALID_HANDLE ); + WARN("format == 0!\n"); + SetLastError(ERROR_INVALID_PARAMETER); return FALSE; } - /* I think this is only possible within one ICD */ - if (glrc1->icd != glrc2->icd) + if(dc_data->pixelformat) { - DBGPRINT( "Error: hglrc1 and hglrc2 use different ICDs!" ); - SetLastError( ERROR_INVALID_HANDLE ); - return FALSE; + TRACE("DC format already set, %i.\n", dc_data->pixelformat); + return (format == dc_data->pixelformat); } - - /* share lists (call ICD) */ - return glrc1->icd->DrvShareLists( glrc1->hglrc, glrc2->hglrc ); -} - - -/*! \brief Flushes GL and swaps front/back buffer if appropriate - * - * \param hdc [IN] Handle to device context to swap buffers for - * - * \retval TRUE Success - * \retval FALSE Failure - */ -BOOL -APIENTRY -rosglSwapBuffers( HDC hdc ) -{ - GLDRIVERDATA *icd = ROSGL_ICDForHDC( hdc ); - DBGTRACE( "Called!" ); - if (icd != NULL) + + if(format <= dc_data->nb_icd_formats) { - DBGPRINT( "Swapping buffers!" ); - if (!icd->DrvSwapBuffers( hdc )) + TRACE("Calling ICD.\n"); + ret = dc_data->icd_data->DrvSetPixelFormat(hdc, format); + if(ret) { - DBGPRINT( "Error: DrvSwapBuffers failed (%d)", GetLastError() ); - return FALSE; + TRACE("Success!\n"); + dc_data->pixelformat = format; } - return TRUE; + return ret; + } + + sw_format = format - dc_data->nb_icd_formats; + if(sw_format <= dc_data->nb_sw_formats) + { + TRACE("Calling SW implementation.\n"); + ret = sw_SetPixelFormat(hdc, dc_data, sw_format); + if(ret) + { + TRACE("Success!\n"); + /* This is now officially a software-only HDC */ + dc_data->icd_data = NULL; + dc_data->pixelformat = format; + } + return ret; } - /* FIXME: implement own functionality? */ - SetLastError( ERROR_INVALID_FUNCTION ); + TRACE("Invalid pixel format!\n"); + SetLastError(ERROR_INVALID_PARAMETER); return FALSE; } - -BOOL -APIENTRY -rosglSwapLayerBuffers( HDC hdc, UINT fuPlanes ) +BOOL WINAPI wglShareLists(HGLRC hglrcSrc, HGLRC hglrcDst) { - BOOL ret = FALSE; - - if(fuPlanes & WGL_SWAP_MAIN_PLANE) - ret = rosglSwapBuffers(hdc); - - if(fuPlanes &~WGL_SWAP_MAIN_PLANE) - DBGTRACE("wglSwapLayerBuffers is not fully implemented\n"); - - return ret; + 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); } -#ifdef __cplusplus -}; /* extern "C" */ -#endif /* __cplusplus */ +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); +} -/* EOF */ +BOOL WINAPI wglSwapLayerBuffers(HDC hdc, UINT fuPlanes) +{ + return FALSE; +} + +DWORD WINAPI wglSwapMultipleBuffers(UINT count, CONST WGLSWAP * toSwap) +{ + return 0; +} diff --git a/reactos/dll/opengl/opengl32_new/wgl_font.c b/reactos/dll/opengl/opengl32/wgl_font.c similarity index 100% rename from reactos/dll/opengl/opengl32_new/wgl_font.c rename to reactos/dll/opengl/opengl32/wgl_font.c diff --git a/reactos/dll/opengl/opengl32_new/CMakeLists.txt b/reactos/dll/opengl/opengl32_new/CMakeLists.txt deleted file mode 100644 index 23dd207d0a0..00000000000 --- a/reactos/dll/opengl/opengl32_new/CMakeLists.txt +++ /dev/null @@ -1,38 +0,0 @@ - -spec2def(opengl32.dll opengl32.spec) - -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 - wgl_font.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) \ No newline at end of file diff --git a/reactos/dll/opengl/opengl32_new/glfuncs.h b/reactos/dll/opengl/opengl32_new/glfuncs.h deleted file mode 100644 index 927792088a3..00000000000 --- a/reactos/dll/opengl/opengl32_new/glfuncs.h +++ /dev/null @@ -1,338 +0,0 @@ -/* 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) \ No newline at end of file diff --git a/reactos/dll/opengl/opengl32_new/opengl32.h b/reactos/dll/opengl/opengl32_new/opengl32.h deleted file mode 100644 index 2bde16d7e2d..00000000000 --- a/reactos/dll/opengl/opengl32_new/opengl32.h +++ /dev/null @@ -1,131 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include - -#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; - PVOID* icdData; -}; - -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); diff --git a/reactos/dll/opengl/opengl32_new/opengl32.spec b/reactos/dll/opengl/opengl32_new/opengl32.spec deleted file mode 100644 index 8e393c9c292..00000000000 --- a/reactos/dll/opengl/opengl32_new/opengl32.spec +++ /dev/null @@ -1,369 +0,0 @@ -@ 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) diff --git a/reactos/dll/opengl/opengl32_new/swimpl.c b/reactos/dll/opengl/opengl32_new/swimpl.c deleted file mode 100644 index bf7aed4a20e..00000000000 --- a/reactos/dll/opengl/opengl32_new/swimpl.c +++ /dev/null @@ -1,799 +0,0 @@ -/* - * 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 - -#include - -#include -WINE_DEFAULT_DEBUG_CHANNEL(opengl32); - -#define WIDTH_BYTES_ALIGN32(cx, bpp) ((((cx) * (bpp) + 31) & ~31) >> 3) - -/* 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; - GLenum readmode; -}; - -#define SW_FB_DOUBLEBUFFERED 0x1 -#define SW_FB_DIBSECTION 0x2 -#define SW_FB_FREE_BITS 0x4 -#define SW_FB_DIRTY_BITS 0x8 -#define SW_FB_DIRTY_SIZE 0x10 -#define SW_FB_DIRTY (SW_FB_DIRTY_BITS | SW_FB_DIRTY_SIZE) - -struct sw_framebuffer -{ - INT sw_format; - UINT format_index; - union - { - void* backbuffer; - void* bits; - }; - void* frontbuffer; - DWORD flags; - BITMAPINFO bmi; -}; - -/* - * Functions that we shadow to compensate with the impossibility - * to use double buffered format in osmesa - */ -static void (GLAPIENTRY * pFinish)(void); -static void (GLAPIENTRY * pReadBuffer)(GLenum); -static void (GLAPIENTRY * pGetBooleanv)(GLenum pname, GLboolean* params); -static void (GLAPIENTRY * pGetFloatv)(GLenum pname, GLfloat* params); -static void (GLAPIENTRY * pGetDoublev)(GLenum pname, GLdouble* params); -static void (GLAPIENTRY * pGetIntegerv)(GLenum pname, GLint* params); -static void (GLAPIENTRY * pReadPixels)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels); - -/* API table for single buffered mode */ -static GLCLTPROCTABLE sw_table_sb; -/* API table for double buffered mode */ -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 }, -}; - -/* Single buffered format specifics */ -static void GLAPIENTRY sw_sb_Finish(void) -{ - struct wgl_dc_data* dc_data = IntGetCurrentDcData(); - struct sw_framebuffer* fb; - HDC hdc = IntGetCurrentDC(); - - /* Call osmesa */ - pFinish(); - - assert(dc_data != NULL); - fb = dc_data->sw_data; - assert(fb != NULL); - - /* osmesa directly updated the bits of the DIB section */ - if(fb->flags & SW_FB_DIBSECTION) - return; - - /* 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); -} - -/* Double buffered format specifics */ -static void sw_db_update_frontbuffer(struct sw_framebuffer* fb, HDC hdc) -{ - unsigned int widthbytes = WIDTH_BYTES_ALIGN32(fb->bmi.bmiHeader.biWidth, - pixel_formats[fb->format_index].color_bits); - size_t buffer_size = widthbytes*fb->bmi.bmiHeader.biHeight; - if(fb->flags & SW_FB_DIRTY_SIZE) - { - if(fb->frontbuffer) - fb->frontbuffer = HeapReAlloc(GetProcessHeap(), 0, fb->frontbuffer, buffer_size); - else - fb->frontbuffer = HeapAlloc(GetProcessHeap(), 0, buffer_size); - fb->flags ^= SW_FB_DIRTY_SIZE; - } - - if(fb->flags & SW_FB_DIRTY_BITS) - { - /* On windows, there is SetDIBitsToDevice, but not FROM device... */ - HBITMAP hbmp; - HDC hmemDC = CreateCompatibleDC(hdc); - void* DIBits; - hbmp = CreateDIBSection(hdc, - &fb->bmi, - DIB_RGB_COLORS, - &DIBits, - NULL, 0); - hbmp = SelectObject(hmemDC, hbmp); - BitBlt(hdc, - 0, - 0, - fb->bmi.bmiHeader.biWidth, - fb->bmi.bmiHeader.biHeight, - hmemDC, - 0, - 0, - SRCCOPY); - /* Copy the bits */ - CopyMemory(fb->frontbuffer, DIBits, buffer_size); - /* Clean up */ - hbmp = SelectObject(hmemDC, hbmp); - DeleteDC(hmemDC); - DeleteObject(hbmp); - /* We're clean */ - fb->flags ^= SW_FB_DIRTY_BITS; - } -} - -static void GLAPIENTRY sw_db_ReadBuffer(GLenum mode) -{ - struct sw_context* ctx = (struct sw_context*)IntGetCurrentDHGLRC(); - - /* All good */ - if(ctx->readmode == mode) - return; - - /* We don't support stereoscopic formats */ - if(mode == GL_FRONT) - mode = GL_FRONT_LEFT; - - if(mode == GL_BACK) - mode = GL_BACK_LEFT; - - /* Validate the asked mode */ - if((mode != GL_FRONT_LEFT) || (mode != GL_BACK_LEFT)) - { - ERR("Incompatble mode passed: %lx.\n", mode); - return; - } - - /* Save it */ - ctx->readmode = mode; -} - -static void GLAPIENTRY sw_db_GetBooleanv(GLenum pname, GLboolean* params) -{ - struct sw_context* ctx = (struct sw_context*)IntGetCurrentDHGLRC(); - switch(pname) - { - case GL_READ_BUFFER: - /* Well, it's never 0, but eh, the spec you know */ - *params = (ctx->readmode != 0); - return; - default: - pGetBooleanv(pname, params); - return; - } -} - -static void GLAPIENTRY sw_db_GetDoublev(GLenum pname, GLdouble* params) -{ - struct sw_context* ctx = (struct sw_context*)IntGetCurrentDHGLRC(); - switch(pname) - { - case GL_READ_BUFFER: - *params = (GLdouble)ctx->readmode; - return; - default: - pGetDoublev(pname, params); - return; - } -} - -static void GLAPIENTRY sw_db_GetFloatv(GLenum pname, GLfloat* params) -{ - struct sw_context* ctx = (struct sw_context*)IntGetCurrentDHGLRC(); - switch(pname) - { - case GL_READ_BUFFER: - *params = (GLfloat)ctx->readmode; - return; - default: - pGetFloatv(pname, params); - return; - } -} - -static void GLAPIENTRY sw_db_GetIntegerv(GLenum pname, GLint* params) -{ - struct sw_context* ctx = (struct sw_context*)IntGetCurrentDHGLRC(); - switch(pname) - { - case GL_READ_BUFFER: - *params = ctx->readmode; - return; - default: - pGetIntegerv(pname, params); - return; - } -} - -static void GLAPIENTRY sw_db_ReadPixels( - GLint x, - GLint y, - GLsizei width, - GLsizei height, - GLenum format, - GLenum type, - GLvoid *pixels -) -{ - struct sw_context* ctx = (struct sw_context*)IntGetCurrentDHGLRC(); - struct wgl_dc_data* dc_data = IntGetCurrentDcData(); - struct sw_framebuffer* fb = dc_data->sw_data; - - /* Quick path */ - if(ctx->readmode == GL_BACK_LEFT) - { - pReadPixels(x, y, width, height, format, type, pixels); - return; - } - - assert(ctx->readmode == GL_FRONT_LEFT); - - /* Update frontbuffer */ - if(fb->flags & SW_FB_DIRTY) - sw_db_update_frontbuffer(fb, IntGetCurrentDC()); - - /* Finish wahtever is going on on backbuffer */ - pFinish(); - /* Tell osmesa we changed the buffer */ - pOSMesaMakeCurrent(ctx->mesa_ctx, fb->frontbuffer, GL_UNSIGNED_BYTE, width, height); - - /* Go ahead */ - pReadPixels(x, y, width, height, format, type, pixels); - - /* Go back to backbuffer operation */ - pOSMesaMakeCurrent(ctx->mesa_ctx, fb->backbuffer, GL_UNSIGNED_BYTE, width, height); -} - -/* WGL <-> OSMesa functions */ -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; indexowner.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 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; - - 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/double buffered. */ -#define SWAP_SB_FUNC(x) do \ -{ \ - p##x = sw_table_sb.glDispatchTable.x; \ - sw_table_sb.glDispatchTable.x = sw_sb_##x; \ -} while(0) - SWAP_SB_FUNC(Finish); -#undef SWAP_SB_FUNC -#define SWAP_DB_FUNC(x) do \ -{ \ - p##x = sw_table_db.glDispatchTable.x; \ - sw_table_db.glDispatchTable.x = sw_db_##x; \ -} while(0) - SWAP_DB_FUNC(ReadBuffer); - SWAP_DB_FUNC(ReadPixels); - SWAP_DB_FUNC(GetBooleanv); - SWAP_DB_FUNC(GetIntegerv); - SWAP_DB_FUNC(GetFloatv); - SWAP_DB_FUNC(GetDoublev); -#undef SWAP_DB_FUNC - - /* OpenGL spec: flush == all pending commands are sent to the server, - * and the client will receive the data in finished time. - * We will call this finish in our case */ - sw_table_sb.glDispatchTable.Flush = 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; - } - /* Set defaults */ - context->hook = NULL; - context->readmode = GL_BACK_LEFT; - 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; - } -} - -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; - /* Do not bother with unchanged size */ - if(width == fb->bmi.bmiHeader.biWidth && height == fb->bmi.bmiHeader.biHeight) - goto end; - /* 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); - TRACE("New res: %lux%lu.\n", width, 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); - /* Mark dirty bit acordingly */ - fb->flags |= SW_FB_DIRTY_SIZE; - } - } - -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; - - TRACE("Res: %lux%lu.\n", width, height); - - if(bits) - { - assert(!(fb->flags & SW_FB_DOUBLEBUFFERED)); - 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 if((width != fb->bmi.bmiHeader.biWidth) || (height != fb->bmi.bmiHeader.biHeight)) - { - 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 | SW_FB_DIRTY_SIZE); - 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; - - /* Finish before swapping */ - pFinish(); - - /* We are now dirty */ - fb->flags |= SW_FB_DIRTY_BITS; - - 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); -} \ No newline at end of file diff --git a/reactos/dll/opengl/opengl32_new/wgl.c b/reactos/dll/opengl/opengl32_new/wgl.c deleted file mode 100644 index 93120c2eeca..00000000000 --- a/reactos/dll/opengl/opengl32_new/wgl.c +++ /dev/null @@ -1,889 +0,0 @@ -/* - * 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 - -#include -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; - - TRACE("Creating context for %p, format %i\n", hdc); - - if(!dc_data) - { - WARN("Not a DC handle!\n"); - SetLastError(ERROR_INVALID_HANDLE); - return NULL; - } - - if(!dc_data->pixelformat) - { - WARN("Pixel format not set!\n"); - SetLastError(ERROR_INVALID_PIXEL_FORMAT); - return NULL; - } - - if(!dc_data->icd_data) - { - TRACE("Calling SW implementation.\n"); - dhglrc = sw_CreateContext(dc_data); - TRACE("done\n"); - } - else - { - TRACE("Calling ICD.\n"); - dhglrc = dc_data->icd_data->DrvCreateContext(hdc); - } - - if(!dhglrc) - { - WARN("Failed!\n"); - SetLastError(ERROR_INVALID_PIXEL_FORMAT); - return NULL; - } - - context = HeapAlloc(GetProcessHeap(), 0, sizeof(*context)); - if(!context) - { - WARN("Failed to allocate a context!\n"); - if(!dc_data->icd_data) - sw_DeleteContext(dhglrc); - else - dc_data->icd_data->DrvDeleteContext(dhglrc); - 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'; - TRACE("Success!\n"); - 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; - - TRACE("HDC %p, format %i.\n", hdc, format); - - if(!dc_data) - { - WARN("Not a valid DC!.\n"); - SetLastError(ERROR_INVALID_HANDLE); - return FALSE; - } - - if(!format) - { - WARN("format == 0!\n"); - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } - - if(dc_data->pixelformat) - { - TRACE("DC format already set, %i.\n", dc_data->pixelformat); - return (format == dc_data->pixelformat); - } - - if(format <= dc_data->nb_icd_formats) - { - TRACE("Calling ICD.\n"); - ret = dc_data->icd_data->DrvSetPixelFormat(hdc, format); - if(ret) - { - TRACE("Success!\n"); - dc_data->pixelformat = format; - } - return ret; - } - - sw_format = format - dc_data->nb_icd_formats; - if(sw_format <= dc_data->nb_sw_formats) - { - TRACE("Calling SW implementation.\n"); - ret = sw_SetPixelFormat(dc_data, sw_format); - if(ret) - { - TRACE("Success!\n"); - /* This is now officially a software-only HDC */ - dc_data->icd_data = NULL; - dc_data->pixelformat = format; - } - return ret; - } - - TRACE("Invalid pixel format!\n"); - 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; -}