/* $info$ tags: thunklibs|GL desc: Handles glXGetProcAddress $end_info$ */ #define GL_GLEXT_PROTOTYPES 1 #define GLX_GLXEXT_PROTOTYPES 1 #include #include #include #include #undef GL_ARB_viewport_array #include "glcorearb.h" #include #include #include #include #include #include "common/Guest.h" #include "thunks.inl" #include "function_packs.inl" #include "function_packs_public.inl" #include "symbol_list.inl" typedef void voidFunc(); // Maps OpenGL API function names to the address of a guest function which is // linked to the corresponding host function pointer const std::unordered_map HostPtrInvokers = std::invoke([]() { #define PAIR(name, unused) Ret[#name] = reinterpret_cast(GetCallerForHostThunkFromRuntimePointer(name)); std::unordered_map Ret; FOREACH_internal_SYMBOL(PAIR) return Ret; #undef PAIR }); extern "C" { voidFunc *glXGetProcAddress(const GLubyte *procname) { auto Ret = fexfn_pack_glXGetProcAddress(procname); if (!Ret) { return nullptr; } auto TargetFuncIt = HostPtrInvokers.find(reinterpret_cast(procname)); if (TargetFuncIt == HostPtrInvokers.end()) { // Extension found in host but not in our interface definition => treat as fatal error fprintf(stderr, "glXGetProcAddress: not found %s\n", procname); __builtin_trap(); } LinkAddressToFunction((uintptr_t)Ret, TargetFuncIt->second); return Ret; } voidFunc *glXGetProcAddressARB(const GLubyte *procname) { return glXGetProcAddress(procname); } } LOAD_LIB(libGL)