static int xdpy_swap_control(ALLEGRO_DISPLAY *display, int vsync_setting) { /* We set the swap interval to 0 if vsync is forced off, and to 1 * if it is forced on. * http://www.opengl.org/registry/specs/SGI/swap_control.txt * If the option is set to 0, we simply use the system default. The * above extension specifies vsync on as default though, so in the * end with GLX we can't force vsync on, just off. */ ALLEGRO_DEBUG("requested vsync=%d.\n", vsync_setting); if (vsync_setting) { if (display->ogl_extras->extension_list->ALLEGRO_GLX_SGI_swap_control) { int x = (vsync_setting == 2) ? 0 : 1; if (glXSwapIntervalSGI(x)) { ALLEGRO_WARN("glXSwapIntervalSGI(%d) failed.\n", x); } } else { ALLEGRO_WARN("no vsync, GLX_SGI_swap_control missing.\n"); /* According to the specification that means it's on, but * the driver might have disabled it. So we do not know. */ vsync_setting = 0; } } return vsync_setting; }
static void d3d_destroy_bitmap(ALLEGRO_BITMAP *bitmap) { ALLEGRO_BITMAP_D3D *d3d_bmp = (ALLEGRO_BITMAP_D3D *)bitmap; if (!al_is_sub_bitmap(bitmap)) { if (d3d_bmp->video_texture) { if (d3d_bmp->video_texture->Release() != 0) { ALLEGRO_WARN("d3d_destroy_bitmap: Release video texture failed.\n"); } } if (d3d_bmp->system_texture) { if (d3d_bmp->system_texture->Release() != 0) { ALLEGRO_WARN("d3d_destroy_bitmap: Release system texture failed.\n"); } } if (d3d_bmp->render_target) { if (d3d_bmp->render_target->Release() != 0) { ALLEGRO_WARN("d3d_destroy_bitmap: Release render target failed.\n"); } } } _al_vector_find_and_delete(&created_bitmaps, &d3d_bmp); }
static bool glsl_set_shader_sampler(ALLEGRO_SHADER *shader, const char *name, ALLEGRO_BITMAP *bitmap, int unit) { ALLEGRO_SHADER_GLSL_S *gl_shader = (ALLEGRO_SHADER_GLSL_S *)shader; GLint handle; GLuint texture; if (bitmap && al_get_bitmap_flags(bitmap) & ALLEGRO_MEMORY_BITMAP) { ALLEGRO_WARN("Cannot use memory bitmap for sampler\n"); return false; } handle = glGetUniformLocation(gl_shader->program_object, name); if (handle < 0) { ALLEGRO_WARN("No uniform variable '%s' in shader program\n", name); return false; } glActiveTexture(GL_TEXTURE0 + unit); texture = bitmap ? al_get_opengl_texture(bitmap) : 0; glBindTexture(GL_TEXTURE_2D, texture); glUniform1i(handle, unit); return check_gl_error(name); }
static void _al_xsys_xinerama_init(ALLEGRO_SYSTEM_XGLX *s) { int event_base = 0; int error_base = 0; /* init xinerama info to defaults */ s->xinerama_available = 0; s->xinerama_screen_count = 0; s->xinerama_screen_info = NULL; _al_mutex_lock(&s->lock); if (XineramaQueryExtension(s->x11display, &event_base, &error_base)) { int minor_version = 0, major_version = 0; int status = XineramaQueryVersion(s->x11display, &major_version, &minor_version); ALLEGRO_INFO("Xinerama version: %i.%i\n", major_version, minor_version); if (status && !XineramaIsActive(s->x11display)) { ALLEGRO_WARN("Xinerama is not active\n"); } else { ALLEGRO_INFO("Xinerama is active\n"); s->xinerama_available = 1; } } else { ALLEGRO_WARN("Xinerama extension is not available.\n"); } _al_mutex_unlock(&s->lock); }
/* _al_win_thread_init: * Initializes COM interface for the calling thread. * Attempts to use Distributed COM if available (installed by default * on every 32-bit Windows starting with Win98 and Win NT4). */ void _al_win_thread_init(void) { HMODULE ole32 = NULL; if (first_call) { first_call = 0; ole32 = GetModuleHandle(TEXT("OLE32.DLL")); if (ole32 != NULL) { _CoInitializeEx = (_CoInitializeEx_ptr) GetProcAddress( ole32, "CoInitializeEx"); } else { ALLEGRO_WARN("OLE32.DLL can't be loaded.\n"); } if (_CoInitializeEx == NULL) { ALLEGRO_WARN("Microsoft Distributed COM is not installed on this system. If you have problems "); ALLEGRO_WARN("with this application, please install the DCOM update. You can find it on the "); ALLEGRO_WARN("Microsoft homepage\n"); } } if (_CoInitializeEx != NULL) _CoInitializeEx(NULL, _COINIT_MULTITHREADED); else CoInitialize(NULL); }
static bool hapxi_upload_effect(ALLEGRO_HAPTIC *dev, ALLEGRO_HAPTIC_EFFECT *effect, ALLEGRO_HAPTIC_EFFECT_ID *id) { ALLEGRO_HAPTIC_XINPUT *hapxi = hapxi_from_al(dev); ALLEGRO_HAPTIC_EFFECT_XINPUT *effxi = NULL; ASSERT(dev); ASSERT(id); ASSERT(effect); /* Set id's values to indicate failure beforehand. */ id->_haptic = NULL; id->_id = -1; id->_pointer = NULL; id->_playing = false; id->_effect_duration = 0.0; id->_start_time = 0.0; id->_end_time = 0.0; if (!al_is_haptic_effect_ok(dev, effect)) return false; al_lock_mutex(hapxi_mutex); /* Is a haptic effect slot available? */ effxi = hapxi_get_available_effect(hapxi); /* No more space for an effect. */ if (!effxi) { ALLEGRO_WARN("No free effect slot."); al_unlock_mutex(hapxi_mutex); return false; } if (!hapxi_effect2win(effxi, effect, hapxi)) { ALLEGRO_WARN("Cannot convert haptic effect to XINPUT effect.\n"); al_unlock_mutex(hapxi_mutex); return false; } effxi->state = ALLEGRO_HAPTIC_EFFECT_XINPUT_STATE_READY; effxi->effect = (*effect); /* set ID handle to signify success */ id->_haptic = dev; id->_pointer = effxi; id->_id = effxi->id; id->_effect_duration = al_get_haptic_effect_duration(effect); al_unlock_mutex(hapxi_mutex); return true; }
static bool glsl_set_shader_float_vector(ALLEGRO_SHADER *shader, const char *name, int num_components, float *f, int num_elems) { ALLEGRO_SHADER_GLSL_S *gl_shader = (ALLEGRO_SHADER_GLSL_S *)shader; GLint handle; handle = glGetUniformLocation(gl_shader->program_object, name); if (handle < 0) { ALLEGRO_WARN("No uniform variable '%s' in shader program\n", name); return false; } switch (num_components) { case 1: glUniform1fv(handle, num_elems, f); break; case 2: glUniform2fv(handle, num_elems, f); break; case 3: glUniform3fv(handle, num_elems, f); break; case 4: glUniform4fv(handle, num_elems, f); break; default: ASSERT(false); break; } return check_gl_error(name); }
static ALLEGRO_DISPLAY_INTERFACE *xglx_get_display_driver(void) { ALLEGRO_SYSTEM_XGLX *system = (ALLEGRO_SYSTEM_XGLX *)al_get_system_driver(); /* Look up the toggle_mouse_grab_key binding. This isn't such a great place * to do it, but the config file is not available until after the system driver * is initialised. */ if (!system->toggle_mouse_grab_keycode) { const char *binding = al_get_config_value(al_get_system_config(), "keyboard", "toggle_mouse_grab_key"); if (binding) { system->toggle_mouse_grab_keycode = _al_parse_key_binding(binding, &system->toggle_mouse_grab_modifiers); if (system->toggle_mouse_grab_keycode) { ALLEGRO_DEBUG("Toggle mouse grab key: '%s'\n", binding); } else { ALLEGRO_WARN("Cannot parse key binding '%s'\n", binding); } } } return _al_display_xglx_driver(); }
static bool _ogl_is_extension_with_version_supported( const char *extension, ALLEGRO_DISPLAY *disp, uint32_t ver) { ALLEGRO_CONFIG *cfg; char const *value; /* For testing purposes, any OpenGL extension can be disable in * the config by using something like: * * [opengl_disabled_extensions] * GL_ARB_texture_non_power_of_two=0 * GL_EXT_framebuffer_object=0 * */ cfg = al_get_system_config(); if (cfg) { value = al_get_config_value(cfg, "opengl_disabled_extensions", extension); if (value) { ALLEGRO_WARN("%s found in [opengl_disabled_extensions].\n", extension); return false; } } /* If the extension is included in the OpenGL version, there is no * need to check the extensions list. */ if (ver > 0 && disp->ogl_extras->ogl_info.version >= ver) { return true; } return _ogl_is_extension_supported(extension, disp); }
/* [user thread] */ static bool xgtk_create_display_hook(ALLEGRO_DISPLAY *display, int w, int h) { ALLEGRO_DISPLAY_XGLX *d = (ALLEGRO_DISPLAY_XGLX *)display; ARGS_CREATE args; d->gtk = al_calloc(1, sizeof(*(d->gtk))); if (!d->gtk) { ALLEGRO_WARN("Out of memory\n"); return false; } if (!_al_gtk_ensure_thread()) { al_free(d->gtk); d->gtk = NULL; return false; } if (!_al_gtk_init_args(&args, sizeof(args))) { al_free(d->gtk); d->gtk = NULL; return false; } args.display = d; args.w = w; args.h = h; args.title = al_get_new_window_title(); return _al_gtk_wait_for_args(do_create_display_hook, &args); }
/* Function: al_set_voice_playing */ bool al_set_voice_playing(ALLEGRO_VOICE *voice, bool val) { ASSERT(voice); if (!voice->attached_stream) { ALLEGRO_DEBUG("Voice has no attachment\n"); return false; } if (voice->is_streaming) { ALLEGRO_WARN("Attempted to change the playing state of a voice " "with a streaming attachment (mixer or audiostreams)\n"); return false; } else { bool playing = al_get_voice_playing(voice); if (playing == val) { if (playing) { ALLEGRO_DEBUG("Voice is already playing\n"); } else { ALLEGRO_DEBUG("Voice is already stopped\n"); } return true; } return _al_kcm_set_voice_playing(voice, voice->mutex, val); } }
/* Function: al_set_render_state */ void al_set_render_state(ALLEGRO_RENDER_STATE state, int value) { ALLEGRO_DISPLAY *display = al_get_current_display(); if (!display) return; switch (state) { case ALLEGRO_ALPHA_TEST: display->render_state.alpha_test = value; break; case ALLEGRO_WRITE_MASK: display->render_state.write_mask = value; break; case ALLEGRO_DEPTH_TEST: display->render_state.depth_test = value; break; case ALLEGRO_DEPTH_FUNCTION: display->render_state.depth_function = value; break; case ALLEGRO_ALPHA_FUNCTION: display->render_state.alpha_function = value; break; case ALLEGRO_ALPHA_TEST_VALUE: display->render_state.alpha_test_value = value; break; default: ALLEGRO_WARN("unknown state to change: %d\n", state); break; } if (display->vt && display->vt->update_render_state) { display->vt->update_render_state(display); } }
static HMODULE load_library_at_path(const char *path_str) { HMODULE lib; /* * XXX LoadLibrary will search the current directory for any dependencies of * the library we are loading. Using LoadLibraryEx with the appropriate * flags would fix that, but when I tried it I was unable to load dsound.dll * on Vista. */ ALLEGRO_DEBUG("Calling LoadLibrary %s\n", path_str); lib = LoadLibraryA(path_str); if (lib) { ALLEGRO_INFO("Loaded %s\n", path_str); } else { DWORD error = GetLastError(); HRESULT hr = HRESULT_FROM_WIN32(error); /* XXX do something with it */ (void)hr; ALLEGRO_WARN("Failed to load %s (error: %ld)\n", path_str, error); } return lib; }
static bool check_gl_error(const char* name) { GLenum err = glGetError(); if (err != 0) { ALLEGRO_WARN("%s (%s)\n", name, _al_gl_error_string(err)); return false; } return true; }
static bool init_dynlib(void) { #ifdef ALLEGRO_CFG_ACODEC_VORBISFILE_DLL if (ov_dll) { return true; } if (!ov_virgin) { return false; } ov_virgin = false; ov_dll = _al_open_library(ALLEGRO_CFG_ACODEC_VORBISFILE_DLL); if (!ov_dll) { ALLEGRO_WARN("Could not load " ALLEGRO_CFG_ACODEC_VORBISFILE_DLL "\n"); return false; } _al_add_exit_func(shutdown_dynlib, "shutdown_dynlib"); #define INITSYM(x) \ do \ { \ lib.x = _al_import_symbol(ov_dll, #x); \ if (lib.x == 0) { \ ALLEGRO_ERROR("undefined symbol in lib structure: " #x "\n"); \ return false; \ } \ } while(0) #else #define INITSYM(x) (lib.x = (x)) #endif memset(&lib, 0, sizeof(lib)); INITSYM(ov_clear); INITSYM(ov_open_callbacks); INITSYM(ov_pcm_total); INITSYM(ov_info); #ifndef TREMOR INITSYM(ov_time_total); INITSYM(ov_time_seek_lap); INITSYM(ov_time_tell); INITSYM(ov_read); #else INITSYM(ov_time_total); INITSYM(ov_time_seek); INITSYM(ov_time_tell); INITSYM(ov_read); #endif return true; #undef INITSYM }
GtkWidget *_al_gtk_get_window(ALLEGRO_DISPLAY *display) { ALLEGRO_DISPLAY_XGLX *d = (ALLEGRO_DISPLAY_XGLX *)display; if (d->overridable_vt == &xgtk_override_vt) { return d->gtk->gtkwindow; } ALLEGRO_WARN("Not display created with GTK.\n"); return NULL; }
/* * Calling LoadLibrary with a relative file name is a security risk: * see e.g. Microsoft Security Advisory (2269637) * "Insecure Library Loading Could Allow Remote Code Execution" */ HMODULE _al_win_safe_load_library(const char *filename) { ALLEGRO_PATH *path1 = NULL; ALLEGRO_PATH *path2 = NULL; char buf[MAX_PATH]; const char *other_dirs[3]; HMODULE lib = NULL; bool msvc_only = false; /* MSVC only: if the executable is in the build configuration directory, * which is also just under the current directory, then also try to load the * library from the current directory. This leads to less surprises when * running example programs. */ #if defined(ALLEGRO_MSVC) msvc_only = true; #endif /* Try to load the library from the directory containing the running * executable, the Windows system directories, or directories on the PATH. * Do NOT try to load the library from the current directory. */ if (al_is_system_installed()) { path1 = al_get_standard_path(ALLEGRO_RESOURCES_PATH); } else if (GetModuleFileName(NULL, buf, sizeof(buf)) < sizeof(buf)) { path1 = al_create_path(buf); } if (msvc_only) { path2 = maybe_parent_dir(path1); } other_dirs[0] = path1 ? al_path_cstr(path1, '\\') : NULL; other_dirs[1] = path2 ? al_path_cstr(path2, '\\') : NULL; other_dirs[2] = NULL; /* sentinel */ _al_sane_strncpy(buf, filename, sizeof(buf)); if (PathFindOnPath(buf, other_dirs)) { ALLEGRO_DEBUG("PathFindOnPath found: %s\n", buf); lib = load_library_at_path(buf); } else { ALLEGRO_WARN("PathFindOnPath failed to find %s\n", filename); } al_destroy_path(path1); al_destroy_path(path2); return lib; }
/* ljoy_init_joystick: [primary thread] * Initialise the joystick driver. */ static bool ljoy_init_joystick(void) { _al_vector_init(&joysticks, sizeof(ALLEGRO_JOYSTICK_LINUX *)); num_joysticks = 0; if (!(config_mutex = al_create_mutex())) { return false; } // Scan for joysticks ljoy_scan(false); ljoy_merge(); #ifdef SUPPORT_HOTPLUG if (!(hotplug_mutex = al_create_mutex())) { al_destroy_mutex(config_mutex); return false; } if (!(hotplug_cond = al_create_cond())) { al_destroy_mutex(config_mutex); al_destroy_mutex(hotplug_mutex); return false; } if (!(hotplug_thread = al_create_thread(hotplug_proc, NULL))) { al_destroy_mutex(config_mutex); al_destroy_mutex(hotplug_mutex); al_destroy_cond(hotplug_cond); return false; } al_start_thread(hotplug_thread); inotify_fd = inotify_init(); if (inotify_fd != -1) { fcntl(inotify_fd, F_SETFL, O_NONBLOCK); /* Modern Linux probably only needs to monitor /dev/input. */ inotify_add_watch(inotify_fd, "/dev/input", IN_CREATE|IN_DELETE); _al_unix_start_watching_fd(inotify_fd, ljoy_config_dev_changed, NULL); ALLEGRO_INFO("Hotplugging enabled\n"); } else { ALLEGRO_WARN("Hotplugging not enabled\n"); if (inotify_fd != -1) { close(inotify_fd); inotify_fd = -1; } } #endif return true; }
/* The voice_is_playing method should only be called on non-streaming sources, and should return true if the voice is playing */ static bool _dsound_voice_is_playing(const ALLEGRO_VOICE *voice) { ALLEGRO_DS_DATA *ex_data = (ALLEGRO_DS_DATA *)voice->extra; DWORD status; if (!ex_data) { ALLEGRO_WARN("ex_data is null\n"); return false; } ex_data->ds8_buffer->GetStatus(&status); return (status & DSBSTATUS_PLAYING); }
static int oss_open(void) { bool force_oss3 = false; ALLEGRO_CONFIG *config = al_get_system_config(); if (config) { const char *force_oss3_cfg; force_oss3_cfg = al_get_config_value(config, "oss", "force_ver3"); if (force_oss3_cfg && force_oss3_cfg[0] != '\0') force_oss3 = strcmp(force_oss3_cfg, "yes") ? false : true; } if (force_oss3) { ALLEGRO_WARN("Skipping OSS4 probe.\n"); } #ifdef OSS_VER_4 bool inited = false; if (!force_oss3) { if (oss_open_ver4()) ALLEGRO_WARN("OSS ver. 4 init failed, trying ver. 3...\n"); else inited = true; } if (!inited && oss_open_ver3()) { ALLEGRO_ERROR("Failed to init OSS.\n"); return 1; } #else ALLEGRO_INFO("OSS4 support not compiled in. Skipping OSS4 probe.\n"); if (oss_open_ver3()) { ALLEGRO_ERROR("Failed to init OSS.\n"); return 1; } #endif return 0; }
/* _al_kcm_refill_stream: * Called by the mixer when the current buffer has been used up. It should * point to the next pending buffer and reset the sample position. * Returns true if the next buffer is available and set up. * Otherwise returns false. */ bool _al_kcm_refill_stream(ALLEGRO_AUDIO_STREAM *stream) { ALLEGRO_SAMPLE_INSTANCE *spl = &stream->spl; void *old_buf = spl->spl_data.buffer.ptr; void *new_buf; size_t i; if (old_buf) { /* Slide the buffers down one position and put the * completed buffer into the used array to be refilled. */ for (i = 0; i < stream->buf_count-1 && stream->pending_bufs[i]; i++) { stream->pending_bufs[i] = stream->pending_bufs[i+1]; } stream->pending_bufs[i] = NULL; for (i = 0; stream->used_bufs[i]; i++) ; stream->used_bufs[i] = old_buf; } new_buf = stream->pending_bufs[0]; stream->spl.spl_data.buffer.ptr = new_buf; if (!new_buf) { ALLEGRO_WARN("Out of buffers\n"); return false; } /* Copy the last MAX_LAG sample values to the front of the new buffer * for interpolation. */ if (old_buf) { const int bytes_per_sample = al_get_channel_count(spl->spl_data.chan_conf) * al_get_audio_depth_size(spl->spl_data.depth); memcpy( (char *) new_buf - bytes_per_sample * MAX_LAG, (char *) old_buf + bytes_per_sample * (spl->pos-MAX_LAG), bytes_per_sample * MAX_LAG); stream->consumed_fragments++; } stream->spl.pos = 0; return true; }
/* joydx_thread_proc: [joystick thread] * Thread loop function for the joystick thread. */ static unsigned __stdcall joydx_thread_proc(LPVOID unused) { double last_update = al_get_time(); /* XXX is this needed? */ _al_win_thread_init(); while (true) { DWORD result; result = WaitForMultipleObjects(joydx_num_joysticks + 1, /* +1 for STOP_EVENT */ joydx_thread_wakers, false, /* wait for any */ 1000); /* 1 second wait */ if (result == WAIT_OBJECT_0) break; /* STOP_EVENT */ EnterCriticalSection(&joydx_thread_cs); { if (al_get_time() > last_update+1 || result == WAIT_TIMEOUT) { joydx_scan(true); last_update = al_get_time(); } if (result != WAIT_TIMEOUT) { int waker_num = result - WAIT_OBJECT_0 - 1; /* -1 for STOP_EVENT */ HANDLE waker = JOYSTICK_WAKER(waker_num); unsigned i; for (i = 0; i < MAX_JOYSTICKS; i++) { if (waker == joydx_joystick[i].waker_event) { update_joystick(&joydx_joystick[i]); break; } } if (i == MAX_JOYSTICKS) { ALLEGRO_WARN("unable to match event to joystick\n"); } } } LeaveCriticalSection(&joydx_thread_cs); } _al_win_thread_exit(); (void)unused; return 0; }
/* By default the combined xinput/directinput driver is used unless directinput * or xinput exclusive is set.*/ static ALLEGRO_JOYSTICK_DRIVER *win_get_joystick_driver(void) { if (win_use_directinput()) { ALLEGRO_DEBUG("Selected DirectInput joystick driver.\n"); return &_al_joydrv_directx; } if (win_use_xinput()) { #ifdef ALLEGRO_CFG_XINPUT ALLEGRO_DEBUG("Selected XInput joystick driver.\n"); return &_al_joydrv_xinput; #else ALLEGRO_WARN("XInput joystick driver not supported.\n"); #endif } #ifdef ALLEGRO_CFG_XINPUT ALLEGRO_DEBUG("Selected combined XInput/DirectInput joystick driver.\n"); return &_al_joydrv_windows_all; #else ALLEGRO_WARN("Combined XInput/DirectInput joystick driver not supported. Usign DirectInput in stead.\n"); return &_al_joydrv_directx; #endif }
/* By default the combined haptic driver is used unless directinput or * xinput exclusive is set in the configuration.*/ static ALLEGRO_HAPTIC_DRIVER *win_get_haptic_driver(void) { if (win_use_directinput()) { ALLEGRO_DEBUG("Selected DirectInput haptic driver.\n"); return &_al_hapdrv_directx; } if (win_use_xinput()) { #ifdef ALLEGRO_CFG_XINPUT ALLEGRO_DEBUG("Selected XInput haptic driver.\n"); return &_al_hapdrv_xinput; #else ALLEGRO_WARN("XInput haptic driver not supported.\n"); #endif } #ifdef ALLEGRO_CFG_XINPUT ALLEGRO_DEBUG("Selected combined XInput/DirectInput haptic driver.\n"); return &_al_hapdrv_windows_all; #else ALLEGRO_WARN("Combined XInput/DirectInput haptic driver not supported. Using DirectInput in stead.\n"); return &_al_hapdrv_directx; #endif }
bool _al_win_init_touch_input_api(void) { /* Reference counter will be negative if we already tried to initialize the driver. * Lack of touch input API is persistent state, so do not test for it again. */ if (touch_input_api_reference_counter < 0) return false; /* Increase API reference counter if it is already initialized. */ if (touch_input_api_reference_counter > 0) { touch_input_api_reference_counter++; return true; } /* Open handle to user32.dll. This one should be always present. */ user32_module = _al_open_library("user32.dll"); if (NULL == user32_module) return false; _al_win_close_touch_input_handle = (CLOSETOUCHINPUTHANDLEPROC)_al_import_symbol(user32_module, "CloseTouchInputHandle"); _al_win_get_touch_input_info = (GETTOUCHINPUTINFOPROC) _al_import_symbol(user32_module, "GetTouchInputInfo"); _al_win_is_touch_window = (ISTOUCHWINDOWPROC) _al_import_symbol(user32_module, "IsTouchWindow"); _al_win_register_touch_window = (REGISTERTOUCHWINDOWPROC) _al_import_symbol(user32_module, "RegisterTouchWindow"); _al_win_unregister_touch_window = (UNREGISTERTOUCHWINDOWPROC)_al_import_symbol(user32_module, "UnregisterTouchWindow"); if (NULL == _al_win_close_touch_input_handle || NULL == _al_win_get_touch_input_info || NULL == _al_win_is_touch_window || NULL == _al_win_register_touch_window || NULL == _al_win_unregister_touch_window) { _al_close_library(user32_module); _al_win_close_touch_input_handle = NULL; _al_win_get_touch_input_info = NULL; _al_win_is_touch_window = NULL; _al_win_register_touch_window = NULL; _al_win_unregister_touch_window = NULL; /* Mark as 'do not try this again'. */ touch_input_api_reference_counter = -1; ALLEGRO_WARN("failed loading the touch input API\n"); return false; } /* Set initial reference count. */ touch_input_api_reference_counter = 1; ALLEGRO_INFO("touch input API installed successfully\n"); return true; }
static bool init_dynlib(void) { #ifdef ALLEGRO_CFG_ACODEC_OPUSFILE_DLL if (op_dll) { return true; } if (!op_virgin) { return false; } op_virgin = false; op_dll = _al_open_library(ALLEGRO_CFG_ACODEC_OPUSFILE_DLL); if (!op_dll) { ALLEGRO_WARN("Could not load " ALLEGRO_CFG_ACODEC_OPUSFILE_DLL "\n"); return false; } _al_add_exit_func(shutdown_dynlib, "shutdown_dynlib"); #define INITSYM(x) \ do \ { \ lib.x = _al_import_symbol(op_dll, #x); \ if (lib.x == 0) { \ ALLEGRO_ERROR("undefined symbol in lib structure: " #x "\n"); \ return false; \ } \ } while(0) #else #define INITSYM(x) (lib.x = (x)) #endif memset(&lib, 0, sizeof(lib)); INITSYM(op_free); INITSYM(op_channel_count); INITSYM(op_open_callbacks); INITSYM(op_pcm_total); INITSYM(op_pcm_seek); INITSYM(op_pcm_tell); INITSYM(op_read); return true; #undef INITSYM }
/* Function: al_load_ogg_vorbis */ ALLEGRO_SAMPLE *al_load_ogg_vorbis(const char *filename) { ALLEGRO_FILE *f; ALLEGRO_SAMPLE *spl; ASSERT(filename); ALLEGRO_INFO("Loading sample %s.\n", filename); f = al_fopen(filename, "rb"); if (!f) { ALLEGRO_WARN("Failed reading %s.\n", filename); return NULL; } spl = al_load_ogg_vorbis_f(f); return spl; }
static bool glsl_set_shader_matrix(ALLEGRO_SHADER *shader, const char *name, ALLEGRO_TRANSFORM *matrix) { ALLEGRO_SHADER_GLSL_S *gl_shader = (ALLEGRO_SHADER_GLSL_S *)shader; GLint handle; handle = glGetUniformLocation(gl_shader->program_object, name); if (handle < 0) { ALLEGRO_WARN("No uniform variable '%s' in shader program\n", name); return false; } glUniformMatrix4fv(handle, 1, false, (float *)matrix->m); return check_gl_error(name); }
static bool glsl_set_shader_float(ALLEGRO_SHADER *shader, const char *name, float f) { ALLEGRO_SHADER_GLSL_S *gl_shader = (ALLEGRO_SHADER_GLSL_S *)shader; GLint handle; handle = glGetUniformLocation(gl_shader->program_object, name); if (handle < 0) { ALLEGRO_WARN("No uniform variable '%s' in shader program\n", name); return false; } glUniform1f(handle, f); return check_gl_error(name); }
/* Function: al_load_ogg_vorbis_audio_stream */ ALLEGRO_AUDIO_STREAM *al_load_ogg_vorbis_audio_stream(const char *filename, size_t buffer_count, unsigned int samples) { ALLEGRO_FILE *f; ALLEGRO_AUDIO_STREAM *stream; ASSERT(filename); ALLEGRO_INFO("Loading stream %s.\n", filename); f = al_fopen(filename, "rb"); if (!f) { ALLEGRO_WARN("Failed reading %s.\n", filename); return NULL; } stream = al_load_ogg_vorbis_audio_stream_f(f, buffer_count, samples); return stream; }