当前位置: 首页>>代码示例>>C++>>正文


C++ SDL_LoadObject函数代码示例

本文整理汇总了C++中SDL_LoadObject函数的典型用法代码示例。如果您正苦于以下问题:C++ SDL_LoadObject函数的具体用法?C++ SDL_LoadObject怎么用?C++ SDL_LoadObject使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了SDL_LoadObject函数的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();
	}
}
开发者ID:MicroVirus,项目名称:7kaa,代码行数:34,代码来源:windows.cpp

示例2: load

bool load() {
	if (loaded) return true;
	lib           = SDL_LoadObject("libgtk-3.so.0");
	if (!lib) lib = SDL_LoadObject("libgtk-x11-2.0.so.0");
	if (!lib) {
		SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Cannot show open file dialog: no GTK library available.");
		return false;
	}

	loadFunc(g_free);
	loadFunc(gtk_dialog_get_type);
	loadFunc(gtk_dialog_run);
	loadFunc(gtk_events_pending);
	loadFunc(gtk_file_chooser_add_filter);
	loadFunc(gtk_file_chooser_dialog_new);
	loadFunc(gtk_file_chooser_get_filename);
	loadFunc(gtk_file_chooser_get_type);
	loadFunc(gtk_file_filter_add_pattern);
	loadFunc(gtk_file_filter_new);
	loadFunc(gtk_file_filter_set_name);
	loadFunc(gtk_init_check);
	loadFunc(gtk_main_iteration);
	loadFunc(gtk_widget_destroy);
	loadFunc(gtk_window_get_type);
	loadFunc(gtk_window_new);
	loadFunc(g_type_check_instance_cast);

	loaded = true;
	return true;
}
开发者ID:piernov,项目名称:OpenBoardView,代码行数:30,代码来源:unix.cpp

示例3: VIVANTE_VideoInit

int
VIVANTE_VideoInit(_THIS)
{
    SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;

#if SDL_VIDEO_DRIVER_VIVANTE_VDK
    videodata->vdk_private = vdkInitialize();
    if (!videodata->vdk_private) {
        return SDL_SetError("vdkInitialize() failed");
    }
#else
    videodata->egl_handle = SDL_LoadObject("libEGL.so.1");
    if (!videodata->egl_handle) {
        videodata->egl_handle = SDL_LoadObject("libEGL.so");
        if (!videodata->egl_handle) {
            return -1;
        }
    }
#define LOAD_FUNC(NAME) \
    videodata->NAME = SDL_LoadFunction(videodata->egl_handle, #NAME); \
    if (!videodata->NAME) return -1;

    LOAD_FUNC(fbGetDisplay);
    LOAD_FUNC(fbGetDisplayByIndex);
    LOAD_FUNC(fbGetDisplayGeometry);
    LOAD_FUNC(fbGetDisplayInfo);
    LOAD_FUNC(fbDestroyDisplay);
    LOAD_FUNC(fbCreateWindow);
    LOAD_FUNC(fbGetWindowGeometry);
    LOAD_FUNC(fbGetWindowInfo);
    LOAD_FUNC(fbDestroyWindow);
#endif

    if (VIVANTE_SetupPlatform(_this) < 0) {
        return -1;
    }

    if (VIVANTE_AddVideoDisplays(_this) < 0) {
        return -1;
    }

    VIVANTE_UpdateDisplayScale(_this);

#ifdef SDL_INPUT_LINUXEV
    if (SDL_EVDEV_Init() < 0) {
        return -1;
    }
#endif

    return 0;
}
开发者ID:GWRon,项目名称:sdl.mod,代码行数:51,代码来源:SDL_vivantevideo.c

示例4: PND_gl_loadlibrary

int
PND_gl_loadlibrary(_THIS, const char *path)
{
    SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;

    /* Check if OpenGL ES library is specified for GF driver */
    if (path == NULL) {
        path = SDL_getenv("SDL_OPENGL_LIBRARY");
        if (path == NULL) {
            path = SDL_getenv("SDL_OPENGLES_LIBRARY");
        }
    }

    /* Check if default library loading requested */
    if (path == NULL) {
        /* Already linked with GF library which provides egl* subset of  */
        /* functions, use Common profile of OpenGL ES library by default */
        path = "/usr/lib/libGLES_CM.so";
    }

    /* Load dynamic library */
    _this->gl_config.dll_handle = SDL_LoadObject(path);
    if (!_this->gl_config.dll_handle) {
        /* Failed to load new GL ES library */
        SDL_SetError("PND: Failed to locate OpenGL ES library");
        return -1;
    }

    /* Store OpenGL ES library path and name */
    SDL_strlcpy(_this->gl_config.driver_path, path,
                SDL_arraysize(_this->gl_config.driver_path));

    /* New OpenGL ES library is loaded */
    return 0;
}
开发者ID:g-truc,项目名称:shooter,代码行数:35,代码来源:SDL_pandora.c

示例5: DSOUND_Load

static int
DSOUND_Load(void)
{
    int loaded = 0;

    DSOUND_Unload();

    DSoundDLL = SDL_LoadObject("DSOUND.DLL");
    if (DSoundDLL == NULL) {
        SDL_SetError("DirectSound: failed to load DSOUND.DLL");
    } else {
        /* Now make sure we have DirectX 8 or better... */
        #define DSOUNDLOAD(f) { \
            p##f = (fn##f) SDL_LoadFunction(DSoundDLL, #f); \
            if (!p##f) loaded = 0; \
        }
        loaded = 1;  /* will reset if necessary. */
        DSOUNDLOAD(DirectSoundCreate8);
        DSOUNDLOAD(DirectSoundEnumerateW);
        DSOUNDLOAD(DirectSoundCaptureEnumerateW);
        #undef DSOUNDLOAD

        if (!loaded) {
            SDL_SetError("DirectSound: System doesn't appear to have DX8.");
        }
    }

    if (!loaded) {
        DSOUND_Unload();
    }

    return loaded;
}
开发者ID:BoonsNaibot,项目名称:kivy-ios,代码行数:33,代码来源:SDL_directsound.c

示例6: 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;

    }
