// Based on the example provided by Eric Wasylishen // https://discourse.libsdl.org/t/sdl-getdesktopdisplaymode-resolution-reported-in-windows-10-when-using-app-scaling/22389 void WIN_InitDPI() { void* userDLL; void* shcoreDLL; shcoreDLL = SDL_LoadObject("SHCORE.DLL"); if (shcoreDLL) { SetProcessDpiAwareness = (HRESULT(WINAPI *)(PROCESS_DPI_AWARENESS)) SDL_LoadFunction(shcoreDLL, "SetProcessDpiAwareness"); } if (SetProcessDpiAwareness) { /* Try Windows 8.1+ version */ HRESULT result = SetProcessDpiAwareness(PROCESS_PER_MONITOR_DPI_AWARE); return; } userDLL = SDL_LoadObject("USER32.DLL"); if (userDLL) { SetProcessDPIAware = (BOOL(WINAPI *)(void)) SDL_LoadFunction(userDLL, "SetProcessDPIAware"); } if (SetProcessDPIAware) { /* Try Vista - Windows 8 version. This has a constant scale factor for all monitors. */ BOOL success = SetProcessDPIAware(); } }
internal sdl_game_code SDLLoadGameCode(const char *SourceDLLName, const char *TempDLLName, const char *LockFileName) { sdl_game_code Result = {}; if (access(LockFileName, F_OK) == -1) { Result.DLLLastWriteTime = SDLGetLastWriteTime(SourceDLLName); SDLCopyFile(SourceDLLName, TempDLLName); Result.GameCodeDLL = SDL_LoadObject(TempDLLName); if (Result.GameCodeDLL) { Result.UpdateAndRender = (game_update_and_render *) SDL_LoadFunction(Result.GameCodeDLL, "GameUpdateAndRender"); Result.GetSoundSamples = (game_get_sound_samples *) SDL_LoadFunction(Result.GameCodeDLL, "GameGetSoundSamples"); Result.IsValid = (Result.UpdateAndRender && Result.GetSoundSamples); } } if (!Result.IsValid) { Result.UpdateAndRender = 0; Result.GetSoundSamples = 0; } return Result; }
/** Calls a function with no args and no return value in the specified DLL */ void CallNoArgNotification( const char *pchModuleName, const char *pchProcName ) { #if defined(_WIN32) void * pMod = (void *)GetModuleHandle( pchModuleName ); if( pMod ) { NoArgNotificationFn_t fn = (NoArgNotificationFn_t)SDL_LoadFunction( pMod, pchProcName ); #elif defined(POSIX) // on POSIX there is no reasonable way to get the handle of a module without the // full path name. Since we don't know that, just assume that the global symbol // name is only defined in the right module NoArgNotificationFn_t fn = (NoArgNotificationFn_t)SDL_LoadFunction( NULL, pchProcName ); #endif if( fn ) { // actually call the function fn(); } #if defined(_WIN32) // unload the module to free up the reference that was returned by SDL_GetLoadedObject SDL_UnloadObject( pMod ); } #endif }
static bool jsplugin_get_entry_points(const String& pluginLibrary, atomic_plugin_validate_function* fvalidate, duk_c_function* finit, String& errorMsg) { *fvalidate = NULL; *finit = NULL; // TODO: cache and use SDL_UnloadObject (when no longer needed) void* handle = SDL_LoadObject(pluginLibrary.CString()); if (handle == NULL) { errorMsg = ToString("Native Plugin: Unable to load %s", pluginLibrary.CString()); return false; } *fvalidate = (atomic_plugin_validate_function) SDL_LoadFunction(handle, "atomic_plugin_validate"); if (!*fvalidate) { errorMsg = ToString("Native Plugin: Unable to get atomic_plugin_validate entry point in %s", pluginLibrary.CString()); return false; } *finit = (duk_c_function) SDL_LoadFunction(handle, "atomic_plugin_init"); if (!*finit) { LOGERRORF("Native Plugin: Unable to get atomic_plugin_init entry point in %s", pluginLibrary.CString()); return false; } return true; }
void SetBrightness(float val) { /* This function exists because SDL2 uses function for brightness which is not supported by opensource X11 drivers */ /* val < 0.0f tries to restore the brightness, less than -1.0 doesn't affect SDL function */ #ifdef USE_X11_GAMMA static BOOL firstCall = true; SDL_SysWMinfo sysInfo; SDL_VERSION(&sysInfo.version); if (SDL_GetWindowWMInfo(sdlWin, &sysInfo) && sysInfo.subsystem == SDL_SYSWM_X11) { static XF86VidModeGamma gammaToRestore = {-1.0f, -1.0f, -1.0f}; static _XF86VidModeGetGamma XF86VidModeGetGamma; static _XF86VidModeSetGamma XF86VidModeSetGamma; if (firstCall && (!XF86VidModeGetGamma || !XF86VidModeSetGamma)) { void *Xxf86vm = SDL_LoadObject(SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE); if (Xxf86vm) { XF86VidModeGetGamma = SDL_LoadFunction(Xxf86vm, "XF86VidModeGetGamma"); XF86VidModeSetGamma = SDL_LoadFunction(Xxf86vm, "XF86VidModeSetGamma"); } } firstCall = false; if (XF86VidModeGetGamma && XF86VidModeSetGamma) { int screen = SDL_GetWindowDisplayIndex(sdlWin); if (screen < 0) screen = 0; if (gammaToRestore.red == -1.0f && gammaToRestore.green == -1.0f && gammaToRestore.blue == -1.0f) XF86VidModeGetGamma(sysInfo.info.x11.display, screen, &gammaToRestore); //Get brightness at first attempt if (val < 0.0f) { if (gammaToRestore.red >= 0.0f && gammaToRestore.green >= 0.0f && gammaToRestore.blue >= 0.0f && XF86VidModeSetGamma(sysInfo.info.x11.display, screen, &gammaToRestore)) //Restore brightness return; else val = 1.0f; } if (val >= 0.0f) { XF86VidModeGamma gamma = {val, val, val}; if (XF86VidModeSetGamma(sysInfo.info.x11.display, screen, &gamma)) //Set brightness return; } } } #endif if (val >= -1.0f) SDL_SetWindowBrightness(sdlWin, val < 0.0f ? 1.0f : val); }
void * PND_gl_getprocaddres(_THIS, const char *proc) { SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; void *function_address; /* Try to get function address through the egl interface */ function_address = eglGetProcAddress(proc); if (function_address != NULL) { return function_address; } /* Then try to get function in the OpenGL ES library */ if (_this->gl_config.dll_handle) { function_address = SDL_LoadFunction(_this->gl_config.dll_handle, proc); if (function_address != NULL) { return function_address; } } /* Failed to get GL ES function address pointer */ SDL_SetError("PND: Cannot locate OpenGL ES function name"); return NULL; }
static void * WAYLAND_GetSym(const char *fnname, int *pHasModule) { int i; void *fn = NULL; for (i = 0; i < SDL_TABLESIZE(waylandlibs); i++) { if (waylandlibs[i].lib != NULL) { fn = SDL_LoadFunction(waylandlibs[i].lib, fnname); if (fn != NULL) break; } } #if DEBUG_DYNAMIC_WAYLAND if (fn != NULL) SDL_Log("WAYLAND: Found '%s' in %s (%p)\n", fnname, waylandlibs[i].libname, fn); else SDL_Log("WAYLAND: Symbol '%s' NOT FOUND!\n", fnname); #endif if (fn == NULL) *pHasModule = 0; /* kill this module. */ return fn; }
static void * X11_GetSym(const char *fnname, int *pHasModule) { int i; void *fn = NULL; for (i = 0; i < SDL_TABLESIZE(x11libs); i++) { if (x11libs[i].lib != NULL) { fn = SDL_LoadFunction(x11libs[i].lib, fnname); if (fn != NULL) break; } } #if DEBUG_DYNAMIC_X11 if (fn != NULL) printf("X11: Found '%s' in %s (%p)\n", fnname, x11libs[i].libname, fn); else printf("X11: Symbol '%s' NOT FOUND!\n", fnname); #endif if (fn == NULL) *pHasModule = 0; /* kill this module. */ return fn; }
SDL_bool D3D_LoadDLL( void **pD3DDLL, IDirect3D9 **pDirect3D9Interface ) { *pD3DDLL = SDL_LoadObject("D3D9.DLL"); if (*pD3DDLL) { IDirect3D9 *(WINAPI * D3DCreate) (UINT SDKVersion); D3DCreate = (IDirect3D9 * (WINAPI *) (UINT)) SDL_LoadFunction(*pD3DDLL, "Direct3DCreate9"); if (D3DCreate) { *pDirect3D9Interface = D3DCreate(D3D_SDK_VERSION); } if (!*pDirect3D9Interface) { SDL_UnloadObject(*pD3DDLL); *pD3DDLL = NULL; return SDL_FALSE; } return SDL_TRUE; } else { *pDirect3D9Interface = NULL; return SDL_FALSE; } }
SDL_bool DXGI_LoadDLL( void **pDXGIDLL , IDXGIFactory **pDXGIFactory ) { *pDXGIDLL = SDL_LoadObject("DXGI.DLL"); if (*pDXGIDLL ) { HRESULT (WINAPI *CreateDXGI)( REFIID riid, void **ppFactory ); CreateDXGI = (HRESULT (WINAPI *) (REFIID, void**)) SDL_LoadFunction(*pDXGIDLL, "CreateDXGIFactory"); if (CreateDXGI) { GUID dxgiGUID = {0x7b7166ec,0x21c7,0x44ae,{0xb2,0x1a,0xc9,0xae,0x32,0x1a,0xe3,0x69}}; if( !SUCCEEDED( CreateDXGI( &dxgiGUID, (void**)pDXGIFactory ))) { *pDXGIFactory = NULL; } } if (!*pDXGIFactory) { SDL_UnloadObject(*pDXGIDLL); *pDXGIDLL = NULL; return SDL_FALSE; } return SDL_TRUE; } else { *pDXGIFactory = NULL; return SDL_FALSE; } }
int IMG_InitTIF() { if ( lib.loaded == 0 ) { lib.handle = SDL_LoadObject(LOAD_TIF_DYNAMIC); if ( lib.handle == NULL ) { return -1; } lib.TIFFClientOpen = (TIFF* (*)(const char*, const char*, thandle_t, TIFFReadWriteProc, TIFFReadWriteProc, TIFFSeekProc, TIFFCloseProc, TIFFSizeProc, TIFFMapFileProc, TIFFUnmapFileProc)) SDL_LoadFunction(lib.handle, "TIFFClientOpen"); if ( lib.TIFFClientOpen == NULL ) { SDL_UnloadObject(lib.handle); return -1; } lib.TIFFClose = (void (*)(TIFF*)) SDL_LoadFunction(lib.handle, "TIFFClose"); if ( lib.TIFFClose == NULL ) { SDL_UnloadObject(lib.handle); return -1; } lib.TIFFGetField = (int (*)(TIFF*, ttag_t, ...)) SDL_LoadFunction(lib.handle, "TIFFGetField"); if ( lib.TIFFGetField == NULL ) { SDL_UnloadObject(lib.handle); return -1; } lib.TIFFReadRGBAImage = (int (*)(TIFF*, uint32, uint32, uint32*, int)) SDL_LoadFunction(lib.handle, "TIFFReadRGBAImage"); if ( lib.TIFFReadRGBAImage == NULL ) { SDL_UnloadObject(lib.handle); return -1; } lib.TIFFSetErrorHandler = (TIFFErrorHandler (*)(TIFFErrorHandler)) SDL_LoadFunction(lib.handle, "TIFFSetErrorHandler"); if ( lib.TIFFSetErrorHandler == NULL ) { SDL_UnloadObject(lib.handle); return -1; } } ++lib.loaded; return 0; }
int main(int argc, char *argv[]) { int retval = 0; int hello = 0; const char *libname = NULL; const char *symname = NULL; void *lib = NULL; fntype fn = NULL; if (argc != 3) { const char *app = argv[0]; SDL_Log("USAGE: %s <library> <functionname>\n", app); SDL_Log(" %s --hello <lib with puts()>\n", app); return 1; } /* Initialize SDL */ if (SDL_Init(0) < 0) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError()); return 2; } if (strcmp(argv[1], "--hello") == 0) { hello = 1; libname = argv[2]; symname = "puts"; } else { libname = argv[1]; symname = argv[2]; } lib = SDL_LoadObject(libname); if (lib == NULL) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_LoadObject('%s') failed: %s\n", libname, SDL_GetError()); retval = 3; } else { fn = (fntype) SDL_LoadFunction(lib, symname); if (fn == NULL) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_LoadFunction('%s') failed: %s\n", symname, SDL_GetError()); retval = 4; } else { SDL_Log("Found %s in %s at %p\n", symname, libname, fn); if (hello) { SDL_Log("Calling function...\n"); fflush(stdout); fn(" HELLO, WORLD!\n"); SDL_Log("...apparently, we survived. :)\n"); SDL_Log("Unloading library...\n"); fflush(stdout); } } SDL_UnloadObject(lib); } SDL_Quit(); return retval; }
int WIN_GL_LoadLibrary(_THIS, const char *path) { void *handle; if (path == NULL) { path = SDL_getenv("SDL_OPENGL_LIBRARY"); } if (path == NULL) { path = DEFAULT_OPENGL; } _this->gl_config.dll_handle = SDL_LoadObject(path); if (!_this->gl_config.dll_handle) { return -1; } SDL_strlcpy(_this->gl_config.driver_path, path, SDL_arraysize(_this->gl_config.driver_path)); /* Allocate OpenGL memory */ _this->gl_data = (struct SDL_GLDriverData *) SDL_calloc(1, sizeof(struct SDL_GLDriverData)); if (!_this->gl_data) { return SDL_OutOfMemory(); } /* Load function pointers */ handle = _this->gl_config.dll_handle; _this->gl_data->wglGetProcAddress = (void *(WINAPI *) (const char *)) SDL_LoadFunction(handle, "wglGetProcAddress"); _this->gl_data->wglCreateContext = (HGLRC(WINAPI *) (HDC)) SDL_LoadFunction(handle, "wglCreateContext"); _this->gl_data->wglDeleteContext = (BOOL(WINAPI *) (HGLRC)) SDL_LoadFunction(handle, "wglDeleteContext"); _this->gl_data->wglMakeCurrent = (BOOL(WINAPI *) (HDC, HGLRC)) SDL_LoadFunction(handle, "wglMakeCurrent"); _this->gl_data->wglShareLists = (BOOL(WINAPI *) (HGLRC, HGLRC)) SDL_LoadFunction(handle, "wglShareLists"); if (!_this->gl_data->wglGetProcAddress || !_this->gl_data->wglCreateContext || !_this->gl_data->wglDeleteContext || !_this->gl_data->wglMakeCurrent) { return SDL_SetError("Could not retrieve OpenGL functions"); } return 0; }
static int load_nas_sym(const char *fn, void **addr) { *addr = SDL_LoadFunction(nas_handle, fn); if (*addr == NULL) { return 0; } return 1; }
void* MFCOpenGLContext::wglLoader(const char* name) { auto wglAddr = reinterpret_cast<void*>(wglGetProcAddress(name)); if (wglAddr == nullptr && _oglDllHandle != nullptr) { wglAddr = SDL_LoadFunction(_oglDllHandle, name); } return wglAddr; }
int main(int argc, char *argv[]) { std::cout << "Testing console output.\n"; void * mydll = SDL_LoadObject("fausnd.dll"); std::cout << SDL_GetError(); double (*faudio_init)(); faudio_init = (double(*)()) SDL_LoadFunction(mydll, "faudio_init"); std::cout << SDL_GetError(); double (*faudio_new_sample)(const char * sfn); faudio_new_sample = (double(*)(const char *)) SDL_LoadFunction(mydll, "faudio_new_sample"); std::cout << SDL_GetError(); double (*faudio_new_generator)(double sid); faudio_new_generator = (double(*)(double)) SDL_LoadFunction(mydll, "faudio_new_generator"); std::cout << SDL_GetError(); double (*faudio_fire_generator)(double gid); faudio_fire_generator = (double(*)(double)) SDL_LoadFunction(mydll, "faudio_fire_generator"); std::cout << SDL_GetError(); double (*faudio_get_generator_playing)(double gid); faudio_get_generator_playing = (double(*)(double)) SDL_LoadFunction(mydll, "faudio_get_generator_playing"); std::cout << SDL_GetError(); faudio_init(); double smp; if(argc == 1) smp = faudio_new_sample("test.wav"); else smp = faudio_new_sample(argv[1]); auto gen = faudio_new_generator(smp); faudio_fire_generator(gen); while(faudio_get_generator_playing(gen)) SDL_Delay(10); return 0; }
static int load_sndio_sym(const char *fn, void **addr) { *addr = SDL_LoadFunction(sndio_handle, fn); if (*addr == NULL) { /* Don't call SDL_SetError(): SDL_LoadFunction already did. */ return 0; } return 1; }
static SDL_bool SDL_UDEV_load_sym(const char *fn, void **addr) { *addr = SDL_LoadFunction(_this->udev_handle, fn); if (*addr == NULL) { /* Don't call SDL_SetError(): SDL_LoadFunction already did. */ return SDL_FALSE; } return SDL_TRUE; }
SDL_bool D3D_LoadDLL(void **pD3DDLL, IDirect3D9 **pDirect3D9Interface) { *pD3DDLL = SDL_LoadObject("D3D9.DLL"); if (*pD3DDLL) { typedef IDirect3D9 *(WINAPI *Direct3DCreate9_t) (UINT SDKVersion); Direct3DCreate9_t Direct3DCreate9Func; #ifdef USE_D3D9EX typedef HRESULT (WINAPI *Direct3DCreate9Ex_t)(UINT SDKVersion, IDirect3D9Ex **ppD3D); Direct3DCreate9Ex_t Direct3DCreate9ExFunc; Direct3DCreate9ExFunc = (Direct3DCreate9Ex_t)SDL_LoadFunction(*pD3DDLL, "Direct3DCreate9Ex"); if (Direct3DCreate9ExFunc) { IDirect3D9Ex *pDirect3D9ExInterface; HRESULT hr = Direct3DCreate9ExFunc(D3D_SDK_VERSION, &pDirect3D9ExInterface); if (SUCCEEDED(hr)) { const GUID IDirect3D9_GUID = { 0x81bdcbca, 0x64d4, 0x426d, { 0xae, 0x8d, 0xad, 0x1, 0x47, 0xf4, 0x27, 0x5c } }; hr = IDirect3D9Ex_QueryInterface(pDirect3D9ExInterface, &IDirect3D9_GUID, (void**)pDirect3D9Interface); IDirect3D9Ex_Release(pDirect3D9ExInterface); if (SUCCEEDED(hr)) { return SDL_TRUE; } } } #endif /* USE_D3D9EX */ Direct3DCreate9Func = (Direct3DCreate9_t)SDL_LoadFunction(*pD3DDLL, "Direct3DCreate9"); if (Direct3DCreate9Func) { *pDirect3D9Interface = Direct3DCreate9Func(D3D_SDK_VERSION); if (*pDirect3D9Interface) { return SDL_TRUE; } } SDL_UnloadObject(*pD3DDLL); *pD3DDLL = NULL; } *pDirect3D9Interface = NULL; return SDL_FALSE; }
int extloader(lua_State * L) { const char * filename = lua_tostring(L, -1); std::string tokenized_name(filename); std::string tokenized_function(filename); for (unsigned int i = 0; i < tokenized_name.size(); i++) { if (tokenized_name[i] == '.') { tokenized_name[i] = '/'; tokenized_function[i] = '_'; } } tokenized_name += library_extension(); void * handle = SDL_LoadObject((std::string(instance->getAppdataDirectory()) + LOVE_PATH_SEPARATOR LOVE_APPDATA_FOLDER LOVE_PATH_SEPARATOR + tokenized_name).c_str()); if (!handle && instance->isRelease()) handle = SDL_LoadObject((std::string(instance->getSaveDirectory()) + LOVE_PATH_SEPARATOR + tokenized_name).c_str()); if (!handle) { lua_pushfstring(L, "\n\tno extension \"%s\" in LOVE paths.\n", filename); return 1; } void * func = SDL_LoadFunction(handle, ("loveopen_" + tokenized_function).c_str()); if (!func) func = SDL_LoadFunction(handle, ("luaopen_" + tokenized_function).c_str()); if (!func) { SDL_UnloadObject(handle); lua_pushfstring(L, "\n\textension \"%s\" is incompatible.\n", filename); return 1; } lua_pushcfunction(L, (lua_CFunction) func); return 1; }
int Mix_InitOgg() { if ( vorbis.loaded == 0 ) { vorbis.handle = SDL_LoadObject(OGG_DYNAMIC); if ( vorbis.handle == NULL ) { return -1; } vorbis.ov_clear = (int (*)(OggVorbis_File *)) SDL_LoadFunction(vorbis.handle, "ov_clear"); if ( vorbis.ov_clear == NULL ) { SDL_UnloadObject(vorbis.handle); return -1; } vorbis.ov_info = (vorbis_info *(*)(OggVorbis_File *,int)) SDL_LoadFunction(vorbis.handle, "ov_info"); if ( vorbis.ov_info == NULL ) { SDL_UnloadObject(vorbis.handle); return -1; } vorbis.ov_open_callbacks = (int (*)(void *, OggVorbis_File *, char *, long, ov_callbacks)) SDL_LoadFunction(vorbis.handle, "ov_open_callbacks"); if ( vorbis.ov_open_callbacks == NULL ) { SDL_UnloadObject(vorbis.handle); return -1; } vorbis.ov_pcm_total = (ogg_int64_t (*)(OggVorbis_File *,int)) SDL_LoadFunction(vorbis.handle, "ov_pcm_total"); if ( vorbis.ov_pcm_total == NULL ) { SDL_UnloadObject(vorbis.handle); return -1; } vorbis.ov_read = #ifdef OGG_USE_TREMOR (long (*)(OggVorbis_File *,char *,int,int *)) #else (long (*)(OggVorbis_File *,char *,int,int,int,int,int *)) #endif SDL_LoadFunction(vorbis.handle, "ov_read"); if ( vorbis.ov_read == NULL ) { SDL_UnloadObject(vorbis.handle); return -1; } vorbis.ov_time_seek = (int (*)(OggVorbis_File *,double)) SDL_LoadFunction(vorbis.handle, "ov_time_seek"); if ( vorbis.ov_time_seek == NULL ) { SDL_UnloadObject(vorbis.handle); return -1; } } ++vorbis.loaded; return 0; }
virtual VoidFunc findSymbol(const char *symbol) { void *func = SDL_LoadFunction(_dlHandle, symbol); if (!func) warning("Failed loading symbol '%s' from plugin '%s' (%s)", symbol, _filename.c_str(), SDL_GetError()); // FIXME HACK: This is a HACK to circumvent a clash between the ISO C++ // standard and POSIX: ISO C++ disallows casting between function pointers // and data pointers, but dlsym always returns a void pointer. For details, // see e.g. <http://www.trilithium.com/johan/2004/12/problem-with-dlsym/>. assert(sizeof(VoidFunc) == sizeof(func)); VoidFunc tmp; memcpy(&tmp, &func, sizeof(VoidFunc)); return tmp; }
void PluginManager::LoadPlugins() { tinydir_dir dir; if (tinydir_open(&dir, PLUGINPATH) == -1) { Log("Error opening file"); } int cpt = 0; while (dir.has_next) { tinydir_file file; if (tinydir_readfile(&dir, &file) == -1) { Log("Error getting file"); } if (std::string(file.extension) == "dll") { void* handle = nullptr; handle = SDL_LoadObject(file.path); if (handle != nullptr) { std::vector<std::string>* (*func)(); func = (std::vector<std::string>*(*)())SDL_LoadFunction(handle, "GetPluginFeatures"); if (func != nullptr) { std::vector<std::string>* pluginFeatures = func(); _plugins.push_back(handle); for (std::string& str : (*pluginFeatures)) { _features[str].push_back(handle); } delete pluginFeatures; } else Log("Unable to load GetPluginFeatures function in : " + std::string(file.path)); } else Log("Unable to load plugin : "+std::string(file.path)); } tinydir_next(&dir); } tinydir_close(&dir); }
void * SDL_EGL_GetProcAddress(_THIS, const char *proc) { static char procname[1024]; void *retval; /* eglGetProcAddress is busted on Android http://code.google.com/p/android/issues/detail?id=7681 */ #if !defined(SDL_VIDEO_DRIVER_ANDROID) && !defined(SDL_VIDEO_DRIVER_MIR) if (_this->egl_data->eglGetProcAddress) { retval = _this->egl_data->eglGetProcAddress(proc); if (retval) { return retval; } } #endif retval = SDL_LoadFunction(_this->egl_data->egl_dll_handle, proc); if (!retval && SDL_strlen(proc) <= 1022) { procname[0] = '_'; SDL_strlcpy(procname + 1, proc, 1022); retval = SDL_LoadFunction(_this->egl_data->egl_dll_handle, procname); } return retval; }
int IMG_InitWEBP() { if ( lib.loaded == 0 ) { lib.handle = SDL_LoadObject(LOAD_WEBP_DYNAMIC); if ( lib.handle == NULL ) { return -1; } lib.webp_get_features_internal = ( VP8StatusCode (*) (const uint8_t *, size_t, WebPBitstreamFeatures*, int) ) SDL_LoadFunction(lib.handle, "WebPGetFeaturesInternal" ); if ( lib.webp_get_features_internal == NULL ) { SDL_UnloadObject(lib.handle); return -1; } lib.webp_decode_rgb_into = ( uint8_t* (*) (const uint8_t*, size_t, uint8_t*, size_t, int ) ) SDL_LoadFunction(lib.handle, "WebPDecodeRGBInto" ); if ( lib.webp_decode_rgb_into == NULL ) { SDL_UnloadObject(lib.handle); return -1; } lib.webp_decode_rgba_into = ( uint8_t* (*) (const uint8_t*, size_t, uint8_t*, size_t, int ) ) SDL_LoadFunction(lib.handle, "WebPDecodeRGBAInto" ); if ( lib.webp_decode_rgba_into == NULL ) { SDL_UnloadObject(lib.handle); return -1; } } ++lib.loaded; return 0; }
bool LoadFunction ( funcptr * function, const char * funcname, void * object ) { *function = (funcptr)SDL_LoadFunction(object, funcname); if(!function) { std::cout << "Could not find reference " << SDL_GetError() << " in " << (object == Video?"Video": object == Audio?"Audio": object == RSP ?"RSP": object == Input?"Input": "Core?") << " dynamic library\n"; return 1; } return 0; }
static int LoadALSALibrary(void) { int i, retval = -1; alsa_handle = SDL_LoadObject(alsa_library); if (alsa_handle) { alsa_loaded = 1; retval = 0; for (i = 0; i < SDL_arraysize(alsa_functions); i++) { *alsa_functions[i].func = SDL_LoadFunction(alsa_handle,alsa_functions[i].name); if (!*alsa_functions[i].func) { retval = -1; UnloadALSALibrary(); break; } } } return retval; }
static BOOL CE_SHFullScreen(HWND hwndRequester, DWORD dwState) { if (SHFullScreen == 0 && aygshell_loaded == 0) { aygshell_loaded = 0; void *lib = SDL_LoadObject("aygshell.dll"); if (lib) { SHFullScreen = (BOOL(WINAPI *) (HWND, DWORD)) SDL_LoadFunction(lib, "SHFullScreen"); } } if (SHFullScreen) { SHFullScreen(hwndRequester, dwState); //printf("SHFullscreen(%i)\n",dwState); } }
static int LoadPulseLibrary(void) { int i, retval = -1; pulse_handle = SDL_LoadObject(pulse_library); if ( pulse_handle ) { pulse_loaded = 1; retval = 0; for ( i=0; i<SDL_arraysize(pulse_functions); ++i ) { *pulse_functions[i].func = SDL_LoadFunction(pulse_handle, pulse_functions[i].name); if ( !*pulse_functions[i].func ) { retval = -1; UnloadPulseLibrary(); break; } } } return retval; }
static int LoadESDLibrary(void) { int i, retval = -1; esd_handle = SDL_LoadObject(esd_library); if ( esd_handle ) { esd_loaded = 1; retval = 0; for ( i=0; i<SDL_TABLESIZE(esd_functions); ++i ) { *esd_functions[i].func = SDL_LoadFunction(esd_handle, esd_functions[i].name); if ( !*esd_functions[i].func ) { retval = -1; UnloadESDLibrary(); break; } } } return retval; }