diff --git a/include/SFML/Graphics/Matrix3.inl b/include/SFML/Graphics/Matrix3.inl index 9be90062..23d454f9 100644 --- a/include/SFML/Graphics/Matrix3.inl +++ b/include/SFML/Graphics/Matrix3.inl @@ -1,6 +1,6 @@ //////////////////////////////////////////////////////////// // -// SFGE - Simple and Fast Game Engine +// SFGE - Simple and Fast Multimedia Library // Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) // // This software is provided 'as-is', without any express or implied warranty. diff --git a/python/setup.py b/python/setup.py index 01e6bfb8..a263fbc2 100644 --- a/python/setup.py +++ b/python/setup.py @@ -10,16 +10,16 @@ setup(name='PySFML', author_email='remi.k2620@gmail.com', url='http://www.sfml-dev.org/', license='zlib/png', - ext_modules=[ Extension('PySFML.sf', \ - ['src/Clock.cpp', 'src/Color.cpp', 'src/Drawable.cpp', \ - 'src/Event.cpp', 'src/Image.cpp', 'src/Input.cpp', 'src/Key.cpp', 'src/main.cpp', 'src/Music.cpp', \ - 'src/Shader.cpp', 'src/Rect.cpp', 'src/RenderWindow.cpp', 'src/Sleep.cpp', \ - 'src/Sprite.cpp', 'src/Text.cpp', 'src/VideoMode.cpp', 'src/View.cpp', 'src/Window.cpp', \ - 'src/Joy.cpp', 'src/Mouse.cpp', 'src/WindowStyle.cpp', 'src/Blend.cpp', 'src/Sound.cpp', \ - 'src/SoundBuffer.cpp', 'src/Listener.cpp', 'src/SoundRecorder.cpp', 'src/SoundBufferRecorder.cpp', \ - 'src/SoundStream.cpp', 'src/Font.cpp', 'src/Glyph.cpp', 'src/Shape.cpp', 'src/ContextSettings.cpp' ], \ - libraries=['sfml-graphics', 'sfml-window', 'sfml-audio', 'sfml-system'], \ - library_dirs=['../lib/mingw'], \ + ext_modules=[ Extension('PySFML.sf', + ['src/Clock.cpp', 'src/Color.cpp', 'src/Drawable.cpp', + 'src/Event.cpp', 'src/Image.cpp', 'src/Input.cpp', 'src/Key.cpp', 'src/main.cpp', 'src/Music.cpp', + 'src/Shader.cpp', 'src/Rect.cpp', 'src/RenderWindow.cpp', 'src/Sleep.cpp', + 'src/Sprite.cpp', 'src/Text.cpp', 'src/VideoMode.cpp', 'src/View.cpp', 'src/Window.cpp', + 'src/Joy.cpp', 'src/Mouse.cpp', 'src/WindowStyle.cpp', 'src/Blend.cpp', 'src/Sound.cpp', + 'src/SoundBuffer.cpp', 'src/Listener.cpp', 'src/SoundRecorder.cpp', 'src/SoundBufferRecorder.cpp', + 'src/SoundStream.cpp', 'src/Font.cpp', 'src/Glyph.cpp', 'src/Shape.cpp', 'src/ContextSettings.cpp'], + libraries=['sfml-graphics', 'sfml-window', 'sfml-audio', 'sfml-system'], + library_dirs=['../lib/mingw'], include_dirs=['../include'] )], package_dir = {'PySFML':'PySFML'}, diff --git a/python/src/Joy.cpp b/python/src/Joy.cpp index 7f20f68f..fdce88c6 100644 --- a/python/src/Joy.cpp +++ b/python/src/Joy.cpp @@ -101,5 +101,14 @@ void PySfJoy_InitConst() obj = PyLong_FromLong(sf::Joy::AxisPOV); PyDict_SetItemString(PySfJoyType.tp_dict, "AxisPOV", obj); Py_DECREF(obj); + obj = PyLong_FromLong(sf::Joy::Count); + PyDict_SetItemString(PySfJoyType.tp_dict, "Count", obj); + Py_DECREF(obj); + obj = PyLong_FromLong(sf::Joy::AxisCount); + PyDict_SetItemString(PySfJoyType.tp_dict, "AxisCount", obj); + Py_DECREF(obj); + obj = PyLong_FromLong(sf::Joy::ButtonCount); + PyDict_SetItemString(PySfJoyType.tp_dict, "ButtonCount", obj); + Py_DECREF(obj); } diff --git a/python/src/Mouse.cpp b/python/src/Mouse.cpp index d0165efc..f2fe2097 100644 --- a/python/src/Mouse.cpp +++ b/python/src/Mouse.cpp @@ -95,5 +95,8 @@ void PySfMouse_InitConst() obj = PyLong_FromLong(sf::Mouse::XButton2); PyDict_SetItemString(PySfMouseType.tp_dict, "XButton2", obj); Py_DECREF(obj); + obj = PyLong_FromLong(sf::Mouse::ButtonCount); + PyDict_SetItemString(PySfMouseType.tp_dict, "ButtonCount", obj); + Py_DECREF(obj); } diff --git a/src/SFML/Audio/SoundRecorder.cpp b/src/SFML/Audio/SoundRecorder.cpp index 37a3c254..670abfe3 100644 --- a/src/SFML/Audio/SoundRecorder.cpp +++ b/src/SFML/Audio/SoundRecorder.cpp @@ -121,7 +121,8 @@ unsigned int SoundRecorder::GetSampleRate() const //////////////////////////////////////////////////////////// bool SoundRecorder::IsAvailable() { - return priv::AudioDevice::IsExtensionSupported("ALC_EXT_CAPTURE"); + return (priv::AudioDevice::IsExtensionSupported("ALC_EXT_CAPTURE") != AL_FALSE) || + (priv::AudioDevice::IsExtensionSupported("ALC_EXT_capture") != AL_FALSE); // "bug" in Mac OS X 10.5 and 10.6 } diff --git a/src/SFML/Audio/SoundStream.cpp b/src/SFML/Audio/SoundStream.cpp index 76a2834a..885148ce 100644 --- a/src/SFML/Audio/SoundStream.cpp +++ b/src/SFML/Audio/SoundStream.cpp @@ -251,19 +251,7 @@ void SoundStream::Run() if (!requestStop) { if (FillAndPushBuffer(bufferNum)) - { - // User requested to stop: check if we must loop or really stop - if (myLoop) - { - // Looping: restart the stream source - OnSeek(0); - } - else - { - // Not looping: request stop - requestStop = true; - } - } + requestStop = true; } } @@ -293,11 +281,29 @@ bool SoundStream::FillAndPushBuffer(unsigned int bufferNum) Chunk data = {NULL, 0}; if (!OnGetData(data)) { + // Mark the buffer as the last one (so that we know when to reset the playing position) myEndBuffers[bufferNum] = true; - requestStop = true; + + // Check if the stream must loop or stop + if (myLoop) + { + // Return to the beginning of the stream source + OnSeek(0); + + // If we previously had no data, try to fill the buffer once again + if (!data.Samples || (data.NbSamples == 0)) + { + return FillAndPushBuffer(bufferNum); + } + } + else + { + // Not looping: request stop + requestStop = true; + } } - // Create and fill the buffer, and push it to the queue + // Fill the buffer if some data was returned if (data.Samples && data.NbSamples) { unsigned int buffer = myBuffers[bufferNum]; @@ -322,12 +328,7 @@ bool SoundStream::FillQueue() for (int i = 0; (i < BuffersCount) && !requestStop; ++i) { if (FillAndPushBuffer(i)) - { - if (myLoop) - OnSeek(0); - else - requestStop = true; - } + requestStop = true; } return requestStop; diff --git a/src/SFML/Window/Cocoa/Joystick.cpp b/src/SFML/Window/Cocoa/Joystick.cpp index ff2a353a..f65ac736 100644 --- a/src/SFML/Window/Cocoa/Joystick.cpp +++ b/src/SFML/Window/Cocoa/Joystick.cpp @@ -49,7 +49,7 @@ void Joystick::Initialize(unsigned int Index) JoystickState Joystick::UpdateState() { // Fill a JoystickState instance with the current joystick state - JoystickState s = {0}; + JoystickState s; return s; } diff --git a/src/SFML/Window/Cocoa/WindowImplCocoa.mm b/src/SFML/Window/Cocoa/WindowImplCocoa.mm index 4f6afddf..b1fe2204 100644 --- a/src/SFML/Window/Cocoa/WindowImplCocoa.mm +++ b/src/SFML/Window/Cocoa/WindowImplCocoa.mm @@ -90,16 +90,35 @@ myWheelStatus(0.0f) { if (Handle) { - if (![(NSWindow *)Handle isKindOfClass:[NSWindow class]]) - std::cerr << "Cannot import this Window Handle because it is not a object" - << "(or one of its subclasses). You gave a <" - << [[(NSWindow *)Handle className] UTF8String] - << "> object." << std::endl; + NSWindow *cocoaWindow = nil; + + // Classical window import + if ([(id)Handle isKindOfClass:[NSWindow class]]) + { + cocoaWindow = (NSWindow *)Handle; + } + // Qt "window" import + else if ([(id)Handle isKindOfClass:[NSView class]]) + { + cocoaWindow = [(NSView *)Handle window]; + } else + { + std::cerr + << "Cannot import this Window Handle because it is neither" + << "a nor object" + << "(or any of its subclasses). You gave a <" + << [[(id)Handle className] UTF8String] + << "> object." + << std::endl; + + } + + if (cocoaWindow) { // We create the window according to the given handle - myWrapper = [[WindowWrapper alloc] initWithWindow:(NSWindow *)Handle + myWrapper = [[WindowWrapper alloc] initWithWindow:cocoaWindow settings:params delegate:this]; @@ -115,6 +134,16 @@ myWheelStatus(0.0f) std::cerr << "Failed to make the public window" << std::endl; } } + else + { + std::cerr + << "Could not get a valid NSWindow object from the given handle" + << " (%p <" + << [[(id)Handle className] UTF8String] + << ">" + << std::endl; + } + } } diff --git a/src/SFML/Window/Linux/Joystick.hpp b/src/SFML/Window/Linux/Joystick.hpp index 17acfbaf..fd407abe 100644 --- a/src/SFML/Window/Linux/Joystick.hpp +++ b/src/SFML/Window/Linux/Joystick.hpp @@ -33,6 +33,7 @@ #include #elif defined(SFML_SYSTEM_FREEBSD) // #include ? + #define ABS_MAX 1 #endif diff --git a/src/SFML/Window/Win32/WindowImplWin32.cpp b/src/SFML/Window/Win32/WindowImplWin32.cpp index 0f3e2ac8..8c128fc9 100644 --- a/src/SFML/Window/Win32/WindowImplWin32.cpp +++ b/src/SFML/Window/Win32/WindowImplWin32.cpp @@ -364,20 +364,16 @@ void WindowImplWin32::SwitchToFullscreen(const VideoMode& mode) return; } - // Change window style (no border, no titlebar, ...) - SetWindowLong(myHandle, GWL_STYLE, WS_POPUP); - SetWindowLong(myHandle, GWL_EXSTYLE, WS_EX_APPWINDOW); - - // And resize it so that it fits the entire screen + // Resize the window so that it fits the entire screen SetWindowPos(myHandle, HWND_TOP, 0, 0, mode.Width, mode.Height, SWP_FRAMECHANGED); ShowWindow(myHandle, SW_SHOW); + // Make the window flags compatible with fullscreen mode + SetWindowLong(myHandle, GWL_STYLE, WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS); + SetWindowLong(myHandle, GWL_EXSTYLE, WS_EX_APPWINDOW); + // Set "this" as the current fullscreen window FullscreenWindow = this; - - // SetPixelFormat can fail (really ?) if window style doesn't contain these flags - long style = GetWindowLong(myHandle, GWL_STYLE); - SetWindowLong(myHandle, GWL_STYLE, style | WS_CLIPCHILDREN | WS_CLIPSIBLINGS); } diff --git a/src/SFML/Window/Window.cpp b/src/SFML/Window/Window.cpp index 60a0daff..f700455d 100644 --- a/src/SFML/Window/Window.cpp +++ b/src/SFML/Window/Window.cpp @@ -426,6 +426,10 @@ void Window::OnEvent(const Event& event) //////////////////////////////////////////////////////////// void Window::Initialize() { + // Clear the event queue + while (!myEvents.empty()) + myEvents.pop(); + // Listen to events from the new window myWindow->AddListener(this); myWindow->AddListener(&myInput);