开发者ID:RobertoMalatesta,项目名称:AtomicGameEngine,代码行数:34,代码来源:JSPlugin.cpp

示例7: 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;
}
开发者ID:coeuvre,项目名称:handmade,代码行数:28,代码来源:sdl_handmade.cpp

示例8: SDL_UDEV_LoadLibrary

int
SDL_UDEV_LoadLibrary(void)
{
    int retval = 0, i;
    
    if (_this == NULL) {
        return SDL_SetError("UDEV not initialized");
    }
    
   
    if (_this->udev_handle == NULL) {
        for( i = 0 ; i < SDL_arraysize(SDL_UDEV_LIBS); i++) {
            _this->udev_handle = SDL_LoadObject(SDL_UDEV_LIBS[i]);
            if (_this->udev_handle != NULL) {
                retval = SDL_UDEV_load_syms();
                if (retval < 0) {
                    SDL_UDEV_UnloadLibrary();
                }
                else {
                    break;
                }
            }
        }
        
        if (_this->udev_handle == NULL) {
            retval = -1;
            /* Don't call SDL_SetError(): SDL_LoadObject already did. */
        }
    }

    return retval;
}
开发者ID:Derek-OBrien,项目名称:DsdlEngine,代码行数:32,代码来源:SDL_udev.c

示例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;
	}
}
开发者ID:Helios-vmg,项目名称:CopperRat,代码行数:25,代码来源:SDL_windowsvideo.c

示例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;
	}
}
开发者ID:Helios-vmg,项目名称:CopperRat,代码行数:28,代码来源:SDL_windowsvideo.c

示例11: SDL_X11_LoadSymbols

/* returns non-zero if all needed symbols were loaded. */
int
SDL_X11_LoadSymbols(void)
{
    int rc = 1;                 /* always succeed if not using Dynamic X11 stuff. */

#ifdef SDL_VIDEO_DRIVER_X11_DYNAMIC
    /* deal with multiple modules (dga, x11, etc) needing these symbols... */
    if (x11_load_refcount++ == 0) {
        int i;
        int *thismod = NULL;
        for (i = 0; i < SDL_TABLESIZE(x11libs); i++) {
            if (x11libs[i].libname != NULL) {
                x11libs[i].lib = SDL_LoadObject(x11libs[i].libname);
            }
        }

#define SDL_X11_MODULE(modname) SDL_X11_HAVE_##modname = 1; /* default yes */
#define SDL_X11_SYM(a,fn,x,y,z)
#include "SDL_x11sym.h"
#undef SDL_X11_MODULE
#undef SDL_X11_SYM

#define SDL_X11_MODULE(modname) thismod = &SDL_X11_HAVE_##modname;
#define SDL_X11_SYM(a,fn,x,y,z) p##fn = (SDL_DYNX11FN_##fn) X11_GetSym(#fn,thismod);
#include "SDL_x11sym.h"
#undef SDL_X11_MODULE
#undef SDL_X11_SYM

#ifdef X_HAVE_UTF8_STRING
        pXCreateIC = (SDL_DYNX11FN_XCreateIC)
                        X11_GetSym("XCreateIC", &SDL_X11_HAVE_UTF8);
        pXGetICValues = (SDL_DYNX11FN_XGetICValues)
                        X11_GetSym("XGetICValues", &SDL_X11_HAVE_UTF8);
#endif

        if (SDL_X11_HAVE_BASEXLIB) {
            /* all required symbols loaded. */
            SDL_ClearError();
        } else {
            /* in case something got loaded... */
            SDL_X11_UnloadSymbols();
            rc = 0;
        }
    }
#else
#define SDL_X11_MODULE(modname) SDL_X11_HAVE_##modname = 1; /* default yes */
#define SDL_X11_SYM(a,fn,x,y,z)
#include "SDL_x11sym.h"
#undef SDL_X11_MODULE
#undef SDL_X11_SYM

#ifdef X_HAVE_UTF8_STRING
    pXCreateIC = XCreateIC;
    pXGetICValues = XGetICValues;
#endif
#endif

    return rc;
}
开发者ID:CarloMaker,项目名称:Urho3D,代码行数:60,代码来源:SDL_x11dyn.c

