本文整理汇总了C++中SDL_LoadFunction函数的典型用法代码示例。如果您正苦于以下问题:C++ SDL_LoadFunction函数的具体用法?C++ SDL_LoadFunction怎么用?C++ SDL_LoadFunction使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SDL_LoadFunction函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WIN_InitDPI
// 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();
}
}
示例2: SDLLoadGameCode
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;
}
示例3: CallNoArgNotification
/** 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
}
示例4: jsplugin_get_entry_points
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;
}
示例5: SetBrightness
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);
}
示例6: PND_gl_getprocaddres
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;
}
示例7: WAYLAND_GetSym
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;
}
示例8: X11_GetSym
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;
}
示例9: D3D_LoadDLL
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;
}
}
示例10: DXGI_LoadDLL
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;
}
}
示例11: IMG_InitTIF
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;
}
示例12: main
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;
}
示例13: WIN_GL_LoadLibrary
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;
}
示例14: load_nas_sym
static int
load_nas_sym(const char *fn, void **addr)
{
*addr = SDL_LoadFunction(nas_handle, fn);
if (*addr == NULL) {
return 0;
}
return 1;
}
示例15: SDL_LoadFunction
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;
}