135c4bbdfSmrg/* 235c4bbdfSmrg * File: glthunk.c 335c4bbdfSmrg * Purpose: cdecl thunk wrapper library for Win32 stdcall OpenGL library 435c4bbdfSmrg * 535c4bbdfSmrg * Copyright (c) Jon TURNEY 2009,2013 635c4bbdfSmrg * 735c4bbdfSmrg * Permission is hereby granted, free of charge, to any person obtaining a 835c4bbdfSmrg * copy of this software and associated documentation files (the "Software"), 935c4bbdfSmrg * to deal in the Software without restriction, including without limitation 1035c4bbdfSmrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 1135c4bbdfSmrg * and/or sell copies of the Software, and to permit persons to whom the 1235c4bbdfSmrg * Software is furnished to do so, subject to the following conditions: 1335c4bbdfSmrg * 1435c4bbdfSmrg * The above copyright notice and this permission notice shall be included in 1535c4bbdfSmrg * all copies or substantial portions of the Software. 1635c4bbdfSmrg * 1735c4bbdfSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1835c4bbdfSmrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1935c4bbdfSmrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 2035c4bbdfSmrg * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 2135c4bbdfSmrg * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 2235c4bbdfSmrg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 2335c4bbdfSmrg * DEALINGS IN THE SOFTWARE. 2435c4bbdfSmrg */ 2535c4bbdfSmrg 2635c4bbdfSmrg// define USE_OPENGL32 makes gl.h declare gl*() function prototypes with stdcall linkage, 2735c4bbdfSmrg// so our generated wrappers will correctly link with the functions in opengl32.dll 2835c4bbdfSmrg#define USE_OPENGL32 2935c4bbdfSmrg 3035c4bbdfSmrg#ifdef HAVE_XWIN_CONFIG_H 3135c4bbdfSmrg#include <xwin-config.h> 3235c4bbdfSmrg#endif 3335c4bbdfSmrg 3435c4bbdfSmrg#include <X11/Xwindows.h> 3535c4bbdfSmrg 3635c4bbdfSmrg#define GL_GLEXT_LEGACY 3735c4bbdfSmrg#include <GL/gl.h> 3835c4bbdfSmrg#undef GL_ARB_imaging 3935c4bbdfSmrg#undef GL_VERSION_1_3 4035c4bbdfSmrg#include <GL/glext.h> 4135c4bbdfSmrg 4235c4bbdfSmrgstatic PROC 4335c4bbdfSmrgglWinResolveHelper(PROC * cache, const char *symbol) 4435c4bbdfSmrg{ 4535c4bbdfSmrg PROC proc = NULL; 4635c4bbdfSmrg 4735c4bbdfSmrg /* If not yet cached, call wglGetProcAddress */ 4835c4bbdfSmrg if ((*cache) == NULL) { 4935c4bbdfSmrg proc = wglGetProcAddress(symbol); 5035c4bbdfSmrg if (proc == NULL) { 5135c4bbdfSmrg (*cache) = (PROC) - 1; 5235c4bbdfSmrg } 5335c4bbdfSmrg else { 5435c4bbdfSmrg (*cache) = proc; 5535c4bbdfSmrg } 5635c4bbdfSmrg } 5735c4bbdfSmrg /* Cached wglGetProcAddress failure */ 5835c4bbdfSmrg else if ((*cache) == (PROC) - 1) { 5935c4bbdfSmrg proc = 0; 6035c4bbdfSmrg } 6135c4bbdfSmrg /* Cached wglGetProcAddress result */ 6235c4bbdfSmrg else { 6335c4bbdfSmrg proc = (*cache); 6435c4bbdfSmrg } 6535c4bbdfSmrg 6635c4bbdfSmrg return proc; 6735c4bbdfSmrg} 6835c4bbdfSmrg 6935c4bbdfSmrg#define RESOLVE_RET(proctype, symbol, retval) \ 7035c4bbdfSmrg static PROC cache = NULL; \ 7135c4bbdfSmrg __stdcall proctype proc = (proctype)glWinResolveHelper(&cache, symbol); \ 7235c4bbdfSmrg if (proc == NULL) { \ 7335c4bbdfSmrg return retval; \ 7435c4bbdfSmrg } 7535c4bbdfSmrg 7635c4bbdfSmrg#define RESOLVE(proctype, symbol) RESOLVE_RET(proctype, symbol,) 7735c4bbdfSmrg 7835c4bbdfSmrg#define RESOLVED_PROC(proctype) proc 7935c4bbdfSmrg 8035c4bbdfSmrg/* 8135c4bbdfSmrg Include generated cdecl wrappers for stdcall gl*() functions in opengl32.dll 8235c4bbdfSmrg 8335c4bbdfSmrg OpenGL 1.2 and upward is treated as extensions, function address must 8435c4bbdfSmrg found using wglGetProcAddress(), but also stdcall so still need wrappers... 8535c4bbdfSmrg*/ 8635c4bbdfSmrg 871b5d61b8Smrg#include "generated_gl_thunks.ic" 88