示例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;
}
开发者ID:ChickenEggSolutions,项目名称:apitest,代码行数:59,代码来源:testloadso.c

示例13: _render_context

MFCOpenGLContext::MFCOpenGLContext(HGLRC hglrc): _render_context(hglrc)
{
	if (_oglDllHandle == nullptr)
	{
		_oglDllHandle = SDL_LoadObject("OPENGL32.DLL");
	}
	++_oglDllReferenceCount;
}
开发者ID:DahBlount,项目名称:fs2open.github.com,代码行数:8,代码来源:MFCGraphicsOperations.cpp

示例14: Mix_InitOgg

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;
}
开发者ID:jcemelanda,项目名称:wormux,代码行数:58,代码来源:dynamic_ogg.c

示例15: SDL_WAYLAND_LoadSymbols

/* returns non-zero if all needed symbols were loaded. */
int
SDL_WAYLAND_LoadSymbols(void)
{
    int rc = 1;                 /* always succeed if not using Dynamic WAYLAND stuff. */

    /* deal with multiple modules (dga, wayland, etc) needing these symbols... */
    if (wayland_load_refcount++ == 0) {
#ifdef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC
        int i;
        int *thismod = NULL;
        for (i = 0; i < SDL_TABLESIZE(waylandlibs); i++) {
            if (waylandlibs[i].libname != NULL) {
                waylandlibs[i].lib = SDL_LoadObject(waylandlibs[i].libname);
            }
        }

#define SDL_WAYLAND_MODULE(modname) SDL_WAYLAND_HAVE_##modname = 1; /* default yes */
#define SDL_WAYLAND_SYM(rc,fn,params)
#define SDL_WAYLAND_INTERFACE(iface)
#include "SDL_waylandsym.h"
#undef SDL_WAYLAND_MODULE
#undef SDL_WAYLAND_SYM
#undef SDL_WAYLAND_INTERFACE

#define SDL_WAYLAND_MODULE(modname) thismod = &SDL_WAYLAND_HAVE_##modname;
#define SDL_WAYLAND_SYM(rc,fn,params) WAYLAND_##fn = (SDL_DYNWAYLANDFN_##fn) WAYLAND_GetSym(#fn,thismod);
#define SDL_WAYLAND_INTERFACE(iface) WAYLAND_##iface = (struct wl_interface *) WAYLAND_GetSym(#iface,thismod);
#include "SDL_waylandsym.h"
#undef SDL_WAYLAND_MODULE
#undef SDL_WAYLAND_SYM
#undef SDL_WAYLAND_INTERFACE

        if (SDL_WAYLAND_HAVE_WAYLAND_CLIENT) {
            /* all required symbols loaded. */
            SDL_ClearError();
        } else {
            /* in case something got loaded... */
            SDL_WAYLAND_UnloadSymbols();
            rc = 0;
        }

#else  /* no dynamic WAYLAND */

#define SDL_WAYLAND_MODULE(modname) SDL_WAYLAND_HAVE_##modname = 1; /* default yes */
#define SDL_WAYLAND_SYM(rc,fn,params) WAYLAND_##fn = fn;
#define SDL_WAYLAND_INTERFACE(iface) WAYLAND_##iface = &iface;
#include "SDL_waylandsym.h"
#undef SDL_WAYLAND_MODULE
#undef SDL_WAYLAND_SYM
#undef SDL_WAYLAND_INTERFACE

#endif
    }

    return rc;
}
开发者ID:Helios-vmg,项目名称:CopperRat,代码行数:57,代码来源:SDL_waylanddyn.c


注:本文中的SDL_LoadObject函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。