Synchronized with trunk

git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1399 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
LaurentGom 2010-02-10 14:42:53 +00:00
commit 79c7bf8e02
11 changed files with 93 additions and 49 deletions

View File

@ -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) // Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
// //
// This software is provided 'as-is', without any express or implied warranty. // This software is provided 'as-is', without any express or implied warranty.

View File

@ -10,16 +10,16 @@ setup(name='PySFML',
author_email='remi.k2620@gmail.com', author_email='remi.k2620@gmail.com',
url='http://www.sfml-dev.org/', url='http://www.sfml-dev.org/',
license='zlib/png', license='zlib/png',
ext_modules=[ Extension('PySFML.sf', \ ext_modules=[ Extension('PySFML.sf',
['src/Clock.cpp', 'src/Color.cpp', 'src/Drawable.cpp', \ ['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/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/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/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/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/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' ], \ 'src/SoundStream.cpp', 'src/Font.cpp', 'src/Glyph.cpp', 'src/Shape.cpp', 'src/ContextSettings.cpp'],
libraries=['sfml-graphics', 'sfml-window', 'sfml-audio', 'sfml-system'], \ libraries=['sfml-graphics', 'sfml-window', 'sfml-audio', 'sfml-system'],
library_dirs=['../lib/mingw'], \ library_dirs=['../lib/mingw'],
include_dirs=['../include'] include_dirs=['../include']
)], )],
package_dir = {'PySFML':'PySFML'}, package_dir = {'PySFML':'PySFML'},

View File

@ -101,5 +101,14 @@ void PySfJoy_InitConst()
obj = PyLong_FromLong(sf::Joy::AxisPOV); obj = PyLong_FromLong(sf::Joy::AxisPOV);
PyDict_SetItemString(PySfJoyType.tp_dict, "AxisPOV", obj); PyDict_SetItemString(PySfJoyType.tp_dict, "AxisPOV", obj);
Py_DECREF(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);
} }

View File

@ -95,5 +95,8 @@ void PySfMouse_InitConst()
obj = PyLong_FromLong(sf::Mouse::XButton2); obj = PyLong_FromLong(sf::Mouse::XButton2);
PyDict_SetItemString(PySfMouseType.tp_dict, "XButton2", obj); PyDict_SetItemString(PySfMouseType.tp_dict, "XButton2", obj);
Py_DECREF(obj); Py_DECREF(obj);
obj = PyLong_FromLong(sf::Mouse::ButtonCount);
PyDict_SetItemString(PySfMouseType.tp_dict, "ButtonCount", obj);
Py_DECREF(obj);
} }

View File

@ -121,7 +121,8 @@ unsigned int SoundRecorder::GetSampleRate() const
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
bool SoundRecorder::IsAvailable() 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
} }

View File

@ -251,19 +251,7 @@ void SoundStream::Run()
if (!requestStop) if (!requestStop)
{ {
if (FillAndPushBuffer(bufferNum)) if (FillAndPushBuffer(bufferNum))
{ requestStop = true;
// 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;
}
}
} }
} }
@ -293,11 +281,29 @@ bool SoundStream::FillAndPushBuffer(unsigned int bufferNum)
Chunk data = {NULL, 0}; Chunk data = {NULL, 0};
if (!OnGetData(data)) if (!OnGetData(data))
{ {
// Mark the buffer as the last one (so that we know when to reset the playing position)
myEndBuffers[bufferNum] = true; 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) if (data.Samples && data.NbSamples)
{ {
unsigned int buffer = myBuffers[bufferNum]; unsigned int buffer = myBuffers[bufferNum];
@ -322,12 +328,7 @@ bool SoundStream::FillQueue()
for (int i = 0; (i < BuffersCount) && !requestStop; ++i) for (int i = 0; (i < BuffersCount) && !requestStop; ++i)
{ {
if (FillAndPushBuffer(i)) if (FillAndPushBuffer(i))
{ requestStop = true;
if (myLoop)
OnSeek(0);
else
requestStop = true;
}
} }
return requestStop; return requestStop;

View File

@ -49,7 +49,7 @@ void Joystick::Initialize(unsigned int Index)
JoystickState Joystick::UpdateState() JoystickState Joystick::UpdateState()
{ {
// Fill a JoystickState instance with the current joystick state // Fill a JoystickState instance with the current joystick state
JoystickState s = {0}; JoystickState s;
return s; return s;
} }

View File

@ -90,16 +90,35 @@ myWheelStatus(0.0f)
{ {
if (Handle) if (Handle)
{ {
if (![(NSWindow *)Handle isKindOfClass:[NSWindow class]]) NSWindow *cocoaWindow = nil;
std::cerr << "Cannot import this Window Handle because it is not a <NSWindow *> object"
<< "(or one of its subclasses). You gave a <" // Classical window import
<< [[(NSWindow *)Handle className] UTF8String] if ([(id)Handle isKindOfClass:[NSWindow class]])
<< "> object." << std::endl; {
cocoaWindow = (NSWindow *)Handle;
}
// Qt "window" import
else if ([(id)Handle isKindOfClass:[NSView class]])
{
cocoaWindow = [(NSView *)Handle window];
}
else else
{
std::cerr
<< "Cannot import this Window Handle because it is neither"
<< "a <NSWindow *> nor <NSView *> 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 // We create the window according to the given handle
myWrapper = [[WindowWrapper alloc] initWithWindow:(NSWindow *)Handle myWrapper = [[WindowWrapper alloc] initWithWindow:cocoaWindow
settings:params settings:params
delegate:this]; delegate:this];
@ -115,6 +134,16 @@ myWheelStatus(0.0f)
std::cerr << "Failed to make the public window" << std::endl; 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;
}
} }
} }

View File

@ -33,6 +33,7 @@
#include <fcntl.h> #include <fcntl.h>
#elif defined(SFML_SYSTEM_FREEBSD) #elif defined(SFML_SYSTEM_FREEBSD)
// #include <sys/joystick.h> ? // #include <sys/joystick.h> ?
#define ABS_MAX 1
#endif #endif

View File

@ -364,20 +364,16 @@ void WindowImplWin32::SwitchToFullscreen(const VideoMode& mode)
return; return;
} }
// Change window style (no border, no titlebar, ...) // Resize the window so that it fits the entire screen
SetWindowLong(myHandle, GWL_STYLE, WS_POPUP);
SetWindowLong(myHandle, GWL_EXSTYLE, WS_EX_APPWINDOW);
// And resize it so that it fits the entire screen
SetWindowPos(myHandle, HWND_TOP, 0, 0, mode.Width, mode.Height, SWP_FRAMECHANGED); SetWindowPos(myHandle, HWND_TOP, 0, 0, mode.Width, mode.Height, SWP_FRAMECHANGED);
ShowWindow(myHandle, SW_SHOW); 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 // Set "this" as the current fullscreen window
FullscreenWindow = this; 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);
} }

View File

@ -426,6 +426,10 @@ void Window::OnEvent(const Event& event)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void Window::Initialize() void Window::Initialize()
{ {
// Clear the event queue
while (!myEvents.empty())
myEvents.pop();
// Listen to events from the new window // Listen to events from the new window
myWindow->AddListener(this); myWindow->AddListener(this);
myWindow->AddListener(&myInput); myWindow->AddListener(&myInput);