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; }
//-------------------------------------------------------------------------------------------- int cartman_mpd_add_fan_verts(cartman_mpd_t *self, cartman_mpd_tile_t *pfan) { // ZZ> This function allocates the vertices needed for a fan_idx int vertexlist[MAP_FAN_VERTICES_MAX + 1]; int vert_count; Uint8 fan_type; tile_definition_t * pdef; //Cartman::mpd_vertex_t * vrt_list; if ( NULL == pfan ) return -1; // grab the mesh if (!self) self = &mesh; //vrt_list = self->vrt2[0]; fan_type = pfan->type; // get the tile definition pdef = TILE_DICT_PTR( tile_dict, fan_type ); if ( NULL == pdef ) { log_warning( "%s - tried to add invalid fan_idx type %d\n", __FUNCTION__, fan_type ); } // check the vertex count vert_count = pdef->numvertices; if ( 0 == vert_count ) { log_warning( "%s - tried to add undefined fan_idx type %d\n", __FUNCTION__, fan_type ); } if ( vert_count > MAP_FAN_VERTICES_MAX ) { log_error( "%s - fan_idx type %d is defined with too many vertices %d\n", __FUNCTION__, fan_type, vert_count ); } cartman_mpd_allocate_vertex_list(self, vertexlist, SDL_arraysize(vertexlist), vert_count); // set the vertex posisions pfan->vrtstart = vertexlist[0]; return pfan->vrtstart; }
SDL_bool Android_Vulkan_GetInstanceExtensions(_THIS, SDL_Window *window, unsigned *count, const char **names) { static const char *const extensionsForAndroid[] = { VK_KHR_SURFACE_EXTENSION_NAME, VK_KHR_ANDROID_SURFACE_EXTENSION_NAME }; if(!_this->vulkan_config.loader_handle) { SDL_SetError("Vulkan is not loaded"); return SDL_FALSE; } return SDL_Vulkan_GetInstanceExtensions_Helper( count, names, SDL_arraysize(extensionsForAndroid), extensionsForAndroid); }
/* FIXME Mir still needs to implement its IM API, for now we assume a single key press produces a character. */ static void HandleKeyEvent(MirKeyEvent const ev, SDL_Window* window) { uint32_t scancode = SDL_SCANCODE_UNKNOWN; Uint8 key_state = ev.action == mir_key_action_up ? SDL_RELEASED : SDL_PRESSED; CheckKeyboardFocus(window); if (ev.scan_code < SDL_arraysize(xfree86_scancode_table2)) scancode = xfree86_scancode_table2[ev.scan_code]; if (scancode != SDL_SCANCODE_UNKNOWN) SDL_SendKeyboardKey(key_state, scancode); if (key_state == SDL_PRESSED) HandleKeyText(ev.key_code); }
static void SDL_DUMMY_DestroyRenderer(SDL_Renderer * renderer) { SDL_DUMMY_RenderData *data = (SDL_DUMMY_RenderData *) renderer->driverdata; int i; if (data) { for (i = 0; i < SDL_arraysize(data->screens); ++i) { if (data->screens[i]) { SDL_FreeSurface(data->screens[i]); } } SDL_free(data); } SDL_free(renderer); }
int DirectFB_GL_LoadLibrary(_THIS, const char *path) { //SDL_DFB_DEVICEDATA(_this); void *handle = NULL; SDL_DFB_DEBUG("Loadlibrary : %s\n", path); if (_this->gl_data->gl_active) { SDL_SetError("OpenGL context already created"); return -1; } if (path == NULL) { path = SDL_getenv("SDL_VIDEO_GL_DRIVER"); if (path == NULL) { path = "libGL.so"; } } handle = GL_LoadObject(path); if (handle == NULL) { SDL_DFB_ERR("Library not found: %s\n", path); /* SDL_LoadObject() will call SDL_SetError() for us. */ return -1; } SDL_DFB_DEBUG("Loaded library: %s\n", path); _this->gl_config.dll_handle = handle; _this->gl_config.driver_loaded = 1; if (path) { SDL_strlcpy(_this->gl_config.driver_path, path, SDL_arraysize(_this->gl_config.driver_path)); } else { *_this->gl_config.driver_path = '\0'; } _this->gl_data->glFinish = DirectFB_GL_GetProcAddress(_this, "glFinish"); _this->gl_data->glFlush = DirectFB_GL_GetProcAddress(_this, "glFlush"); 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; }
//-------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------- void add_object_to_table( treasure_table_t table[], const char *name ) { //ZF> Adds a new treasure object to the specified treasure table //Avoid null pointers if ( table == NULL ) return; //Make sure there is enough size to add one more if ( table->size + 1 >= TREASURE_TABLE_SIZE ) { log_warning( "No more room to add object (%s) to table, consider increasing TREASURE_TABLE_SIZE (currently %i)\n", name, TREASURE_TABLE_SIZE ); return; } //Add the element to the list strncpy( table->object_list[ table->size ], name, SDL_arraysize( table->object_list[ table->size ] ) ); table->size++; }
LoadPlayerElement::LoadPlayerElement(std::shared_ptr<ObjectProfile> profile) : _name("*NONE*"), _profile(profile), _skinRef(profile->getSkinOverride()), _selectedByPlayer(-1), _inputDevice(INPUT_DEVICE_UNKNOWN), _isSelected(false) { // load the quest info from "quest.txt" so we can determine the valid modules quest_log_download_vfs(_questLog, SDL_arraysize(_questLog), profile->getPathname().c_str()); // load the chop data from "naming.txt" to generate the character name (kinda silly how it's done currently) RandomName randomName; randomName.loadFromFile(profile->getPathname() + "/naming.txt"); // generate the name from the chop _name = randomName.generateRandomName(); }
static SDL_keysym *TranslateKey(int scancode, SDL_keysym *keysym) { /* Sanity check */ if (scancode >= SDL_arraysize(keymap)) scancode = KEYCODE_UNKNOWN; /* Set the keysym information */ keysym->scancode = scancode; keysym->sym = keymap[scancode]; keysym->mod = KMOD_NONE; /* If UNICODE is on, get the UNICODE value for the key */ keysym->unicode = 0; if (SDL_TranslateUNICODE) { /* Populate the unicode field with the ASCII value */ keysym->unicode = scancode; } return (keysym); }
//-------------------------------------------------------------------------------------------- SDL_md2_vertex_t * load_SDL_md2_vertex_RW( SDL_RWops * rw, SDL_md2_vertex_t * pdata, size_t count ) { if ( NULL == pdata ) return pdata; memset( pdata, 0, count * sizeof( SDL_md2_vertex_t ) ); if ( NULL == rw ) return pdata; for (size_t i = 0; i < count; ++i) { SDL_md2_vertex_t * pvrt = pdata + i; read_SDL_vecuc_RW( rw, pvrt->v, SDL_arraysize( pdata->v ) ); SDL_RWread( rw, &( pvrt->normalIndex ), 1, 1 ); } return pdata; }
SDL_Scancode SDL_GetScancodeFromName(const char *name) { unsigned int i; if (!name || !*name) { return SDL_SCANCODE_UNKNOWN; } for (i = 0; i < SDL_arraysize(SDL_scancode_names); ++i) { if (!SDL_scancode_names[i]) { continue; } if (SDL_strcasecmp(name, SDL_scancode_names[i]) == 0) { return static_cast<SDL_Scancode>(i); } } return SDL_SCANCODE_UNKNOWN; }
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_arraysize(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; }
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; }
void D3D_AddRenderDriver(_THIS) { SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; SDL_RendererInfo *info = &D3D_RenderDriver.info; SDL_DisplayMode *mode = &SDL_CurrentDisplay.desktop_mode; if (data->d3d) { int i; int formats[] = { SDL_PIXELFORMAT_INDEX8, SDL_PIXELFORMAT_RGB332, SDL_PIXELFORMAT_RGB444, SDL_PIXELFORMAT_RGB555, SDL_PIXELFORMAT_ARGB4444, SDL_PIXELFORMAT_ARGB1555, SDL_PIXELFORMAT_RGB565, SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB2101010, }; for (i = 0; i < SDL_arraysize(formats); ++i) { if (D3D_IsTextureFormatAvailable (data->d3d, mode->format, formats[i])) { info->texture_formats[info->num_texture_formats++] = formats[i]; } } info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_YV12; info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_IYUV; info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_YUY2; info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_UYVY; info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_YVYU; SDL_AddRenderDriver(0, &D3D_RenderDriver); } }
static void X11_DestroyRenderer(SDL_Renderer * renderer) { X11_RenderData *data = (X11_RenderData *) renderer->driverdata; int i; if (data) { for (i = 0; i < SDL_arraysize(data->pixmaps); ++i) { if (data->pixmaps[i] != None) { XFreePixmap(data->display, data->pixmaps[i]); } } if (data->gc) { XFreeGC(data->display, data->gc); } SDL_FreeDirtyRects(&data->dirty); SDL_free(data); } SDL_free(renderer); }
static SDL_Scancode TranslateKeycode(int keycode) { SDL_Scancode scancode = SDL_SCANCODE_UNKNOWN; if( keycode < SDL_arraysize( Android_Keycodes ) ) scancode = Android_Keycodes[keycode]; // if( scancode == SDL_SCANCODE_UNKNOWN ) // __android_log_print(ANDROID_LOG_INFO, "SDL", "Unknown keycode %d", keycode); // else // { // printf( "Converted Android KeyCode %i into SDL ScanCode %i", keycode, scancode ); // sprintf( str, "ScanCode %i", scancode ); // Android_JNI_ShowToast( str ); // } return scancode; }
static void keyboard_handle_key(void *data, struct wl_keyboard *keyboard, uint32_t serial, uint32_t time, uint32_t key, uint32_t state_w) { struct SDL_WaylandInput *input = data; SDL_WindowData *window = input->keyboard_focus; enum wl_keyboard_key_state state = state_w; const xkb_keysym_t *syms; uint32_t scancode; char text[8]; int size; if (key < SDL_arraysize(xfree86_scancode_table2)) { scancode = xfree86_scancode_table2[key]; // TODO when do we get WL_KEYBOARD_KEY_STATE_REPEAT? if (scancode != SDL_SCANCODE_UNKNOWN) SDL_SendKeyboardKey(state == WL_KEYBOARD_KEY_STATE_PRESSED ? SDL_PRESSED : SDL_RELEASED, scancode); } if (!window || window->keyboard_device != input || !input->xkb.state) return; // TODO can this happen? if (WAYLAND_xkb_state_key_get_syms(input->xkb.state, key + 8, &syms) != 1) return; if (state) { size = WAYLAND_xkb_keysym_to_utf8(syms[0], text, sizeof text); if (size > 0) { text[size] = 0; Wayland_data_device_set_serial(input->data_device, serial); SDL_SendKeyboardText(text); } } }
void PrintAttributes(void) { int value; // current resolution SDL_Surface *surface = SDL_GetVideoSurface(); SDL_PixelFormat *format = surface->format; DebugPrint("\nCurrent: %dx%d %dbpp\n", surface->w, surface->h, format->BitsPerPixel); // get fullscreen resolutions DebugPrint("\nResolutions:\n"); SDL_Rect **modes = SDL_ListModes(NULL, SDL_OPENGL | SDL_FULLSCREEN); for (SDL_Rect **mode = modes; *mode != NULL; ++mode) DebugPrint("%dx%d\n", (*mode)->w, (*mode)->h); const char *attrib[] = { "SDL_GL_RED_SIZE", "SDL_GL_GREEN_SIZE", "SDL_GL_BLUE_SIZE", "SDL_GL_ALPHA_SIZE", "SDL_GL_BUFFER_SIZE", "SDL_GL_DOUBLEBUFFER", "SDL_GL_DEPTH_SIZE", "SDL_GL_STENCIL_SIZE", "SDL_GL_ACCUM_RED_SIZE", "SDL_GL_ACCUM_GREEN_SIZE", "SDL_GL_ACCUM_BLUE_SIZE", "SDL_GL_ACCUM_ALPHA_SIZE", "SDL_GL_STEREO", "SDL_GL_MULTISAMPLEBUFFERS", "SDL_GL_MULTISAMPLESAMPLES", "SDL_GL_ACCELERATED_VISUAL", "SDL_GL_SWAP_CONTROL" }; for (int i = 0; i < SDL_arraysize(attrib); ++i) { SDL_GL_GetAttribute( SDL_GLattr(i), &value ); DebugPrint( "%s: %d\n", attrib[i], value); } }
//-------------------------------------------------------------------------------------------- void load_one_treasure_table_vfs( vfs_FILE* fileread, treasure_table_t* new_table ) { //ZF> Creates and loads a treasure table from the specified file until a :END is encountered new_table->size = 0; //Invalid file if ( fileread == NULL ) return; //Keep adding objects into the table until we encounter a :END while ( goto_colon( NULL, fileread, bfalse ) ) { STRING szTemp; fget_string( fileread, szTemp, SDL_arraysize( szTemp ) ); //Check if we reached the end of this table if ( 0 == strcmp( szTemp, "END" ) ) break; //Nope, add one more to the table add_object_to_table( new_table, szTemp ); } }
static void SetMMerror(char *function, MMRESULT code) { size_t len; char errbuf[MAXERRORLENGTH]; #ifdef _WIN32_WCE wchar_t werrbuf[MAXERRORLENGTH]; #endif SDL_snprintf(errbuf, SDL_arraysize(errbuf), "%s: ", function); len = SDL_strlen(errbuf); #ifdef _WIN32_WCE /* UNICODE version */ waveOutGetErrorText(code, werrbuf, MAXERRORLENGTH-len); WideCharToMultiByte(CP_ACP,0,werrbuf,-1,errbuf+len,MAXERRORLENGTH-len,NULL,NULL); #else waveOutGetErrorText(code, errbuf+len, (UINT)(MAXERRORLENGTH-len)); #endif SDL_SetError("%s",errbuf); }
static void UpdateXInputJoystickState(SDL_Joystick * joystick, XINPUT_STATE_EX *pXInputState, XINPUT_BATTERY_INFORMATION_EX *pBatteryInformation) { static WORD s_XInputButtons[] = { XINPUT_GAMEPAD_A, XINPUT_GAMEPAD_B, XINPUT_GAMEPAD_X, XINPUT_GAMEPAD_Y, XINPUT_GAMEPAD_LEFT_SHOULDER, XINPUT_GAMEPAD_RIGHT_SHOULDER, XINPUT_GAMEPAD_BACK, XINPUT_GAMEPAD_START, XINPUT_GAMEPAD_LEFT_THUMB, XINPUT_GAMEPAD_RIGHT_THUMB, XINPUT_GAMEPAD_GUIDE }; WORD wButtons = pXInputState->Gamepad.wButtons; Uint8 button; Uint8 hat = SDL_HAT_CENTERED; SDL_PrivateJoystickAxis(joystick, 0, (Sint16)pXInputState->Gamepad.sThumbLX); SDL_PrivateJoystickAxis(joystick, 1, (Sint16)(-SDL_max(-32767, pXInputState->Gamepad.sThumbLY))); SDL_PrivateJoystickAxis(joystick, 2, (Sint16)(((int)pXInputState->Gamepad.bLeftTrigger * 65535 / 255) - 32768)); SDL_PrivateJoystickAxis(joystick, 3, (Sint16)pXInputState->Gamepad.sThumbRX); SDL_PrivateJoystickAxis(joystick, 4, (Sint16)(-SDL_max(-32767, pXInputState->Gamepad.sThumbRY))); SDL_PrivateJoystickAxis(joystick, 5, (Sint16)(((int)pXInputState->Gamepad.bRightTrigger * 65535 / 255) - 32768)); for (button = 0; button < SDL_arraysize(s_XInputButtons); ++button) { SDL_PrivateJoystickButton(joystick, button, (wButtons & s_XInputButtons[button]) ? SDL_PRESSED : SDL_RELEASED); } if (wButtons & XINPUT_GAMEPAD_DPAD_UP) { hat |= SDL_HAT_UP; } if (wButtons & XINPUT_GAMEPAD_DPAD_DOWN) { hat |= SDL_HAT_DOWN; } if (wButtons & XINPUT_GAMEPAD_DPAD_LEFT) { hat |= SDL_HAT_LEFT; } if (wButtons & XINPUT_GAMEPAD_DPAD_RIGHT) { hat |= SDL_HAT_RIGHT; } SDL_PrivateJoystickHat(joystick, 0, hat); UpdateXInputJoystickBatteryInformation( joystick, pBatteryInformation ); }
void SDL_EnumUnixAudioDevices(int iscapture, int classic, int (*test)(int fd), SDL_AddAudioDevice addfn) { const int flags = ((iscapture) ? OPEN_FLAGS_INPUT : OPEN_FLAGS_OUTPUT); const char *audiodev; char audiopath[1024]; if (test == NULL) test = test_stub; /* Figure out what our audio device is */ if (((audiodev = SDL_getenv("SDL_PATH_DSP")) == NULL) && ((audiodev = SDL_getenv("AUDIODEV")) == NULL)) { if (classic) { audiodev = _PATH_DEV_AUDIO; } else { struct stat sb; /* Added support for /dev/sound/\* in Linux 2.4 */ if (((stat("/dev/sound", &sb) == 0) && S_ISDIR(sb.st_mode)) && ((stat(_PATH_DEV_DSP24, &sb) == 0) && S_ISCHR(sb.st_mode))) { audiodev = _PATH_DEV_DSP24; } else { audiodev = _PATH_DEV_DSP; } } } test_device(audiodev, flags, test, addfn); if (SDL_strlen(audiodev) < (sizeof(audiopath) - 3)) { int instance = 0; while (instance++ <= 64) { SDL_snprintf(audiopath, SDL_arraysize(audiopath), "%s%d", audiodev, instance); test_device(audiopath, flags, test, addfn); } } }
void WIMP_SetWMCaption(_THIS, const char *title, const char *icon) { _kernel_swi_regs regs; SDL_strlcpy(this->hidden->title, title, SDL_arraysize(this->hidden->title)); if (RISCOS_GetWimpVersion() < 380) { int block[6]; regs.r[1] = (int)block; _kernel_swi(Wimp_GetCaretPosition, ®s, ®s); if (block[0] == (int)this->hidden->window_handle) { regs.r[0] = -1; _kernel_swi(Wimp_SetCaretPosition, ®s,®s); } else { regs.r[0] = this->hidden->window_handle; regs.r[1] = -1; regs.r[2] = -1; regs.r[3] = -1; _kernel_swi(Wimp_SetCaretPosition, ®s,®s); } regs.r[0] = block[0]; regs.r[1] = block[1]; regs.r[2] = block[2]; regs.r[3] = block[3]; regs.r[4] = block[4]; regs.r[5] = block[5]; _kernel_swi(Wimp_SetCaretPosition, ®s,®s); } else { regs.r[0] = this->hidden->window_handle; regs.r[1] = 0x4b534154; /* "TASK" */ regs.r[2] = 3; /* Redraw title */ _kernel_swi(Wimp_ForceRedraw, ®s, ®s); } }
/* * Clean up after system specific haptic stuff */ void SDL_SYS_HapticQuit(void) { int i; for (i = 0; i < SDL_arraysize(SDL_hapticlist); ++i) { if (SDL_hapticlist[i].name) { SDL_free(SDL_hapticlist[i].name); SDL_hapticlist[i].name = NULL; } } if (dinput != NULL) { IDirectInput_Release(dinput); dinput = NULL; } if (coinitialized) { WIN_CoUninitialize(); coinitialized = SDL_FALSE; } }
/* Function to perform any system-specific joystick related cleanup */ void SDL_SYS_JoystickQuit(void) { int i; for (i = 0; i < SDL_arraysize(SYS_JoystickNames); ++i) { if (SYS_JoystickNames[i]) { SDL_free(SYS_JoystickNames[i]); SYS_JoystickNames[i] = NULL; } } if (dinput != NULL) { IDirectInput_Release(dinput); dinput = NULL; } if (coinitialized) { WIN_CoUninitialize(); coinitialized = SDL_FALSE; } }
//-------------------------------------------------------------------------------------------- bool_t setup_read_vfs() { /// @details BB@> read the setup file // Read the local setup.txt fs_ensureUserFile( "setup.txt", btrue ); snprintf( _config_filename, SDL_arraysize( _config_filename ), "%s" SLASH_STR "setup.txt", fs_getUserDirectory() ); // do NOT force the file to open in a read directory if it doesn't exist. this will cause a failure in // linux if the directory is read-only lConfigSetup = LoadConfigFile( _config_filename, bfalse ); //Did something go wrong? if ( NULL == lConfigSetup ) { log_error( "Could not load setup settings: \"%s\"\n", _config_filename ); return bfalse; } log_info( "Loaded setup file - \"%s\".\n", _config_filename ); return btrue; }
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 */ #ifdef WIZ_GLES_LITE path = "/lib/libopengles_lite.so"; #else path = "/usr/lib/libGLES_CM.so"; #endif } /* 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; }
/* Try to get the name of the program */ static char *get_progname(void) { char *progname = NULL; #ifdef __LINUX__ FILE *fp; static char temp[BUFSIZ]; SDL_snprintf(temp, SDL_arraysize(temp), "/proc/%d/cmdline", getpid()); fp = fopen(temp, "r"); if ( fp != NULL ) { if ( fgets(temp, sizeof(temp)-1, fp) ) { progname = SDL_strrchr(temp, '/'); if ( progname == NULL ) { progname = temp; } else { progname = progname+1; } } fclose(fp); } #endif return(progname); }
static int LoadFusionSoundLibrary(void) { int i, retval = -1; if (fs_handle == NULL) { fs_handle = SDL_LoadObject(fs_library); if (fs_handle != NULL) { retval = 0; for (i = 0; i < SDL_arraysize(fs_functions); ++i) { *fs_functions[i].func = SDL_LoadFunction(fs_handle, fs_functions[i].name); if (!*fs_functions[i].func) { retval = -1; UnloadFusionSoundLibrary(); break; } } } } return retval; }