diff --git a/bindings/d/AUTHORS b/bindings/d/AUTHORS deleted file mode 100644 index 266b2457..00000000 --- a/bindings/d/AUTHORS +++ /dev/null @@ -1,2 +0,0 @@ -SirJulio (Dagorn Julien) => sirjulio13@gmail.com -Insomniak => insomniak.fr@gmail.com diff --git a/bindings/d/LICENCE b/bindings/d/LICENCE deleted file mode 100644 index 48844753..00000000 --- a/bindings/d/LICENCE +++ /dev/null @@ -1,18 +0,0 @@ -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any damages -arising from the use of this software. - -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it -freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - - 3. This notice may not be removed or altered from any source - distribution. diff --git a/bindings/d/import/dsfml/audio/all.d b/bindings/d/import/dsfml/audio/all.d deleted file mode 100644 index 918cfb8d..00000000 --- a/bindings/d/import/dsfml/audio/all.d +++ /dev/null @@ -1,36 +0,0 @@ -/* -* DSFML - SFML Library wrapper for the D programming language. -* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com) -* Copyright (C) 2010 Andreas Hollandt -* -* This software is provided 'as-is', without any express or -* implied warranty. In no event will the authors be held -* liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute -* it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; -* you must not claim that you wrote the original software. -* If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but -* is not required. -* -* 2. Altered source versions must be plainly marked as such, -* and must not be misrepresented as being the original software. -* -* 3. This notice may not be removed or altered from any -* source distribution. -*/ - -module dsfml.audio.all; - -public import - dsfml.audio.listener, - dsfml.audio.music, - dsfml.audio.sound, - dsfml.audio.soundbuffer, - dsfml.audio.soundbufferrecorder, - dsfml.audio.soundrecorder, - dsfml.audio.soundstream; diff --git a/bindings/d/import/dsfml/audio/listener.d b/bindings/d/import/dsfml/audio/listener.d deleted file mode 100644 index 408b4e7b..00000000 --- a/bindings/d/import/dsfml/audio/listener.d +++ /dev/null @@ -1,185 +0,0 @@ -/* -* DSFML - SFML Library wrapper for the D programming language. -* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com) -* Copyright (C) 2010 Andreas Hollandt -* -* This software is provided 'as-is', without any express or -* implied warranty. In no event will the authors be held -* liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute -* it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; -* you must not claim that you wrote the original software. -* If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but -* is not required. -* -* 2. Altered source versions must be plainly marked as such, -* and must not be misrepresented as being the original software. -* -* 3. This notice may not be removed or altered from any -* source distribution. -*/ - -module dsfml.audio.listener; - -import dsfml.system.common; -import dsfml.system.vector; - -/** -* Listener is a global interface for defining the audio -* listener properties ; the audio listener is the point in -* the scene from where all the sounds are heard. -* -* See_Also: -* SFML Tutorial for sound spatialization example. -*/ -class Listener -{ - - /** - * Change the global volume of all the sounds. - * The default volume is 100 - * - * Params: - * volume = New global volume, in the range [0, 100] - */ - static void setGlobalVolume(float volume) - in - { - assert (volume >= 0.f && volume <= 100.f); - } - body - { - sfListener_SetGlobalVolume(volume); - } - - /** - * Get the current value of the global volume of all the sounds - * - * Returns: - * Current global volume, in the range [0, 100] - */ - static float getGlobalVolume() - { - return sfListener_GetGlobalVolume(); - } - - /** - * Change the position of the listener. - * The default position is (0, 0, 0) - * - * Params: - * posX = X position of the listener in the world - * posY = Y position of the listener in the world - * posZ = Z position of the listener in the world - */ - static void setPosition(float posX, float posY, float posZ) - { - sfListener_SetPosition(posX, posY, posZ); - } - - /** - * Change the position of the listener. - * The default position is (0, 0, 0) - * - * Params: - * position = new position - */ - static void setPosition(Vector3f position) - { - sfListener_SetPosition(position.x, position.y, position.z); - } - - - /** - * Get the current position of the listener - * - * Returns: - * Current position - */ - static Vector3f getPosition() - { - Vector3f ret; - sfListener_GetPosition(&ret.x, &ret.y, &ret.z); - return ret; - } - - /** - * Change the orientation of the listener - * The default direction is (0, 0, -1) - * - * Params: - * directionX = X component of the listener's direction - * directionY = Y component of the listener's direction - * directionZ = Z component of the listener's direction - */ - static void setDirection(float directionX, float directionY, float directionZ) - { - sfListener_SetDirection(directionX, directionY, directionZ); - } - - /** - * Change the orientation of the listener - * The default direction is (0, 0, -1) - * - * Params: - * direction = Position of the point the listener must look at - */ - static void setDirection(Vector3f position) - { - sfListener_SetDirection(position.x, position.y, position.z); - } - - /** - * Get the current orientation of the listener - * - * Returns: - * Position of the point the listener is looking at - */ - static Vector3f getDirection() - { - Vector3f ret; - sfListener_GetDirection(&ret.x, &ret.y, &ret.z); - return ret; - } - -private: - -// External ==================================================================== - - extern (C) - { - typedef void function(float) pf_sfListener_SetGlobalVolume; - typedef float function() pf_sfListener_GetGlobalVolume; - typedef void function(float, float, float) pf_sfListener_SetPosition; - typedef void function(float*, float*, float*) pf_sfListener_GetPosition; - typedef void function(float, float, float) pf_sfListener_SetDirection; - typedef void function(float*, float*, float*) pf_sfListener_GetDirection; - - static pf_sfListener_SetGlobalVolume sfListener_SetGlobalVolume; - static pf_sfListener_GetGlobalVolume sfListener_GetGlobalVolume; - static pf_sfListener_SetPosition sfListener_SetPosition; - static pf_sfListener_GetPosition sfListener_GetPosition; - static pf_sfListener_SetDirection sfListener_SetDirection; - static pf_sfListener_GetDirection sfListener_GetDirection; - } - - static this() - { - debug - DllLoader dll = DllLoader.load("csfml-audio-d-2"); - else - DllLoader dll = DllLoader.load("csfml-audio-2"); - - sfListener_SetGlobalVolume = cast(pf_sfListener_SetGlobalVolume)dll.getSymbol("sfListener_SetGlobalVolume"); - sfListener_GetGlobalVolume = cast(pf_sfListener_GetGlobalVolume)dll.getSymbol("sfListener_GetGlobalVolume"); - sfListener_SetPosition = cast(pf_sfListener_SetPosition)dll.getSymbol("sfListener_SetPosition"); - sfListener_GetPosition = cast(pf_sfListener_GetPosition)dll.getSymbol("sfListener_GetPosition"); - sfListener_SetDirection = cast(pf_sfListener_SetDirection)dll.getSymbol("sfListener_SetDirection"); - sfListener_GetDirection = cast(pf_sfListener_GetDirection)dll.getSymbol("sfListener_GetDirection"); - } -} diff --git a/bindings/d/import/dsfml/audio/music.d b/bindings/d/import/dsfml/audio/music.d deleted file mode 100644 index 39f64acf..00000000 --- a/bindings/d/import/dsfml/audio/music.d +++ /dev/null @@ -1,188 +0,0 @@ -/* -* DSFML - SFML Library wrapper for the D programming language. -* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com) -* Copyright (C) 2010 Andreas Hollandt -* -* This software is provided 'as-is', without any express or -* implied warranty. In no event will the authors be held -* liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute -* it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; -* you must not claim that you wrote the original software. -* If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but -* is not required. -* -* 2. Altered source versions must be plainly marked as such, -* and must not be misrepresented as being the original software. -* -* 3. This notice may not be removed or altered from any -* source distribution. -*/ - -module dsfml.audio.music; - -import dsfml.audio.soundsource; - -import dsfml.system.common; -import dsfml.system.exception; -import dsfml.system.stringutil; -import dsfml.system.vector; - -/** -* Music defines a big sound played using streaming, -* so usually what we call a music :) -*/ -class Music : SoundSource!("sfMusic") -{ - /** - * Open a music file (doesn't play it -- call Play for that) - * - * Params: - * filename = Path of the file to open - * - */ - this(string filename) - { - if (filename is null || filename.length == 0) - throw new LoadingException("LoadingException : Filename is invalid."); - - m_ptr = sfMusic_CreateFromFile(toStringz(filename)); // TODO: this is a hack, should properly call the super constructor - } - - /** - * Open a music file from memory (doesn't play it -- call Play() for that) - * - * Params: - * data = file data in memory - * - */ - this(byte[] data) - { - if (data is null || data.length == 0) - throw new Exception("LoadingException : Memory stream is invalid."); - - m_ptr = sfMusic_CreateFromMemory(data.ptr, data.length); // TODO: ditto - } - - /** - * Start playing the audio stream - */ - void play() - { - sfMusic_Play(m_ptr); - } - - /** - * Stop playing the audio stream - */ - void stop() - { - sfMusic_Stop(m_ptr); - } - - /** - * Pause the audio stream - */ - void pause() - { - sfMusic_Pause(m_ptr); - } - - - /** - * Return the number of channels (1 = mono, 2 = stereo) - * - * Returns: - * Number of channels - */ - uint getChannelsCount() - { - return sfMusic_GetChannelsCount(m_ptr); - } - - /** - * Get the stream sample rate - * - * Returns: - * Stream frequency (number of samples per second) - */ - uint getSampleRate() - { - return sfMusic_GetSampleRate(m_ptr); - } - - - /** - * Get the music duration - * - * Returns: - * Music duration, in seconds - */ - float getDuration() - { - return sfMusic_GetDuration(m_ptr); - } - - /** - * Tell whether or not the music is looping - * - * Returns: - * True if the music is looping, false otherwise - */ - bool getLoop() - { - return cast(bool)sfMusic_GetLoop(m_ptr); - } - - /** - * Set the music loop state. - * This parameter is disabled by default - * - * Params: - * loop = True to play in loop, false to play once - */ - void setLoop(bool loop) - { - sfMusic_SetLoop(m_ptr, loop); - } -} - -private: - -extern(C) -{ -SFMLClass function(cchar*) sfMusic_CreateFromFile; -SFMLClass function(byte*, size_t) sfMusic_CreateFromMemory; -void function(SFMLClass, int) sfMusic_SetLoop; -bool function(SFMLClass) sfMusic_GetLoop; -float function(SFMLClass) sfMusic_GetDuration; -void function(SFMLClass) sfMusic_Play; -void function(SFMLClass) sfMusic_Pause; -void function(SFMLClass) sfMusic_Stop; -uint function(SFMLClass) sfMusic_GetChannelsCount; -uint function(SFMLClass) sfMusic_GetSampleRate; -} - -static this() -{ -debug - DllLoader dll = DllLoader.load("csfml-audio-d-2"); -else - DllLoader dll = DllLoader.load("csfml-audio-2"); - - mixin(loadFromSharedLib("sfMusic_CreateFromFile")); - mixin(loadFromSharedLib("sfMusic_CreateFromMemory")); - mixin(loadFromSharedLib("sfMusic_SetLoop")); - mixin(loadFromSharedLib("sfMusic_GetLoop")); - mixin(loadFromSharedLib("sfMusic_GetDuration")); - mixin(loadFromSharedLib("sfMusic_Play")); - mixin(loadFromSharedLib("sfMusic_Pause")); - mixin(loadFromSharedLib("sfMusic_Stop")); - mixin(loadFromSharedLib("sfMusic_GetChannelsCount")); - mixin(loadFromSharedLib("sfMusic_GetSampleRate")); -} \ No newline at end of file diff --git a/bindings/d/import/dsfml/audio/sound.d b/bindings/d/import/dsfml/audio/sound.d deleted file mode 100644 index c13922ad..00000000 --- a/bindings/d/import/dsfml/audio/sound.d +++ /dev/null @@ -1,224 +0,0 @@ -/* - * DSFML - SFML Library wrapper for the D programming language. - * Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com) - * Copyright (C) 2010 Andreas Hollandt - * - * This software is provided 'as-is', without any express or - * implied warranty. In no event will the authors be held - * liable for any damages arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute - * it freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; - * you must not claim that you wrote the original software. - * If you use this software in a product, an acknowledgment - * in the product documentation would be appreciated but - * is not required. - * - * 2. Altered source versions must be plainly marked as such, - * and must not be misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any - * source distribution. - */ - -module dsfml.audio.sound; - -import dsfml.audio.soundbuffer; -import dsfml.audio.soundsource; - -import dsfml.system.common; -import dsfml.system.exception; -import dsfml.system.vector; - -/** - * Sound defines the properties of the sound such as position, - * volume, pitch, etc. - */ -class Sound : SoundSource!("sfSound") -{ - /** - * Default constructor - */ - this() - { - super(); - } - - /** - * Construct the sound from its parameters - * - * Params: - * soundbuffer = Sound buffer to play - * loop = Loop flag (false by default) - * pitch = Value of the pitch (1 by default) - * volume = Volume (100 by default) - * x = X position (0 by default) - * y = Y position (0 by default) - * z = Z position (0 by default) - * - * Throws: - * NullParameterException if buffer is null - */ - this(SoundBuffer soundbuffer, bool loop = false, float pitch = 1.f, float volume = 100.f, float x = 0.f, float y = 0.f, float z = 0.f) - { - if (soundbuffer is null) - throw new NullParameterException("NullParameterException : SoundBuffer is null."); - - super(); - buffer = soundbuffer; - loop = loop; - pitch = pitch; - volume = volume; - setPosition(x, y, z); - } - - - /** - * Play the sound - */ - void play() - { - sfSound_Play(m_ptr); - } - - /** - * Pause the sound - */ - void pause() - { - sfSound_Pause(m_ptr); - } - - /** - * Stop the sound - */ - void stop() - { - sfSound_Stop(m_ptr); - } - -@property -{ - /** - * Set the source buffer - * - * Params: - * buffer = New sound buffer to bind to the sound - */ - void buffer(SoundBuffer buffer) - { - if (buffer is null) - throw new NullParameterException("NullParameterException : SoundBuffer is null."); - - m_buffer = buffer; - sfSound_SetBuffer(m_ptr, buffer.nativePointer); - } - - /** - * Set the sound loop state. - * This parameter is disabled by default - * - * Params: - * loop = True to play in loop, false to play once - */ - void loop(bool loop) - { - sfSound_SetLoop(m_ptr, loop); - } - - /** - * Set the current playing offset of a sound - * - * Params: - * offset = new playing position, expressed in seconds - */ - void playingOffset(float offset) - { - sfSound_SetPlayingOffset(m_ptr, offset); - } - - - /** - * Get the source buffer - * - * Returns: - * Sound buffer bound to the sound (can be NULL) - */ - SoundBuffer buffer() - { - return m_buffer; - } - - /** - * Tell whether or not the sound is looping - * - * Returns: - * True if the sound is looping, false otherwise - */ - bool loop() - { - - return cast(bool)(sfSound_GetLoop(m_ptr)); - } - - /** - * Get the current playing position of the sound - * - * Returns: - * Current playing position, expressed in seconds - */ - float playingOffset() - { - return sfSound_GetPlayingOffset(m_ptr); - } -} - -private: - SoundBuffer m_buffer; - -// External ==================================================================== - - extern (C) - { - typedef void function(SFMLClass) pf_sfSound_Play; - typedef void function(SFMLClass) pf_sfSound_Pause; - typedef void function(SFMLClass) pf_sfSound_Stop; - typedef void function(SFMLClass, SFMLClass) pf_sfSound_SetBuffer; - typedef SFMLClass function(SFMLClass) pf_sfSound_GetBuffer; - typedef void function(SFMLClass, int) pf_sfSound_SetLoop; - typedef int function(SFMLClass) pf_sfSound_GetLoop; - typedef float function(SFMLClass) pf_sfSound_GetPlayingOffset; - typedef void function(SFMLClass, float) pf_sfSound_SetPlayingOffset; - - static pf_sfSound_Play sfSound_Play; - static pf_sfSound_Pause sfSound_Pause; - static pf_sfSound_Stop sfSound_Stop; - static pf_sfSound_SetBuffer sfSound_SetBuffer; - static pf_sfSound_GetBuffer sfSound_GetBuffer; - static pf_sfSound_SetLoop sfSound_SetLoop; - static pf_sfSound_GetLoop sfSound_GetLoop; - static pf_sfSound_GetPlayingOffset sfSound_GetPlayingOffset; - static pf_sfSound_SetPlayingOffset sfSound_SetPlayingOffset; - } - - static this() - { - debug - DllLoader dll = DllLoader.load("csfml-audio-d-2"); - else - DllLoader dll = DllLoader.load("csfml-audio-2"); - - sfSound_Play = cast(pf_sfSound_Play)dll.getSymbol("sfSound_Play"); - sfSound_Pause = cast(pf_sfSound_Pause)dll.getSymbol("sfSound_Pause"); - sfSound_Stop = cast(pf_sfSound_Stop)dll.getSymbol("sfSound_Stop"); - sfSound_SetBuffer = cast(pf_sfSound_SetBuffer)dll.getSymbol("sfSound_SetBuffer"); - sfSound_GetBuffer = cast(pf_sfSound_GetBuffer)dll.getSymbol("sfSound_GetBuffer"); - sfSound_SetLoop = cast(pf_sfSound_SetLoop)dll.getSymbol("sfSound_SetLoop"); - sfSound_GetLoop = cast(pf_sfSound_GetLoop)dll.getSymbol("sfSound_GetLoop"); - sfSound_GetPlayingOffset = cast(pf_sfSound_GetPlayingOffset)dll.getSymbol("sfSound_GetPlayingOffset"); - sfSound_SetPlayingOffset = cast(pf_sfSound_SetPlayingOffset)dll.getSymbol("sfSound_SetPlayingOffset"); - } -} \ No newline at end of file diff --git a/bindings/d/import/dsfml/audio/soundbuffer.d b/bindings/d/import/dsfml/audio/soundbuffer.d deleted file mode 100644 index b2793f7b..00000000 --- a/bindings/d/import/dsfml/audio/soundbuffer.d +++ /dev/null @@ -1,205 +0,0 @@ -/* - * DSFML - SFML Library wrapper for the D programming language. - * Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com) - * Copyright (C) 2010 Andreas Hollandt - * - * This software is provided 'as-is', without any express or - * implied warranty. In no event will the authors be held - * liable for any damages arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute - * it freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; - * you must not claim that you wrote the original software. - * If you use this software in a product, an acknowledgment - * in the product documentation would be appreciated but - * is not required. - * - * 2. Altered source versions must be plainly marked as such, - * and must not be misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any - * source distribution. - */ - -module dsfml.audio.soundbuffer; - -import dsfml.system.common; -import dsfml.system.exception; -import dsfml.system.stringutil; - - -/** - * SoundBuffer is the low-level for loading and manipulating - * sound buffers - */ -class SoundBuffer : DSFMLObject -{ - /** - * Load the sound buffer from a file - * - * Params: - * filename = Path of the sound file to load - * - * Throws: - * LoadingException on failure - */ - this(string filename) - { - if (filename is null || filename.length == 0) - throw new LoadingException("LoadingException : Filename is invalid."); - - super(sfSoundBuffer_CreateFromFile(toStringz(filename))); - } - - /** - * Load the sound buffer from a file in memory - * - * Params: - * data = Array of file data in memory - * - * Throws: - * LoadingException on failure - */ - this(byte[] data) - { - if (data is null || data.length == 0) - throw new Exception("LoadingException : Memory stream is invalid."); - - super(sfSoundBuffer_CreateFromMemory(data.ptr, data.length)); - } - - /** - * Load the sound buffer from an array of samples - assumed format for - * samples is 16 bits signed integer - * - * Params: - * samples = Array of samples in memory - * channelsCount = Number of channels (1 = mono, 2 = stereo, ...) - * sampleRate = Frequency (number of samples to play per second) - * - * Throws: - * LoadingException on failure - */ - this(const(short)[] samples, uint channelsCount, uint sampleRate) - { - if (samples is null || samples.length == 0) - throw new Exception("LoadingException : Samples array is invalid."); - - super(sfSoundBuffer_CreateFromSamples(samples.ptr, samples.length, channelsCount, sampleRate)); - } - - override void dispose() - { - sfSoundBuffer_Destroy(m_ptr); - } - - - - /** - * Save the sound buffer to a file - * - * Params: - * filename = Path of the sound file to write - * - * Returns: - * True if saving has been successful - */ - bool saveToFile(string filename) - { - if (filename !is null && filename.length > 0 ) - { - return cast(bool)sfSoundBuffer_SaveToFile(m_ptr, toStringz(filename)); - } - return false; - } - -@property -{ - /** - * Return the sound samples - * - * Returns: - * Array of sound samples, in 16 bits signed integer format - */ - short[] samples() - { - short* temp = null; - temp = sfSoundBuffer_GetSamples(m_ptr); - - return temp is null ? null : temp[0..samplesCount()]; - } - - /** - * Return the samples count - * - * Returns: - * Number of samples - */ - size_t samplesCount() - { - return sfSoundBuffer_GetSamplesCount(m_ptr); - } - - /** - * Get the sample rate - * - * Returns: - * Sound frequency (number of samples per second) - */ - uint sampleRate() - { - return sfSoundBuffer_GetSampleRate(m_ptr); - } - - /** - * Return the number of channels (1 = mono, 2 = stereo, ...) - * - * Returns: - * Number of channels - */ - uint channelsCount() - { - return sfSoundBuffer_GetChannelsCount(m_ptr); - } - - /** - * Get the sound duration - * - * Returns: - * Sound duration, in seconds - */ - float duration() - { - return sfSoundBuffer_GetDuration(m_ptr); - } -} - -package: - this(SFMLClass ptr) - { - super(ptr, true); - } - -private: - - static extern(C) - { - SFMLClass function(cchar*) sfSoundBuffer_CreateFromFile; - SFMLClass function(const(byte)*, size_t) sfSoundBuffer_CreateFromMemory; - SFMLClass function(const(short)*, size_t, uint, uint) sfSoundBuffer_CreateFromSamples; - void function(SFMLClass) sfSoundBuffer_Destroy; - int function(SFMLClass, cchar*) sfSoundBuffer_SaveToFile; - short* function(SFMLClass) sfSoundBuffer_GetSamples; - size_t function(SFMLClass) sfSoundBuffer_GetSamplesCount; - uint function(SFMLClass) sfSoundBuffer_GetSampleRate; - uint function(SFMLClass) sfSoundBuffer_GetChannelsCount; - float function(SFMLClass) sfSoundBuffer_GetDuration; - } - - mixin(loadFromSharedLib2("csfml-audio", "sfSoundBuffer", - "CreateFromFile", "CreateFromMemory", "CreateFromSamples", "Destroy", "SaveToFile", "GetSamples", "GetSamplesCount", - "GetSampleRate", "GetChannelsCount", "GetDuration")); -} \ No newline at end of file diff --git a/bindings/d/import/dsfml/audio/soundbufferrecorder.d b/bindings/d/import/dsfml/audio/soundbufferrecorder.d deleted file mode 100644 index caf1fc50..00000000 --- a/bindings/d/import/dsfml/audio/soundbufferrecorder.d +++ /dev/null @@ -1,109 +0,0 @@ -/* -* DSFML - SFML Library wrapper for the D programming language. -* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com) -* Copyright (C) 2010 Andreas Hollandt -* -* This software is provided 'as-is', without any express or -* implied warranty. In no event will the authors be held -* liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute -* it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; -* you must not claim that you wrote the original software. -* If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but -* is not required. -* -* 2. Altered source versions must be plainly marked as such, -* and must not be misrepresented as being the original software. -* -* 3. This notice may not be removed or altered from any -* source distribution. -*/ - -module dsfml.audio.soundbufferrecorder; - -import dsfml.system.common; - -import dsfml.audio.soundbuffer; -import dsfml.audio.soundrecorder; - -/** -* Specialized sfSoundRecorder which saves the captured -* audio data into a sound buffer -*/ -class SoundBufferRecorder : SoundRecorder -{ - /** - * Constructor - */ - this() - { - super(sfSoundBufferRecorder_Create()); - } - - override void dispose() - { - sfSoundBufferRecorder_Destroy(m_ptr); - } - - /** - * Get the sound buffer containing the captured audio data - * - * Returns: - * SoundBuffer containing the captured audio data - * - */ - SoundBuffer getBuffer() - { - return new SoundBuffer(sfSoundBufferRecorder_GetBuffer(m_ptr)); - } - -protected: - - override bool onStart() - { - return true; - } - - override bool onProcessSamples(short[] s) - { - return true; - } - - override void onStop() - { - - } - -private: - -// External ==================================================================== - - extern (C) - { - typedef SFMLClass function() pf_sfSoundBufferRecorder_Create; - typedef void function(SFMLClass) pf_sfSoundBufferRecorder_Destroy; - typedef SFMLClass function(SFMLClass) pf_sfSoundBufferRecorder_GetBuffer; - - static pf_sfSoundBufferRecorder_Create sfSoundBufferRecorder_Create; - static pf_sfSoundBufferRecorder_Destroy sfSoundBufferRecorder_Destroy; - static pf_sfSoundBufferRecorder_GetBuffer sfSoundBufferRecorder_GetBuffer; - } - - static this() - { - debug - DllLoader dll = DllLoader.load("csfml-audio-d-2"); - else - DllLoader dll = DllLoader.load("csfml-audio-2"); - - sfSoundBufferRecorder_Create = cast(pf_sfSoundBufferRecorder_Create)dll.getSymbol("sfSoundBufferRecorder_Create"); - sfSoundBufferRecorder_Destroy = cast(pf_sfSoundBufferRecorder_Destroy)dll.getSymbol("sfSoundBufferRecorder_Destroy"); - sfSoundBufferRecorder_GetBuffer = cast(pf_sfSoundBufferRecorder_GetBuffer)dll.getSymbol("sfSoundBufferRecorder_GetBuffer"); - } -} - diff --git a/bindings/d/import/dsfml/audio/soundrecorder.d b/bindings/d/import/dsfml/audio/soundrecorder.d deleted file mode 100644 index 8a2562f1..00000000 --- a/bindings/d/import/dsfml/audio/soundrecorder.d +++ /dev/null @@ -1,316 +0,0 @@ -/* -* DSFML - SFML Library wrapper for the D programming language. -* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com) -* Copyright (C) 2010 Andreas Hollandt -* -* This software is provided 'as-is', without any express or -* implied warranty. In no event will the authors be held -* liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute -* it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; -* you must not claim that you wrote the original software. -* If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but -* is not required. -* -* 2. Altered source versions must be plainly marked as such, -* and must not be misrepresented as being the original software. -* -* 3. This notice may not be removed or altered from any -* source distribution. -*/ - -module dsfml.audio.soundrecorder; - -import dsfml.audio.soundbuffer; - -import dsfml.system.alloc; -import dsfml.system.common; - -import dsfml.system.linkedlist; -import dsfml.system.lock; - -import core.thread; -import core.sync.mutex; - -/** -* SoundRecorder is an interface for capturing sound data. -* -* $(B onProcessSamples and onStop will be called by a different thread, take care of synchronization issues.) -* -* Examples: -* ------- -* class MySoundRecorder : SoundRecorder -* { -* this() -* { -* -* } -* -* protected bool onStart() -* { -* return true; -* } -* -* protected void onStop() -* { -* -* } -* -* protected bool onProcessSamples(out short[]) -* { -* // Process data here -* -* return true; //return true to continue capture, else return false -* } -* } -* ------- -*/ -abstract class SoundRecorder : DSFMLObject -{ - override void dispose() - { - if (m_flag) - stop(); - - m_instances.remove(m_id); - sfSoundRecorder_Destroy(m_ptr); - } - - - /** - * Start the capture. - * - * Only one capture can happen at the same time - * - * Params: - * sampleRate : Sound frequency (the more samples, the higher the quality) - * (44100 by default = CD quality) - */ - void start(uint sampleRate = 44100) - { - sfSoundRecorder_Start(m_ptr, sampleRate); - m_t = new Thread(&threadPoll); - m_t.start(); - } - - /** - * Stop the capture - */ - void stop() - { - sfSoundRecorder_Stop(m_ptr); - m_flag = false; - m_t.join(); - m_t = null; - } - - /** - * Get the sample rate - * - * Returns: - * Frequency, in samples per second - */ - uint getSampleRate() - { - return sfSoundRecorder_GetSampleRate(m_ptr); - } - - /** - * Tell if the system supports sound capture. - * If not, this class won't be usable - * - * Returns: - * True if audio capture is supported - * - */ - static bool isAvailable() - { - return cast(bool) sfSoundRecorder_IsAvailable(); - } - -protected: - /** - * Protected constructor - */ - this() - { - m_id = ++seed; - m_instances[m_id] = this; - super(sfSoundRecorder_Create(&internalOnStart, &internalCallback, &internalOnStop, &m_id)); - - init(true); - } - - this(SFMLClass ptr) - { - super(ptr); - - init(false); - } - - /** - * Start recording audio data - * - * Returns: - * False to abort recording audio data, true to start - */ - abstract bool onStart(); - - /** - * Stop recording audio data - */ - abstract void onStop(); - - /** - * callback function - * - * Parameters: - * samples = Array of samples - * - * Returns: - * true to continue recording, false to stop. - */ - abstract bool onProcessSamples(short[] samples); - - bool m_disposed; -private: - /* - * an init function to initialize id of the object. - */ - void init(bool flag) - { - if (flag) - { - m_list = new LinkedList!(Samples)(); - - m_flag = true; - m_continue = true; - - m_mutex = new Mutex(); - } - } - - void* m_userData; - int m_id; - - static int seed = 0; - static SoundRecorder[int] m_instances; - - /* - * Extern C callback function - * - * This function must be static for C interop. To retrieve the current - * instance, we retrieve id of the sender in the user data, and search associated instance - * in the associative array. - * - * We don't call delegate or derived class on that thread because GC is not aware of this thread - * instead we enqueue data informations in a queue and poll this queue with a managed thread. - */ - extern(C) static int internalCallback(short* s, size_t size, void* user) - { - int id; - // retrieve instance - if ((id = *cast(int*)(user)) in m_instances) - { - SoundRecorder temp = m_instances[id]; - scope Lock l = new Lock(temp.m_mutex); - if (temp.m_continue) - // this new is allowed because Samples is an custom alloc class. - temp.m_list.enqueue(new Samples(s, size)); - return temp.m_continue; - } - return false; - } - - extern(C) static int internalOnStart(void* user) - { - int id; - bool ret = false; - if ((id = *cast(int*)(user)) in m_instances) - { - SoundRecorder temp = m_instances[id]; - ret = temp.onStart(); - } - - return ret; - } - - extern(C) static void internalOnStop(void* user) - { - // Nothing to do - } - - /* - * Managed thread loop - */ - void threadPoll() - { - while (m_flag) - { - Thread.sleep(50_000_0); // 50ms - // if samples are available - if (!m_list.empty) - { - // Lock ressources - scope Lock l = new Lock(m_mutex); - - Samples s = m_list.dequeue; - m_continue = this.onProcessSamples(s.data[0..s.length].dup); - - delete s; - - if (!m_continue) - { - // delete all samples left - foreach(Samples dummy; m_list) - delete dummy; - break; - } - } - } - - onStop(); - } - - Mutex m_mutex; - - bool m_flag; - bool m_continue = true; - LinkedList!(Samples) m_list; - Thread m_t; - -// External ==================================================================== - - static extern (C) - { - SFMLClass function(int function(void*), int function(const(short)*, size_t, void*), void function(void*), void*) sfSoundRecorder_Create; - void function(SFMLClass) sfSoundRecorder_Destroy; - void function(SFMLClass, uint SampleRate) sfSoundRecorder_Start; - void function(SFMLClass) sfSoundRecorder_Stop; - uint function(SFMLClass) sfSoundRecorder_GetSampleRate; - int function() sfSoundRecorder_IsAvailable; - } - - mixin(loadFromSharedLib2("csfml-audio", "sfSoundRecorder", "Create", "Destroy", "Start", - "Stop", "GetSampleRate", "IsAvailable")); -} - -// Use explicit alloc to allow instaciation by C thread -private class Samples -{ - mixin Alloc; - - this(short* data, size_t length) - { - this.data = data; - this.length = length; - } - - public short* data; - public size_t length; -} \ No newline at end of file diff --git a/bindings/d/import/dsfml/audio/soundsource.d b/bindings/d/import/dsfml/audio/soundsource.d deleted file mode 100644 index 64b9d2ba..00000000 --- a/bindings/d/import/dsfml/audio/soundsource.d +++ /dev/null @@ -1,311 +0,0 @@ -/* - * DSFML - SFML Library wrapper for the D programming language. - * Copyright (C) 2010 Andreas Hollandt - * - * This software is provided 'as-is', without any express or - * implied warranty. In no event will the authors be held - * liable for any damages arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute - * it freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; - * you must not claim that you wrote the original software. - * If you use this software in a product, an acknowledgment - * in the product documentation would be appreciated but - * is not required. - * - * 2. Altered source versions must be plainly marked as such, - * and must not be misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any - * source distribution. - */ - -module dsfml.audio.soundsource; - -import dsfml.system.vector; -import dsfml.system.common; - - -/// the sound's current status -enum SoundStatus -{ - Stopped, /// Sound is not playing - Paused, /// Sound is paused - Playing /// Sound is playing -} - -/// base class -package class SoundSource(alias derivedClassName) : DSFMLObject -{ -protected: - - /** - * Default constructor - * - * This constructor is meant ot be called by derived classes only. - * - */ - this() - { - super(sfSoundSource_Create()); - } - - this(SFMLClass ptr) - { - super(ptr); - } - - override void dispose() - { - sfSoundSource_Destroy(m_ptr); - } - -public: - - /** - * Set the 3D position of the sound in the audio scene - * - * Only sounds with one channel (mono sounds) can be spatialized. - * The default position of a sound is (0, 0, 0). - * - * Params: - * x = X coordinate of the position of the sound in the scene - * y = Y coordinate of the position of the sound in the scene - * z = Z coordinate of the position of the sound in the scene - */ - void setPosition(float x, float y, float z) - { - sfSoundSource_SetPosition(m_ptr, x, y, z); - } - -@property -{ - /** - * Get the current status of the sound (stopped, paused, playing) - * - * Returns: - * current status of the sound - */ - SoundStatus status() - { - return sfSoundSource_GetStatus(m_ptr); - } - - /** - * Set the pitch of the sound - * - * The pitch represents the perceived fundamental frequency - * of a sound; thus you can make a sound more acute or grave - * by changing its pitch. A side effect of changing the pitch - * is to modify the playing speed of the sound as well. - * The default value for the pitch is 1. - * - * Params: - * pitch = New pitch to apply to the sound - */ - void pitch(float pitch) - { - sfSoundSource_SetPitch(m_ptr, pitch); - } - - /** - * Get the pitch of the sound - * - * Returns: - * pitch of the sound - */ - float pitch() - { - return sfSoundSource_GetPitch(m_ptr); - } - - /** - * Set the volume of the sound - * - * The volume is a value between 0 (mute) and 100 (full volume). - * The default value for the volume is 100. - * - * Params: - * volume = volume of the sound - */ - void volume(float volume) - in - { - assert(volume >= 0 && volume <= 100); - } - body - { - sfSoundSource_SetVolume(m_ptr, volume); - } - - /** - * Get the volume of the sound - * - * Returns: - * Volume of the sound, in the range [0, 100] - */ - float volume() - { - return sfSoundSource_GetVolume(m_ptr); - } - - /** - * Set the 3D position of the sound in the audio scene - * - * Only sounds with one channel (mono sounds) can be - * spatialized. - * The default position of a sound is (0, 0, 0). - * - * Params: - * position = Position of the sound in the scene - */ - void position(Vector3f position) - { - sfSoundSource_SetPosition(m_ptr, position.x, position.y, position.z); - } - - /** - * Get the 3D position of the sound in the audio scene - * - * Returns: - * Position of the sound - */ - Vector3f position() - { - Vector3f ret; - sfSoundSource_GetPosition(m_ptr, &ret.x, &ret.y, &ret.z); - return ret; - } - - /** - * Make the sound's position relative to the listener or absolute - * - * Making a sound relative to the listener will ensure that it will always - * be played the same way regardless the position of the listener. - * This can be useful for non-spatialized sounds, sounds that are - * produced by the listener, or sounds attached to it. - * The default value is false (position is absolute). - * - * Params: - * relative = True to set the position relative, false to set it absolute - */ - void relativeToListener(bool relative) - { - sfSoundSource_SetRelativeToListener(m_ptr, relative); - } - - /** - * Tell whether the sound's position is relative to the listener or is absolute - * - * Returns: - * True if the position is relative, false if it's absolute - */ - bool relativeToListener() - { - return sfSoundSource_IsRelativeToListener(m_ptr); - } - - /** - * Set the minimum distance of the sound - * - * The "minimum distance" of a sound is the maximum - * distance at which it is heard at its maximum volume. Further - * than the minimum distance, it will start to fade out according - * to its attenuation factor. A value of 0 ("inside the head - * of the listener") is an invalid value and is forbidden. - * The default value of the minimum distance is 1. - * - * Params: - * distance = New minimum distance of the sound - * - * \see GetMinDistance, SetAttenuation - * - */ - void minDistance(float distance) - { - sfSoundSource_SetMinDistance(m_ptr, distance); - } - - /** - * Get the minimum distance of the sound - * - * Returns: - * Minimum distance of the sound - * - * \see SetMinDistance, GetAttenuation - * - */ - float minDistance() - { - return sfSoundSource_GetMinDistance(m_ptr); - } - - /** - * Set the attenuation factor of the sound - * - * The attenuation is a multiplicative factor which makes - * the sound more or less loud according to its distance - * from the listener. An attenuation of 0 will produce a - * non-attenuated sound, i.e. its volume will always be the same - * whether it is heard from near or from far. On the other hand, - * an attenuation value such as 100 will make the sound fade out - * very quickly as it gets further from the listener. - * The default value of the attenuation is 1. - * - * Params: - * attenuation = New attenuation factor of the sound - * - * \see GetAttenuation, SetMinDistance - * - */ - void attenuation(float attenuation) - { - sfSoundSource_SetAttenuation(m_ptr, attenuation); - } - - /** - * Get the attenuation factor of the sound - * - * Returns: - * Attenuation factor of the sound - * - * \see SetAttenuation, GetMinDistance - * - */ - float attenuation() - { - return sfSoundSource_GetAttenuation(m_ptr); - } -} // of @property - - -private: - - static extern(C) - { - SFMLClass function() sfSoundSource_Create; - void function(SFMLClass) sfSoundSource_Destroy; - - SoundStatus function(SFMLClass) sfSoundSource_GetStatus; - void function(SFMLClass, float) sfSoundSource_SetPitch; - void function(SFMLClass, float) sfSoundSource_SetVolume; - void function(SFMLClass, float, float, float) sfSoundSource_SetPosition; - float function(SFMLClass) sfSoundSource_GetPitch; - float function(SFMLClass) sfSoundSource_GetVolume; - void function(SFMLClass, float*, float*, float*) sfSoundSource_GetPosition; - float function(SFMLClass) sfSoundSource_GetMinDistance; - float function(SFMLClass) sfSoundSource_GetAttenuation; - void function(SFMLClass, float) sfSoundSource_SetMinDistance; - void function(SFMLClass, float) sfSoundSource_SetAttenuation; - - void function(SFMLClass, bool) sfSoundSource_SetRelativeToListener; - bool function(SFMLClass) sfSoundSource_IsRelativeToListener; - } - - mixin(loadDerivedFromSharedLib("csfml-audio", "sfSoundSource", derivedClassName, - "Create", "Destroy", "GetStatus", "GetPitch", "SetPitch", "GetVolume", "SetVolume", "GetPosition", "SetPosition", - "GetMinDistance", "SetMinDistance", "GetAttenuation", "SetAttenuation", "SetRelativeToListener", "IsRelativeToListener")); -} \ No newline at end of file diff --git a/bindings/d/import/dsfml/audio/soundstream.d b/bindings/d/import/dsfml/audio/soundstream.d deleted file mode 100644 index 8fb4d060..00000000 --- a/bindings/d/import/dsfml/audio/soundstream.d +++ /dev/null @@ -1,384 +0,0 @@ -/* -* DSFML - SFML Library wrapper for the D programming language. -* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com) -* Copyright (C) 2010 Andreas Hollandt -* -* This software is provided 'as-is', without any express or -* implied warranty. In no event will the authors be held -* liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute -* it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; -* you must not claim that you wrote the original software. -* If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but -* is not required. -* -* 2. Altered source versions must be plainly marked as such, -* and must not be misrepresented as being the original software. -* -* 3. This notice may not be removed or altered from any -* source distribution. -*/ - -module dsfml.audio.soundstream; - -import dsfml.system.alloc; -import dsfml.system.common; -import dsfml.system.vector; -import dsfml.system.linkedlist; -import dsfml.system.lock; - -import core.thread; -import core.sync.mutex; - -import dsfml.audio.sound; -import dsfml.audio.soundsource; - -/** -* SoundStream is a streamed sound, ie samples are acquired -* while the sound is playing. Use it for big sounds that would -* require hundreds of MB in memory, or for streaming sound from the network. -* -* SoundStream is a base class and cannot be instanciated directly. -* -* $(B onGetData override will be called by a different thread, take care of synchronization issues.) onStart is called by the thread which called .play(). -* -* ------------------------ -* class MySoundStream : SoundStream -* { -* this() -* { -* super(2, 44100); // you need to initialize the base class before any operation. -* } -* protected bool onGetData(out short[] data) -* { -* //You need to fill data array with some samples -* -* return true; //or false if you want to stop playback -* } -* -* protected bool onStart() -* { -* return true; -* } -* } -* ------------------------ -*/ -abstract class SoundStream : SoundSource!("sfSoundStream") -{ - override void dispose() - { - stop(); - sfSoundStream_Destroy(m_ptr); - s_instances.remove(m_id); - } - - /** - * Start playing the stream - */ - void play() - { - m_flag = true; - sfSoundStream_Play(m_ptr); - - if (status != SoundStatus.Paused) - { - m_t = new Thread(&threadPoll); - m_t.start(); - } - } - - /** - * Pause the stream - */ - void pause() - { - sfSoundStream_Pause(m_ptr); - } - - /** - * Stop the stream - */ - void stop() - { - m_flag = false; - sfSoundStream_Stop(m_ptr); - m_t.join(); - if (m_dummy !is null) - delete m_dummy; - } - -@property -{ - /** - * Get number of channels of the stream - * - * Returns: - * number of channels - */ - uint channelsCount() - { - return m_channelsCount; - } - - /** - * Get the sample rate of the stream - * - * Returns: - * sample rate - */ - uint sampleRate() - { - return m_sampleRate; - } - - /** - * Get the current playing offset of the stream - * - * Returns: - * current playing offset, in seconds. - */ - float playingOffset() - { - return sfSoundStream_GetPlayingOffset(m_ptr); - } - - /** - * Set the current playing position of a music - * - * Params: - * timeOffset = New playing position, expressed in seconds - */ - void playingOffset(float timeOffset) - { - sfSoundStream_SetPlayingOffset(m_ptr, timeOffset); - } - - /** - * Tell whether or not the stream is looping - * - * Returns: - * True if the music is looping, false otherwise - */ - bool loop() - { - if (m_ptr !is null) - return cast(bool)sfSoundStream_GetLoop(m_ptr); - return false; - } - - /** - * Set the stream loop state. - * - * Disabled by default. - * - * Params: - * loop = true to play in loop, false to play once - */ - void loop(bool loop) - { - if (m_ptr !is null) - sfSoundStream_SetLoop(m_ptr, loop); - } -} // of @property - -protected: - /** - * Protected constructor - * - * Params: - * channelsCount = number of channel - * sampleRate = sample rate of the stream - * - */ - this(uint channelsCount, uint sampleRate) - { - m_channelsCount = channelsCount; - m_sampleRate = sampleRate; - - super(sfSoundStream_Create(&externalOnGetData, &externalOnSeek, channelsCount, sampleRate, &m_id)); - - m_mutex = new Mutex(); - - m_samples = new LinkedList!(Data); - - m_t = new Thread(&this.threadPoll); - - m_id = ++s_seed; - s_instances[m_id] = this; - } - - /** - * Called each time the stream is seeked - */ - abstract void onSeek(float timeOffset); - - /** - * Called each time the stream needs new data. - * This method will be call by an other thread, take care of possible synchronisation issues. - * - * Params: - * data = array of samples to stream - * - * Returns: - * true to continue streaming, false to stop - */ - abstract bool onGetData(out short[] data); -private: - - // Called sync when user calling play() - // TODO: check if it's correct that way - extern(C) static void externalOnSeek(float t, void* user) - { - int id; - if ((id = *cast(int*) user) in s_instances) - { - SoundStream temp = s_instances[id]; - return (temp.onSeek(t)); - } - } - - // C Thread callback (no allocation can be done) - extern (C) static int externalOnGetData(sfSoundStreamChunk* data, void* user) - { - int id, flag = false; - // Get calling soundStream - if ((id = *cast(int*) user) in s_instances) - { - SoundStream temp = s_instances[id]; - //if no samples are available but streaming is not stopped, we sleep the thread - while (temp.m_samples.empty && temp.m_flag) - Thread.sleep(10_000_0); // 10ms - - scope Lock l = new Lock(temp.m_mutex); - if (!temp.m_samples.empty) - { - if (temp.m_dummy !is null) - delete temp.m_dummy; - - temp.m_dummy = temp.m_samples.dequeue; - - if ((flag = temp.m_dummy.Flag) == true) - { - data.Samples = temp.m_dummy.Samples.ptr; - data.NbSamples = temp.m_dummy.Samples.length; - } - else - { - data.Samples = null; - data.NbSamples = 0; - } - } - } - return flag; - } - - // Managed thread loop - void threadPoll() - { - short[] data; - bool ret = true; - // while streaming is active ... - while (ret && m_flag) - { - { - scope Lock l = new Lock(m_mutex); - // see how many samples are available (keep always 2 samples ready) - if (m_samples.getCount < 2) - { - // if we need new samples, lock and call derived class - ret = onGetData(data); - m_samples.enqueue(new Data(data, ret)); - } - } - Thread.sleep(100_000_0); // 100ms - } - } - - private class Data - { - short[] Samples; - bool Flag; - - mixin Alloc; - - this (short[] samples, bool flag) - { - this.Samples = samples; - this.Flag = flag; - } - } - - Thread m_t; - Mutex m_mutex; - LinkedList!(Data) m_samples; - Data m_dummy; - - bool m_flag; - - uint m_channelsCount; - uint m_sampleRate; - - int m_id; - static SoundStream[int] s_instances; - static int s_seed = 0; - -// External ==================================================================== - - extern (C) - { - struct sfSoundStreamChunk{ short* Samples; uint NbSamples; } - - alias void function(float, void*) sfSoundStreamSeekCallback; - alias int function (sfSoundStreamChunk*, void*) sfSoundStreamGetDataCallback; - - alias SFMLClass function(sfSoundStreamGetDataCallback, sfSoundStreamSeekCallback, uint, uint, void*) pf_sfSoundStream_Create; - alias void function(SFMLClass) pf_sfSoundStream_Destroy; - alias void function(SFMLClass) pf_sfSoundStream_Play; - alias void function(SFMLClass) pf_sfSoundStream_Pause; - alias void function(SFMLClass) pf_sfSoundStream_Stop; - alias uint function(SFMLClass) pf_sfSoundStream_GetChannelsCount; - alias uint function(SFMLClass) pf_sfSoundStream_GetSampleRate; - alias float function(SFMLClass) pf_sfSoundStream_GetPlayingOffset; - alias void function(SFMLClass, float) pf_sfSoundStream_SetPlayingOffset; - alias int function(SFMLClass) pf_sfSoundStream_GetLoop; - alias void function(SFMLClass, int) pf_sfSoundStream_SetLoop; - - - static pf_sfSoundStream_Create sfSoundStream_Create; - static pf_sfSoundStream_Destroy sfSoundStream_Destroy; - static pf_sfSoundStream_Play sfSoundStream_Play; - static pf_sfSoundStream_Pause sfSoundStream_Pause; - static pf_sfSoundStream_Stop sfSoundStream_Stop; - static pf_sfSoundStream_GetChannelsCount sfSoundStream_GetChannelsCount; - static pf_sfSoundStream_GetSampleRate sfSoundStream_GetSampleRate; - static pf_sfSoundStream_GetPlayingOffset sfSoundStream_GetPlayingOffset; - static pf_sfSoundStream_SetPlayingOffset sfSoundStream_SetPlayingOffset; - static pf_sfSoundStream_GetLoop sfSoundStream_GetLoop; - static pf_sfSoundStream_SetLoop sfSoundStream_SetLoop; - } - - static this() - { - debug - DllLoader dll = DllLoader.load("csfml-audio-d-2"); - else - DllLoader dll = DllLoader.load("csfml-audio-2"); - - sfSoundStream_Create = cast(pf_sfSoundStream_Create)dll.getSymbol("sfSoundStream_Create"); - sfSoundStream_Destroy = cast(pf_sfSoundStream_Destroy)dll.getSymbol("sfSoundStream_Destroy"); - sfSoundStream_Play = cast(pf_sfSoundStream_Play)dll.getSymbol("sfSoundStream_Play"); - sfSoundStream_Pause = cast(pf_sfSoundStream_Pause)dll.getSymbol("sfSoundStream_Pause"); - sfSoundStream_Stop = cast(pf_sfSoundStream_Stop)dll.getSymbol("sfSoundStream_Stop"); - sfSoundStream_GetChannelsCount = cast(pf_sfSoundStream_GetChannelsCount)dll.getSymbol("sfSoundStream_GetChannelsCount"); - sfSoundStream_GetSampleRate = cast(pf_sfSoundStream_GetSampleRate)dll.getSymbol("sfSoundStream_GetSampleRate"); - sfSoundStream_GetPlayingOffset = cast(pf_sfSoundStream_GetPlayingOffset)dll.getSymbol("sfSoundStream_GetPlayingOffset"); - sfSoundStream_SetPlayingOffset = cast(pf_sfSoundStream_SetPlayingOffset)dll.getSymbol("sfSoundStream_SetPlayingOffset"); - sfSoundStream_GetLoop = cast(pf_sfSoundStream_GetLoop)dll.getSymbol("sfSoundStream_GetLoop"); - sfSoundStream_SetLoop = cast(pf_sfSoundStream_SetLoop)dll.getSymbol("sfSoundStream_SetLoop"); - } -} \ No newline at end of file diff --git a/bindings/d/import/dsfml/graphics/all.d b/bindings/d/import/dsfml/graphics/all.d deleted file mode 100644 index 9fc102ce..00000000 --- a/bindings/d/import/dsfml/graphics/all.d +++ /dev/null @@ -1,41 +0,0 @@ -/* -* DSFML - SFML Library wrapper for the D programming language. -* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com) -* Copyright (C) 2010 Andreas Hollandt -* -* This software is provided 'as-is', without any express or -* implied warranty. In no event will the authors be held -* liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute -* it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; -* you must not claim that you wrote the original software. -* If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but -* is not required. -* -* 2. Altered source versions must be plainly marked as such, -* and must not be misrepresented as being the original software. -* -* 3. This notice may not be removed or altered from any -* source distribution. -*/ - -module dsfml.graphics.all; - -public import - dsfml.graphics.blendmode, - dsfml.graphics.color, - dsfml.graphics.font, - dsfml.graphics.idrawable, - dsfml.graphics.image, - dsfml.graphics.shader, - dsfml.graphics.rect, - dsfml.graphics.renderwindow, - dsfml.graphics.shape, - dsfml.graphics.sprite, - dsfml.graphics.text, - dsfml.graphics.view; diff --git a/bindings/d/import/dsfml/graphics/blendmode.d b/bindings/d/import/dsfml/graphics/blendmode.d deleted file mode 100644 index fcb91e74..00000000 --- a/bindings/d/import/dsfml/graphics/blendmode.d +++ /dev/null @@ -1,38 +0,0 @@ -/* -* DSFML - SFML Library wrapper for the D programming language. -* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com) -* Copyright (C) 2010 Andreas Hollandt -* -* This software is provided 'as-is', without any express or -* implied warranty. In no event will the authors be held -* liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute -* it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; -* you must not claim that you wrote the original software. -* If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but -* is not required. -* -* 2. Altered source versions must be plainly marked as such, -* and must not be misrepresented as being the original software. -* -* 3. This notice may not be removed or altered from any -* source distribution. -*/ - -module dsfml.graphics.blendmode; - -/** -* Enumerate the blending modes for drawable objects. -*/ -enum BlendMode -{ - ALPHA, /// Pixel = Src * a + Dest * (1 - a) - ADD, /// Pixel = Src + Dest - MULTIPLY, /// Pixel = Src * Dest - NONE /// No blending -} diff --git a/bindings/d/import/dsfml/graphics/color.d b/bindings/d/import/dsfml/graphics/color.d deleted file mode 100644 index 8750fd7a..00000000 --- a/bindings/d/import/dsfml/graphics/color.d +++ /dev/null @@ -1,123 +0,0 @@ -/* -* DSFML - SFML Library wrapper for the D programming language. -* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com) -* Copyright (C) 2010 Andreas Hollandt -* -* This software is provided 'as-is', without any express or -* implied warranty. In no event will the authors be held -* liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute -* it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; -* you must not claim that you wrote the original software. -* If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but -* is not required. -* -* 2. Altered source versions must be plainly marked as such, -* and must not be misrepresented as being the original software. -* -* 3. This notice may not be removed or altered from any -* source distribution. -*/ - -module dsfml.graphics.color; - -import std.string; - -alias RGBA Color; // standard Color is RGBA - -/** - * Color is an utility structure for manipulating colors - */ -struct RGBA -{ -align(1): - ubyte r; /// Red component - ubyte g; /// Green component - ubyte b; /// Blue component - ubyte a = 255; /// Alpha (transparency) component, 255 = opaque - - /** - * Operator == and != overload to compare two colors - */ - const bool opEquals(ref const(Color) color2) - { - return - (r == color2.r) - && (g == color2.g) - && (b == color2.b) - && (a == color2.a); - } - /** - * Operator + overload to add two colors - */ - Color opAdd(Color color2) - { - ubyte r = this.r + color2.r > 255 ? 255 : cast(ubyte) (this.r + color2.r); - ubyte g = this.g + color2.g > 255 ? 255 : cast(ubyte) (this.g + color2.g); - ubyte b = this.b + color2.b > 255 ? 255 : cast(ubyte) (this.b + color2.b); - ubyte a = this.a + color2.a > 255 ? 255 : cast(ubyte) (this.a + color2.a); - - return Color(r, g, b, a); - } - - /** - * Operator += overload - */ - Color opAddAssign(Color color2) - { - this.r = this.r + color2.r > 255 ? 255 : cast(ubyte) (this.r + color2.r); - this.g = this.g + color2.g > 255 ? 255 : cast(ubyte) (this.g + color2.g); - this.b = this.b + color2.b > 255 ? 255 : cast(ubyte) (this.b + color2.b); - this.a = this.a + color2.a > 255 ? 255 : cast(ubyte) (this.a + color2.a); - - return this; - } - - /** - * Operator * overload to modulate colors - */ - Color opMul(Color color2) - { - ubyte r = cast(ubyte) (this.r * color2.r / 255); - ubyte g = cast(ubyte) (this.g * color2.g / 255); - ubyte b = cast(ubyte) (this.b * color2.b / 255); - ubyte a = cast(ubyte) (this.a * color2.a / 255); - - return Color(r, g, b, a); - } - - /** - * Operator *= overload - */ - Color opMulAssign(Color color2) - { - this.r = cast(ubyte) (this.r * color2.r / 255); - this.g = cast(ubyte) (this.g * color2.g / 255); - this.b = cast(ubyte) (this.b * color2.b / 255); - this.a = cast(ubyte) (this.a * color2.a / 255); - - return this; - } - - string toString() - { - return std.string.format("(%d,%d,%d,%d)", r,g,b,a); - } - - static immutable - { - Color BLACK = Color(0, 0, 0); /// Black predefined color - Color WHITE = Color(255, 255, 255); /// White predefined color - Color RED = Color(255, 0, 0); /// Red predefined color - Color GREEN = Color(0, 255, 0); /// Green predefined color - Color BLUE = Color(0, 0, 255); /// Blue predefined color - Color YELLOW = Color(255, 0, 255); /// Yellow predefined color - Color MAGENTA = Color(255, 0, 255); /// Magenta predefined color - Color CYAN = Color(0, 255, 255); /// Cyan predefined color - } -} \ No newline at end of file diff --git a/bindings/d/import/dsfml/graphics/drawableimpl.d b/bindings/d/import/dsfml/graphics/drawableimpl.d deleted file mode 100644 index 916876e9..00000000 --- a/bindings/d/import/dsfml/graphics/drawableimpl.d +++ /dev/null @@ -1,268 +0,0 @@ -/* -* DSFML - SFML Library wrapper for the D programming language. -* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com) -* Copyright (C) 2010 Andreas Hollandt -* -* This software is provided 'as-is', without any express or -* implied warranty. In no event will the authors be held -* liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute -* it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; -* you must not claim that you wrote the original software. -* If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but -* is not required. -* -* 2. Altered source versions must be plainly marked as such, -* and must not be misrepresented as being the original software. -* -* 3. This notice may not be removed or altered from any -* source distribution. -*/ - -module dsfml.graphics.drawableimpl; - -public import dsfml.system.common; -import dsfml.system.vector; - -import dsfml.graphics.irendertarget; -import dsfml.graphics.idrawable, - dsfml.graphics.color, - dsfml.graphics.blendmode, - dsfml.graphics.renderwindow, - dsfml.graphics.renderimage, - dsfml.graphics.shader; - - -/* - * Package base class of all drawable. - * Provide implementation of IDrawable and functions aliases. - */ -package class DrawableImpl(string derivedClassName) : DSFMLObject, IDrawable -{ -protected: - this() - { - super(sfDrawable_Create()); - } - - this(SFMLClass ptr) - { - super(ptr, true); - } - - override void dispose() - { - sfDrawable_Destroy(m_ptr); - } - -public: - override void rotate(float angle) - { - sfDrawable_Rotate(m_ptr, angle); - } - - override void move(float offsetX, float offsetY) - { - sfDrawable_Move(m_ptr, offsetX, offsetY); - } - - override void move(Vector2f offset) - { - sfDrawable_Move(m_ptr, offset.x, offset.y); - } - - override Vector2f transformToLocal(Vector2f point) const - { - Vector2f ret; - sfDrawable_TransformToLocal(m_ptr, point.x, point.y, &ret.x, &ret.y); - return ret; - } - - override Vector2f transformToGlobal(Vector2f point) const - { - Vector2f ret; - sfDrawable_TransformToLocal(m_ptr, point.x, point.y, &ret.x, &ret.y); - return ret; - } - - override void render(IRenderTarget window) - { - sfRenderWindow_DrawThis((cast(DSFMLObject)window).nativePointer, m_ptr); - } - - override void renderWithShader(IRenderTarget window, Shader shader) - { - sfRenderWindow_DrawThisWithShader((cast(DSFMLObject)window).nativePointer, m_ptr, shader.nativePointer); - } - - override void setPosition(float x, float y) - { - sfDrawable_SetPosition(m_ptr, x, y); - } - - override void setScale(float scaleX, float scaleY) - { - sfDrawable_SetScale(m_ptr, scaleX, scaleY); - } - - override void setOrigin(float originX, float originY) - { - sfDrawable_SetOrigin(m_ptr, originX, originY); - } - -@property -{ - override void x(float x) - { - sfDrawable_SetX(m_ptr, x); - } - - override void y(float y) - { - sfDrawable_SetY(m_ptr, y); - } - - override void position(Vector2f vec) - { - sfDrawable_SetPosition(m_ptr, vec.x, vec.y); - } - - override void scaleX(float scale) - { - if (scale > 0) - sfDrawable_SetScaleX(m_ptr, scale); - } - - override void scaleY(float scale) - { - if (scale > 0) - sfDrawable_SetScaleY(m_ptr, scale); - } - - override void scale(Vector2f scale) - { - if (scale.x > 0 && scale.y > 0) - sfDrawable_SetScale(m_ptr, scale.x, scale.y); - } - - override void origin(Vector2f origin) - { - sfDrawable_SetOrigin(m_ptr, origin.x, origin.y); - } - - override void rotation(float angle) - { - sfDrawable_SetRotation(m_ptr, angle); - } - - override void color(Color c) - { - sfDrawable_SetColor(m_ptr, c); - } - - override void blendMode(BlendMode mode) - { - sfDrawable_SetBlendMode(m_ptr, mode); - } - - override Vector2f position() const - { - return Vector2f(sfDrawable_GetX(m_ptr), sfDrawable_GetY(m_ptr)); - } - - override Vector2f scale() const - { - return Vector2f(sfDrawable_GetScaleX(m_ptr), sfDrawable_GetScaleY(m_ptr)); - } - - override Vector2f origin() const - { - return Vector2f(sfDrawable_GetOriginX(m_ptr), sfDrawable_GetOriginY(m_ptr)); - } - - override float rotation() const - { - return sfDrawable_GetRotation(m_ptr); - } - - override Color color() const - { - return sfDrawable_GetColor(m_ptr); - } - - override BlendMode blendMode() const - { - return cast(BlendMode)(sfDrawable_GetBlendMode(m_ptr)); - } - - override void scale(Vector2f scale) - { - sfDrawable_SetScale(m_ptr, scale.x, scale.y); - } -} - -private: - - static extern(C) - { - SFMLClass function() sfDrawable_Create; - void function(SFMLClass) sfDrawable_Destroy; - void function(SFMLClass, float) sfDrawable_SetX; - void function(SFMLClass, float) sfDrawable_SetY; - void function(SFMLClass, float, float) sfDrawable_SetPosition; - void function(SFMLClass, float) sfDrawable_SetScaleX; - void function(SFMLClass, float) sfDrawable_SetScaleY; - void function(SFMLClass, float, float) sfDrawable_SetScale; - void function(SFMLClass, float) sfDrawable_SetRotation; - void function(SFMLClass, float, float) sfDrawable_SetOrigin; - void function(SFMLClass, Color) sfDrawable_SetColor; - void function(SFMLClass, BlendMode) sfDrawable_SetBlendMode; - float function(SFMLClass) sfDrawable_GetX; - float function(SFMLClass) sfDrawable_GetY; - float function(SFMLClass) sfDrawable_GetScaleX; - float function(SFMLClass) sfDrawable_GetScaleY; - float function(SFMLClass) sfDrawable_GetRotation; - float function(SFMLClass) sfDrawable_GetOriginX; - float function(SFMLClass) sfDrawable_GetOriginY; - Color function(SFMLClass) sfDrawable_GetColor; - BlendMode function(SFMLClass) sfDrawable_GetBlendMode; - void function(SFMLClass, float, float) sfDrawable_Move; - void function(SFMLClass, float, float) sfDrawable_Scale; - void function(SFMLClass, float) sfDrawable_Rotate; - void function(SFMLClass, float, float, float*, float*) sfDrawable_TransformToLocal; - void function(SFMLClass, float, float, float*, float*) sfDrawable_TransformToGlobal; - - typedef void function(SFMLClass, SFMLClass) pf_sfRenderWindow_DrawThis; - typedef void function(SFMLClass, SFMLClass, SFMLClass) pf_sfRenderWindow_DrawThisWithShader; - typedef void function(SFMLClass, SFMLClass) pf_sfRenderImage_DrawThis; - typedef void function(SFMLClass, SFMLClass, SFMLClass) pf_sfRenderImage_DrawThisWithShader; - - pf_sfRenderWindow_DrawThis sfRenderWindow_DrawThis; - pf_sfRenderWindow_DrawThisWithShader sfRenderWindow_DrawThisWithShader; - pf_sfRenderImage_DrawThis sfRenderImage_DrawThis; - pf_sfRenderImage_DrawThisWithShader sfRenderImage_DrawThisWithShader; - } - - mixin(loadDerivedFromSharedLib("csfml-graphics", "sfDrawable", derivedClassName, - "Create", "Destroy", "SetX", "SetY", "SetPosition", "SetScaleX", "SetScaleY", "SetScale", "SetRotation", "SetOrigin", "SetColor", "SetBlendMode", - "GetX", "GetY", "GetScaleX", "GetScaleY", "GetRotation", "GetOriginX", "GetOriginY", "GetColor", "GetBlendMode", "Move", - "Scale", "Rotate", "TransformToLocal", "TransformToGlobal")); - - static this() - { - debug - DllLoader dll = DllLoader.load("csfml-graphics-d-2"); - else - DllLoader dll = DllLoader.load("csfml-graphics-2"); - - sfRenderWindow_DrawThis = cast(pf_sfRenderWindow_DrawThis)dll.getSymbol("sfRenderWindow_Draw" ~ derivedClassName[2..$]); - sfRenderWindow_DrawThisWithShader = cast(pf_sfRenderWindow_DrawThisWithShader)dll.getSymbol("sfRenderWindow_Draw" ~ derivedClassName[2..$] ~ "WithShader"); - sfRenderImage_DrawThis = cast(pf_sfRenderImage_DrawThis)dll.getSymbol("sfRenderImage_Draw" ~ derivedClassName[2..$]); - sfRenderImage_DrawThisWithShader = cast(pf_sfRenderImage_DrawThisWithShader)dll.getSymbol("sfRenderImage_Draw" ~ derivedClassName[2..$] ~ "WithShader"); - } -} diff --git a/bindings/d/import/dsfml/graphics/font.d b/bindings/d/import/dsfml/graphics/font.d deleted file mode 100644 index 0cbfa045..00000000 --- a/bindings/d/import/dsfml/graphics/font.d +++ /dev/null @@ -1,193 +0,0 @@ -/* -* DSFML - SFML Library wrapper for the D programming language. -* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com) -* Copyright (C) 2010 Andreas Hollandt -* -* This software is provided 'as-is', without any express or -* implied warranty. In no event will the authors be held -* liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute -* it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; -* you must not claim that you wrote the original software. -* If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but -* is not required. -* -* 2. Altered source versions must be plainly marked as such, -* and must not be misrepresented as being the original software. -* -* 3. This notice may not be removed or altered from any -* source distribution. -*/ - -module dsfml.graphics.font; - -import dsfml.system.common, - dsfml.system.exception, - dsfml.system.stringutil; - -import dsfml.graphics.rect, - dsfml.graphics.image; - - -/// Glyph describes a glyph (a visual character) -struct Glyph -{ - int Advance; /// Offset to move horizontically to the next character - IntRect Bounds; /// Bounding rectangle of the glyph, in coordinates relative to the baseline - IntRect SubRect; /// Texture coordinates of the glyph inside the font's image -} - -/** -* Font is the low-level class for loading and -* manipulating character fonts. -*/ -class Font : DSFMLObject -{ -private: - static Font s_default; -public: - - /** - * Get SFML default built-in font (Arial) - */ - static Font getDefaultFont() - { - if (s_default is null) - s_default = new Font(sfFont_GetDefaultFont()); - return s_default; - } - - /** - * construct the Font from a file - * - * Params: - * filename = font file to load - */ - this(string filename) - { - if (filename is null || filename.length == 0) - throw new LoadingException("LoadingException : Filename is invalid."); - - super(sfFont_CreateFromFile(toStringz(filename))); - } - - /** - * construct the Font from a file in memory - * - * Params: - * data = data to load - */ - this(ubyte[] data) - { - if (data is null || data.length == 0) - throw new Exception("LoadingException : Memory stream is invalid."); - - super(sfFont_CreateFromMemory(data.ptr, data.length)); - } - - - override void dispose() - { - sfFont_Destroy(m_ptr); - } - - /** - * get a glyph in a font - * - * Params: - * codePoint = Unicode code point of the character to get - * charSize = Reference character size - * bold = Retrieve the bold version or the regular one? - * Returns: - * The glyph corresponding to codePoint and charSize - */ - Glyph getGlyph(uint codePoint, uint charSize, bool bold) - { - return sfFont_GetGlyph(m_ptr, codePoint, charSize, bold); - } - - /** - * Get the kerning offset of two glyphs - * - * Params: - * first = Unicode code point of the first character - * second = Unicode code point of the second character - * charSize = Reference character size - * - * Returns: - * Kerning value for first and second, in pixels - */ - int getKerning(uint first, uint second, uint charSize) - { - return sfFont_GetKerning(m_ptr, first, second, charSize); - } - - /** - * Get the vertical offset to apply between two consecutive lines of text. - * - * Params: - * charSize = Reference character size - * - * Returns: - * Line spacing, in pixels - */ - int getLineSpacing(uint charSize) - { - return sfFont_GetLineSpacing(m_ptr, charSize); - } - - Image getImage(uint charSize) - { - return new Image(sfFont_GetImage(m_ptr, charSize)); - } - -package: - - this(SFMLClass ptr) - { - super(ptr, true); - } - -private: - static extern(C) - { - // sfFont - SFMLClass function() sfFont_Create; - SFMLClass function(cchar*) sfFont_CreateFromFile; - SFMLClass function(ubyte*, size_t) sfFont_CreateFromMemory; - void function(SFMLClass) sfFont_Destroy; - SFMLClass function() sfFont_GetDefaultFont; - - // DSFML2 - Glyph function(SFMLClass, uint, uint, bool) sfFont_GetGlyph; - int function(SFMLClass, uint, uint, uint) sfFont_GetKerning; - int function(SFMLClass, uint) sfFont_GetLineSpacing; - SFMLClass function(SFMLClass, uint) sfFont_GetImage; - } - - static this() - { - debug - DllLoader dll = DllLoader.load("csfml-graphics-d-2"); - else - DllLoader dll = DllLoader.load("csfml-graphics-2"); - - // sfFont - mixin(loadFromSharedLib("sfFont_CreateFromFile")); - mixin(loadFromSharedLib("sfFont_CreateFromMemory")); - mixin(loadFromSharedLib("sfFont_Destroy")); - mixin(loadFromSharedLib("sfFont_GetDefaultFont")); - - // DSFML2 - mixin(loadFromSharedLib("sfFont_GetGlyph")); - mixin(loadFromSharedLib("sfFont_GetKerning")); - mixin(loadFromSharedLib("sfFont_GetLineSpacing")); - mixin(loadFromSharedLib("sfFont_GetImage")); - - } -} \ No newline at end of file diff --git a/bindings/d/import/dsfml/graphics/idrawable.d b/bindings/d/import/dsfml/graphics/idrawable.d deleted file mode 100644 index a96dbcbf..00000000 --- a/bindings/d/import/dsfml/graphics/idrawable.d +++ /dev/null @@ -1,283 +0,0 @@ -/* - * DSFML - SFML Library wrapper for the D programming language. - * Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com) - * Copyright (C) 2010 Andreas Hollandt - * - * This software is provided 'as-is', without any express or - * implied warranty. In no event will the authors be held - * liable for any damages arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute - * it freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; - * you must not claim that you wrote the original software. - * If you use this software in a product, an acknowledgment - * in the product documentation would be appreciated but - * is not required. - * - * 2. Altered source versions must be plainly marked as such, - * and must not be misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any - * source distribution. - */ - -module dsfml.graphics.idrawable; - -import dsfml.system.vector; - -import dsfml.graphics.irendertarget; -import dsfml.graphics.color, - dsfml.graphics.blendmode, - dsfml.graphics.shader; - - -/** - * Interface for drawable object - * - * Shape, Text and Sprite implement IDrawable - */ -interface IDrawable -{ - /** - * Set the position of the object - * - * Params: - * x = New left coordinate - * y = New top coordinate - */ - void setPosition(float x, float y); - - /** - * Set the scale of the object - * - * Params: - * scaleX = New horizontal scale > 0 - * scaleY = New vertical scale > 0 - */ - void setScale(float scalex, float scaley); - // in {assert(scalex > 0 && scalex > 0);} // TODO: add in again when interface contracts work - - /** - * Set the origin of the object, in coordinates relative to the - * top-left of the object (take 2 values). - * The default origin is (0, 0) - * - * Params: - * originX : X coordinate of the origin - * originY : Y coordinate of the origin - */ - void setOrigin(float originX, float originY); - -@property -{ - /** - * Set the left position of the object - * - * Params: - * x = New left coordinate - */ - void x(float x); - - /** - * Set the top position of the object - * - * Params: - * y = New top coordinate - */ - void y(float y); - - /** - * Set the position of the object - * - * Params: - * vec = new position - */ - void position(Vector2f vec); - - /** - * Set the horizontal scale of the object - * - * Params: - * scale = New horizontal scale (Strictly positive) - */ - void scaleX(float scale); - - /** - * Set the vertical scale of the object - * - * Params: - * scale = New vertical scale (Strictly positive) - */ - void scaleY(float scale); - - /** - * Set the scale of the object - * - * Params: - * scale = new scale - */ - void scale(Vector2f scale); -// in {assert(scale.x > 0 && scale.y > 0);} // TODO - - /** - * Set the origin of the object, in coordinates relative to the - * top-left of the object (take a 2D vector). - * The default origin is (0, 0) - * - * Params: - * origin : New origin - */ - void origin(Vector2f origin); - - - /** - * Set the rotation of the object - * - * Params: - * angle = Angle of rotation, in degree - */ - void rotation(float angle); - - /** - * Set the color - * - * Params: - * c = New color - */ - void color(Color c); - - /** - * Set the blending mode for the object. - * The default blend mode is Blend.Alpha - * - * Params: - * mode = New blending mode - */ - void blendMode(BlendMode mode); - -const -{ - /** - * Get the position of the object - * - * Returns: - * Current position - * - */ - Vector2f position(); - - /** - * Get the current scale of the object - * - * Returns: - * Current scale - */ - Vector2f scale(); - - /** - * Get the origin of the object - * - * Returns: - * Current position of the origin - * - */ - Vector2f origin(); - - /** - * Get the rotation angle of the object - * - * Returns: - * Angle of rotation, in degree - */ - float rotation(); - - /** - * Get the color of the string - * - * Returns: - * Current color - */ - Color color(); - - /** - * Get the current blending mode - * - * Returns: - * Current blending mode - */ - BlendMode blendMode(); -} // const -} // @property - - /** - * Rotate the object - * Angle is added to the current orientation of the objet - * - * Params: - * angle = Angle of rotation in degree - */ - void rotate(float angle); - - /** - * Move the object - * New offset is added to object current position - * - * Params: - * offsetX = Offset on the X axis - * offsetY = Offset on the Y axis - */ - void move(float offsetX, float offsetY); - - /** - * Move the object - * New offset is added to object current position - * - * Params: - * offset = Amount of units to move the object of - */ - void move(Vector2f offset); - - /** - * Transform a point from global coordinates into local coordinates - * (ie it applies the inverse of object's origin, translation, rotation and scale to the point) - * - * Params: - * point = Point to transform - * - * Returns: - * Transformed point - */ - Vector2f transformToLocal(Vector2f point) const; - - /** - * Transform a point from local coordinates into global coordinates - * (ie it applies the inverse of object's origin, translation, rotation and scale to the point) - * - * Params: - * point = Point to transform - * - * Returns: - * Transformed point - */ - Vector2f transformToGlobal(Vector2f point) const; - - /** - * Render the specific geometry of the object - * - * Params: - * window = Target into which render the object - */ - void render(IRenderTarget window); - - /** - * Render the specific geometry of the object with a shader - * - * Params: - * window = Render target - * shader = Shader to use - */ - void renderWithShader(IRenderTarget window, Shader shader); -} \ No newline at end of file diff --git a/bindings/d/import/dsfml/graphics/image.d b/bindings/d/import/dsfml/graphics/image.d deleted file mode 100644 index 42988acd..00000000 --- a/bindings/d/import/dsfml/graphics/image.d +++ /dev/null @@ -1,352 +0,0 @@ -/* -* DSFML - SFML Library wrapper for the D programming language. -* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com) -* Copyright (C) 2010 Andreas Hollandt -* -* This software is provided 'as-is', without any express or -* implied warranty. In no event will the authors be held -* liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute -* it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; -* you must not claim that you wrote the original software. -* If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but -* is not required. -* -* 2. Altered source versions must be plainly marked as such, -* and must not be misrepresented as being the original software. -* -* 3. This notice may not be removed or altered from any -* source distribution. -*/ - - -module dsfml.graphics.image; - -import dsfml.graphics.color, - dsfml.graphics.rect; -// dsfml.graphics.renderwindow; - -import dsfml.system.common, - dsfml.system.exception, - dsfml.system.stringutil; - - -/** - * Image is the low-level class for loading and - * manipulating images - */ -class Image : DSFMLObject -{ -package: - this(SFMLClass ptr) - { - super(ptr, true); - } - -public: - - /** - * Default constructor - */ - this() - { - super(sfImage_Create()); - } - - /** - * Construct an empty image - * - * Params: - * width = Image width - * height = Image height - * col = Image color (black by default) - */ - this(uint width, uint height, Color col = Color.BLACK) - { - super(sfImage_CreateFromColor(width, height, col)); - } - - /** - * Construct the image from a file - * - * Params: - * filename = Path of the image file to load - * - * Throws: - * LoadingException if filename is empty or null. - */ - this(string filename) - { - if (filename is null || filename.length == 0) - throw new LoadingException("LoadingException : Filename is invalid."); - - super(sfImage_CreateFromFile(toStringz(filename))); - } - - /** - * Construct the image from a file in memory - * - * Params: - * data = array of data in memory - * Throws: - * LoadingException if data is empty or null. - */ - this(ubyte[] data) - { - if (data is null || data.length == 0) - throw new LoadingException("Memory stream is invalid."); - - super(sfImage_CreateFromMemory(data.ptr, data.length)); - } - - /** - * Construct the image directly from an array of pixels - * - * Params: - * width = Image width - * height = Image height - * data = array of pixels in memory (assumed format is RGBA) - * - * Throws: - * LoadingException if data length doesn't match Width * Height * 4 - */ - this(uint width, uint height, ubyte[] data) - { - if (width * height * 4 != data.length) - throw new LoadingException("Pixels array length doesn't match the specified size."); - - super(sfImage_CreateFromPixels(width, height, data.ptr)); - } - - override void dispose() - { - sfImage_Destroy(m_ptr); - } - - /** - * Save the content of the image to a file - * - * Params: - * filename = Path of the file to save (overwritten if already exist) - * - * Returns: - * True if saving was successful - */ - bool saveToFile(string filename) - { - return cast(bool)sfImage_SaveToFile(m_ptr, toStringz(filename)); - } - - /** - * Create an empty image - * - * Params: - * width = Image width - * height = Image height - * col = Image color (black by default) - * - * Returns: - * True if creation was successful - */ - bool create(uint width, uint height, Color col = Color.BLACK) - { - m_ptr = sfImage_CreateFromColor(width, height, col); - return (m_ptr !is null); - } - - /** - * Create transparency mask from a specified colorkey - * - * Params: - * colorKey = Color to become transparent - * alpha = Alpha value to use for transparent pixels (0 by default) - */ - void createMaskFromColor(Color colorKey, ubyte alpha = 0) - { - sfImage_CreateMaskFromColor(m_ptr, colorKey, alpha); - } - -/+ - /** - * Create the image from the current contents of the - * given window - * - * Params: - * window = Window to capture - * sourceRect = Sub-rectangle of the screen to copy (empty by default - entire image) - * - * Returns: - * True if copy was successful - */ - bool copyScreen(RenderWindow window, IntRect sourceRect = IntRect()) - { - return cast(bool)sfImage_CopyScreen(m_ptr, window.nativePointer, sourceRect); - } -+/ - - /** - * Copy pixels from another image onto this one. - * This function does a slow pixel copy and should only - * be used at initialization time - * - * Params: - * source = Source image to copy - * destX = X coordinate of the destination position - * destY = Y coordinate of the destination position - * sourceRect = Sub-rectangle of the source image to copy - */ - void copyImage(Image source, uint destX, uint destY, IntRect sourceRect = IntRect()) - { - sfImage_CopyImage(m_ptr, source.nativePointer, destX, destY, sourceRect); - } - - /** - * Change the color of a pixel - * Don't forget to call Update when you end modifying pixels - * - * Params: - * x = X coordinate of pixel in the image - * y = Y coordinate of pixel in the image - * col = New color for pixel (X, Y) - */ - void setPixel(uint x, uint y, Color col) - { - sfImage_SetPixel(m_ptr, x, y, col); - } - - /** - * Get a pixel from the image - * - * Params: - * x = X coordinate of pixel in the image - * y = Y coordinate of pixel in the image - * - * Returns: - * Color of pixel (x, y) - */ - Color getPixel(uint x, uint y) - { - return sfImage_GetPixel(m_ptr, x, y); - } - - /** - * Get an array of pixels (8 bits integers RGBA) - * Array size is GetWidth() x GetHeight() x 4 - * This array becomes invalid if you reload or resize the image - * - * Returns: - * array of pixels - */ - ubyte[] getPixelsArray() - { - return sfImage_GetPixelsPtr(m_ptr)[0..width() * height() * 4]; - } - - /** - * Bind the image for rendering - */ - void bind() - { - sfImage_Bind(m_ptr); - } - - /** - * Update a sub-rectangle of the image from an array of pixels - * - * Warning: for performances reasons, this function doesn't - * perform any check; thus you're responsible of ensuring that - * rectangle does not exceed the image size, and that - * pixels contains enough elements. - * - * Params: - * rectangle = sub rectangle of the image to update - * pixels = array of pixels to write to the image - */ - void updatePixels(ubyte[] pixels, IntRect rectangle) - { - sfImage_UpdatePixels(m_ptr, pixels.ptr, rectangle); - } - -@property -{ - /** - * Enable or disable image smooth filter. - * This parameter is enabled by default - * - * Params: - * s = True to enable smoothing filter, false to disable it - */ - void smooth(bool s) - { - sfImage_SetSmooth(m_ptr, s); - } - - /** - * Return the width of the image - * - * Returns: - * Width in pixels - */ - uint width() - { - return sfImage_GetWidth(m_ptr); - } - - /** - * Return the height of the image - * - * Returns: - * Height in pixels - */ - uint height() - { - return sfImage_GetHeight(m_ptr); - } - - /** - * Tells whether the smooth filtering is enabled or not - * - * Returns: - * True if image smoothing is enabled - */ - bool smooth() - { - return cast(bool)sfImage_IsSmooth(m_ptr); - } -} - -private: - static extern (C) - { - SFMLClass function() sfImage_Create; - SFMLClass function(uint, uint, Color) sfImage_CreateFromColor; - SFMLClass function(uint, uint, ubyte*) sfImage_CreateFromPixels; - SFMLClass function(cchar*) sfImage_CreateFromFile; - SFMLClass function(ubyte* ,size_t) sfImage_CreateFromMemory; - void function(SFMLClass) sfImage_Destroy; - int function(SFMLClass, cchar*) sfImage_SaveToFile; - void function(SFMLClass, Color, ubyte) sfImage_CreateMaskFromColor; - SFMLClass function(SFMLClass) sfImage_Copy; - int function(SFMLClass, SFMLClass, IntRect) sfImage_CopyScreen; - void function(SFMLClass, SFMLClass, uint, uint, IntRect) sfImage_CopyImage; - void function(SFMLClass, uint, uint, Color) sfImage_SetPixel; - Color function(SFMLClass, uint, uint) sfImage_GetPixel; - ubyte* function(SFMLClass) sfImage_GetPixelsPtr; - void function(SFMLClass) sfImage_Bind; - void function(SFMLClass, int) sfImage_SetSmooth; - uint function(SFMLClass) sfImage_GetWidth; - uint function(SFMLClass) sfImage_GetHeight; - int function(SFMLClass) sfImage_IsSmooth; - void function(SFMLClass, ubyte*, IntRect) sfImage_UpdatePixels; - } - - mixin(loadFromSharedLib2("csfml-graphics", "sfImage", - "Create", "CreateFromColor", "CreateFromPixels", "CreateFromFile", "CreateFromMemory", "Destroy", "SaveToFile", - "CreateMaskFromColor", "Copy", "CopyScreen", "CopyImage", "SetPixel", "GetPixel", "GetPixelsPtr", "Bind", "SetSmooth", "GetWidth", - "GetHeight", "IsSmooth", "UpdatePixels")); -} \ No newline at end of file diff --git a/bindings/d/import/dsfml/graphics/irendertarget.d b/bindings/d/import/dsfml/graphics/irendertarget.d deleted file mode 100644 index 719a2a48..00000000 --- a/bindings/d/import/dsfml/graphics/irendertarget.d +++ /dev/null @@ -1,138 +0,0 @@ -/* - * DSFML - SFML Library wrapper for the D programming language. - * Copyright (C) 2010 Andreas Hollandt - * - * This software is provided 'as-is', without any express or - * implied warranty. In no event will the authors be held - * liable for any damages arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute - * it freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; - * you must not claim that you wrote the original software. - * If you use this software in a product, an acknowledgment - * in the product documentation would be appreciated but - * is not required. - * - * 2. Altered source versions must be plainly marked as such, - * and must not be misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any - * source distribution. - */ - -module dsfml.graphics.irendertarget; - -import dsfml.system.vector; -import dsfml.graphics.idrawable; -import dsfml.graphics.rect; -import dsfml.graphics.shader; -import dsfml.graphics.view; -import dsfml.graphics.color; - -interface IRenderTarget -{ - /** - * Clear the entire target with a single color - * - * \param color : Color to use to clear the render target - * - */ - void clear(Color color = Color()); - - /** - * Draw something into the target - * - * \param object : Object to draw - * - */ - void draw(IDrawable object); - - /** - * Draw something into the target with a shader - * - * \param object : Object to draw - * \param shader : Shader to apply - * - */ - void draw(IDrawable object, Shader shader); - - /** - * Convert a point in target coordinates into view coordinates - * - * \param x : X coordinate of the point to convert, relative to the target - * \param y : Y coordinate of the point to convert, relative to the target - * \param view : Target view to convert the point to, null to use the currently associated view - * - * \return Converted point - * - */ - Vector2f convertCoords(uint x, uint y, View view = null); - - /** - * Save the current OpenGL render states and matrices - * - */ - void saveGLStates(); - - /** - * Restore the previously saved OpenGL render states and matrices - * - */ - void restoreGLStates(); - -@property -{ - /** - * Get the width of the rendering region of the target - * - * \return Width in pixels - * - */ - uint width(); - - /** - * Get the height of the rendering region of the target - * - * \return Height in pixels - * - */ - uint height(); - - /** - * Change the current active view. - * - * \param view : New view to use (pass GetDefaultView() to set the default view) - * - */ - void view(View view); - - /** - * Get the current view - * - * \return Current view active in the window - * - */ - View view(); - - /** - * Get the default view of the window - * - * \return Default view - * - */ - View defaultView(); - - /** - * Get the viewport of a view applied to this target - * - * \param view Target view - * - * \return Viewport rectangle, expressed in pixels in the current target - * - */ - IntRect viewport(View view); -} -} \ No newline at end of file diff --git a/bindings/d/import/dsfml/graphics/rect.d b/bindings/d/import/dsfml/graphics/rect.d deleted file mode 100644 index 3e8b9df1..00000000 --- a/bindings/d/import/dsfml/graphics/rect.d +++ /dev/null @@ -1,149 +0,0 @@ -/* -* DSFML - SFML Library wrapper for the D programming language. -* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com) -* Copyright (C) 2010 Andreas Hollandt -* -* This software is provided 'as-is', without any express or -* implied warranty. In no event will the authors be held -* liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute -* it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; -* you must not claim that you wrote the original software. -* If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but -* is not required. -* -* 2. Altered source versions must be plainly marked as such, -* and must not be misrepresented as being the original software. -* -* 3. This notice may not be removed or altered from any -* source distribution. -*/ - -module dsfml.graphics.rect; - -version (Tango) -{ - import tango.core.Traits; -} -else -{ - template isIntegerType(T) - { - const bool isIntegerType = - is (T == byte) || - is (T == short) || - is (T == int) || - is (T == long); - } - - template isRealType(T) - { - const bool isRealType = - is (T == float) || - is (T == double) || - is (T == real); - } -} - -/** - * Rect is an utility class for manipulating rectangles. - * Template parameter defines the type of coordinates (integer float, ...) - */ -struct Rect(T) -{ - T left; // Left coordinate of the rectangle - T top; // Top coordinate of the rectangle - T width; // width - T height; // height - - static if (!isIntegerType!(T) && !isRealType!(T)) - { - static assert (0, "This type is not supported by Rectangle"); - } - - T min(T)(T i, T j) - { - return i < j ? i : j; - } - - T max(T)(T i, T j) - { - return i > j ? i : j; - } - - /** - * Get the right coordinate of the rectangle - */ - T right() - { - return left + width; - } - - /** - * Get the bottom coordinate of the rectangle - */ - T bottom() - { - return top + height; - } - - /** - * Check if a point is inside the rectangle's area - * - * Params: - * x = X coordinate of the point to test - * y = Y coordinate of the point to test - * - * Returns: - * True if the point is inside - */ - bool contains(T x, T y) - { - return (x >= left) && (x < right) && (y >= top) && (y < bottom); - } - - /** - * Check intersection between two rectangles - * - * Params: - * rectangle = Rectangle to test - * overlappingRect = Rectangle to be filled with overlapping rect (NULL by default) - * - * Returns: - * True if rectangles overlap - */ - bool intersects(Rect!(T) rectangle, out Rect!(T) overlappingRect = Rect!(T)()) - { - // Compute overlapping rect - auto overlapping = Rect!(T)( - max(left, rectangle.left), - max(top, rectangle.top), - min(right, rectangle.right), - min(bottom, rectangle.bottom) - ); - - // If overlapping rect is valid, then there is intersection - if ((overlapping.left < overlapping.right) && (overlapping.top < overlapping.bottom)) - { - overlappingRect = overlapping; - return true; - } - else - { - overlappingRect = Rect!(T)(); - return false; - } - } - - //bool opEquals -} - -///Alias -alias Rect!(int) IntRect; -///ditto -alias Rect!(float) FloatRect; \ No newline at end of file diff --git a/bindings/d/import/dsfml/graphics/renderimage.d b/bindings/d/import/dsfml/graphics/renderimage.d deleted file mode 100644 index 76bdbe6c..00000000 --- a/bindings/d/import/dsfml/graphics/renderimage.d +++ /dev/null @@ -1,316 +0,0 @@ -/* - * DSFML - SFML Library wrapper for the D programming language. - * Copyright (C) 2010 Andreas Hollandt - * - * This software is provided 'as-is', without any express or - * implied warranty. In no event will the authors be held - * liable for any damages arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute - * it freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; - * you must not claim that you wrote the original software. - * If you use this software in a product, an acknowledgment - * in the product documentation would be appreciated but - * is not required. - * - * 2. Altered source versions must be plainly marked as such, - * and must not be misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any - * source distribution. - */ - - -module dsfml.graphics.renderimage; - -import dsfml.system.common, - dsfml.system.exception, - dsfml.system.stringutil, - dsfml.system.vector; - -import dsfml.graphics.idrawable, - dsfml.graphics.image, - dsfml.graphics.color, - dsfml.graphics.rect, - dsfml.graphics.shader, - dsfml.graphics.view, - dsfml.graphics.irendertarget; - - -/** - * Target for 2D rendering into an image that can be reused in a sprite - */ -class RenderImage : DSFMLObject, IRenderTarget -{ -private: - Image _image = null; - View _view = null; - View _defaultView = null; - -package: - this(SFMLClass ptr) - { - super(ptr, true); - } - - override void dispose() - { - sfRenderImage_Destroy(m_ptr); - } - -public: - - /** - * Construct a new renderimage - * - * Params: - * width = Width of the renderimage - * height = Height of the renderimage - * depthBuffer = Do you want a depth-buffer attached? (useful only if you're doing 3D OpenGL on the renderimage) - */ - this(uint width, uint height, bool depthBuffer = false) - { - super(sfRenderImage_Create(width, height, depthBuffer)); - } - - /** - * Update the contents of the target image - */ - void display() - { - sfRenderImage_Display(m_ptr); - } - - /** - * Draw something on a renderimage - * - * Params: - * drawable = object to draw - */ - void draw(IDrawable drawable) - { - drawable.render(this); - } - - /** - * - * Params: - * drawable = Object to draw - * shader = Shader to use - */ - void draw(IDrawable drawable, Shader shader) - { - drawable.renderWithShader(this, shader); - } - - /** - * Clear the renderimage with the given color - * - * Params: - * color = Fill color - */ - void clear(Color color) - { - sfRenderImage_Clear(m_ptr, color); - } - - /** - * Convert a point in image coordinates into view coordinates - * - * Params: - * imageX = X coordinate of the point to convert, relative to the image - * imageY = Y coordinate of the point to convert, relative to the image - * targetView = Target view to convert the point to (pass NULL to use the current view) - * - * Returns: - * Converted point - */ - Vector2f convertCoords(uint imageX, uint imageY, View targetView = null) - { - Vector2f vec; - sfRenderImage_ConvertCoords(m_ptr, imageX, imageY, &vec.x, &vec.y, targetView is null ? null : targetView.nativePointer); - return vec; - } - - - - /** - * Save the current OpenGL render states and matrices - */ - void saveGLStates() - { - sfRenderImage_SaveGLStates(m_ptr); - } - - /** - * Restore the previously saved OpenGL render states and matrices - */ - void restoreGLStates() - { - sfRenderImage_RestoreGLStates(m_ptr); - } - -@property -{ - /** - * Return the width of the rendering region of a renderimage - * - * Returns: - * Width in pixels - */ - uint width() - { - return sfRenderImage_GetWidth(m_ptr); - } - - /** - * Return the height of the rendering region of a renderimage - * - * Returns: - * Height in pixels - */ - uint height() - { - return sfRenderImage_GetHeight(m_ptr); - } - - /** - * Activate or deactivate a renderimage as the current target for rendering - * - * Params: - * active = true to activate, false to deactivate - * Returns: - * true if operation was successful, false otherwise - */ - bool active(bool activ) - { - return sfRenderImage_SetActive(m_ptr, activ); - } - - /** - * Change the current active view of a renderimage - * - * Params: - * view = Pointer to the new view - */ - void view(View v) - { - if (_view !is null) - { - _view.setHandled(false); - } - - sfRenderImage_SetView(m_ptr, v.nativePointer); - - _view = v; - _view.setHandled(true); - } - - /** - * Get the current active view rectangle - * - * Returns: - * current view rectangle, in global coordinates - */ - View view() - { - if (_view is null) - { - SFMLClass cView = sfRenderImage_GetView(m_ptr); - _view = new View(cView, true); - } - return _view; - } - - /** - * Get the default view - * - * Returns: - * default view - */ - View defaultView() - { - if (_defaultView is null) - { - SFMLClass cView = sfRenderImage_GetDefaultView(m_ptr); - _defaultView = new View(cView, true); - } - return _defaultView; - } - - - IntRect viewport(View v = null) // TODO: is there a need to accept other Views than the currently assigned one? - { - return sfRenderImage_GetViewport(m_ptr, v is null ? _view.nativePointer : v.nativePointer); - } - - /** - * Get the target image - * - * Returns: - * target image - */ - Image image() - { - if (_image is null) - { - SFMLClass cImage = sfRenderImage_GetImage(m_ptr); - _image = new Image(cImage); - } - return _image; - } - - /** - * Check whether the system supports render images or not - * - * Returns: - * true if the RenderImage class can be used - */ - bool isAvailable() - { - return sfRenderImage_IsAvailable(); - } -} - -private: - static extern(C) - { - SFMLClass function(uint, uint, bool) sfRenderImage_Create; - void function(SFMLClass) sfRenderImage_Destroy; - uint function(SFMLClass) sfRenderImage_GetWidth; - uint function(SFMLClass) sfRenderImage_GetHeight; - bool function(SFMLClass, bool) sfRenderImage_SetActive; - void function(SFMLClass) sfRenderImage_Display; - - void function(SFMLClass, void*) sfRenderImage_DrawSprite; - void function(SFMLClass, void*) sfRenderImage_DrawShape; - void function(SFMLClass, void*) sfRenderImage_DrawText; - - void function(SFMLClass, void*, void*) sfRenderImage_DrawSpriteWithShader; - void function(SFMLClass, void*, void*) sfRenderImage_DrawShapeWithShader; - void function(SFMLClass, void*, void*) sfRenderImage_DrawTextWithShader; - - void function(SFMLClass, Color) sfRenderImage_Clear; - void function(SFMLClass, SFMLClass) sfRenderImage_SetView; - SFMLClass function(SFMLClass) sfRenderImage_GetView; - SFMLClass function(SFMLClass) sfRenderImage_GetDefaultView; - IntRect function(SFMLClass, SFMLClass) sfRenderImage_GetViewport; - void function(SFMLClass, uint, uint, float*, float*, SFMLClass) sfRenderImage_ConvertCoords; - SFMLClass function(SFMLClass) sfRenderImage_GetImage; - bool function() sfRenderImage_IsAvailable; - - // DSFML2 - void function(SFMLClass) sfRenderImage_SaveGLStates; - void function(SFMLClass) sfRenderImage_RestoreGLStates; - } - - mixin(loadFromSharedLib2("csfml-graphics", "sfRenderImage", "Create", "Destroy", "GetWidth", "GetHeight", - "SetActive", "Display", "Clear", "SetView", "GetView", "GetDefaultView", "GetViewport", "ConvertCoords", - "GetImage", "IsAvailable", - // DSFML2 - "SaveGLStates", "RestoreGLStates")); - -} \ No newline at end of file diff --git a/bindings/d/import/dsfml/graphics/renderwindow.d b/bindings/d/import/dsfml/graphics/renderwindow.d deleted file mode 100644 index fa23631c..00000000 --- a/bindings/d/import/dsfml/graphics/renderwindow.d +++ /dev/null @@ -1,336 +0,0 @@ -/* -* DSFML - SFML Library wrapper for the D programming language. -* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com) -* Copyright (C) 2010 Andreas Hollandt -* -* This software is provided 'as-is', without any express or -* implied warranty. In no event will the authors be held -* liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute -* it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; -* you must not claim that you wrote the original software. -* If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but -* is not required. -* -* 2. Altered source versions must be plainly marked as such, -* and must not be misrepresented as being the original software. -* -* 3. This notice may not be removed or altered from any -* source distribution. -*/ - -module dsfml.graphics.renderwindow; - -import dsfml.graphics.color, - dsfml.graphics.rect, - dsfml.graphics.shader, - dsfml.graphics.view, - dsfml.graphics.idrawable, - dsfml.graphics.irendertarget; - -import dsfml.window.event, - dsfml.window.input, - dsfml.window.videomode, - dsfml.window.window, - dsfml.window.windowhandle; - -import dsfml.system.common, - dsfml.system.stringutil, - dsfml.system.vector; - -/** - * Simple wrapper for Window that allows easy 2D rendering. - */ -class RenderWindow : Window, IRenderTarget -{ -private: - View m_view = null; - View m_defaultView = null; - -public: - - /** - * Construct the window - * - * Params: - * mode = Video mode to use - * title = Title of the window - * windowStyle = Window style (Resize | Close by default) - * settings = Context settings (default is default ContextSettings values) - */ - this(VideoMode mode, string title, Style windowStyle = Style.Default, ContextSettings settings = ContextSettings()) - { - super(sfRenderWindow_Create(mode, toStringz(title), windowStyle, &settings)); - m_input = new Input(sfRenderWindow_GetInput(m_ptr)); - } - - /** - * Construct the window from an existing control - * - * Params: - * handle = Platform-specific handle of the control - * settings = Context settings (default is default ContextSettings values) - */ - this(WindowHandle handle, ContextSettings settings = ContextSettings()) - { - super(sfRenderWindow_CreateFromHandle(handle, &settings)); - m_input = new Input(sfRenderWindow_GetInput(m_ptr)); - } - - override void dispose() - { - sfRenderWindow_Destroy(m_ptr); - } - - /** - * Create (or recreate) the window - * - * Input created with getInput will become invalid. - * - * Params: - * mode = Video mode to use - * title = Title of the window - * windowStyle = Window style (Resize | Close by default) - * settings = Context settings (default is default ContextSettings values) - * - */ - override void create(VideoMode mode, string title, Style windowStyle = Style.Default, ContextSettings settings = ContextSettings()) - { - if (m_ptr !is null) - dispose(); - - m_ptr = sfRenderWindow_Create(mode, toStringz(title), windowStyle, &settings); - m_input = new Input(sfRenderWindow_GetInput(m_ptr)); - } - - /** - * Create (or recreate) the window from an existing control - * - * Input created with getInput become invalid. - * - * Params: - * handle = Platform-specific handle of the control - * settings = Context settings (default is default ContextSettings values) - * - */ - override void create(WindowHandle handle, ContextSettings settings = ContextSettings()) - { - if (m_ptr !is null) - dispose(); - - m_ptr = sfRenderWindow_CreateFromHandle(handle, &settings); - m_input = new Input(sfRenderWindow_GetInput(m_ptr)); - } - - /** - * Draw a sprite, shape or text on the window with a shader - * - * Params: - * drawable = IDrawable to draw - * shader = Shader to use - */ - void draw(IDrawable drawable, Shader shader) - { - drawable.renderWithShader(this, shader); - } - - /** - * Draw a sprite, shape or text - * - * Params: - * drawable = IDrawable to draw - */ - void draw(IDrawable drawable) - { - drawable.render(this); - } - - /** - * Clear the screen with the given color. - * - * Params: - * col = Fill color - */ - void clear(Color col = Color.BLACK) - { - sfRenderWindow_Clear(m_ptr, col); - } - - - - /** - * Convert a point in window coordinates into view coordinates - * - * Params: - * windowX = X coordinate of the point to convert, relative to the window - * windowY = Y coordinate of the point to convert, relative to the window - * targetView = Target view to convert the point to (pass NULL to use the current view) - * - * Returns: - * Converted point - */ - Vector2f convertCoords(uint windowX, uint windowY, View targetView = null) - { - Vector2f vec; - sfRenderWindow_ConvertCoords(m_ptr, windowX, windowY, &vec.x, &vec.y, targetView is null ? null : targetView.nativePointer); - return vec; - } - - /** - * Save the current OpenGL render states and matrices - */ - void saveGLStates() - { - sfRenderWindow_SaveGLStates(m_ptr); - } - - /** - * Restore the previously saved OpenGL render states and matrices - */ - void restoreGLStates() - { - sfRenderWindow_RestoreGLStates(m_ptr); - } - -@property -{ - /** - * Change the current active view. - * The current view is defined with the initial size of the window - * - * Params: - * newView = Pointer to the new view (pass getDefaultView to set the default view) - */ - void view(View newView) - { - if (m_view !is null) - { - m_view.setHandled(false); - } - - sfRenderWindow_SetView(m_ptr, newView.nativePointer); - - m_view = newView; - m_view.setHandled(true); - } - - /** - * Get the current view rectangle - * - * Returns: - * current view rectangle, in global coordinates - */ - View view() - { - if (m_view is null) - { - SFMLClass cView = sfRenderWindow_GetView(m_ptr); - m_view = new View(cView, true); - } - return m_view; - } - - /** - * Get the default view - * - * Returns: - * default view - */ - View defaultView() - { - if (m_defaultView is null) - { - SFMLClass cView = sfRenderWindow_GetDefaultView(m_ptr); - m_defaultView = new View(cView, true); - } - return m_defaultView; - } - - /** - * Return the width of the rendering region of a renderwindow - * - * Returns: - * Width in pixels - */ - override uint width() - { - return sfRenderWindow_GetWidth(m_ptr); - } - - /** - * Return the height of the rendering region of a renderwindow - * - * Returns: - * Height in pixels - */ - override uint height() - { - return sfRenderWindow_GetHeight(m_ptr); - } - - /** - * Get the viewport of a view applied to this target - * - * Params: - * view = Target view - * Returns: - * Viewport rectangle, expressed in pixels in the current target - */ - IntRect viewport(View v = null) // TODO: is there a need to accept other Views than the currently assigned one? - { - return sfRenderWindow_GetViewport(m_ptr, v is null ? m_view.nativePointer : v.nativePointer); - } -} - -private: - - static extern(C) - { - SFMLClass function(VideoMode, cchar*, Style, ContextSettings*)sfRenderWindow_Create; - SFMLClass function(WindowHandle, ContextSettings*) sfRenderWindow_CreateFromHandle; - void function(SFMLClass) sfRenderWindow_Destroy; - SFMLClass function(SFMLClass) sfRenderWindow_GetInput; - bool function(SFMLClass) sfRenderWindow_IsOpened; - uint function(SFMLClass) sfRenderWindow_GetWidth; - uint function(SFMLClass) sfRenderWindow_GetHeight; - - /* - void function(SFMLClass, SFMLClass) sfRenderWindow_DrawSprite; - void function(SFMLClass, SFMLClass) sfRenderWindow_DrawShape; - void function(SFMLClass, SFMLClass) sfRenderWindow_DrawText; - - void function(SFMLClass, SFMLClass, SFMLClass) sfRenderWindow_DrawSpriteWithShader; - void function(SFMLClass, SFMLClass, SFMLClass) sfRenderWindow_DrawShapeWithShader; - void function(SFMLClass, SFMLClass, SFMLClass) sfRenderWindow_DrawTextWithShader; - */ - - SFMLClass function(SFMLClass) sfRenderWindow_Capture; - void function(SFMLClass, Color) sfRenderWindow_Clear; - void function(SFMLClass, SFMLClass) sfRenderWindow_SetView; - SFMLClass function(SFMLClass) sfRenderWindow_GetView; - SFMLClass function(SFMLClass) sfRenderWindow_GetDefaultView; - void function(SFMLClass, uint, uint, float*, float*, SFMLClass) sfRenderWindow_ConvertCoords; - - // DSFML2 - void function(SFMLClass) sfRenderWindow_SaveGLStates; - void function(SFMLClass) sfRenderWindow_RestoreGLStates; - IntRect function(SFMLClass, SFMLClass) sfRenderWindow_GetViewport; - } - - mixin(loadFromSharedLib2("csfml-graphics", "sfRenderWindow", "Create", "CreateFromHandle", - "Destroy", "GetInput", "Clear", "SetView", "GetView", "GetDefaultView", "ConvertCoords", - "GetWidth", "GetHeight", - // DSFML2 - "SaveGLStates", "RestoreGLStates", "GetViewport")); - - - static ~this() - { - - } -} \ No newline at end of file diff --git a/bindings/d/import/dsfml/graphics/shader.d b/bindings/d/import/dsfml/graphics/shader.d deleted file mode 100644 index ea7e07b7..00000000 --- a/bindings/d/import/dsfml/graphics/shader.d +++ /dev/null @@ -1,177 +0,0 @@ -/* -* DSFML - SFML Library wrapper for the D programming language. -* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com) -* Copyright (C) 2010 Andreas Hollandt -* -* This software is provided 'as-is', without any express or -* implied warranty. In no event will the authors be held -* liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute -* it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; -* you must not claim that you wrote the original software. -* If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but -* is not required. -* -* 2. Altered source versions must be plainly marked as such, -* and must not be misrepresented as being the original software. -* -* 3. This notice may not be removed or altered from any -* source distribution. -*/ - -module dsfml.graphics.shader; - -import dsfml.graphics.image; - -import dsfml.system.common; -import dsfml.system.exception; -import dsfml.system.stringutil; - - -/** -* Define loading methods for effect -*/ -enum LoadingType -{ - FROMFILE, /// string represents a file path - FROMSTRING /// string represents effect code -} - -/** -* Shader is used to apply a post effect to a window -* -* See_Also: -* $(LINK2 http://www.sfml-dev.org/tutorials/graphics-postfx.php, SFML post FX tutorial) from more informations about Post effects and GLSL fragment shaders syntax. -*/ -class Shader : DSFMLObject -{ -private: - Image m_texture; - -public: - - /** - * construct the effect - * - * Params: - * effect = Path of a file or string containing the effect. - * type = type of the effect (default is FROMFILE) - */ - this(string effect, LoadingType type = LoadingType.FROMFILE) - { - if (effect is null || effect.length == 0) - throw new LoadingException("LoadingException : Effect is invalid."); - - if (type == LoadingType.FROMFILE) - super(sfShader_CreateFromFile(toStringz(effect))); - else - super(sfShader_CreateFromMemory(toStringz(effect))); - } - - override void dispose() - { - sfShader_Destroy(m_ptr); - } - - /** - * Change parameters of the effect - * - * Params: - * name = Parameter name in the effect - */ - void setParameter(string name, float x) - { - sfShader_SetParameter1(m_ptr, toStringz(name), x); - } - - /** - * ditto - */ - void setParameter(string name, float x, float y) - { - sfShader_SetParameter2(m_ptr, toStringz(name), x, y); - } - - /** - * ditto - */ - void setParameter(string name, float x, float y, float z) - { - sfShader_SetParameter3(m_ptr, toStringz(name), x, y, z); - } - - /** - * ditto - */ - void setParameter(string name, float x, float y, float z, float w) - { - sfShader_SetParameter4(m_ptr, toStringz(name), x, y, z, w); - } - - /** - * Set a texture parameter - * - * Params: - * name = Texture name in the effect - * texture = Image to set (pass NULL to use content of current framebuffer) - */ - void setTexture(string name, Image texture) - { - m_texture = texture; - sfShader_SetTexture(m_ptr, toStringz(name), texture is null ? null : texture.nativePointer); - } - - /** - * Tell whether or not the system supports shaders - * - * Returns: - * True if the system can use shaders - */ - static bool isAvailable() - { - return cast(bool)sfShader_IsAvailable(); - } - - -private: - - static extern(C) - { - SFMLClass function(cchar*) sfShader_CreateFromFile; - SFMLClass function(cchar*) sfShader_CreateFromMemory; - void function(SFMLClass) sfShader_Destroy; - void function(SFMLClass, cchar*, float) sfShader_SetParameter1; - void function(SFMLClass, cchar*, float, float) sfShader_SetParameter2; - void function(SFMLClass, cchar*, float, float, float) sfShader_SetParameter3; - void function(SFMLClass, cchar*, float, float, float, float) sfShader_SetParameter4; - void function(SFMLClass, cchar*, SFMLClass) sfShader_SetTexture; - int function() sfShader_IsAvailable; - void function(SFMLClass) sfShader_Bind; - void function(SFMLClass) sfShader_Unbind; - } - - static this() - { - debug - DllLoader dll = DllLoader.load("csfml-graphics-d-2"); - else - DllLoader dll = DllLoader.load("csfml-graphics-2"); - - mixin(loadFromSharedLib("sfShader_CreateFromFile")); - mixin(loadFromSharedLib("sfShader_CreateFromMemory")); - mixin(loadFromSharedLib("sfShader_Destroy")); - mixin(loadFromSharedLib("sfShader_SetParameter1")); - mixin(loadFromSharedLib("sfShader_SetParameter2")); - mixin(loadFromSharedLib("sfShader_SetParameter3")); - mixin(loadFromSharedLib("sfShader_SetParameter4")); - mixin(loadFromSharedLib("sfShader_SetTexture")); - mixin(loadFromSharedLib("sfShader_IsAvailable")); - mixin(loadFromSharedLib("sfShader_Bind")); - mixin(loadFromSharedLib("sfShader_Unbind")); - } -} \ No newline at end of file diff --git a/bindings/d/import/dsfml/graphics/shape.d b/bindings/d/import/dsfml/graphics/shape.d deleted file mode 100644 index 87f40dc4..00000000 --- a/bindings/d/import/dsfml/graphics/shape.d +++ /dev/null @@ -1,306 +0,0 @@ -/* - * DSFML - SFML Library wrapper for the D programming language. - * Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com) - * Copyright (C) 2010 Andreas Hollandt - * - * This software is provided 'as-is', without any express or - * implied warranty. In no event will the authors be held - * liable for any damages arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute - * it freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; - * you must not claim that you wrote the original software. - * If you use this software in a product, an acknowledgment - * in the product documentation would be appreciated but - * is not required. - * - * 2. Altered source versions must be plainly marked as such, - * and must not be misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any - * source distribution. - */ - -module dsfml.graphics.shape; - -import dsfml.system.vector; - -import dsfml.graphics.blendmode; -import dsfml.graphics.color; -import dsfml.graphics.drawableimpl; - -/** - * Shape defines a drawable convex shape ; it also defines - * helper functions to draw simple shapes like - * lines, rectangles, circles, etc. - */ -class Shape : DrawableImpl!("sfShape") -{ -private: - this (SFMLClass ptr) - { - super(ptr); - } - -public: - this() - { - super(); - } - - /** - * Add a point to the shape - * - * Params: - * x = X position of the point - * y = Y position of the point - * col = Color of the point (white by default) - * outlineCol = Outline color of the point (black by default) - */ - void addPoint(float x, float y, Color col = Color.WHITE, Color outlineCol = Color.BLACK) - { - sfShape_AddPoint(m_ptr, x, y, col, outlineCol); - } - - /** - * Add a point to the shape - * - * Params: - * position = position of the point - * col = Color of the point (white by default) - * outlineCol = Outline color of the point (black by default) - */ - void addPoint(Vector2f position, Color col = Color.WHITE, Color outlineCol = Color.BLACK) - { - sfShape_AddPoint(m_ptr, position.x, position.x, col, outlineCol); - } - -@property -{ - /** - * Enable or disable filling the shape. - * Fill is enabled by default. - * - * Params: - * enable = True to enable, false to disable - */ - void enableFill(bool enable) - { - sfShape_EnableFill(m_ptr, enable); - } - - /** - * Enable or disable drawing a shape outline. - * Outline is enabled by default - * - * Params: - * enable = True to enable, false to disable - */ - void enableOutline(bool enable) - { - sfShape_EnableOutline(m_ptr, enable); - } - - /** - * Change the thickness of a shape outline - * - * Params: - * thickness = New thickness - */ - void outlineThickness(float thickness) - { - sfShape_SetOutlineThickness(m_ptr, thickness); - } - - /** - * Get the thickness of the shape outline - * - * Returns: - * Current outline thickness - * - */ - float outlineThickness() - { - return sfShape_GetOutlineThickness(m_ptr); - } - - /** - * Get the number of points composing a shape - * - * Returns: - * Total number of points - */ - uint pointsCount() - { - return sfShape_GetPointsCount(m_ptr); - } -} - - /** - * Get a point of the shape - * - * Params: - * index = Index of the point - * - * Returns: - * position of the point - */ - Vector2f getPointPosition(uint index) - { - float x, y; - sfShape_GetPointPosition(m_ptr, index, &x, &y); - return Vector2f(x, y); - } - - /** - * Set the position of a shape point - * - * Params: - * index = Index of the point - * position = New position of the point - */ - void setPointPosition(uint index, Vector2f position) - { - sfShape_SetPointPosition(m_ptr, index, position.x, position.y); - } - - /** - * Get the color of a shape's point - * - * Params: - * index = Index of the point - * - * Returns: - * Color of the point - */ - Color getPointColor(uint index) - { - return sfShape_GetPointColor(m_ptr, index); - } - - /** - * Set the color of a shape's point - * - * Params: - * index = Index of the point - * color = new color of the point - */ - void setPointColor(uint index, Color color) - { - sfShape_SetPointColor(m_ptr, index, color); - } - - /** - * Get the outline color of a shape's point - * - * Params: - * index = Index of the point - * - * Returns: - * Color of the outline - */ - Color getPointOutlineColor(uint index) - { - return sfShape_GetPointOutlineColor(m_ptr, index); - } - - /** - * Set the outline color of a shape's point - * - * Params: - * index = Index of the point - * color = new color of the point - */ - void setPointOutlineColor(uint index, Color color) - { - sfShape_SetPointOutlineColor(m_ptr, index, color); - } - - - - /** - * Create a shape made of a single line - * - * Params: - * p1X, p1Y = Position of the first point - * p2X, p2Y = Position second point - * thickness = Line thickness - * col = Color used to draw the line - * outline = Outline thickness (0 by default) - * outlineCol = Color used to draw the outline (black by default) - * - * Returns: - * New line shape - */ - static Shape line(float p1X, float p1Y, float p2X, float p2Y, float thickness, Color col, float outline = 0.f, Color outlineCol = Color.BLACK) - { - - return new Shape(sfShape_CreateLine(p1X, p1Y, p2X, p2Y, thickness, col, outline, outlineCol)); - } - - /** - * Create a shape made of a single rectangle - * - * Params: - * left, top = Top-left corner of the rectangle - * width, height = Size of the rectangle - * col = Color used to fill the rectangle - * outline = Outline thickness (0 by default) - * outlineCol = Color used to draw the outline (black by default) - * - * Returns: - * new rectangle shape - */ - static Shape rectangle(float left, float top, float width, float height, Color col, float outline = 0.f, Color outlineCol = Color.BLACK) - { - return new Shape(sfShape_CreateRectangle(left, top, width, height, col, outline, outlineCol)); - } - - /** - * Create a shape made of a single circle - * - * Params: - * x = X position of the center - * y = Y position of the center - * radius = Radius - * col = Color used to fill the circle - * outline = Outline thickness (0 by default) - * outlineCol = Color used to draw the outline (black by default) - * - * Returns: - * new circle shape - */ - static Shape circle(float x, float y, float radius, Color col, float outline = 0.f, Color outlineCol = Color.BLACK) - { - return new Shape(sfShape_CreateCircle(x, y, radius, col, outline, outlineCol)); - } - -private: - - static extern(C) - { - SFMLClass function(float, float, float, float, float, Color, float, Color) sfShape_CreateLine; - SFMLClass function(float, float, float, float, Color, float, Color) sfShape_CreateRectangle; - SFMLClass function(float, float, float, Color, float, Color) sfShape_CreateCircle; - void function(SFMLClass, float, float, Color, Color) sfShape_AddPoint; - void function(SFMLClass, int) sfShape_EnableFill; - void function(SFMLClass, int) sfShape_EnableOutline; - void function(SFMLClass, float Width) sfShape_SetOutlineThickness; - float function(SFMLClass) sfShape_GetOutlineThickness; - uint function(SFMLClass) sfShape_GetPointsCount; - void function(SFMLClass, uint Index, float* X, float* Y) sfShape_GetPointPosition; - void function(SFMLClass, uint Index, float X, float Y) sfShape_SetPointPosition; - Color function(SFMLClass, uint index) sfShape_GetPointColor; - void function(SFMLClass, uint index, Color color) sfShape_SetPointColor; - Color function(SFMLClass, uint index) sfShape_GetPointOutlineColor; - void function(SFMLClass, uint index, Color color) sfShape_SetPointOutlineColor; - } - - mixin(loadFromSharedLib2("csfml-graphics", "sfShape", - "CreateLine", "CreateRectangle", "CreateCircle", "AddPoint", "EnableFill", "EnableOutline", "SetOutlineThickness", "GetOutlineThickness", - "GetPointsCount", "GetPointPosition", "SetPointPosition", "GetPointColor", "SetPointColor", "GetPointOutlineColor", - "SetPointOutlineColor")); -} \ No newline at end of file diff --git a/bindings/d/import/dsfml/graphics/sprite.d b/bindings/d/import/dsfml/graphics/sprite.d deleted file mode 100644 index a8f32df5..00000000 --- a/bindings/d/import/dsfml/graphics/sprite.d +++ /dev/null @@ -1,238 +0,0 @@ -/* -* DSFML - SFML Library wrapper for the D programming language. -* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com) -* Copyright (C) 2010 Andreas Hollandt -* -* This software is provided 'as-is', without any express or -* implied warranty. In no event will the authors be held -* liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute -* it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; -* you must not claim that you wrote the original software. -* If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but -* is not required. -* -* 2. Altered source versions must be plainly marked as such, -* and must not be misrepresented as being the original software. -* -* 3. This notice may not be removed or altered from any -* source distribution. -*/ - -module dsfml.graphics.sprite; - -import dsfml.graphics.blendmode; -import dsfml.graphics.color; -import dsfml.graphics.drawableimpl; -import dsfml.graphics.image; -import dsfml.graphics.rect; - -import dsfml.system.vector; - -/** -* Sprite defines a sprite : texture, transformations, -* color, and draw on screen -* See_Also: -* IDrawable -*/ -class Sprite : DrawableImpl!("sfSprite") -{ -private: - Image m_image; //< Image used to draw the sprite - IntRect m_subRect; //< Sub-rectangle of source image to assign to the sprite - -public: - - /** - * Default constructor - */ - this() - { - super(); - } - - /** - * Construct the sprite from a source image - * - * Params: - * img = Image of the sprite - * left = Left coordinate of the sprite (0 by default) - * top = Top coordinate of the sprite (0 by default) - * scalex = Horizontal scale (1 by default) - * scaley = Vertical scale (1 by default) - * rot = Orientation, in degrees (0 by default) - * col = Color of the sprite (white by default) - */ - this(Image img, float left = 0.f, float top = 0.f, float scalex = 1.f, float scaley = 1.f, float rot = 0.f, Color col = Color.WHITE) - { - super(); - m_image = img; - sfSprite_SetImage(m_ptr, img.nativePointer, true); - x = left; - y = top; - scaleX = scalex; - scaleY = scaley; - rotation = rot; - color = col; - } - - /** - * Change the image of the sprite - * - * Params: - * img = New image - * adjustToNewSize = adjust sprite subrect to new image size - */ - void setImage(Image img, bool adjustToNewSize = false) - { - assert(img !is null, "Trying to set a null image."); - sfSprite_SetImage(m_ptr, img.nativePointer, adjustToNewSize); - m_image = img; - } - - @property void image(Image img) - { - setImage(img, false); - } - - /** - * Resize the sprite (by changing its scale factors). - * The default size is defined by the subrect - * - * Params: - * width = New width (must be strictly positive) - * height = New height (must be strictly positive) - */ - void resize(float width, float height) - { - if (width > 0 && height > 0) - sfSprite_Resize(m_ptr, width, height); - } - - /** - * Resize the sprite (by changing its scale factors). - * The default size is defined by the subrect - * - * Params: - * size = New size (both coordinates must be strictly positive) - */ - void resize(Vector2f size) - { - if (size.x > 0 && size.y > 0) - sfSprite_Resize(m_ptr, size.x, size.y); - } - - - /** - * Flip the sprite horizontally - * - * Params: - * flipped = True to flip the sprite - */ - void flipX(bool flipped) - { - sfSprite_FlipX(m_ptr, flipped); - } - - /** - * Flip the sprite vertically - * - * Params: - * flipped = True to flip the sprite - */ - void flipY(bool flipped) - { - sfSprite_FlipY(m_ptr, flipped); - } - - /** - * Get the color of a given pixel in the sprite - * - * Params: - * x = X coordinate - * y = Y coordinate - * - * Returns: - * Color of pixel - */ - Color getPixel(uint x, uint y) const - { - return sfSprite_GetPixel(m_ptr, x, y); - } - -@property -{ - /** - * Set the sub-rectangle of a sprite inside the source image. - * - * Params: - * rect = New sub-rectangle - */ - void subRect(IntRect rect) - { - sfSprite_SetSubRect(m_ptr, rect); - m_subRect = rect; - } - - /** - * Get the source image of the sprite - * - * Returns: - * Pointer to the image (can be NULL) - */ - Image image() - { - return m_image; - } - - /** - * Get the sub-rectangle of the sprite inside the source image - * - * Returns: - * Sub-rectangle - */ - IntRect subRect() - { - if (m_subRect == IntRect()) - m_subRect = sfSprite_GetSubRect(m_ptr); - //m_subRect = IntRect(0, 0, m_image.getWidth(), m_image.getHeight()); - - return m_subRect; - } - - /** - * Get the sprite size - * - * Returns: - * Size of the sprite - */ - Vector2f size() const - { - return Vector2f(sfSprite_GetWidth(m_ptr), sfSprite_GetHeight(m_ptr)); - } -} - -private: - - static extern(C) - { - void function(SFMLClass, SFMLClass, bool) sfSprite_SetImage; - void function(SFMLClass, IntRect) sfSprite_SetSubRect; - void function(SFMLClass, float, float) sfSprite_Resize; - void function(SFMLClass, int) sfSprite_FlipX; - void function(SFMLClass, int) sfSprite_FlipY; - SFMLClass function(SFMLClass) sfSprite_GetImage; - IntRect function(SFMLClass) sfSprite_GetSubRect; - float function(SFMLClass) sfSprite_GetWidth; - float function(SFMLClass) sfSprite_GetHeight; - Color function(SFMLClass, uint, uint) sfSprite_GetPixel; - } - - mixin(loadFromSharedLib2("csfml-graphics", "sfSprite", - "SetImage", "SetSubRect", "Resize", "FlipX", "FlipY", "GetImage", "GetSubRect", "GetWidth", "GetHeight", "GetPixel")); -} \ No newline at end of file diff --git a/bindings/d/import/dsfml/graphics/text.d b/bindings/d/import/dsfml/graphics/text.d deleted file mode 100644 index 72a65c45..00000000 --- a/bindings/d/import/dsfml/graphics/text.d +++ /dev/null @@ -1,277 +0,0 @@ -/* -* DSFML - SFML Library wrapper for the D programming language. -* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com) -* Copyright (C) 2010 Andreas Hollandt -* -* This software is provided 'as-is', without any express or -* implied warranty. In no event will the authors be held -* liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute -* it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; -* you must not claim that you wrote the original software. -* If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but -* is not required. -* -* 2. Altered source versions must be plainly marked as such, -* and must not be misrepresented as being the original software. -* -* 3. This notice may not be removed or altered from any -* source distribution. -*/ - -module dsfml.graphics.text; - -import dsfml.graphics.blendmode; -import dsfml.graphics.color; -import dsfml.graphics.font; -import dsfml.graphics.drawableimpl; -import dsfml.graphics.rect; - -import dsfml.system.stringutil; -import dsfml.system.vector; - - -/** - * Enumerate the text drawing styles - */ -enum TextStyle -{ - REGULAR = 0, /// Regular characters, no style - BOLD = 1 << 0, /// Characters are bold - ITALIC = 1 << 1, /// Characters are in italic - UNDERLINED = 1 << 2 /// Characters are underlined -} - -/** -* Text defines a graphical 2D text, that can be drawn on screen -* -* All string litterals used must be prefixed with c for utf-8 -* and d for utf-32 string. -* -* Examples : -* --------------------------------------------------------------- -* Text s = new Text("Hello"c); -* //this(string, Font, float) -* s = new Text("Hello"d); -* //this(dstring, Font, float) -* --------------------------------------------------------------- -* -* See_Also: -* IDrawable -*/ -class Text : DrawableImpl!("sfText") -{ -private: - Font m_font; - -public: - /** - * Construct the string from a text - * - * Prefixs string litterals with c - * - * Params: - * s = Text assigned to the string - * f = Font used to draw the string (use default font) - * size = Characters size, in pixels (32 by default) - */ - this(string s, Font f = Font.getDefaultFont(), uint size = 30) - { - super(); - - font = f; - text = s; - characterSize = size; - } - - /** - * Construct the string from a unicode text - * - * Prefixs string litterals with d - * - * Params: - * s = Text assigned to the string - * f = Font used to draw the string (use default font) - * size = Characters size, in pixels (32 by default) - */ - this(dstring s, Font f = Font.getDefaultFont(), uint size = 30) - { - super(); - - font = f; - text = s; - characterSize = size; - } - -@property -{ - /** - * Set the text (from a multibyte string) - * - * Params: - * text = New text - */ - void text(string text) - { - sfText_SetString(m_ptr, toStringz(text)); - } - - /** - * Set the text (from a unicode string) - * - * Params: - * text = New text - */ - void text(dstring text) - { - sfText_SetUnicodeString(m_ptr, toStringz(text)); - } - - /** - * Get the text (returns a multibyte string) - * - * Returns: - * Text - */ - string text() - { - return fromStringz(sfText_GetString(m_ptr)); - } - - /** - * Set the font of the string - * - * Params: - * f = Font - */ - void font(Font f) - { - m_font = f; - sfText_SetFont(m_ptr, f.nativePointer); - } - - /** - * Set the size of the string - * - * Params: - * size = New size, in pixels - */ - void characterSize(uint size) - { - sfText_SetCharacterSize(m_ptr, size); - } - - /** - * Set the style of the text - * The default style is Regular - * - * Params: - * TextStyle = New text style, (combination of Style enum values) - * - */ - void style(TextStyle tstyle) - { - sfText_SetStyle(m_ptr, tstyle); - } - - /** - * Get the text (returns a unicode string) - * - * Returns: - * Text - */ - dstring unicodeText() - { - return fromStringz(sfText_GetUnicodeString(m_ptr)); - } - - /** - * Get the font used by the string - * - * Returns: - * Font name - */ - Font font() - { - return m_font; - } - - /** - * Get the size of the characters - * - * Returns: - * Size of the characters - */ - uint characterSize() - { - return sfText_GetCharacterSize(m_ptr); - } - - /** - * Get the current font style - * - * Returns: - * Font style - */ - TextStyle style() - { - return sfText_GetStyle(m_ptr); - } - - /** - * Get the string rectangle on screen - * - * Returns: - * Rectangle contaning the string in screen coordinates - */ - FloatRect rect() - { - return sfText_GetRect(m_ptr); - } -} - - /** - * Return the visual position of the Index-th character of the string, - * in coordinates relative to the string - * (note : translation, center, rotation and scale are not applied) - * - * Params: - * index = Index of the character - * - * Returns: - * Position of the Index-th character (end of string of Index is out of range) - */ - Vector2f getCharacterPos(size_t index) - { - Vector2f ret; - sfText_GetCharacterPos(m_ptr, index, &ret.x, &ret.y); - return ret; - } - -private: - - static extern(C) - { - void function(SFMLClass, cchar*) sfText_SetString; - void function(SFMLClass, cdchar*) sfText_SetUnicodeString; - void function(SFMLClass, SFMLClass) sfText_SetFont; - void function(SFMLClass, uint) sfText_SetCharacterSize; - void function(SFMLClass, TextStyle) sfText_SetStyle; - idchar* function(SFMLClass) sfText_GetUnicodeString; - ichar* function(SFMLClass) sfText_GetString; - SFMLClass function(SFMLClass) sfText_GetFont; - uint function(SFMLClass) sfText_GetCharacterSize; - TextStyle function (SFMLClass) sfText_GetStyle; - void function(SFMLClass, size_t, float*, float*) sfText_GetCharacterPos; - FloatRect function(SFMLClass) sfText_GetRect; - } - - mixin(loadFromSharedLib2("csfml-graphics", "sfText", - "SetString", "SetUnicodeString", "SetFont", "SetCharacterSize", "SetStyle", "GetUnicodeString", "GetString", "GetFont", - "GetCharacterSize", "GetStyle", "GetCharacterPos", "GetRect")); -} \ No newline at end of file diff --git a/bindings/d/import/dsfml/graphics/view.d b/bindings/d/import/dsfml/graphics/view.d deleted file mode 100644 index c1357bb8..00000000 --- a/bindings/d/import/dsfml/graphics/view.d +++ /dev/null @@ -1,347 +0,0 @@ -/* -* DSFML - SFML Library wrapper for the D programming language. -* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com) -* Copyright (C) 2010 Andreas Hollandt -* -* This software is provided 'as-is', without any express or -* implied warranty. In no event will the authors be held -* liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute -* it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; -* you must not claim that you wrote the original software. -* If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but -* is not required. -* -* 2. Altered source versions must be plainly marked as such, -* and must not be misrepresented as being the original software. -* -* 3. This notice may not be removed or altered from any -* source distribution. -*/ - -module dsfml.graphics.view; - -import dsfml.graphics.rect; - -import dsfml.system.common, - dsfml.system.vector; - -/** -* This class defines a view (position, size and zoom) ; -* you can consider it as a camera -*/ -class View : DSFMLObject -{ -private: - FloatRect _rect; // a view defines a source area of the scene to display, and a destination area into the rendertarget where to map the source area - FloatRect _viewport; // the viewport is the destination area in the rendertarget - bool m_isModified = true; - -public: - /** - * Constructor - * - * Default view (1000 x 1000) - */ - this() - { - super(sfView_Create()); - } - - /** - * Constructor - * - * Params: - * center = center of the view - * size = size of the view (width, height) - */ - this(Vector2f center, Vector2f size) - { - super(sfView_CreateFromRect(FloatRect(center.x - size.x / 2, center.y - size.y / 2, size.x, size.y) )); - } - - /** - * Constructor - * - * Params: - * rect = Rectangle defining the position and size of the view - */ - this(FloatRect rect) - { - super(sfView_CreateFromRect(rect)); - } - - override void dispose() - { - sfView_Destroy(m_ptr); - } - - /** - * Change the center of the view - * - * Params: - * x = X coordinates of the new center - * y = Y coordinates of the new center - */ - void setCenter(float x, float y) - { - sfView_SetCenter(m_ptr, x, y); - m_isModified = true; - } - - /** - * Change the center of the view - * - * Params: - * center = New center - */ - void setCenter(Vector2f center) - { - sfView_SetCenter(m_ptr, center.x, center.y); - m_isModified = true; - } - - /** - * Change the size of the view (take 2 values) - * - * Params: - * width = New width - * height = New height - */ - void setSize(float width, float height) - { - sfView_SetSize(m_ptr, width, height); - m_isModified = true; - } - - /** - * Change the size of the view (take 2 values) - * - * Params: - * size = New size - */ - void setSize(Vector2f size) - { - sfView_SetSize(m_ptr, size.x, size.y); - m_isModified = true; - } - - /** - * Rebuild the view from a rectangle - * - * Params: - * viewport : Rectangle defining the position and size of the view - */ - void setViewport(FloatRect viewport) - { - sfView_SetViewport(m_ptr, viewport); - _viewport = viewport; - } - - /** - * Get the center of the view - * - * Returns: - * Center of the view - */ - Vector2f getCenter() - { - return Vector2f(sfView_GetCenterX(m_ptr), sfView_GetCenterY(m_ptr)); - } - - /** - * Get the size of the view - * - * Returns: - * size of the view - */ - Vector2f getSize() - { - return Vector2f(sfView_GetWidth(m_ptr), sfView_GetHeight(m_ptr)); - } - - /** - * Get the width of the view - * - * Returns: - * width of the view - */ - float getWidth() - { - return sfView_GetWidth(m_ptr); - } - - /** - * Get the height of the view - * - * Returns: - * height of the view - */ - float getHeight() - { - return sfView_GetHeight(m_ptr); - } - - /** - * Get the bounding retangle of the view - */ - FloatRect getViewport() - { - if (m_isModified) - { - m_isModified = false; - _viewport = sfView_GetViewport(m_ptr); - } - return _viewport; - } - - /** - * Move the view - * - * Params: - * offsetX = Offset to move the view, on X axis - * offsetY = Offset to move the view, on Y axis - */ - View move(float offsetX, float offsetY) - { - sfView_Move(m_ptr, offsetX, offsetY); - m_isModified = true; - - return this; - } - - /** - * Move the view - * - * Params: - * offset = offsetto move the view - */ - View move(Vector2f offset) - { - sfView_Move(m_ptr, offset.x, offset.y); - m_isModified = true; - - return this; - } - - /** - * Resize the view rectangle to simulate a zoom / unzoom effect - * - * Params: - * factor = Zoom factor to apply, relative to the current zoom - */ - View zoom(float factor) - { - sfView_Zoom(m_ptr, factor); - m_isModified = true; - - return this; - } - - /** - * Rotate the view relatively to its current orientation. - * - * Params: - * angle = Angle to rotate, in degree - */ - View rotate(float angle) - { - sfView_Rotate(m_ptr, angle); - - return this; - } - - /** - * Set the orientation of the view - * The default rotation of a view is 0 degree - * - * Params: - * angle = New angle, in degrees - */ - View setRotation(float angle) - { - sfView_SetRotation(m_ptr, angle); - - return this; - } - - /** - * Get the current orientation of the view - * - * Returns: - * Rotation angle of the view, in degrees - */ - float getRotation() - { - return sfView_GetRotation(m_ptr); - } - - void reset(FloatRect rect) - { - sfView_Reset(m_ptr, rect); - _rect = rect; - } -package: - - this(SFMLClass ptr, bool preventDelete) - { - super(ptr, preventDelete); - } - -private: - static extern(C) - { - SFMLClass function() sfView_Create; - SFMLClass function(FloatRect) sfView_CreateFromRect; - void function(SFMLClass) sfView_Destroy; - void function(SFMLClass, float, float) sfView_SetCenter; - void function(SFMLClass, float, float) sfView_SetSize; - void function(SFMLClass, FloatRect) sfView_SetViewport; - float function(SFMLClass) sfView_GetCenterX; - float function(SFMLClass) sfView_GetCenterY; - float function(SFMLClass) sfView_GetWidth; - float function(SFMLClass) sfView_GetHeight; - FloatRect function(SFMLClass) sfView_GetViewport; - void function(SFMLClass, float, float) sfView_Move; - void function(SFMLClass, float) sfView_Zoom; - - // DSFML2 - void function(SFMLClass, float) sfView_SetRotation; - float function(SFMLClass) sfView_GetRotation; - void function(SFMLClass, float) sfView_Rotate; - void function(SFMLClass, FloatRect) sfView_Reset; - } - - static this() - { - debug - DllLoader dll = DllLoader.load("csfml-graphics-d-2"); - else - DllLoader dll = DllLoader.load("csfml-graphics-2"); - - mixin(loadFromSharedLib("sfView_Create")); - mixin(loadFromSharedLib("sfView_CreateFromRect")); - mixin(loadFromSharedLib("sfView_Destroy")); - mixin(loadFromSharedLib("sfView_SetCenter")); - mixin(loadFromSharedLib("sfView_SetSize")); - mixin(loadFromSharedLib("sfView_SetViewport")); - mixin(loadFromSharedLib("sfView_GetCenterX")); - mixin(loadFromSharedLib("sfView_GetCenterY")); - mixin(loadFromSharedLib("sfView_GetWidth")); - mixin(loadFromSharedLib("sfView_GetHeight")); - mixin(loadFromSharedLib("sfView_GetViewport")); - mixin(loadFromSharedLib("sfView_Move")); - mixin(loadFromSharedLib("sfView_Zoom")); - - // DSFML2 - mixin(loadFromSharedLib("sfView_SetRotation")); - mixin(loadFromSharedLib("sfView_GetRotation")); - mixin(loadFromSharedLib("sfView_Rotate")); - mixin(loadFromSharedLib("sfView_Reset")); - } -} \ No newline at end of file diff --git a/bindings/d/import/dsfml/network/all.d b/bindings/d/import/dsfml/network/all.d deleted file mode 100644 index 4a310d8c..00000000 --- a/bindings/d/import/dsfml/network/all.d +++ /dev/null @@ -1,38 +0,0 @@ -/* -* DSFML - SFML Library wrapper for the D programming language. -* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com) -* Copyright (C) 2010 Andreas Hollandt -* -* This software is provided 'as-is', without any express or -* implied warranty. In no event will the authors be held -* liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute -* it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; -* you must not claim that you wrote the original software. -* If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but -* is not required. -* -* 2. Altered source versions must be plainly marked as such, -* and must not be misrepresented as being the original software. -* -* 3. This notice may not be removed or altered from any -* source distribution. -*/ - -module dsfml.network.all; - -public import - dsfml.network.ftp, - dsfml.network.http, - dsfml.network.ipaddress, - dsfml.network.packet, - dsfml.network.socketselector, - dsfml.network.socketstatus, - dsfml.network.tcpsocket, - dsfml.network.udpsocket, - dsfml.network.tcplistener ; diff --git a/bindings/d/import/dsfml/network/ftp.d b/bindings/d/import/dsfml/network/ftp.d deleted file mode 100644 index 7fbc36cd..00000000 --- a/bindings/d/import/dsfml/network/ftp.d +++ /dev/null @@ -1,602 +0,0 @@ -/* -* DSFML - SFML Library wrapper for the D programming language. -* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com) -* Copyright (C) 2010 Andreas Hollandt -* -* This software is provided 'as-is', without any express or -* implied warranty. In no event will the authors be held -* liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute -* it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; -* you must not claim that you wrote the original software. -* If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but -* is not required. -* -* 2. Altered source versions must be plainly marked as such, -* and must not be misrepresented as being the original software. -* -* 3. This notice may not be removed or altered from any -* source distribution. -*/ - -module dsfml.network.ftp; - -import dsfml.system.common; -import dsfml.system.stringutil; - -import dsfml.network.ipaddress; - - -/** -* Enumeration of transfer mode -*/ -enum FtpTransferMode -{ - BINARY, ///< Binary mode (file is transfered as a sequence of bytes) - ASCII, ///< Text mode using ASCII encoding - EBCDIC ///< Text mode using EBCDIC encoding -} - -/** -* Enumerate all the valid status codes returned in -* a FTP response -*/ -enum FtpStatus -{ - // 1xx: the requested action is being initiated, - // expect another reply before proceeding with a new command - RESTARTMARKERREPLY = 110, ///< Restart marker reply - SERVICEREADYSOON = 120, ///< Service ready in N minutes - DATACONNECTIONALREADYOPENED = 125, ///< Data connection already opened, transfer starting - OPENINGDATACONNECTION = 150, ///< File status ok, about to open data connection - - // 2xx: the requested action has been successfully completed - OK = 200, ///< Command ok - POINTLESSCOMMAND = 202, ///< Command not implemented - SYSTEMSTATUS = 211, ///< System status, or system help reply - DIRECTORYSTATUS = 212, ///< Directory status - FILESTATUS = 213, ///< File status - HELPMESSAGE = 214, ///< Help message - SYSTEMTYPE = 215, ///< NAME system type, where NAME is an official system name from the list in the Assigned Numbers document - SERVICEREADY = 220, ///< Service ready for new user - CLOSINGCONNECTION = 221, ///< Service closing control connection - DATACONNECTIONOPENED = 225, ///< Data connection open, no transfer in progress - CLOSINGDATACONNECTION = 226, ///< Closing data connection, requested file action successful - ENTERINGPASSIVEMODE = 227, ///< Entering passive mode - LOGGEDIN = 230, ///< User logged in, proceed. Logged out if appropriate - FILEACTIONOK = 250, ///< Requested file action ok - DIRECTORYOK = 257, ///< PATHNAME created - - // 3xx: the command has been accepted, but the requested action - // is dormant, pending receipt of further information - NEEDPASSWORD = 331, ///< User name ok, need password - NEEDACCOUNTTOLOGIN = 332, ///< Need account for login - NEEDINFORMATION = 350, ///< Requested file action pending further information - - // 4xx: the command was not accepted and the requested action did not take place, - // but the error condition is temporary and the action may be requested again - SERVICEUNAVAILABLE = 421, ///< Service not available, closing control connection - DATACONNECTIONUNAVAILABLE = 425, ///< Can't open data connection - TRANSFERABORTED = 426, ///< Connection closed, transfer aborted - FILEACTIONABORTED = 450, ///< Requested file action not taken - LOCALERROR = 451, ///< Requested action aborted, local error in processing - INSUFFICIENTSTORAGESPACE = 452, ///< Requested action not taken; insufficient storage space in system, file unavailable - - // 5xx: the command was not accepted and - // the requested action did not take place - COMMANDUNKNOWN = 500, ///< Syntax error, command unrecognized - PARAMETERSUNKNOWN = 501, ///< Syntax error in parameters or arguments - COMMANDNOTIMPLEMENTED = 502, ///< Command not implemented - BADCOMMANDSEQUENCE = 503, ///< Bad sequence of commands - PARAMETERNOTIMPLEMENTED = 504, ///< Command not implemented for that parameter - NOTLOGGEDIN = 530, ///< Not logged in - NEEDACCOUNTTOSTORE = 532, ///< Need account for storing files - FILEUNAVAILABLE = 550, ///< Requested action not taken, file unavailable - PAGETYPEUNKNOWN = 551, ///< Requested action aborted, page type unknown - NOTENOUGHMEMORY = 552, ///< Requested file action aborted, exceeded storage allocation - FILENAMENOTALLOWED = 553, ///< Requested action not taken, file name not allowed - - // 10xx: SFML custom codes - INVALIDRESPONSE = 1000, ///< Response is not a valid FTP one - CONNECTIONFAILED = 1001, ///< Connection with server failed - CONNECTIONCLOSED = 1002, ///< Connection with server closed - INVALIDFILE = 1003 ///< Invalid file to upload / download -} - - -/** -* This class provides methods for manipulating the FTP protocol (described in RFC 959). -* It provides easy access and transfers to remote directories and files on a FTP server. -*/ -class Ftp : DSFMLObject -{ - /** - * This class wraps a FTP response, which is basically : - * - a status code - * - a message - */ - static class FtpResponse : DSFMLObject - { - override void dispose() - { - sfFtpResponse_Destroy(m_ptr); - } - - /** - * Convenience function to check if the response status code - * means a success - * - * Returns: - * True if status is success (code < 400) - */ - bool isOk() - { - return cast(bool)sfFtpResponse_IsOk(m_ptr); - } - - /** - * Get the response status code - * - * Returns: - * Status code - */ - FtpStatus getStatus() - { - return sfFtpResponse_GetStatus(m_ptr); - } - - /** - * Get the full message contained in the response - * - * Returns: - * The response message - */ - string getMessage() - { - return fromStringz(sfFtpResponse_GetMessage(m_ptr)); - } - - private: - this(SFMLClass ptr) - { - super(ptr); - } - // External ================================================================ - - extern (C) - { - typedef void function(SFMLClass) pf_sfFtpResponse_Destroy; - typedef int function(SFMLClass) pf_sfFtpResponse_IsOk; - typedef FtpStatus function(SFMLClass) pf_sfFtpResponse_GetStatus; - typedef ichar* function(SFMLClass) pf_sfFtpResponse_GetMessage; - - static pf_sfFtpResponse_Destroy sfFtpResponse_Destroy; - static pf_sfFtpResponse_IsOk sfFtpResponse_IsOk; - static pf_sfFtpResponse_GetStatus sfFtpResponse_GetStatus; - static pf_sfFtpResponse_GetMessage sfFtpResponse_GetMessage; - } - static this() - { - DllLoader dll = DllLoader.load("csfml-network-2"); - - sfFtpResponse_Destroy = cast(pf_sfFtpResponse_Destroy)dll.getSymbol("sfFtpResponse_Destroy"); - sfFtpResponse_IsOk = cast(pf_sfFtpResponse_IsOk)dll.getSymbol("sfFtpResponse_IsOk"); - sfFtpResponse_GetStatus = cast(pf_sfFtpResponse_GetStatus)dll.getSymbol("sfFtpResponse_GetStatus"); - sfFtpResponse_GetMessage = cast(pf_sfFtpResponse_GetMessage)dll.getSymbol("sfFtpResponse_GetMessage"); - } - } - - /** - * Specialization of FTP response returning a directory - */ - static class FtpDirectoryResponse : FtpResponse - { - override void dispose() - { - sfFtpDirectoryResponse_Destroy(m_ptr); - } - - /** - * Get the directory returned in the response. - * - * Returns: - * Directory name - */ - string getDirectory() - { - return fromStringz(sfFtpDirectoryResponse_GetDirectory(m_ptr)); - } - - private: - this(SFMLClass ptr) - { - super(ptr); - } - // External ================================================================ - - extern (C) - { - typedef void function(SFMLClass) pf_sfFtpDirectoryResponse_Destroy; - typedef ichar* function(SFMLClass) pf_sfFtpDirectoryResponse_GetDirectory; - - static pf_sfFtpDirectoryResponse_Destroy sfFtpDirectoryResponse_Destroy; - static pf_sfFtpDirectoryResponse_GetDirectory sfFtpDirectoryResponse_GetDirectory; - } - static this() - { - DllLoader dll = DllLoader.load("csfml-network-2"); - - sfFtpDirectoryResponse_Destroy = cast(pf_sfFtpDirectoryResponse_Destroy)dll.getSymbol("sfFtpDirectoryResponse_Destroy"); - sfFtpDirectoryResponse_GetDirectory = cast(pf_sfFtpDirectoryResponse_GetDirectory)dll.getSymbol("sfFtpDirectoryResponse_GetDirectory"); - } - - } - - /** - * Specialization of FTP response returning a filename listing. - */ - static class FtpListingResponse : FtpResponse - { - override void dispose() - { - sfFtpListingResponse_Destroy(m_ptr); - } - - /** - * Get the number of files in the listing - * - * Returns: - * Total number of files - */ - size_t getCount() - { - return sfFtpListingResponse_GetCount(m_ptr); - } - - /** - * Get the index-th filename in the directory - * - * Params: - * index = Index of the filename to get - * - * Returns: - * Filename - */ - string opIndex(size_t index) - { - return fromStringz(sfFtpListingResponse_GetFilename(m_ptr, index)); - } - - /** - * Foreach implementation - */ - int opApply(int delegate(string) dg) - { - size_t count = getCount(); - int result; - - for(int i = 0; i < count; i++) - { - result = dg(this[i]); - if (result) - break; - } - - return result; - } - - private: - this(SFMLClass ptr) - { - super(ptr); - } - - // External ================================================================ - extern (C) - { - typedef void function(SFMLClass) pf_sfFtpListingResponse_Destroy; - typedef size_t function(SFMLClass) pf_sfFtpListingResponse_GetCount; - typedef ichar* function(SFMLClass, size_t) pf_sfFtpListingResponse_GetFilename; - - static pf_sfFtpListingResponse_Destroy sfFtpListingResponse_Destroy; - static pf_sfFtpListingResponse_GetCount sfFtpListingResponse_GetCount; - static pf_sfFtpListingResponse_GetFilename sfFtpListingResponse_GetFilename; - } - static this() - { - DllLoader dll = DllLoader.load("csfml-network-2"); - - sfFtpListingResponse_Destroy = cast(pf_sfFtpListingResponse_Destroy)dll.getSymbol("sfFtpListingResponse_Destroy"); - sfFtpListingResponse_GetCount = cast(pf_sfFtpListingResponse_GetCount)dll.getSymbol("sfFtpListingResponse_GetCount"); - sfFtpListingResponse_GetFilename = cast(pf_sfFtpListingResponse_GetFilename)dll.getSymbol("sfFtpListingResponse_GetFilename"); - } - } - - /** - * Default constructor - */ - this() - { - super(sfFtp_Create()); - } - - override void dispose() - { - sfFtp_Destroy(m_ptr); - } - - /** - * Connect to the specified FTP server - * - * Params: - * server = FTP server to connect to - * port = Port used for connection (21 by default, standard FTP port) - * timeout = Maximum time to wait, in seconds (0 by default, means no timeout) - * - * Returns: - * Server response to the request - */ - FtpResponse connect(IPAddress server, ushort port = 21, float timeout = 0.f) - { - return new FtpResponse(sfFtp_Connect(m_ptr, server, port, timeout)); - } - - /** - * Log in using anonymous account - * - * Returns: - * Server response to the request - */ - FtpResponse login() - { - return new FtpResponse(sfFtp_LoginAnonymous(m_ptr)); - } - - /** - * Log in using a username and a password - * - * Params: - * username = User name - * password = password - * - * Returns: - * Server response to the request - */ - FtpResponse login(string username, string password) - { - return new FtpResponse(sfFtp_Login(m_ptr, toStringz(username), toStringz(password))); - } - - /** - * Close the connection with FTP server - * - * Returns: - * Server response to the request - */ - FtpResponse disconnect() - { - return new FtpResponse(sfFtp_Disconnect(m_ptr)); - } - - /** - * Send a null command to prevent from being disconnected. - * - * Returns: - * Server response to the request - */ - FtpResponse keepAlive() - { - return new FtpResponse(sfFtp_KeepAlive(m_ptr)); - } - - /** - * Get the current working directory - * - * Returns: - * Server response to the request - */ - FtpDirectoryResponse getWorkingDirectory() - { - return new FtpDirectoryResponse(sfFtp_GetWorkingDirectory(m_ptr)); - } - - /** - * Get the content of the given directory (subdirectories and files). - * - * Params: - * directory = directory to list (null by default, the current one) - * - * Returns: - * Server response to the request - */ - FtpListingResponse getDirectoryListing(string directory = null) - { - return new FtpListingResponse(sfFtp_GetDirectoryListing(m_ptr, toStringz(directory))); - } - - /** - * Change the current working directory - * - * Params: - * directory = New directory, relative to the current one. - * - * Returns: - * Server response to the request - */ - FtpResponse changeDirectory(string directory) - { - return new FtpResponse(sfFtp_ChangeDirectory(m_ptr, toStringz(directory))); - } - - /** - * Go to the parent directory of the current one - * - * Returns: - * Server response to the request - */ - FtpResponse parentDirectory() - { - return new FtpResponse(sfFtp_ParentDirectory(m_ptr)); - } - - /** - * Create a new directory - * - * Params: - * name = name of the directory to create - * - * Returns: - * Server response to the request - */ - FtpResponse createDirectory(string name) - { - return new FtpResponse(sfFtp_CreateDirectory(m_ptr, toStringz(name))); - } - - /** - * remove an existing directory - * - * Params: - * name = name of the directory to remove - * - * Returns: - * Server response to the request - */ - FtpResponse deleteDirectory(string name) - { - return new FtpResponse(sfFtp_DeleteDirectory(m_ptr, toStringz(name))); - } - - /** - * Rename a file - * - * Params: - * name = file to rename - * newName = new name - * - * Returns: - * Server response to the request - */ - FtpResponse renameFile(string name, string newName) - { - return new FtpResponse(sfFtp_RenameFile(m_ptr, toStringz(name), toStringz(newName))); - } - - /** - * Remove an existing file - * - * Params: - * name = file to remove - * - * Returns: - * Server response to the request - */ - FtpResponse deleteFile(string name) - { - return new FtpResponse(sfFtp_DeleteFile(m_ptr, toStringz(name))); - } - - /** - * Download a file from the server - * - * Params: - * distantFile = Path of the distant file to download - * destFile = Where to put the file on the local computer - * mode = transfer mode (binary by default) - * - * Returns: - * Server response to the request - */ - FtpResponse download(string distantFile, string destFile, FtpTransferMode mode = FtpTransferMode.BINARY) - { - return new FtpResponse(sfFtp_Download(m_ptr, toStringz(distantFile), toStringz(destFile), mode)); - } - - /** - * Upload a file to the server - * - * Params: - * localFile = Path of the local file to upload - * destPath = Where to put the file on the server - * mode = transfer mode (binary by default) - * Returns: - * Server response to the request - */ - FtpResponse upload(string localFile, string destFile, FtpTransferMode mode = FtpTransferMode.BINARY) - { - return new FtpResponse(sfFtp_Upload(m_ptr, toStringz(localFile), toStringz(destFile), mode)); - } - -private: - -// External ==================================================================== - - extern (C) - { - typedef SFMLClass function() pf_sfFtp_Create; - typedef void function(SFMLClass) pf_sfFtp_Destroy; - typedef SFMLClass function(SFMLClass, IPAddress, ushort, float) pf_sfFtp_Connect; - typedef SFMLClass function(SFMLClass) pf_sfFtp_LoginAnonymous; - typedef SFMLClass function(SFMLClass, cchar*, cchar*) pf_sfFtp_Login; - typedef SFMLClass function(SFMLClass) pf_sfFtp_Disconnect; - typedef SFMLClass function(SFMLClass) pf_sfFtp_KeepAlive; - typedef SFMLClass function(SFMLClass) pf_sfFtp_GetWorkingDirectory; - typedef SFMLClass function(SFMLClass, cchar*) pf_sfFtp_GetDirectoryListing; - typedef SFMLClass function(SFMLClass, cchar*) pf_sfFtp_ChangeDirectory; - typedef SFMLClass function(SFMLClass) pf_sfFtp_ParentDirectory; - typedef SFMLClass function(SFMLClass, cchar*) pf_sfFtp_CreateDirectory; - typedef SFMLClass function(SFMLClass, cchar*) pf_sfFtp_DeleteDirectory; - typedef SFMLClass function(SFMLClass, cchar*, cchar*) pf_sfFtp_RenameFile; - typedef SFMLClass function(SFMLClass, cchar*) pf_sfFtp_DeleteFile; - typedef SFMLClass function(SFMLClass, cchar*, cchar*, FtpTransferMode) pf_sfFtp_Download; - typedef SFMLClass function(SFMLClass, cchar*, cchar*, FtpTransferMode) pf_sfFtp_Upload; - - static pf_sfFtp_Create sfFtp_Create; - static pf_sfFtp_Destroy sfFtp_Destroy; - static pf_sfFtp_Connect sfFtp_Connect; - static pf_sfFtp_LoginAnonymous sfFtp_LoginAnonymous; - static pf_sfFtp_Login sfFtp_Login; - static pf_sfFtp_Disconnect sfFtp_Disconnect; - static pf_sfFtp_KeepAlive sfFtp_KeepAlive; - static pf_sfFtp_GetWorkingDirectory sfFtp_GetWorkingDirectory; - static pf_sfFtp_GetDirectoryListing sfFtp_GetDirectoryListing; - static pf_sfFtp_ChangeDirectory sfFtp_ChangeDirectory; - static pf_sfFtp_ParentDirectory sfFtp_ParentDirectory; - static pf_sfFtp_CreateDirectory sfFtp_CreateDirectory; - static pf_sfFtp_DeleteDirectory sfFtp_DeleteDirectory; - static pf_sfFtp_RenameFile sfFtp_RenameFile; - static pf_sfFtp_DeleteFile sfFtp_DeleteFile; - static pf_sfFtp_Download sfFtp_Download; - static pf_sfFtp_Upload sfFtp_Upload; - } - static this() - { - debug - DllLoader dll = DllLoader.load("csfml-network-d-2"); - else - DllLoader dll = DllLoader.load("csfml-network-2"); - - sfFtp_Create = cast(pf_sfFtp_Create)dll.getSymbol("sfFtp_Create"); - sfFtp_Destroy = cast(pf_sfFtp_Destroy)dll.getSymbol("sfFtp_Destroy"); - sfFtp_Connect = cast(pf_sfFtp_Connect)dll.getSymbol("sfFtp_Connect"); - sfFtp_LoginAnonymous = cast(pf_sfFtp_LoginAnonymous)dll.getSymbol("sfFtp_LoginAnonymous"); - sfFtp_Login = cast(pf_sfFtp_Login)dll.getSymbol("sfFtp_Login"); - sfFtp_Disconnect = cast(pf_sfFtp_Disconnect)dll.getSymbol("sfFtp_Disconnect"); - sfFtp_KeepAlive = cast(pf_sfFtp_KeepAlive)dll.getSymbol("sfFtp_KeepAlive"); - sfFtp_GetWorkingDirectory = cast(pf_sfFtp_GetWorkingDirectory)dll.getSymbol("sfFtp_GetWorkingDirectory"); - sfFtp_GetDirectoryListing = cast(pf_sfFtp_GetDirectoryListing)dll.getSymbol("sfFtp_GetDirectoryListing"); - sfFtp_ChangeDirectory = cast(pf_sfFtp_ChangeDirectory)dll.getSymbol("sfFtp_ChangeDirectory"); - sfFtp_ParentDirectory = cast(pf_sfFtp_ParentDirectory)dll.getSymbol("sfFtp_ParentDirectory"); - sfFtp_sfFtp_CreateDirectoryDirectory = cast(pf_sfFtp_CreateDirectory)dll.getSymbol("sfFtp_CreateDirectory"); - sfFtp_DeleteDirectory = cast(pf_sfFtp_DeleteDirectory)dll.getSymbol("sfFtp_DeleteDirectory"); - sfFtp_RenameFile = cast(pf_sfFtp_RenameFile)dll.getSymbol("sfFtp_RenameFile"); - sfFtp_DeleteFile = cast(pf_sfFtp_DeleteFile)dll.getSymbol("sfFtp_DeleteFile"); - sfFtp_Download = cast(pf_sfFtp_Download)dll.getSymbol("sfFtp_Download"); - sfFtp_Upload = cast(pf_sfFtp_Upload)dll.getSymbol("sfFtp_Upload"); - } -} diff --git a/bindings/d/import/dsfml/network/http.d b/bindings/d/import/dsfml/network/http.d deleted file mode 100644 index 1ab94302..00000000 --- a/bindings/d/import/dsfml/network/http.d +++ /dev/null @@ -1,398 +0,0 @@ -/* -* DSFML - SFML Library wrapper for the D programming language. -* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com) -* Copyright (C) 2010 Andreas Hollandt -* -* This software is provided 'as-is', without any express or -* implied warranty. In no event will the authors be held -* liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute -* it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; -* you must not claim that you wrote the original software. -* If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but -* is not required. -* -* 2. Altered source versions must be plainly marked as such, -* and must not be misrepresented as being the original software. -* -* 3. This notice may not be removed or altered from any -* source distribution. -*/ - -module dsfml.network.http; - -import dsfml.system.stringutil; -import dsfml.system.common; - -/** -* HTTP methods enumeration -*/ -enum HttpMethod -{ - GET, ///< Request in get mode, standard method to retrieve a page - POST, ///< Request in post mode, usually to send data to a page - HEAD ///< Request a page's header only -} - -/** -* HTTP response status code -*/ -enum HttpStatus -{ - // 2xx: success - OK = 200, ///< Most common code returned when operation was successful - CREATED = 201, ///< The resource has successfully been created - ACCEPTED = 202, ///< The request has been accepted, but will be processed later by the server - NOCONTENT = 204, ///< Sent when the server didn't send any data in return - - // 3xx: redirection - MULTIPLECHOICES = 300, ///< The requested page can be accessed from several locations - MOVEDPERMANENTLY = 301, ///< The requested page has permanently moved to a new location - MOVEDTEMPORARILY = 302, ///< The requested page has temporarily moved to a new location - NOTMODIFIED = 304, ///< For conditionnal requests, means the requested page hasn't changed and doesn't need to be refreshed - - // 4xx: client error - BADREQUEST = 400, ///< The server couldn't understand the request (syntax error) - UNAUTHORIZED = 401, ///< The requested page needs an authentification to be accessed - FORBIDDEN = 403, ///< The requested page cannot be accessed at all, even with authentification - NOTFOUND = 404, ///< The requested page doesn't exist - - // 5xx: server error - INTERNALSERVERERROR = 500, ///< The server encountered an unexpected error - NOTIMPLEMENTED = 501, ///< The server doesn't implement a requested feature - BADGATEWAY = 502, ///< The gateway server has received an error from the source server - SERVICENOTAVAILABLE = 503, ///< The server is temporarily unavailable (overloaded, in maintenance, ...) - - // 10xx: SFML custom codes - INVALIDRESPONSE = 1000, ///< Response is not a valid HTTP one - CONNECTIONFAILED = 1001 ///< Connection with server failed -} - -/** -* This class provides methods for manipulating the HTTP protocol (described in -* RFC 1945). -* It can connect to a website, get files, send requests -*/ -class Http : DSFMLObject -{ - /** - * Wrapper for a http request, which is basically : - * - a header with a method, a target URI and a set of field/value pairs - * - an optional body (for POST requests) - */ - static class Response : DSFMLObject - { - override void dispose() - { - sfHttpResponse_Destroy(m_ptr); - } - - /** - * Get the value of a field - * - * Params: - * field = Name of the field to get (case-insensitive) - * Returns: - * Value of the field, or enpty string if not found - */ - string getField(string field) - { - return fromStringz(sfHttpResponse_GetField(m_ptr, toStringz(field))); - } - - /** - * Get the header status code - * - * Returns: - * header status code - */ - HttpStatus getStatus() - { - return sfHttpResponse_GetStatus(m_ptr); - } - - /** - * Get the major HTTP version number of the response - * - * Returns: - * Major version number - */ - uint getMajorHTTPVersion() - { - return sfHttpResponse_GetMajorVersion(m_ptr); - } - - /** - * Get the minor HTTP version number of the response - * - * Returns: - * Minor version number - */ - uint getMinorHTTPVersion() - { - return sfHttpResponse_GetMinorVersion(m_ptr); - } - - /** - * Get the body of the response. The body can contain : - * - the requested page (for GET requests) - * - a response from the server (for POST requests) - * - nothing (for HEAD requests) - * - an error message (in case of an error) - * - * Returns: - * the response body - */ - string getBody() - { - return fromStringz(sfHttpResponse_GetBody(m_ptr)); - } - - private: - this(SFMLClass ptr) - { - super(ptr); - } - // External ================================================================ - extern (C) - { - typedef void function(SFMLClass) pf_sfHttpResponse_Destroy; - typedef ichar* function(SFMLClass, cchar*) pf_sfHttpResponse_GetField; - typedef HttpStatus function(SFMLClass) pf_sfHttpResponse_GetStatus; - typedef uint function(SFMLClass) pf_sfHttpResponse_GetMajorVersion; - typedef uint function(SFMLClass) pf_sfHttpResponse_GetMinorVersion; - typedef ichar* function(SFMLClass) pf_sfHttpResponse_GetBody; - - static pf_sfHttpResponse_Destroy sfHttpResponse_Destroy; - static pf_sfHttpResponse_GetField sfHttpResponse_GetField; - static pf_sfHttpResponse_GetStatus sfHttpResponse_GetStatus; - static pf_sfHttpResponse_GetMajorVersion sfHttpResponse_GetMajorVersion; - static pf_sfHttpResponse_GetMinorVersion sfHttpResponse_GetMinorVersion; - static pf_sfHttpResponse_GetBody sfHttpResponse_GetBody; - } - - static this() - { - DllLoader dll = DllLoader.load("csfml-network-2"); - - sfHttpResponse_Destroy = cast(pf_sfHttpResponse_Destroy)dll.getSymbol("sfHttpResponse_Destroy"); - sfHttpResponse_GetField = cast(pf_sfHttpResponse_GetField)dll.getSymbol("sfHttpResponse_GetField"); - sfHttpResponse_GetStatus = cast(pf_sfHttpResponse_GetStatus)dll.getSymbol("sfHttpResponse_GetStatus"); - sfHttpResponse_GetMajorVersion = cast(pf_sfHttpResponse_GetMajorVersion)dll.getSymbol("sfHttpResponse_GetMajorVersion"); - sfHttpResponse_GetMinorVersion = cast(pf_sfHttpResponse_GetMinorVersion)dll.getSymbol("sfHttpResponse_GetMinorVersion"); - sfHttpResponse_GetBody = cast(pf_sfHttpResponse_GetBody)dll.getSymbol("sfHttpResponse_GetBody"); - } - } - - /** - * Wrapper for a HTTP response which is basically : - * - a header with a status code and a set of field/value pairs - * - a body (the content of the requested resource) - */ - static class Request : DSFMLObject - { - /** - * Constructor - * - * Params: - * requestMethod = Method to use for the request (Get by default) - * uri = Target URI ("/" by default -- index page) - * requestBody = Content of the request's body (empty by default) - */ - this(HttpMethod requestMethod = HttpMethod.GET, string uri = "/", string requestBody = "") - { - super(sfHttpRequest_Create()); - sfHttpRequest_SetMethod(m_ptr, requestMethod); - sfHttpRequest_SetUri(m_ptr, toStringz(uri)); - sfHttpRequest_SetBody(m_ptr, toStringz(requestBody)); - } - - /** - * Set the value of a field. Field is created if it doesn't exists. - * - * Params: - * field = name of the field to set (case-insensitive) - * value = value of the field - */ - void setField(string field, string value) - { - sfHttpRequest_SetField(m_ptr, toStringz(field), toStringz(value)); - } - - /** - * Set the request method. - * - * Params: - * requestMethod = Method to use for the request. - */ - void setMethod(HttpMethod requestMethod) - { - sfHttpRequest_SetMethod(m_ptr, requestMethod); - } - - /** - * Set the target URI of the request. - * - * Params: - * uri = URI to request, local to the host. - * Returns: - */ - void setUri(string uri) - { - sfHttpRequest_SetUri(m_ptr, toStringz(uri)); - } - - /** - * Set the HTTP version of the request. - * - * Params: - * major = Major version number - * minor = Minor version number - */ - void setHttpVersion(uint major, uint minor) - { - sfHttpRequest_SetHttpVersion(m_ptr, major, minor); - } - - /** - * Set the body of the request. This parameter is optionnal and make sense - * only for POST requests. - * - * Params: - * requestBody = Content of the request body. - */ - void setBody(string requestBody) - { - sfHttpRequest_SetBody(m_ptr, toStringz(requestBody)); - } - - private: - - // External ================================================================ - extern (C) - { - typedef SFMLClass function() pf_sfHttpRequest_Create; - typedef void function(SFMLClass) pf_sfHttpRequest_Destroy; - typedef void function(SFMLClass, cchar*, cchar*) pf_sfHttpRequest_SetField; - typedef void function(SFMLClass, HttpMethod) pf_sfHttpRequest_SetMethod; - typedef void function(SFMLClass, cchar*) pf_sfHttpRequest_SetUri; - typedef void function(SFMLClass, uint, uint) pf_sfHttpRequest_SetHttpVersion; - typedef void function(SFMLClass, cchar*) pf_sfHttpRequest_SetBody; - - static pf_sfHttpRequest_Create sfHttpRequest_Create; - static pf_sfHttpRequest_Destroy sfHttpRequest_Destroy; - static pf_sfHttpRequest_SetField sfHttpRequest_SetField; - static pf_sfHttpRequest_SetMethod sfHttpRequest_SetMethod; - static pf_sfHttpRequest_SetUri sfHttpRequest_SetUri; - static pf_sfHttpRequest_SetHttpVersion sfHttpRequest_SetHttpVersion; - static pf_sfHttpRequest_SetBody sfHttpRequest_SetBody; - } - - static this() - { - DllLoader dll = DllLoader.load("csfml-network-2"); - - sfHttpRequest_Create = cast(pf_sfHttpRequest_Create)dll.getSymbol("sfHttpRequest_Create"); - sfHttpRequest_Destroy = cast(pf_sfHttpRequest_Destroy)dll.getSymbol("sfHttpRequest_Destroy"); - sfHttpRequest_SetField = cast(pf_sfHttpRequest_SetField)dll.getSymbol("sfHttpRequest_SetField"); - sfHttpRequest_SetMethod = cast(pf_sfHttpRequest_SetMethod)dll.getSymbol("sfHttpRequest_SetMethod"); - sfHttpRequest_SetUri = cast(pf_sfHttpRequest_SetUri)dll.getSymbol("sfHttpRequest_SetUri"); - sfHttpRequest_SetHttpVersion = cast(pf_sfHttpRequest_SetHttpVersion)dll.getSymbol("sfHttpRequest_SetHttpVersion"); - sfHttpRequest_SetBody = cast(pf_sfHttpRequest_SetBody)dll.getSymbol("sfHttpRequest_SetBody"); - } - } - - /** - * Constructor - */ - this() - { - super(sfHttp_Create()); - } - - /** - * Constructor - * - * Params: - * host = Web server to connect to - * port = port to use for connection (0 by default -- use the standard port of the protocol) - */ - this(string host, ushort port = 0) - { - super(sfHttp_Create()); - sfHttp_SetHost(m_ptr, toStringz(host), port); - } - - override void dispose() - { - sfHttp_Destroy(m_ptr); - } - - /** - * Set the target host. - * - * Params: - * host = Web server to connect to - * port = port to use for connection (0 by default -- use the standard port of the protocol) - */ - void setHost(string host, ushort port = 0) - { - sfHttp_SetHost(m_ptr, toStringz(host), port); - } - - /** - * Send a HTTP request and return the server's response. - * You must be connected to a host before sending requests. - * Any missing mandatory header field will be added with an appropriate value. - * - * Warning : this function waits for the server's response and may - * not return instantly; use a thread if you don't want to block your - * application. - * - * Params: - * req = Request to send - * - * Returns: - * Server's response - */ - - Response sendRequest(Request req) - { - return new Response( sfHttp_SendRequest(m_ptr, req.nativePointer) ); - } - -private: - -// External ==================================================================== - - extern (C) - { - typedef SFMLClass function() pf_sfHttp_Create; - typedef void function(SFMLClass) pf_sfHttp_Destroy; - typedef void function(SFMLClass, cchar*, ushort) pf_sfHttp_SetHost; - typedef SFMLClass function(SFMLClass, SFMLClass) pf_sfHttp_SendRequest; - - static pf_sfHttp_Create sfHttp_Create; - static pf_sfHttp_Destroy sfHttp_Destroy; - static pf_sfHttp_SetHost sfHttp_SetHost; - static pf_sfHttp_SendRequest sfHttp_SendRequest; - } - - static this() - { - debug - DllLoader dll = DllLoader.load("csfml-network-d-2"); - else - DllLoader dll = DllLoader.load("csfml-network-2"); - - sfHttp_Create = cast(pf_sfHttp_Create)dll.getSymbol("sfHttp_Create"); - sfHttp_Destroy = cast(pf_sfHttp_Destroy)dll.getSymbol("sfHttp_Destroy"); - sfHttp_SetHost = cast(pf_sfHttp_SetHost)dll.getSymbol("sfHttp_SetHost"); - sfHttp_SendRequest = cast(pf_sfHttp_SendRequest)dll.getSymbol("sfHttp_SendRequest"); - } -} diff --git a/bindings/d/import/dsfml/network/ipaddress.d b/bindings/d/import/dsfml/network/ipaddress.d deleted file mode 100644 index fd785c86..00000000 --- a/bindings/d/import/dsfml/network/ipaddress.d +++ /dev/null @@ -1,148 +0,0 @@ -/* -* DSFML - SFML Library wrapper for the D programming language. -* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com) -* Copyright (C) 2010 Andreas Hollandt -* -* This software is provided 'as-is', without any express or -* implied warranty. In no event will the authors be held -* liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute -* it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; -* you must not claim that you wrote the original software. -* If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but -* is not required. -* -* 2. Altered source versions must be plainly marked as such, -* and must not be misrepresented as being the original software. -* -* 3. This notice may not be removed or altered from any -* source distribution. -*/ - -module dsfml.network.ipaddress; - -import dsfml.system.common; -import dsfml.system.stringutil; - -/** - * IPAddress provides easy manipulation of IP v4 addresses - */ -struct IPAddress -{ - byte[16] Address; - - /** - * Construct the address from a string - * - * Params: - * address = IP address ("xxx.xxx.xxx.xxx") or network name - * - */ - static opCall(string address) - { - return sfIpAddress_FromString(toStringz(address)); - } - - - /** - * Construct the address from 4 bytes - * - * Params: - * byte0 = First byte of the address - * byte1 = Second byte of the address - * byte2 = Third byte of the address - * byte3 = Fourth byte of the address - * - */ - static opCall(ubyte byte0, ubyte byte1, ubyte byte2, ubyte byte3) - { - return sfIpAddress_FromBytes(byte0, byte1, byte2, byte3); - } - - /** - * Construct the address from a 32 bits integer - * - * Params: - * address = 4 bytes of the address packed into a 32 bits integer - * - */ - static opCall(uint address) - { - return sfIpAddress_FromInteger(address); - } - - /** - * Get the empty/invalid address - * - * Returns: - * Empty object that represents invalid addresses - */ - static IPAddress None() - { - return sfIpAddress_None(); - } - -@property -{ - /** - * Get the computer's local IP address (from the LAN point of view) - * - * Returns: - * Local IP address - * - */ - static IPAddress localAddress() - { - return sfIpAddress_GetLocalAddress(); - } - - /** - * Get the computer's public IP address (from the web point of view). - * The only way to get a public address is to ask it to a - * distant website ; as a consequence, this function may be - * very slow -- use it as few as possible ! - * - * Returns: - * Public IP address - * - */ - static IPAddress publicAddress() - { - return sfIpAddress_GetPublicAddress(); - } - - /** - * Local host address (to connect to the same computer). - */ - static IPAddress localHost() - { - return sfIpAddress_LocalHost(); - } -} - - const bool opEquals(ref const(IPAddress) other) - { - return Address == other.Address; - } -} - -private: - -static extern(C) -{ - IPAddress function(cchar*) sfIpAddress_FromString; - IPAddress function(ubyte, ubyte, ubyte, ubyte)sfIpAddress_FromBytes; - IPAddress function(uint) sfIpAddress_FromInteger; - IPAddress function() sfIpAddress_None; - IPAddress function() sfIpAddress_GetLocalAddress; - IPAddress function() sfIpAddress_GetPublicAddress; - IPAddress function() sfIpAddress_LocalHost; -} - -mixin(loadFromSharedLib2("csfml-network", "sfIpAddress", - "FromBytes", "FromString", "FromInteger", "GetLocalAddress", "GetPublicAddress", "None", "LocalHost")); \ No newline at end of file diff --git a/bindings/d/import/dsfml/network/packet.d b/bindings/d/import/dsfml/network/packet.d deleted file mode 100644 index 9a09646a..00000000 --- a/bindings/d/import/dsfml/network/packet.d +++ /dev/null @@ -1,417 +0,0 @@ -/* -* DSFML - SFML Library wrapper for the D programming language. -* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com) -* Copyright (C) 2010 Andreas Hollandt -* -* This software is provided 'as-is', without any express or -* implied warranty. In no event will the authors be held -* liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute -* it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; -* you must not claim that you wrote the original software. -* If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but -* is not required. -* -* 2. Altered source versions must be plainly marked as such, -* and must not be misrepresented as being the original software. -* -* 3. This notice may not be removed or altered from any -* source distribution. -*/ - -module dsfml.network.packet; - -import dsfml.system.common; -import dsfml.system.stringutil; - -/** -* Packet wraps data to send / to receive through the network -* -* The order of insertion and extraction must be the same. -* -* You can derive from Packet and override onSend and onReceive to do custom operations before send or after reception. -* -* Litterals integer are promoted to int. -* Litterals floating point are promoted to float. -* -* Extraction or insertion can be specified with explicit template. -* Examples: -* ------------------------------------------------------------ -* Packet p = new Packet(); -* -* int i = 32, j = 42; -* string k = hello; -* -* p.set(i, k, j); //Set the data in the packet -* -* int a, b; -* string c; -* p.get(a, c, b); //Get data from the packet -* -* //... -* -* Packet p = new Packet(); -* p.set!(byte)(5); // Litteral are inserted with byte type -* ------------------------------------------------------------ -* -* See_Also: -* $(LINK2 http://www.digitalmars.com/d/1.0/lex.html, D litterals Specification) for more informations. -*/ -class Packet : DSFMLObject -{ - /** - * Default constructor - * - */ - this() - { - super(sfPacket_Create()); - } - - override void dispose() - { - sfPacket_Destroy(m_ptr); - } - - /** - * Append data to the end of the packet. - * - * Params: - * data = Array of data to append - * - */ - void append(byte[] data) - { - if (data !is null) - sfPacket_Append(m_ptr, data.ptr, data.length); - } - - /** - * Clear the packet data - * - */ - void clear() - { - sfPacket_Clear(m_ptr); - } - - /** - * Get an array to the data contained in the packet - * $(B the returned array may be invalid after you - * append data to the packet) - * - * Returns: - * array of data - * - * Remarks: - * return an array of $(B all) data in the packet. - * - * ---------- - * Packet p = new Packet(); - * - * string str1 = "Hi"; - * string str2 = "Hello"; - * - * p.set(str1, str2); - * - * // Retrieve str1 from packet - * string str3; - * p.get(str3); - * - * // Returns an array containing str1 and str2. - * byte[] ptr = p.getData(); - * ---------- - */ - byte[] getData() - { - if (canRead) - return sfPacket_GetData(m_ptr)[0..getDataSize()]; - else - return null; - } - - - /** - * Get the size of the data contained in the packet - * - * Returns: - * Data size, in bytes - */ - uint getDataSize() - { - return sfPacket_GetDataSize(m_ptr); - } - - /** - * Tell if the reading position has reached the end of the packet - * - * Returns: - * true if all data have been read. - */ - bool endOfPacket() - { - return cast(bool)sfPacket_EndOfPacket(m_ptr); - } - /** - * Tell if the packet is valid for reading - * - * Returns: - * True if data can be extracted from the packet - * - */ - bool canRead() - { - return cast(bool)sfPacket_CanRead(m_ptr); - } - - - /** - * Add new variables to the packet - * Accept (u)byte, (u)short, (u)int, float, double, string and wstring types - */ - Packet set(T...)(T t) - { - foreach (v; t) - internalSet(t); - return this; - } - - /** - * Retrieve data from the packet - * Accept (u)byte, (u)short, (u)int, float, double, string and wstring types - */ - Packet get(T...)(ref T t) - { - foreach (v; t) - internalGet(t); - return this; - } - - /** - * Called before packet is send - * - * Params: - * size = Variable to fill with the size of the data to send - * Returns: - * Array of byte to send - */ - byte[] onSend() - { - return getData(); - } - - /** - * Called after a packet has been received - * - * Params: - * data = Array of byte received - */ - void onReceive(byte[] data) - { - append(data); - } - -private: - void internalGet(ref bool data) - { - data = cast(bool)sfPacket_ReadInt32(m_ptr); - } - void internalGet(ref byte data) - { - data = sfPacket_ReadInt8(m_ptr); - } - void internalGet(ref ubyte data) - { - data = sfPacket_ReadUint8(m_ptr); - } - void internalGet(ref short data) - { - data = sfPacket_ReadInt16(m_ptr); - } - void internalGet(ref ushort data) - { - data = sfPacket_ReadUint16(m_ptr); - } - void internalGet(ref int data) - { - data = sfPacket_ReadInt32(m_ptr); - } - void internalGet(ref uint data) - { - data = sfPacket_ReadUint32(m_ptr); - } - void internalGet(ref float data) - { - data = sfPacket_ReadFloat(m_ptr); - } - void internalGet(ref double data) - { - data = sfPacket_ReadDouble(m_ptr); - } - void internalGet(ref string data) - { - scope char[] temp = new char[sfPacket_GetDataSize(m_ptr)]; - sfPacket_ReadString(m_ptr, temp.ptr); - size_t l = fromStringz(temp.ptr).length; - data = cast(string) temp[0 .. l]; - } - - void internalGet(ref wstring data) - { - scope wchar[] temp = new wchar[sfPacket_GetDataSize(m_ptr)]; - sfPacket_ReadWideString(m_ptr, temp.ptr); - size_t l = fromStringz(temp.ptr).length; - data = cast(wstring) temp[0 .. l]; - } - - void internalSet(bool data) - { - sfPacket_WriteInt32(m_ptr, cast(int)data); - } - void internalSet(byte data) - { - sfPacket_WriteInt8(m_ptr, data); - } - void internalSet(ubyte data) - { - sfPacket_WriteUint8(m_ptr, data); - } - void internalSet(short data) - { - sfPacket_WriteInt16(m_ptr, data); - } - void internalSet(ushort data) - { - sfPacket_WriteUint16(m_ptr, data); - } - void internalSet(int data) - { - sfPacket_WriteInt32(m_ptr, data); - } - void internalSet(uint data) - { - sfPacket_WriteUint32(m_ptr, data); - } - void internalSet(float data) - { - sfPacket_WriteFloat(m_ptr, data); - } - void internalSet(double data) - { - sfPacket_WriteDouble(m_ptr, data); - } - void internalSet(string data) - { - sfPacket_WriteString(m_ptr, toStringz(data)); - } - - void internalSet(wstring data) - { - sfPacket_WriteWideString(m_ptr, toStringz(data)); - } - -// External ==================================================================== - - extern (C) - { - typedef SFMLClass function() pf_sfPacket_Create; - typedef void function(SFMLClass) pf_sfPacket_Destroy; - typedef void function(SFMLClass, const(void)*, size_t) pf_sfPacket_Append; - typedef void function(SFMLClass) pf_sfPacket_Clear; - typedef byte* function(SFMLClass) pf_sfPacket_GetData; - typedef uint function(SFMLClass) pf_sfPacket_GetDataSize; - typedef int function(SFMLClass) pf_sfPacket_EndOfPacket; - typedef int function(SFMLClass) pf_sfPacket_CanRead; - typedef byte function(SFMLClass) pf_sfPacket_ReadInt8; - typedef ubyte function(SFMLClass) pf_sfPacket_ReadUint8; - typedef short function(SFMLClass) pf_sfPacket_ReadInt16; - typedef ushort function(SFMLClass) pf_sfPacket_ReadUint16; - typedef int function(SFMLClass) pf_sfPacket_ReadInt32; - typedef uint function(SFMLClass) pf_sfPacket_ReadUint32; - typedef float function(SFMLClass) pf_sfPacket_ReadFloat; - typedef double function(SFMLClass) pf_sfPacket_ReadDouble; - typedef void function(SFMLClass, char*) pf_sfPacket_ReadString; - typedef void function(SFMLClass, wchar*) pf_sfPacket_ReadWideString; - typedef void function(SFMLClass, byte) pf_sfPacket_WriteInt8; - typedef void function(SFMLClass, ubyte) pf_sfPacket_WriteUint8; - typedef void function(SFMLClass, short) pf_sfPacket_WriteInt16; - typedef void function(SFMLClass, ushort) pf_sfPacket_WriteUint16; - typedef void function(SFMLClass, int) pf_sfPacket_WriteInt32; - typedef void function(SFMLClass, uint) pf_sfPacket_WriteUint32; - typedef void function(SFMLClass, float) pf_sfPacket_WriteFloat; - typedef void function(SFMLClass, double) pf_sfPacket_WriteDouble; - typedef void function(SFMLClass, cchar*) pf_sfPacket_WriteString; - typedef void function(SFMLClass, cwchar*) pf_sfPacket_WriteWideString; - - static pf_sfPacket_Create sfPacket_Create; - static pf_sfPacket_Destroy sfPacket_Destroy; - static pf_sfPacket_Append sfPacket_Append; - static pf_sfPacket_Clear sfPacket_Clear; - static pf_sfPacket_GetData sfPacket_GetData; - static pf_sfPacket_GetDataSize sfPacket_GetDataSize; - static pf_sfPacket_EndOfPacket sfPacket_EndOfPacket; - static pf_sfPacket_CanRead sfPacket_CanRead; - static pf_sfPacket_ReadInt8 sfPacket_ReadInt8; - static pf_sfPacket_ReadUint8 sfPacket_ReadUint8; - static pf_sfPacket_ReadInt16 sfPacket_ReadInt16; - static pf_sfPacket_ReadUint16 sfPacket_ReadUint16; - static pf_sfPacket_ReadInt32 sfPacket_ReadInt32; - static pf_sfPacket_ReadUint32 sfPacket_ReadUint32; - static pf_sfPacket_ReadFloat sfPacket_ReadFloat; - static pf_sfPacket_ReadDouble sfPacket_ReadDouble; - static pf_sfPacket_ReadString sfPacket_ReadString; - static pf_sfPacket_ReadWideString sfPacket_ReadWideString; - static pf_sfPacket_WriteInt8 sfPacket_WriteInt8; - static pf_sfPacket_WriteUint8 sfPacket_WriteUint8; - static pf_sfPacket_WriteInt16 sfPacket_WriteInt16; - static pf_sfPacket_WriteUint16 sfPacket_WriteUint16; - static pf_sfPacket_WriteInt32 sfPacket_WriteInt32; - static pf_sfPacket_WriteUint32 sfPacket_WriteUint32; - static pf_sfPacket_WriteFloat sfPacket_WriteFloat; - static pf_sfPacket_WriteDouble sfPacket_WriteDouble; - static pf_sfPacket_WriteString sfPacket_WriteString; - static pf_sfPacket_WriteWideString sfPacket_WriteWideString; - } - - static this() - { - debug - DllLoader dll = DllLoader.load("csfml-network-d-2"); - else - DllLoader dll = DllLoader.load("csfml-network-2"); - - sfPacket_Append = cast(pf_sfPacket_Append)dll.getSymbol("sfPacket_Append"); - sfPacket_CanRead = cast(pf_sfPacket_CanRead)dll.getSymbol("sfPacket_CanRead"); - sfPacket_Clear = cast(pf_sfPacket_Clear)dll.getSymbol("sfPacket_Clear"); - sfPacket_Create = cast(pf_sfPacket_Create)dll.getSymbol("sfPacket_Create"); - sfPacket_Destroy = cast(pf_sfPacket_Destroy)dll.getSymbol("sfPacket_Destroy"); - sfPacket_EndOfPacket = cast(pf_sfPacket_EndOfPacket)dll.getSymbol("sfPacket_EndOfPacket"); - sfPacket_GetData = cast(pf_sfPacket_GetData)dll.getSymbol("sfPacket_GetData"); - sfPacket_GetDataSize = cast(pf_sfPacket_GetDataSize)dll.getSymbol("sfPacket_GetDataSize"); - sfPacket_ReadDouble = cast(pf_sfPacket_ReadDouble)dll.getSymbol("sfPacket_ReadDouble"); - sfPacket_ReadFloat = cast(pf_sfPacket_ReadFloat)dll.getSymbol("sfPacket_ReadFloat"); - sfPacket_ReadInt16 = cast(pf_sfPacket_ReadInt16)dll.getSymbol("sfPacket_ReadInt16"); - sfPacket_ReadInt32 = cast(pf_sfPacket_ReadInt32)dll.getSymbol("sfPacket_ReadInt32"); - sfPacket_ReadInt8 = cast(pf_sfPacket_ReadInt8)dll.getSymbol("sfPacket_ReadInt8"); - sfPacket_ReadString = cast(pf_sfPacket_ReadString)dll.getSymbol("sfPacket_ReadString"); - sfPacket_ReadWideString = cast(pf_sfPacket_ReadWideString)dll.getSymbol("sfPacket_ReadWideString"); - sfPacket_ReadUint16 = cast(pf_sfPacket_ReadUint16)dll.getSymbol("sfPacket_ReadUint16"); - sfPacket_ReadUint32 = cast(pf_sfPacket_ReadUint32)dll.getSymbol("sfPacket_ReadUint32"); - sfPacket_ReadUint8 = cast(pf_sfPacket_ReadUint8)dll.getSymbol("sfPacket_ReadUint8"); - sfPacket_WriteDouble = cast(pf_sfPacket_WriteDouble)dll.getSymbol("sfPacket_WriteDouble"); - sfPacket_WriteFloat = cast(pf_sfPacket_WriteFloat)dll.getSymbol("sfPacket_WriteFloat"); - sfPacket_WriteInt16 = cast(pf_sfPacket_WriteInt16)dll.getSymbol("sfPacket_WriteInt16"); - sfPacket_WriteInt32 = cast(pf_sfPacket_WriteInt32)dll.getSymbol("sfPacket_WriteInt32"); - sfPacket_WriteInt8 = cast(pf_sfPacket_WriteInt8)dll.getSymbol("sfPacket_WriteInt8"); - sfPacket_WriteString = cast(pf_sfPacket_WriteString)dll.getSymbol("sfPacket_WriteString"); - sfPacket_WriteWideString = cast(pf_sfPacket_WriteWideString)dll.getSymbol("sfPacket_WriteWideString"); - sfPacket_WriteUint16 = cast(pf_sfPacket_WriteUint16)dll.getSymbol("sfPacket_WriteUint16"); - sfPacket_WriteUint32 = cast(pf_sfPacket_WriteUint32)dll.getSymbol("sfPacket_WriteUint32"); - sfPacket_WriteUint8 = cast(pf_sfPacket_WriteUint8)dll.getSymbol("sfPacket_WriteUint8"); - } -} diff --git a/bindings/d/import/dsfml/network/socketselector.d b/bindings/d/import/dsfml/network/socketselector.d deleted file mode 100644 index e85abc77..00000000 --- a/bindings/d/import/dsfml/network/socketselector.d +++ /dev/null @@ -1,153 +0,0 @@ -/* -* DSFML - SFML Library wrapper for the D programming language. -* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com) -* Copyright (C) 2010 Andreas Hollandt -* -* This software is provided 'as-is', without any express or -* implied warranty. In no event will the authors be held -* liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute -* it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; -* you must not claim that you wrote the original software. -* If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but -* is not required. -* -* 2. Altered source versions must be plainly marked as such, -* and must not be misrepresented as being the original software. -* -* 3. This notice may not be removed or altered from any -* source distribution. -*/ - -module dsfml.network.socketselector; - -import dsfml.network.tcpsocket; -import dsfml.network.udpsocket; - -import dsfml.system.common; - -/** - * Multiplexer that allows to read from multiple sockets - */ -class SocketSelector : DSFMLObject -{ - /** - * Default constructor - */ - this() - { - super(sfSocketSelector_Create()); - } - - override void dispose() - { - sfSocketSelector_Destroy(m_ptr); - } - - /** - * Add a socket to watch - * - * Params: - * socket = A tcp or udp socket - */ - void add(T socket) - { - if (!(socket.nativePointer in m_watchedSockets)) - { - sfSocketSelector_Add(m_ptr, socket.nativePointer); - m_watchedSockets[socket.nativePointer] = socket; - m_numSocketsWatched++; - } - } - - /** - * Remove a previously added socket - * - * Params: - * socket = A tcp or udp socket - */ - void remove(T socket) - { - if (socket.nativePointer in m_watchedSockets) - { - sfSocketSelector_Remove(m_ptr, socket.nativePointer); - m_watchedSockets.remove(socket.nativePointer); - m_numSocketsWatched--; - } - } - - /** - * Clear all sockets being watched - */ - void clear() - { - sfSocketSelector_Clear(m_ptr); - foreach(key; m_watchedSockets.keys) - m_watchedSockets.remove(key); - m_numSocketsWatched = 0; - } - - /** - * Wait and collect sockets which are ready for reading. - * This functions will return either when at least one socket - * is ready, or when the given time is out - * - * Params: - * timeout = Maximum time to wait, in seconds (0 to disable timeout) - * - * Returns: - * Number of sockets ready - */ - uint wait(float timeout = 0.f) - { - return sfSocketSelector_Wait(m_ptr, timeout); - } - - /** - * After a call to Wait(), get the Index-th socket which is - * ready for reading. The total number of sockets ready - * is the integer returned by the previous call to Wait() - * - * Params: - * index = Index of the socket to get - * - * Returns: - * The Index-th socket - */ - T GetSocketsReady(uint index) - { - return m_watchedSockets[sfSocketSelector_GetSocketReady(m_ptr, index)]; - } - - -private: -// size_t m_numSocketsWatched; -// T[void*] m_watchedSockets; - -// External ==================================================================== - static extern(C) - { - SFMLClass function() sfSocketSelector_Create; - void function(SFMLClass) sfSocketSelector_Destroy; - void function(SFMLClass, SFMLClass) sfSocketSelector_AddTcpListener; - void function(SFMLClass, SFMLClass) sfSocketSelector_AddTcpSocket; - void function(SFMLClass, SFMLClass) sfSocketSelector_AddUdpSocket; - void function(SFMLClass, SFMLClass) sfSocketSelector_RemoveTcpListener; - void function(SFMLClass, SFMLClass) sfSocketSelector_RemoveTcpSocket; - void function(SFMLClass, SFMLClass) sfSocketSelector_RemoveUdpSocket; - void function(SFMLClass) sfSocketSelector_Clear; - bool function(SFMLClass, float) sfSocketSelector_Wait; - bool function(SFMLClass, SFMLClass) sfSocketSelector_IsTcpListenerReady; - bool function(SFMLClass, SFMLClass) sfSocketSelector_IsTcpSocketReady; - bool function(SFMLClass, SFMLClass) sfSocketSelector_IsUdpSocketReady; - } - - mixin(loadFromSharedLib2("csfml-network", "sfSocketSelector", - "Create", "Destroy", "AddTcpListener", "AddTcpSocket", "AddUdpSocket", "RemoveTcpListener", "RemoveTcpSocket", "RemoveUdpSocket", - "Clear", "Wait", "IsTcpListenerReady", "IsTcpSocketReady", "IsUdpSocketReady")); -} \ No newline at end of file diff --git a/bindings/d/import/dsfml/network/socketstatus.d b/bindings/d/import/dsfml/network/socketstatus.d deleted file mode 100644 index ee7ec515..00000000 --- a/bindings/d/import/dsfml/network/socketstatus.d +++ /dev/null @@ -1,38 +0,0 @@ -/* -* DSFML - SFML Library wrapper for the D programming language. -* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com) -* Copyright (C) 2010 Andreas Hollandt -* -* This software is provided 'as-is', without any express or -* implied warranty. In no event will the authors be held -* liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute -* it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; -* you must not claim that you wrote the original software. -* If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but -* is not required. -* -* 2. Altered source versions must be plainly marked as such, -* and must not be misrepresented as being the original software. -* -* 3. This notice may not be removed or altered from any -* source distribution. -*/ - -module dsfml.network.socketstatus; - -/** -* Enumeration of status returned by socket functions -*/ -enum SocketStatus -{ - DONE, /// - NOTREADY, /// - DISCONNECTED, /// - UNEXPECTEDERROR /// -} diff --git a/bindings/d/import/dsfml/network/tcplistener.d b/bindings/d/import/dsfml/network/tcplistener.d deleted file mode 100644 index a0b682ce..00000000 --- a/bindings/d/import/dsfml/network/tcplistener.d +++ /dev/null @@ -1,49 +0,0 @@ -/* - * DSFML - SFML Library wrapper for the D programming language. - * Copyright (C) 2010 Andreas Hollandt - * - * This software is provided 'as-is', without any express or - * implied warranty. In no event will the authors be held - * liable for any damages arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute - * it freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; - * you must not claim that you wrote the original software. - * If you use this software in a product, an acknowledgment - * in the product documentation would be appreciated but - * is not required. - * - * 2. Altered source versions must be plainly marked as such, - * and must not be misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any - * source distribution. - */ - -module dsfml.network.tcplistener; - -import dsfml.network.socketstatus; -import dsfml.system.common; - -class TcpListener : DSFMLObject -{ -private: -public: - -private: - static extern(C) - { - SFMLClass function() sfTcpListener_Create; - void function(SFMLClass) sfTcpListener_Destroy; - void function(SFMLClass, bool) sfTcpListener_SetBlocking; - bool function(SFMLClass) sfTcpListener_IsBlocking; - SocketStatus function(SFMLClass, ushort) sfTcpListener_Listen; - SocketStatus function(SFMLClass, SFMLClass*) sfTcpListener_Accept; - } - - mixin(loadFromSharedLib2("csfml-network", "sfTcpListener", - "Create", "Destroy", "SetBlocking", "IsBlocking", "Listen", "Accept")); -} \ No newline at end of file diff --git a/bindings/d/import/dsfml/network/tcpsocket.d b/bindings/d/import/dsfml/network/tcpsocket.d deleted file mode 100644 index 71637444..00000000 --- a/bindings/d/import/dsfml/network/tcpsocket.d +++ /dev/null @@ -1,273 +0,0 @@ -/* -* DSFML - SFML Library wrapper for the D programming language. -* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com) -* Copyright (C) 2010 Andreas Hollandt -* -* This software is provided 'as-is', without any express or -* implied warranty. In no event will the authors be held -* liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute -* it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; -* you must not claim that you wrote the original software. -* If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but -* is not required. -* -* 2. Altered source versions must be plainly marked as such, -* and must not be misrepresented as being the original software. -* -* 3. This notice may not be removed or altered from any -* source distribution. -*/ - -module dsfml.network.tcpsocket; - -import dsfml.network.ipaddress; -import dsfml.network.packet; -import dsfml.network.socketstatus; - -import dsfml.system.common; - -/** -* TcpSocket wraps a socket using TCP protocol to send data safely (but a bit slower) -*/ -class TcpSocket : DSFMLObject -{ - /** - * Default constructor - */ - this() - { - super(sfTcpSocket_Create()); - m_intermediatePacket = new Packet(); - } - - override void dispose() - { - sfTcpSocket_Destroy(m_ptr); - } - - /** - * Connect to another computer on a specified port - * - * Params: - * port = Port to use for transfers (warning : ports < 1024 are reserved) - * hostAddress = IP Address of the host to connect to - * timeout = Maximum time to wait in seconds (0 by default : no timeout) - * - * Returns: - * True if operation has been successful - */ - bool connect(ushort port, IPAddress hostAddress, float timeout = 0.f) - { - return cast(bool) !sfTcpSocket_Connect(m_ptr, port, hostAddress, timeout); - } - - /** - * Listen to a specified port for incoming data or connections - * - * Params: - * port = Port to listen to - * - * Returns: - * True if operation has been successful - */ - bool listen(ushort port) - { - return cast(bool)sfTcpSocket_Listen(m_ptr, port); - } - - /** - * Wait for a connection (must be listening to a port). - * This function is blocking. - * - * Params: - * connected = Socket containing the connection with the connected client - * - * Returns: - * Status code - */ - SocketStatus accept(TcpSocket connected) - { - SFMLClass temp = null; - SocketStatus ret = sfTcpSocket_Accept(m_ptr, &temp, null); - connected.m_ptr = temp; - return ret; - } - - /** - * Wait for a connection (must be listening to a port). - * This function is blocking. - * - * Params: - * connected = Socket containing the connection with the connected client - * address = Pointer to an address to fill with client infos - * - * Returns: - * Status code - */ - SocketStatus accept(TcpSocket connected, out IPAddress address) - { - SFMLClass temp = null; - SocketStatus ret = sfTcpSocket_Accept(m_ptr, &temp, &address); - connected.m_ptr = temp; - return ret; - } - - /** - * Send an array of bytes to the host (must be connected first) - * - * Params: - * data = array of bytes to send - * - * Returns: - * Status code - */ - SocketStatus send(byte[] data) - in - { - assert(data && data.length); - } - body - { - return cast(SocketStatus)sfTcpSocket_Send(m_ptr, data.ptr, data.length); - } - - /** - * Receive an array of bytes from the host (must be connected first). - * This function will block until a connection was accepted - * - * Params: - * data = array to fill (make sure it is big enough) - * sizeReceived = Number of bytes received - * - * Returns: - * Status code - * - * Remarks: - * Assert if data is null or length == 0 - * - */ - SocketStatus receive(byte[] data, out size_t sizeReceived) - in - { - assert(data && data.length); - } - body - { - return cast(SocketStatus)sfTcpSocket_Receive(m_ptr, data.ptr, data.length, &sizeReceived); - } - - - /** - * Send a packet of data to the host (must be connected first) - * - * Params: - * packetToSend = Packet to send - * - * Returns: - * Status code - * - */ - SocketStatus send(Packet packetToSend) - { - byte[] dataArray = packetToSend.onSend(); - m_intermediatePacket.append(dataArray); - SocketStatus stat = cast(SocketStatus)sfTcpSocket_SendPacket(m_ptr, m_intermediatePacket.nativePointer); - m_intermediatePacket.clear(); - return stat; - } - - /** - * Receive a packet from the host (must be connected first). - * This function will block if the socket is blocking - * - * Params: - * packetToReceive = Packet to fill with received data - * - * Returns: - * Status code - * - */ - SocketStatus receive(Packet packetToReceive) - { - SocketStatus stat = cast(SocketStatus)sfTcpSocket_ReceivePacket(m_ptr, m_intermediatePacket.nativePointer); - packetToReceive.onReceive(m_intermediatePacket.getData); - m_intermediatePacket.clear(); - return stat; - } - - /** - * Check if the socket is in a valid state ; this function - * can be called any time to check if the socket is OK - * - * Returns: - * True if the socket is valid - * - */ - bool isValid() - { - return cast(bool)sfTcpSocket_IsValid(m_ptr); - } - -package: - - this (SFMLClass ptr) - { - super(ptr); - m_intermediatePacket = new Packet(); - } - - -private: - Packet m_intermediatePacket; - -// External ==================================================================== - extern (C) - { - typedef SFMLClass function() pf_sfTcpSocket_Create; - typedef void function(SFMLClass) pf_sfTcpSocket_Destroy; - typedef int function(SFMLClass, ushort, IPAddress, float) pf_sfTcpSocket_Connect; - typedef int function(SFMLClass, ushort) pf_sfTcpSocket_Listen; - typedef SocketStatus function(SFMLClass, SFMLClass*, IPAddress*) pf_sfTcpSocket_Accept; - typedef SocketStatus function(SFMLClass, const(byte)*, size_t) pf_sfTcpSocket_Send; - typedef SocketStatus function(SFMLClass, byte*, size_t, size_t*) pf_sfTcpSocket_Receive; - typedef SocketStatus function(SFMLClass, SFMLClass) pf_sfTcpSocket_SendPacket; - typedef SocketStatus function(SFMLClass, SFMLClass) pf_sfTcpSocket_ReceivePacket; - typedef int function(SFMLClass) pf_sfTcpSocket_IsValid; - - static pf_sfTcpSocket_Create sfTcpSocket_Create; - static pf_sfTcpSocket_Destroy sfTcpSocket_Destroy; - static pf_sfTcpSocket_Connect sfTcpSocket_Connect; - static pf_sfTcpSocket_Listen sfTcpSocket_Listen; - static pf_sfTcpSocket_Accept sfTcpSocket_Accept; - static pf_sfTcpSocket_Send sfTcpSocket_Send; - static pf_sfTcpSocket_Receive sfTcpSocket_Receive; - static pf_sfTcpSocket_SendPacket sfTcpSocket_SendPacket; - static pf_sfTcpSocket_ReceivePacket sfTcpSocket_ReceivePacket; - static pf_sfTcpSocket_IsValid sfTcpSocket_IsValid; - } - - static this() - { - debug - DllLoader dll = DllLoader.load("csfml-network-d-2"); - else - DllLoader dll = DllLoader.load("csfml-network-2"); - - sfTcpSocket_Accept = cast(pf_sfTcpSocket_Accept)dll.getSymbol("sfTcpSocket_Accept"); - sfTcpSocket_Connect = cast(pf_sfTcpSocket_Connect)dll.getSymbol("sfTcpSocket_Connect"); - sfTcpSocket_Create = cast(pf_sfTcpSocket_Create)dll.getSymbol("sfTcpSocket_Create"); - sfTcpSocket_Destroy = cast(pf_sfTcpSocket_Destroy)dll.getSymbol("sfTcpSocket_Destroy"); - sfTcpSocket_IsValid = cast(pf_sfTcpSocket_IsValid)dll.getSymbol("sfTcpSocket_IsValid"); - sfTcpSocket_Listen = cast(pf_sfTcpSocket_Listen)dll.getSymbol("sfTcpSocket_Listen"); - sfTcpSocket_Receive = cast(pf_sfTcpSocket_Receive)dll.getSymbol("sfTcpSocket_Receive"); - sfTcpSocket_ReceivePacket = cast(pf_sfTcpSocket_ReceivePacket)dll.getSymbol("sfTcpSocket_ReceivePacket"); - sfTcpSocket_Send = cast(pf_sfTcpSocket_Send)dll.getSymbol("sfTcpSocket_Send"); - sfTcpSocket_SendPacket = cast(pf_sfTcpSocket_SendPacket)dll.getSymbol("sfTcpSocket_SendPacket"); - } -} diff --git a/bindings/d/import/dsfml/network/udpsocket.d b/bindings/d/import/dsfml/network/udpsocket.d deleted file mode 100644 index 2778df18..00000000 --- a/bindings/d/import/dsfml/network/udpsocket.d +++ /dev/null @@ -1,241 +0,0 @@ -/* -* DSFML - SFML Library wrapper for the D programming language. -* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com) -* Copyright (C) 2010 Andreas Hollandt -* -* This software is provided 'as-is', without any express or -* implied warranty. In no event will the authors be held -* liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute -* it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; -* you must not claim that you wrote the original software. -* If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but -* is not required. -* -* 2. Altered source versions must be plainly marked as such, -* and must not be misrepresented as being the original software. -* -* 3. This notice may not be removed or altered from any -* source distribution. -*/ - -module dsfml.network.udpsocket; - -import dsfml.network.ipaddress; -import dsfml.network.packet; -import dsfml.network.socketstatus; - -import dsfml.system.common; - -/** - * UdpSocket wraps a socket using UDP protocol to - * send data fastly (but with less safety) - */ -class UdpSocket : DSFMLObject -{ - /** - * Default constructor - */ - this() - { - super(sfUdpSocket_Create()); - m_intermediatePacket = new Packet(); - } - - override void dispose() - { - sfUdpSocket_Destroy(m_ptr); - } - - /** - * Bind the socket to a specific port - * - * Params: - * port = Port to bind the socket to - * - * Returns: - * True if operation has been successful - * - */ - bool bind(ushort port) - { - m_port = port; - return cast(bool)sfUdpSocket_Bind(m_ptr, port); - } - - /** - * Unbind the socket from its previous port, if any - * - * Returns: True if operation has been successful - * - */ - bool unbind() - { - m_port = 0; - return cast(bool)sfUdpSocket_Unbind(m_ptr, m_port); - } - - /** - * Send an array of bytes - * - * Params: - * data = bytes array to send - * address = Address of the computer to send the packet to - * port = Port to send the data to - * - * Returns: - * Status code - * - */ - SocketStatus send(byte[] data, IPAddress address, ushort port) - { - return cast(SocketStatus) sfUdpSocket_Send(m_ptr, data.ptr, data.length, address, port); - } - - /** - * Receive an array of bytes. - * This function is blocking. - * - * Params: - * data = Pointer to a byte array to fill (make sure it is big enough) - * sizeReceived = Number of bytes received - * address = Address of the computer which sent the data - * - * Returns: - * Status code - * - * Remarks: - * Assert if data is null or length == 0 - * - */ - SocketStatus receive(byte[] data, out size_t sizeReceived, out IPAddress address) - { - SocketStatus ret = sfUdpSocket_Receive(m_ptr, data.ptr, data.length, &sizeReceived, &address); - return ret; - } - - /** - * Send a packet of data - * - * Params: - * packetToSend = Packet to send - * address = Address of the computer to send the packet to - * port = Port to send the data to - * - * Returns: - * Status code - * - */ - SocketStatus send(Packet packetToSend, IPAddress address, ushort port) - { - byte[] dataArray = packetToSend.onSend(); - m_intermediatePacket.append(dataArray); - SocketStatus stat = cast(SocketStatus)sfUdpSocket_SendPacket(m_ptr, m_intermediatePacket.nativePointer, address, port); - m_intermediatePacket.clear(); - return stat; - } - - /** - * Receive a packet. - * This function is blocking. - * - * Params: - * packetToReceive = Packet to fill with received data - * address = Address of the computer which sent the packet - * - * Returns: - * Status code - * - */ - SocketStatus receive(Packet packetToReceive, out IPAddress address) - { - SocketStatus ret = sfUdpSocket_ReceivePacket(m_ptr, m_intermediatePacket.nativePointer, &address); - packetToReceive.onReceive(m_intermediatePacket.getData); - m_intermediatePacket.clear(); - return ret; - - } - - /** - * Check if the socket is in a valid state ; this function - * can be called any time to check if the socket is OK - * - * Returns: - * True if the socket is valid - * - */ - bool isValid() - { - return cast(bool)sfUdpSocket_IsValid(m_ptr); - } - - /** - * Get the port the socket is currently bound to - * - * Returns: - * Current port (0 means the socket is not bound) - */ - ushort getPort() - { - return m_port; - } - -package: - this (SFMLClass ptr) - { - super(ptr); - m_intermediatePacket = new Packet(); - } - -private: - Packet m_intermediatePacket; - ushort m_port; - -// External ==================================================================== - - extern (C) - { - typedef SFMLClass function() pf_sfUdpSocket_Create; - typedef void function(SFMLClass) pf_sfUdpSocket_Destroy; - typedef int function(SFMLClass, ushort) pf_sfUdpSocket_Bind; - typedef int function(SFMLClass, ushort) pf_sfUdpSocket_Unbind; - typedef SocketStatus function(SFMLClass, byte*, size_t, IPAddress, ushort) pf_sfUdpSocket_Send; - typedef SocketStatus function(SFMLClass, byte*, size_t, size_t*, IPAddress*) pf_sfUdpSocket_Receive; - typedef SocketStatus function(SFMLClass, SFMLClass, IPAddress, ushort) pf_sfUdpSocket_SendPacket; - typedef SocketStatus function(SFMLClass, SFMLClass, IPAddress*) pf_sfUdpSocket_ReceivePacket; - typedef int function(SFMLClass) pf_sfUdpSocket_IsValid; - - static pf_sfUdpSocket_Create sfUdpSocket_Create; - static pf_sfUdpSocket_Destroy sfUdpSocket_Destroy; - static pf_sfUdpSocket_Bind sfUdpSocket_Bind; - static pf_sfUdpSocket_Unbind sfUdpSocket_Unbind; - static pf_sfUdpSocket_Send sfUdpSocket_Send; - static pf_sfUdpSocket_Receive sfUdpSocket_Receive; - static pf_sfUdpSocket_SendPacket sfUdpSocket_SendPacket; - static pf_sfUdpSocket_ReceivePacket sfUdpSocket_ReceivePacket; - static pf_sfUdpSocket_IsValid sfUdpSocket_IsValid; - } - - static this() - { - debug - DllLoader dll = DllLoader.load("csfml-network-d-2"); - else - DllLoader dll = DllLoader.load("csfml-network-2"); - - sfUdpSocket_Bind = cast(pf_sfUdpSocket_Bind)dll.getSymbol("sfUdpSocket_Bind"); - sfUdpSocket_Create = cast(pf_sfUdpSocket_Create)dll.getSymbol("sfUdpSocket_Create"); - sfUdpSocket_Destroy = cast(pf_sfUdpSocket_Destroy)dll.getSymbol("sfUdpSocket_Destroy"); - sfUdpSocket_IsValid = cast(pf_sfUdpSocket_IsValid)dll.getSymbol("sfUdpSocket_IsValid"); - sfUdpSocket_Receive = cast(pf_sfUdpSocket_Receive)dll.getSymbol("sfUdpSocket_Receive"); - sfUdpSocket_ReceivePacket = cast(pf_sfUdpSocket_ReceivePacket)dll.getSymbol("sfUdpSocket_ReceivePacket"); - sfUdpSocket_Send = cast(pf_sfUdpSocket_Send)dll.getSymbol("sfUdpSocket_Send"); - sfUdpSocket_SendPacket = cast(pf_sfUdpSocket_SendPacket)dll.getSymbol("sfUdpSocket_SendPacket"); - sfUdpSocket_Unbind = cast(pf_sfUdpSocket_Unbind)dll.getSymbol("sfUdpSocket_Unbind"); - } -} diff --git a/bindings/d/import/dsfml/system/all.d b/bindings/d/import/dsfml/system/all.d deleted file mode 100644 index 1de561bf..00000000 --- a/bindings/d/import/dsfml/system/all.d +++ /dev/null @@ -1,47 +0,0 @@ -/* -* DSFML - SFML Library wrapper for the D programming language. -* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com) -* Copyright (C) 2010 Andreas Hollandt -* -* This software is provided 'as-is', without any express or -* implied warranty. In no event will the authors be held -* liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute -* it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; -* you must not claim that you wrote the original software. -* If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but -* is not required. -* -* 2. Altered source versions must be plainly marked as such, -* and must not be misrepresented as being the original software. -* -* 3. This notice may not be removed or altered from any -* source distribution. -*/ - -module dsfml.system.all; - -version (linux) -{ - version (build) - { - pragma(link, "dl"); //Link libdl.so (dlopen, dlsym) - } -} - -version (darwin) -{ - version (build) - { - pragma(link, "dl"); //Link libdl.dylib (dlopen, dlsym) - } -} - -public import - dsfml.system.lock, - dsfml.system.vector; \ No newline at end of file diff --git a/bindings/d/import/dsfml/system/alloc.d b/bindings/d/import/dsfml/system/alloc.d deleted file mode 100644 index b04c9f01..00000000 --- a/bindings/d/import/dsfml/system/alloc.d +++ /dev/null @@ -1,84 +0,0 @@ -/* -* DSFML - SFML Library wrapper for the D programming language. -* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com) -* Copyright (C) 2010 Andreas Hollandt -* -* This software is provided 'as-is', without any express or -* implied warranty. In no event will the authors be held -* liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute -* it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; -* you must not claim that you wrote the original software. -* If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but -* is not required. -* -* 2. Altered source versions must be plainly marked as such, -* and must not be misrepresented as being the original software. -* -* 3. This notice may not be removed or altered from any -* source distribution. -*/ - -module dsfml.system.alloc; - -version (Tango) -{ - public import tango.core.Memory; -} -else -{ - public import core.memory; -} - -/* - struct GC - { - static void* malloc(uint size) - { - return std.c.stdlib.malloc(size); - } - - static void free(void* ptr) - { - std.c.stdlib.free(ptr); - } - - static void addRange(void* ptr, uint size) - { - std.gc.addRange(ptr, ptr + size); - } - - static void removeRange(void* ptr) - { - std.gc.removeRange(ptr); - } - } - -*/ - -/* -* Template for native non-GCed allocation for interaction between C and D threads. -*/ -template Alloc() -{ - new (size_t size) - { - void* p = GC.malloc(size); - if (!p) - assert(0, "Memory allocation failed"); - - GC.addRange(p, size); - return p; - } - - delete(void* p) - { - GC.removeRange(p); - GC.free(p); - } -} \ No newline at end of file diff --git a/bindings/d/import/dsfml/system/common.d b/bindings/d/import/dsfml/system/common.d deleted file mode 100644 index 59f04f20..00000000 --- a/bindings/d/import/dsfml/system/common.d +++ /dev/null @@ -1,141 +0,0 @@ -/* -* DSFML - SFML Library wrapper for the D programming language. -* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com) -* Copyright (C) 2010 Andreas Hollandt -* -* This software is provided 'as-is', without any express or -* implied warranty. In no event will the authors be held -* liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute -* it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; -* you must not claim that you wrote the original software. -* If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but -* is not required. -* -* 2. Altered source versions must be plainly marked as such, -* and must not be misrepresented as being the original software. -* -* 3. This notice may not be removed or altered from any -* source distribution. -*/ - -module dsfml.system.common; - -public import dsfml.system.dllloader; - -// type aliases for D2 -package -{ - alias const(char) cchar; - alias const(wchar) cwchar; - alias const(dchar) cdchar; - alias immutable(char) ichar; - alias immutable(wchar) iwchar; - alias immutable(dchar) idchar; - alias const(char)[] cstring; - -// alias immutable(void) ivoid; - alias const(void) cvoid; - typedef immutable(void)* SFMLClass; -} - -// used to mixin code function -string loadFromSharedLib(string fname) -{ - return fname ~ " = " ~ "cast(typeof(" ~ fname ~ ")) dll.getSymbol(\"" ~ fname ~ "\");"; -} - -//used to mixin code function -string loadFromSharedLib2(S...)(string lib, string className, S fnames) -{ - string res = `static this() -{ - debug - DllLoader dll = DllLoader.load("` ~ lib ~ `-d-2"); - else - DllLoader dll = DllLoader.load("` ~ lib ~ `-2"); - -`; - - foreach(fname; fnames) - { - res ~= "\t" ~ className ~ "_" ~ fname ~ " = " ~ "cast(typeof(" ~ className ~ "_" ~ fname ~ ")) dll.getSymbol(\"" ~ className ~ "_" ~ fname ~ "\");\n"; - } - return res ~ "}\n"; -} - -string loadDerivedFromSharedLib(S...)(string lib, string baseClass, string derivedClass, S fnames) -{ - string res = `static this() -{ - debug - DllLoader dll = DllLoader.load("` ~ lib ~ `-d-2"); - else - DllLoader dll = DllLoader.load("` ~ lib ~ `-2"); - -`; - - foreach(fname; fnames) - { - res ~= "\t" ~ baseClass ~ "_" ~ fname ~ " = " ~ "cast(typeof(" ~ baseClass ~ "_" ~ fname ~ ")) dll.getSymbol(\"" ~ derivedClass ~ "_" ~ fname ~ "\");\n"; - } - return res ~ "}\n"; -} - -/** - * Base class for all DSFML classes. - */ -class DSFMLObject -{ -private: - bool m_preventDelete; - -protected: - SFMLClass m_ptr; - - abstract void dispose(); - -public: - /// get the underlying C pointer - @property final SFMLClass nativePointer() - { - return m_ptr; - } - -public: - - this(SFMLClass ptr, bool preventDelete = false) - { - m_ptr = ptr; - m_preventDelete = preventDelete; - } - - ~this() - { - if (!m_preventDelete) - dispose(); - - m_ptr = m_ptr.init; - } - - - final void setHandled(bool handled) - { - m_preventDelete = handled; - } - - override bool opEquals(Object o) - { - return (m_ptr == (cast(DSFMLObject)o).nativePointer); - } - - protected invariant() - { - assert(m_ptr !is null, "Problem occurs with a null pointer in " ~ this.toString); - } -} \ No newline at end of file diff --git a/bindings/d/import/dsfml/system/dllloader.d b/bindings/d/import/dsfml/system/dllloader.d deleted file mode 100644 index 9ffbcad8..00000000 --- a/bindings/d/import/dsfml/system/dllloader.d +++ /dev/null @@ -1,238 +0,0 @@ -/* -* DSFML - SFML Library wrapper for the D programming language. -* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com) -* Copyright (C) 2010 Andreas Hollandt -* -* This software is provided 'as-is', without any express or -* implied warranty. In no event will the authors be held -* liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute -* it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; -* you must not claim that you wrote the original software. -* If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but -* is not required. -* -* 2. Altered source versions must be plainly marked as such, -* and must not be misrepresented as being the original software. -* -* 3. This notice may not be removed or altered from any -* source distribution. -*/ - -module dsfml.system.dllloader; - -import dsfml.system.stringutil; - -version (Tango) -{ - import tango.io.Console; - import tango.sys.SharedLib; -} -else -{ - import std.stdio; - - version (Windows) - { - import std.c.windows.windows; - import std.windows.syserror; // for error strings - alias HMODULE MODULEHANDLE; - } - else version (linux) - { - import std.c.linux.linux; - alias void* MODULEHANDLE; - - const int RTLD_NOW = 0x00002; - const int RTLD_GLOBAL = 0x00100; - } - else version (darwin) - { - alias void* MODULEHANDLE; - - const int RTLD_NOW = 0x2; - const int RTLD_GLOBAL = 0x8; - - extern (C) - { - void* dlopen(char* file, int mode); - int dlclose(void* handle); - void* dlsym(void* handle, char* name); - char* dlerror(); - } - } -} - -static this() -{ - version (Tango) - { - SharedLib.throwExceptions = false; - } -} - -static ~this() -{ -// DllLoader.closeAll(); -} - -private void report(string msg, string lib, string symb) -{ - string str = "Loading error. Reason : " ~ msg ~ " (library : " ~ lib ~ ", symbol : " ~ symb ~ ")"; - version (Tango) - { - Cerr(str).newline; - } - else - { - stderr.writeln(str); - } -} - - -/** -* Simple Dll loader. -*/ -class DllLoader -{ - static DllLoader load(string library) - { - version (Windows) - { - string libraryName = library ~ ".dll"; - } - else version (linux) - { - string libraryName = "lib" ~ library ~ ".so"; - } - else version (darwin) - { - string libraryName = "lib" ~ library ~ ".dylib"; - } - - if (libraryName in alreadyLoaded) - { - return alreadyLoaded[libraryName]; - } - else - { - DllLoader temp = new DllLoader(libraryName); - alreadyLoaded[libraryName] = temp; - return temp; - } - } - - void* getSymbol(string symbolName) - { - void* symb; - version (Tango) - { - symb = m_lib.getSymbol(toStringz(symbolName)); - } - else - { - version (Windows) - { - symb = GetProcAddress(m_lib, toStringz(symbolName)); - } - else version (linux) - { - symb = dlsym(m_lib, toStringz(symbolName)); - } - else version (darwin) - { - symb = dlsym(m_lib, toStringz(symbolName)); - } - } - - if (symb is null) - debug report( "Symbol cannot be found in specified library", m_libPath, symbolName); - - return symb; - } - - void close() - { - version (Tango) - { - m_lib.unload(); - } - else - { - version (Windows) - { - FreeLibrary(m_lib); - } - else version (linux) - { - dlclose(m_lib); - } - else version (darwin) - { - dlclose(m_lib); - } - alreadyLoaded.remove(this.m_libPath); - } - } - - static void closeAll() - { - foreach(lib; alreadyLoaded.values) - { - lib.close(); - } - } - -private: - this(string libraryPath) - { - m_libPath = libraryPath; - - version (Tango) - { - m_lib = SharedLib.load(libraryPath); - } - else - { - version (Windows) - { - m_lib = LoadLibraryA(toStringz(libraryPath)); - } - else version (linux) - { - m_lib = dlopen(toStringz(libraryPath), RTLD_NOW | RTLD_GLOBAL); - } - else version (darwin) - { - m_lib = dlopen(toStringz(libraryPath), RTLD_NOW | RTLD_GLOBAL); - if (m_lib is null) - m_lib = dlopen(toStringz("@executable_path/" ~ libraryPath), RTLD_NOW | RTLD_GLOBAL); - } - } - if (m_lib is null) - { - debug report("Cannot open library", m_libPath, null); - version (Windows) - { - debug report("Windows error message: " ~ sysErrorString(GetLastError()), m_libPath, null); - } - } - } - - version (Tango) - { - SharedLib m_lib; - } - else - { - MODULEHANDLE m_lib; - } - - static DllLoader[string] alreadyLoaded; - string m_libPath; -} diff --git a/bindings/d/import/dsfml/system/exception.d b/bindings/d/import/dsfml/system/exception.d deleted file mode 100644 index e996360c..00000000 --- a/bindings/d/import/dsfml/system/exception.d +++ /dev/null @@ -1,43 +0,0 @@ -/* -* DSFML - SFML Library wrapper for the D programming language. -* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com) -* Copyright (C) 2010 Andreas Hollandt -* -* This software is provided 'as-is', without any express or -* implied warranty. In no event will the authors be held -* liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute -* it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; -* you must not claim that you wrote the original software. -* If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but -* is not required. -* -* 2. Altered source versions must be plainly marked as such, -* and must not be misrepresented as being the original software. -* -* 3. This notice may not be removed or altered from any -* source distribution. -*/ - -module dsfml.system.exception; - -class LoadingException : Exception -{ - this(string msg) - { - super(msg); - } -} - -class NullParameterException : Exception -{ - this(string msg) - { - super(msg); - } -} diff --git a/bindings/d/import/dsfml/system/linkedlist.d b/bindings/d/import/dsfml/system/linkedlist.d deleted file mode 100644 index 815e3783..00000000 --- a/bindings/d/import/dsfml/system/linkedlist.d +++ /dev/null @@ -1,103 +0,0 @@ -/* -* DSFML - SFML Library wrapper for the D programming language. -* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com) -* Copyright (C) 2010 Andreas Hollandt -* -* This software is provided 'as-is', without any express or -* implied warranty. In no event will the authors be held -* liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute -* it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; -* you must not claim that you wrote the original software. -* If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but -* is not required. -* -* 2. Altered source versions must be plainly marked as such, -* and must not be misrepresented as being the original software. -* -* 3. This notice may not be removed or altered from any -* source distribution. -*/ - -module dsfml.system.linkedlist; - -/* -* Trivial implementation of Queue linked list (for internal use) -*/ -class LinkedList(T) -{ - Node!(T) head; - Node!(T) tail; - private size_t m_count; - - void enqueue(T object) - { - if (empty) - head = tail = new Node!(T)(object); - else - { - tail.Next = new Node!(T)(object); - tail = tail.Next; - } - m_count++; - } - - T dequeue() - { - T o; - if (empty) - o = T.init; - else - { - o = head.Data; - head = head.Next; - m_count--; - } - return o; - } - - bool empty() - { - return (head is null); - } - - size_t getCount() - { - return m_count; - } - - void clear() - { - T data; - while ((data = dequeue()) !is T.init) {} - } - - int opApply(int delegate(ref T) dg) - { - T data; - int result; - while ((data = dequeue) !is T.init) - { - if ((result = dg(data)) != 0) - break; - } - return result; - } -} - -private class Node(T) -{ - Node Next; - T Data; - - this(T data) - { - Data = data; - } -} - diff --git a/bindings/d/import/dsfml/system/lock.d b/bindings/d/import/dsfml/system/lock.d deleted file mode 100644 index 6c1e96f5..00000000 --- a/bindings/d/import/dsfml/system/lock.d +++ /dev/null @@ -1,66 +0,0 @@ -/* -* DSFML - SFML Library wrapper for the D programming language. -* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com) -* Copyright (C) 2010 Andreas Hollandt -* -* This software is provided 'as-is', without any express or -* implied warranty. In no event will the authors be held -* liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute -* it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; -* you must not claim that you wrote the original software. -* If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but -* is not required. -* -* 2. Altered source versions must be plainly marked as such, -* and must not be misrepresented as being the original software. -* -* 3. This notice may not be removed or altered from any -* source distribution. -*/ - -module dsfml.system.lock; - -import core.sync.mutex; - -/** -* Encapsulation of an critical section. Unlocking is guaranteed when the Lock goes out of scope, even on exception. -* -* Remarks: -* Lock is a scope class, you need to mark Lock object as scope : -* -* ----------------- -* Mutex m = new Mutex; -* //.. -* { -* scope Lock l = new Lock(m); -* // Critical section -* } // End of critical (Destructor called and mutex unlocked) -* //.. -* -* ----------------- -*/ -scope class Lock -{ - /** - * Construct the lock and lock the mutex - */ - this(Mutex m) - { - m_mutex = m; - m_mutex.lock(); - } - - ~this() - { - m_mutex.unlock(); - } - -private: - Mutex m_mutex; -} diff --git a/bindings/d/import/dsfml/system/stringutil.d b/bindings/d/import/dsfml/system/stringutil.d deleted file mode 100644 index d3ff28c9..00000000 --- a/bindings/d/import/dsfml/system/stringutil.d +++ /dev/null @@ -1,82 +0,0 @@ -/* -* DSFML - SFML Library wrapper for the D programming language. -* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com) -* Copyright (C) 2010 Andreas Hollandt -* -* This software is provided 'as-is', without any express or -* implied warranty. In no event will the authors be held -* liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute -* it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; -* you must not claim that you wrote the original software. -* If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but -* is not required. -* -* 2. Altered source versions must be plainly marked as such, -* and must not be misrepresented as being the original software. -* -* 3. This notice may not be removed or altered from any -* source distribution. -*/ - -module dsfml.system.stringutil; - -import std.traits; // for Unqual - -/* -version (Tango) -{ - public import tango.stdc.stringz; -} -else -{ - public import std.string; -} -*/ - - - T* toStringz(T)(T[] str) - { - if (str is null) - return null; - else if (str.length && str[$ - 1] is T.init) - return str.ptr; - - auto ret = new Unqual!(T)[str.length + 1]; - - ret[0 .. str.length] = str[0 .. $]; - ret[str.length] = 0; - - return cast(T*) ret.ptr; - } - - - size_t stringLength(T)(T* p) - { - if (p is null || *p == T.init) - return 0; - - size_t length; - - while (*(p + length)) - { - length++; - } - - return length; - } - - T[] fromStringz(T)(T* ptr) - { - auto ret = new Unqual!(T)[stringLength(ptr)]; - ret[0..$] = ptr[0..ret.length]; - - return cast(T[]) ret; - } - - \ No newline at end of file diff --git a/bindings/d/import/dsfml/system/vector.d b/bindings/d/import/dsfml/system/vector.d deleted file mode 100644 index 123a3d8c..00000000 --- a/bindings/d/import/dsfml/system/vector.d +++ /dev/null @@ -1,470 +0,0 @@ -/* -* DSFML - SFML Library wrapper for the D programming language. -* Copyright (C) 2010 Andreas Hollandt -* -* This software is provided 'as-is', without any express or -* implied warranty. In no event will the authors be held -* liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute -* it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; -* you must not claim that you wrote the original software. -* If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but -* is not required. -* -* 2. Altered source versions must be plainly marked as such, -* and must not be misrepresented as being the original software. -* -* 3. This notice may not be removed or altered from any -* source distribution. -*/ -module dsfml.system.vector; - -import std.conv; -import std.math; -import std.traits : isFloatingPoint; - -import std.typetuple; - -/** - * generic fixed-size Vector struct - * - * Params: - * T = element type - * dim = vector dimension - */ -struct Vector(T, uint dim) -{ - static assert (dim >= 2 && dim <= 4); - - // vectors of 3 floats are extended to 4 to make it possible to use SSE optimizations - private const realdim = (is(T == float) && dim == 3 && sseAvailable) ? 4 : dim; - // vectors of (3)4 floats or 2 doubles will use SSE - private const bool useSSE = (is(T == float) && realdim == 4 /* || is(T == double) && dim == 2 */ ) && sseAvailable; - - private alias LengthReturnType!(T) LengthType; // the type returned by length - union - { - /// normal struct element access - struct - { - static if (dim >= 1) T x; - static if (dim >= 2) T y; - static if (dim >= 3) T z; - static if (dim >= 4) T w; - } - - struct - { - static if (dim >= 1) T r; - static if (dim >= 2) T g; - static if (dim >= 3) T b; - static if (dim >= 4) T a; - } - - // only the array has the hidden 4th value in case of vec3f - // this is to be able to foreach over tuple without computing w unnecessarily - T[realdim] cell; /// array access - Repeat!(T, dim) tuple; /// for tuple access - } - - // zero vectors - static if (2 == dim) const static Vector zero = Vector(0, 0); - static if (3 == dim) const static Vector zero = Vector(0, 0, 0); - static if (4 == dim) const static Vector zero = Vector(0, 0, 0, 0); - - static if (2 == dim) const static Vector one = Vector(1, 1); - static if (3 == dim) const static Vector one = Vector(1, 1, 1); - static if (4 == dim) const static Vector one = Vector(1, 1, 1, 1); - - static if (2 == dim) const static Vector unitX = Vector(1, 0); - static if (3 == dim) const static Vector unitX = Vector(1, 0, 0); - static if (4 == dim) const static Vector unitX = Vector(1, 0, 0, 0); - - static if (2 == dim) const static Vector unitY = Vector(0, 1); - static if (3 == dim) const static Vector unitY = Vector(0, 1, 0); - static if (4 == dim) const static Vector unitY = Vector(0, 1, 0, 0); - - static if (3 == dim) const static Vector unitZ = Vector(0, 0, 1); - static if (4 == dim) const static Vector unitZ = Vector(0, 0, 1, 0); - - static if (4 == dim) const static Vector unitW = Vector(0, 0, 0, 1); - - - /// ensure that no component is a NaN - invariant() - { - assert(isValid()); - } - - // checks if the elements aren't NaNs - private bool isValid() const - { - static if (dim >= 1) if (isNaN(x)) return false; - static if (dim >= 2) if (isNaN(y)) return false; - static if (dim >= 3) if (isNaN(z)) return false; - static if (dim >= 4) if (isNaN(w)) return false; - return true; - } - - /************************************************************************************ - * Operator overloading - ***********************************************************************************/ - - /// negate the vector - Vector opUnary(string op : "-")() const - { - static if (dim == 2) return Vector(-x, -y); - else static if (dim == 3) return Vector(-x, -y, -z); - else static if (dim == 4) return Vector(-x, -y, -z, -w); - } - - /// dot product - T opBinary(string op : "*")(typeof(this) v) const - if (is(typeof(T+T)) && is(typeof(T*T))) - { - static if (dim == 2) return x*v.x + y*v.y; - else static if (dim == 3) return x*v.x + y*v.y + z*v.z; - else static if (dim == 4) return x*v.x + y*v.y + z*v.z + w*v.w; - } - - /// element-wise operations, +, -, - Vector opBinary(string op, U:typeof(this))(U v) const - // check if the operation is supported on the type T - if (op != "*" && (op == "+" && is(typeof(T+T)) || op == "-" && is(typeof(T-T)) || op == "*" && is(typeof(T*T)) - || op == "/" && is(typeof(T/T)) || op == "%" && is(typeof(T%T)))) - { - Vector res = void; - foreach (i, x; tuple) - mixin("res.tuple[i] = tuple[i] " ~ op ~ " v.tuple[i];"); - return res; - } - - /// operations with a scalar - Vector opBinary(string op, U)(U s) const - { - Vector res = void; - foreach(i, x; tuple) - mixin("res.tuple[i] = tuple[i] " ~ op ~ " s;"); - return res; - } - - /// element-wise assign operations, +=, -=, ... - Vector opOpAssign(string op, U:Vector)(U v) - { - foreach (i, _; tuple) - mixin("tuple[i] " ~ op ~ "= v.tuple[i];"); - - return this; - } - - /// (*=) overload - Vector opOpAssign(string op, U)(U s) - if (!is(U:typeof(this))) // TODO: there's some dmd bug about this - { - foreach (i, _; tuple) - mixin("tuple[i] " ~ op ~ "= s;"); - - return this; - } - - /// return length*length - @property LengthType sqLength() - { - static if (2 == dim) return (x * x + y * y); - else static if (3 == dim) return (x * x + y * y + z * z); - else static if (4 == dim) return (x * x + y * y + z * z + w * w); - else static assert (false); - } - - /// return the vector length - @property LengthType length() - { - static if (useSSE) - { - static if (is(t == float) && dim == 3) // make sure that w is 0 - assert(w == 0); - - float res; - auto p = cell.ptr; - asm - { -// movups XMM0, &cell; - mov EAX, p; - movups XMM0, [EAX]; - mulps XMM0, XMM0; // v0 = vec(x*x, y*y, z*z, w*w) - movaps XMM1, XMM0; // v1 = v0 - shufps XMM0, XMM1, 0x4e; // v0 = vec(z*z, w*w, x*x, y*y) - addps XMM0, XMM1; // v0 = vec(x*x + z*z, y*y + w*w, z*z + x*x, w*w + y*y) - movaps XMM1, XMM0; // v1 = v0 - shufps XMM1, XMM1, 0x11; // v1 = vec(w*w + y*y, z*z + x*x, w*w + y*y, z*z + x*x) - addps XMM0, XMM1; // v0 = |vec|^2 at all 4 positions - rsqrtss XMM0, XMM0; // v0 = 1/sqrt(v0) - rcpss XMM0, XMM0; // v= = 1/v0 - movss res, XMM0; - } - return res; - } - else - { - // compute squared length - auto ret = sqLength(); - - // compute sqrt - version(useFastSqrt) - { - static if (is(T == float)) - return fastSqrt(ret); - } - return sqrt(ret); - } - } - - void normalize() - { - static if (useSSE) - { - static if (is(t == float) && dim == 3) // make sure that w is 0 - assert (w == 0, "vector component w isn't 0!"); - - auto p = cell.ptr; - asm - { - mov EAX, p; - movups XMM0, [EAX]; - movaps XMM2, XMM0; // save it for later - - mulps XMM0, XMM0; // v0 = vec(x*x, y*y, z*z, w*w) - movaps XMM1, XMM0; // v1 = v0 - shufps XMM0, XMM1, 0x4e; // v0 = vec(z*z, w*w, x*x, y*y) - addps XMM0, XMM1; // v0 = vec(x*x + z*z, y*y + w*w, z*z + x*x, w*w + y*y) - movaps XMM1, XMM0; // v1 = v0 - shufps XMM1, XMM1, 0x11; // v1 = vec(w*w + y*y, z*z + x*x, w*w + y*y, z*z + x*x) - addps XMM0, XMM1; // v0 = |vec|^2 at all 4 positions - rsqrtps XMM0, XMM0; // v0 = 1/sqrt(v0) - mulps XMM2, XMM0; // v2 = vec * v0 - - movups [EAX], XMM0; - } - } - else - { - auto len = length(); - foreach(i, _; tuple) // bug 2411 workaround, foreach ref on tuples doesn't work - tuple[i] /= len; - } - } - - /// return normalized version of this vector - Vector normalized() - { - Vector res = this; - res.normalize(); - return res; - } - - /// - string toString() - { - string res = "["; - - res ~= to!(string)(x); - static if (dim >= 2) res ~= ", " ~ to!(string)(y); - static if (dim >= 3) res ~= ", " ~ to!(string)(z); - static if (dim >= 4) res ~= ", " ~ to!(string)(w); - - return res ~ "]"; - } - - static if (is(T == float)) - { - /// do a quick normalize using fast approximate inverse sqrt - void quickNormalize() - { - T inv = invSqrt(sqLength); - this *= inv; - } - - /// return a normalized version of this vector - Vector quickNormalized() - { - auto res = this; - res.quickNormalize(); - return res; - } - } - - /// return a pointer to the vector data - @property T* ptr() - { - return &x; - } - - /// calculate distance to other vector - LengthType distance(Vector other) - { - assert (isValid); - assert (other.isValid); - other -= this; // doable cause other is a struct not ref - return other.length; - } - - /// - bool opEquals(ref const Vector v) const - { - assert (isValid); - assert (v.isValid); - - static if (dim >= 1) if (x != v.x) return false; - static if (dim >= 2) if (y != v.y) return false; - static if (dim >= 3) if (z != v.z) return false; - static if (dim >= 4) if (w != v.w) return false; - return true; - } - - /// swizzling - @property Vector!(T,n.length) opDispatch(string n)() const - if (allCharsValid(n,"xyzw"[0..dim])) - { - static if (n.length == 2) return - Vector!(T,n.length)(cell[n[0]-'x'], cell[n[1]-'x']); - static if (n.length == 3) return - Vector!(T,n.length)(cell[n[0]-'x'], cell[n[1]-'x'], cell[n[2]-'x']); - static if (n.length == 4) return - Vector!(T,n.length)(cell[n[0]-'x'], cell[n[1]-'x'], cell[n[2]-'x'], cell[n[3]-'x']); - } - - // helper function - static private bool allCharsValid( string s, string valid ) - { - foreach ( e1; s ) - { - bool b = false; - foreach (e2; valid) - b |= e1 == e2; - if (!b) - return false; - } - return true; - } - - /// - bool isUnit() - { - real sql = cast(real)sqLength(); - return abs(sql - 1.0) < 0.001; - } - -} - -/******* useful alias declarations *******/ - -alias Vector!(float, 2) Vector2f; /// -alias Vector!(float, 3) Vector3f; /// -alias Vector!(float, 4) Vector4f; /// - -alias Vector!(double, 2) Vector2d; /// -alias Vector!(double, 3) Vector3d; /// -alias Vector!(double, 4) Vector4d; /// - -alias Vector!(int, 2) Vector2i; /// -alias Vector!(int, 3) Vector3i; /// -alias Vector!(int, 4) Vector4i; /// - -alias Vector!(uint, 2) Vector2ui; /// -alias Vector!(uint, 3) Vector3ui; /// -alias Vector!(uint, 4) Vector4ui; /// - -alias Vector!(ushort, 2) Vector2us; /// -alias Vector!(ushort, 3) Vector3us; /// -alias Vector!(ushort, 4) Vector4us; /// - -alias Vector!(ubyte, 2) Vector2ub; /// -alias Vector!(ubyte, 3) Vector3ub; /// -alias Vector!(ubyte, 4) Vector4ub; /// - - -// TODO: do all kinds of unittesting -import std.stdio; -unittest -{ - writeln("unittests running"); - Vector3f v = {1.5f, 1.f, 0.5f}; - Vector3f w = {-1.f, 2.f, -0.5f}; - - writefln("v: %f w: %f", v.length - sqrt(3.5f), w.length - sqrt(5.25f)); - // strangely calculating w.length is much less accurate - assert(v.length - sqrt(3.5f) < 0.001, sseAvailable ? "SSE length calculation failed" : "normal length calculation failed"); - assert(w.length - sqrt(5.25f) < 0.001, sseAvailable ? "SSE length calculation failed" : "normal length calculation failed"); - - assert(v+w == Vector3f(0.5f, 3.f, 0.f)); - assert(v-w == Vector3f(2.5f, -1.f, 1.f)); - - auto r = v.xy; - writeln(r); -} - -/** - * compute 1/sqrt(x) - * assumes x > 0 - * - * Copyright (C) 2002-2006 Chris Lomont - * explanation on www.lomont.org - */ -float invSqrt(float x) -{ - assert(x > 0); - - float xhalf = 0.5f * x; - int i = *cast(int*)&x; // get bits for floating value - i = 0x5f375a86 - (i >> 1); // gives initial guess y0 with magic number - x = *cast(float*)&i; // convert bits back to float - x = x*(1.5f - xhalf * x * x); // Newton step, repeating increases accuracy - return x; -} - - -/** - * compute sqrt(x) - * assumes x >= 0 - */ -float fastSqrt(float x) -{ - assert(x >= 0); - - int i = *cast(int*) &x; - if (0 == ((i >> 23)&255)) - return 0; // close - return x * invSqrt(x); -} - -// get the correct return type for the length function -private template LengthReturnType(T) -{ - static if (is(T == float) || is(T == double) || is(T == real)) - alias T LengthReturnType; - else - alias float LengthReturnType; -} - -/// repeat a type count times -template Repeat(T, int count) -{ - static if (!count) - alias TypeTuple!() Repeat; - else - alias TypeTuple!(T, Repeat!(T, count-1)) Repeat; -} - -// determine SSE usability -// TODO: make more sophisticated -version(X86) - version(D_InlineAsm_X86) - const bool sseAvailable = is(typeof({void* foo; asm { mov EAX, foo; movups XMM0, [EAX]; } })); -version(X86_64) - version(D_InlineAsm_X86_64) - const bool sseAvailable = false; // TODO: add this \ No newline at end of file diff --git a/bindings/d/import/dsfml/window/all.d b/bindings/d/import/dsfml/window/all.d deleted file mode 100644 index e6d809b6..00000000 --- a/bindings/d/import/dsfml/window/all.d +++ /dev/null @@ -1,34 +0,0 @@ -/* -* DSFML - SFML Library wrapper for the D programming language. -* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com) -* Copyright (C) 2010 Andreas Hollandt -* -* This software is provided 'as-is', without any express or -* implied warranty. In no event will the authors be held -* liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute -* it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; -* you must not claim that you wrote the original software. -* If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but -* is not required. -* -* 2. Altered source versions must be plainly marked as such, -* and must not be misrepresented as being the original software. -* -* 3. This notice may not be removed or altered from any -* source distribution. -*/ - -module dsfml.window.all; - -public import - dsfml.window.event, - dsfml.window.input, - dsfml.window.videomode, - dsfml.window.window, - dsfml.window.windowhandle; diff --git a/bindings/d/import/dsfml/window/context.d b/bindings/d/import/dsfml/window/context.d deleted file mode 100644 index 40c09dde..00000000 --- a/bindings/d/import/dsfml/window/context.d +++ /dev/null @@ -1,68 +0,0 @@ -/* -* DSFML - SFML Library wrapper for the D programming language. -* Copyright (C) 2010 Andreas Hollandt -* -* This software is provided 'as-is', without any express or -* implied warranty. In no event will the authors be held -* liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute -* it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; -* you must not claim that you wrote the original software. -* If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but -* is not required. -* -* 2. Altered source versions must be plainly marked as such, -* and must not be misrepresented as being the original software. -* -* 3. This notice may not be removed or altered from any -* source distribution. -*/ - -module dsfml.window.context; - -import dsfml.system.common; - -/** - * - */ -class Context : DSFMLObject -{ - /** - * - */ - this() - { - super(sfContext_Create()); - } - - override void dispose() - { - sfContext_Destroy(m_ptr); - } - - /** - * - * Params: - * active = - */ - void setActive(bool active) - { - sfContext_SetActive(m_ptr, active); - } - -private: - static extern(C) - { - SFMLClass function() sfContext_Create; - void function(SFMLClass) sfContext_Destroy; - void function(SFMLClass, bool) sfContext_SetActive; - } - - mixin(loadFromSharedLib2("csfml-window", "sfContext", - "Create", "Destroy", "SetActive")); -} \ No newline at end of file diff --git a/bindings/d/import/dsfml/window/event.d b/bindings/d/import/dsfml/window/event.d deleted file mode 100644 index e878ecf0..00000000 --- a/bindings/d/import/dsfml/window/event.d +++ /dev/null @@ -1,326 +0,0 @@ -/* -* DSFML - SFML Library wrapper for the D programming language. -* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com) -* Copyright (C) 2010 Andreas Hollandt -* -* This software is provided 'as-is', without any express or -* implied warranty. In no event will the authors be held -* liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute -* it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; -* you must not claim that you wrote the original software. -* If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but -* is not required. -* -* 2. Altered source versions must be plainly marked as such, -* and must not be misrepresented as being the original software. -* -* 3. This notice may not be removed or altered from any -* source distribution. -*/ - -module dsfml.window.event; - -/** -* Definition of key codes for keyboard events -* -* $(B Possibles values:)$(BR) -* Except letters and numbers, you can use :$(BR) -* * LCONTROL, LSHIFT, LALT, LSYSTEM, RCONTROL, RSHIFT, RALT, RSYSTEM.$(BR) -* * LBRACKET, RBRACKET, SEMICOLON, COMMA, PERIOD, QUOTE, SLASH, BACKSLASH, TILDE, EQUAL, DASH.$(BR) -* * SPACE, RETURN, BACK, TAB, PAGEUP, PAGEDOWN, END, HOME, INSERT, DELETE.$(BR) -* * ADD, SUBTRACT, MULTIPLY, DIVIDE, LEFT, RIGHT, UP, DOWN.$(BR) -* * Numpad0, Numpad1, Numpad2, Numpad3, Numpad4, Numpad5, Numpad6, Numpad7, Numpad8, Numpad9.$(BR) -* * F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15.$(BR) -*/ -enum KeyCode -{ - A = 'a', - B = 'b', - C = 'c', - D = 'd', - E = 'e', - F = 'f', - G = 'g', - H = 'h', - I = 'i', - J = 'j', - K = 'k', - L = 'l', - M = 'm', - N = 'n', - O = 'o', - P = 'p', - Q = 'q', - R = 'r', - S = 's', - T = 't', - U = 'u', - V = 'v', - W = 'w', - X = 'x', - Y = 'y', - Z = 'z', - Num0 = '0', - Num1 = '1', - Num2 = '2', - Num3 = '3', - Num4 = '4', - Num5 = '5', - Num6 = '6', - Num7 = '7', - Num8 = '8', - Num9 = '9', - Escape = 256, - LControl, - LShift, - LAlt, - LSystem, - RControl, - RShist, - RAlt, - RSystem, - Menu, - LBracket, - RBracket, - Semicolon, - Comma, - Period, - Quote, - Slash, - Backslash, - Tilde, - Equal, - Dash, - Space, - Return, - Back, - Tab, - PageUp, - PageDown, - End, - Home, - Insert, - Delete, - Add, - Subtract, - Multiply, - Divide, - Left, - Right, - Up, - Down, - Numpad0, - Numpad1, - Numpad2, - Numpad3, - Numpad4, - Numpad5, - Numpad6, - Numpad7, - Numpad8, - Numpad9, - F1, - F2, - F3, - F4, - F5, - F6, - F7, - F8, - F9, - F10, - F11, - F12, - F13, - F14, - F15, - Pause, -} - - -/** -* Definition of button codes for mouse events -*/ -enum MouseButtons -{ - Left, /// - Right, /// - Middle, /// - XButton1, /// - XButton2 /// -} - - - -/** -* Definition of joystick axis for joystick events -*/ -enum JoyAxis -{ - AxisX, /// - AxisY, /// - AxisZ, /// - AxisR, /// - AxisU, /// - AxisV, /// - AxisPOV /// -} - - -/// EventType -enum EventType -{ - Closed, - Resized, - LostFocus, - GainedFocus, - TextEntered, - KeyPressed, - KeyReleased, - MouseWheelMoved, - MouseButtonPressed, - MouseButtonReleased, - MouseMoved, - MouseEntered, - MouseLeft, - JoyButtonPressed, - JoyButtonReleased, - JoyMoved - -} - -/** -* Event defines a system event and its parameters -*/ -align(1) struct Event -{ - /** - * Enumeration of the different types of events. Accessing a value of another event that the one received (e.g. Event.Size.Width when receiving an KEYPRESSED event) will result in undefined behavior. - * $(UL - * $(LI CLOSED) - * $(LI LOSTFOCUS) - * $(LI GAINEDFOCUS) - * $(LI RESIZED - * $(UL - * $(LI Event.Size.Width : new Width, in pixels.) - * $(LI Event.Size.Height : new height, in pixels.) - * ) - * ) - * $(LI TEXTENTERED - * $(UL - * $(LI Event.Text.Unicode : dchar entered.) - * ) - * ) - * $(LI KEYPRESSED, KEYRELEASED - * $(UL - * $(LI Event.Key.Code : Key code of the key.) - * $(LI Event.Key.Alt : Alt pressed ?) - * $(LI Event.Key.Control : Control pressed ?) - * $(LI Event.Key.Shift : Shift pressed ?) - * ) - * ) - * $(LI MOUSEWHEELMOVED - * $(UL - * $(LI Event.MouseWheel.Delta : Wheel move (positive if forward, negative else.) ) - * ) - * ) - * $(LI MOUSEBUTTONPRESSED, MOUSEBUTTONRELEASED - * $(UL - * $(LI Event.MouseButton.Button : Mouse button pressed.) - * $(LI Event.MouseButton.X : Cursor X position.) - * $(LI Event.MouseButton.Y : Cursor X position.) - * ) - * ) - * $(LI MOUSEMOVED - * $(UL - * $(LI Event.MouseMove.X : Cursor X position. Local coordinates.) - * $(LI Event.MouseMove.Y : Cursor Y position. Local coordinates.) - * ) - * ) - * $(LI MOUSEENTERED) - * $(LI MOUSELEFT) - * $(LI JOYBUTTONPRESSED, JOYBUTTONRELEASED - * $(UL - * $(LI Event.JoyButton.JoystickId : Id of the joystick.) - * $(LI Event.JoyButton.Button : Joystick button pressed.) - * ) - * ) - * $(LI JOYMOVED - * $(UL - * $(LI Event.JoyMove.JoystickId : Id of the joystick.) - * $(LI Event.JoyMove.Axis : Moved axis.) - * $(LI Event.JoyMove.Position : Actual position of the axis [-100, 100], except for POV [0, 360].) - * ) - * ) - * ) - */ - EventType Type; - - union - { - struct SText - { - dchar Unicode; - } - SText Text; - - struct SKey - { - align(4): // cause bool is size 1 - KeyCode Code; - bool Alt; - bool Control; - bool Shift; - } - SKey Key; - - struct SMouseMove - { - int X; - int Y; - } - SMouseMove MouseMove; - - struct SMouseButton - { - MouseButtons Button; - int X; - int Y; - } - SMouseButton MouseButton; - - struct SMouseWheel - { - int Delta; - } - SMouseWheel MouseWheel; - - struct SJoyMove - { - uint JoystickId; - JoyAxis Axis; - float Position; - } - SJoyMove JoyMove; - - struct SJoyButton - { - uint JoystickId; - uint Button; - } - SJoyButton JoyButton; - - struct SSize - { - uint Width; - uint Height; - } - SSize Size; - } -} \ No newline at end of file diff --git a/bindings/d/import/dsfml/window/input.d b/bindings/d/import/dsfml/window/input.d deleted file mode 100644 index 00abf966..00000000 --- a/bindings/d/import/dsfml/window/input.d +++ /dev/null @@ -1,152 +0,0 @@ -/* - * DSFML - SFML Library wrapper for the D programming language. - * Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com) - * Copyright (C) 2010 Andreas Hollandt - * - * This software is provided 'as-is', without any express or - * implied warranty. In no event will the authors be held - * liable for any damages arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute - * it freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; - * you must not claim that you wrote the original software. - * If you use this software in a product, an acknowledgment - * in the product documentation would be appreciated but - * is not required. - * - * 2. Altered source versions must be plainly marked as such, - * and must not be misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any - * source distribution. - */ - -module dsfml.window.input; - -import dsfml.system.common; - -import dsfml.window.event; - -/** - * Input handles real-time input from keyboard and mouse. - * Use it instead of events to handle continuous moves and more - * game-friendly inputs - */ -class Input : DSFMLObject -{ -public: // TODO: try to fix this, doesn't work with package - this(SFMLClass input) - { - super(input, true); - } - - override void dispose() - { - // nothing to do - } - -public: - /** - * Get the state of a key - * - * Params: - * key = Key to check - * - * Returns: - * True if key is down, false if key is up - */ - bool isKeyDown(KeyCode key) - { - return cast(bool)sfInput_IsKeyDown(m_ptr, key); - } - - /** - * Get the state of a mouse button - * - * Params: - * button = Button to check - * - * Returns: - * True if button is down, false if button is up - */ - bool isMouseButtonDown(MouseButtons button) - { - return cast(bool)sfInput_IsMouseButtonDown(m_ptr, button); - } - - /** - * Get the state of a joystick button - * - * Params: - * joyId = Identifier of the joystick to check (0 or 1) - * button = Button to check - * - * Returns: - * True if button is down, false if button is up - */ - bool isJoystickButtonDown(uint joyId, uint button) - { - return cast(bool)sfInput_IsJoystickButtonDown(m_ptr, joyId, button); - } - - /** - * Get a joystick axis position - * - * Params: - * joyId = Identifier of the joystick to check (0 or 1) - * axis = Axis to get - * - * Returns: - * Current axis position, in the range [-100, 100] (except for POV, which is [0, 360]) - */ - float getJoystickAxis(uint joyId, JoyAxis axis) - { - return sfInput_GetJoystickAxis(m_ptr, joyId, axis); - } - -@property -{ - /** - * Get the mouse X position - * - * Returns: - * Current mouse left position, relative to owner window - */ - int mouseX() - { - return sfInput_GetMouseX(m_ptr); - } - - /** - * Get the mouse Y position - * - * Returns: - * Current mouse top position, relative to owner window - * - */ - int mouseY() - { - return sfInput_GetMouseY(m_ptr); - } -} - -private: - -// External ==================================================================== - - static extern (C) - { - int function(SFMLClass, KeyCode) sfInput_IsKeyDown; - int function(SFMLClass, MouseButtons) sfInput_IsMouseButtonDown; - int function(SFMLClass, uint, uint) sfInput_IsJoystickButtonDown; - int function(SFMLClass) sfInput_GetMouseX; - int function(SFMLClass) sfInput_GetMouseY; - float function(SFMLClass, uint, JoyAxis) sfInput_GetJoystickAxis; - } - - mixin(loadFromSharedLib2("csfml-window", "sfInput", - "IsKeyDown", "IsMouseButtonDown", "IsJoystickButtonDown", "GetMouseX", "GetMouseY", "GetJoystickAxis")); -} \ No newline at end of file diff --git a/bindings/d/import/dsfml/window/videomode.d b/bindings/d/import/dsfml/window/videomode.d deleted file mode 100644 index 6d3e391a..00000000 --- a/bindings/d/import/dsfml/window/videomode.d +++ /dev/null @@ -1,105 +0,0 @@ -/* - * DSFML - SFML Library wrapper for the D programming language. - * Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com) - * Copyright (C) 2010 Andreas Hollandt - * - * This software is provided 'as-is', without any express or - * implied warranty. In no event will the authors be held - * liable for any damages arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute - * it freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; - * you must not claim that you wrote the original software. - * If you use this software in a product, an acknowledgment - * in the product documentation would be appreciated but - * is not required. - * - * 2. Altered source versions must be plainly marked as such, - * and must not be misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any - * source distribution. - */ - -module dsfml.window.videomode; - -import dsfml.system.common; - -/** - * VideoMode defines a video mode (width, height, bpp, frequency) - * and provides static functions for getting modes supported - * by the display device - */ -struct VideoMode -{ - uint Width; /// Video mode width, in pixels - uint Height; /// Video mode height, in pixels - uint BitsPerPixel = 32; /// Video mode pixel depth, in bits per pixels - - -@property -{ - /** - * Get the current desktop video mode - * - * Returns: - * Current desktop video mode - */ - static VideoMode getDesktopMode() - { - return sfVideoMode_GetDesktopMode(); - } - - /** - * Get all the supported video modes for fullscreen mode. - * Modes are sorted from best to worst. - * - * Returns: - * video mode array - */ - static VideoMode[] getFullscreenModes() - { - size_t arraySize; - VideoMode* array = sfVideoMode_GetFullscreenModes(&arraySize); // TODO: check pointer? - return array[0 .. arraySize]; - } - - /** - * Tell whether or not the video mode is supported - * - * Returns: - * True if video mode is supported, false otherwise - */ - bool isValid() - { - return cast(bool)sfVideoMode_IsValid(this); - } -} - - /** - * Comparison operator overload -- tell if two video modes are equal - * - * Params: - * Other : Video mode to compare - * - * Returns: - * True if modes are equal - */ - const bool opEquals(ref const(VideoMode) other) - { - return ((other.Width == Width) && (other.Height == Height) && (other.BitsPerPixel == BitsPerPixel)); - } -} - -extern (C) -{ - VideoMode function() sfVideoMode_GetDesktopMode; - VideoMode* function(size_t*) sfVideoMode_GetFullscreenModes; - int function(VideoMode) sfVideoMode_IsValid; -} - -mixin(loadFromSharedLib2("csfml-window", "sfVideoMode", - "GetDesktopMode", "GetFullscreenModes", "IsValid")); \ No newline at end of file diff --git a/bindings/d/import/dsfml/window/window.d b/bindings/d/import/dsfml/window/window.d deleted file mode 100644 index c25fd4d3..00000000 --- a/bindings/d/import/dsfml/window/window.d +++ /dev/null @@ -1,454 +0,0 @@ -/* - * DSFML - SFML Library wrapper for the D programming language. - * Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com) - * Copyright (C) 2010 Andreas Hollandt - * - * This software is provided 'as-is', without any express or - * implied warranty. In no event will the authors be held - * liable for any damages arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute - * it freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; - * you must not claim that you wrote the original software. - * If you use this software in a product, an acknowledgment - * in the product documentation would be appreciated but - * is not required. - * - * 2. Altered source versions must be plainly marked as such, - * and must not be misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any - * source distribution. - */ - -module dsfml.window.window; - -import dsfml.window.event; -import dsfml.window.input; -import dsfml.window.videomode; -import dsfml.window.windowhandle; - -import dsfml.system.common; -import dsfml.system.stringutil; - - -/** - * Window style - */ -enum Style : uint -{ - None = 0, /// No border / title bar (this flag and all others are mutually exclusive) - Titlebar = 1 << 0, /// Title bar + fixed border - Resize = 1 << 1, /// Titlebar + resizable border + maximize button - Close = 1 << 2, /// Titlebar + close button - Fullscreen = 1 << 3, /// Fullscreen mode (this flag and all others are mutually exclusive) - - Default = Titlebar | Resize | Close /// Default window style -} - - -/** - * Structure defining the creation settings of windows - */ -struct ContextSettings -{ - uint DepthBits = 24; /// Bits of the depth buffer - uint StencilBits = 8; /// Bits of the stencil buffer - uint AntialiasingLevel = 0; /// Level of antialiasing - uint MajorVersion = 3; /// Major number of the context version to create - uint MinorVersion = 0; /// Minor number of the context version to create -} - - -/** - * Window is a rendering window ; it can create a new window - * or connect to an existing one - */ -class Window : DSFMLObject -{ -protected: - this(SFMLClass ptr) - { - super(ptr); - } - - Input m_input; - - override void dispose() - { - m_input = null; - sfWindow_Destroy(m_ptr); - } - -public: - /** - * Construct a new window - * - * Params: - * mode = Video mode to use - * title = Title of the window - * windowStyle = Window style (Resize | Close by default) - * settings = Context settings (default is default ContextSettings values) - */ - this(VideoMode mode, string title, Style windowStyle = Style.Default, ContextSettings settings = ContextSettings()) - { - super(sfWindow_Create(mode, toStringz(title), windowStyle, &settings)); - } - - /** - * Construct the window from an existing control - * - * Params: - * handle = Platform-specific handle of the control - * settings = Context settings (default is default ContextSettings values) - */ - this(WindowHandle handle, ContextSettings settings = ContextSettings()) - { - super(sfWindow_CreateFromHandle(handle, &settings)); - } - - /** - * Create (or recreate) the window - * - * Input created with getInput becomes invalid. - * - * Params: - * mode = Video mode to use - * title = Title of the window - * windowStyle = Window style (Resize | Close by default) - * settings = Context settings (default is default ContextSettings values) - */ - void create(VideoMode mode, string title, Style windowStyle = Style.Default, ContextSettings settings = ContextSettings()) - { - if (m_ptr !is null) - dispose(); - - m_ptr = sfWindow_Create(mode, toStringz(title), windowStyle, &settings); - } - - /** - * Create (or recreate) the window from an existing control - * - * Input created with getInput becomes invalid. - * - * Params: - * handle = Platform-specific handle of the control - * settings = Context settings (default is default ContextSettings values) - */ - void create(WindowHandle handle, ContextSettings settings = ContextSettings()) - { - if (m_ptr !is null) - dispose(); - - m_ptr = sfWindow_CreateFromHandle(handle, &settings); - } - - /** - * Close (destroy) the window. - * You can call create to recreate a valid window - */ - void close() - { - sfWindow_Close(m_ptr); - } - - - /** - * Get the event on top of events stack, if any, and pop it - * - * Params: - * eventReceived = Event to fill, if any - * - * Returns: - * True if an event was returned, false if events stack was empty - */ - bool getEvent(out Event eventReceived) - { - return cast(bool) sfWindow_GetEvent(m_ptr, &eventReceived); - } - - /** - * Wait for an event and return it - * - * This function is blocking: if there's no pending event then it will wait until an event is received. - * After this function returns (and no error occured), the \a event object is always valid and filled properly. - * This function is typically used when you have a thread that is dedicated to events handling: you want to make this thread - * sleep as long as no new event is received. - * - * Params: - * e Event to be returned - * - * Returns: - * false if any error occured - */ - bool waitEvent(out Event e) - { - return sfWindow_WaitEvent(m_ptr, &e); - } - - /** - * Show or hide the window - * - * Params: - * state = True to show, false to hide - * - */ - void show(bool state) - { - sfWindow_Show(m_ptr, state); - } - - /** - * Display the window on screen - */ - void display() - { - sfWindow_Display(m_ptr); - } - - /** - * Enable / disable vertical synchronization - * - * Params: - * enabled : True to enable v-sync, false to deactivate - */ - void enableVerticalSync(bool enabled) - { - sfWindow_EnableVerticalSync(m_ptr, enabled); - } - -@property -{ - /** - * Tell whether or not a window is opened - * - * Returns: - * True if window is currently open. - */ - bool isOpened() - { - return cast(bool) sfWindow_IsOpened(m_ptr); - } - /** - * Get the width of the rendering region of the window - * - * Returns: - * Width in pixels - */ - uint width() - { - return sfWindow_GetWidth(m_ptr); - } - - /** - * Get the height of the rendering region of the window - * - * Returns: - * Height in pixels - */ - uint height() - { - return sfWindow_GetHeight(m_ptr); - } - - /** - * Get the creation settings of a window - * - * Returns: - * Settings used to create the window - */ - ContextSettings settings() - { - return sfWindow_GetSettings(m_ptr); - } - - /** - * Show or hide the mouse cursor - * - * Params: - * show : True to show, false to hide - */ - void showMouseCursor(bool show) - { - sfWindow_ShowMouseCursor(m_ptr, show); - } - - /** - * Enable or disable automatic key-repeat for keydown events. - * Automatic key-repeat is enabled by default. - * - * Params: - * enabled = true to enable, false to disable - */ - void enableKeyRepeat(bool enabled) - { - sfWindow_EnableKeyRepeat(m_ptr, enabled); - } - - /** - * Set the window as the current target for rendering - * - * Params: - * active = True to activate, false to deactivate - * Returns: - * True if operation was successful, false otherwise - */ - bool active(bool active) - { - return cast(bool)sfWindow_SetActive(m_ptr, active); - } - - /** - * Get the input manager of the window - * - * Returns: - * An input manager - * See_Also : - * Input - */ - Input input() - { - if (m_input is null) - m_input = new Input(sfWindow_GetInput(m_ptr)); - return m_input; - } - - /** - * Limit the framerate to a maximum fixed frequency - * - * Params: - * limit : Framerate limit, in frames per seconds (use 0 to disable limit) - */ - void framerateLimit(uint limit) - { - sfWindow_SetFramerateLimit(m_ptr, limit); - } - - /** - * Get the time the last frame took - * - * Returns: - * time in seconds - */ - float frameTime() - { - return sfWindow_GetFrameTime(m_ptr); - } - - /** - * Change the joystick threshold, ie. the value below which - * no move event will be generated - * - * Params: - * threshold : New threshold, in range [0, 100] - */ - void joystickThreshold(float threshold) - { - sfWindow_SetJoystickThreshold(m_ptr, threshold); - } - - /** - * Retrieve the Os-specific handle of a window - * - * Params: - * renderWindow = Renderwindow object - */ - WindowHandle windowHandle() - { - return sfWindow_GetSystemHandle(m_ptr); - } -} - - /** - * Change the position of the mouse cursor - * - * Params: - * left = Left coordinate of the cursor, relative to the window - * top = Top coordinate of the cursor, relative to the window - */ - void setCursorPosition(uint left, uint top) - { - sfWindow_SetCursorPosition(m_ptr, left, top); - } - - /** - * Change the position of the window on screen. - * Only works for top-level windows - * - * Params: - * left = Left position - * top = Top position - */ - void setPosition(int left, int top) - { - sfWindow_SetPosition(m_ptr, left, top); - } - - /** - * change the size of the rendering region of the window - * - * Params: - * width : new width - * height : new height - */ - void setSize(uint width, uint height) - { - sfWindow_SetSize(m_ptr, width, height); - } - - /** - * Change the window's icon - * - * Params: - * width = Icon's width, in pixels - * height = Icon's height, in pixels - * data = array of pixels in memory, format must be RGBA 32 bits - * - */ - void setIcon(size_t width, size_t height, ubyte[] data) - { - sfWindow_SetIcon(m_ptr, width, height, data.ptr); - } - -private: - -// External ==================================================================== - static extern(C) - { - SFMLClass function(VideoMode, cchar*, Style, ContextSettings*)sfWindow_Create; - SFMLClass function(WindowHandle, ContextSettings*) sfWindow_CreateFromHandle; - void function(SFMLClass) sfWindow_Destroy; - void function(SFMLClass) sfWindow_Close; - int function(SFMLClass) sfWindow_IsOpened; - uint function(SFMLClass) sfWindow_GetWidth; - uint function(SFMLClass) sfWindow_GetHeight; - ContextSettings function(SFMLClass Window) sfWindow_GetSettings; - int function(SFMLClass, Event*) sfWindow_GetEvent; - void function(SFMLClass, int) sfWindow_EnableVerticalSync; - void function(SFMLClass, int) sfWindow_ShowMouseCursor; - void function(SFMLClass, uint, uint) sfWindow_SetCursorPosition; - void function(SFMLClass, int, int) sfWindow_SetPosition; - void function(SFMLClass, uint, uint) sfWindow_SetSize; - void function(SFMLClass, int) sfWindow_Show; - void function(SFMLClass, int) sfWindow_EnableKeyRepeat; - void function(SFMLClass, size_t, size_t, ubyte*) sfWindow_SetIcon; - int function(SFMLClass, int) sfWindow_SetActive; - void function(SFMLClass) sfWindow_Display; - SFMLClass function(SFMLClass) sfWindow_GetInput; - void function(SFMLClass, uint) sfWindow_SetFramerateLimit; - float function(SFMLClass) sfWindow_GetFrameTime; - void function(SFMLClass, float) sfWindow_SetJoystickThreshold; - - // DSFML2 - bool function(SFMLClass, void*) sfWindow_WaitEvent; - WindowHandle function(SFMLClass) sfWindow_GetSystemHandle; - } - - mixin(loadFromSharedLib2("csfml-window", "sfWindow", - "Create", "CreateFromHandle", "Destroy", "Close", "IsOpened", "GetWidth", "GetHeight", "GetSettings", "GetEvent", "EnableVerticalSync", - "ShowMouseCursor", "SetCursorPosition", "SetPosition", "SetSize", "Show", "EnableKeyRepeat", "SetIcon", "SetActive", "Display", - "GetInput", "SetFramerateLimit", "GetFrameTime", "SetJoystickThreshold", "WaitEvent", "GetSystemHandle")); -} \ No newline at end of file diff --git a/bindings/d/import/dsfml/window/windowhandle.d b/bindings/d/import/dsfml/window/windowhandle.d deleted file mode 100644 index 19d30fd8..00000000 --- a/bindings/d/import/dsfml/window/windowhandle.d +++ /dev/null @@ -1,47 +0,0 @@ -/* -* DSFML - SFML Library wrapper for the D programming language. -* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com) -* Copyright (C) 2010 Andreas Hollandt -* -* This software is provided 'as-is', without any express or -* implied warranty. In no event will the authors be held -* liable for any damages arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute -* it freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; -* you must not claim that you wrote the original software. -* If you use this software in a product, an acknowledgment -* in the product documentation would be appreciated but -* is not required. -* -* 2. Altered source versions must be plainly marked as such, -* and must not be misrepresented as being the original software. -* -* 3. This notice may not be removed or altered from any -* source distribution. -*/ - -module dsfml.window.windowhandle; - -/** -* Define a low-level window handle type, specific to -* each platform -*/ -version(Windows) -{ - // Windows defines a void* handle (HWND) - typedef void* WindowHandle; -} -else version(linux) -{ - // Unix - X11 defines an unsigned integer handle (Window) - typedef ulong WindowHandle; -} -else version(darwin) -{ - // Mac OS X defines a void* handle (NSWindow) - typedef void* WindowHandle; -} \ No newline at end of file diff --git a/bindings/d/import/dsss.conf b/bindings/d/import/dsss.conf deleted file mode 100644 index e9ea3a76..00000000 --- a/bindings/d/import/dsss.conf +++ /dev/null @@ -1,46 +0,0 @@ -name=dsfml - -[dsfml/audio] -type = library -target = dsfml-audio -version (Windows){ - postbuild += copy "dsfml-audio.lib" "../lib/dsfml-audio.lib" -} else version (linux){ - postbuild += cp -f "libdsfml-audio.a" "../lib/libdsfml-audio.a" -} - -[dsfml/network] -type = library -target = dsfml-network -version (Windows){ - postbuild += copy "dsfml-network.lib" "../lib/dsfml-network.lib" -} else version (linux){ - postbuild += cp -f "libdsfml-network.a" "../lib/libdsfml-network.a" -} - -[dsfml/graphics] -type = library -target = dsfml-graphics -version (Windows){ - postbuild += copy "dsfml-graphics.lib" "../lib/dsfml-graphics.lib" -} else version (linux){ - postbuild += cp -f "libdsfml-graphics.a" "../lib/libdsfml-graphics.a" -} - -[dsfml/system] -type = library -target = dsfml-system -version (Windows){ - postbuild += copy "dsfml-system.lib" "../lib/dsfml-system.lib" -} else version (linux){ - postbuild += cp -f "libdsfml-system.a" "../lib/libdsfml-system.a" -} - -[dsfml/window] -type = library -target = dsfml-window -version (Windows){ - postbuild += copy "dsfml-window.lib" "../lib/dsfml-window.lib" -} else version (linux){ - postbuild += cp -f "libdsfml-window.a" "../lib/libdsfml-window.a" -} diff --git a/bindings/d/samples/dsfml/bin/Data/background.jpg b/bindings/d/samples/dsfml/bin/Data/background.jpg deleted file mode 100644 index c778e86b..00000000 Binary files a/bindings/d/samples/dsfml/bin/Data/background.jpg and /dev/null differ diff --git a/bindings/d/samples/dsfml/bin/Data/ball.tga b/bindings/d/samples/dsfml/bin/Data/ball.tga deleted file mode 100644 index e5103c84..00000000 Binary files a/bindings/d/samples/dsfml/bin/Data/ball.tga and /dev/null differ diff --git a/bindings/d/samples/dsfml/bin/Data/ball.wav b/bindings/d/samples/dsfml/bin/Data/ball.wav deleted file mode 100644 index 8b3cfbad..00000000 Binary files a/bindings/d/samples/dsfml/bin/Data/ball.wav and /dev/null differ diff --git a/bindings/d/samples/dsfml/bin/Data/bluerallyecarleft.bmp b/bindings/d/samples/dsfml/bin/Data/bluerallyecarleft.bmp deleted file mode 100644 index afd8c94a..00000000 Binary files a/bindings/d/samples/dsfml/bin/Data/bluerallyecarleft.bmp and /dev/null differ diff --git a/bindings/d/samples/dsfml/bin/Data/bluerallyecarright.bmp b/bindings/d/samples/dsfml/bin/Data/bluerallyecarright.bmp deleted file mode 100644 index 07d839b9..00000000 Binary files a/bindings/d/samples/dsfml/bin/Data/bluerallyecarright.bmp and /dev/null differ diff --git a/bindings/d/samples/dsfml/bin/Data/blur.sfx b/bindings/d/samples/dsfml/bin/Data/blur.sfx deleted file mode 100644 index 04bfec53..00000000 --- a/bindings/d/samples/dsfml/bin/Data/blur.sfx +++ /dev/null @@ -1,16 +0,0 @@ -texture framebuffer -float offset - -effect -{ - vec2 offx = vec2(offset, 0.0); - vec2 offy = vec2(0.0, offset); - - vec4 c0 = framebuffer(_in); - vec4 c1 = framebuffer(_in - offy); - vec4 c2 = framebuffer(_in + offy); - vec4 c3 = framebuffer(_in - offx); - vec4 c4 = framebuffer(_in + offx); - - _out = c0 * 0.2 + c1 * 0.2 + c2 * 0.2 + c3 * 0.2 + c4 * 0.2; -} diff --git a/bindings/d/samples/dsfml/bin/Data/car_idle.wav b/bindings/d/samples/dsfml/bin/Data/car_idle.wav deleted file mode 100644 index 51a55f89..00000000 Binary files a/bindings/d/samples/dsfml/bin/Data/car_idle.wav and /dev/null differ diff --git a/bindings/d/samples/dsfml/bin/Data/cheeseburger.ttf b/bindings/d/samples/dsfml/bin/Data/cheeseburger.ttf deleted file mode 100644 index 47704266..00000000 Binary files a/bindings/d/samples/dsfml/bin/Data/cheeseburger.ttf and /dev/null differ diff --git a/bindings/d/samples/dsfml/bin/Data/colorize.sfx b/bindings/d/samples/dsfml/bin/Data/colorize.sfx deleted file mode 100644 index bcb48ebc..00000000 --- a/bindings/d/samples/dsfml/bin/Data/colorize.sfx +++ /dev/null @@ -1,10 +0,0 @@ -texture framebuffer -vec3 color - -effect -{ - vec4 pixel = framebuffer(_in); - float gray = pixel.r * 0.39 + pixel.g * 0.50 + pixel.b * 0.11; - - _out = vec4(gray * color, 1.0) * 0.6 + pixel * 0.4; -} diff --git a/bindings/d/samples/dsfml/bin/Data/crosshair.bmp b/bindings/d/samples/dsfml/bin/Data/crosshair.bmp deleted file mode 100644 index b1532f1c..00000000 Binary files a/bindings/d/samples/dsfml/bin/Data/crosshair.bmp and /dev/null differ diff --git a/bindings/d/samples/dsfml/bin/Data/crosshair.tga b/bindings/d/samples/dsfml/bin/Data/crosshair.tga deleted file mode 100644 index 8b79c295..00000000 Binary files a/bindings/d/samples/dsfml/bin/Data/crosshair.tga and /dev/null differ diff --git a/bindings/d/samples/dsfml/bin/Data/fisheye.sfx b/bindings/d/samples/dsfml/bin/Data/fisheye.sfx deleted file mode 100644 index cbc31ee7..00000000 --- a/bindings/d/samples/dsfml/bin/Data/fisheye.sfx +++ /dev/null @@ -1,12 +0,0 @@ -texture framebuffer -vec2 mouse - -effect -{ - float len = distance(_in, mouse) * 7.0; - - if (len < 1.0) - _out = framebuffer(_in + (_in - mouse) * len); - else - _out = framebuffer(_in); -} diff --git a/bindings/d/samples/dsfml/bin/Data/nothing.sfx b/bindings/d/samples/dsfml/bin/Data/nothing.sfx deleted file mode 100644 index 133b4e31..00000000 --- a/bindings/d/samples/dsfml/bin/Data/nothing.sfx +++ /dev/null @@ -1,6 +0,0 @@ -texture framebuffer - -effect -{ - _out = framebuffer(_in); -} diff --git a/bindings/d/samples/dsfml/bin/Data/opengl/background.jpg b/bindings/d/samples/dsfml/bin/Data/opengl/background.jpg deleted file mode 100644 index 20724fa9..00000000 Binary files a/bindings/d/samples/dsfml/bin/Data/opengl/background.jpg and /dev/null differ diff --git a/bindings/d/samples/dsfml/bin/Data/opengl/texture.jpg b/bindings/d/samples/dsfml/bin/Data/opengl/texture.jpg deleted file mode 100644 index 6cf7528e..00000000 Binary files a/bindings/d/samples/dsfml/bin/Data/opengl/texture.jpg and /dev/null differ diff --git a/bindings/d/samples/dsfml/bin/Data/paddle.tga b/bindings/d/samples/dsfml/bin/Data/paddle.tga deleted file mode 100644 index 34bd6b84..00000000 Binary files a/bindings/d/samples/dsfml/bin/Data/paddle.tga and /dev/null differ diff --git a/bindings/d/samples/dsfml/bin/Data/wave.jpg b/bindings/d/samples/dsfml/bin/Data/wave.jpg deleted file mode 100644 index cd125b8c..00000000 Binary files a/bindings/d/samples/dsfml/bin/Data/wave.jpg and /dev/null differ diff --git a/bindings/d/samples/dsfml/bin/Data/wave.sfx b/bindings/d/samples/dsfml/bin/Data/wave.sfx deleted file mode 100644 index 49b46071..00000000 --- a/bindings/d/samples/dsfml/bin/Data/wave.sfx +++ /dev/null @@ -1,12 +0,0 @@ -texture framebuffer -texture wave -vec2 offset - -effect -{ - vec2 texoffset = wave(_in * offset).xy; - texoffset -= vec2(0.5, 0.5); - texoffset *= 0.05; - - _out = framebuffer(_in + texoffset); -} diff --git a/bindings/d/samples/dsfml/bin/libsndfile-1.dll b/bindings/d/samples/dsfml/bin/libsndfile-1.dll deleted file mode 100644 index f112de2b..00000000 Binary files a/bindings/d/samples/dsfml/bin/libsndfile-1.dll and /dev/null differ diff --git a/bindings/d/samples/dsfml/bin/openal32.dll b/bindings/d/samples/dsfml/bin/openal32.dll deleted file mode 100644 index e6498443..00000000 Binary files a/bindings/d/samples/dsfml/bin/openal32.dll and /dev/null differ diff --git a/bindings/d/samples/dsfml/dfl/DFLSample.d b/bindings/d/samples/dsfml/dfl/DFLSample.d deleted file mode 100644 index b228248e..00000000 --- a/bindings/d/samples/dsfml/dfl/DFLSample.d +++ /dev/null @@ -1,230 +0,0 @@ -module dflsample; - -import dsfml.system.all; -import dsfml.window.all; - -// DFL and Derelict must be present. -import dfl.all; - -import Derelict.opengl.gl; -import Derelict.opengl.glu; - - -// An enum for each controls methods -enum ControlMethod -{ - MOUSE, - KEYBOARD -} - -void main() -{ - DerelictGL.load(); - DerelictGLU.load(); - //Start the message loop - Application.run(new MyForm()); -} - -//A simple form with a groupbox to choose input method and the openGL control -class MyForm : Form -{ - GLControl m_gl; - GroupBox m_gbx; - RadioButton m_rb1; - RadioButton m_rb2; - - this() - { - m_gbx = new GroupBox(); - m_gbx.dock = DockStyle.TOP; - m_gbx.height = 40; - m_gbx.text = "Choose your input"; - this.controls.add(m_gbx); - - m_rb1 = new RadioButton(); - m_rb1.text = "Mouse"; - m_rb1.location = Point(10, 15); - m_rb1.checked = true; - m_rb1.click ~= &radioButtonClick; - m_gbx.controls.add(m_rb1); - - m_rb2 = new RadioButton(); - m_rb2.text = "Keyboard"; - m_rb2.location = Point(m_rb1.width + 10, 15); - m_rb2.click ~= &radioButtonClick; - m_gbx.controls.add(m_rb2); - - m_gl = new GLControl(); - m_gl.dock = DockStyle.FILL; - m_gl.controlMethod = ControlMethod.MOUSE; - this.controls.add(m_gl); - - this.text = "DFL Opengl Integration Sample"; - } - - private void radioButtonClick(Control c, EventArgs ea) - { - m_gl.controlMethod(c.text == "Mouse" ? ControlMethod.MOUSE : ControlMethod.KEYBOARD); - m_gl.focus(); - } - -} - -//Our OpenGL control -class GLControl : Control -{ - Window m_win; - Input i; - Timer m_timer; - GLfloat rotx = 0.f, roty = 0.f; - ControlMethod m_method = ControlMethod.MOUSE; - - this () - { - super(); - this.setStyle(ControlStyles.SELECTABLE | ControlStyles.ALL_PAINTING_IN_WM_PAINT | ControlStyles.WANT_ALL_KEYS, true); - - //We set a timer to ensure periodic refresh of the window - m_timer = new Timer(); - m_timer.interval(10); - m_timer.tick ~= &this.onTick; - - } - - public void controlMethod(ControlMethod m) - { - m_method = m; - } - - //Override of the onHandleCreated method of Control - //integration of DSFML window in a control need a valid handle - protected void onHandleCreated(EventArgs ea) - { - super.onHandleCreated(ea); - - //Construction of the window - m_win = new Window(cast(WindowHandle)this.handle); - - //Get the input for further use - i = m_win.getInput(); - - //Now that the Window is instanciated, we can start the timer. - m_timer.start(); - - //Some opengl initializations functions - glClearDepth(1.f); - glClearColor(0.f, 0.f, 0.f, 0.f); - glEnable(GL_DEPTH_TEST); - glDepthMask(GL_TRUE); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - gluPerspective(90.f, 1.f, 1.f, 500.f); - } - - //We handle Mouse leaving and entering the control to hide or show the cursor - protected void onMouseEnter(MouseEventArgs mea) - { - super.onMouseEnter(mea); - Cursor.current.hide(); - } - - protected void onMouseLeave(MouseEventArgs mea) - { - super.onMouseLeave(mea); - Cursor.current.show(); - } - - //If the window is resize, we need to modify openGL view - protected void onResize(EventArgs ea) - { - super.onResize(ea); - glViewport(0, 0, this.width, this.height); - } - - protected void onTick(Timer t, EventArgs ea) - { - draw(); - } - - protected void onPaint(PaintEventArgs pea) - { - super.onPaint(pea); - draw(); - } - - private void handleKeys() - { - if (i.isKeyDown(KeyCode.UP)) - rotx += 1.f; - if (i.isKeyDown(KeyCode.DOWN)) - rotx += -1.f; - if (i.isKeyDown(KeyCode.LEFT)) - roty += -1.f; - if (i.isKeyDown(KeyCode.RIGHT)) - roty += 1.f; - - } - private void handleMousePos() - { - rotx = i.getMouseY() - (this.height / 2.0); - roty = i.getMouseX() - (this.width / 2.0); - } - - private void draw() - { - if (m_method == ControlMethod.KEYBOARD) - handleKeys(); - else - handleMousePos(); - - m_win.setActive(true); - - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glTranslatef(0.f, 0.f, -200.f); - glRotatef(rotx, 1.f, 0.f, 0.f); - glRotatef(roty, 0.f, 1.f, 0.f); - - glBegin(GL_QUADS); - glColor3f(1.f, 0.f, 0.f); - glVertex3f(-50.f, -50.f, -50.f); - glVertex3f(-50.f, 50.f, -50.f); - glVertex3f( 50.f, 50.f, -50.f); - glVertex3f( 50.f, -50.f, -50.f); - - glColor3f(0.f, 1.f, 0.f); - glVertex3f(-50.f, -50.f, 50.f); - glVertex3f(-50.f, 50.f, 50.f); - glVertex3f( 50.f, 50.f, 50.f); - glVertex3f( 50.f, -50.f, 50.f); - - glColor3f(0.f, 0.f, 1.f); - glVertex3f(-50.f, -50.f, -50.f); - glVertex3f(-50.f, 50.f, -50.f); - glVertex3f(-50.f, 50.f, 50.f); - glVertex3f(-50.f, -50.f, 50.f); - - glColor3f(1.f, 1.f, 0.f); - glVertex3f(50.f, -50.f, -50.f); - glVertex3f(50.f, 50.f, -50.f); - glVertex3f(50.f, 50.f, 50.f); - glVertex3f(50.f, -50.f, 50.f); - - glColor3f(1.f, 0.f, 1.f); - glVertex3f(-50.f, -50.f, 50.f); - glVertex3f(-50.f, -50.f, -50.f); - glVertex3f( 50.f, -50.f, -50.f); - glVertex3f( 50.f, -50.f, 50.f); - - glColor3f(0.f, 1.f, 1.f); - glVertex3f(-50.f, 50.f, 50.f); - glVertex3f(-50.f, 50.f, -50.f); - glVertex3f( 50.f, 50.f, -50.f); - glVertex3f( 50.f, 50.f, 50.f); - glEnd(); - - m_win.display(); - } -} diff --git a/bindings/d/samples/dsfml/dsss.conf b/bindings/d/samples/dsfml/dsss.conf deleted file mode 100644 index 17fe1efc..00000000 --- a/bindings/d/samples/dsfml/dsss.conf +++ /dev/null @@ -1,33 +0,0 @@ -[*] -buildflags += -I../../import -Ivoip - -[pong/pong.d] -target = bin/pong - -[postFX/postFX.d] -target = bin/postFX - -[socket/socketclient.d] -target = bin/client - -[socket/socketserver.d] -target = bin/server - -[sound3d/sound3d.d] -target = bin/sound3d - -[soundstream/soundstream.d] -target = bin/soundstream - -[view/view.d] -target = bin/view - -[voip/entry.d] -target = bin/voip - -version (Windows){ - version (DFL){ - [dfl/dflsample.d] - target = bin/dflSample - } -} diff --git a/bindings/d/samples/dsfml/opengl/opengl.d b/bindings/d/samples/dsfml/opengl/opengl.d deleted file mode 100644 index 6fd3f83a..00000000 --- a/bindings/d/samples/dsfml/opengl/opengl.d +++ /dev/null @@ -1,155 +0,0 @@ -module opengl; - -import dsfml.system.all; -import dsfml.audio.all; -import dsfml.window.all; -import dsfml.graphics.all; - -import std.perf; - -import derelict.opengl.gl; -import derelict.opengl.glu; - -void main() -{ - // Create the main window - auto window = new RenderWindow(VideoMode(800, 600), "DSFML OpenGL", Style.Default, ContextSettings(24,8,0,3,1)); - - DerelictGL.load(); - DerelictGLU.load(); - - // Create a sprite for the background - auto backgroundImage = new Image("Data/opengl/background.jpg"); - auto background = new Sprite(backgroundImage); - - // Load an OpenGL texture. - // We could directly use an Image as an OpenGL texture (with its Bind() member function), - // but here we want more control on it (generate mipmaps, ...) so we create a new one from the image pixels - GLuint texture = 0; - { - auto image = new Image("Data/opengl/texture.jpg"); - - glGenTextures(1, &texture); - glBindTexture(GL_TEXTURE_2D, texture); - gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, image.width, image.height, GL_RGBA, GL_UNSIGNED_BYTE, image.getPixelsArray().ptr); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); - } - - // Enable Z-buffer read and write - glEnable(GL_DEPTH_TEST); - glDepthMask(GL_TRUE); - glClearDepth(1.f); - - // Setup a perspective projection - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - gluPerspective(90.f, 1.f, 1.f, 500.f); - - // Bind our texture - glEnable(GL_TEXTURE_2D); - glBindTexture(GL_TEXTURE_2D, texture); - glColor4f(1.f, 1.f, 1.f, 1.f); - - // Create a clock for measuring the time elapsed - auto clock = new PerformanceCounter(); - clock.start(); - - // Start game loop - while (window.isOpened()) - { - // Process events - Event event; - while (window.getEvent(event)) - { - // Close window : exit - if (event.Type == EventType.Closed) - window.close(); - - // Escape key : exit - if ((event.Type == EventType.KeyPressed) && (event.Key.Code == KeyCode.Escape)) - window.close(); - - // Adjust the viewport when the window is resized - if (event.Type == EventType.Resized) - glViewport(0, 0, event.Size.Width, event.Size.Height); - } - - // Draw the background - window.saveGLStates(); - window.draw(background); - window.restoreGLStates(); - - // Activate the window before using OpenGL commands. - // This is useless here because we have only one window which is - // always the active one, but don't forget it if you use multiple windows - window.active = true; - - // Clear the depth buffer - glClear(GL_DEPTH_BUFFER_BIT); - - // We get the position of the mouse cursor, so that we can move the box accordingly - float x = window.input.mouseX * 200.f / window.width - 100.f; - float y = -window.input.mouseY * 200.f / window.height + 100.f; - - // Apply some transformations - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glTranslatef(x, y, -100.f); - - clock.stop(); - glRotatef(clock.microseconds() * 0.000001 * 50, 1.f, 0.f, 0.f); - glRotatef(clock.microseconds() * 0.000001 * 30, 0.f, 1.f, 0.f); - glRotatef(clock.microseconds() * 0.000001 * 90, 0.f, 0.f, 1.f); - - // Draw a cube - float size = 20.f; - glBegin(GL_QUADS); - - glTexCoord2f(0, 0); glVertex3f(-size, -size, -size); - glTexCoord2f(0, 1); glVertex3f(-size, size, -size); - glTexCoord2f(1, 1); glVertex3f( size, size, -size); - glTexCoord2f(1, 0); glVertex3f( size, -size, -size); - - glTexCoord2f(0, 0); glVertex3f(-size, -size, size); - glTexCoord2f(0, 1); glVertex3f(-size, size, size); - glTexCoord2f(1, 1); glVertex3f( size, size, size); - glTexCoord2f(1, 0); glVertex3f( size, -size, size); - - glTexCoord2f(0, 0); glVertex3f(-size, -size, -size); - glTexCoord2f(0, 1); glVertex3f(-size, size, -size); - glTexCoord2f(1, 1); glVertex3f(-size, size, size); - glTexCoord2f(1, 0); glVertex3f(-size, -size, size); - - glTexCoord2f(0, 0); glVertex3f(size, -size, -size); - glTexCoord2f(0, 1); glVertex3f(size, size, -size); - glTexCoord2f(1, 1); glVertex3f(size, size, size); - glTexCoord2f(1, 0); glVertex3f(size, -size, size); - - glTexCoord2f(0, 1); glVertex3f(-size, -size, size); - glTexCoord2f(0, 0); glVertex3f(-size, -size, -size); - glTexCoord2f(1, 0); glVertex3f( size, -size, -size); - glTexCoord2f(1, 1); glVertex3f( size, -size, size); - - glTexCoord2f(0, 1); glVertex3f(-size, size, size); - glTexCoord2f(0, 0); glVertex3f(-size, size, -size); - glTexCoord2f(1, 0); glVertex3f( size, size, -size); - glTexCoord2f(1, 1); glVertex3f( size, size, size); - - glEnd(); - - // Draw some text on top of our OpenGL object - window.saveGLStates(); - Text text = new Text("DSFML / OpenGL demo"c); - text.position = Vector2f(250.f, 450.f); - text.color = Color(255, 255, 255, 170); - window.draw(text); - window.restoreGLStates(); - - // Finally, display the rendered frame on screen - window.display(); - } - - // Don't forget to destroy our texture - glDeleteTextures(1, &texture); -} \ No newline at end of file diff --git a/bindings/d/samples/dsfml/pong/pong.d b/bindings/d/samples/dsfml/pong/pong.d deleted file mode 100644 index 2c90f0bd..00000000 --- a/bindings/d/samples/dsfml/pong/pong.d +++ /dev/null @@ -1,202 +0,0 @@ -module pong; - -import dsfml.system.all; -import dsfml.audio.all; -import dsfml.window.all; -import dsfml.graphics.all; - -version (Tango) -{ - import tango.io.Stdout; - import tango.math.Math; -} -else -{ - import std.math; - import std.perf; - import std.random; -} - -void main() -{ - // Defines PI - const float PI = 3.14159f; - - // Create the window of the application - RenderWindow app = new RenderWindow(VideoMode(800, 600, 32), "SFML Pong"); - - app.useVerticalSync(false); - - Input i = app.input; - - // Load the sounds used in the game - Sound BallSound = new Sound(new SoundBuffer("Data/ball.wav")); - - // Load the images used in the game - Image PaddleImage = new Image("Data/paddle.tga"); - Image BallImage = new Image("Data/ball.tga"); - - - // Initialize the end text - Text End = new Text(""c); - Font font = new Font("Data/cheeseburger.ttf"); - End.font = font; - End.characterSize = 60; - End.move(150.f, 200.f); - End.color = Color(50, 50, 250); - - Text fps = new Text(""c, font, 30); - fps.move(50.f, 50.f); - fps.color = Color.BLACK; - - // Create the sprites of the background, the paddles and the ball - Sprite LeftPaddle = new Sprite(PaddleImage); - Sprite RightPaddle = new Sprite(PaddleImage); - Sprite Ball = new Sprite(BallImage); - - LeftPaddle.move(10, (app.view.getHeight() - LeftPaddle.size.y) / 2); - RightPaddle.move(app.view.getWidth() - RightPaddle.size.x - 10, (app.view.getHeight() - RightPaddle.size.y) / 2); - Ball.move((app.view.getWidth() - Ball.size.x) / 2, (app.view.getHeight() - Ball.size.y) / 2); - - // Define the paddles properties - auto AITimer = new PerformanceCounter(); - const long AITime = 100; // 100 ms - float LeftPaddleSpeed = 400.f; - float RightPaddleSpeed = 400.f; - - // Define the ball properties - float BallSpeed = 400.f; - float BallAngle = 0.f; - do - { - // Make sure the ball initial angle is not too much vertical - BallAngle = uniform(0.f, 2 * PI); - } while (abs(cos(BallAngle)) < 0.7f); - - bool IsPlaying = true; - - Event evt; - uint iFps = 0; - auto fpsClock = new PerformanceCounter(); - - while (app.isOpened()) - { - app.clear(Color(255, 255, 255, 255)); - - // Handle events - while (app.getEvent(evt)) - { - // Window closed or escape key pressed : exit - if ((evt.Type == EventType.Closed) || - ((evt.Type == EventType.KeyPressed) && (evt.Key.Code == KeyCode.Escape))) - { - app.close(); - break; - } - } - - if (IsPlaying) - { - // Move the player's paddle - if (i.isKeyDown(KeyCode.Up) && (LeftPaddle.position.y > 5.f)) - LeftPaddle.move(0.f, -LeftPaddleSpeed * app.frameTime); - if (i.isKeyDown(KeyCode.Down) && (LeftPaddle.position.y < app.view.getHeight() - LeftPaddle.size.y - 5.f)) - LeftPaddle.move(0.f, LeftPaddleSpeed * app.frameTime); - - // Move the computer's paddle - if (((RightPaddleSpeed < 0.f) && (RightPaddle.position.y > 5.f)) || - ((RightPaddleSpeed > 0.f) && (RightPaddle.position.y < app.view.getHeight() - RightPaddle.size.y - 5.f))) - { - RightPaddle.move(0.f, RightPaddleSpeed * app.frameTime); - } - - // Update the computer's paddle direction according to the ball position - AITimer.stop(); - if (AITimer.milliseconds > AITime) - { - AITimer.start(); - if ((RightPaddleSpeed < 0) && (Ball.position.y + Ball.size.y > RightPaddle.position.y + RightPaddle.size.y)) - RightPaddleSpeed = -RightPaddleSpeed; - if ((RightPaddleSpeed > 0) && (Ball.position.y < RightPaddle.position.y)) - RightPaddleSpeed = -RightPaddleSpeed; - } - - - - // Move the ball - float Factor = BallSpeed * app.frameTime; - Ball.move(cos(BallAngle) * Factor, sin(BallAngle) * Factor); - - // Check collisions between the ball and the screen - if (Ball.position.x < 0.f) - { - IsPlaying = false; - End.text("You lost !\n(press escape to exit)"c); - } - - if (Ball.position.x + Ball.size.x > app.view.getWidth()) - { - IsPlaying = false; - End.text("You won !\n(press escape to exit)"c); - } - - if (Ball.position.y < 0.f) - { - BallSound.play(); - BallAngle = -BallAngle; - Ball.y = 0.1f; - } - - if (Ball.position.y + Ball.size.y > app.view.getHeight()) - { - BallSound.play(); - BallAngle = -BallAngle; - Ball.y = app.view.getHeight() - Ball.size.y - 0.1f; - } - // Check the collisions between the ball and the paddles - // Left Paddle - if (Ball.position.x < LeftPaddle.position.x + LeftPaddle.size.x && - Ball.position.x > LeftPaddle.position.x + (LeftPaddle.size.x / 2.0f) && - Ball.position.y + Ball.size.y >= LeftPaddle.position.y && - Ball.position.y <= LeftPaddle.position.y + LeftPaddle.size.y) - { - BallSound.play(); - BallAngle = PI - BallAngle; - Ball.x = LeftPaddle.position.x + LeftPaddle.size.x + 0.1f; - } - - // Right Paddle - if (Ball.position.x + Ball.size.x > RightPaddle.position.x && - Ball.position.x + Ball.size.x < RightPaddle.position.x + (RightPaddle.size.x / 2.0f) && - Ball.position.y + Ball.size.y >= RightPaddle.position.y && - Ball.position.y <= RightPaddle.position.y + RightPaddle.size.y) - { - BallSound.play(); - BallAngle = PI - BallAngle; - Ball.x = RightPaddle.position.x - Ball.size.x - 0.1f; - } - } - - // Draw the background, paddles and ball sprites - - app.draw(LeftPaddle); - app.draw(RightPaddle); - app.draw(Ball); - - fpsClock.stop(); - if(fpsClock.seconds >= 1) - { - fps.text = std.string.format("%d fps", iFps); - iFps = 0; - fpsClock.start(); - } - ++iFps; - app.draw(fps); - // If the game is over, display the end message - if (!IsPlaying) - app.draw(End); - - // Display things on screen - app.display(); - } -} \ No newline at end of file diff --git a/bindings/d/samples/dsfml/postFX/postFX.d b/bindings/d/samples/dsfml/postFX/postFX.d deleted file mode 100644 index 0d6d864c..00000000 --- a/bindings/d/samples/dsfml/postFX/postFX.d +++ /dev/null @@ -1,117 +0,0 @@ -module postfx; - -import dsfml.graphics.all; -import dsfml.system.all; -import dsfml.window.all; - -const char[][5] EFFECTS = ["nothing", "blur", "colorize", "fisheye", "wave"]; - -void main() -{ - int actualIndex; - - // Check that the system can use post effects - if (PostFX.canUsePostFX() == false) - assert(0, "Your system doesn't support Post Effects."); - - // Create the main window - RenderWindow app = new RenderWindow(VideoMode(800, 600), "SFML PostFX"); - app.setFramerateLimit(100); - - // Load a cute background image to display :) - Sprite background = new Sprite(new Image("Data/background.jpg")); - - // Load the image needed for the wave effect - Image WaveImage = new Image("Data/wave.jpg"); - - // Load all effects - PostFX[char[]] Effects; - foreach(char[] c; EFFECTS) - { - Effects[c] = new PostFX("Data/" ~ c ~ ".sfx"); - } - PostFX currentEffect = Effects[EFFECTS[actualIndex]]; - - // Do specific initializations - Effects["nothing"].setTexture("framebuffer", null); - Effects["blur"].setTexture("framebuffer", null); - Effects["blur"].setParameter("offset", 0.f); - Effects["colorize"].setTexture("framebuffer", null); - Effects["colorize"].setParameter("color", 1.f, 1.f, 1.f); - Effects["fisheye"].setTexture("framebuffer", null); - Effects["wave"].setTexture("framebuffer", null); - Effects["wave"].setTexture("wave", WaveImage); - - Font f = new Font("Data/cheeseburger.ttf"); - - // Define a string for displaying current effect description - Text curFXStr = new Text("Current effect is " ~ EFFECTS[actualIndex]); - curFXStr.setFont(f); - curFXStr.setPosition(20.f, 0.f); - - // Define a string for displaying help - Text infoStr = new Text("Move your mouse to change the effect parameters\nPress numpad + and - to change effect\nWarning : some effects may not work\ndepending on your graphics card"c); - infoStr.setFont(f); - infoStr.setPosition(20.f, 460.f); - infoStr.setColor(Color(200, 100, 150)); - - // Start the game loop - while (app.isOpened()) - { - // Process events - Event evt; - while (app.getEvent(evt)) - { - // Close window : exit - if (evt.Type == Event.EventType.CLOSED || - evt.Type == Event.EventType.KEYPRESSED && evt.Key.Code == KeyCode.ESCAPE) - app.close(); - - if (evt.Type == Event.EventType.KEYPRESSED) - { - // Add key : next effect - if (evt.Key.Code == KeyCode.ADD) - { - if (actualIndex == 4) - actualIndex = 0; - else - actualIndex++; - currentEffect = Effects[EFFECTS[actualIndex]]; - curFXStr.setText("Current effect is " ~ EFFECTS[actualIndex]); - } - - // Subtract key : previous effect - if (evt.Key.Code == KeyCode.SUBTRACT) - { - if (actualIndex == 0) - actualIndex = 4; - else - actualIndex--; - currentEffect = Effects[EFFECTS[actualIndex]]; - curFXStr.setText("Current effect is " ~ EFFECTS[actualIndex]); - } - } - } - - // Get the mouse position in the range [0, 1] - float X = app.getInput().getMouseX() / cast(float) app.getWidth(); - float Y = app.getInput().getMouseY() / cast(float) app.getHeight(); - - // Update the current effect - if (EFFECTS[actualIndex] == "blur") currentEffect.setParameter("offset", X * Y * 0.1f); - else if (EFFECTS[actualIndex] == "colorize") currentEffect.setParameter("color", 0.3f, X, Y); - else if (EFFECTS[actualIndex] == "fisheye") currentEffect.setParameter("mouse", X, 1.f - Y); - else if (EFFECTS[actualIndex] == "wave") currentEffect.setParameter("offset", X, Y); - - // Draw background and apply the post-fx - app.draw(background); - app.draw(currentEffect); - - // Draw interface strings - app.draw(curFXStr); - app.draw(infoStr); - - // Finally, display the rendered frame on screen - app.display(); - } -} diff --git a/bindings/d/samples/dsfml/socket/socketclient.d b/bindings/d/samples/dsfml/socket/socketclient.d deleted file mode 100644 index 2a25114e..00000000 --- a/bindings/d/samples/dsfml/socket/socketclient.d +++ /dev/null @@ -1,66 +0,0 @@ -module socketclient; - -import dsfml.system.all; -import dsfml.network.all; - -version (Tango) -{ - import tango.io.Console; - import tango.io.Stdout; -} -else -{ - import std.stdio; -} - - -void main() -{ - //The TCP socket - SocketTCP client = new SocketTCP(); - //Try to connect to server (on localhost for this sample) - client.connect(9000, IPAddress.LOCALHOST); - - display("Connected to server."w); - - //Prepare a packet with a string - Packet p = new Packet(); - p.set("Hello from the client !"w); - if (client.send(p) != SocketStatus.DONE) // Assert on error - assert(0); - - //Clear the packet - p.clear(); - - //Wait for the response of the server and display it - if (client.receive(p) != SocketStatus.DONE) - assert(0); - wchar[] c; - p.get(c); - display("Packet received : "w ~ c); - read(); -} - -void display(wchar[] c) -{ - version (Tango) - { - Stdout(c).newline; - } - else - { - writefln("%s", c); - } -} - -void read() -{ - version (Tango) - { - Cin.get(); - } - else - { - readln(); - } -} diff --git a/bindings/d/samples/dsfml/socket/socketserver.d b/bindings/d/samples/dsfml/socket/socketserver.d deleted file mode 100644 index afab76fb..00000000 --- a/bindings/d/samples/dsfml/socket/socketserver.d +++ /dev/null @@ -1,83 +0,0 @@ -module socketserver; - -import dsfml.system.all; -import dsfml.network.all; - -version (Tango) -{ - import tango.io.Console; - import tango.io.Stdout; -} -else -{ - import std.stdio; -} - -void main() -{ - //We create a TCP socket for listening incomming client - SocketTCP listener = new SocketTCP(); - - //Set a random port for the listener - if (!listener.listen(9000)) - assert(0); - - //Creation of TCP socket - SocketTCP client = new SocketTCP(); - IPAddress ipClient; - - display("Waiting for client."w); - - if (listener.accept(client, ipClient) == SocketStatus.DONE) //This call blocks until client connection - { - display("New client connected."w); - //The packet for retrieving the client message - Packet p = new Packet(); - display("Waiting for data"w); - if (client.receive(p) != SocketStatus.DONE) //Assert on reception error - assert(0); - - - //Display the string send by the client - wchar[] c; - p.get(c); - display("Packet received : "w ~ c); - - //Clear the packet (We could use a new one) - p.clear(); - - //and send response to client - client.send(p.set("Hello from the server !"w)); - } - read(); -} - -/** -* Multilib string display -*/ -void display(wchar[] c) -{ - version (Tango) - { - Stdout(c).newline; - } - else - { - writefln("%s", c); - } -} - -/** -* Dummy function to prevent console closing on windows -*/ -void read() -{ - version (Tango) - { - Cin.get(); - } - else - { - readln(); - } -} diff --git a/bindings/d/samples/dsfml/sound3d/sound3d.d b/bindings/d/samples/dsfml/sound3d/sound3d.d deleted file mode 100644 index 17e0d08d..00000000 --- a/bindings/d/samples/dsfml/sound3d/sound3d.d +++ /dev/null @@ -1,185 +0,0 @@ -module sound3d; - -import dsfml.system.all; -import dsfml.window.all; -import dsfml.graphics.all; -import dsfml.audio.all; - -void main() -{ - //We create our window with a limit of 100 and a white backcolor. - RenderWindow app = new RenderWindow (VideoMode(800, 600, 32), "Sound Spatialization Sample"); - app.useVerticalSync(true); - - Font f = new Font("Data/cheeseburger.ttf"); - - //Some instructions - Text s = new Text("Click anywhere on screen to change listener position.\nPress + or - to modify the speed of the car."c, f); - - s.characterSize = 34; - s.setPosition(20, 30); - s.color = Color.BLACK; - - //We prepare our images and the sound - string[2] images = ["Data/bluerallyecarleft.bmp", "Data/bluerallyecarright.bmp"]; - Car c = new Car(images, "Data/car_idle.wav"); - - int carSpeed = 100; - - //Set default position for the car and the listener - c.position = Vector2f(0, 300); - SoundListener.position = Vector2f(400, 300); - - c.startPlaying(); - - //Start the main loop - while (app.isOpened()) - { - app.clear(Color.WHITE); - Event evt; - //The event loop - while (app.getEvent(evt)) - { - // if the window is closed, we can leave the game loop - if (evt.Type == EventType.Closed) - app.close(); - // we handle the click event to change listener position - else if (evt.Type == EventType.MouseButtonPressed && evt.MouseButton.Button == MouseButtons.Left) - { - Input i = app.input; - SoundListener.position = Vector2f(i.mouseX, i.mouseY); - } - // and eventual keys press - else if (evt.Type == EventType.KeyPressed) - { - //Change the car speed - if (evt.Key.Code == KeyCode.Add) - { - carSpeed += 25; - } - else if (evt.Key.Code == KeyCode.Substract) - { - carSpeed -= 25; - } - } - } - - //We move constantly our car. - c.move(Vector2f(app.frameTime * carSpeed, 0)); - - //Draw all the sprite and string on render window - app.draw(s); - app.draw(c.sprite); - app.draw(SoundListener.sprite); - - //And finally display the window - app.display(); - } - - -} - -// Encapsulate the listener position and the visor sprite. -// There is only one listener so all the methods are statics. -class SoundListener -{ - static Sprite s_crosshair; - static Vector2f s_p; - - static this() - { - Image crosshairImg = new Image("Data/crosshair.tga"); - crosshairImg.createMaskFromColor(Color.WHITE); - - s_crosshair = new Sprite(crosshairImg); - s_crosshair.setOrigin(s_crosshair.size.x / 2, s_crosshair.size.y / 2); - - //Listener.setTarget(1.f, 0.f, 0.f); - } - - // Adjust position of the listener - @property static void position(Vector2f p) - { - Listener.setPosition(p.x, p.y, 5.f); - s_crosshair.setPosition(p.x, p.y); - } - - @property static Sprite sprite() - { - return s_crosshair; - } -} - - -//! Class encapsulating all data for our car -class Car -{ - Vector2f m_actual; - Sprite m_sprite; - Sound m_sound; - bool reverse; - Image[2] imgs; - - //Constructor with with a fixed size string array of image path, and a string for the sound path - this (string[2] images, string soundFilename) - { - //load images and create filter - imgs[0] = new Image(images[0]); imgs[1] = new Image(images[1]); - - foreach(img; imgs) - img.createMaskFromColor(Color(97, 68, 43)); - - m_sprite = new Sprite(imgs[0]); - m_sprite.setOrigin(m_sprite.size.x / 2, m_sprite.size.y / 2); - - SoundBuffer buff = new SoundBuffer(soundFilename); - - //load our sound with loop enabled - m_sound = new Sound(buff, true); - m_sound.attenuation = .05f; - } - - // Begin the sound play - void startPlaying() - { - m_sound.play(); - } - - // Set the position of the car on the window - // Used to setup the begin car window and sound location - @property void position(Vector2f p) - { - m_sprite.setPosition(p.x, p.y); - m_sound.setPosition(p.x, 0, p.y); - } - - //Move the car (visual and sound position) - //If the car leave the screen, we change the sprite image and reverse moving - void move(Vector2f vec) - { - // if the car is beyond the right screen limit - if (!reverse && m_sprite.position.x > 850) - { - m_sprite.setImage(imgs[1]); - reverse = true; - } - // same as above but for left limit - else if (reverse && vec.x + m_sprite.position.x < -50) - { - m_sprite.setImage(imgs[0]); - reverse = false; - } - - if (reverse) - vec = -vec; - - m_sprite.move(vec); - Vector2f pos = m_sprite.position; - m_sound.setPosition(pos.x , pos.y, 0); - } - - @property Sprite sprite() - { - return m_sprite; - } -} \ No newline at end of file diff --git a/bindings/d/samples/dsfml/soundstream/soundstream.d b/bindings/d/samples/dsfml/soundstream/soundstream.d deleted file mode 100644 index 03ba555c..00000000 --- a/bindings/d/samples/dsfml/soundstream/soundstream.d +++ /dev/null @@ -1,97 +0,0 @@ -module soundstream; - -import dsfml.system.all; -import dsfml.audio.all; - -version (Tango) -{ - import tango.io.Console; - import tango.io.Stdout; -} -else -{ - import std.stdio; -} - -// SoundStream is an abstract class. -// You need to implement onStart() and onGetData() -// Don't forget to call initialize() before any usage or playback will fail. -class MySoundStream : SoundStream -{ - SoundBuffer m_buff; - short[] m_data; - size_t m_cursor; - - this() - { - // We initialize the stream with some sound informations - super(1, 11025); - - // We create a sound buffer to load samples from files - m_buff = new SoundBuffer("Data/car_idle.wav"); - m_data = m_buff.samples[0..m_buff.samplesCount]; - } - -protected: -/* - bool onStart() - { - // No specifics things to do, just return true. - return true; - } -*/ - override bool onGetData(out short[] data) - { - // We ensure that we have enough data to send - if (m_cursor + this.sampleRate > m_data.length) - return false; - - // Assign data in the buffer ... - data = m_data[m_cursor..m_cursor + this.sampleRate]; - // ... and increment the cursor - m_cursor += this.sampleRate; - return true; - } - - override void onSeek(float timeOffset) - { - - } -} - -void main() -{ - MySoundStream stream = new MySoundStream(); - - display("Playing sound !\n Press enter to stop playback."); - stream.play(); - read(); // prevent console from closing - stream.stop(); -} - -void display(string c) -{ - version (Tango) - { - Stdout(c).newline; - } - else - { - writeln(c); - } -} - -/** -* Dummy function to prevent console closing on windows -*/ -void read() -{ - version (Tango) - { - Cin.get(); - } - else - { - readln(); - } -} \ No newline at end of file diff --git a/bindings/d/samples/dsfml/view/view.d b/bindings/d/samples/dsfml/view/view.d deleted file mode 100644 index c100fc31..00000000 --- a/bindings/d/samples/dsfml/view/view.d +++ /dev/null @@ -1,69 +0,0 @@ -module view; - -import dsfml.system.all; -import dsfml.window.all; -import dsfml.graphics.all; - -void main() -{ - RenderWindow window = new RenderWindow(VideoMode(800, 600), "View sample"); - window.framerateLimit = 100; - Input input = window.input; - Vector2f top; - FloatRect bound; - Shape s; - bool mousePressed; - - Sprite background = new Sprite(new Image("Data/background.jpg")); - - Font f = new Font("Data/cheeseburger.ttf"); - Text str = new Text("Create a selection of the background with your mouse.\nPress Enter to zoom to this selection.\nPress Escape to return to the default view."c, f); - - while (window.isOpened()) - { - Event evt; - - while (window.getEvent(evt)) - { - if ( evt.Type == EventType.MouseButtonPressed && - evt.MouseButton.Button == MouseButtons.Left) - { - top = window.convertCoords(input.mouseX, input.mouseY); - mousePressed = true; - - } - else if ( evt.Type == EventType.MouseButtonReleased && - evt.MouseButton.Button == MouseButtons.Left) - { - mousePressed = false; - } - else if ( evt.Type == EventType.MouseMoved && - mousePressed) - { - Vector2f bottom = window.convertCoords(input.mouseX, input.mouseY); - bound = FloatRect(top.x, top.y, bottom.x-top.x, bottom.y-top.y); - s = Shape.rectangle(bound.left, bound.top, bound.width, bound.height, Color(0, 0, 0, 0), 1, Color.BLACK); - } - else if ( evt.Type == EventType.KeyPressed && - evt.Key.Code == KeyCode.Return) - { - if (bound != FloatRect()) - window.view = new View(bound); - s = null; - } - else if ( evt.Type == EventType.KeyPressed && - evt.Key.Code == KeyCode.Escape) - { - window.view = window.defaultView; - } - else if ( evt.Type == EventType.Closed) - window.close(); - - } - - window.draw(background); - window.draw(str); - if (s !is null) window.draw(s); - window.display(); - } -} \ No newline at end of file diff --git a/bindings/d/samples/dsfml/voip/client.d b/bindings/d/samples/dsfml/voip/client.d deleted file mode 100644 index f2dc4027..00000000 --- a/bindings/d/samples/dsfml/voip/client.d +++ /dev/null @@ -1,72 +0,0 @@ -module client; - -import util; - - -// Specialization of audio recorder for sending recorded audio -// data through the network -class NetworkRecorder : SoundRecorder -{ -public: - - // Constructor - this(SocketTCP Socket) - { - mySocket = Socket; - } - - ~this() - { - delete mySocket; - } -protected: - override bool onStart() - { - return true; - } - - override void onStop() - { - - } - - override bool onProcessSamples(short[] samples) - { - // Pack the audio samples into a network packet - Packet PacketOut = new Packet(); - PacketOut.set(AudioData); - PacketOut.append((cast(byte*)samples.ptr)[0..samples.length * short.sizeof]); - // Send the audio packet to the server - return mySocket.send(PacketOut) == SocketStatus.DONE; - } - - SocketTCP mySocket; ///< Socket used to communicate with the server -} - -void runClient(IPAddress adr, int port) -{ - // Create a TCP socket for communicating with server - SocketTCP Socket = new SocketTCP(); - - // Connect to the specified server - if (!Socket.connect(port, adr)) - return; - - // Wait for user input... - Cout("Press enter to start recording audio").newline; - Cin.get(); - - // Create a instance of our custom recorder - NetworkRecorder Recorder = new NetworkRecorder(Socket); - - // Start capturing audio data - Recorder.start(44100); - Cout("Press enter to stop recording audio").newline; - Cin.get(); - Recorder.stop(); - - // Send a "end-of-stream" packet - Packet PacketOut = new Packet(); - PacketOut.set(EndOfStream); - Socket.send(PacketOut); -} diff --git a/bindings/d/samples/dsfml/voip/entry.d b/bindings/d/samples/dsfml/voip/entry.d deleted file mode 100644 index 01c5c630..00000000 --- a/bindings/d/samples/dsfml/voip/entry.d +++ /dev/null @@ -1,46 +0,0 @@ -module entry; - -import util; -import server; -import client; - -int main(char[][] args) -{ - char[][] argc = args.dup; - if (argc.length > 1) - { - if ( argc[1] == "-c" && - argc.length == 4) - { - IPAddress adr = IPAddress(argc[2]); - - if (adr.isValid() && - parse(argc[3]) <= 60000 && - parse(argc[3]) >= 1000) - { - runClient(adr, parse(argc[3])); - } - else - printUsage(); - } - else if ( argc[1] == "-s" && - argc.length == 3 && - parse(argc[2]) <= 60000 && - parse(argc[2]) >= 1000) - { - runServer(parse(argc[2])); - - } - else - printUsage(); - } - else - printUsage(); - - return 0; -} - -void printUsage() -{ - Cout("Usage :\n voip.exe [-c [ip address] | -s] [port] \n -c = run as client\n -s = run as server\n ip address = address of the server\n port = port between 1000 and 65000\n").newline; -} diff --git a/bindings/d/samples/dsfml/voip/server.d b/bindings/d/samples/dsfml/voip/server.d deleted file mode 100644 index 41b182a0..00000000 --- a/bindings/d/samples/dsfml/voip/server.d +++ /dev/null @@ -1,162 +0,0 @@ -module server; - -import util; - -class NetworkAudioStream : SoundStream -{ -public: - static this() - { - s_sync = new Object(); - } - - // Default constructor - this() - { - myListener = new SocketTCP(); - myClient = new SocketTCP(); - // Set the sound parameters - super(1, 44100); - } - - // Destructor - ~this() - { - // Close the sockets - delete myClient; - delete myListener; - } - - // Run the server, stream audio data from the client - void start(int Port) - { - if (!myHasFinished) - { - // Listen to the given port for incoming connections - if (!myListener.listen(Port)) - return; - Cout("Listening").newline; - myListener.accept(myClient); - Cout("New Client").newline; - // Start playback - play(); - - // Start receiving audio data - receiveLoop(); - } - else - { - // Start playback - play(); - } - } - -protected: - - override bool onStart() - { - // Reset the playing offset - myOffset = 0; - - return true; - } - - override bool onGetData(out short[] data) - { - // We have reached the end of the buffer and all audio data have been played : we can stop playback - if ((myOffset == mySamples.length) && myHasFinished) - return false; - // No new data has arrived since last update : wait until we get some - while (myOffset == mySamples.length && !myHasFinished) - sleep(0.01f); - - synchronized(s_sync) - { - myTempBuffer = mySamples[myOffset..mySamples.length]; - // Update the playing offset - myOffset += myTempBuffer.length; - } - - data = myTempBuffer; - return true; - } - -private: - - void receiveLoop() - { - while (!myHasFinished) - { - // Get waiting audio data from the network - Packet PacketIn = new Packet(); - if (myClient.receive(PacketIn) != SocketStatus.DONE) - break; - - // Extract the message ID - ubyte Id; - PacketIn.get(Id); - - if (Id == AudioData) - { - // Extract audio samples from the packet, and append it to our samples buffer - - synchronized(s_sync) - { - byte* temp = PacketIn.getData().ptr; - temp++; - - mySamples ~= (cast(short*)temp)[0..(PacketIn.getDataSize - byte.sizeof ) / short.sizeof]; - } - } - else if (Id == EndOfStream) - { - // End of stream reached : we stop receiving audio data - myHasFinished = true; - } - else - { - // Something's wrong... - myHasFinished = true; - } - } - } - - SocketTCP myListener; - SocketTCP myClient; - short[] mySamples; - short[] myTempBuffer; - size_t myOffset; - bool myHasFinished; - - static Object s_sync; -}; - - - -// Launch a server and wait for incoming audio data from -// a connected client -void runServer(int Port) -{ - // Build an audio stream to play sound data as it is received through the network - NetworkAudioStream audioStream = new NetworkAudioStream; - audioStream.start(Port); - - // Loop until the sound playback is finished - while (audioStream.getStatus() != SoundStatus.STOPPED) - { - // Leave some CPU time for other threads - sleep(0.1f); - } - - Cout("Enter to replay").newline; - Cin.get(); - // Replay the sound (just to make sure replaying the received data is OK) - audioStream.play(); - - // Loop until the sound playback is finished - while (audioStream.getStatus() != SoundStatus.STOPPED) - { - // Leave some CPU time for other threads - sleep(0.1f); - } -} diff --git a/bindings/d/samples/dsfml/voip/util.d b/bindings/d/samples/dsfml/voip/util.d deleted file mode 100644 index ebf548b8..00000000 --- a/bindings/d/samples/dsfml/voip/util.d +++ /dev/null @@ -1,49 +0,0 @@ -module util; - -const ubyte AudioData = 1; -const ubyte EndOfStream = 2; - -public import dsfml.system.all; -public import dsfml.audio.all; -public import dsfml.network.all; - -version(Tango) -{ - public import tango.io.Console; - public import tango.text.convert.Integer; -} -else -{ - public import std.stdio; - - //simple abstraction of Cout & Cin for phobos - class Cout - { - static Cout s_c; - static this() - { - s_c = new Cout(); - } - - static Cout opCall(char[] str) - { - writefln("%s", str); - return s_c; - } - void newline() - { - - } - } - - class Cin - { - static char[] get() - { - return readln(); - } - } - - public import std.string : atoi; - alias atoi parse; -} diff --git a/bindings/python/MANIFEST.in b/bindings/python/MANIFEST.in deleted file mode 100644 index f58b8d26..00000000 --- a/bindings/python/MANIFEST.in +++ /dev/null @@ -1,5 +0,0 @@ -graft src -graft scripts -graft doc -graft samples - diff --git a/bindings/python/PySFML/__init__.py b/bindings/python/PySFML/__init__.py deleted file mode 100644 index 48163e52..00000000 --- a/bindings/python/PySFML/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -__all__ = ['sf'] - diff --git a/bindings/python/doc/style.css b/bindings/python/doc/style.css deleted file mode 100644 index 0a59e690..00000000 --- a/bindings/python/doc/style.css +++ /dev/null @@ -1,96 +0,0 @@ -div#logo -{ - margin-bottom : 1em; - background : url("http://www.sfml-dev.org/images/logo-bg.jpg") repeat-x; -} - -div#logo a -{ - display : block; -} - -div.class_desc -{ - margin-left:10px; - font-weight: bolder; - color:#168; -} - -div.base_class -{ - margin-top:8px; - margin-left:10px; - font-weight: bold; - color:#168; -} - -div.attr_name -{ - margin-top:20px; - margin-left:10px; - font-weight: bolder; -} - -div.inherited -{ - margin-left:20px; - font-size: smaller; -} - -div.desc -{ - margin-left:20px; -} - -div.event_member -{ - margin-left:30px; - font-weight: lighter; -} - -p#footer -{ - text-decoration : overline; - color : #606060; - padding-top : 1em; - text-align : center; - font-size : smaller; -} - -p#footer a -{ - color : #007298; - text-decoration : none; -} - -H1 { - text-align : center; - margin-top : 0px; - color : #2090B0; - font-size : 160%; -} -H2 { - font-size: 120%; -} -H3 { - font-size: 100%; -} - -a { - color: #2090B0; -} -a:visited { - color: #2090B0; -} -HR { height: 1px; - border: none; - border-top: 1px solid black; -} - -BODY,H1,H2,H3,H4,H5,H6,P,CENTER,TD,TH,UL,DL,DIV { - font-family: Geneva, Arial, Helvetica, sans-serif; -} -BODY,TD { - font-size: 90%; -} - diff --git a/bindings/python/samples/data/apple.png b/bindings/python/samples/data/apple.png deleted file mode 100644 index 0cfb031d..00000000 Binary files a/bindings/python/samples/data/apple.png and /dev/null differ diff --git a/bindings/python/samples/data/cheeseburger.ttf b/bindings/python/samples/data/cheeseburger.ttf deleted file mode 100644 index 47704266..00000000 Binary files a/bindings/python/samples/data/cheeseburger.ttf and /dev/null differ diff --git a/bindings/python/samples/data/fart.wav b/bindings/python/samples/data/fart.wav deleted file mode 100644 index b265837a..00000000 Binary files a/bindings/python/samples/data/fart.wav and /dev/null differ diff --git a/bindings/python/samples/data/rond2.png b/bindings/python/samples/data/rond2.png deleted file mode 100644 index 8d36b1d6..00000000 Binary files a/bindings/python/samples/data/rond2.png and /dev/null differ diff --git a/bindings/python/samples/hellosfml.py b/bindings/python/samples/hellosfml.py deleted file mode 100644 index d52c99c5..00000000 --- a/bindings/python/samples/hellosfml.py +++ /dev/null @@ -1,98 +0,0 @@ -# coding=utf-8 -from PySFML import sf -import random - -# Simple class for an apple. -class Apple: - sprite = None - speed = (2, 2) - rotationstep = 1 - - def __init__( self, image ): - self.sprite = sf.Sprite( image ) - self.sprite.SetOrigin( image.GetWidth() / 2, image.GetHeight() / 2 ) - -# Set resolution and create the window. -Resolution = (800, 600) - -wnd = sf.RenderWindow( sf.VideoMode( Resolution[0], Resolution[1], 32 ), "Hello SFML!" ) -wnd.UseVerticalSync( True ) - -# Load a fancy font. -cheese = sf.Font() -cheese.LoadFromFile( "data/cheeseburger.ttf" ) - -# Create a text. -text = sf.Text( u"Hello SFML from Python!", cheese, 50 ) -text.SetOrigin( text.GetRect().GetSize()[0] / 2, text.GetRect().GetSize()[1] / 2 ) -text.SetPosition( 400, 300 ) -text.SetColor( sf.Color( 0, 100, 0, 100 ) ) - -# Create a text for FPS display. -fpstext = sf.Text( u"FPS: --", cheese ) -fpstext.SetColor( sf.Color( 0, 0, 0 ) ) -currentfps = 0 -fpsclock = sf.Clock() - -# Load apple image from file. -appleimage = sf.Image() -appleimage.LoadFromFile( "data/apple.png" ) - -# Create some apples with random position, speed, rotation and color. -apples = [Apple( appleimage ) for num in range( 0, 100 )] -for apple in apples: - apple.sprite.SetOrigin( appleimage.GetWidth() / 2, appleimage.GetHeight() / 2 ) - apple.sprite.SetPosition( - random.randint( apple.sprite.GetOrigin()[0], Resolution[0] - apple.sprite.GetOrigin()[0] ), - random.randint( apple.sprite.GetOrigin()[1], Resolution[1] - apple.sprite.GetOrigin()[1] ) - ) - apple.sprite.SetColor( sf.Color( random.randint( 100, 255 ), random.randint( 100, 255 ), random.randint( 100, 255 ) ) ) - - randx = random.randint( -3, 3 ) - randy = random.randint( -3, 3 ) - apple.speed = (1 if randx == 0 else randx, 1 if randy == 0 else randy) - - apple.rotationstep = random.uniform( 1.0, 20.0 ) - 10.0 - -event = sf.Event() - -# Main loop. -while wnd.IsOpened(): - # Fetch all pending events and process them. - while wnd.GetEvent( event ): - # Quit when window has been closed or Escape has been pressed. - if event.Type == sf.Event.Closed: - wnd.Close() - elif event.Type == sf.Event.KeyPressed and event.Key.Code == sf.Key.Escape: - wnd.Close() - - # Clear window to white color. - wnd.Clear( sf.Color( 255, 255, 255 ) ) - - # Draw all apples and texts. - for apple in apples: - wnd.Draw( apple.sprite ) - - wnd.Draw( text ) - wnd.Draw( fpstext ) - - wnd.Display() # Display everything. - - # Count FPS. - currentfps += 1 - if fpsclock.GetElapsedTime() >= 1.0: - fpsclock.Reset() - fpstext.SetString( u"FPS: " + unicode( currentfps ) ) - currentfps = 0 - - # Update apples (for the "bounce effect"). - for apple in apples: - apple.sprite.Move( apple.speed[0], apple.speed[1] ) - apple.sprite.Rotate( apple.rotationstep ) - - realpos = (apple.sprite.GetPosition()[0] - apple.sprite.GetOrigin()[0], apple.sprite.GetPosition()[1] - apple.sprite.GetOrigin()[1]) - if (apple.speed[0] > 0 and realpos[0] >= Resolution[0] - appleimage.GetWidth()) or (apple.speed[0] < 0 and realpos[0] <= 0): - apple.speed = (apple.speed[0] * -1, apple.speed[1]) - - if (apple.speed[1] > 0 and realpos[1] >= Resolution[1] - appleimage.GetWidth()) or (apple.speed[1] < 0 and realpos[1] <= 0): - apple.speed = (apple.speed[0], apple.speed[1] * -1) diff --git a/bindings/python/samples/opengl.py b/bindings/python/samples/opengl.py deleted file mode 100644 index 93ce04fe..00000000 --- a/bindings/python/samples/opengl.py +++ /dev/null @@ -1,165 +0,0 @@ -#!/usr/bin/python - -from PySFML import sf - -from OpenGL.GL import * -from OpenGL.GLUT import * -from OpenGL.GLU import * - - -def main(): - - # Create main window - App = sf.RenderWindow(sf.VideoMode(800, 600), "SFML OpenGL") - App.SetActive() - - # Create a sprite for the background - BackgroundImage = sf.Image() - if not BackgroundImage.LoadFromFile("../../samples/bin/datas/opengl/background.jpg"): - return - Background = sf.Sprite(BackgroundImage) - - # Load an OpenGL texture. - # We could directly use a sf.Image as an OpenGL texture (with its Bind() member function), - # but here we want more control on it (generate mipmaps, ...) so we create a new one - - Image = sf.Image() - if not Image.LoadFromFile("../../samples/bin/datas/opengl/texture.jpg"): - return - # The next line is a bit different from the C++ version - Texture = glGenTextures(1) # instead of glGenTextures(1, &Texture); - glBindTexture(GL_TEXTURE_2D, Texture) - # It is almost the same line there, except in C++, the last argument was Image.GetPixelsPtr(). - # In python, GetPixels simply returns a string. - gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, Image.GetWidth(), Image.GetHeight(), GL_RGBA, GL_UNSIGNED_BYTE, Image.GetPixels()) - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR) - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR) - - - # Enable Z-buffer read and write - glEnable(GL_DEPTH_TEST) - glDepthMask(GL_TRUE) - glClearDepth(1.) - - # Setup a perspective projection - glMatrixMode(GL_PROJECTION) - glLoadIdentity() - gluPerspective(90., 1., 1., 500.) - - # Bind our texture - glEnable(GL_TEXTURE_2D) - glBindTexture(GL_TEXTURE_2D, Texture) - glColor4f(1., 1., 1., 1.) - - # Create a clock for measuring the time elapsed - Clock = sf.Clock() - - # Start game loop - while App.IsOpened(): - # Process events - Event = sf.Event() - while App.GetEvent(Event): - # Close window : exit - if Event.Type == sf.Event.Closed: - App.Close() - - # Escape key : exit - if (Event.Type == sf.Event.KeyPressed) and (Event.Key.Code == sf.Key.Escape): - App.Close() - - # Adjust the viewport when the window is resized - if Event.Type == sf.Event.Resized: - glViewport(0, 0, Event.Size.Width, Event.Size.Height) - - # Draw background - App.Draw(Background) - - # Active window to be able to perform OpenGL commands. - App.SetActive() - - # Clear depth buffer - glClear(GL_DEPTH_BUFFER_BIT) - - # Apply some transformations - glMatrixMode(GL_MODELVIEW) - glLoadIdentity() - glTranslatef(0, 0, -200) - glRotatef(Clock.GetElapsedTime() * 50, 1, 0, 0) - glRotatef(Clock.GetElapsedTime() * 30, 0, 1, 0) - glRotatef(Clock.GetElapsedTime() * 90, 0, 0, 1) - - # Draw a cube - glBegin(GL_QUADS) - - glTexCoord2f(0, 0) - glVertex3f(-50., -50., -50.) - glTexCoord2f(0, 1) - glVertex3f(-50., 50., -50.) - glTexCoord2f(1, 1) - glVertex3f( 50., 50., -50.) - glTexCoord2f(1, 0) - glVertex3f( 50., -50., -50.) - - glTexCoord2f(0, 0) - glVertex3f(-50., -50., 50.) - glTexCoord2f(0, 1) - glVertex3f(-50., 50., 50.) - glTexCoord2f(1, 1) - glVertex3f( 50., 50., 50.) - glTexCoord2f(1, 0) - glVertex3f( 50., -50., 50.) - - glTexCoord2f(0, 0) - glVertex3f(-50., -50., -50.) - glTexCoord2f(0, 1) - glVertex3f(-50., 50., -50.) - glTexCoord2f(1, 1) - glVertex3f(-50., 50., 50.) - glTexCoord2f(1, 0) - glVertex3f(-50., -50., 50.) - - glTexCoord2f(0, 0) - glVertex3f(50., -50., -50.) - glTexCoord2f(0, 1) - glVertex3f(50., 50., -50.) - glTexCoord2f(1, 1) - glVertex3f(50., 50., 50.) - glTexCoord2f(1, 0) - glVertex3f(50., -50., 50.) - - glTexCoord2f(0, 1) - glVertex3f(-50., -50., 50.) - glTexCoord2f(0, 0) - glVertex3f(-50., -50., -50.) - glTexCoord2f(1, 0) - glVertex3f( 50., -50., -50.) - glTexCoord2f(1, 1) - glVertex3f( 50., -50., 50.) - - glTexCoord2f(0, 1) - glVertex3f(-50., 50., 50.) - glTexCoord2f(0, 0) - glVertex3f(-50., 50., -50.) - glTexCoord2f(1, 0) - glVertex3f( 50., 50., -50.) - glTexCoord2f(1, 1) - glVertex3f( 50., 50., 50.) - - glEnd() - - # Draw some text on top of our OpenGL object - Text = sf.Text("This is a rotating cube") - Text.SetPosition(230., 300.) - Text.SetColor(sf.Color(128, 0, 128)) - App.Draw(Text) - - # Finally, display the rendered frame on screen - App.Display() - - # Don't forget to destroy our texture - # In C++, the call to this function was a bit different - glDeleteTextures(Texture) # instead of glDeleteTextures(1, &Texture); - - return -main() - diff --git a/bindings/python/samples/sound.py b/bindings/python/samples/sound.py deleted file mode 100644 index 8d91de68..00000000 --- a/bindings/python/samples/sound.py +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/python - -# You can notice that here we use PySFML.sf instead of just PySFML -# Therefore it won't be needed to put sf. in front of SFML classes - -from PySFML import sf - - -def Main(): - Buffer = sf.SoundBuffer() - if not Buffer.LoadFromFile("data/fart.wav"): # Loads the sound - return - Fart = sf.Sound(Buffer, False) - - WindowWidth, WindowHeight = 640, 480 - App = sf.RenderWindow(sf.VideoMode(WindowWidth,WindowHeight,32), "Sound with PySFML", sf.Style.Close, sf.ContextSettings(24,8,0)) - App.SetFramerateLimit(30) - - EventHandler = sf.Event() - InputHandler = App.GetInput() - - Text = sf.Text("Turn the sound on.\nClick anywhere on the screen.\nMove the mouse. Click again.\nTry clicking in the corners.") - Text.SetX(30.) - Text.SetY(20.) - Text.SetColor(sf.Color(150, 100, 10, 255)) - - while App.IsOpened(): # Main loop - while App.GetEvent(EventHandler): # Event Handler - if EventHandler.Type == sf.Event.Closed: - App.Close() - if EventHandler.Type == sf.Event.KeyPressed and EventHandler.Key.Code == sf.Key.Escape: - App.Close() - if EventHandler.Type == sf.Event.MouseButtonPressed and EventHandler.MouseButton.Button == sf.Mouse.Left: - Fart.SetPitch(1.5 - 1.*InputHandler.GetMouseY()/WindowHeight) - Fart.SetPosition( 1.*(InputHandler.GetMouseX() - WindowWidth/2)/(WindowWidth/20), 2., -2.) - Fart.Play() - App.Draw(Text) - App.Display() - App.Clear(sf.Color.Black) - - -Main() - diff --git a/bindings/python/samples/sound_capture.py b/bindings/python/samples/sound_capture.py deleted file mode 100644 index 9a496593..00000000 --- a/bindings/python/samples/sound_capture.py +++ /dev/null @@ -1,68 +0,0 @@ -#!/usr/bin/env python - -from PySFML import sf - -def Main(): - # Check that the device can capture audio - if sf.SoundRecorder.IsAvailable() == False: - print "Sorry, audio capture is not supported by your system" - return - - # Choose the sample rate - SampleRate = 0 - SampleRate = int(raw_input("Please choose the sample rate for sound capture (44100 is CD quality) : ")) - - # Wait for user input... - print "Press enter to start recording audio" - raw_input() - - # Here we'll use an integrated custom recorder, which saves the captured data into a sfSoundBuffer - Recorder = sf.SoundBufferRecorder() - - # Audio capture is done in a separate thread, so we can block the main thread while it is capturing - Recorder.Start(SampleRate) - print "Recording... press enter to stop" - raw_input() - Recorder.Stop() - - # Get the buffer containing the captured data - Buffer = Recorder.GetBuffer() - - # Display captured sound informations - print "Sound information :" - print " " + str(Buffer.GetDuration()) + " seconds" - print " " + str(Buffer.GetSampleRate()) + " samples / seconds" - print " " + str(Buffer.GetChannelsCount()) + " channels" - - # Choose what to do with the recorded sound data - Choice = str(raw_input("What do you want to do with captured sound (p = play, s = save) ? ")) - - if Choice == 's': - # Choose the filename - Filename = str(raw_input("Choose the file to create : ")) - - # Save the buffer - Buffer.SaveToFile(Filename); - else: - # Create a sound instance and play it - Sound = sf.Sound(Buffer) - Sound.Play() - - # Wait until finished - while Sound.GetStatus() == sf.Sound.Playing: - # Display the playing position - I don't know how to do this in python - # std::cout << "\rPlaying... " << std::fixed << std::setprecision(2) << Sound.GetPlayingOffset() << " sec"; - - # Leave some CPU time for other threads - sf.Sleep(0.1) - - # Finished ! - print "Done !" - - # Wait until the user presses 'enter' key - print "Press enter to exit..." - raw_input() - - return - -Main() diff --git a/bindings/python/samples/sound_capture_py3.py b/bindings/python/samples/sound_capture_py3.py deleted file mode 100644 index 2f2053da..00000000 --- a/bindings/python/samples/sound_capture_py3.py +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/env python - -from PySFML import sf - -def Main(): - # Check that the device can capture audio - if sf.SoundRecorder.CanCapture() == False: - print("Sorry, audio capture is not supported by your system") - return - - # Choose the sample rate - SampleRate = int(input("Please choose the sample rate for sound capture (44100 is CD quality) : ")) - - # Wait for user input... - print("Press enter to start recording audio") - input() - - # Here we'll use an integrated custom recorder, which saves the captured data into a sfSoundBuffer - Recorder = sf.SoundBufferRecorder() - - # Audio capture is done in a separate thread, so we can block the main thread while it is capturing - Recorder.Start(SampleRate) - print("Recording... press enter to stop") - input() - Recorder.Stop() - - # Get the buffer containing the captured data - Buffer = Recorder.GetBuffer() - - # Display captured sound informations - print("Sound information :") - print(" " + str(Buffer.GetDuration()) + " seconds") - print(" " + str(Buffer.GetSampleRate()) + " samples / seconds") - print(" " + str(Buffer.GetChannelsCount()) + " channels") - - # Choose what to do with the recorded sound data - Choice = str(input("What do you want to do with captured sound (p = play, s = save) ? ")) - - if Choice == 's': - # Choose the filename - Filename = str(input("Choose the file to create : ")) - - # Save the buffer - Buffer.SaveToFile(Filename); - else: - # Create a sound instance and play it - Sound = sf.Sound(Buffer) - Sound.Play() - - # Wait until finished - while Sound.GetStatus() == sf.Sound.Playing: - # Display the playing position - I don't know how to do this in python - # std::cout << "\rPlaying... " << std::fixed << std::setprecision(2) << Sound.GetPlayingOffset() << " sec"; - - # Leave some CPU time for other threads - sf.Sleep(0.1) - - # Finished ! - print("Done !") - - # Wait until the user presses 'enter' key - print("Press enter to exit...") - input() - - return - -Main() diff --git a/bindings/python/samples/sound_stream.py b/bindings/python/samples/sound_stream.py deleted file mode 100755 index a4e7a470..00000000 --- a/bindings/python/samples/sound_stream.py +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/python - -from PySFML import sf - -class MyCustomStream(sf.SoundStream): - - def Open(self, Filename): - # Load the sound data into a sound buffer - self.SoundData = sf.SoundBuffer() - if not self.SoundData.LoadFromFile(Filename): - return False - # Initialize the stream with the sound parameters - self.Initialize(self.SoundData.GetChannelsCount(), self.SoundData.GetSampleRate()) - # Copy the audio samples into our internal array - self.myBuffer = self.SoundData.GetSamples() - return True - - def OnStart(self): - self.myOffset = 0 - self.myBufferSize = 80000 - return True - - def OnGetData(self): - # Check if there is enough data to stream - if self.myOffset > len(self.myBuffer): - # Returning something else than a string means that we want to stop playing the stream - return "" - # Data contains the string of samples we will return - if self.myOffset + self.myBufferSize >= len(self.myBuffer): - print "End of audio data reached" - Data = self.myBuffer[self.myOffset:] - else: - Data = self.myBuffer[self.myOffset:self.myOffset+self.myBufferSize] - # Update the offset - self.myOffset = self.myBufferSize + self.myOffset - return Data - -def Main(): - Stream = MyCustomStream() - Stream.Open("./data/fart.wav") - Stream.Play() - print "Playing 5 seconds of audio data..." - sf.Sleep(5) - Stream.Stop() - print "Press enter to exit..." - raw_input() - -Main() - diff --git a/bindings/python/samples/sound_stream_py3.py b/bindings/python/samples/sound_stream_py3.py deleted file mode 100755 index bd1a73f8..00000000 --- a/bindings/python/samples/sound_stream_py3.py +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/python - -from PySFML import sf - -class MyCustomStream(sf.SoundStream): - - def Open(self, Filename): - # Load the sound data into a sound buffer - self.SoundData = sf.SoundBuffer() - if not self.SoundData.LoadFromFile(Filename): - return False - # Initialize the stream with the sound parameters - self.Initialize(self.SoundData.GetChannelsCount(), self.SoundData.GetSampleRate()) - # Copy the audio samples into our internal array - self.myBuffer = self.SoundData.GetSamples() - return True - - def OnStart(self): - self.myOffset = 0 - self.myBufferSize = 80000 - return True - - def OnGetData(self): - # Check if there is enough data to stream - if self.myOffset > len(self.myBuffer): - # Returning something else than a string means that we want to stop playing the stream - return "" - # Data contains the string of samples we will return - if self.myOffset + self.myBufferSize >= len(self.myBuffer): - print("End of audio data reached") - Data = self.myBuffer[self.myOffset:] - else: - Data = self.myBuffer[self.myOffset:self.myOffset+self.myBufferSize] - # Update the offset - self.myOffset = self.myBufferSize + self.myOffset - return Data - -def Main(): - Stream = MyCustomStream() - Stream.Open("./data/fart.wav") - Stream.Play() - print("Playing 5 seconds of audio data...") - sf.Sleep(5) - Stream.Stop() - print("Press enter to exit...") - input() - -Main() - diff --git a/bindings/python/samples/worm.py b/bindings/python/samples/worm.py deleted file mode 100644 index 49bb1085..00000000 --- a/bindings/python/samples/worm.py +++ /dev/null @@ -1,272 +0,0 @@ -#!/usr/bin/python - -from PySFML import sf -import math -import random - -class Menu: - def __init__(self, screen_width, screen_height): - self.selection = 0 - text_color = sf.Color(220, 220, 20, 255) - self.spacing = screen_height/7 - - self.title = sf.Text("PyWorm!") - self.title.SetColor(text_color) - self.title.SetPosition(screen_width/2-80., self.spacing) - - levels = ["Very Easy", "Easy", "Medium", "Hard"] - x_align = [-80., -50., -70., -50.] - self.strings = [] - for i in range(0, 4): - string = sf.Text(levels[i]) - string.SetColor(text_color) - string.SetPosition(screen_width/2+x_align[i], (2+i)*self.spacing+20) - self.strings.append(string) - - self.rectangle = sf.Shape.Rectangle(0, 0, screen_width, 40, sf.Color(50, 50, 10)) - - def next_frame(self, win): - self.rectangle.SetY(self.spacing*(2 + self.selection)+20) - win.Draw(self.rectangle) - win.Draw(self.title) - win.Draw(self.strings) - - def key_up(self, pressed): - if pressed: - self.selection = (self.selection - 1) % 4 - def key_down(self, pressed): - if pressed: - self.selection = (self.selection + 1) % 4 - - - -class Apple(sf.Sprite): - def __init__(self): - apple_img = sf.Image() # Apple's image - if not apple_img.LoadFromFile("./data/apple.png"): - pass - # print "Could not load data/apple.png" - sf.Sprite.__init__(self, apple_img) - self.SetOrigin(apple_img.GetWidth()/2, apple_img.GetHeight()/2) - self.size = apple_img.GetWidth() - - def random_move(self, arena): - self.SetPosition( \ - random.randrange(arena.arena_left+arena.border, arena.arena_right-arena.border), \ - random.randrange(arena.arena_top+arena.border, arena.arena_bottom-arena.border) \ - ) - - -class Arena(dict): - shrink_value, border, arena_top = 20, 30, 20 - def __init__(self, window_width, window_height): - self.window_width = window_width - self.arena_bottom, self.exit_left, self.exit_right = window_height-80, window_width/2 - 50, window_width/2 + 50 - self['level_str'] = sf.Text() - self['level_str'].SetColor(sf.Color.White) - self['level_str'].SetPosition(60., window_height-60) - self['score_str'] = sf.Text() - self['score_str'].SetColor(sf.Color.White) - self['score_str'].SetPosition(260., window_height-60) - self.exit_rect = sf.Shape.Rectangle(self.exit_left, 0, self.exit_right, self.arena_top, sf.Color.Black) - self.reset() - self.update_arena_rect() - - def update_arena_rect(self): - self['arena_rect'] = sf.Shape.Rectangle(self.arena_left, self.arena_top, self.arena_right, self.arena_bottom, sf.Color.Black) - - def reset(self): - self.level, self.score, self.arena_left, self.arena_right = 1, 0, self.shrink_value, self.window_width-self.shrink_value - self.update_arena_rect() - self['level_str'].SetString("Level: 1") - self['score_str'].SetString("Score: 0") - - def update_score(self): - self.score += 1 - self['score_str'].SetString("Score: " + str(self.score)) - - def next_level(self): - self.level += 1 - self['level_str'].SetString("Level: " + str(self.level)) - self.arena_left += self.shrink_value - self.arena_right -= self.shrink_value - self.update_arena_rect() - self.score += 4 - self.update_score() - -class Part(sf.Sprite): - def __init__(self, rond, x, y): - sf.Sprite.__init__(self, rond) - self.SetOrigin(rond.GetWidth()/2, rond.GetHeight()/2) - self.SetPosition(x, y) - -class Worm(list): - parts_spacing, turn_step, part_size, start_x, start_y, required_length, grow_length = 3, 0.15, 6.0, 50., 50., 300, 20 - - def __init__(self, difficulty): - self.parts_per_frame = 1 + difficulty - self.angle = 0 - self.direction = 0 # 0, 1 or -1 according to the key pressed - self.rond = sf.Image() - self.level_completed = False - if not self.rond.LoadFromFile("./data/rond2.png"): - pass - # print "Could not load data/rond2.png" - - def reset(self, arena): - self.targeted_length, self.angle, self.direction = 30, 0, 0 - self[:] = [Part(self.rond, arena.arena_left+self.start_x, arena.arena_top+self.start_y)] - - def left(self, pressed): - if pressed: - self.direction = -1 - elif self.direction == -1: - self.direction = 0 - def right(self, pressed): - if pressed: - self.direction = 1 - elif self.direction == 1: - self.direction = 0 - def restart(self, arena): - if self.targeted_length == 0 and not self.level_completed: - arena.reset() - self.reset(arena) - return True - else: - return False - - def crash(self): - self.targeted_length = 0 - - def move(self, arena, apple): - head_x, head_y = -1, -1 - if self.is_running(): # Create new parts and check collisions if the worm hasn't crashed yet - for i in range(self.parts_per_frame): # We create PartsPerFrame Worm's parts - self.angle += self.direction*self.turn_step - head_x, head_y = self[-1].GetPosition() - head_x += self.parts_spacing*math.cos(self.angle) - head_y += self.parts_spacing*math.sin(self.angle) - if self.is_running() and self.targeted_length <= self.required_length: # let's check if the worm ate the apple - if math.hypot(apple.GetPosition()[0] - head_x, apple.GetPosition()[1] - head_y) < apple.size/2 + self.part_size/2: # Yes it did - arena.update_score() - self.targeted_length += self.grow_length # The worm gets longer - apple.random_move(arena) - if head_xarena.arena_right-self.part_size/2 or head_yarena.arena_bottom-self.part_size/2: # Crash into a wall - if len(self) > self.required_length: - if head_yarena.exit_right-self.part_size/2: # Crash into the exit walls - self.crash() - elif head_y < 0: - self.level_completed = True - self.targeted_length = 0 - else: - self.crash() - elif self.is_running(): - self.crash() - if self.is_running(): - self.append(Part(self.rond, head_x, head_y)) - if len(self) > self.targeted_length: - if len(self) - self.targeted_length >= self.parts_per_frame: - del self[0:self.parts_per_frame] - else: - del self[0:len(self) - self.targeted_length] - - if (head_x, head_y) == (-1, -1) and len(self) > 0: - head_x, head_y = self[-1].GetPosition() - - if len(self) > self.part_size/self.parts_spacing + 1: - for i in range(len(self)): - if i < len(self) - self.part_size/self.parts_spacing - 1: - test_x, test_y = self[i].GetPosition() - if math.hypot(head_x-test_x, head_y-test_y) < self.part_size and self.is_running(): # Check for collision - self.crash() - - if len(self) == 0: - if self.level_completed: - self.level_completed = False - arena.next_level() - self.reset(arena) - - def is_running(self): - return (self.targeted_length > 0) and not self.level_completed - def draw_exit(self): - return self.targeted_length > self.required_length or self.level_completed - -class Game: - def __init__(self, difficulty, window_width, window_height): - self.arena = Arena(window_width, window_height) - self.worm = Worm(difficulty) - self.worm.reset(self.arena) - self.apple = Apple() - self.apple.random_move(self.arena) - self.pause = False - - def enter(self, pressed): - if pressed: - if not self.worm.restart(self.arena): - self.pause = not self.pause - - def next_frame(self, win): - win.Draw(self.arena.values()) - if not self.pause: - self.worm.move(self.arena, self.apple) - if self.worm.draw_exit(): - win.Draw(self.arena.exit_rect) - elif self.worm.is_running(): - win.Draw(self.apple) - win.Draw(self.worm) - - -class Main: - # Entry Point - def __init__(self): - # Initialize the window - self.win = sf.RenderWindow(sf.VideoMode(800, 600,32), "PyWorm", sf.Style.Close) # Creates the window - self.win.EnableKeyRepeat(False) - background_color = sf.Color(100, 100, 0, 255) - self.win.SetFramerateLimit(30) - event = sf.Event() - self.keys = {} # keys to watch - self.menu_begin() - - # Boucle principale - while self.win.IsOpened(): - while self.win.GetEvent(event): # Event Handler - if event.Type == sf.Event.Closed: - self.win.Close() - elif event.Type == sf.Event.KeyPressed or event.Type == sf.Event.KeyReleased: - if event.Key.Code in self.keys: - self.keys[event.Key.Code](event.Type == sf.Event.KeyPressed) - self.win.Display() - self.win.Clear(background_color) - self.next_frame(self.win) - - # Menu - def menu_begin(self): - self.menu = Menu(self.win.GetWidth(), self.win.GetHeight()) - self.keys = {sf.Key.Escape:self.close_window, sf.Key.Up:self.menu.key_up, sf.Key.Down:self.menu.key_down, sf.Key.Return:self.menu_end} - self.next_frame = self.menu.next_frame - - def close_window(self, pressed): - if pressed: - self.win.Close() - - def menu_end(self, pressed): - if pressed: - selection = self.menu.selection - del self.menu - self.game_begin(selection) - - # Game - def game_begin(self, selection): - self.game = Game(selection, self.win.GetWidth(), self.win.GetHeight()) - self.keys = {sf.Key.Left:self.game.worm.left, sf.Key.Right:self.game.worm.right, sf.Key.Return:self.game.enter, sf.Key.Escape:self.game_end} - self.next_frame = self.game.next_frame - - def game_end(self, pressed): - if pressed: - del self.game - self.menu_begin() - -Main() - diff --git a/bindings/python/scripts/footer.htm b/bindings/python/scripts/footer.htm deleted file mode 100644 index 77030f7c..00000000 --- a/bindings/python/scripts/footer.htm +++ /dev/null @@ -1,7 +0,0 @@ - - - - - diff --git a/bindings/python/scripts/gen_doc.py b/bindings/python/scripts/gen_doc.py deleted file mode 100755 index 99e4721e..00000000 --- a/bindings/python/scripts/gen_doc.py +++ /dev/null @@ -1,118 +0,0 @@ -#!/usr/bin/python -# coding=UTF-8 - -from PySFML import sf - -# Amélioration à faire : trouver les méthodes héritées, et de quelle classe - -def function_str(function, class_name=None): - string = '' - name = function.__name__ - doc = function.__doc__ - if not doc.startswith(name+'('): - string += name+"(...)"+'\n' - string += doc+'\n' - strings = string.split('\n') - strings[0] = '
'+strings[0]+'
\n
' - string = strings[0] - for s in strings[1:-1]: - string += s + '
' - string += strings[-1] - inherited = '' - if class_name != None: - try: - base_class_name = function.__objclass__.__name__ - if base_class_name != class_name: - inherited = '
Inherited
\n' - except AttributeError: - pass - return string.replace('\t', '    ')+'
\n'+inherited - -class FilesManager: - def __init__(self): - self.files = {} - f = open("header.htm") - self.header = f.read() - f.close() - f = open("footer.htm") - self.footer = f.read() - f.close() - - def add(self, filename, string): - if not self.files.has_key(filename): - self.files[filename] = open('../doc/' + filename + '.html', 'w') - self.files[filename].write(self.header.replace('TITLE', filename)) - self.files[filename].write(string) - - def __del__(self): - for filename in self.files: - self.files[filename].write(self.footer) - self.files[filename].close() - - -def Main(): - - fm = FilesManager() - - fm.add('index', '

PySFML index

\n') - - fm.add('index', '

Classes

\n') - - module_methods = "" - module_constants = "" - - for m in dir(sf): - if not m.startswith('__'): - if m == 'Event': - attr = sf.Event() - else: - attr = getattr(sf, m) - if type(attr) == str: - module_constants += '
'+m+'
\n
"'+attr+'"
\n' - elif str(type(attr)) == "" or str(type(attr)) == "": - module_methods += function_str(attr) - else: - fm.add('index', ''+m+'
\n') - info = {'Attributes':'', 'Constants':'', 'Methods':'', 'Static methods':''} - members = "" - constants = "" - static_methods = "" - methods = "" - for n in dir(attr): - if not n.startswith('__'): - attr2 = getattr(attr, n) - if str(type(attr2)) == "": # member - info['Attributes'] += '
'+n+'
\n
'+attr2.__doc__+'
\n' - elif type(attr2) == long: - info['Attributes'] += '
'+n+'
\n' - elif type(attr2) == int or type(attr2) == sf.Color: # int or color (constant) - info['Constants'] += '
'+n+'
\n' - elif str(type(attr2)) == "": # static method - info['Static methods'] += function_str(attr2, m) - elif str(type(attr2)) == "": # method - info['Methods'] += function_str(attr2, m) - elif str(type(attr2)).startswith("\n
' + attr2.__doc__+'
\n' - for o in dir(attr2): - if not o.startswith('__'): - attr3 = getattr(attr2, o) - info['Attributes'] += '
> ' + o + '
\n' - else: - print "Warning : unknown type for " + n + " " + str(type(attr2)) - fm.add(m, '

sf.'+m+' Class Reference

\n') - fm.add(m, '
'+attr.__doc__.replace('\n', '
\n').replace('\t', '    ')+'
\n') - if m != 'Event': - base = attr.__base__.__name__ - if base != 'object': - fm.add(m, '
Base class: sf.'+base+'.
\n') - for t in info: - if info[t] != '': - fm.add(m, '

'+t+'

\n'+info[t]+'
\n') - fm.add(m, '
\n
\n') - - fm.add('index', '

Module methods

\n' + module_methods) - - fm.add('index', '

Module constants

\n' + module_constants) - -Main() - diff --git a/bindings/python/scripts/header.htm b/bindings/python/scripts/header.htm deleted file mode 100644 index f335b428..00000000 --- a/bindings/python/scripts/header.htm +++ /dev/null @@ -1,11 +0,0 @@ - - - - PySFML - Python binding for SFML (Simple and Fast Multimedia Library) - TITLE - - - - - diff --git a/bindings/python/setup.py b/bindings/python/setup.py deleted file mode 100644 index a263fbc2..00000000 --- a/bindings/python/setup.py +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env python -# coding=UTF-8 - -from distutils.core import setup, Extension - -setup(name='PySFML', - version='1.6', - description='Python binding for SFML (Simple and Fast Multimedia Library)', - author='Rémi Koenig', - 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'], - include_dirs=['../include'] - )], - package_dir = {'PySFML':'PySFML'}, - packages=['PySFML'], - ) diff --git a/bindings/python/src/Blend.cpp b/bindings/python/src/Blend.cpp deleted file mode 100644 index dc43ca5c..00000000 --- a/bindings/python/src/Blend.cpp +++ /dev/null @@ -1,100 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// PySFML - Python binding for SFML (Simple and Fast Multimedia Library) -// Copyright (C) 2007, 2008 Rémi Koenig (remi.k2620@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#include "Blend.hpp" - -#include "compat.hpp" - - -static PyObject * -PySfBlend_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PySfBlend *self; - self = (PySfBlend *)type->tp_alloc(type, 0); - return (PyObject *)self; -} - - -PyTypeObject PySfBlendType = { - head_init - "Blend", /*tp_name*/ - sizeof(PySfBlend), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - 0, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash */ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ - "Enumerate the blending modes for drawable objects.\n\ -Alpha Pixel = Src * a + Dest * (1 - a).\n\ -Add Pixel = Src + Dest.\n\ -Multiply Pixel = Src * Dest.\n\ -None No blending.", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PySfBlend_new, /* tp_new */ -}; - -void PySfBlend_InitConst() -{ - PyObject *obj; - obj = PyLong_FromLong(sf::Blend::Alpha); - PyDict_SetItemString(PySfBlendType.tp_dict, "Alpha", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Blend::Add); - PyDict_SetItemString(PySfBlendType.tp_dict, "Add", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Blend::Multiply); - PyDict_SetItemString(PySfBlendType.tp_dict, "Multiply", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Blend::None); - PyDict_SetItemString(PySfBlendType.tp_dict, "None", obj); - Py_DECREF(obj); -} - diff --git a/bindings/python/src/Blend.hpp b/bindings/python/src/Blend.hpp deleted file mode 100644 index f6108736..00000000 --- a/bindings/python/src/Blend.hpp +++ /dev/null @@ -1,39 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// PySFML - Python binding for SFML (Simple and Fast Multimedia Library) -// Copyright (C) 2007, 2008 Rémi Koenig (remi.k2620@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#ifndef __PYBLEND_HPP -#define __PYBLEND_HPP - -#include - -#include - -typedef struct { - PyObject_HEAD -} PySfBlend; - -void -PySfBlend_InitConst(); - -#endif diff --git a/bindings/python/src/Clock.cpp b/bindings/python/src/Clock.cpp deleted file mode 100644 index c6ba6288..00000000 --- a/bindings/python/src/Clock.cpp +++ /dev/null @@ -1,110 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// PySFML - Python binding for SFML (Simple and Fast Multimedia Library) -// Copyright (C) 2007, 2008 Rémi Koenig (remi.k2620@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#include "Clock.hpp" - -#include "compat.hpp" - - -static void -PySfClock_dealloc(PySfClock *self) -{ - delete self->obj; - free_object(self); -} - -static PyObject * -PySfClock_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PySfClock *self; - - self = (PySfClock *)type->tp_alloc(type, 0); - if (self != NULL) - self->obj = new sf::Clock(); - - return (PyObject *)self; -} - - -static PyObject* -PySfClock_GetElapsedTime(PySfClock *self) -{ - return PyFloat_FromDouble(self->obj->GetElapsedTime()); -} - -static PyObject* -PySfClock_Reset(PySfClock *self) -{ - self->obj->Reset(); - Py_RETURN_NONE; -} - -static PyMethodDef PySfClock_methods[] = { - {"GetElapsedTime", (PyCFunction)PySfClock_GetElapsedTime, METH_NOARGS, "GetElapsedTime()\nGet the time elapsed since last reset."}, - {"Reset", (PyCFunction)PySfClock_Reset, METH_NOARGS, "Reset()\nRestart the timer."}, - {NULL} /* Sentinel */ -}; - -PyTypeObject PySfClockType = { - head_init - "Clock", /*tp_name*/ - sizeof(PySfClock), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - (destructor)PySfClock_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare (tp_reserved in py3k)*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash */ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ - "sf.Clock is an utility class for manipulating time.", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - PySfClock_methods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PySfClock_new, /* tp_new */ -}; - - diff --git a/bindings/python/src/Clock.hpp b/bindings/python/src/Clock.hpp deleted file mode 100644 index d0a32f65..00000000 --- a/bindings/python/src/Clock.hpp +++ /dev/null @@ -1,37 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// PySFML - Python binding for SFML (Simple and Fast Multimedia Library) -// Copyright (C) 2007, 2008 Rémi Koenig (remi.k2620@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#ifndef __PYCLOCK_HPP -#define __PYCLOCK_HPP - -#include - -#include - -typedef struct { - PyObject_HEAD - sf::Clock *obj; -} PySfClock; - -#endif diff --git a/bindings/python/src/Color.cpp b/bindings/python/src/Color.cpp deleted file mode 100644 index 567a2da9..00000000 --- a/bindings/python/src/Color.cpp +++ /dev/null @@ -1,198 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// PySFML - Python binding for SFML (Simple and Fast Multimedia Library) -// Copyright (C) 2007, 2008 Rémi Koenig (remi.k2620@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#include "Color.hpp" - -#include "offsetof.hpp" -#include "compat.hpp" - -static PyMemberDef PySfColor_members[] = { - {(char *)"r", T_UBYTE, offsetof(PySfColor, r), 0, (char *)"Red component."}, - {(char *)"g", T_UBYTE, offsetof(PySfColor, g), 0, (char *)"Green component."}, - {(char *)"b", T_UBYTE, offsetof(PySfColor, b), 0, (char *)"Blue component."}, - {(char *)"a", T_UBYTE, offsetof(PySfColor, a), 0, (char *)"Alpha (transparency) component."}, - {NULL} /* Sentinel */ -}; - - - -static void -PySfColor_dealloc(PySfColor *self) -{ - delete self->obj; - free_object(self); -} - -void -PySfColorUpdate(PySfColor *self) -{ - self->obj->r = self->r; - self->obj->g = self->g; - self->obj->b = self->b; - self->obj->a = self->a; -} - -static PyObject * -PySfColor_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PySfColor *self; - self = (PySfColor *)type->tp_alloc(type, 0); - if (self != NULL) - { - self->r = 0; - self->g = 0; - self->b = 0; - self->a = 255; - self->obj = new sf::Color(0, 0, 0, 255); - } - return (PyObject *)self; -} - -static int -PySfColor_init(PySfColor *self, PyObject *args, PyObject *kwds) -{ - const char *kwlist[] = {"r", "g", "b", "a", NULL}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "BBB|B:Color.__init__", (char **)kwlist, &(self->r), &(self->g), &(self->b), &(self->a))) - return -1; - PySfColorUpdate(self); - return 0; -} - -PyTypeObject PySfColorType = { - head_init - "Color", /*tp_name*/ - sizeof(PySfColor), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - (destructor)PySfColor_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash */ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ - "sf.Color is an utility class for manipulating 32-bits RGBA colors.", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - PySfColor_members, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc)PySfColor_init, /* tp_init */ - 0, /* tp_alloc */ - PySfColor_new, /* tp_new */ -}; - -PySfColor * -GetNewPySfColor() -{ - return PyObject_New(PySfColor, &PySfColorType); -} - -void -PySfColor_InitConst() -{ - PySfColor *Black, *White, *Red, *Green, *Blue, *Yellow, *Magenta, *Cyan; - Black = GetNewPySfColor(); - Black->obj = (sf::Color *) &(sf::Color::Black); - Black->r = sf::Color::Black.r; - Black->g = sf::Color::Black.g; - Black->b = sf::Color::Black.b; - Black->a = sf::Color::Black.a; - PyDict_SetItemString(PySfColorType.tp_dict, "Black", (PyObject *)Black); - Py_DECREF(Black); - White = GetNewPySfColor(); - White->obj = (sf::Color *) &(sf::Color::White); - White->r = sf::Color::White.r; - White->g = sf::Color::White.g; - White->b = sf::Color::White.b; - White->a = sf::Color::White.a; - PyDict_SetItemString(PySfColorType.tp_dict, "White", (PyObject *)White); - Py_DECREF(White); - Red = GetNewPySfColor(); - Red->obj = (sf::Color *) &(sf::Color::Red); - Red->r = sf::Color::Red.r; - Red->g = sf::Color::Red.g; - Red->b = sf::Color::Red.b; - Red->a = sf::Color::Red.a; - PyDict_SetItemString(PySfColorType.tp_dict, "Red", (PyObject *)Red); - Py_DECREF(Red); - Green = GetNewPySfColor(); - Green->obj = (sf::Color *) &(sf::Color::Green); - Green->r = sf::Color::Green.r; - Green->g = sf::Color::Green.g; - Green->b = sf::Color::Green.b; - Green->a = sf::Color::Green.a; - PyDict_SetItemString(PySfColorType.tp_dict, "Green", (PyObject *)Green); - Py_DECREF(Green); - Blue = GetNewPySfColor(); - Blue->obj = (sf::Color *) &(sf::Color::Blue); - Blue->r = sf::Color::Blue.r; - Blue->g = sf::Color::Blue.g; - Blue->b = sf::Color::Blue.b; - Blue->a = sf::Color::Blue.a; - PyDict_SetItemString(PySfColorType.tp_dict, "Blue", (PyObject *)Blue); - Py_DECREF(Blue); - Yellow = GetNewPySfColor(); - Yellow->obj = (sf::Color *) &(sf::Color::Yellow); - Yellow->r = sf::Color::Yellow.r; - Yellow->g = sf::Color::Yellow.g; - Yellow->b = sf::Color::Yellow.b; - Yellow->a = sf::Color::Yellow.a; - PyDict_SetItemString(PySfColorType.tp_dict, "Yellow", (PyObject *)Yellow); - Py_DECREF(Yellow); - Magenta = GetNewPySfColor(); - Magenta->obj = (sf::Color *) &(sf::Color::Magenta); - Magenta->r = sf::Color::Magenta.r; - Magenta->g = sf::Color::Magenta.g; - Magenta->b = sf::Color::Magenta.b; - Magenta->a = sf::Color::Magenta.a; - PyDict_SetItemString(PySfColorType.tp_dict, "Magenta", (PyObject *)Magenta); - Py_DECREF(Magenta); - Cyan = GetNewPySfColor(); - Cyan->obj = (sf::Color *) &(sf::Color::Cyan); - Cyan->r = sf::Color::Cyan.r; - Cyan->g = sf::Color::Cyan.g; - Cyan->b = sf::Color::Cyan.b; - Cyan->a = sf::Color::Cyan.a; - PyDict_SetItemString(PySfColorType.tp_dict, "Cyan", (PyObject *)Cyan); - Py_DECREF(Cyan); -} - diff --git a/bindings/python/src/Color.hpp b/bindings/python/src/Color.hpp deleted file mode 100644 index d86ed7f4..00000000 --- a/bindings/python/src/Color.hpp +++ /dev/null @@ -1,52 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// PySFML - Python binding for SFML (Simple and Fast Multimedia Library) -// Copyright (C) 2007, 2008 Rémi Koenig (remi.k2620@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#ifndef __PYCOLOR_HPP -#define __PYCOLOR_HPP - -#include -#include - -#include - - -typedef struct { - PyObject_HEAD - unsigned char r; - unsigned char g; - unsigned char b; - unsigned char a; - sf::Color *obj; -} PySfColor; - -PySfColor * -GetNewPySfColor(); - -void -PySfColorUpdate(PySfColor *self); - -void -PySfColor_InitConst(); - -#endif diff --git a/bindings/python/src/ContextSettings.cpp b/bindings/python/src/ContextSettings.cpp deleted file mode 100644 index 6537858d..00000000 --- a/bindings/python/src/ContextSettings.cpp +++ /dev/null @@ -1,125 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// PySFML - Python binding for SFML (Simple and Fast Multimedia Library) -// Copyright (C) 2007, 2008 Rémi Koenig (remi.k2620@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#include "ContextSettings.hpp" - -#include - -#include "offsetof.hpp" -#include "compat.hpp" - -static PyMemberDef PySfContextSettings_members[] = { - {(char *)"DepthBits", T_UINT, offsetof(PySfContextSettings, DepthBits), 0, (char *)"Depth buffer bits (24 by default)"}, - {(char *)"StencilBits", T_UINT, offsetof(PySfContextSettings, StencilBits), 0, (char *)"Stencil buffer bits (8 by default)"}, - {(char *)"AntialiasingLevel", T_UINT, offsetof(PySfContextSettings, AntialiasingLevel), 0, (char *)"Antialiasing level (0 by default)"}, - {(char *)"MajorVersion", T_UINT, offsetof(PySfContextSettings, MajorVersion), 0, (char *)"Major number of the context version to create. (2 by default)"}, - {(char *)"MinorVersion", T_UINT, offsetof(PySfContextSettings, MinorVersion), 0, (char *)"Minor number of the context version to create. (0 by default)"}, - {NULL} /* Sentinel */ -}; - - -static void -PySfContextSettings_dealloc(PySfContextSettings *self) -{ - delete self->obj; - free_object(self); -} - -void -PySfContextSettingsUpdate(PySfContextSettings *self) -{ - self->obj->DepthBits = self->DepthBits; - self->obj->StencilBits = self->StencilBits; - self->obj->AntialiasingLevel = self->AntialiasingLevel; - self->obj->MajorVersion = self->MajorVersion; - self->obj->MinorVersion = self->MinorVersion; -} - -static PyObject * -PySfContextSettings_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - const char *kwlist[] = {"DepthBits", "StencilBits", "AntialiasingLevel", "MajorVersion", "MinorVersion", NULL}; - PySfContextSettings *self; - self = (PySfContextSettings *)type->tp_alloc(type, 0); - if (self != NULL) - { - self->DepthBits = 24; - self->StencilBits = 8; - self->AntialiasingLevel = 0; - self->MajorVersion = 2; - self->MinorVersion = 0; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "|IIIII:ContextSettings.__init__", (char **)kwlist, &(self->DepthBits), &(self->StencilBits), &(self->AntialiasingLevel), &(self->MajorVersion), &(self->MinorVersion))) - return NULL; - self->obj = new sf::ContextSettings(self->DepthBits, self->StencilBits, self->AntialiasingLevel, self->MajorVersion, self->MinorVersion); - } - return (PyObject *)self; -} - -PyTypeObject PySfContextSettingsType = { - head_init - "ContextSettings", /*tp_name*/ - sizeof(PySfContextSettings), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - (destructor)PySfContextSettings_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash */ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ - "Structure defining the creation settings of windows.", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - PySfContextSettings_members, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PySfContextSettings_new, /* tp_new */ -}; - -PySfContextSettings * -GetNewPySfContextSettings() -{ - return PyObject_New(PySfContextSettings, &PySfContextSettingsType); -} - diff --git a/bindings/python/src/ContextSettings.hpp b/bindings/python/src/ContextSettings.hpp deleted file mode 100644 index d8b09a1a..00000000 --- a/bindings/python/src/ContextSettings.hpp +++ /dev/null @@ -1,49 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// PySFML - Python binding for SFML (Simple and Fast Multimedia Library) -// Copyright (C) 2007, 2008 Rémi Koenig (remi.k2620@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#ifndef __PYWINDOWSETTINGS_HPP -#define __PYWINDOWSETTINGS_HPP - -#include - -#include - - -typedef struct { - PyObject_HEAD - unsigned int DepthBits; - unsigned int StencilBits; - unsigned int AntialiasingLevel; - unsigned int MajorVersion; - unsigned int MinorVersion; - sf::ContextSettings *obj; -} PySfContextSettings; - -void -PySfContextSettingsUpdate(PySfContextSettings *self); - -PySfContextSettings * -GetNewPySfContextSettings(); - -#endif diff --git a/bindings/python/src/Drawable.cpp b/bindings/python/src/Drawable.cpp deleted file mode 100644 index 33b37eeb..00000000 --- a/bindings/python/src/Drawable.cpp +++ /dev/null @@ -1,325 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// PySFML - Python binding for SFML (Simple and Fast Multimedia Library) -// Copyright (C) 2007, 2008 Rémi Koenig (remi.k2620@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#include "Drawable.hpp" -#include "Color.hpp" - -#include "compat.hpp" - - -extern PyTypeObject PySfColorType; - - -void CustomDrawable::Render(sf::RenderTarget& Target, sf::RenderQueue& Queue) const -{ - if (RenderFunction) - PyObject_CallFunction(RenderFunction, (char *)"OO", RenderWindow, Queue); - else - { - PyErr_SetString(PyExc_RuntimeError, "Custom drawables must have a render method defined"); - PyErr_Print(); - } -} - -static void -PySfDrawable_dealloc(PySfDrawable *self) -{ - delete self->obj; - free_object(self); -} - -static PyObject * -PySfDrawable_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PySfDrawable *self; - self = (PySfDrawable *)type->tp_alloc(type, 0); - if (self != NULL) - { - self->IsCustom = true; - self->obj = new CustomDrawable(); - if (PyObject_HasAttrString((PyObject *)self, "Render")) - self->obj->RenderFunction = PyObject_GetAttrString((PyObject *)self, "Render"); - else - self->obj->RenderFunction = NULL; - self->obj->RenderWindow = NULL; - } - return (PyObject *)self; -} - -static PyObject * -PySfDrawable_SetX(PySfDrawable* self, PyObject *args) -{ - self->obj->SetX(PyFloat_AsDouble(args)); - Py_RETURN_NONE; -} -static PyObject * -PySfDrawable_SetY(PySfDrawable* self, PyObject *args) -{ - self->obj->SetY(PyFloat_AsDouble(args)); - Py_RETURN_NONE; -} -static PyObject * -PySfDrawable_SetScale(PySfDrawable* self, PyObject *args) -{ - float ScaleX, ScaleY; - if (!PyArg_ParseTuple(args, "ff:Drawable.SetScale", &ScaleX, &ScaleY) ) - return NULL; - self->obj->SetScale(ScaleX, ScaleY); - Py_RETURN_NONE; -} -static PyObject * -PySfDrawable_SetScaleX(PySfDrawable* self, PyObject *args) -{ - self->obj->SetScaleX(PyFloat_AsDouble(args)); - Py_RETURN_NONE; -} -static PyObject * -PySfDrawable_SetScaleY(PySfDrawable* self, PyObject *args) -{ - self->obj->SetScaleY(PyFloat_AsDouble(args)); - Py_RETURN_NONE; -} - -static PyObject * -PySfDrawable_SetRotation(PySfDrawable* self, PyObject *args) -{ - self->obj->SetRotation(PyFloat_AsDouble(args)); - Py_RETURN_NONE; -} -static PyObject * -PySfDrawable_SetOrigin(PySfDrawable* self, PyObject *args) -{ - float x, y; - if (!PyArg_ParseTuple(args, "ff:Drawable.SetOrigin", &x, &y) ) - return NULL; - self->obj->SetOrigin(x, y); - Py_RETURN_NONE; -} -static PyObject * -PySfDrawable_GetOrigin(PySfDrawable* self) -{ - sf::Vector2f Vect = self->obj->GetOrigin(); - return Py_BuildValue("ff", Vect.x, Vect.y); -} - -static PyObject * -PySfDrawable_SetColor(PySfDrawable* self, PyObject *args) -{ - PySfColor *Color = (PySfColor *)args; - if (!PyObject_TypeCheck(args, &PySfColorType)) - { - PyErr_SetString(PyExc_TypeError, "Drawable.SetColor() Argument is not a sf.Color"); - return NULL; - } - PySfColorUpdate(Color); - self->obj->SetColor(*(Color->obj)); - Py_RETURN_NONE; -} -static PyObject * -PySfDrawable_GetPosition(PySfDrawable* self) -{ - sf::Vector2f Vect = self->obj->GetPosition(); - return Py_BuildValue("ff", Vect.x, Vect.y); -} -static PyObject * -PySfDrawable_GetScale(PySfDrawable* self) -{ - sf::Vector2f Vect = self->obj->GetScale(); - return Py_BuildValue("ff", Vect.x, Vect.y); -} -static PyObject * -PySfDrawable_GetRotation(PySfDrawable* self) -{ - return PyFloat_FromDouble(self->obj->GetRotation()); -} - -static PyObject * -PySfDrawable_GetColor(PySfDrawable* self) -{ - PySfColor *Color; - - Color = GetNewPySfColor(); - Color->obj = new sf::Color( self->obj->GetColor() ); - Color->r = Color->obj->r; - Color->g = Color->obj->g; - Color->b = Color->obj->b; - Color->a = Color->obj->a; - - return (PyObject *)Color; -} -static PyObject * -PySfDrawable_Move(PySfDrawable* self, PyObject *args) -{ - float x, y; - if (!PyArg_ParseTuple(args, "ff:Drawable.Move", &x, &y) ) - return NULL; - self->obj->Move(x, y); - Py_RETURN_NONE; -} -static PyObject * -PySfDrawable_Rotate(PySfDrawable* self, PyObject *args) -{ - self->obj->Rotate(PyFloat_AsDouble(args)); - Py_RETURN_NONE; -} -static PyObject * -PySfDrawable_Scale(PySfDrawable* self, PyObject *args) -{ - float FactorX, FactorY; - if (!PyArg_ParseTuple(args, "ff:Drawable.Scale", &FactorX, &FactorY) ) - return NULL; - self->obj->Scale(FactorX, FactorY); - Py_RETURN_NONE; -} - -static PyObject * -PySfDrawable_SetBlendMode(PySfDrawable* self, PyObject *args) -{ - self->obj->SetBlendMode((sf::Blend::Mode)PyLong_AsUnsignedLong(args)); - Py_RETURN_NONE; -} - -static PyObject * -PySfDrawable_SetPosition(PySfDrawable* self, PyObject *args) -{ - float Left, Top; - if (!PyArg_ParseTuple(args, "ff:Drawable.SetPosition", &Left, &Top) ) - return NULL; - self->obj->SetPosition(Left, Top); - Py_RETURN_NONE; -} - -static PyObject * -PySfDrawable_TransformToLocal(PySfDrawable* self, PyObject *args) -{ - float X, Y; - if (!PyArg_ParseTuple(args, "ff:Drawable.TransformToLocal", &X, &Y) ) - return NULL; - sf::Vector2f result = self->obj->TransformToLocal(sf::Vector2f(X, Y)); - return Py_BuildValue("ff", result.x, result.y); -} - -static PyObject * -PySfDrawable_TransformToGlobal(PySfDrawable* self, PyObject *args) -{ - float X, Y; - if (!PyArg_ParseTuple(args, "ff:Drawable.TransformToGlobal", &X, &Y) ) - return NULL; - sf::Vector2f result = self->obj->TransformToGlobal(sf::Vector2f(X, Y)); - return Py_BuildValue("ff", result.x, result.y); -} - -int PySfDrawable_setattro(PyObject* self, PyObject *attr_name, PyObject *v) -{ -#ifdef IS_PY3K - PyObject *string = PyUnicode_AsUTF8String(attr_name); - if (string == NULL) return NULL; - std::string Name(PyBytes_AsString(string)); -#else - std::string Name(PyString_AsString(attr_name)); -#endif - if (Name == "Render") - { - Py_CLEAR(((PySfDrawable*)self)->obj->RenderFunction); - Py_INCREF(v); - ((PySfDrawable*)self)->obj->RenderFunction = v; - } -#ifdef IS_PY3K - Py_DECREF(string); -#endif - return PyObject_GenericSetAttr(self, attr_name, v); -} - -static PyMethodDef PySfDrawable_methods[] = { - {"TransformToLocal", (PyCFunction)PySfDrawable_TransformToLocal, METH_VARARGS, "TransformToLocal(X, Y)\n\ -Transform a point from global coordinates into local coordinates (ie it applies the inverse of object's origin, translation, rotation and scale to the point). Returns a tuple.\n\ - X : X coordinate of the point to transform\n\ - Y : Y coordinate of the point to transform"}, - {"TransformToGlobal", (PyCFunction)PySfDrawable_TransformToGlobal, METH_VARARGS, "TransformToGlobal(X, Y)\n\ -Transform a point from local coordinates into global coordinates (ie it applies the object's origin, translation, rotation and scale to the point). Returns a tuple.\n\ - X : X coordinate of the point to transform\n\ - Y : Y coordinate of the point to transform"}, - {"SetX", (PyCFunction)PySfDrawable_SetX, METH_O, "SetX(X)\nSet the X position of the object.\n X : New X coordinate"}, - {"SetY", (PyCFunction)PySfDrawable_SetY, METH_O, "SetY(Y)\nSet the Y position of the object.\n Y : New Y coordinate"}, - {"SetScale", (PyCFunction)PySfDrawable_SetScale, METH_VARARGS, "SetScale(ScaleX, ScaleY)\nSet the scale of the object.\n ScaleX : New horizontal scale (must be strictly positive)\n ScaleY : New vertical scale (must be strictly positive)"}, - {"SetScaleX", (PyCFunction)PySfDrawable_SetScaleX, METH_O, "SetScaleX(ScaleX)\nSet the X scale factor of the object.\n ScaleX : New horizontal scale (must be strictly positive)"}, - {"SetScaleY", (PyCFunction)PySfDrawable_SetScaleY, METH_O, "SetScaleY(ScaleY)\nSet the Y scale factor of the object.\n ScaleY : New vertical scale (must be strictly positive)"}, - {"SetRotation", (PyCFunction)PySfDrawable_SetRotation, METH_O, "SetRotation(Rotation)\nSet the orientation of the object.\n Rotation : Angle of rotation, in degrees"}, - {"SetOrigin", (PyCFunction)PySfDrawable_SetOrigin, METH_VARARGS, "SetOrigin(OriginX, OriginY)\nSet the origin of the object, in coordinates relative to the object.\n OriginX : X coordinate of the origin\n OriginY : Y coordinate of the origin"}, - {"GetOrigin", (PyCFunction)PySfDrawable_GetOrigin, METH_NOARGS, "GetOrigin()\nGet the origin of the object, in coordinates relative to the object."}, - {"SetColor", (PyCFunction)PySfDrawable_SetColor, METH_O, "SetColor(Color)\nSet the color of the object.\n Color : New color"}, - {"GetPosition", (PyCFunction)PySfDrawable_GetPosition, METH_NOARGS, "GetPosition()\nGet the position of the object."}, - {"GetScale", (PyCFunction)PySfDrawable_GetScale, METH_NOARGS, "GetScale()\nGet the scale of the object."}, - {"GetRotation", (PyCFunction)PySfDrawable_GetRotation, METH_NOARGS, "GetRotation()\nGet the orientation of the object."}, - {"GetColor", (PyCFunction)PySfDrawable_GetColor, METH_NOARGS, "GetColor()\nGet the color of the object."}, - {"Move", (PyCFunction)PySfDrawable_Move, METH_VARARGS, "Move(OffsetX, OffsetY)\nMove the object.\n OffsetX : X offset\n OffsetY : Y offset "}, - {"Scale", (PyCFunction)PySfDrawable_Scale, METH_VARARGS, "Scale(FactorX, FactorY)\nScale the object.\n FactorX : Scaling factor on X (must be strictly positive)\n FactorY : Scaling factor on Y (must be strictly positive)"}, - {"Rotate", (PyCFunction)PySfDrawable_Rotate, METH_O, "Rotate(Angle)\nRotate the object.\n Angle : Angle of rotation, in degrees"}, - {"SetBlendMode", (PyCFunction)PySfDrawable_SetBlendMode, METH_O, "SetBlendMode(Mode)\nSet the blending mode for the object. The default blend mode is sf.Blend.Alpha\n Mode : New blending mode"}, - {"SetPosition", (PyCFunction)PySfDrawable_SetPosition, METH_VARARGS, "SetPosition(X, Y)\nSet the position of the object.\n X : New X coordinate\n Y : New Y coordinate"}, - {NULL} /* Sentinel */ -}; - -PyTypeObject PySfDrawableType = { - head_init - "Drawable", /*tp_name*/ - sizeof(PySfDrawable), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - (destructor)PySfDrawable_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash */ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - PySfDrawable_setattro, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ - "Abstract base class for every object that can be drawn into a render window.", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - PySfDrawable_methods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PySfDrawable_new, /* tp_new */ -}; - - diff --git a/bindings/python/src/Drawable.hpp b/bindings/python/src/Drawable.hpp deleted file mode 100644 index 12af4fe6..00000000 --- a/bindings/python/src/Drawable.hpp +++ /dev/null @@ -1,53 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// PySFML - Python binding for SFML (Simple and Fast Multimedia Library) -// Copyright (C) 2007, 2008 Rémi Koenig (remi.k2620@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#ifndef __PYDRAWABLE_H -#define __PYDRAWABLE_H - -#include - -#include -#include - -#include "RenderWindow.hpp" -#include "RenderQueue.hpp" - -class CustomDrawable : public sf::Drawable -{ -protected : - virtual void Render(sf::RenderTarget& Target, sf::RenderQueue& Queue) const; -public : - PySfRenderWindow *RenderWindow; - PyObject *RenderFunction; -}; - - -typedef struct { - PyObject_HEAD - bool IsCustom; - CustomDrawable *obj; -} PySfDrawable; - -#endif - diff --git a/bindings/python/src/Event.cpp b/bindings/python/src/Event.cpp deleted file mode 100644 index 449295de..00000000 --- a/bindings/python/src/Event.cpp +++ /dev/null @@ -1,780 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// PySFML - Python binding for SFML (Simple and Fast Multimedia Library) -// Copyright (C) 2007, 2008 Rémi Koenig (remi.k2620@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#include "Event.hpp" - -#include - -#include "compat.hpp" - -//////////////////////////////// -// Text Events Parameters -//////////////////////////////// - -PyMemberDef PySfEventText_members[] = { - {(char *)"Unicode", T_USHORT, offsetof(PySfEventText, Unicode), READONLY, (char *)""}, - {NULL} /* Sentinel */ -}; - -static PyObject * -PySfEventText_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PySfEventText *self; - - self = (PySfEventText *)type->tp_alloc(type, 0); - if (self != NULL) - { - self->Unicode = 0; - } - - return (PyObject *)self; -} - -void -PySfEventText_dealloc(PySfEventText* self) -{ - free_object(self); -} - -PyTypeObject PySfEventTextType = { - head_init - "Event.Text", /*tp_name*/ - sizeof(PySfEventText), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - (destructor)PySfEventText_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash */ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT, /*tp_flags*/ - "Text Events Parameters", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - PySfEventText_members, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PySfEventText_new, /* tp_new */ -}; - - - -///////////////////////////////////// -// Keyboard Events Parameters -///////////////////////////////////// - -static PyObject * -PySfEventKey_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PySfEventKey *self; - - self = (PySfEventKey *)type->tp_alloc(type, 0); - if (self != NULL) - { - Py_INCREF(Py_False); - self->Alt = Py_False; - Py_INCREF(Py_False); - self->Control = Py_False; - Py_INCREF(Py_False); - self->Shift = Py_False; - } - - return (PyObject *)self; -} - -void -PySfEventKey_dealloc(PySfEventKey* self) -{ - free_object(self); -} - -PyMemberDef PySfEventKey_members[] = { - {(char *)"Alt", T_OBJECT, offsetof(PySfEventKey, Alt), READONLY, (char *)""}, - {(char *)"Control", T_OBJECT, offsetof(PySfEventKey, Control), READONLY, (char *)""}, - {(char *)"Shift", T_OBJECT, offsetof(PySfEventKey, Shift), READONLY, (char *)""}, - {(char *)"Code", T_UINT, offsetof(PySfEventKey, Code), READONLY, (char *)""}, - {NULL} /* Sentinel */ -}; - -PyTypeObject PySfEventKeyType = { - head_init - "Event.Key", /*tp_name*/ - sizeof(PySfEventKey), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - (destructor)PySfEventKey_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash */ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT, /*tp_flags*/ - "Key Events Parameters", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - PySfEventKey_members, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PySfEventKey_new, /* tp_new */ -}; - - -//////////////////////////////////// -// MouseMove Events Parameters -//////////////////////////////////// - -static PyObject * -PySfEventMouseMove_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PySfEventMouseMove *self; - - self = (PySfEventMouseMove *)type->tp_alloc(type, 0); - if (self != NULL) - { - self->X = 0; - self->Y = 0; - } - - return (PyObject *)self; -} - -void -PySfEventMouseMove_dealloc(PySfEventMouseMove *self) -{ - free_object(self); -} - - -PyMemberDef PySfEventMouseMove_members[] = { - {(char *)"X", T_INT, offsetof(PySfEventMouseMove, X), READONLY, (char *)""}, - {(char *)"Y", T_INT, offsetof(PySfEventMouseMove, Y), READONLY, (char *)""}, - {NULL} /* Sentinel */ -}; - -PyTypeObject PySfEventMouseMoveType = { - head_init - "Event.MouseMove", /*tp_name*/ - sizeof(PySfEventMouseMove), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - (destructor)PySfEventMouseMove_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash */ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT, /*tp_flags*/ - "MouseMove Events Parameters", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - PySfEventMouseMove_members, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PySfEventMouseMove_new, /* tp_new */ -}; - - -//////////////////////////////////// -// MouseButton Events Parameters -//////////////////////////////////// - -static PyObject * -PySfEventMouseButton_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PySfEventMouseButton *self; - - self = (PySfEventMouseButton *)type->tp_alloc(type, 0); - if (self != NULL) - { - self->Button = 0; - self->X = 0; - self->Y = 0; - } - - return (PyObject *)self; -} - -void -PySfEventMouseButton_dealloc(PySfEventMouseButton* self) -{ - free_object(self); -} - - -PyMemberDef PySfEventMouseButton_members[] = { - {(char *)"Button", T_UINT, offsetof(PySfEventMouseButton, Button), READONLY, (char *)""}, - {(char *)"X", T_INT, offsetof(PySfEventMouseButton, X), READONLY, (char *)""}, - {(char *)"Y", T_INT, offsetof(PySfEventMouseButton, Y), READONLY, (char *)""}, - {NULL} /* Sentinel */ -}; - -PyTypeObject PySfEventMouseButtonType = { - head_init - "Event.MouseButton", /*tp_name*/ - sizeof(PySfEventMouseButton), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - (destructor)PySfEventMouseButton_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash */ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT, /*tp_flags*/ - "MouseButton Events Parameters", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - PySfEventMouseButton_members, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PySfEventMouseButton_new, /* tp_new */ -}; - - -//////////////////////////////// -// MouseWheel Events Parameters -//////////////////////////////// - -static PyObject * -PySfEventMouseWheel_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PySfEventMouseWheel *self; - - self = (PySfEventMouseWheel *)type->tp_alloc(type, 0); - if (self != NULL) - { - self->Delta = 0; - } - - return (PyObject *)self; -} - -void -PySfEventMouseWheel_dealloc(PySfEventMouseWheel* self) -{ - free_object(self); -} - -PyMemberDef PySfEventMouseWheel_members[] = { - {(char *)"Delta", T_INT, offsetof(PySfEventMouseWheel,Delta), READONLY, (char *)""}, - {NULL} /* Sentinel */ -}; - -PyTypeObject PySfEventMouseWheelType = { - head_init - "Event.MouseWheel", /*tp_name*/ - sizeof(PySfEventMouseWheel), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - (destructor)PySfEventMouseWheel_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash */ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT, /*tp_flags*/ - "MouseWheel Events Parameters", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - PySfEventMouseWheel_members, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PySfEventMouseWheel_new, /* tp_new */ -}; - - -//////////////////////////////////// -// JoyMove Events Parameters -//////////////////////////////////// - -static PyObject * -PySfEventJoyMove_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PySfEventJoyMove *self; - - self = (PySfEventJoyMove *)type->tp_alloc(type, 0); - if (self != NULL) - { - self->JoystickId = 0; - self->Axis = 0; - self->Position = 0.f; - } - - return (PyObject *)self; -} - -void -PySfEventJoyMove_dealloc(PySfEventJoyMove* self) -{ - free_object(self); -} - - -PyMemberDef PySfEventJoyMove_members[] = { - {(char *)"JoystickId", T_UINT, offsetof(PySfEventJoyMove,JoystickId), READONLY, (char *)""}, - {(char *)"Axis", T_UINT, offsetof(PySfEventJoyMove,Axis), READONLY, (char *)""}, - {(char *)"Position", T_FLOAT, offsetof(PySfEventJoyMove,Position), READONLY, (char *)""}, - {NULL} /* Sentinel */ -}; - -PyTypeObject PySfEventJoyMoveType = { - head_init - "Event.JoyMove", /*tp_name*/ - sizeof(PySfEventJoyMove), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - (destructor)PySfEventJoyMove_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash */ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT, /*tp_flags*/ - "JoyMove Events Parameters", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - PySfEventJoyMove_members, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PySfEventJoyMove_new, /* tp_new */ -}; - - -//////////////////////////////////// -// JoyButton Events Parameters -//////////////////////////////////// - -static PyObject * -PySfEventJoyButton_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PySfEventJoyButton *self; - - self = (PySfEventJoyButton *)type->tp_alloc(type, 0); - if (self != NULL) - { - self->JoystickId = 0; - self->Button = 0; - } - - return (PyObject *)self; -} - -void -PySfEventJoyButton_dealloc(PySfEventJoyButton* self) -{ - free_object(self); -} - - -PyMemberDef PySfEventJoyButton_members[] = { - {(char *)"JoystickId", T_UINT, offsetof(PySfEventJoyButton, JoystickId), READONLY, (char *)""}, - {(char *)"Button", T_UINT, offsetof(PySfEventJoyButton, Button), READONLY, (char *)""}, - {NULL} /* Sentinel */ -}; - -PyTypeObject PySfEventJoyButtonType = { - head_init - "Event.JoyButton", /*tp_name*/ - sizeof(PySfEventJoyButton), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - (destructor)PySfEventJoyButton_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash */ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT, /*tp_flags*/ - "JoyButton Events Parameters", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - PySfEventJoyButton_members, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PySfEventJoyButton_new, /* tp_new */ -}; - - -//////////////////////////////////// -// Size Events Parameters -//////////////////////////////////// - -static PyObject * -PySfEventSize_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PySfEventSize *self; - - self = (PySfEventSize *)type->tp_alloc(type, 0); - if (self != NULL) - { - self->Width = 0; - self->Height = 0; - } - - return (PyObject *)self; -} - -void -PySfEventSize_dealloc(PySfEventSize* self) -{ - free_object(self); -} - -PyMemberDef PySfEventSize_members[] = { - {(char *)"Width", T_UINT, offsetof(PySfEventSize, Width), READONLY, (char *)""}, - {(char *)"Height", T_UINT, offsetof(PySfEventSize, Height), READONLY, (char *)""}, - {NULL} /* Sentinel */ -}; - -PyTypeObject PySfEventSizeType = { - head_init - "Event.Size", /*tp_name*/ - sizeof(PySfEventSize), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - (destructor)PySfEventSize_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash */ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT, /*tp_flags*/ - "Size Events Parameters", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - PySfEventSize_members, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PySfEventSize_new, /* tp_new */ -}; - - - - - - -//////////////////////////////////// -// sf.Event -//////////////////////////////////// - - -static PyObject * -PySfEvent_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PySfEvent *self; - - self = (PySfEvent *)type->tp_alloc(type, 0); - if (self != NULL) - { - self->Text = (PySfEventText *)PySfEventText_new(&PySfEventTextType, NULL, NULL); - self->Key = (PySfEventKey *)PySfEventKey_new(&PySfEventKeyType, NULL, NULL); - self->MouseMove = (PySfEventMouseMove *)PySfEventMouseMove_new(&PySfEventMouseMoveType, NULL, NULL); - self->MouseButton = (PySfEventMouseButton *)PySfEventMouseButton_new(&PySfEventMouseButtonType, NULL, NULL); - self->MouseWheel = (PySfEventMouseWheel *)PySfEventMouseWheel_new(&PySfEventMouseWheelType, NULL, NULL); - self->JoyMove = (PySfEventJoyMove *)PySfEventJoyMove_new(&PySfEventJoyMoveType, NULL, NULL); - self->JoyButton = (PySfEventJoyButton *)PySfEventJoyButton_new(&PySfEventJoyButtonType, NULL, NULL); - self->Size = (PySfEventSize *)PySfEventSize_new(&PySfEventSizeType, NULL, NULL); - self->obj = new sf::Event(); - } - - return (PyObject *)self; -} - -static void -PySfEvent_dealloc(PySfEvent* self) -{ - Py_DECREF(self->Text); - Py_DECREF(self->Key); - Py_DECREF(self->MouseMove); - Py_DECREF(self->MouseButton); - Py_DECREF(self->MouseWheel); - Py_DECREF(self->JoyMove); - Py_DECREF(self->JoyButton); - Py_DECREF(self->Size); - delete self->obj; - free_object(self); -} - -static PyMemberDef PySfEvent_members[] = { - {(char *)"Text", T_OBJECT, offsetof(PySfEvent, Text), READONLY, (char *)"Text Events Parameters"}, - {(char *)"Key", T_OBJECT, offsetof(PySfEvent, Key), READONLY, (char *)"Keyboard Events Parameters"}, - {(char *)"MouseMove", T_OBJECT, offsetof(PySfEvent, MouseMove), READONLY, (char *)"MouseMove Events Parameters"}, - {(char *)"MouseButton", T_OBJECT, offsetof(PySfEvent, MouseButton), READONLY, (char *)"MouseButton Events Parameters"}, - {(char *)"MouseWheel", T_OBJECT, offsetof(PySfEvent, MouseWheel), READONLY, (char *)"MouseWheel Events Parameters"}, - {(char *)"JoyMove", T_OBJECT, offsetof(PySfEvent, JoyMove), READONLY, (char *)"JoyMove Events Parameters"}, - {(char *)"JoyButton", T_OBJECT, offsetof(PySfEvent, JoyButton), READONLY, (char *)"JoyButton Events Parameters"}, - {(char *)"Size", T_OBJECT, offsetof(PySfEvent, Size), READONLY, (char *)"Size Events Parameters"}, - {(char *)"Type", T_UINT, offsetof(PySfEvent, Type), READONLY, (char *)"Type Events Parameters"}, - {NULL} /* Sentinel */ -}; - -PyTypeObject PySfEventType = { - head_init - "Event", /*tp_name*/ - sizeof(PySfEvent), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - (destructor)PySfEvent_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash */ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ - "sf.Event defines a system event and its parameters", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - PySfEvent_members, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PySfEvent_new, /* tp_new */ -}; - - -void -PySfEvent_InitConst() -{ - PyObject *obj; - obj = PyLong_FromLong(sf::Event::KeyReleased); - PyDict_SetItemString(PySfEventType.tp_dict, "KeyReleased", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Event::LostFocus); - PyDict_SetItemString(PySfEventType.tp_dict, "LostFocus", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Event::GainedFocus); - PyDict_SetItemString(PySfEventType.tp_dict, "GainedFocus", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Event::KeyPressed); - PyDict_SetItemString(PySfEventType.tp_dict, "KeyPressed", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Event::MouseWheelMoved); - PyDict_SetItemString(PySfEventType.tp_dict, "MouseWheelMoved", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Event::TextEntered); - PyDict_SetItemString(PySfEventType.tp_dict, "TextEntered", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Event::MouseMoved); - PyDict_SetItemString(PySfEventType.tp_dict, "MouseMoved", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Event::JoyButtonPressed); - PyDict_SetItemString(PySfEventType.tp_dict, "JoyButtonPressed", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Event::MouseButtonReleased); - PyDict_SetItemString(PySfEventType.tp_dict, "MouseButtonReleased", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Event::Closed); - PyDict_SetItemString(PySfEventType.tp_dict, "Closed", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Event::MouseButtonPressed); - PyDict_SetItemString(PySfEventType.tp_dict, "MouseButtonPressed", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Event::JoyMoved); - PyDict_SetItemString(PySfEventType.tp_dict, "JoyMoved", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Event::JoyButtonReleased); - PyDict_SetItemString(PySfEventType.tp_dict, "JoyButtonReleased", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Event::Resized); - PyDict_SetItemString(PySfEventType.tp_dict, "Resized", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Event::MouseEntered); - PyDict_SetItemString(PySfEventType.tp_dict, "MouseEntered", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Event::MouseLeft); - PyDict_SetItemString(PySfEventType.tp_dict, "MouseLeft", obj); - Py_DECREF(obj); -} - diff --git a/bindings/python/src/Event.hpp b/bindings/python/src/Event.hpp deleted file mode 100644 index fa8f8fa4..00000000 --- a/bindings/python/src/Event.hpp +++ /dev/null @@ -1,105 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// PySFML - Python binding for SFML (Simple and Fast Multimedia Library) -// Copyright (C) 2007, 2008 Rémi Koenig (remi.k2620@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#ifndef __PYEVENT_HPP -#define __PYEVENT_HPP - -#include - -#include - -typedef struct -{ - PyObject_HEAD - unsigned int short Unicode; -} PySfEventText; - -typedef struct -{ - PyObject_HEAD - PyObject *Alt; - PyObject *Control; - PyObject *Shift; - unsigned int Code; -} PySfEventKey; - -typedef struct -{ - PyObject_HEAD - int X; - int Y; -} PySfEventMouseMove; - -typedef struct -{ - PyObject_HEAD - unsigned int Button; - int X; - int Y; -} PySfEventMouseButton; - -typedef struct -{ - PyObject_HEAD - int Delta; -} PySfEventMouseWheel; - -typedef struct { - PyObject_HEAD - unsigned int JoystickId; - unsigned int Axis; - float Position; -} PySfEventJoyMove; - -typedef struct { - PyObject_HEAD - unsigned int JoystickId; - unsigned int Button; -} PySfEventJoyButton; - -typedef struct -{ - PyObject_HEAD - unsigned int Width; - unsigned int Height; -} PySfEventSize; - -typedef struct { - PyObject_HEAD - PySfEventText *Text; - PySfEventKey *Key; - PySfEventMouseMove *MouseMove; - PySfEventMouseButton *MouseButton; - PySfEventMouseWheel *MouseWheel; - PySfEventJoyMove *JoyMove; - PySfEventJoyButton *JoyButton; - PySfEventSize *Size; - unsigned int Type; - sf::Event *obj; -} PySfEvent; - -void -PySfEvent_InitConst(); - -#endif diff --git a/bindings/python/src/Font.cpp b/bindings/python/src/Font.cpp deleted file mode 100644 index f2475ce3..00000000 --- a/bindings/python/src/Font.cpp +++ /dev/null @@ -1,200 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// PySFML - Python binding for SFML (Simple and Fast Multimedia Library) -// Copyright (C) 2007, 2008 Rémi Koenig (remi.k2620@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#include "Font.hpp" -#include "Glyph.hpp" -#include "Image.hpp" - -#include "compat.hpp" - - -static void -PySfFont_dealloc(PySfFont *self) -{ - if (self->Owner) - delete self->obj; - free_object(self); -} - -static PyObject * -PySfFont_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PySfFont *self; - self = (PySfFont *)type->tp_alloc(type, 0); - if (self != NULL) - { - self->Owner = true; - self->obj = new sf::Font(); - } - return (PyObject *)self; -} - -static PyObject * -PySfFont_LoadFromFile( PySfFont* self, PyObject *args ) { - char* Filename; - bool result; - - if( PyArg_ParseTuple( args, "s:Font.LoadFromFile", &Filename ) ) { - result = self->obj->LoadFromFile(Filename); - } - else { - PyErr_BadArgument(); - return NULL; - } - - return PyBool_FromLong( result ); -} - -static PyObject * -PySfFont_LoadFromMemory( PySfFont* self, PyObject *args ) { - unsigned int Size; - char* Data; - bool result; - - if( PyArg_ParseTuple( args, "s#:Font.LoadFromMemory", &Data, &Size ) ) { - result = self->obj->LoadFromMemory( Data, Size ); - } - else { - PyErr_BadArgument(); - return NULL; - } - - return PyBool_FromLong( result ); -} - -static PyObject * -PySfFont_GetDefaultFont(PySfFont* self, PyObject *args) -{ - PySfFont *DefaultFont = GetNewPySfFont(); - DefaultFont->Owner = false; - DefaultFont->obj = (sf::Font *)&(sf::Font::GetDefaultFont()); - return (PyObject *)DefaultFont; -} - -static PyObject * -PySfFont_GetGlyph(PySfFont* self, PyObject *args) { - unsigned int codepoint( 0 ); - unsigned int charsize( 0 ); - bool bold( false ); - - if( !PyArg_ParseTuple( args, "IIb:Font.LoadFromFile", &codepoint, &charsize, &bold ) ) { - PyErr_BadArgument(); - return NULL; - } - - PySfGlyph* glyph( GetNewPySfGlyph() ); - - glyph->Owner = false; - glyph->Rectangle = GetNewPySfIntRect(); - glyph->Rectangle->Owner = false; - glyph->TexCoords = GetNewPySfFloatRect(); - glyph->TexCoords->Owner = false; - - glyph->obj = const_cast( &( self->obj->GetGlyph( codepoint, charsize, bold ) ) ); - glyph->Rectangle->obj = &glyph->obj->Rectangle; - glyph->TexCoords->obj = &glyph->obj->TexCoords; - - PySfGlyphUpdateSelf( glyph ); - - return reinterpret_cast( glyph ); -} - -static PyObject * -PySfFont_GetImage( PySfFont* self, PyObject* args ) { - PySfImage* image( GetNewPySfImage() ); - - image->obj = new sf::Image( self->obj->GetImage( PyLong_AsUnsignedLong( args ) ) ); - - return reinterpret_cast( image ); -} - -static PyMethodDef PySfFont_methods[] = { - {"LoadFromFile", (PyCFunction)PySfFont_LoadFromFile, METH_VARARGS, "LoadFromFile(Filename))\n\ -Load the font from a file. Returns True if loading was successful.\n\ - Filename : Font file to load"}, - {"LoadFromMemory", (PyCFunction)PySfFont_LoadFromMemory, METH_VARARGS, "LoadFromMemory(Data)\n\ -Load the font from a file in memory. Returns True if loading was successful.\n\ - Data : data to load"}, - {"GetDefaultFont", (PyCFunction)PySfFont_GetDefaultFont, METH_NOARGS | METH_STATIC, "GetDefaultFont()\n\ -Get the SFML default built-in font (Arial)."}, - {"GetImage", (PyCFunction)PySfFont_GetImage, METH_O, "GetImage(characterSize)\n\ -Get the image containing the rendered characters (glyphs).\n\ - characterSize: Character size."}, - {"GetGlyph", (PyCFunction)PySfFont_GetGlyph, METH_VARARGS, "GetGlyph(codePoint, characterSize, bold)\n\ -Get the description of a glyph (character) given by its code point, character size and boldness. Returns glyph's visual settings, or an invalid glyph if character not found.\n\ - codePoint : Unicode code point value of the character to get.\n\ - characterSize: Size of character\n\ - bold: Bold character"}, - {NULL} /* Sentinel */ -}; - - -PyTypeObject PySfFontType = { - head_init - "Font", /*tp_name*/ - sizeof(PySfFont), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - (destructor)PySfFont_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash */ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ - "sf.Font is the low-level class for loading and manipulating character fonts. This class is meant to be used by sf.String.\nDefault constructor : sf.Font().", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - PySfFont_methods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PySfFont_new, /* tp_new */ -}; - -PySfFont * -GetNewPySfFont() -{ - return PyObject_New(PySfFont, &PySfFontType); -} - - diff --git a/bindings/python/src/Font.hpp b/bindings/python/src/Font.hpp deleted file mode 100644 index a8105504..00000000 --- a/bindings/python/src/Font.hpp +++ /dev/null @@ -1,42 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// PySFML - Python binding for SFML (Simple and Fast Multimedia Library) -// Copyright (C) 2007, 2008 Rémi Koenig (remi.k2620@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#ifndef __PYFONT_HPP -#define __PYFONT_HPP - -#include - -#include - - -typedef struct { - PyObject_HEAD - bool Owner; - sf::Font *obj; -} PySfFont; - -PySfFont * -GetNewPySfFont(); - -#endif diff --git a/bindings/python/src/Glyph.cpp b/bindings/python/src/Glyph.cpp deleted file mode 100644 index d805c478..00000000 --- a/bindings/python/src/Glyph.cpp +++ /dev/null @@ -1,145 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// PySFML - Python binding for SFML (Simple and Fast Multimedia Library) -// Copyright (C) 2007, 2008 Rémi Koenig (remi.k2620@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#include "Glyph.hpp" - -#include - -#include "offsetof.hpp" -#include "compat.hpp" - - -static PyMemberDef PySfGlyph_members[] = { - {(char *)"Advance", T_INT, offsetof(PySfGlyph, Advance), 0, (char *)"Offset to move horizontically to the next character."}, - {(char *)"Rectangle", T_OBJECT, offsetof(PySfGlyph, Rectangle), 0, (char *)"Bounding rectangle of the glyph, in relative coordinates."}, - {(char *)"TexCoords", T_OBJECT, offsetof(PySfGlyph, TexCoords), 0, (char *)"Texture coordinates of the glyph inside the bitmap font."}, - {NULL} /* Sentinel */ -}; - - -static void -PySfGlyph_dealloc(PySfGlyph *self) -{ - Py_CLEAR(self->Rectangle); - Py_CLEAR(self->TexCoords); - delete self->obj; - free_object(self); -} - -void -PySfGlyphUpdateObj(PySfGlyph *self) -{ - self->obj->Advance = self->Advance; - PySfIntRectUpdateSelf(self->Rectangle); - PySfFloatRectUpdateSelf(self->TexCoords); -} - -void -PySfGlyphUpdateSelf(PySfGlyph *self) -{ - self->Advance = self->obj->Advance; - PySfIntRectUpdateObj(self->Rectangle); - PySfFloatRectUpdateObj(self->TexCoords); -} - -static PyObject * -PySfGlyph_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PySfGlyph *self; - self = (PySfGlyph *)type->tp_alloc(type, 0); - if (self != NULL) - { - self->Rectangle = GetNewPySfIntRect(); - self->Rectangle->Owner = false; - self->TexCoords = GetNewPySfFloatRect(); - self->TexCoords->Owner = false; - self->obj = new sf::Glyph(); - self->Owner = true; - self->Advance = self->obj->Advance; - self->Rectangle->obj = &(self->obj->Rectangle); - self->TexCoords->obj = &(self->obj->TexCoords); - PySfIntRectUpdateSelf(self->Rectangle); - PySfFloatRectUpdateSelf(self->TexCoords); - } - return (PyObject *)self; -} - -int -PySfGlyph_setattro(PyObject* self, PyObject *attr_name, PyObject *v) -{ - int result = PyObject_GenericSetAttr(self, attr_name, v); - PySfGlyph *Glyph = (PySfGlyph *)self; - Glyph->obj->Rectangle = *(Glyph->Rectangle->obj); - Glyph->obj->TexCoords = *(Glyph->TexCoords->obj); - Glyph->obj->Advance = Glyph->Advance; - return result; -} - -PyTypeObject PySfGlyphType = { - head_init - "Glyph", /*tp_name*/ - sizeof(PySfGlyph), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - (destructor)PySfGlyph_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash */ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ - "Structure describing a glyph (a visual character).", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - PySfGlyph_members, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PySfGlyph_new, /* tp_new */ -}; - -PySfGlyph * -GetNewPySfGlyph() -{ - return PyObject_New(PySfGlyph, &PySfGlyphType); -} - diff --git a/bindings/python/src/Glyph.hpp b/bindings/python/src/Glyph.hpp deleted file mode 100644 index d461b5d1..00000000 --- a/bindings/python/src/Glyph.hpp +++ /dev/null @@ -1,53 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// PySFML - Python binding for SFML (Simple and Fast Multimedia Library) -// Copyright (C) 2007, 2008 Rémi Koenig (remi.k2620@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#ifndef __PYGLYPH_HPP -#define __PYGLYPH_HPP - -#include - -#include - -#include "Rect.hpp" - - -typedef struct { - PyObject_HEAD - bool Owner; - int Advance; - PySfIntRect *Rectangle; - PySfFloatRect *TexCoords; - sf::Glyph *obj; -} PySfGlyph; - -PySfGlyph * -GetNewPySfGlyph(); - -void -PySfGlyphUpdateObj(PySfGlyph *self); - -void -PySfGlyphUpdateSelf(PySfGlyph *self); - -#endif diff --git a/bindings/python/src/Image.cpp b/bindings/python/src/Image.cpp deleted file mode 100644 index 8eee10e4..00000000 --- a/bindings/python/src/Image.cpp +++ /dev/null @@ -1,410 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// PySFML - Python binding for SFML (Simple and Fast Multimedia Library) -// Copyright (C) 2007, 2008 Rémi Koenig (remi.k2620@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#include "Image.hpp" -#include "RenderWindow.hpp" -#include "Color.hpp" -#include "Rect.hpp" - -#include "compat.hpp" - -extern PyTypeObject PySfColorType; -extern PyTypeObject PySfIntRectType; -extern PyTypeObject PySfRenderWindowType; - -static void -PySfImage_dealloc(PySfImage* self) -{ - delete self->obj; - free_object(self); -} - -static PyObject * -PySfImage_new(PyTypeObject *type, PyObject *args, PyObject *kwds); - -static PyObject * -PySfImage_Create(PySfImage* self, PyObject *args, PyObject *kwds) -{ - PySfColor *ColorTmp=NULL; - sf::Color *Color; - unsigned int Width=0, Height=0; - const char *kwlist[] = {"Width", "Height", "Color", NULL}; - - if (!PyArg_ParseTupleAndKeywords(args, kwds, "|IIO!:Image.Create", (char **)kwlist, &Width, &Height, &PySfColorType, &ColorTmp)) - return NULL; - - if (ColorTmp) - { - Color = ColorTmp->obj; - PySfColorUpdate(ColorTmp); - self->obj->Create(Width, Height, *Color); - } - else - self->obj->Create(Width, Height); - - Py_RETURN_NONE; -} - -static PyObject * -PySfImage_CopyScreen(PySfImage* self, PyObject *args) -{ - PySfRenderWindow *RenderWindow; - PySfIntRect *SourceRect=NULL; - bool Result; - - if (!PyArg_ParseTuple(args, "O!|O!:Image.CopyScreen", &PySfRenderWindowType, &RenderWindow, &PySfIntRectType, &SourceRect)) - return NULL; - - - if (SourceRect) - Result = self->obj->CopyScreen(*(RenderWindow->obj), *(SourceRect->obj)); - else - Result = self->obj->CopyScreen(*(RenderWindow->obj)); - if (Result) - Py_RETURN_TRUE; - else - Py_RETURN_FALSE; -} - -static PyObject * -PySfImage_SetPixel(PySfImage* self, PyObject *args, PyObject *kwds) -{ - PySfColor *ColorTmp=NULL; - sf::Color *Color; - unsigned int x=0, y=0; - const char *kwlist[] = {"x", "y", "Color", NULL}; - - - if (!PyArg_ParseTupleAndKeywords(args, kwds, "II|O!:Image.SetPixel", (char **)kwlist, &x, &y, &PySfColorType, &ColorTmp)) - return NULL; - - - if (ColorTmp) - { - Color = ColorTmp->obj; - PySfColorUpdate(ColorTmp); - self->obj->SetPixel(x, y, *Color); - } - - Py_RETURN_NONE; -} - -static PyObject * -PySfImage_GetPixel(PySfImage* self, PyObject *args) -{ - PySfColor *Color; - unsigned int x=0, y=0; - - - if (!PyArg_ParseTuple(args, "II:Image.GetPixel", &x, &y)) - return NULL; - - - Color = GetNewPySfColor(); - Color->obj = new sf::Color(self->obj->GetPixel(x, y)); - Color->r = Color->obj->r; - Color->g = Color->obj->g; - Color->b = Color->obj->b; - Color->a = Color->obj->a; - - return (PyObject *)Color; -} - -static PyObject * -PySfImage_CreateMaskFromColor(PySfImage* self, PyObject *args) -{ - PySfColor *ColorTmp= (PySfColor *)args; - sf::Color *Color; - - if (!PyObject_TypeCheck(ColorTmp, &PySfColorType)) - { - PyErr_SetString(PyExc_TypeError, "Image.CreateMaskFromColor() Argument must be a sf.Color"); - return NULL; - } - Color = ColorTmp->obj; - PySfColorUpdate(ColorTmp); - self->obj->CreateMaskFromColor(*Color); - - Py_RETURN_NONE; -} - -static PyObject * -PySfImage_LoadFromMemory(PySfImage* self, PyObject *args) -{ - unsigned int SizeInBytes; - char *Data; - - if (!PyArg_ParseTuple(args, "s#:Image.LoadFromMemory", &Data, &SizeInBytes)) - return NULL; - - return PyBool_FromLong(self->obj->LoadFromMemory(Data, (std::size_t) SizeInBytes)); -} - -static PyObject * -PySfImage_LoadFromPixels(PySfImage* self, PyObject *args) -{ - unsigned int Width, Height, Size; - char *Data; - - if (! PyArg_ParseTuple(args, "IIs#:Image.LoadFromPixels", &Width, &Height, &Data, &Size)) - return NULL; - - self->obj->LoadFromPixels(Width, Height, (sf::Uint8*) Data); - Py_RETURN_NONE; -} - -static PyObject * -PySfImage_GetPixels(PySfImage *self) -{ -#ifdef IS_PY3K - return PyBytes_FromStringAndSize((const char *)(self->obj->GetPixelsPtr()), self->obj->GetWidth()*self->obj->GetHeight()*4); -#else - return PyString_FromStringAndSize((const char *)(self->obj->GetPixelsPtr()), self->obj->GetWidth()*self->obj->GetHeight()*4); -#endif -} - -static PyObject * -PySfImage_LoadFromFile (PySfImage *self, PyObject *args) -{ - load_from_file(self, args); -} - -static PyObject * -PySfImage_SaveToFile (PySfImage *self, PyObject *args) -{ - save_to_file(self, args); -} - -static PyObject * -PySfImage_Bind(PySfImage *self) -{ - self->obj->Bind(); - Py_RETURN_NONE; -} - -static PyObject * -PySfImage_SetSmooth (PySfImage *self, PyObject *args) -{ - self->obj->SetSmooth(PyBool_AsBool(args)); - Py_RETURN_NONE; -} - -static PyObject * -PySfImage_IsSmooth (PySfImage *self) -{ - return PyBool_FromLong(self->obj->IsSmooth()); -} - -static PyObject * -PySfImage_GetWidth(PySfImage *self) -{ - return PyLong_FromUnsignedLong(self->obj->GetWidth()); -} - -static PyObject * -PySfImage_GetHeight(PySfImage *self) -{ - return PyLong_FromUnsignedLong(self->obj->GetHeight()); -} - -static PyObject * -PySfImage_GetValidSize(PySfImage* self, PyObject *args) -{ - unsigned long S = PyLong_AsUnsignedLong(args); - return PyLong_FromUnsignedLong(sf::Image::GetValidSize(S)); -} - -static PyObject * -PySfImage_GetTexCoords(PySfImage* self, PyObject *args) -{ - PySfIntRect *RectArg = NULL; - - if (!PyArg_ParseTuple(args, "O!:Image.GetTextCoords", &PySfIntRectType, &RectArg)) - return NULL; - - PySfFloatRect *Rect; - - Rect = GetNewPySfFloatRect(); - Rect->Owner = true; - Rect->obj = new sf::FloatRect(self->obj->GetTexCoords(*(RectArg->obj))); - PySfFloatRectUpdateSelf(Rect); - - return (PyObject *)Rect; -} - -static int -PySfImage_init(PySfImage *self, PyObject *args, PyObject *kwds) -{ - int size = PyTuple_Size(args); - if (size > 0) - { - if (PySfImage_Create(self, args, kwds) == NULL) - { - if (size != 3) - return -1; - else if (PySfImage_LoadFromPixels(self, args) == NULL) - return -1; - else PyErr_Clear(); - } - } - return 0; -} - -static PyObject * -PySfImage_Copy(PySfImage* self, PyObject *args, PyObject *kwds); - -static PyMethodDef PySfImage_methods[] = { - {"Copy", (PyCFunction)PySfImage_Copy, METH_VARARGS, "Copy(Source, DestX, DestY, SourceRect = sf.IntRect(0,0,0,0))\n\ -Copy pixels from another image onto this one. This function does a slow pixel copy and should only be used at initialization time.\n\ - Source : Source image to copy\n\ - DestX : X coordinate of the destination position\n\ - DestY : Y coordinate of the destination position\n\ - SourceRect : Sub-rectangle of the source image to copy (empty by default - entire image)\n\ - ApplyAlpha : Should the copy take in account the source transparency? (false by default)"}, - {"Create", (PyCFunction)PySfImage_Create, METH_VARARGS, "Create(Width=0, Height=0, Color=sf.Color.Black)\n\ -Create an empty image.\n\ - Width : Image width\n\ - Height : Image height\n\ - Col : Image color (black by default)"}, - {"CopyScreen", (PyCFunction)PySfImage_CopyScreen, METH_VARARGS, "CopyScreen(Window, SourceRect)\n\ -Create the image from the current contents of the given window. Return True if copy was successful.\n\ - Window : Window to capture\n\ - SourceRect : Sub-rectangle of the screen to copy (empty by default - entire image)"}, - {"SetPixel", (PyCFunction)PySfImage_SetPixel, METH_VARARGS | METH_KEYWORDS, "SetPixel(X, Y, Col)\nChange the color of a pixel.\n\ - X : X coordinate of pixel in the image\n Y : Y coordinate of pixel in the image\n Col : New color for pixel (X, Y)"}, - {"GetPixel", (PyCFunction)PySfImage_GetPixel, METH_VARARGS, "GetPixel(X, Y)\nGet a pixel from the image."}, - {"LoadFromFile", (PyCFunction)PySfImage_LoadFromFile, METH_O, "LoadFromFile(Path)\nLoad the surface from a file."}, - {"SaveToFile", (PyCFunction)PySfImage_SaveToFile, METH_O, "SaveToFile(Path)\nSave the content of the image to a file."}, - {"LoadFromMemory", (PyCFunction)PySfImage_LoadFromMemory, METH_VARARGS, "LoadFromMemory(Data)\nLoad the image from a file in memory."}, - {"LoadFromPixels", (PyCFunction)PySfImage_LoadFromPixels, METH_VARARGS, "LoadFromPixels(Width, Height, Data)\nLoad the image directly from a string of pixels."}, - {"GetPixels", (PyCFunction)PySfImage_GetPixels, METH_NOARGS, "GetPixels()\nGet a string representing the array of pixels (8 bits integers RGBA). String length is GetWidth() x GetHeight() x 4. This string becomes invalid if you reload or resize the image."}, - {"CreateMaskFromColor", (PyCFunction)PySfImage_CreateMaskFromColor, METH_O, "CreateMaskFromColor(Color)\nCreate transparency mask from a specified colorkey."}, - {"Bind", (PyCFunction)PySfImage_Bind, METH_NOARGS, "Bind()\nBind the image for rendering."}, - {"SetSmooth", (PyCFunction)PySfImage_SetSmooth, METH_O, "SetSmooth(Smooth)\nEnable or disable image smooth filter."}, - {"IsSmooth", (PyCFunction)PySfImage_IsSmooth, METH_NOARGS, "IsOpened(Smooth)\nTells whether the smooth filtering is enabled or not."}, - {"GetWidth", (PyCFunction)PySfImage_GetWidth, METH_NOARGS, "GetWidth()\nReturn the width of the image."}, - {"GetHeight", (PyCFunction)PySfImage_GetHeight, METH_NOARGS, "GetHeight()\nReturn the height of the image."}, - {"GetTexCoords", (PyCFunction)PySfImage_GetTexCoords, METH_VARARGS, "GetTexCoords(Rect)\nConvert a subrect expressed in pixels, into float texture coordinates. Returns texture coordinates corresponding to the sub-rectangle (sf.FloatRect instance)\n\ - Rect : Sub-rectangle of image to convert"}, - {"GetValidSize", (PyCFunction)PySfImage_GetValidSize, METH_STATIC | METH_O, "GetValidSize(Size)\nGet a valid texture size according to hardware support. Returns valid nearest size (greater than or equal to specified size).\n\ - Size : Size to convert"}, - {NULL} /* Sentinel */ -}; - -PyTypeObject PySfImageType = { - head_init - "Image", /*tp_name*/ - sizeof(PySfImage), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - (destructor)PySfImage_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash */ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ - "sf.Image is the low-level class for loading and manipulating images.\n\ -Default constructor : sf.Image()\n\ -Other constructors : sf.Image(Width=0, Height=0, Color=sf.Color.Black) or sf.Image(Width, Height, Data).\n\ -Copy constructor : sf.Image(Copy) where Copy is a sf.Image instance.", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - PySfImage_methods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc)PySfImage_init, /* tp_init */ - 0, /* tp_alloc */ - PySfImage_new, /* tp_new */ -}; - -static PyObject * -PySfImage_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PySfImage *self; - self = (PySfImage *)type->tp_alloc(type, 0); - if (self != NULL) - { - if (PyTuple_Size(args) == 1) - { - PySfImage *Image; - if (PyArg_ParseTuple(args, "O!", &PySfImageType, &Image)) - { - self->obj = new sf::Image(*(Image->obj)); - } - else PyErr_Clear(); - } - else self->obj = new sf::Image(); - } - return (PyObject *)self; -} - -static PyObject * -PySfImage_Copy(PySfImage* self, PyObject *args, PyObject *kwds) -{ - const char *kwlist[] = {"Source", "DestX", "DestY", "SourceRect", "ApplyAlpha", NULL}; - PySfIntRect *SourceRect = NULL; - PySfImage *Source = NULL; - unsigned int DestX, DestY; - PyObject *PyApplyAlpha = NULL; - bool ApplyAlpha = false; - - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!II|O!O:Image.Copy", (char **)kwlist, &PySfImageType, &Source, &DestX, &DestY, &PySfIntRectType, &SourceRect, &PyApplyAlpha)) - return NULL; - - if (PyApplyAlpha) - if (PyObject_IsTrue(PyApplyAlpha)) - ApplyAlpha = true; - - if (SourceRect) - self->obj->Copy(*(Source->obj), DestX, DestY, *(SourceRect->obj), ApplyAlpha); - else - self->obj->Copy(*(Source->obj), DestX, DestY, sf::IntRect(0, 0, 0, 0), ApplyAlpha); - - Py_RETURN_NONE; -} - -PySfImage * -GetNewPySfImage() -{ - return PyObject_New(PySfImage, &PySfImageType); -} - diff --git a/bindings/python/src/Image.hpp b/bindings/python/src/Image.hpp deleted file mode 100644 index ff195c7a..00000000 --- a/bindings/python/src/Image.hpp +++ /dev/null @@ -1,42 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// PySFML - Python binding for SFML (Simple and Fast Multimedia Library) -// Copyright (C) 2007, 2008 Rémi Koenig (remi.k2620@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#ifndef __PYIMAGE_HPP -#define __PYIMAGE_HPP - -#include - -#include - - -typedef struct { - PyObject_HEAD - sf::Image *obj; -} PySfImage; - -PySfImage * -GetNewPySfImage(); - -#endif - diff --git a/bindings/python/src/Input.cpp b/bindings/python/src/Input.cpp deleted file mode 100644 index d3322a5b..00000000 --- a/bindings/python/src/Input.cpp +++ /dev/null @@ -1,134 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// PySFML - Python binding for SFML (Simple and Fast Multimedia Library) -// Copyright (C) 2007, 2008 Rémi Koenig (remi.k2620@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#include "Input.hpp" - -#include "compat.hpp" - - -static PyObject * -PySfInput_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PyErr_SetString(PyExc_RuntimeError, "You can't create an Input object yourself, because an Input object must always be associated to its window.\nThe only way to get an Input is by creating a window and calling : Input = MyWindow.GetInput()."); - return NULL; -} - -static PyObject* -PySfInput_IsKeyDown(PySfInput *self, PyObject *args) -{ - return PyBool_FromLong(self->obj->IsKeyDown( (sf::Key::Code) PyLong_AsLong(args) )); -} - -static PyObject* -PySfInput_IsMouseButtonDown(PySfInput *self, PyObject *args) -{ - return PyBool_FromLong(self->obj->IsMouseButtonDown( (sf::Mouse::Button) PyLong_AsLong(args) )); -} - -static PyObject* -PySfInput_IsJoystickButtonDown(PySfInput *self, PyObject *args) -{ - unsigned int JoyId, Button; - if (! PyArg_ParseTuple (args, "II:Input.IsJoystickButtonDown", &JoyId, &Button)) - return NULL; - return PyBool_FromLong(self->obj->IsJoystickButtonDown(JoyId, Button)); -} - -static PyObject* -PySfInput_GetMouseX(PySfInput *self) -{ - return PyLong_FromLong(self->obj->GetMouseX()); -} -static PyObject* -PySfInput_GetMouseY(PySfInput *self) -{ - return PyLong_FromLong(self->obj->GetMouseY()); -} - -static PyObject* -PySfInput_GetJoystickAxis(PySfInput *self, PyObject *args) -{ - unsigned int JoyId, Axis; - if (! PyArg_ParseTuple (args, "II:Input.GetJoystickAxis", &JoyId, &Axis)) - return NULL; - return PyFloat_FromDouble(self->obj->GetJoystickAxis(JoyId, (sf::Joy::Axis) Axis)); -} - -static PyMethodDef PySfInput_methods[] = { - {"IsKeyDown", (PyCFunction)PySfInput_IsKeyDown, METH_O, "IsKeyDown(KeyCode)\nGet the state of a key. Returns True if key is down, false if key is up.\n KeyCode : Key to check"}, - {"IsMouseButtonDown", (PyCFunction)PySfInput_IsMouseButtonDown, METH_O, "IsMouseButtonDown(Button)\nGet the state of a mouse button. Returns True if button is down, false if button is up.\n Button : Button to check"}, - {"IsJoystickButtonDown", (PyCFunction)PySfInput_IsJoystickButtonDown, METH_VARARGS, "IsJoystickButtonDown(JoyId, Button)\nGet the state of a joystick button. Returns True if button is down, false if button is up.\n JoyId : Identifier of the joystick to check (0 or 1)\n Button : Button to check"}, - {"GetMouseX", (PyCFunction)PySfInput_GetMouseX, METH_NOARGS, "GetMouseX()\nGet the mouse X position."}, - {"GetMouseY", (PyCFunction)PySfInput_GetMouseY, METH_NOARGS, "GetMouseY()\nGet the mouse Y position."}, - {"GetJoystickAxis", (PyCFunction)PySfInput_GetJoystickAxis, METH_VARARGS, "GetJoystickAxis(JoyId, Axis)\nGet a joystick axis position. Returns current axis position, in the range [-100, 100] (except for POV, which is [0, 360])\n JoyId : Identifier of the joystick to check (0 or 1)\n Axis : Axis to get"}, - {NULL} /* Sentinel */ -}; - -PyTypeObject PySfInputType = { - head_init - "Input", /*tp_name*/ - sizeof(PySfInput), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - 0, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash */ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ - "sf.Input handles real-time input from keyboard and mouse. Use it instead of events to handle continuous moves and more game-friendly inputs.", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - PySfInput_methods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PySfInput_new, /* tp_new */ -}; - -PySfInput * -GetNewPySfInput() -{ - return PyObject_New(PySfInput, &PySfInputType); -} - diff --git a/bindings/python/src/Input.hpp b/bindings/python/src/Input.hpp deleted file mode 100644 index 73df3652..00000000 --- a/bindings/python/src/Input.hpp +++ /dev/null @@ -1,40 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// PySFML - Python binding for SFML (Simple and Fast Multimedia Library) -// Copyright (C) 2007, 2008 Rémi Koenig (remi.k2620@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#ifndef __PYINPUT_HPP -#define __PYINPUT_HPP - -#include - -#include - -typedef struct { - PyObject_HEAD - sf::Input *obj; -} PySfInput; - -PySfInput * -GetNewPySfInput(); - -#endif diff --git a/bindings/python/src/Joy.cpp b/bindings/python/src/Joy.cpp deleted file mode 100644 index fdce88c6..00000000 --- a/bindings/python/src/Joy.cpp +++ /dev/null @@ -1,114 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// PySFML - Python binding for SFML (Simple and Fast Multimedia Library) -// Copyright (C) 2007, 2008 Rémi Koenig (remi.k2620@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#include "Joy.hpp" - -#include "compat.hpp" - - -static PyObject * -PySfJoy_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PySfJoy *self; - self = (PySfJoy *)type->tp_alloc(type, 0); - return (PyObject *)self; -} - - -PyTypeObject PySfJoyType = { - head_init - "Joy", /*tp_name*/ - sizeof(PySfJoy), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - 0, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash */ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ - "Definition of joystick axis for joystick events.", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PySfJoy_new, /* tp_new */ -}; - -void PySfJoy_InitConst() -{ - PyObject *obj; - obj = PyLong_FromLong(sf::Joy::AxisX); - PyDict_SetItemString(PySfJoyType.tp_dict, "AxisX", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Joy::AxisY); - PyDict_SetItemString(PySfJoyType.tp_dict, "AxisY", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Joy::AxisZ); - PyDict_SetItemString(PySfJoyType.tp_dict, "AxisZ", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Joy::AxisR); - PyDict_SetItemString(PySfJoyType.tp_dict, "AxisR", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Joy::AxisU); - PyDict_SetItemString(PySfJoyType.tp_dict, "AxisU", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Joy::AxisV); - PyDict_SetItemString(PySfJoyType.tp_dict, "AxisV", obj); - Py_DECREF(obj); - 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/bindings/python/src/Joy.hpp b/bindings/python/src/Joy.hpp deleted file mode 100644 index 6daf4bb3..00000000 --- a/bindings/python/src/Joy.hpp +++ /dev/null @@ -1,39 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// PySFML - Python binding for SFML (Simple and Fast Multimedia Library) -// Copyright (C) 2007, 2008 Rémi Koenig (remi.k2620@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#ifndef __PYJOY_HPP -#define __PYJOY_HPP - -#include - -#include - -typedef struct { - PyObject_HEAD -} PySfJoy; - -void -PySfJoy_InitConst(); - -#endif diff --git a/bindings/python/src/Key.cpp b/bindings/python/src/Key.cpp deleted file mode 100644 index 9b807cfa..00000000 --- a/bindings/python/src/Key.cpp +++ /dev/null @@ -1,385 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// PySFML - Python binding for SFML (Simple and Fast Multimedia Library) -// Copyright (C) 2007, 2008 Rémi Koenig (remi.k2620@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#include "Key.hpp" - -#include "compat.hpp" - -static PyObject * -PySfKey_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PySfKey *self; - self = (PySfKey *)type->tp_alloc(type, 0); - return (PyObject *)self; -} - -PyTypeObject PySfKeyType = { - head_init - "Key", /*tp_name*/ - sizeof(PySfKey), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - 0, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash */ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ - "Definition of key codes for keyboard events.", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PySfKey_new, /* tp_new */ -}; - -void PySfKey_InitConst() -{ - PyObject *obj; - obj = PyLong_FromLong(sf::Key::Numpad2); - PyDict_SetItemString(PySfKeyType.tp_dict, "Numpad2", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::Numpad3); - PyDict_SetItemString(PySfKeyType.tp_dict, "Numpad3", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::Numpad0); - PyDict_SetItemString(PySfKeyType.tp_dict, "Numpad0", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::Numpad1); - PyDict_SetItemString(PySfKeyType.tp_dict, "Numpad1", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::Numpad6); - PyDict_SetItemString(PySfKeyType.tp_dict, "Numpad6", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::Numpad7); - PyDict_SetItemString(PySfKeyType.tp_dict, "Numpad7", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::Numpad4); - PyDict_SetItemString(PySfKeyType.tp_dict, "Numpad4", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::Numpad5); - PyDict_SetItemString(PySfKeyType.tp_dict, "Numpad5", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::Numpad8); - PyDict_SetItemString(PySfKeyType.tp_dict, "Numpad8", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::Numpad9); - PyDict_SetItemString(PySfKeyType.tp_dict, "Numpad9", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::RAlt); - PyDict_SetItemString(PySfKeyType.tp_dict, "RAlt", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::PageUp); - PyDict_SetItemString(PySfKeyType.tp_dict, "PageUp", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::Multiply); - PyDict_SetItemString(PySfKeyType.tp_dict, "Multiply", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::D); - PyDict_SetItemString(PySfKeyType.tp_dict, "D", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::SemiColon); - PyDict_SetItemString(PySfKeyType.tp_dict, "SemiColon", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::H); - PyDict_SetItemString(PySfKeyType.tp_dict, "H", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::L); - PyDict_SetItemString(PySfKeyType.tp_dict, "L", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::P); - PyDict_SetItemString(PySfKeyType.tp_dict, "P", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::Num7); - PyDict_SetItemString(PySfKeyType.tp_dict, "Num7", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::T); - PyDict_SetItemString(PySfKeyType.tp_dict, "T", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::X); - PyDict_SetItemString(PySfKeyType.tp_dict, "X", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::RSystem); - PyDict_SetItemString(PySfKeyType.tp_dict, "RSystem", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::F5); - PyDict_SetItemString(PySfKeyType.tp_dict, "F5", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::Num4); - PyDict_SetItemString(PySfKeyType.tp_dict, "Num4", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::Num5); - PyDict_SetItemString(PySfKeyType.tp_dict, "Num5", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::Num6); - PyDict_SetItemString(PySfKeyType.tp_dict, "Num6", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::Right); - PyDict_SetItemString(PySfKeyType.tp_dict, "Right", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::Num0); - PyDict_SetItemString(PySfKeyType.tp_dict, "Num0", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::Num1); - PyDict_SetItemString(PySfKeyType.tp_dict, "Num1", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::Num2); - PyDict_SetItemString(PySfKeyType.tp_dict, "Num2", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::Num3); - PyDict_SetItemString(PySfKeyType.tp_dict, "Num3", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::LControl); - PyDict_SetItemString(PySfKeyType.tp_dict, "LControl", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::Num8); - PyDict_SetItemString(PySfKeyType.tp_dict, "Num8", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::Num9); - PyDict_SetItemString(PySfKeyType.tp_dict, "Num9", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::Tab); - PyDict_SetItemString(PySfKeyType.tp_dict, "Tab", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::RBracket); - PyDict_SetItemString(PySfKeyType.tp_dict, "RBracket", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::End); - PyDict_SetItemString(PySfKeyType.tp_dict, "End", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::BackSlash); - PyDict_SetItemString(PySfKeyType.tp_dict, "BackSlash", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::LShift); - PyDict_SetItemString(PySfKeyType.tp_dict, "LShift", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::E); - PyDict_SetItemString(PySfKeyType.tp_dict, "E", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::C); - PyDict_SetItemString(PySfKeyType.tp_dict, "C", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::G); - PyDict_SetItemString(PySfKeyType.tp_dict, "G", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::K); - PyDict_SetItemString(PySfKeyType.tp_dict, "K", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::Up); - PyDict_SetItemString(PySfKeyType.tp_dict, "Up", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::O); - PyDict_SetItemString(PySfKeyType.tp_dict, "O", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::S); - PyDict_SetItemString(PySfKeyType.tp_dict, "S", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::W); - PyDict_SetItemString(PySfKeyType.tp_dict, "W", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::F12); - PyDict_SetItemString(PySfKeyType.tp_dict, "F12", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::F13); - PyDict_SetItemString(PySfKeyType.tp_dict, "F13", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::F10); - PyDict_SetItemString(PySfKeyType.tp_dict, "F10", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::F11); - PyDict_SetItemString(PySfKeyType.tp_dict, "F11", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::F14); - PyDict_SetItemString(PySfKeyType.tp_dict, "F14", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::Delete); - PyDict_SetItemString(PySfKeyType.tp_dict, "Delete", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::Back); - PyDict_SetItemString(PySfKeyType.tp_dict, "Back", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::Tilde); - PyDict_SetItemString(PySfKeyType.tp_dict, "Tilde", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::Home); - PyDict_SetItemString(PySfKeyType.tp_dict, "Home", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::Pause); - PyDict_SetItemString(PySfKeyType.tp_dict, "Pause", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::Add); - PyDict_SetItemString(PySfKeyType.tp_dict, "Add", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::F15); - PyDict_SetItemString(PySfKeyType.tp_dict, "F15", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::Subtract); - PyDict_SetItemString(PySfKeyType.tp_dict, "Subtract", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::B); - PyDict_SetItemString(PySfKeyType.tp_dict, "B", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::F); - PyDict_SetItemString(PySfKeyType.tp_dict, "F", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::J); - PyDict_SetItemString(PySfKeyType.tp_dict, "J", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::N); - PyDict_SetItemString(PySfKeyType.tp_dict, "N", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::LBracket); - PyDict_SetItemString(PySfKeyType.tp_dict, "LBracket", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::R); - PyDict_SetItemString(PySfKeyType.tp_dict, "R", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::V); - PyDict_SetItemString(PySfKeyType.tp_dict, "V", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::LSystem); - PyDict_SetItemString(PySfKeyType.tp_dict, "LSystem", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::Z); - PyDict_SetItemString(PySfKeyType.tp_dict, "Z", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::Left); - PyDict_SetItemString(PySfKeyType.tp_dict, "Left", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::F1); - PyDict_SetItemString(PySfKeyType.tp_dict, "F1", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::F2); - PyDict_SetItemString(PySfKeyType.tp_dict, "F2", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::F3); - PyDict_SetItemString(PySfKeyType.tp_dict, "F3", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::F4); - PyDict_SetItemString(PySfKeyType.tp_dict, "F4", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::Divide); - PyDict_SetItemString(PySfKeyType.tp_dict, "Divide", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::F6); - PyDict_SetItemString(PySfKeyType.tp_dict, "F6", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::F7); - PyDict_SetItemString(PySfKeyType.tp_dict, "F7", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::F8); - PyDict_SetItemString(PySfKeyType.tp_dict, "F8", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::F9); - PyDict_SetItemString(PySfKeyType.tp_dict, "F9", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::Period); - PyDict_SetItemString(PySfKeyType.tp_dict, "Period", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::Down); - PyDict_SetItemString(PySfKeyType.tp_dict, "Down", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::PageDown); - PyDict_SetItemString(PySfKeyType.tp_dict, "PageDown", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::Space); - PyDict_SetItemString(PySfKeyType.tp_dict, "Space", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::Menu); - PyDict_SetItemString(PySfKeyType.tp_dict, "Menu", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::RControl); - PyDict_SetItemString(PySfKeyType.tp_dict, "RControl", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::Slash); - PyDict_SetItemString(PySfKeyType.tp_dict, "Slash", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::Return); - PyDict_SetItemString(PySfKeyType.tp_dict, "Return", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::Quote); - PyDict_SetItemString(PySfKeyType.tp_dict, "Quote", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::A); - PyDict_SetItemString(PySfKeyType.tp_dict, "A", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::Insert); - PyDict_SetItemString(PySfKeyType.tp_dict, "Insert", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::RShift); - PyDict_SetItemString(PySfKeyType.tp_dict, "RShift", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::I); - PyDict_SetItemString(PySfKeyType.tp_dict, "I", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::Escape); - PyDict_SetItemString(PySfKeyType.tp_dict, "Escape", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::M); - PyDict_SetItemString(PySfKeyType.tp_dict, "M", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::Equal); - PyDict_SetItemString(PySfKeyType.tp_dict, "Equal", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::Q); - PyDict_SetItemString(PySfKeyType.tp_dict, "Q", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::U); - PyDict_SetItemString(PySfKeyType.tp_dict, "U", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::Y); - PyDict_SetItemString(PySfKeyType.tp_dict, "Y", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::Dash); - PyDict_SetItemString(PySfKeyType.tp_dict, "Dash", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::Comma); - PyDict_SetItemString(PySfKeyType.tp_dict, "Comma", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Key::LAlt); - PyDict_SetItemString(PySfKeyType.tp_dict, "LAlt", obj); - Py_DECREF(obj); -} - diff --git a/bindings/python/src/Key.hpp b/bindings/python/src/Key.hpp deleted file mode 100644 index 1af17a21..00000000 --- a/bindings/python/src/Key.hpp +++ /dev/null @@ -1,39 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// PySFML - Python binding for SFML (Simple and Fast Multimedia Library) -// Copyright (C) 2007, 2008 Rémi Koenig (remi.k2620@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#ifndef __PYKEY_HPP -#define __PYKEY_HPP - -#include - -#include - -typedef struct { - PyObject_HEAD -} PySfKey; - -void -PySfKey_InitConst(); - -#endif diff --git a/bindings/python/src/Listener.cpp b/bindings/python/src/Listener.cpp deleted file mode 100644 index 6ad479e8..00000000 --- a/bindings/python/src/Listener.cpp +++ /dev/null @@ -1,128 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// PySFML - Python binding for SFML (Simple and Fast Multimedia Library) -// Copyright (C) 2007, 2008 Rémi Koenig (remi.k2620@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#include "Listener.hpp" - -#include "compat.hpp" - - -static PyObject * -PySfListener_SetGlobalVolume(PySfListener* self, PyObject *args) -{ - sf::Listener::SetGlobalVolume(PyFloat_AsDouble(args)); - Py_RETURN_NONE; -} - -static PyObject * -PySfListener_GetGlobalVolume(PySfListener* self) -{ - return PyFloat_FromDouble(sf::Listener::GetGlobalVolume()); -} - -static PyObject * -PySfListener_SetPosition(PySfListener* self, PyObject *args) -{ - float X, Y, Z; - if (!PyArg_ParseTuple(args, "fff:Listener.SetPosition", &X, &Y, &Z)) - return NULL; - sf::Listener::SetPosition(X, Y, Z); - Py_RETURN_NONE; -} - -static PyObject* -PySfListener_GetPosition(PySfListener *self) -{ - sf::Vector3f Vect = sf::Listener::GetPosition(); - return Py_BuildValue("fff", Vect.x, Vect.y, Vect.z); -} - -static PyObject * -PySfListener_SetDirection(PySfListener* self, PyObject *args) -{ - float X, Y, Z; - if (!PyArg_ParseTuple(args, "fff:Listener.SetDirection", &X, &Y, &Z)) - return NULL; - sf::Listener::SetDirection(X, Y, Z); - Py_RETURN_NONE; -} - -static PyObject* -PySfListener_GetDirection(PySfListener *self) -{ - sf::Vector3f Vect = sf::Listener::GetDirection(); - return Py_BuildValue("fff", Vect.x, Vect.y, Vect.z); -} - -static PyMethodDef PySfListener_methods[] = { - {"SetGlobalVolume", (PyCFunction)PySfListener_SetGlobalVolume, METH_STATIC | METH_O, "SetGlobalVolume(Volume)\nChange the global volume of all the sounds."}, - {"GetGlobalVolume", (PyCFunction)PySfListener_GetGlobalVolume, METH_STATIC | METH_NOARGS, "GetGlobalVolume()\nGet the current value of the global volume of all the sounds."}, - {"SetPosition", (PyCFunction)PySfListener_SetPosition, METH_STATIC | METH_VARARGS, "SetPosition(X, Y, Z)\nChange the position of the listener."}, - {"GetPosition", (PyCFunction)PySfListener_GetPosition, METH_STATIC | METH_NOARGS, "GetPosition()\nGet the current position of the listener."}, - {"SetDirection", (PyCFunction)PySfListener_SetDirection, METH_STATIC | METH_VARARGS, "SetDirection(X, Y, Z)\nChange the orientation of the listener (the point he must look at)"}, - {"GetDirection", (PyCFunction)PySfListener_GetDirection, METH_STATIC | METH_NOARGS, "GetDirection()\nGet the current orientation of the listener (the point he's looking at)"}, - {NULL} /* Sentinel */ -}; - -PyTypeObject PySfListenerType = { - head_init - "Listener", /*tp_name*/ - sizeof(PySfListener), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - 0, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash */ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ - "Listener is a global interface for defining the audio listener properties ; the audio listener is the point in the scene from where all the sounds are heard.", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - PySfListener_methods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ -}; - - diff --git a/bindings/python/src/Listener.hpp b/bindings/python/src/Listener.hpp deleted file mode 100644 index 123956b6..00000000 --- a/bindings/python/src/Listener.hpp +++ /dev/null @@ -1,37 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// PySFML - Python binding for SFML (Simple and Fast Multimedia Library) -// Copyright (C) 2007, 2008 Rémi Koenig (remi.k2620@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#ifndef __PYLISTENER_HPP -#define __PYLISTENER_HPP - -#include - -#include - - -typedef struct { - PyObject_HEAD -} PySfListener; - -#endif diff --git a/bindings/python/src/Mouse.cpp b/bindings/python/src/Mouse.cpp deleted file mode 100644 index f2fe2097..00000000 --- a/bindings/python/src/Mouse.cpp +++ /dev/null @@ -1,102 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// PySFML - Python binding for SFML (Simple and Fast Multimedia Library) -// Copyright (C) 2007, 2008 Rémi Koenig (remi.k2620@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#include "Mouse.hpp" - -#include "compat.hpp" - - -static PyObject * -PySfMouse_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PySfMouse *self; - self = (PySfMouse *)type->tp_alloc(type, 0); - return (PyObject *)self; -} - - -PyTypeObject PySfMouseType = { - head_init - "Mouse", /*tp_name*/ - sizeof(PySfMouse), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - 0, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash */ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ - "Definition of button codes for mouse events.", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PySfMouse_new, /* tp_new */ -}; - -void PySfMouse_InitConst() -{ - PyObject *obj; - obj = PyLong_FromLong(sf::Mouse::Left); - PyDict_SetItemString(PySfMouseType.tp_dict, "Left", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Mouse::Right); - PyDict_SetItemString(PySfMouseType.tp_dict, "Right", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Mouse::Middle); - PyDict_SetItemString(PySfMouseType.tp_dict, "Middle", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Mouse::XButton1); - PyDict_SetItemString(PySfMouseType.tp_dict, "XButton1", obj); - Py_DECREF(obj); - 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/bindings/python/src/Mouse.hpp b/bindings/python/src/Mouse.hpp deleted file mode 100644 index 3e0ca33a..00000000 --- a/bindings/python/src/Mouse.hpp +++ /dev/null @@ -1,39 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// PySFML - Python binding for SFML (Simple and Fast Multimedia Library) -// Copyright (C) 2007, 2008 Rémi Koenig (remi.k2620@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#ifndef __PYMOUSE_HPP -#define __PYMOUSE_HPP - -#include - -#include - -typedef struct { - PyObject_HEAD -} PySfMouse; - -void -PySfMouse_InitConst(); - -#endif diff --git a/bindings/python/src/Music.cpp b/bindings/python/src/Music.cpp deleted file mode 100644 index 14645e9b..00000000 --- a/bindings/python/src/Music.cpp +++ /dev/null @@ -1,140 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// PySFML - Python binding for SFML (Simple and Fast Multimedia Library) -// Copyright (C) 2007, 2008 Rémi Koenig (remi.k2620@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#include "Music.hpp" - -#include "compat.hpp" - - -extern PyTypeObject PySfSoundStreamType; - - -static void -PySfMusic_dealloc(PySfMusic *self) -{ - delete self->obj; - free_object(self); -} - -static PyObject * -PySfMusic_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PySfMusic *self; - self = (PySfMusic *)type->tp_alloc(type, 0); - if (self != NULL) - { - self->obj = new sf::Music(); - } - return (PyObject *)self; -} - -static PyObject* -PySfMusic_OpenFromMemory(PySfMusic *self, PyObject *args) -{ - unsigned int SizeInBytes; - char *Data; - - if (!PyArg_ParseTuple(args, "s#:Music.OpenFromMemory", &Data, &SizeInBytes)) - return NULL; - - return PyBool_FromLong(self->obj->OpenFromMemory(Data, (std::size_t) SizeInBytes)); -} - -static PyObject* -PySfMusic_OpenFromFile(PySfMusic *self, PyObject *args) -{ - char *path; -#ifdef IS_PY3K - PyObject *string = PyUnicode_AsUTF8String(args); - if (string == NULL) - return NULL; - path = PyBytes_AsString(string); -#else - path = PyString_AsString(args); -#endif - bool result = self->obj->OpenFromFile(path); -#ifdef IS_PY3K - Py_DECREF(string); -#endif - return PyBool_FromLong(result); -} - -static PyObject* -PySfMusic_GetDuration(PySfMusic *self) -{ - return PyFloat_FromDouble((double)(self->obj->GetDuration())); -} - - -static PyMethodDef PySfMusic_methods[] = { - {"OpenFromFile", (PyCFunction)PySfMusic_OpenFromFile, METH_O, "OpenFromFile(Filename)\nOpen a music file (doesn't play it -- call Play() for that). Returns True if loading has been successful.\n Filename : Path of the music file to open"}, - {"OpenFromMemory", (PyCFunction)PySfMusic_OpenFromMemory, METH_VARARGS, "OpenFromMemory(Data)\nOpen a music file (doesn't play it -- call Play() for that). Returns True if loading has been successful.\n Data : string representing the file data in memory"}, - {"GetDuration", (PyCFunction)PySfMusic_GetDuration, METH_NOARGS, "GetDuration()\nGet the sound duration."}, - {NULL} /* Sentinel */ -}; - - -PyTypeObject PySfMusicType = { - head_init - "Music", /*tp_name*/ - sizeof(PySfMusic), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - (destructor)PySfMusic_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash */ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ - "sf.Music defines a big sound played using streaming, so usually what we call a music :).\n\ -Constructor: sf.Music()", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - PySfMusic_methods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - &PySfSoundStreamType, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PySfMusic_new, /* tp_new */ -}; - - diff --git a/bindings/python/src/Music.hpp b/bindings/python/src/Music.hpp deleted file mode 100644 index a69c47d1..00000000 --- a/bindings/python/src/Music.hpp +++ /dev/null @@ -1,37 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// PySFML - Python binding for SFML (Simple and Fast Multimedia Library) -// Copyright (C) 2007, 2008 Rémi Koenig (remi.k2620@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#ifndef __PYMUSIC_HPP -#define __PYMUSIC_HPP - -#include - -#include - -typedef struct { - PyObject_HEAD - sf::Music *obj; -} PySfMusic; - -#endif diff --git a/bindings/python/src/Rect.cpp b/bindings/python/src/Rect.cpp deleted file mode 100644 index 48afffc2..00000000 --- a/bindings/python/src/Rect.cpp +++ /dev/null @@ -1,394 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// PySFML - Python binding for SFML (Simple and Fast Multimedia Library) -// Copyright (C) 2007, 2008 Rémi Koenig (remi.k2620@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#include "Rect.hpp" - -#include - -#include "compat.hpp" -#include "offsetof.hpp" - - -static PyMemberDef PySfIntRect_members[] = { - {(char *)"Left", T_INT, offsetof(PySfIntRect, Left), 0, (char *)"Left coordinate of the rectangle."}, - {(char *)"Top", T_INT, offsetof(PySfIntRect, Top), 0, (char *)"Top coordinate of the rectangle."}, - {(char *)"Right", T_INT, offsetof(PySfIntRect, Right), 0, (char *)"Right coordinate of the rectangle."}, - {(char *)"Bottom", T_INT, offsetof(PySfIntRect, Bottom), 0, (char *)"Bottom coordinate of the rectangle."}, - {NULL} /* Sentinel */ -}; - -static PyMemberDef PySfFloatRect_members[] = { - {(char *)"Left", T_FLOAT, offsetof(PySfFloatRect, Left), 0, (char *)"Left coordinate of the rectangle."}, - {(char *)"Top", T_FLOAT, offsetof(PySfFloatRect, Top), 0, (char *)"Top coordinate of the rectangle."}, - {(char *)"Right", T_FLOAT, offsetof(PySfFloatRect, Right), 0, (char *)"Right coordinate of the rectangle."}, - {(char *)"Bottom", T_FLOAT, offsetof(PySfFloatRect, Bottom), 0, (char *)"Bottom coordinate of the rectangle."}, - {NULL} /* Sentinel */ -}; - -static void -PySfIntRect_dealloc(PySfIntRect* self) -{ - if (self->Owner) - delete self->obj; - free_object(self); -} - -static void -PySfFloatRect_dealloc(PySfFloatRect* self) -{ - if (self->Owner) - delete self->obj; - free_object(self); -} - -static PyObject * -PySfIntRect_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - const char *kwlist[] = {"Left", "Top", "Right", "Bottom", NULL}; - PySfIntRect *self; - self = (PySfIntRect *)type->tp_alloc(type, 0); - if (self != NULL) - { - self->Owner = true; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "iiii:IntRect.__new__", (char **)kwlist, &(self->Left), &(self->Top), &(self->Right), &(self->Bottom))) - return NULL; - self->obj = new sf::IntRect(self->Left, self->Top, self->Right, self->Bottom); - } - return (PyObject *)self; -} - -static PyObject * -PySfFloatRect_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - const char *kwlist[] = {"Left", "Top", "Right", "Bottom", NULL}; - PySfFloatRect *self; - self = (PySfFloatRect *)type->tp_alloc(type, 0); - if (self != NULL) - { - self->Owner = true; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "ffff:FloatRect.__new__", (char **)kwlist, &(self->Left), &(self->Top), &(self->Right), &(self->Bottom))) - return NULL; - self->obj = new sf::FloatRect(self->Left, self->Top, self->Right, self->Bottom); - } - return (PyObject *)self; -} - -static PyObject * -PySfIntRect_GetSize(PySfIntRect *self) -{ - sf::Vector2i size( self->obj->GetSize() ); - return Py_BuildValue( "ii", size.x, size.y ); -} - -static PyObject * -PySfIntRect_Contains(PySfIntRect* self, PyObject *args); - -static PyObject * -PySfIntRect_Intersects(PySfIntRect* self, PyObject *args); - -static PyObject * -PySfFloatRect_GetSize(PySfFloatRect *self) -{ - sf::Vector2f size( self->obj->GetSize() ); - return Py_BuildValue( "ff", size.x, size.y ); -} - -static PyObject * -PySfFloatRect_Contains(PySfFloatRect* self, PyObject *args); - -static PyObject * -PySfFloatRect_Intersects(PySfFloatRect* self, PyObject *args); - -static PyObject * -PySfIntRect_Offset(PySfIntRect* self, PyObject *args) -{ - int OffsetX, OffsetY; - - if (!PyArg_ParseTuple(args, "ii:IntRect.Offset", &OffsetX, &OffsetY)) - return NULL; - - self->obj->Offset(OffsetX, OffsetY); - PySfIntRectUpdateSelf(self); - Py_RETURN_NONE; -} - -static PyObject * -PySfFloatRect_Offset(PySfFloatRect* self, PyObject *args) -{ - float OffsetX, OffsetY; - - if (!PyArg_ParseTuple(args, "ff:FloatRect.Offset", &OffsetX, &OffsetY)) - return NULL; - - self->obj->Offset(OffsetX, OffsetY); - PySfFloatRectUpdateSelf(self); - Py_RETURN_NONE; -} - - -static PyMethodDef PySfIntRect_methods[] = { - {"Offset", (PyCFunction)PySfIntRect_Offset, METH_VARARGS, "Offset(OffsetX, OffsetY)\n\ -Move the whole rectangle by the given offset.\n\ - OffsetX : Horizontal offset\n\ - OffsetY : Vertical offset\n\ -"}, - {"GetSize", (PyCFunction)PySfIntRect_GetSize, METH_NOARGS, "GetSize()\nGet the rectangle's size."}, - {"Contains", (PyCFunction)PySfIntRect_Contains, METH_VARARGS, "Contains(X, Y)\n\ -Check if a point is inside the rectangle's area.\n\ - X : X coordinate of the point to test\n\ - Y : Y coordinate of the point to test"}, - {"Intersects", (PyCFunction)PySfIntRect_Intersects, METH_VARARGS, "Intersects(Rectangle, OverlappingRect=None)\n\ -Check intersection between two rectangles.\n\ - Rectangle : Rectangle to test\n\ - OverlappingRect : Rectangle to be filled with overlapping rect (None by default)"}, - {NULL} /* Sentinel */ -}; - - -static PyMethodDef PySfFloatRect_methods[] = { - {"Offset", (PyCFunction)PySfFloatRect_Offset, METH_VARARGS, "Offset(OffsetX, OffsetY)\n\ -Move the whole rectangle by the given offset.\n\ - OffsetX : Horizontal offset\n\ - OffsetY : Vertical offset\n\ -"}, - {"GetSize", (PyCFunction)PySfFloatRect_GetSize, METH_NOARGS, "GetSize()\nGet the rectangle's size."}, - {"Contains", (PyCFunction)PySfFloatRect_Contains, METH_VARARGS, "Contains(X, Y)\n\ -Check if a point is inside the rectangle's area.\n\ - X : X coordinate of the point to test\n\ - Y : Y coordinate of the point to test"}, - {"Intersects", (PyCFunction)PySfFloatRect_Intersects, METH_VARARGS, "Intersects(Rectangle, OverlappingRect=None)\n\ -Check intersection between two rectangles.\n\ - Rectangle : Rectangle to test\n\ - OverlappingRect : Rectangle to be filled with overlapping rect (None by default)"}, - {NULL} /* Sentinel */ -}; - -int -PySfIntRect_setattro(PyObject* self, PyObject *attr_name, PyObject *v) -{ - int result = PyObject_GenericSetAttr(self, attr_name, v); - PySfIntRect *Rect = (PySfIntRect *)self; - PySfIntRectUpdateObj(Rect); - return result; -} - -int -PySfFloatRect_setattro(PyObject* self, PyObject *attr_name, PyObject *v) -{ - int result = PyObject_GenericSetAttr(self, attr_name, v); - PySfFloatRect *Rect = (PySfFloatRect *)self; - PySfFloatRectUpdateObj(Rect); - return result; -} - -PyTypeObject PySfIntRectType = { - head_init - "IntRect", /*tp_name*/ - sizeof(PySfIntRect), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - (destructor)PySfIntRect_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash */ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - PySfIntRect_setattro, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ - "sf.IntRect is an utility class for manipulating rectangles.", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - PySfIntRect_methods, /* tp_methods */ - PySfIntRect_members, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PySfIntRect_new, /* tp_new */ -}; - - -PyTypeObject PySfFloatRectType = { - head_init - "FloatRect", /*tp_name*/ - sizeof(PySfFloatRect), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - (destructor)PySfFloatRect_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash */ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - PySfFloatRect_setattro, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ - "sf.FloatRect is an utility class for manipulating rectangles.", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - PySfFloatRect_methods, /* tp_methods */ - PySfFloatRect_members, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PySfFloatRect_new, /* tp_new */ -}; - - -static PyObject * -PySfFloatRect_Contains(PySfFloatRect* self, PyObject *args) -{ - float x=0, y=0; - - if (!PyArg_ParseTuple(args, "ff:FloatRect.Contains", &x, &y)) - return NULL; - - return PyBool_FromLong(self->obj->Contains(x,y)); -} - -static PyObject * -PySfFloatRect_Intersects(PySfFloatRect* self, PyObject *args) -{ - PySfFloatRect *Rect=NULL, *Intersection=NULL; - bool result; - - if (!PyArg_ParseTuple(args, "O!|O!:FloatRect.Intersects", &PySfFloatRectType, &Rect, &PySfFloatRectType, &Intersection)) - return NULL; - - if (Intersection) - result = self->obj->Intersects(*(Rect->obj), *(Intersection->obj)); - else - result = self->obj->Intersects(*(Rect->obj)); - - return PyBool_FromLong(result); -} - - -static PyObject * -PySfIntRect_Contains(PySfIntRect* self, PyObject *args) -{ - unsigned int x=0, y=0; - - if (!PyArg_ParseTuple(args, "II:IntRect.Contains", &x, &y)) - return NULL; - - return PyBool_FromLong(self->obj->Contains(x,y)); -} - -static PyObject * -PySfIntRect_Intersects(PySfIntRect* self, PyObject *args) -{ - PySfIntRect *Rect=NULL, *Intersection=NULL; - bool result; - - if (!PyArg_ParseTuple(args, "O!|O!:IntRect.Intersects", &PySfIntRectType, &Rect, &PySfIntRectType, &Intersection)) - return NULL; - - if (Intersection) - result = self->obj->Intersects(*(Rect->obj), *(Intersection->obj)); - else - result = self->obj->Intersects(*(Rect->obj)); - - return PyBool_FromLong(result); -} - -void -PySfIntRectUpdateObj(PySfIntRect *self) -{ - self->obj->Left = self->Left; - self->obj->Right = self->Right; - self->obj->Top = self->Top; - self->obj->Bottom = self->Bottom; -} - -void -PySfFloatRectUpdateObj(PySfFloatRect *self) -{ - self->obj->Left = self->Left; - self->obj->Right = self->Right; - self->obj->Top = self->Top; - self->obj->Bottom = self->Bottom; -} - -void -PySfIntRectUpdateSelf(PySfIntRect *self) -{ - self->Left = self->obj->Left; - self->Right = self->obj->Right; - self->Top = self->obj->Top; - self->Bottom = self->obj->Bottom; -} - -void -PySfFloatRectUpdateSelf(PySfFloatRect *self) -{ - self->Left = self->obj->Left; - self->Right = self->obj->Right; - self->Top = self->obj->Top; - self->Bottom = self->obj->Bottom; -} - -PySfIntRect * -GetNewPySfIntRect() -{ - return PyObject_New(PySfIntRect, &PySfIntRectType); -} - -PySfFloatRect * -GetNewPySfFloatRect() -{ - return PyObject_New(PySfFloatRect, &PySfFloatRectType); -} - - diff --git a/bindings/python/src/Rect.hpp b/bindings/python/src/Rect.hpp deleted file mode 100644 index 69385f45..00000000 --- a/bindings/python/src/Rect.hpp +++ /dev/null @@ -1,70 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// PySFML - Python binding for SFML (Simple and Fast Multimedia Library) -// Copyright (C) 2007, 2008 Rémi Koenig (remi.k2620@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#ifndef __PYRECT_HPP -#define __PYRECT_HPP - -#include - -#include - -typedef struct { - PyObject_HEAD - bool Owner; - int Left; - int Right; - int Top; - int Bottom; - sf::IntRect *obj; -} PySfIntRect; - -typedef struct { - PyObject_HEAD - bool Owner; - float Left; - float Right; - float Top; - float Bottom; - sf::FloatRect *obj; -} PySfFloatRect; - -PySfIntRect * -GetNewPySfIntRect(); - -PySfFloatRect * -GetNewPySfFloatRect(); - -void -PySfIntRectUpdateObj(PySfIntRect *self); - -void -PySfFloatRectUpdateObj(PySfFloatRect *self); - -void -PySfIntRectUpdateSelf(PySfIntRect *self); - -void -PySfFloatRectUpdateSelf(PySfFloatRect *self); - -#endif diff --git a/bindings/python/src/RenderQueue.cpp b/bindings/python/src/RenderQueue.cpp deleted file mode 100644 index b14acae8..00000000 --- a/bindings/python/src/RenderQueue.cpp +++ /dev/null @@ -1,94 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// PySFML - Python binding for SFML (Simple and Fast Multimedia Library) -// Copyright (C) 2007-2009 Rémi Koenig (remi.k2620@gmail.com) -// Stefan "Tank" Schindler -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#include "RenderQueue.hpp" - -#include "compat.hpp" - -static void -PySfRenderQueue_dealloc(PySfRenderQueue* self) -{ - delete self->obj; - free_object( self ); -} - -static PyObject* -PySfRenderQueue_new(PyTypeObject* type, PyObjects* args, PyObject* kwds) -{ - PySfRenderQueue* self(static_cast(type->tp_alloc(type, 0))); - - if(self != 0) - { - self->obj = new sf::RenderQueue(); - } - - return static_cast( self ) -} - -static PyMethodDef PySfImage_methods[] = { - {NULL} /* Sentinel */ -}; - -PyTypeObject PySfImageType = { - head_init - "RenderQueue", /*tp_name*/ - sizeof(PySfRenderQueue), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - (destructor)PySfRenderQueue_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash */ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ - "Implements a queue of rendering commands.\n\ -Default constructor : sf.RenderQueue()" /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - PySfRenderQueue_methods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PySfRenderQueue_new, /* tp_new */ -}; diff --git a/bindings/python/src/RenderQueue.hpp b/bindings/python/src/RenderQueue.hpp deleted file mode 100644 index ecce3cec..00000000 --- a/bindings/python/src/RenderQueue.hpp +++ /dev/null @@ -1,40 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// PySFML - Python binding for SFML (Simple and Fast Multimedia Library) -// Copyright (C) 2007-2009 Rémi Koenig (remi.k2620@gmail.com) -// Stefan "Tank" Schindler -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#ifndef __PYRENDERQUEUE_H -#define __PYRENDERQUEUE_H - -#include - -#include - -struct PySfRenderQueue { - PyObject_HEAD - sf::RenderQueue* obj; -}; - -PySfRenderQueue* GetNewPySfRenderQueue(); - -#endif diff --git a/bindings/python/src/RenderWindow.cpp b/bindings/python/src/RenderWindow.cpp deleted file mode 100644 index d167b42d..00000000 --- a/bindings/python/src/RenderWindow.cpp +++ /dev/null @@ -1,286 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// PySFML - Python binding for SFML (Simple and Fast Multimedia Library) -// Copyright (C) 2007, 2008 Rémi Koenig (remi.k2620@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#include "RenderWindow.hpp" -#include "Image.hpp" -#include "Window.hpp" -#include "Color.hpp" -#include "Drawable.hpp" - -#include "compat.hpp" - -#include - - -extern PyTypeObject PySfViewType; -extern PyTypeObject PySfWindowType; -extern PyTypeObject PySfRenderWindowType; -extern PyTypeObject PySfColorType; -extern PyTypeObject PySfDrawableType; - - -static void -PySfRenderWindow_dealloc(PySfRenderWindow* self) -{ - Py_CLEAR(self->View); - delete self->obj; - free_object(self); -} - -static PyObject * -PySfRenderWindow_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PySfRenderWindow *self; - self = (PySfRenderWindow *)type->tp_alloc(type, 0); - if (self != NULL) - { - self->obj = new sf::RenderWindow(); - self->View = NULL; - } - return (PyObject *)self; -} - -static PyObject * -PySfRenderWindow_ConvertCoords(PySfRenderWindow *self, PyObject *args) -{ - unsigned int WindowX, WindowY; - PySfView *PyTargetView = NULL; - sf::Vector2f Vect; - - if (!PyArg_ParseTuple(args, "II|O!:RenderWindow.ConvertCoords", &WindowX, &WindowY, &PySfViewType, &PyTargetView)) - return NULL; - - if (PyTargetView) - { - Vect = self->obj->ConvertCoords(WindowX, WindowY, *PyTargetView->obj); - } - else - { - Vect = self->obj->ConvertCoords(WindowX, WindowY); - } - - return Py_BuildValue("ff", Vect.x, Vect.y); -} - -static bool -PySfRenderWindow_DrawObject(PySfRenderWindow *RenderWindow, PySfDrawable *Obj) -{ - if (PyObject_TypeCheck((PyObject *)Obj, &PySfDrawableType)) - { - if (Obj->IsCustom) - { - Py_CLEAR(Obj->obj->RenderWindow); - Py_INCREF(RenderWindow); - Obj->obj->RenderWindow = RenderWindow; - } - RenderWindow->obj->Draw(*(Obj->obj)); - return true; - } - return false; -} - -static PyObject * -PySfRenderWindow_Draw(PySfRenderWindow *self, PyObject *args) -{ - if (args == NULL) - return NULL; - if (!PySfRenderWindow_DrawObject(self, (PySfDrawable *)args)) - { - PyObject *iterator = PyObject_GetIter(args); - PyObject *item; - PyErr_Clear(); - if (iterator == NULL) - { - PyErr_SetString(PyExc_TypeError, "Argument to Draw method is neither a Drawable nor an iterable."); - return NULL; - } - while ((item = PyIter_Next(iterator))) - { - if (!PySfRenderWindow_DrawObject(self, (PySfDrawable *)item)) - { - PyErr_SetString(PyExc_TypeError, "Object in iterable not a Drawable."); - return NULL; - } - Py_DECREF(item); - } - Py_DECREF(iterator); - } - if (PyErr_Occurred()) - return NULL; - Py_RETURN_NONE; -} - - -static PyObject * -PySfRenderWindow_Clear(PySfRenderWindow *self, PyObject *args) -{ - PySfColor *Color = NULL; - if (!PyArg_ParseTuple(args, "|O!:RenderWindow.Clear", &PySfColorType, &Color)) - return NULL; - if (Color == NULL) self->obj->Clear(sf::Color::Black); - else - { - PySfColorUpdate(Color); - self->obj->Clear(*(Color->obj)); - } - Py_RETURN_NONE; -} - -static PyObject * -PySfRenderWindow_SetActive(PySfRenderWindow *self, PyObject *args) -{ - PyObject* Active( 0 ); - - PyArg_ParseTuple( args, "|O", &Active ); - self->obj->SetActive( Active == 0 ? true : PyBool_AsBool( Active ) ); - - Py_RETURN_NONE; -} - -static PyObject * -PySfRenderWindow_GetView(PySfRenderWindow *self) -{ - if (self->View != NULL) - { - Py_INCREF(self->View); - return (PyObject *)(self->View); - } - else - { - PySfView *View; - - View = GetNewPySfView(); - View->Owner = false; - View->obj = (sf::View *)&(self->obj->GetView()); - Py_INCREF(View); - self->View = View; - return (PyObject *)View; - } -} - -static PyObject * -PySfRenderWindow_SetView(PySfRenderWindow* self, PyObject *args) -{ - PySfView *View = (PySfView *)args; - if (!PyObject_TypeCheck(View, &PySfViewType)) - { - PyErr_SetString(PyExc_TypeError, "RenderWindow.SetView() Argument is not a sf.View"); - return NULL; - } - Py_CLEAR(self->View); - Py_INCREF(View); - self->View = View; - self->obj->SetView(*(View->obj)); - Py_RETURN_NONE; -} - -static PyObject * -PySfRenderWindow_GetDefaultView(PySfRenderWindow *self) -{ - PySfView *View; - - View = GetNewPySfView(); - View->Owner = false; - - // Python doesn't know anything about 'const', so cast away. Be careful with - // not changing the default view! - View->obj = const_cast( &( self->obj->GetDefaultView() ) ); - - return (PyObject *)View; -} - -static PyMethodDef PySfRenderWindow_methods[] = { - {"SetActive", (PyCFunction)PySfRenderWindow_SetActive, METH_VARARGS, "SetActive(Active)\n\ -Activate or deactivate the window as the current target for OpenGL rendering.\n\ - Active : True to activate window. (default: True)"}, - {"Clear", (PyCFunction)PySfRenderWindow_Clear, METH_VARARGS, "Clear(FillColor)\n\ -Clear the entire target with a single color.\n\ - FillColor : Color to use to clear the render target."}, - {"GetDefaultView", (PyCFunction)PySfRenderWindow_GetDefaultView, METH_NOARGS, "GetDefaultView()\n\ -Get the default view of the window for read / write (returns a sf.View instance)."}, - {"GetView", (PyCFunction)PySfRenderWindow_GetView, METH_NOARGS, "GetView()\n\ -Get the current view rectangle (returns a sf.View instance)."}, - {"SetView", (PyCFunction)PySfRenderWindow_SetView, METH_O, "SetView(View)\n\ -Change the current active view. View must be a sf.View instance."}, - {"Draw", (PyCFunction)PySfRenderWindow_Draw, METH_O, "Draw(Drawable)\n\ -Draw something on the window. The argument can be a drawable or any object supporting the iterator protocol and containing drawables (for example a tuple of drawables)."}, - {"ConvertCoords", (PyCFunction)PySfRenderWindow_ConvertCoords, METH_VARARGS, "ConvertCoords(WindowX, WindowY, TargetView)\n\ -Convert a point in window coordinates into view coordinates. Returns a tuple of two floats.\n\ - WindowX : X coordinate of the point to convert, relative to the window\n\ - WindowY : Y coordinate of the point to convert, relative to the window\n\ - TargetView : Target view to convert the point to (NULL by default -- uses the current view)."}, - {NULL} /* Sentinel */ -}; - -PyTypeObject PySfRenderWindowType = { - head_init - "RenderWindow", /*tp_name*/ - sizeof(PySfRenderWindow), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - (destructor)PySfRenderWindow_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash */ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ - "Simple wrapper for sf.Window that allows easy 2D rendering.\n\ -Default constructor : sf.RenderWindow()\n\ -Construct a new window : sf.RenderWindow(Mode, Title, Style::Resize|Style::Close, Params = WindowSettings())\n\ - Mode : Video mode to use\n\ - Title : Title of the window\n\ - WindowStyle : Window style (Resize | Close by default)\n\ - Params : Creation parameters (see default constructor for default values)\n\ -Construct the window from an existing control : sf.RenderWindow(Handle, Params)\n\ - Handle : handle of the control (long integer)\n\ - Params : Creation parameters (see default constructor for default values)", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - PySfRenderWindow_methods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - &PySfWindowType, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PySfRenderWindow_new, /* tp_new */ -}; - - diff --git a/bindings/python/src/RenderWindow.hpp b/bindings/python/src/RenderWindow.hpp deleted file mode 100644 index 0a488977..00000000 --- a/bindings/python/src/RenderWindow.hpp +++ /dev/null @@ -1,41 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// PySFML - Python binding for SFML (Simple and Fast Multimedia Library) -// Copyright (C) 2007, 2008 Rémi Koenig (remi.k2620@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#ifndef __PYRENDERWINDOW_HPP -#define __PYRENDERWINDOW_HPP - -#include - -#include - -#include "View.hpp" - -typedef struct { - PyObject_HEAD - sf::RenderWindow *obj; - PySfView *View; -} PySfRenderWindow; - - -#endif diff --git a/bindings/python/src/Shader.cpp b/bindings/python/src/Shader.cpp deleted file mode 100644 index 2a5dd383..00000000 --- a/bindings/python/src/Shader.cpp +++ /dev/null @@ -1,194 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// PySFML - Python binding for SFML (Simple and Fast Multimedia Library) -// Copyright (C) 2007, 2008 Rémi Koenig (remi.k2620@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#include "Shader.hpp" -#include "Drawable.hpp" -#include "Image.hpp" - -#include "compat.hpp" - - -extern PyTypeObject PySfImageType; -extern PyTypeObject PySfDrawableType; - - -static void -PySfShader_dealloc(PySfShader *self) -{ - delete self->obj; - free_object(self); -} - -static PyObject * -PySfShader_new(PyTypeObject *type, PyObject *args, PyObject *kwds); - -static PyObject * -PySfShader_LoadFromFile (PySfShader *self, PyObject *args) -{ - load_from_file(self, args); -} - -static PyObject * -PySfShader_LoadFromMemory (PySfShader *self, PyObject *args) -{ - char *effect; -#ifdef IS_PY3K - PyObject *string = PyUnicode_AsUTF8String(args); - if (string == NULL) - return NULL; - effect = PyBytes_AsString(string); -#else - effect = PyString_AsString(args); -#endif - bool result = self->obj->LoadFromMemory(effect); -#ifdef IS_PY3K - Py_DECREF(string); -#endif - return PyBool_FromLong(result); -} - -static PyObject * PySfShader_SetParameter(PySfShader* self, PyObject *args) { char *Name; float X, Y, Z, W; int size = PyTuple_Size(args); if (!PyArg_ParseTuple(args, "sf|fff:Shader.SetParameter", &Name, &X, &Y, &Z, &W)) return NULL; - - switch (size) - { - case 2: - self->obj->SetParameter(Name, X); - break; - case 3: - self->obj->SetParameter(Name, X, Y); - break; - case 4: - self->obj->SetParameter(Name, X, Y, Z); - break; - case 5: - self->obj->SetParameter(Name, X, Y, Z, W); - break; - default: - break; - } - - Py_RETURN_NONE; -} - -static PyObject * -PySfShader_SetTexture(PySfShader* self, PyObject *args) -{ - PySfImage *Image = NULL; - char *Name; - if (! PyArg_ParseTuple(args, "sO", &Name, &Image)) - { - return NULL; - } - - if (!PyObject_TypeCheck(Image, &PySfImageType)) - { - PyErr_SetString(PyExc_TypeError, "Shader.SetTexture() Argument 2 must be an sf.Image instance."); - return NULL; - } - - self->obj->SetTexture(Name, *Image->obj); - - Py_RETURN_NONE; -} - -static PyObject * -PySfShader_IsAvailable(PySfShader* self, PyObject *args) -{ - return PyBool_FromLong(sf::Shader::IsAvailable()); -} - - -static PyMethodDef PySfShader_methods[] = { - {"LoadFromFile", (PyCFunction)PySfShader_LoadFromFile, METH_O, "LoadFromFile(Filename)\nLoad the effect from a file."}, - {"LoadFromMemory", (PyCFunction)PySfShader_LoadFromMemory, METH_O, "LoadFromMemory(Effect)\nLoad the effect from a text in memory."}, - {"SetParameter", (PyCFunction)PySfShader_SetParameter, METH_VARARGS, "SetParameter(X), SetParameter(X, Y), SetParameter(X, Y, Z), SetParameter(X, Y, Z, W)\nChange a parameter of the effect.\n\ - Name : Parameter name in the effect\n\ - X,Y,Z,W : Values to assign."}, - {"SetTexture", (PyCFunction)PySfShader_SetTexture, METH_VARARGS, "SetTexture(Name, Texture)\nSet a texture parameter.\n\ - Name : Texture name in the effect\n\ - Texture : Image to set (pass sf.Shader.CurrentTexture to use content of current framebuffer)"}, - {"IsAvailable", (PyCFunction)PySfShader_IsAvailable, METH_STATIC | METH_NOARGS, "IsAvailable()\nTell wether or not the system supports post-effects."}, - {NULL} /* Sentinel */ -}; - -PyTypeObject PySfShaderType = { - head_init - "Shader", /*tp_name*/ - sizeof(PySfShader), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - (destructor)PySfShader_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash */ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ - "sf.Shader is used to apply a post effect to a window.\n\ -Default constructor : sf.Shader()\n\ -Copy constructor : sf.Shader(Copy) where Copy is a sf.Shader instance.", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - PySfShader_methods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - &PySfDrawableType, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PySfShader_new, /* tp_new */ -}; - - -static PyObject * -PySfShader_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PySfShader *self; - self = (PySfShader *)type->tp_alloc(type, 0); - if (self != NULL) - { - PySfShader *Copy = NULL; - self->IsCustom = false; - if (!PyArg_ParseTuple(args, "|O!", &PySfShaderType, &Copy)) - return NULL; - if (Copy) self->obj = new sf::Shader(*(Copy->obj)); - else self->obj = new sf::Shader(); - } - return (PyObject *)self; -} diff --git a/bindings/python/src/Shader.hpp b/bindings/python/src/Shader.hpp deleted file mode 100644 index ebfcde32..00000000 --- a/bindings/python/src/Shader.hpp +++ /dev/null @@ -1,38 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// PySFML - Python binding for SFML (Simple and Fast Multimedia Library) -// Copyright (C) 2007, 2008 Rémi Koenig (remi.k2620@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#ifndef __PYPOSTFX_HPP -#define __PYPOSTFX_HPP - -#include - -#include - -typedef struct { - PyObject_HEAD - bool IsCustom; - sf::Shader *obj; -} PySfShader; - -#endif diff --git a/bindings/python/src/Shape.cpp b/bindings/python/src/Shape.cpp deleted file mode 100644 index 6ac2dd4a..00000000 --- a/bindings/python/src/Shape.cpp +++ /dev/null @@ -1,379 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// PySFML - Python binding for SFML (Simple and Fast Multimedia Library) -// Copyright (C) 2007, 2008 Rémi Koenig (remi.k2620@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#include "Shape.hpp" - -#include -#include "Color.hpp" - -#include "compat.hpp" - -extern PyTypeObject PySfColorType; -extern PyTypeObject PySfDrawableType; - - -static void -PySfShape_dealloc(PySfShape* self) -{ - delete self->obj; - free_object(self); -} - -static PyObject * -PySfShape_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PySfShape *self; - self = (PySfShape *)type->tp_alloc(type, 0); - if (self != NULL) - { - self->obj = new sf::Shape(); - self->IsCustom = false; - } - return (PyObject *)self; -} - -// void AddPoint(float X, float Y, const Color& Col = Color(255, 255, 255), const Color& OutlineCol = Color(0, 0, 0)); -static PyObject * -PySfShape_AddPoint(PySfShape* self, PyObject *args, PyObject *kwds) -{ - const char *kwlist[] = {"X", "Y", "Col", "OutlineCol", NULL}; - float X, Y; - sf::Color *Col, *OutlineCol; - PySfColor *ColTmp=NULL, *OutlineColTmp=NULL; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "ff|O!O!:Shape.AddPoint", (char **)kwlist, &X, &Y, &PySfColorType, &ColTmp, &PySfColorType, &OutlineColTmp)) - return NULL; - - if (ColTmp) - { - PySfColorUpdate(ColTmp); - Col = ColTmp->obj; - } - else - Col = (sf::Color *)&sf::Color::White; - - if (OutlineColTmp) - { - PySfColorUpdate(OutlineColTmp); - OutlineCol = OutlineColTmp->obj; - } - else - OutlineCol = (sf::Color *)&sf::Color::Black; - - self->obj->AddPoint(X, Y, *Col, *OutlineCol); - - Py_RETURN_NONE; -} - -static PyObject * -PySfShape_SetOutlineWidth(PySfShape* self, PyObject *args) -{ - self->obj->SetOutlineWidth(PyFloat_AsDouble(args)); - Py_RETURN_NONE; -} - -static PyObject * -PySfShape_GetOutlineWidth(PySfShape* self) -{ - return PyFloat_FromDouble(self->obj->GetOutlineWidth()); -} - -// static Shape Line(float X0, float Y0, float X1, float Y1, float Thickness, const Color& Col, float Outline = 0.f, const Color& OutlineCol = sf::Color(0, 0, 0)); -static PyObject * -PySfShape_Line(PySfShape* self, PyObject *args, PyObject *kwds) -{ - const char *kwlist[] = {"X0", "Y0", "X1", "Y1", "Thickness", "Col", "Outline", "OutlineCol", NULL}; - PySfShape *Line = GetNewPySfShape(); - float X0, Y0, X1, Y1, Thickness, Outline = 0.f; - sf::Color *OutlineCol; - PySfColor *ColTmp, *OutlineColTmp=NULL; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "fffffO!|fO!:Shape.Line", (char **)kwlist, &X0, &Y0, &X1, &Y1, &Thickness, &PySfColorType, &ColTmp, &Outline, &PySfColorType, &OutlineColTmp)) - return NULL; - if (OutlineColTmp) - { - PySfColorUpdate(OutlineColTmp); - OutlineCol = OutlineColTmp->obj; - } - else - OutlineCol = (sf::Color *)&sf::Color::Black; - - PySfColorUpdate(ColTmp); - Line->obj = new sf::Shape(sf::Shape::Line(X0, Y0, X1, Y1, Thickness, *(ColTmp->obj), Outline, *OutlineCol)); - return (PyObject *)Line; -} - -// static Shape Rectangle(float X0, float Y0, float X1, float Y1, const Color& Col, float Outline = 0.f, const Color& OutlineCol = sf::Color(0, 0, 0)); -static PyObject * -PySfShape_Rectangle(PySfShape* self, PyObject *args, PyObject *kwds) -{ - const char *kwlist[] = {"X0", "Y0", "X1", "Y1", "Col", "Outline", "OutlineCol", NULL}; - PySfShape *Rectangle = GetNewPySfShape(); - float X0, Y0, X1, Y1, Outline = 0.f; - sf::Color *OutlineCol; - PySfColor *ColTmp, *OutlineColTmp=NULL; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "ffffO!|fO!:Shape.Rectangle", (char **)kwlist, &X0, &Y0, &X1, &Y1, &PySfColorType, &ColTmp, &Outline, &PySfColorType, &OutlineColTmp)) - return NULL; - if (OutlineColTmp) - { - PySfColorUpdate(OutlineColTmp); - OutlineCol = OutlineColTmp->obj; - } - else - OutlineCol = (sf::Color *)&sf::Color::Black; - - PySfColorUpdate(ColTmp); - Rectangle->obj = new sf::Shape(sf::Shape::Rectangle(X0, Y0, X1, Y1, *(ColTmp->obj), Outline, *OutlineCol)); - return (PyObject *)Rectangle; -} - -// static Shape Circle(float X, float Y, float Radius, const Color& Col, float Outline = 0.f, const Color& OutlineCol = sf::Color(0, 0, 0)); -static PyObject * -PySfShape_Circle(PySfShape* self, PyObject *args, PyObject *kwds) -{ - const char *kwlist[] = {"X", "Y", "Radius", "Col", "Outline", "OutlineCol", NULL}; - PySfShape *Circle = GetNewPySfShape(); - float X, Y, Radius, Outline = 0.f; - sf::Color *OutlineCol; - PySfColor *ColTmp, *OutlineColTmp=NULL; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "fffO!|fO!:Shape.Circle", (char **)kwlist, &X, &Y, &Radius, &PySfColorType, &ColTmp, &Outline, &PySfColorType, &OutlineColTmp)) - return NULL; - if (OutlineColTmp) - { - PySfColorUpdate(OutlineColTmp); - OutlineCol = OutlineColTmp->obj; - } - else - OutlineCol = (sf::Color *)&sf::Color::Black; - - PySfColorUpdate(ColTmp); - Circle->obj = new sf::Shape(sf::Shape::Circle(X, Y, Radius, *(ColTmp->obj), Outline, *OutlineCol)); - return (PyObject *)Circle; -} - -static PyObject * -PySfShape_GetPointPosition(PySfShape* self, PyObject *args) -{ - sf::Vector2f result = self->obj->GetPointPosition(PyLong_AsUnsignedLong(args)); - return Py_BuildValue("ff", result.x, result.y); -} - -static PyObject * -PySfShape_GetPointColor(PySfShape* self, PyObject *args) -{ - PySfColor *PyColor = GetNewPySfColor(); - PyColor->obj = new sf::Color(self->obj->GetPointColor(PyLong_AsUnsignedLong(args))); - PyColor->r = PyColor->obj->r; - PyColor->g = PyColor->obj->g; - PyColor->b = PyColor->obj->b; - PyColor->a = PyColor->obj->a; - return (PyObject *)PyColor; -} - -static PyObject * -PySfShape_GetPointOutlineColor(PySfShape* self, PyObject *args) -{ - PySfColor *PyColor = GetNewPySfColor(); - PyColor->obj = new sf::Color(self->obj->GetPointOutlineColor(PyLong_AsUnsignedLong(args))); - PyColor->r = PyColor->obj->r; - PyColor->g = PyColor->obj->g; - PyColor->b = PyColor->obj->b; - PyColor->a = PyColor->obj->a; - return (PyObject *)PyColor; -} - -static PyObject * -PySfShape_SetPointPosition(PySfShape* self, PyObject *args) -{ - unsigned int Index; - float X, Y; - if (!PyArg_ParseTuple(args, "Iff:Shape.SetPointPosition", &Index, &X, &Y)) - return NULL; - self->obj->SetPointPosition(Index, X, Y); - Py_RETURN_NONE; -} - -static PyObject * -PySfShape_SetPointColor(PySfShape* self, PyObject *args) -{ - unsigned int Index; - PySfColor *Color; - if (!PyArg_ParseTuple(args, "IO!:Shape.SetPointColor", &Index, &PySfColorType, &Color)) - return NULL; - PySfColorUpdate(Color); - self->obj->SetPointColor(Index, *(Color->obj)); - Py_RETURN_NONE; -} - -static PyObject * -PySfShape_SetPointOutlineColor(PySfShape* self, PyObject *args) -{ - unsigned int Index; - PySfColor *Color; - if (!PyArg_ParseTuple(args, "IO!:Shape.SetPointOutlineColor", &Index, &PySfColorType, &Color)) - return NULL; - PySfColorUpdate(Color); - self->obj->SetPointOutlineColor(Index, *(Color->obj)); - Py_RETURN_NONE; -} - -static PyObject * -PySfShape_GetNbPoints(PySfShape* self, PyObject *args) -{ - return PyLong_FromUnsignedLong(self->obj->GetNbPoints()); -} - -static PyObject * -PySfShape_EnableFill(PySfShape* self, PyObject *args) -{ - self->obj->EnableFill(PyBool_AsBool(args)); - Py_RETURN_NONE; -} - -static PyObject * -PySfShape_EnableOutline(PySfShape* self, PyObject *args) -{ - self->obj->EnableOutline(PyBool_AsBool(args)); - Py_RETURN_NONE; -} - -static PyMethodDef PySfShape_methods[] = { - {"GetPointPosition", (PyCFunction)PySfShape_GetPointPosition, METH_O, "GetPointPosition(Index)\n\ -Get the position of a point.\n\ - Index : Index-th point."}, - {"GetPointColor", (PyCFunction)PySfShape_GetPointColor, METH_O, "GetPointColor(Index)\n\ -Get the color of a point.\n Index : Index-th point."}, - {"GetPointOutlineColor", (PyCFunction)PySfShape_GetPointOutlineColor, METH_O, "GetPointOutlineColor(Index)\n\ -Get the outline color of a point.\n Index : Index-th point."}, - {"SetPointPosition", (PyCFunction)PySfShape_SetPointPosition, METH_VARARGS, "SetPointPosition(Index, X, Y).\n\ -Set the position of a point\n\ - Index : Index of the point, in range [0, GetNbPoints() - 1]\n\ - X : New X coordinate of the Index-th point\n\ - Y : New Y coordinate of the Index-th point."}, - {"SetPointColor", (PyCFunction)PySfShape_SetPointColor, METH_VARARGS, "SetPointColor(Index, Color).\n\ -Set the color of a point\n\ - Index : Index of the point, in range [0, GetNbPoints() - 1]\n\ - Col : New color of the Index-th point."}, - {"SetPointOutlineColor", (PyCFunction)PySfShape_SetPointOutlineColor, METH_VARARGS, "SetPointOutlineColor(Index, Color).\n\ -Set the outline color of a point\n\ - Index : Index of the point, in range [0, GetNbPoints() - 1]\n\ - Col : New color of the Index-th point."}, - {"GetNbPoints", (PyCFunction)PySfShape_GetNbPoints, METH_NOARGS, "GetNbPoints()\n\ -Get the number of points composing the shape."}, - {"EnableFill", (PyCFunction)PySfShape_EnableFill, METH_O, "EnableFill(Enable)\n\ -Enable or disable filling the shape. Fill is enabled by default.\n\ - Enable : True to enable, false to disable."}, - {"EnableOutline", (PyCFunction)PySfShape_EnableOutline, METH_O, "EnableOutline(Enable)\n\ -Enable or disable drawing the shape outline. Outline is enabled by default.\n\ - Enable : True to enable, false to disable"}, - {"AddPoint", (PyCFunction)PySfShape_AddPoint, METH_VARARGS | METH_KEYWORDS, "AddPoint(X, Y, Col=sf.Color.White, OutlineCol=sf.Color.Black)\n\ -Add a point to the shape.\n\ - X : X coordinate of the point\n\ - Y : Y coordinate of the point\n\ - Col : Color of the point (white by default)\n\ - OutlineCol : Outline color of the point (black by default)."}, - {"SetOutlineWidth", (PyCFunction)PySfShape_SetOutlineWidth, METH_O, "SetOutlineWidth(Width)\n\ -Change the width of the shape outline.\n\ - Width : New width (use 0 to remove the outline)."}, - {"GetOutlineWidth", (PyCFunction)PySfShape_GetOutlineWidth, METH_NOARGS, "GetOutlineWidth()\n\ -Get the width of the shape outline."}, - {"Line", (PyCFunction)PySfShape_Line, METH_STATIC | METH_VARARGS | METH_KEYWORDS, "Line(X0, Y0, X1, Y1, Thickness, Col, Outline = 0., OutlineCol = sf.Color(0, 0, 0))\n\ -Create a shape made of a single line.\n\ - X0 : X coordinate of the first point.\n\ - Y0 : Y coordinate of the first point.\n\ - X1 : X coordinate of the second point.\n\ - Y1 : Y coordinate of the second point.\n\ - Thickness : Line thickness.\n\ - Col : Color used to draw the line\n\ - Outline : Outline width (0 by default)\n\ - OutlineCol : Color used to draw the outline (black by default)."}, - {"Rectangle", (PyCFunction)PySfShape_Rectangle, METH_STATIC | METH_VARARGS | METH_KEYWORDS, "Rectangle(X0, Y0, X1, Y1, Col, Outline = 0., OutlineCol = sf.Color(0, 0, 0))\n\ -Create a shape made of a single rectangle.\n\ - X0 : X coordinate of the first point.\n\ - Y0 : Y coordinate of the first point.\n\ - X1 : X coordinate of the second point.\n\ - Y1 : Y coordinate of the second point.\n\ - Col : Color used to fill the rectangle.\n\ - Outline : Outline width (0 by default).\n\ - OutlineCol : Color used to draw the outline (black by default)."}, - {"Circle", (PyCFunction)PySfShape_Circle, METH_STATIC | METH_VARARGS | METH_KEYWORDS, "Circle(X, Y, Radius, Col, Outline = 0., OutlineCol = sf.Color(0, 0, 0))\n\ -Create a shape made of a single circle.\n\ - X : X coordinate of the center.\n\ - Y : Y coordinate of the center.\n\ - Radius : Radius\n\ - Col : Color used to fill the rectangle.\n\ - Outline : Outline width (0 by default).\n\ - OutlineCol : Color used to draw the outline (black by default)."}, - {NULL} /* Sentinel */ -}; - - -PyTypeObject PySfShapeType = { - head_init - "Shape", /*tp_name*/ - sizeof(PySfShape), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - (destructor)PySfShape_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash */ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ - "Shape defines a drawable convex shape ; it also defines helper functions to draw simple shapes like lines, rectangles, circles, etc.\nDefault constructor: Shape()", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - PySfShape_methods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - &PySfDrawableType, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PySfShape_new, /* tp_new */ -}; - - -PySfShape * -GetNewPySfShape() -{ - PySfShape *Shape = PyObject_New(PySfShape, &PySfShapeType); - Shape->IsCustom = false; - return Shape; -} - diff --git a/bindings/python/src/Shape.hpp b/bindings/python/src/Shape.hpp deleted file mode 100644 index 7e21bfc9..00000000 --- a/bindings/python/src/Shape.hpp +++ /dev/null @@ -1,42 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// PySFML - Python binding for SFML (Simple and Fast Multimedia Library) -// Copyright (C) 2007, 2008 Rémi Koenig (remi.k2620@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#ifndef __PYSHAPE_HPP -#define __PYSHAPE_HPP - -#include - -#include - - -typedef struct { - PyObject_HEAD - bool IsCustom; - sf::Shape *obj; -} PySfShape; - -PySfShape * -GetNewPySfShape(); - -#endif diff --git a/bindings/python/src/Sleep.cpp b/bindings/python/src/Sleep.cpp deleted file mode 100644 index 303c8856..00000000 --- a/bindings/python/src/Sleep.cpp +++ /dev/null @@ -1,33 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// PySFML - Python binding for SFML (Simple and Fast Multimedia Library) -// Copyright (C) 2007, 2008 Rémi Koenig (remi.k2620@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#include "Sleep.hpp" - -PyObject * -PySFML_Sleep (PyObject *self, PyObject *args) -{ - sf::Sleep(PyFloat_AsDouble(args)); - Py_RETURN_NONE; -} - diff --git a/bindings/python/src/Sleep.hpp b/bindings/python/src/Sleep.hpp deleted file mode 100644 index 3c78fd73..00000000 --- a/bindings/python/src/Sleep.hpp +++ /dev/null @@ -1,35 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// PySFML - Python binding for SFML (Simple and Fast Multimedia Library) -// Copyright (C) 2007, 2008 Rémi Koenig (remi.k2620@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#ifndef __PYSLEEP_HPP -#define __PYSLEEP_HPP - -#include - -#include - -PyObject * -PySFML_Sleep (PyObject *self, PyObject *args); - -#endif diff --git a/bindings/python/src/Sound.cpp b/bindings/python/src/Sound.cpp deleted file mode 100644 index 926d2c69..00000000 --- a/bindings/python/src/Sound.cpp +++ /dev/null @@ -1,338 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// PySFML - Python binding for SFML (Simple and Fast Multimedia Library) -// Copyright (C) 2007, 2008 Rémi Koenig (remi.k2620@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#include "Sound.hpp" -#include "SoundBuffer.hpp" - -#include "compat.hpp" - - -extern PyTypeObject PySfSoundBufferType; - - -static void -PySfSound_dealloc(PySfSound *self) -{ - delete self->obj; - free_object(self); -} - -static PyObject * -PySfSound_new(PyTypeObject *type, PyObject *args, PyObject *kwds); - -static int -PySfSound_init(PySfSound *self, PyObject *args, PyObject *kwds) -{ - const char *kwlist[] = {"Buffer", "Loop", "Pitch", "Volume", "X", "Y", "Z", NULL}; - PySfSoundBuffer *Buffer=NULL; - PyObject *Loop=NULL; - float Pitch=1.f, Volume=100.f, X=0.f, Y=0.f, Z=0.f; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O!Offfff:Sound.__new__", (char **)kwlist, &PySfSoundBufferType, &Buffer, &Loop, &Pitch, &Volume, &X, &Y, &Z)) - return -1; - { - if (Loop) - self->obj->SetLoop(PyBool_AsBool(Loop)); - if (Buffer) - self->obj->SetBuffer(*(Buffer->obj)); - self->obj->SetPitch(Pitch); - self->obj->SetVolume(Volume); - self->obj->SetPosition(X, Y, Z); - } - return 0; -} - -static PyObject* -PySfSound_SetBuffer(PySfSound *self, PyObject *args) -{ - PySfSoundBuffer *Buffer = (PySfSoundBuffer *)args; - if (!PyObject_TypeCheck(args, &PySfSoundBufferType)) - { - PyErr_SetString(PyExc_TypeError, "Sound.SetBuffer() The argument must be a sf.SoundBuffer."); - return NULL; - } - - self->obj->SetBuffer(*(Buffer->obj)); - Py_RETURN_NONE; -} - -static PyObject* -PySfSound_SetLoop(PySfSound *self, PyObject *args) -{ - self->obj->SetLoop(PyBool_AsBool(args)); - Py_RETURN_NONE; -} - -static PyObject* -PySfSound_SetRelativeToListener(PySfSound *self, PyObject *args) -{ - self->obj->SetRelativeToListener(PyBool_AsBool(args)); - Py_RETURN_NONE; -} - -static PyObject* -PySfSound_IsRelativeToListener(PySfSound *self) -{ - return PyBool_FromLong(self->obj->IsRelativeToListener()); -} - -static PyObject* -PySfSound_SetPitch(PySfSound *self, PyObject *args) -{ - self->obj->SetPitch(PyFloat_AsDouble(args)); - Py_RETURN_NONE; -} - -static PyObject* -PySfSound_SetMinDistance(PySfSound *self, PyObject *args) -{ - self->obj->SetMinDistance(PyFloat_AsDouble(args)); - Py_RETURN_NONE; -} - -static PyObject* -PySfSound_SetAttenuation(PySfSound *self, PyObject *args) -{ - self->obj->SetAttenuation(PyFloat_AsDouble(args)); - Py_RETURN_NONE; -} - -static PyObject* -PySfSound_SetVolume(PySfSound *self, PyObject *args) -{ - self->obj->SetVolume(PyFloat_AsDouble(args)); - Py_RETURN_NONE; -} - -static PyObject* -PySfSound_GetPitch(PySfSound *self) -{ - return PyFloat_FromDouble(self->obj->GetPitch()); -} - -static PyObject* -PySfSound_GetMinDistance(PySfSound *self) -{ - return PyFloat_FromDouble(self->obj->GetMinDistance()); -} - -static PyObject* -PySfSound_GetAttenuation(PySfSound *self) -{ - return PyFloat_FromDouble(self->obj->GetAttenuation()); -} - -static PyObject* -PySfSound_GetVolume(PySfSound *self) -{ - return PyFloat_FromDouble(self->obj->GetVolume()); -} - -static PyObject* -PySfSound_GetPosition(PySfSound *self) -{ - sf::Vector3f Vect = self->obj->GetPosition(); - return Py_BuildValue("fff", Vect.x, Vect.y, Vect.z); -} - -static PyObject* -PySfSound_GetPlayingOffset(PySfSound *self) -{ - return PyFloat_FromDouble(self->obj->GetPlayingOffset()); -} - -static PyObject* -PySfSound_GetLoop(PySfSound *self) -{ - return PyBool_FromLong(self->obj->GetLoop()); -} - -static PyObject* -PySfSound_Play(PySfSound *self) -{ - self->obj->Play(); - Py_RETURN_NONE; -} - -static PyObject* -PySfSound_Pause(PySfSound *self) -{ - self->obj->Pause(); - Py_RETURN_NONE; -} - -static PyObject* -PySfSound_Stop(PySfSound *self) -{ - self->obj->Stop(); - Py_RETURN_NONE; -} - -static PyObject* -PySfSound_GetStatus(PySfSound *self) -{ - return PyLong_FromUnsignedLong(self->obj->GetStatus()); -} - -static PyObject* -PySfSound_SetPosition(PySfSound *self, PyObject *args) -{ - float X, Y, Z; - if (!PyArg_ParseTuple(args, "fff:Sound.SetPosition", &X, &Y, &Z)) - return NULL; - self->obj->SetPosition(X, Y, Z); - Py_RETURN_NONE; -} - -static PyObject * -PySfSound_GetBuffer(PySfSound *self) -{ - PySfSoundBuffer *Buffer; - - Buffer = GetNewPySfSoundBuffer(); - Buffer->obj = new sf::SoundBuffer(*(self->obj->GetBuffer())); - - return (PyObject *)Buffer; -} - -static PyObject* -PySfSound_SetPlayingOffset(PySfSound *self, PyObject *args) -{ - self->obj->SetPlayingOffset(PyFloat_AsDouble(args)); - Py_RETURN_NONE; -} - -static PyMethodDef PySfSound_methods[] = { - {"SetRelativeToListener", (PyCFunction)PySfSound_SetRelativeToListener, METH_O, "SetRelativeToListener(Relative)\nMake the sound's position relative to the listener's position, or absolute. The default value is false (absolute)\n Relative : True to set the position relative, false to set it absolute"}, - {"IsRelativeToListener", (PyCFunction)PySfSound_IsRelativeToListener, METH_NOARGS, "IsRelativeToListener()\nTell if the sound's position is relative to the listener's position, or if it's absolute."}, - {"SetPlayingOffset", (PyCFunction)PySfSound_SetPlayingOffset, METH_O, "SetPlayingOffset(TimeOffset)\nSet the current playing position of the sound.\n TimeOffset : New playing position, expressed in seconds"}, - {"SetLoop", (PyCFunction)PySfSound_SetLoop, METH_O, "SetLoop(Loop)\nSet the Sound loop state.\n Loop : True to play in loop, false to play once"}, - {"SetBuffer", (PyCFunction)PySfSound_SetBuffer, METH_O, "SetBuffer(Buffer)\nSet the source buffer.\n Buffer : New sound buffer to bind to the sound "}, - {"SetPitch", (PyCFunction)PySfSound_SetPitch, METH_O, "SetPitch(Pitch)\nSet the sound pitch. The default pitch is 1.\n Pitch : New pitch"}, - {"SetMinDistance", (PyCFunction)PySfSound_SetMinDistance, METH_O, "SetMinDistance(MinDistance)\nSet the minimum distance - closer than this distance, the listener will hear the sound at its maximum volume. The default minimum distance is 1.0.\n MinDistance : New minimum distance for the sound"}, - {"SetAttenuation", (PyCFunction)PySfSound_SetAttenuation, METH_O, "SetAttenuation(Attenuation)\nSet the attenuation factor - the higher the attenuation, the more the sound will be attenuated with distance from listener. The default attenuation factor 1.0.\n Attenuation : New attenuation factor for the sound"}, - {"SetVolume", (PyCFunction)PySfSound_SetVolume, METH_O, "SetVolume(Volume)\nSet the sound volume.\n Volume : Volume (in range [0, 100])"}, - {"SetPosition", (PyCFunction)PySfSound_SetPosition, METH_VARARGS, "SetPosition(X, Y, Z)\nSet the sound position in the world.\n X,Y,Z : Position of the sound in the world"}, - {"GetLoop", (PyCFunction)PySfSound_GetLoop, METH_NOARGS, "GetLoop()\nTell whether or not the Sound is looping."}, - {"GetBuffer", (PyCFunction)PySfSound_GetBuffer, METH_NOARGS, "GetBuffer()\nGet the source buffer. Returns a new sf.SoundBuffer object."}, - {"GetPitch", (PyCFunction)PySfSound_GetPitch, METH_NOARGS, "GetPitch()\nGet the sound pitch."}, - {"GetMinDistance", (PyCFunction)PySfSound_GetMinDistance, METH_NOARGS, "GetMinDistance()\nGet the minimum distance."}, - {"GetAttenuation", (PyCFunction)PySfSound_GetAttenuation, METH_NOARGS, "GetAttenuation()\nGet the attenuation factor."}, - {"GetVolume", (PyCFunction)PySfSound_GetVolume, METH_NOARGS, "GetVolume()\nGet the sound volume."}, - {"GetPosition", (PyCFunction)PySfSound_GetPosition, METH_NOARGS, "GetPosition()\nGet the sound position in the world. Returns a tuple."}, - {"Play", (PyCFunction)PySfSound_Play, METH_NOARGS, "Play()\nPlay the sound."}, - {"Pause", (PyCFunction)PySfSound_Pause, METH_NOARGS, "Pause()\nPause the sound."}, - {"Stop", (PyCFunction)PySfSound_Stop, METH_NOARGS, "Stop()\nStop the sound."}, - {"GetStatus", (PyCFunction)PySfSound_GetStatus, METH_NOARGS, "GetStatus()\nGet the status of the sound (stopped, paused, playing)."}, - {"GetPlayingOffset", (PyCFunction)PySfSound_GetPlayingOffset, METH_NOARGS, "GetPlayingOffset()\nGet the current playing position of the sound."}, - {NULL} /* Sentinel */ -}; - -PyTypeObject PySfSoundType = { - head_init - "Sound", /*tp_name*/ - sizeof(PySfSound), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - (destructor)PySfSound_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash */ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ - "sf.Sound defines the properties of a sound such as position, volume, pitch, etc.\n\ -Default constructor : Sound()\n\ -Construct the sound from its parameters : Sound(Buffer, Loop = False, Pitch = 1., Volume = 100., X = 0., Y = 0., Z = 0.);\n\ - Buffer : Sound buffer to play (None by default)\n\ - Loop : Loop flag (False by default)\n\ - Pitch : Value of the pitch (1. by default)\n\ - Volume : Volume (100. by default)\n\ - X : X position (0. by default)\n\ - Y : Y position (0. by default)\n\ - Z : Z position (0. by default)\n\ -Copy constructor : Sound(Copy) where Copy is a sf.Sound instance.", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - PySfSound_methods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc)PySfSound_init, /* tp_init */ - 0, /* tp_alloc */ - PySfSound_new, /* tp_new */ -}; - -static PyObject * -PySfSound_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PySfSound *self; - self = (PySfSound *)type->tp_alloc(type, 0); - if (self != NULL) - { - if (PyTuple_Size(args) == 1) - { - PySfSound *Copy; - if (PyArg_ParseTuple(args, "O!:Sound.__new__", &PySfSoundType, &Copy)) - { - self->obj = new sf::Sound(*(Copy->obj)); - return (PyObject *)self; - } - else PyErr_Clear(); - } - self->obj = new sf::Sound(); - } - return (PyObject *)self; -} - -void -PySfSound_InitConst() -{ - PyObject *obj; - obj = PyLong_FromLong(sf::Sound::Stopped); - PyDict_SetItemString(PySfSoundType.tp_dict, "Stopped", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Sound::Paused); - PyDict_SetItemString(PySfSoundType.tp_dict, "Paused", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Sound::Playing); - PyDict_SetItemString(PySfSoundType.tp_dict, "Playing", obj); - Py_DECREF(obj); -} - diff --git a/bindings/python/src/Sound.hpp b/bindings/python/src/Sound.hpp deleted file mode 100644 index 4992a5d7..00000000 --- a/bindings/python/src/Sound.hpp +++ /dev/null @@ -1,40 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// PySFML - Python binding for SFML (Simple and Fast Multimedia Library) -// Copyright (C) 2007, 2008 Rémi Koenig (remi.k2620@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#ifndef __PYSOUND_HPP -#define __PYSOUND_HPP - -#include - -#include - -typedef struct { - PyObject_HEAD - sf::Sound *obj; -} PySfSound; - -void -PySfSound_InitConst(); - -#endif diff --git a/bindings/python/src/SoundBuffer.cpp b/bindings/python/src/SoundBuffer.cpp deleted file mode 100644 index bf4ac168..00000000 --- a/bindings/python/src/SoundBuffer.cpp +++ /dev/null @@ -1,194 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// PySFML - Python binding for SFML (Simple and Fast Multimedia Library) -// Copyright (C) 2007, 2008 Rémi Koenig (remi.k2620@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#include "SoundBuffer.hpp" - -#include "compat.hpp" - - -static void -PySfSoundBuffer_dealloc(PySfSoundBuffer *self) -{ - delete self->obj; - free_object(self); -} - -static PyObject * -PySfSoundBuffer_new(PyTypeObject *type, PyObject *args, PyObject *kwds); - -static PyObject* -PySfSoundBuffer_LoadFromFile(PySfSoundBuffer *self, PyObject *args) -{ - load_from_file(self, args); -} - -static PyObject * -PySfSoundBuffer_LoadFromMemory(PySfSoundBuffer* self, PyObject *args) -{ - unsigned int SizeInBytes; - char *Data; - - if (!PyArg_ParseTuple(args, "s#:SoundBuffer.LoadFromMemory", &Data, &SizeInBytes)) - return NULL; - - return PyBool_FromLong(self->obj->LoadFromMemory(Data, (std::size_t) SizeInBytes)); -} - -static PyObject * -PySfSoundBuffer_LoadFromSamples(PySfSoundBuffer* self, PyObject *args) -{ - unsigned int SizeInBytes, ChannelsCount, SampleRate; - char *Data; - - if (!PyArg_ParseTuple(args, "s#II:SoundBuffer.LoadFromSamples", &Data, &SizeInBytes, &ChannelsCount, &SampleRate)) - return NULL; - - return PyBool_FromLong(self->obj->LoadFromSamples((const sf::Int16*)Data, (std::size_t) SizeInBytes/2, ChannelsCount, SampleRate)); -} - -static PyObject* -PySfSoundBuffer_GetSamples(PySfSoundBuffer *self) -{ -#ifdef IS_PY3K - return PyBytes_FromStringAndSize((const char *)(self->obj->GetSamples()), self->obj->GetSamplesCount()*2); -#else - return PyString_FromStringAndSize((const char *)(self->obj->GetSamples()), self->obj->GetSamplesCount()*2); -#endif -} - -static PyObject* -PySfSoundBuffer_SaveToFile(PySfSoundBuffer *self, PyObject *args) -{ - save_to_file(self, args); -} - -static PyObject* -PySfSoundBuffer_GetDuration(PySfSoundBuffer *self) -{ - return PyFloat_FromDouble((double)(self->obj->GetDuration())); -} - -static PyObject* -PySfSoundBuffer_GetChannelsCount(PySfSoundBuffer *self) -{ - return PyLong_FromUnsignedLong(self->obj->GetChannelsCount()); -} - -static PyObject* -PySfSoundBuffer_GetSampleRate(PySfSoundBuffer *self) -{ - return PyLong_FromUnsignedLong(self->obj->GetSampleRate()); -} - -static PyObject* -PySfSoundBuffer_GetSamplesCount(PySfSoundBuffer *self) -{ - return PyLong_FromUnsignedLong(self->obj->GetSamplesCount()); -} - - -static PyMethodDef PySfSoundBuffer_methods[] = { - {"LoadFromFile", (PyCFunction)PySfSoundBuffer_LoadFromFile, METH_O, "LoadFromFile(FileName)\nLoad the sound buffer from a file. Returns True if loading has been successful.\n Filename : Path of the sound file to load"}, - {"SaveToFile", (PyCFunction)PySfSoundBuffer_SaveToFile, METH_O, "SaveToFile(Filename)\nSave the sound buffer to a file. Returns True if saving has been successful.\n Filename : Path of the sound file to write"}, - {"LoadFromMemory", (PyCFunction)PySfSoundBuffer_LoadFromMemory, METH_O, "LoadFromMemory(Data)\nLoad the sound buffer from a string in memory.\n Data : string representing the file data in memory "}, - {"LoadFromSamples", (PyCFunction)PySfSoundBuffer_LoadFromSamples, METH_VARARGS, "LoadFromSamples(Samples, ChannelsCount, SampleRate)\nLoad the sound buffer from an array of samples - assumed format for samples is 16 bits signed integer.\n\ - Samples : Pointer to the samples in memory\n\ - ChannelsCount : Number of channels (1 = mono, 2 = stereo, ...)\n\ - SampleRate : Frequency (number of samples to play per second)"}, - {"GetDuration", (PyCFunction)PySfSoundBuffer_GetDuration, METH_NOARGS, "GetDuration()\nGet the sound duration."}, - {"GetChannelsCount", (PyCFunction)PySfSoundBuffer_GetChannelsCount, METH_NOARGS, "GetChannelsCount()\nReturn the number of channels (1 = mono, 2 = stereo)."}, - {"GetSampleRate", (PyCFunction)PySfSoundBuffer_GetSampleRate, METH_NOARGS, "GetSampleRate()\nGet the sound frequency (sample rate)."}, - {"GetSamplesCount", (PyCFunction)PySfSoundBuffer_GetSamplesCount, METH_NOARGS, "GetSamplesCount()\nReturn the samples count."}, - {"GetSamples", (PyCFunction)PySfSoundBuffer_GetSamples, METH_NOARGS, "GetSamples()\nReturn the sound samples as a string."}, - {NULL} /* Sentinel */ -}; - -PyTypeObject PySfSoundBufferType = { - head_init - "SoundBuffer", /*tp_name*/ - sizeof(PySfSoundBuffer), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - (destructor)PySfSoundBuffer_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash */ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ - "sf.SoundBuffer is the low-level for loading and manipulating sound buffers.\n\ -Default constructor : SoundBuffer()\n\ -Copy constructor : SoundBuffer(Copy) where Copy is a sf.SoundBuffer instance.", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - PySfSoundBuffer_methods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PySfSoundBuffer_new, /* tp_new */ -}; - -static PyObject * -PySfSoundBuffer_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PySfSoundBuffer *self; - self = (PySfSoundBuffer *)type->tp_alloc(type, 0); - if (self != NULL) - { - PySfSoundBuffer *Copy=NULL; - if (PyArg_ParseTuple(args, "O!:SoundBuffer.__init__", &PySfSoundBufferType, &Copy)) - { - self->obj = new sf::SoundBuffer(*(Copy->obj)); - return (PyObject *)self; - } - PyErr_Clear(); - self->obj = new sf::SoundBuffer(); - } - return (PyObject *)self; -} - -PySfSoundBuffer * -GetNewPySfSoundBuffer() -{ - return PyObject_New(PySfSoundBuffer, &PySfSoundBufferType); -} - diff --git a/bindings/python/src/SoundBuffer.hpp b/bindings/python/src/SoundBuffer.hpp deleted file mode 100644 index 4a35fb3e..00000000 --- a/bindings/python/src/SoundBuffer.hpp +++ /dev/null @@ -1,40 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// PySFML - Python binding for SFML (Simple and Fast Multimedia Library) -// Copyright (C) 2007, 2008 Rémi Koenig (remi.k2620@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#ifndef __PYSOUNDBUFFER_HPP -#define __PYSOUNDBUFFER_HPP - -#include - -#include - -typedef struct { - PyObject_HEAD - sf::SoundBuffer *obj; -} PySfSoundBuffer; - -PySfSoundBuffer * -GetNewPySfSoundBuffer(); - -#endif diff --git a/bindings/python/src/SoundBufferRecorder.cpp b/bindings/python/src/SoundBufferRecorder.cpp deleted file mode 100644 index 05978f6f..00000000 --- a/bindings/python/src/SoundBufferRecorder.cpp +++ /dev/null @@ -1,106 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// PySFML - Python binding for SFML (Simple and Fast Multimedia Library) -// Copyright (C) 2007, 2008 Rémi Koenig (remi.k2620@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#include "SoundBufferRecorder.hpp" -#include "SoundBuffer.hpp" - -#include "compat.hpp" - - -extern PyTypeObject PySfSoundRecorderType; - - -static void -PySfSoundBufferRecorder_dealloc(PySfSoundBufferRecorder *self) -{ - delete self->obj; - free_object(self); -} - -static PyObject * -PySfSoundBufferRecorder_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PySfSoundBufferRecorder *self; - self = (PySfSoundBufferRecorder *)type->tp_alloc(type, 0); - if (self != NULL) - self->obj = new sf::SoundBufferRecorder(); - return (PyObject *)self; -} - -static PyObject * -PySfSoundBufferRecorder_GetBuffer(PySfSoundBufferRecorder* self) -{ - PySfSoundBuffer *SoundBuffer = GetNewPySfSoundBuffer(); - SoundBuffer->obj = new sf::SoundBuffer(self->obj->GetBuffer()); - return (PyObject *)SoundBuffer; -} - - -static PyMethodDef PySfSoundBufferRecorder_methods[] = { - {"GetBuffer", (PyCFunction)PySfSoundBufferRecorder_GetBuffer, METH_NOARGS, "GetBuffer()\nGet the sound buffer containing the captured audio data. Returns a SoundBuffer object. Returns a sf.SoundBuffer instance."}, - {NULL} /* Sentinel */ -}; - -PyTypeObject PySfSoundBufferRecorderType = { - head_init - "SoundBufferRecorder", /*tp_name*/ - sizeof(PySfSoundBufferRecorder), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - (destructor)PySfSoundBufferRecorder_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash */ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ - "Specialized SoundRecorder which saves the captured audio data into a sound buffer.", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - PySfSoundBufferRecorder_methods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - &PySfSoundRecorderType, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PySfSoundBufferRecorder_new, /* tp_new */ -}; - - diff --git a/bindings/python/src/SoundBufferRecorder.hpp b/bindings/python/src/SoundBufferRecorder.hpp deleted file mode 100644 index 4feadbe3..00000000 --- a/bindings/python/src/SoundBufferRecorder.hpp +++ /dev/null @@ -1,37 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// PySFML - Python binding for SFML (Simple and Fast Multimedia Library) -// Copyright (C) 2007, 2008 Rémi Koenig (remi.k2620@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#ifndef __PYSOUNDBUFFERRECORDER_HPP -#define __PYSOUNDBUFFERRECORDER_HPP - -#include - -#include - -typedef struct { - PyObject_HEAD - sf::SoundBufferRecorder *obj; -} PySfSoundBufferRecorder; - -#endif diff --git a/bindings/python/src/SoundRecorder.cpp b/bindings/python/src/SoundRecorder.cpp deleted file mode 100644 index 4fc9facc..00000000 --- a/bindings/python/src/SoundRecorder.cpp +++ /dev/null @@ -1,166 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// PySFML - Python binding for SFML (Simple and Fast Multimedia Library) -// Copyright (C) 2007, 2008 Rémi Koenig (remi.k2620@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#include "SoundRecorder.hpp" - -#include "compat.hpp" - -bool CustomSoundRecorder::OnStart() -{ - bool result = false; - if (PyObject_HasAttrString(SoundRecorder, "OnStart")) - { - PyObject *OnStart = PyObject_GetAttrString(SoundRecorder, "OnStart"); - PyObject *Result = PyObject_CallFunction(OnStart, NULL); - result = PyBool_AsBool(Result); - Py_DECREF(OnStart); - Py_DECREF(Result); - } - return result; -} - -bool CustomSoundRecorder::OnProcessSamples(const sf::Int16* Samples, std::size_t SamplesCount) -{ - bool result = false; - if (PyObject_HasAttrString(SoundRecorder, "OnGetData")) - { - PyObject *OnGetData = PyObject_GetAttrString(SoundRecorder, "OnGetData"); - PyObject *Result = PyObject_CallFunction(OnGetData, (char *)"#s", (char *)Samples, SamplesCount*2); - result = PyBool_AsBool(Result); - Py_DECREF(OnGetData); - Py_DECREF(Result); - } - return result; -} - -void CustomSoundRecorder::OnStop() -{ - if (PyObject_HasAttrString(SoundRecorder, "OnStop")) - { - PyObject *OnStop = PyObject_GetAttrString(SoundRecorder, "OnStop"); - PyObject_CallFunction(OnStop, NULL); - Py_DECREF(OnStop); - } -} - -static void -PySfSoundRecorder_dealloc(PySfSoundRecorder* self) -{ - delete self->obj; - free_object(self); -} - -static PyObject * -PySfSoundRecorder_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PySfSoundRecorder *self; - self = (PySfSoundRecorder *)type->tp_alloc(type, 0); - if (self != NULL) - { - self->obj = new CustomSoundRecorder(); - self->obj->SoundRecorder = (PyObject *)self; - } - return (PyObject *)self; -} - -static PyObject * -PySfSoundRecorder_Start(PySfSoundRecorder* self, PyObject *args) -{ - self->obj->Start(PyLong_AsLong(args)); - Py_RETURN_NONE; -} - -static PyObject * -PySfSoundRecorder_Stop(PySfSoundRecorder* self) -{ - self->obj->Stop(); - Py_RETURN_NONE; -} - -static PyObject * -PySfSoundRecorder_GetSampleRate(PySfSoundRecorder* self) -{ - return PyLong_FromLong(self->obj->GetSampleRate()); -} - -static PyObject * -PySfSoundRecorder_IsAvailable(PySfSoundRecorder* self) -{ - return PyBool_FromLong(sf::SoundRecorder::IsAvailable()); -} - - -static PyMethodDef PySfSoundRecorder_methods[] = { - {"Start", (PyCFunction)PySfSoundRecorder_Start, METH_O, "Start(SampleRate=44100)\nStart the capture. Warning : only one capture can happen at the same time.\n SampleRate : Sound frequency (the more samples, the higher the quality) (44100 by default = CD quality)."}, - {"Stop", (PyCFunction)PySfSoundRecorder_Stop, METH_NOARGS, "Stop()\nStop the capture."}, - {"GetSampleRate", (PyCFunction)PySfSoundRecorder_GetSampleRate, METH_NOARGS, "GetSampleRate()\nGet the sample rate. Returns the frequency, in samples per second."}, - {"IsAvailable", (PyCFunction)PySfSoundRecorder_IsAvailable, METH_STATIC | METH_NOARGS, "IsAvailable()\nTell if the system supports sound capture. If not, this class won't be usable. Returns True if audio capture is supported."}, - {NULL} /* Sentinel */ -}; - - -PyTypeObject PySfSoundRecorderType = { - head_init - "SoundRecorder", /*tp_name*/ - sizeof(PySfSoundRecorder), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - (destructor)PySfSoundRecorder_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash */ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ - "SoundRecorder is an interface for capturing sound data, it is meant to be used as a base class.\n\ -Construct the sound recorder with a callback function for processing captured samples : SoundRecorder(Callback, UserData)\n\ - Callback : Callback function for processing captured samples. This function must take two parameters: the first one is a string containing captured samples, the second one is UserData.\n\ - UserData : Data to pass to the callback function (None by default).", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - PySfSoundRecorder_methods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PySfSoundRecorder_new, /* tp_new */ -}; - diff --git a/bindings/python/src/SoundRecorder.hpp b/bindings/python/src/SoundRecorder.hpp deleted file mode 100644 index cc360024..00000000 --- a/bindings/python/src/SoundRecorder.hpp +++ /dev/null @@ -1,46 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// PySFML - Python binding for SFML (Simple and Fast Multimedia Library) -// Copyright (C) 2007, 2008 Rémi Koenig (remi.k2620@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#ifndef __PYSOUNDRECORDER_HPP -#define __PYSOUNDRECORDER_HPP - -#include - -#include - -class CustomSoundRecorder : public sf::SoundRecorder -{ -public : - PyObject *SoundRecorder; - virtual bool OnStart(); - virtual bool OnProcessSamples(const sf::Int16* Samples, std::size_t SamplesCount); - virtual void OnStop(); -}; - -typedef struct { - PyObject_HEAD - CustomSoundRecorder *obj; -} PySfSoundRecorder; - -#endif diff --git a/bindings/python/src/SoundStream.cpp b/bindings/python/src/SoundStream.cpp deleted file mode 100644 index 7c73bbf4..00000000 --- a/bindings/python/src/SoundStream.cpp +++ /dev/null @@ -1,346 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// PySFML - Python binding for SFML (Simple and Fast Multimedia Library) -// Copyright (C) 2007, 2008 Rémi Koenig (remi.k2620@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#include "SoundStream.hpp" - -#include "compat.hpp" - - -void CustomSoundStream::OnSeek(float TimeOffset) -{ - PyGILState_STATE gstate; - gstate = PyGILState_Ensure(); - if (PyObject_HasAttrString(SoundStream, "OnSeek")) - { - PyObject *OnSeek = PyObject_GetAttrString(SoundStream, "OnSeek"); - if (OnSeek != NULL) - { - PyObject_CallFunction(OnSeek, const_cast( "f" ), TimeOffset); - Py_CLEAR(OnSeek); - } - } - if (PyErr_Occurred()) - { - PyErr_Print(); - } - PyGILState_Release(gstate); -} - -bool CustomSoundStream::OnGetData(Chunk& Data) -{ - PyGILState_STATE gstate; - bool result = false; - PyObject *Function, *PyData; - gstate = PyGILState_Ensure(); - Function = PyObject_GetAttrString(SoundStream, "OnGetData"); - if (Function != NULL) - { - PyData = PyObject_CallFunction(Function, NULL); - if (PyData != NULL) - { - if (PyArg_Parse(PyData, "s#", &(Data.Samples), &(Data.NbSamples))) - { - Data.NbSamples /= 2; - if (Data.NbSamples > 0) - result = true; - } - Py_CLEAR(PyData); - } - Py_CLEAR(Function); - } - if (PyErr_Occurred()) - { - PyErr_Print(); - result = false; - } - PyGILState_Release(gstate); - return result; -} - -void CustomSoundStream::Init(unsigned int ChannelsCount, unsigned int SampleRate) -{ - Initialize(ChannelsCount, SampleRate); -} - -static void -PySfSoundStream_dealloc(PySfSoundStream *self) -{ - delete self->obj; - free_object(self); -} - -static PyObject * -PySfSoundStream_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PySfSoundStream *self; - self = (PySfSoundStream *)type->tp_alloc(type, 0); - if (self != NULL) - { - self->obj = new CustomSoundStream(); - self->obj->SoundStream = (PyObject *)self; - } - return (PyObject *)self; -} - -static PyObject * -PySfSoundStream_Initialize(PySfSoundStream *self, PyObject *args) -{ - unsigned int ChannelsCount, SampleRate; - if (!PyArg_ParseTuple(args, "II:SoundStream.Initialize", &ChannelsCount, &SampleRate)) - return NULL; - self->obj->Init(ChannelsCount, SampleRate); - Py_RETURN_NONE; -} - -static PyObject* -PySfSoundStream_Play(PySfSoundStream *self) -{ - self->obj->Play(); - Py_RETURN_NONE; -} - -static PyObject* -PySfSoundStream_Stop(PySfSoundStream *self) -{ - self->obj->Stop(); - Py_RETURN_NONE; -} - -static PyObject* -PySfSoundStream_GetChannelsCount(PySfSoundStream *self) -{ - return PyLong_FromUnsignedLong(self->obj->GetChannelsCount()); -} - -static PyObject* -PySfSoundStream_GetSampleRate(PySfSoundStream *self) -{ - return PyLong_FromUnsignedLong(self->obj->GetSampleRate()); -} - -static PyObject* -PySfSoundStream_SetPitch(PySfSoundStream *self, PyObject *args) -{ - self->obj->SetPitch(PyFloat_AsDouble(args)); - Py_RETURN_NONE; -} - -static PyObject* -PySfSoundStream_SetMinDistance(PySfSoundStream *self, PyObject *args) -{ - self->obj->SetMinDistance(PyFloat_AsDouble(args)); - Py_RETURN_NONE; -} - -static PyObject* -PySfSoundStream_SetAttenuation(PySfSoundStream *self, PyObject *args) -{ - self->obj->SetAttenuation(PyFloat_AsDouble(args)); - Py_RETURN_NONE; -} - -static PyObject* -PySfSoundStream_SetVolume(PySfSoundStream *self, PyObject *args) -{ - self->obj->SetVolume(PyFloat_AsDouble(args)); - Py_RETURN_NONE; -} - -static PyObject* -PySfSoundStream_GetPitch(PySfSoundStream *self) -{ - return PyFloat_FromDouble(self->obj->GetPitch()); -} - -static PyObject* -PySfSoundStream_GetMinDistance(PySfSoundStream *self) -{ - return PyFloat_FromDouble(self->obj->GetMinDistance()); -} - -static PyObject* -PySfSoundStream_GetAttenuation(PySfSoundStream *self) -{ - return PyFloat_FromDouble(self->obj->GetAttenuation()); -} - -static PyObject* -PySfSoundStream_GetVolume(PySfSoundStream *self) -{ - return PyFloat_FromDouble(self->obj->GetVolume()); -} - -static PyObject* -PySfSoundStream_GetPosition(PySfSoundStream *self) -{ - sf::Vector3f Vect = self->obj->GetPosition(); - return Py_BuildValue("fff", Vect.x, Vect.y, Vect.z); -} - -static PyObject* -PySfSoundStream_Pause(PySfSoundStream *self) -{ - self->obj->Pause(); - Py_RETURN_NONE; -} - -static PyObject* -PySfSoundStream_SetPosition(PySfSoundStream *self, PyObject *args) -{ - float X, Y, Z; - if (!PyArg_ParseTuple(args, "fff:SoundStream.SetPosition", &X, &Y, &Z)) - return NULL; - self->obj->SetPosition(X, Y, Z); - Py_RETURN_NONE; -} - -static PyObject* -PySfSoundStream_GetStatus(PySfSoundStream *self) -{ - return PyLong_FromUnsignedLong(self->obj->GetStatus()); -} - -static PyObject* -PySfSoundStream_SetLoop(PySfSoundStream *self, PyObject *args) -{ - self->obj->SetLoop(PyBool_AsBool(args)); - Py_RETURN_NONE; -} - -static PyObject* -PySfSoundStream_GetLoop(PySfSoundStream *self) -{ - return PyBool_FromLong(self->obj->GetLoop()); -} - -static PyObject* -PySfSoundStream_GetPlayingOffset(PySfSoundStream *self) -{ - return PyFloat_FromDouble(self->obj->GetPlayingOffset()); -} - -static PyObject* -PySfSoundStream_SetRelativeToListener(PySfSoundStream *self, PyObject *args) -{ - self->obj->SetRelativeToListener(PyBool_AsBool(args)); - Py_RETURN_NONE; -} - -static PyObject* -PySfSoundStream_IsRelativeToListener(PySfSoundStream *self) -{ - return PyBool_FromLong(self->obj->IsRelativeToListener()); -} - -static PyMethodDef PySfSoundStream_methods[] = { - {"SetRelativeToListener", (PyCFunction)PySfSoundStream_SetRelativeToListener, METH_O, "SetRelativeToListener(Relative)\nMake the sound's position relative to the listener's position, or absolute. The default value is false (absolute)\n Relative : True to set the position relative, false to set it absolute"}, - {"IsRelativeToListener", (PyCFunction)PySfSoundStream_IsRelativeToListener, METH_NOARGS, "IsRelativeToListener()\nTell if the sound's position is relative to the listener's position, or if it's absolute."}, - {"Initialize", (PyCFunction)PySfSoundStream_Initialize, METH_VARARGS, "Initialize(ChannelsCount, SampleRate)\n\ -Set the audio stream parameters, you must call it before Play()\n\ - ChannelsCount : Number of channels\n\ - SampleRate : Sample rate."}, - {"Play", (PyCFunction)PySfSoundStream_Play, METH_NOARGS, "Play()\nPlay the sound."}, - {"Stop", (PyCFunction)PySfSoundStream_Stop, METH_NOARGS, "Stop()\nStop the sound."}, - {"GetChannelsCount", (PyCFunction)PySfSoundStream_GetChannelsCount, METH_NOARGS, "GetChannelsCount()\nReturn the number of channels (1 = mono, 2 = stereo)."}, - {"GetSampleRate", (PyCFunction)PySfSoundStream_GetSampleRate, METH_NOARGS, "GetSampleRate()\nGet the sound frequency (sample rate)."}, - {"GetStatus", (PyCFunction)PySfSoundStream_GetStatus, METH_NOARGS, "GetStatus()\nGet the status of the sound (stopped, paused, playing)."}, - {"SetLoop", (PyCFunction)PySfSoundStream_SetLoop, METH_O, "SetLoop(Loop)\nSet the music loop state. This parameter is disabled by default\n Loop : True to play in loop, false to play once "}, - {"GetLoop", (PyCFunction)PySfSoundStream_GetLoop, METH_NOARGS, "GetLoop()\nTell whether or not the music is looping."}, - {"GetPlayingOffset", (PyCFunction)PySfSoundStream_GetPlayingOffset, METH_NOARGS, "GetPlayingOffset()\nGet the current playing position of the stream."}, -/* The following methods should be inherited from sf.Sound */ - {"SetPitch", (PyCFunction)PySfSoundStream_SetPitch, METH_O, "SetPitch(Pitch)\nSet the sound pitch. The default pitch is 1.\n Pitch : New pitch"}, - {"SetMinDistance", (PyCFunction)PySfSoundStream_SetMinDistance, METH_O, "SetMinDistance(MinDistance)\nSet the minimum distance - closer than this distance, the listener will hear the sound at its maximum volume. The default minimum distance is 1.0.\n MinDistance : New minimum distance for the sound"}, - {"SetAttenuation", (PyCFunction)PySfSoundStream_SetAttenuation, METH_O, "SetAttenuation(Attenuation)\nSet the attenuation factor - the higher the attenuation, the more the sound will be attenuated with distance from listener. The default attenuation factor 1.0.\n Attenuation : New attenuation factor for the sound"}, - {"SetVolume", (PyCFunction)PySfSoundStream_SetVolume, METH_O, "SetVolume(Volume)\nSet the sound volume.\n Volume : Volume (in range [0, 100])"}, - {"SetPosition", (PyCFunction)PySfSoundStream_SetPosition, METH_VARARGS, "SetPosition(X, Y, Z)\nSet the sound position in the world.\n X,Y,Z : Position of the sound in the world"}, - {"GetPitch", (PyCFunction)PySfSoundStream_GetPitch, METH_NOARGS, "GetPitch()\nGet the sound pitch."}, - {"GetMinDistance", (PyCFunction)PySfSoundStream_GetMinDistance, METH_NOARGS, "GetMinDistance()\nGet the minimum distance."}, - {"GetAttenuation", (PyCFunction)PySfSoundStream_GetAttenuation, METH_NOARGS, "GetAttenuation()\nGet the attenuation factor."}, - {"GetVolume", (PyCFunction)PySfSoundStream_GetVolume, METH_NOARGS, "GetVolume()\nGet the sound volume."}, - {"GetPosition", (PyCFunction)PySfSoundStream_GetPosition, METH_NOARGS, "GetPosition()\nGet the sound position in the world. Returns a tuple."}, - {"Pause", (PyCFunction)PySfSoundStream_Pause, METH_NOARGS, "Pause()\nPause the sound."}, - {NULL} /* Sentinel */ -}; - - -PyTypeObject PySfSoundStreamType = { - head_init - "SoundStream", /*tp_name*/ - sizeof(PySfSoundStream), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - (destructor)PySfSoundStream_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash */ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ - "SoundStream is a streamed sound, ie samples are acquired\ -while the sound is playing. Use it for big sounds that would\ -require hundreds of MB in memory (see Music),\ -or for streaming sound from the network", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - PySfSoundStream_methods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PySfSoundStream_new, /* tp_new */ -}; - - -void -PySfSoundStream_InitConst() -{ - PyObject *obj; - obj = PyLong_FromLong(sf::SoundStream::Stopped); - PyDict_SetItemString(PySfSoundStreamType.tp_dict, "Stopped", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::SoundStream::Paused); - PyDict_SetItemString(PySfSoundStreamType.tp_dict, "Paused", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::SoundStream::Playing); - PyDict_SetItemString(PySfSoundStreamType.tp_dict, "Playing", obj); - Py_DECREF(obj); -} - diff --git a/bindings/python/src/SoundStream.hpp b/bindings/python/src/SoundStream.hpp deleted file mode 100644 index 055c7fba..00000000 --- a/bindings/python/src/SoundStream.hpp +++ /dev/null @@ -1,51 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// PySFML - Python binding for SFML (Simple and Fast Multimedia Library) -// Copyright (C) 2007, 2008 Rémi Koenig (remi.k2620@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#ifndef __PYSOUNDSTREAM_HPP -#define __PYSOUNDSTREAM_HPP - -#include - -#include - -class CustomSoundStream : public sf::SoundStream -{ -public : - PyObject *SoundStream; - virtual void OnSeek(float TimeOffset); - virtual bool OnGetData(Chunk& Data); - void Init(unsigned int ChannelsCount, unsigned int SampleRate); -}; - - -typedef struct { - PyObject_HEAD - CustomSoundStream *obj; -} PySfSoundStream; - -void -PySfSoundStream_InitConst(); - -#endif - diff --git a/bindings/python/src/Sprite.cpp b/bindings/python/src/Sprite.cpp deleted file mode 100644 index 4c47a4cd..00000000 --- a/bindings/python/src/Sprite.cpp +++ /dev/null @@ -1,256 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// PySFML - Python binding for SFML (Simple and Fast Multimedia Library) -// Copyright (C) 2007, 2008 Rémi Koenig (remi.k2620@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#include "Sprite.hpp" -#include "Drawable.hpp" -#include "Color.hpp" - -#include "compat.hpp" - - -extern PyTypeObject PySfColorType; -extern PyTypeObject PySfImageType; -extern PyTypeObject PySfIntRectType; -extern PyTypeObject PySfDrawableType; - - -static void -PySfSprite_dealloc(PySfSprite *self) -{ - Py_CLEAR(self->Image); - Py_CLEAR(self->SubRect); - delete self->obj; - free_object(self); -} - -static PyObject * -PySfSprite_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PySfSprite *self; - - self = (PySfSprite *)type->tp_alloc(type, 0); - - if (self != NULL) - { - self->Image = NULL; - self->SubRect = NULL; - self->IsCustom = false; - } - - return (PyObject *)self; -} - - -static int -PySfSprite_init(PySfSprite *self, PyObject *args, PyObject *kwds) -{ - const char *kwlist[] = {"Image", "X", "Y", "ScaleX", "ScaleY", "Rotation", "Color", NULL}; - float X=0, Y=0, ScaleX=1, ScaleY=1, Rotation=0; - PySfImage *Image=NULL; - PySfColor *Color=NULL; - - if (! PyArg_ParseTupleAndKeywords(args, kwds, "O!|fffffO!:Sprite.__init__", (char **)kwlist, &PySfImageType, &Image, &X, &Y, &ScaleX, &ScaleY, &Rotation, &PySfColorType, &Color)) - return -1; - - Py_INCREF(Image); - self->Image = Image; - if (Color != NULL) - self->obj = new sf::Sprite(*(Image->obj), sf::Vector2f(X, Y), sf::Vector2f(ScaleX, ScaleY), Rotation, *(Color->obj)); - else - self->obj = new sf::Sprite(*(Image->obj), sf::Vector2f(X, Y), sf::Vector2f(ScaleX, ScaleY), Rotation); - - return 0; -} - - - -static PyObject * -PySfSprite_SetImage(PySfSprite* self, PyObject *args) -{ - PySfImage *Image = (PySfImage *)args; - if (! PyObject_TypeCheck(Image, &PySfImageType)) - { - PyErr_SetString(PyExc_TypeError, "Sprite.SetImage() Argument is not a sf.Image"); - return NULL; - } - Py_CLEAR(self->Image); - Py_INCREF(Image); - self->Image = Image; - self->obj->SetImage(*(Image->obj)); - Py_RETURN_NONE; -} - -static PyObject * -PySfSprite_GetImage(PySfSprite* self) -{ - Py_INCREF(self->Image); - return (PyObject *)(self->Image); -} - -static PyObject * -PySfSprite_GetPixel(PySfSprite* self, PyObject *args) -{ - PySfColor *Color; - unsigned int x=0, y=0; - - if (!PyArg_ParseTuple(args, "II:Sprite.GetPixel", &x, &y)) - return NULL; - - Color = GetNewPySfColor(); - Color->obj = new sf::Color(self->obj->GetPixel(x, y)); - Color->r = Color->obj->r; - Color->g = Color->obj->g; - Color->b = Color->obj->b; - Color->a = Color->obj->a; - - return (PyObject *)Color; -} - -static PyObject * -PySfSprite_Resize(PySfSprite* self, PyObject *args) -{ - float W=0, H=0; - - if (! PyArg_ParseTuple(args, "ff:Sprite.Resize", &W, &H)) - return NULL; - - self->obj->Resize(W,H); - Py_RETURN_NONE; -} - -static PyObject * -PySfSprite_GetSubRect(PySfSprite* self) -{ - if (self->SubRect != NULL) - { - Py_INCREF(self->SubRect); - return (PyObject *)(self->SubRect); - } - else - { - PySfIntRect *Rect; - Rect = GetNewPySfIntRect(); - Rect->Owner = false; - Rect->obj = (sf::IntRect *) &(self->obj->GetSubRect()); - PySfIntRectUpdateSelf(Rect); - Py_INCREF(Rect); - self->SubRect = Rect; - return (PyObject *)Rect; - } -} - -static PyObject * -PySfSprite_SetSubRect(PySfSprite* self, PyObject *args) -{ - PySfIntRect *Rect = (PySfIntRect *)args; - if (!PyObject_TypeCheck(Rect, &PySfIntRectType)) - { - PyErr_SetString(PyExc_TypeError, "Sprite.SetSubRect() Argument is not a sf.IntRect instance"); - return NULL; - } - Py_CLEAR(self->SubRect); - Py_INCREF(Rect); - self->SubRect = Rect; - self->obj->SetSubRect(*(Rect->obj)); - Py_RETURN_NONE; -} - -static PyObject * -PySfSprite_FlipX(PySfSprite* self, PyObject *args) -{ - self->obj->FlipX(PyBool_AsBool(args)); - Py_RETURN_NONE; -} - -static PyObject * -PySfSprite_FlipY(PySfSprite* self, PyObject *args) -{ - self->obj->FlipY(PyBool_AsBool(args)); - Py_RETURN_NONE; -} - -static PyObject * -PySfSprite_GetSize(PySfSprite* self) -{ - sf::Vector2f Vect = self->obj->GetSize(); - return Py_BuildValue("ff", Vect.x, Vect.y); -} - -static PyMethodDef PySfSprite_methods[] = { - {"SetImage", (PyCFunction)PySfSprite_SetImage, METH_O, "SetImage(Image)\nChange the image of the sprite.\n Image : new image (sf.Image instance)"}, - {"GetImage", (PyCFunction)PySfSprite_GetImage, METH_NOARGS, "GetImage()\nGet the source image of the sprite."}, - {"GetSize", (PyCFunction)PySfSprite_GetSize, METH_NOARGS, "GetSize()\nGet the sprite's size."}, - {"GetPixel", (PyCFunction)PySfSprite_GetPixel, METH_VARARGS, "GetPixel()\nGet the color of a given pixel in the sprite."}, - {"Resize", (PyCFunction)PySfSprite_Resize, METH_VARARGS, "Resize(Width, Height)\nResize the sprite (by changing its scale factors). The default size is defined by the subrect.\n\ - Width : New width (must be strictly positive)\n\ - Height : New height (must be strictly positive)"}, - {"GetSubRect", (PyCFunction)PySfSprite_GetSubRect, METH_NOARGS, "GetSubRect()\nGet the sub-rectangle of the sprite inside the source image."}, - {"SetSubRect", (PyCFunction)PySfSprite_SetSubRect, METH_O, "SetSubRect(SubRect)\nSet the sub-rectangle of the sprite inside the source image. By default, the subrect covers the entire source image.\n SubRect : New sub-rectangle"}, - {"FlipX", (PyCFunction)PySfSprite_FlipX, METH_O, "FlipX(Flipped)\nFlip the sprite horizontally.\n Flipped : True to flip the sprite"}, - {"FlipY", (PyCFunction)PySfSprite_FlipY, METH_O, "FlipY(Flipped)\nFlip the sprite vertically.\n Flipped : True to flip the sprite"}, - {NULL} /* Sentinel */ -}; - -PyTypeObject PySfSpriteType = { - head_init - "Sprite", /*tp_name*/ - sizeof(PySfSprite), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - (destructor)PySfSprite_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash */ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ - "sfSprite defines a sprite : texture, transformations, color, and draw on screen", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - PySfSprite_methods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - &PySfDrawableType, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc)PySfSprite_init, /* tp_init */ - 0, /* tp_alloc */ - PySfSprite_new, /* tp_new */ -}; - - diff --git a/bindings/python/src/Sprite.hpp b/bindings/python/src/Sprite.hpp deleted file mode 100644 index 78ae631e..00000000 --- a/bindings/python/src/Sprite.hpp +++ /dev/null @@ -1,43 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// PySFML - Python binding for SFML (Simple and Fast Multimedia Library) -// Copyright (C) 2007, 2008 Rémi Koenig (remi.k2620@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#ifndef __PYSPRITE_HPP -#define __PYSPRITE_HPP - -#include - -#include - -#include "Image.hpp" -#include "Rect.hpp" - -typedef struct { - PyObject_HEAD - bool IsCustom; - sf::Sprite *obj; - PySfImage *Image; - PySfIntRect *SubRect; -} PySfSprite; - -#endif diff --git a/bindings/python/src/Text.cpp b/bindings/python/src/Text.cpp deleted file mode 100644 index 84529c16..00000000 --- a/bindings/python/src/Text.cpp +++ /dev/null @@ -1,307 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// PySFML - Python binding for SFML (Simple and Fast Multimedia Library) -// Copyright (C) 2007, 2008 Rémi Koenig (remi.k2620@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#include "Text.hpp" -#include "Font.hpp" -#include "Color.hpp" -#include "Rect.hpp" - -#include "compat.hpp" - - -extern PyTypeObject PySfDrawableType; -extern PyTypeObject PySfFontType; - - -static void -PySfText_dealloc(PySfText *self) -{ - Py_CLEAR(self->font); - delete self->obj; - free_object(self); -} - -static PyObject * -PySfText_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PySfText *self; - self = (PySfText *)type->tp_alloc(type, 0); - if (self != NULL) - { - self->font = NULL; - self->IsCustom = false; - self->obj = new sf::Text(); - } - return (PyObject *)self; -} - -static PyObject * -PySfText_SetString(PySfText* self, PyObject *args) -{ - char *Text, *EncodingStr=NULL; - int Length; - std::string Encoding; - if (PyArg_ParseTuple(args, "u:Text.SetString", &Text)) - { -#if Py_UNICODE_SIZE == 4 - self->obj->SetString((sf::Uint32 *)Text); -#else - self->obj->SetString((sf::Uint16 *)Text); -#endif - } - else if (PyArg_ParseTuple(args, "s|#s:Text.SetString", &Text, &Length, &EncodingStr)) - { - PyErr_Clear(); - if (EncodingStr == NULL) - self->obj->SetString(Text); - else - { - Encoding.assign(EncodingStr); - if (Encoding == "utf8") - self->obj->SetString(Text); - else if (Encoding == "utf16") - self->obj->SetString(Text+2); - else if (Encoding == "utf32") - self->obj->SetString(Text+4); - else - { - PyErr_Format(PyExc_TypeError, "Text.SetString() Encoding %s not supported", EncodingStr); - return NULL; - } - } - } - else - { - PyErr_BadArgument(); - return NULL; - } - Py_RETURN_NONE; -} - -static PyObject * -PySfText_SetFont(PySfText* self, PyObject *args) -{ - PySfFont *Font = (PySfFont *)args; - if (!PyObject_TypeCheck(Font, &PySfFontType)) - { - PyErr_SetString(PyExc_ValueError, "Text.SetFont() Argument must be a sf.Font"); - return NULL; - } - Py_CLEAR(self->font); - Py_INCREF(args); - self->font = Font; - self->obj->SetFont(*(Font->obj)); - Py_RETURN_NONE; -} - -static PyObject * -PySfText_SetCharacterSize(PySfText* self, PyObject *args) -{ - self->obj->SetCharacterSize(PyFloat_AsDouble(args)); - Py_RETURN_NONE; -} - -static PyObject * -PySfText_GetCharacterSize(PySfText* self) -{ - return PyFloat_FromDouble(self->obj->GetCharacterSize()); -} - -static PyObject * -PySfText_SetStyle(PySfText* self, PyObject *args) -{ - self->obj->SetStyle(PyLong_AsUnsignedLong(args)); - Py_RETURN_NONE; -} - -static PyObject * -PySfText_GetStyle(PySfText* self) -{ - return PyLong_FromUnsignedLong(self->obj->GetStyle()); -} - -static PyObject * -PySfText_GetString(PySfText* self) -{ -#if Py_UNICODE_SIZE == 4 - const sf::String& Text(self->obj->GetString()); -#else - const sf::String& Text(self->obj->GetString()); -#endif - return PyUnicode_FromUnicode((const Py_UNICODE*)Text.ToAnsiString().c_str(), Text.GetSize()); -} - -static PyObject * -PySfText_GetFont(PySfText* self) -{ - if (self->font == NULL) - { - PySfFont *Font = GetNewPySfFont(); - Font->obj = (sf::Font *)&(sf::Font::GetDefaultFont()); - Font->Owner = false; - return (PyObject *)Font; - } - else - { - Py_INCREF(self->font); - return (PyObject *)(self->font); - } -} - -static PyObject * -PySfText_GetRect(PySfText* self) -{ - PySfFloatRect *Rect; - - Rect = GetNewPySfFloatRect(); - Rect->Owner = true; - Rect->obj = new sf::FloatRect (self->obj->GetRect()); - PySfFloatRectUpdateSelf(Rect); - - return (PyObject *)Rect; -} - -static PyObject * -PySfText_GetCharacterPos(PySfText* self, PyObject *args) -{ - sf::Vector2f Pos = self->obj->GetCharacterPos(PyLong_AsUnsignedLong(args)); - return Py_BuildValue("ff", Pos.x, Pos.y); -} - -static int -PySfText_init(PySfText *self, PyObject *args, PyObject *kwds) -{ - const char *kwlist[] = {"Text", "Font", "Size", NULL}; - float Size = 30.f; - PyObject *Text=NULL; - PySfFont *Font = NULL; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OO!f:Text.__new__", (char **)kwlist, &Text, &PySfFontType, &Font, &Size)) - return -1; - - if (Text != NULL) - { - if (PyUnicode_Check(Text)) - { -#if Py_UNICODE_SIZE == 4 - self->obj->SetString((sf::Uint32 *)PyUnicode_AS_UNICODE(Text)); -#else - self->obj->SetString((sf::Uint16 *)PyUnicode_AS_UNICODE(Text)); -#endif - } -#ifdef IS_PY3K - else if (PyBytes_Check(Text)) - self->obj->SetString(PyBytes_AsString(Text)); -#else - else if (PyString_Check(Text)) - self->obj->SetString(PyString_AsString(Text)); -#endif - else - { - PyErr_SetString(PyExc_TypeError, "Text.__init__() first argument must be str"); - return -1; - } - } - if (Font) PySfText_SetFont(self, (PyObject *)Font); - self->obj->SetCharacterSize(Size); - return 0; -} - - -static PyMethodDef PySfText_methods[] = { - {"GetCharacterPos", (PyCFunction)PySfText_GetCharacterPos, METH_O, "GetCharacterPos(Index)\n\ -Return the visual position (a tuple of two floats) of the Index-th character of the string, in coordinates relative to the string (note : translation, center, rotation and scale are not applied)\n\ - Index : Index of the character"}, - {"SetString", (PyCFunction)PySfText_SetString, METH_VARARGS, "SetString(UnicodeText) or SetString(Text, Encoding='utf8')\nSet the text. Valid encodings are 'utf8', 'utf16' and 'utf32'.\n Text : New text"}, - {"GetString", (PyCFunction)PySfText_GetString, METH_NOARGS, "GetString()\nGet the text as an unicode string."}, - {"SetFont", (PyCFunction)PySfText_SetFont, METH_O, "SetFont(Font)\nSet the font of the string.\n Font : font to use"}, - {"GetFont", (PyCFunction)PySfText_GetFont, METH_NOARGS, "GetFont()\nGet the font used by the string."}, - {"SetCharacterSize", (PyCFunction)PySfText_SetCharacterSize, METH_O, "SetCharacterSize(Size)\nSet the size of the text.\n Size : New size, in pixels"}, - {"GetCharacterSize", (PyCFunction)PySfText_GetCharacterSize, METH_NOARGS, "GetCharacterSize()\nGet the size of the characters."}, - {"SetStyle", (PyCFunction)PySfText_SetStyle, METH_O, "SetStyle(TextSize)\nSet the style of the text. The default style is Regular.\n TextSize : New text style, (combination of Style values)"}, - {"GetStyle", (PyCFunction)PySfText_GetStyle, METH_NOARGS, "GetStyle()\nGet the style of the text."}, - {"GetRect", (PyCFunction)PySfText_GetRect, METH_NOARGS, "GetRect()\nGet the string rectangle on screen."}, - {NULL} /* Sentinel */ -}; - -PyTypeObject PySfTextType = { - head_init - "Text", /*tp_name*/ - sizeof(PySfText), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - (destructor)PySfText_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash */ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ - "sf.Text defines a graphical 2D text, that can be drawn on screen.\n\ -Default constructor : Text ()\nConstruct the string from an unicode or an ascii string : Text(Text, Font=sf.Font.GetDefaultFont(), Size=30.)\n Text : Text assigned to the string\n Font : Font used to draw the string (SFML built-in font by default)\n Size : Characters size (30 by default)", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - PySfText_methods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - &PySfDrawableType, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc)PySfText_init, /* tp_init */ - 0, /* tp_alloc */ - PySfText_new, /* tp_new */ -}; - - - -void PySfText_InitConst() -{ - PyObject *obj; - obj = PyLong_FromLong(sf::Text::Regular); - PyDict_SetItemString(PySfTextType.tp_dict, "Regular", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Text::Bold); - PyDict_SetItemString(PySfTextType.tp_dict, "Bold", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Text::Italic); - PyDict_SetItemString(PySfTextType.tp_dict, "Italic", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Text::Underlined); - PyDict_SetItemString(PySfTextType.tp_dict, "Underlined", obj); - Py_DECREF(obj); -} - diff --git a/bindings/python/src/Text.hpp b/bindings/python/src/Text.hpp deleted file mode 100644 index 077f1ba0..00000000 --- a/bindings/python/src/Text.hpp +++ /dev/null @@ -1,43 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// PySFML - Python binding for SFML (Simple and Fast Multimedia Library) -// Copyright (C) 2007, 2008 Rémi Koenig (remi.k2620@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#ifndef __PYSTRING_HPP -#define __PYSTRING_HPP - -#include - -#include - -#include "Font.hpp" - -typedef struct { - PyObject_HEAD - bool IsCustom; - sf::Text *obj; - PySfFont *font; -} PySfText; - -void PySfText_InitConst(); - -#endif diff --git a/bindings/python/src/VideoMode.cpp b/bindings/python/src/VideoMode.cpp deleted file mode 100644 index b989cd43..00000000 --- a/bindings/python/src/VideoMode.cpp +++ /dev/null @@ -1,197 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// PySFML - Python binding for SFML (Simple and Fast Multimedia Library) -// Copyright (C) 2007, 2008 Rémi Koenig (remi.k2620@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#include "VideoMode.hpp" - -#include - -#include "offsetof.hpp" -#include "compat.hpp" - - -static PyMemberDef PySfVideoMode_members[] = { - {(char *)"Width", T_UINT, offsetof(PySfVideoMode, Width), 0, (char *)"Video mode width, in pixels."}, - {(char *)"Height", T_UINT, offsetof(PySfVideoMode, Height), 0, (char *)"Video mode height, in pixels."}, - {(char *)"BitsPerPixel", T_UINT, offsetof(PySfVideoMode, BitsPerPixel), 0, (char *)"Video mode pixel depth, in bits per pixels."}, - {NULL} /* Sentinel */ -}; - - -static void -PySfVideoMode_dealloc(PySfVideoMode* self) -{ - delete self->obj; - free_object(self); -} - -static PyObject * -PySfVideoMode_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - const char *kwlist[] = {"Width", "Height", "BitsPerPixel", NULL}; - PySfVideoMode *self; - self = (PySfVideoMode *)type->tp_alloc(type, 0); - if (self != NULL) - { - self->BitsPerPixel = 32; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "II|I:VideoMode.__new__", (char **)kwlist, &self->Width, &self->Height, &self->BitsPerPixel)) - return NULL; - self->obj = new sf::VideoMode(self->Width, self->Height, self->BitsPerPixel); - } - return (PyObject *)self; -} - -static PyObject * -PySfVideoMode_IsValid(PySfVideoMode* self) -{ - return PyBool_FromLong(self->obj->IsValid()); -} - -static PyObject * -PySfVideoMode_GetDesktopMode(PySfVideoMode* self) -{ - PySfVideoMode *VideoMode; - - VideoMode = GetNewPySfVideoMode(); - VideoMode->obj = new sf::VideoMode(sf::VideoMode::GetDesktopMode()); - VideoMode->Width = VideoMode->obj->Width; - VideoMode->Height = VideoMode->obj->Height; - VideoMode->BitsPerPixel = VideoMode->obj->BitsPerPixel; - - return (PyObject *)VideoMode; -} - -static PyObject * -PySfVideoMode_GetMode(PySfVideoMode* self, PyObject *args) -{ - std::size_t index; - PySfVideoMode *VideoMode; - - index = (std::size_t)PyLong_AsLong(args); - - VideoMode = GetNewPySfVideoMode(); - VideoMode->obj = new sf::VideoMode(sf::VideoMode::GetMode(index)); - VideoMode->Width = VideoMode->obj->Width; - VideoMode->Height = VideoMode->obj->Height; - VideoMode->BitsPerPixel = VideoMode->obj->BitsPerPixel; - - return (PyObject *)VideoMode; -} - -static PyObject * -PySfVideoMode_GetModesCount(PySfVideoMode* self) -{ - return PyLong_FromLong(sf::VideoMode::GetModesCount()); -} - - -static PyMethodDef PySfVideoMode_methods[] = { - {"IsValid", (PyCFunction)PySfVideoMode_IsValid, METH_NOARGS, "IsValid()\nTell whether or not the video mode is supported."}, - {"GetDesktopMode", (PyCFunction)PySfVideoMode_GetDesktopMode, METH_STATIC | METH_NOARGS, "GetDesktopMode()\nGet the current desktop video mode."}, - {"GetMode", (PyCFunction)PySfVideoMode_GetMode, METH_STATIC | METH_O, "GetMode(Index)\nGet a valid video mode. Index must be in range [0, GetModesCount()[ Modes are sorted from best to worst.\n Index : Index of video mode to get"}, - {"GetModesCount", (PyCFunction)PySfVideoMode_GetModesCount, METH_STATIC | METH_NOARGS, "GetModesCount()\nGet valid video modes count."}, - {NULL} /* Sentinel */ -}; - -PyObject * -PySfVideoMode_richcompare(PyObject *o1, PyObject *o2, int op) -{ - if (*(((PySfVideoMode *)o1)->obj) == *(((PySfVideoMode *)o2)->obj)) - { - if (op==Py_EQ) - Py_RETURN_TRUE; - if (op==Py_NE) - Py_RETURN_FALSE; - } - else - { - if (op==Py_EQ) - Py_RETURN_FALSE; - if (op==Py_NE) - Py_RETURN_TRUE; - } - PyErr_SetString(PyExc_TypeError, "VideoMode comparison : only == and != make sens."); - return NULL; -} - -int -PySfVideoMode_setattro(PyObject* self, PyObject *attr_name, PyObject *v) -{ - int result = PyObject_GenericSetAttr(self, attr_name, v); - PySfVideoMode *Mode = (PySfVideoMode *)self; - Mode->obj->Width = Mode->Width; - Mode->obj->Height = Mode->Height; - Mode->obj->BitsPerPixel = Mode->BitsPerPixel; - return result; -} - -PyTypeObject PySfVideoModeType = { - head_init - "VideoMode", /*tp_name*/ - sizeof(PySfVideoMode), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - (destructor)PySfVideoMode_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash */ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ - "sf.VideoMode defines a video mode (width, height, bpp, frequency) and provides functions for getting modes supported by the display device\n\ -Default constructor : VideoMode()\n\ -Construct the video mode with its attributes : VideoMode(ModeWidth, ModeHeight, ModeBpp = 32)\n ModeWidth : Width in pixels\n ModeHeight : Height in pixels\n ModeBpp : Pixel depths in bits per pixel (32 by default)", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - PySfVideoMode_richcompare, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - PySfVideoMode_methods, /* tp_methods */ - PySfVideoMode_members, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PySfVideoMode_new, /* tp_new */ -}; - - -PySfVideoMode * -GetNewPySfVideoMode() -{ - return PyObject_New(PySfVideoMode, &PySfVideoModeType); -} - diff --git a/bindings/python/src/VideoMode.hpp b/bindings/python/src/VideoMode.hpp deleted file mode 100644 index 3db195e8..00000000 --- a/bindings/python/src/VideoMode.hpp +++ /dev/null @@ -1,43 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// PySFML - Python binding for SFML (Simple and Fast Multimedia Library) -// Copyright (C) 2007, 2008 Rémi Koenig (remi.k2620@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#ifndef __PYVIDEOMODE_HPP -#define __PYVIDEOMODE_HPP - -#include - -#include - -typedef struct { - PyObject_HEAD - unsigned int Width; - unsigned int Height; - unsigned int BitsPerPixel; - sf::VideoMode *obj; -} PySfVideoMode; - -PySfVideoMode * -GetNewPySfVideoMode(); - -#endif diff --git a/bindings/python/src/View.cpp b/bindings/python/src/View.cpp deleted file mode 100644 index 922c4346..00000000 --- a/bindings/python/src/View.cpp +++ /dev/null @@ -1,168 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// PySFML - Python binding for SFML (Simple and Fast Multimedia Library) -// Copyright (C) 2007, 2008 Rémi Koenig (remi.k2620@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#include "View.hpp" - -#include "offsetof.hpp" -#include "compat.hpp" - - -extern PyTypeObject PySfFloatRectType; - - -static void -PySfView_dealloc(PySfView *self) -{ - if (self->Owner) - delete self->obj; - free_object(self); -} - -static PyObject * -PySfView_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PySfView *self; - - self = (PySfView *)type->tp_alloc(type, 0); - if (self != NULL) - { - self->Owner = true; - PySfFloatRect *Rect = NULL; - if (!PyArg_ParseTuple(args, "|O!:View.__new__", &PySfFloatRectType, &Rect)) - return NULL; - - if (Rect != NULL) - self->obj = new sf::View( (const sf::FloatRect) *(Rect->obj)); - else - self->obj = new sf::View(); - } - - return (PyObject *)self; -} - -static PyObject * -PySfView_GetCenter(PySfView* self) -{ - sf::Vector2f Vect = self->obj->GetCenter(); - return Py_BuildValue("ff", Vect.x, Vect.y); -} - -static PyObject * -PySfView_Reset(PySfView* self, PyObject *args) -{ - PySfFloatRect *Rect = (PySfFloatRect *)args; - if (!PyObject_TypeCheck(Rect, &PySfFloatRectType)) - { - PyErr_SetString(PyExc_TypeError, "View.Reset() Argument is not a sf.FloatRect instance"); - return NULL; - } - self->obj->Reset(*(Rect->obj)); - Py_RETURN_NONE; -} - -static PyObject * -PySfView_Move(PySfView* self, PyObject *args) -{ - float x, y; - if (!PyArg_ParseTuple(args, "ff:View.Move", &x, &y) ) - return NULL; - self->obj->Move(x, y); - Py_RETURN_NONE; -} - -static PyObject * -PySfView_SetCenter(PySfView* self, PyObject *args) -{ - float x, y; - if (!PyArg_ParseTuple(args, "ff:View.SetCenter", &x, &y) ) - return NULL; - self->obj->SetCenter(x, y); - Py_RETURN_NONE; -} - -static PyObject * -PySfView_Zoom(PySfView* self, PyObject *args) -{ - self->obj->Zoom(PyFloat_AsDouble(args)); - Py_RETURN_NONE; -} - -static PyMethodDef PySfView_methods[] = { - {"GetCenter", (PyCFunction)PySfView_GetCenter, METH_NOARGS, "GetCenter()\nGet the center of the view."}, - {"Move", (PyCFunction)PySfView_Move, METH_VARARGS, "Move(OffsetX, OffsetY)\nMove the view.\n\ - OffsetX : Offset to move the view, on X axis\n\ - OffsetY : Offset to move the view, on Y axis"}, - {"Reset", (PyCFunction)PySfView_Reset, METH_O, "Reset(ViewRect)\nRebuild the view from a rectangle.\n ViewRect : Rectangle defining the position and size of the view."}, - {"SetCenter", (PyCFunction)PySfView_SetCenter, METH_VARARGS, "SetCenter(X, Y)\nChange the center of the view."}, - {"Zoom", (PyCFunction)PySfView_Zoom, METH_O, "Zoom(Factor)\nResize the view rectangle to simulate a zoom / unzoom effect."}, - {NULL} /* Sentinel */ -}; - -PyTypeObject PySfViewType = { - head_init - "View", /*tp_name*/ - sizeof(PySfView), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - (destructor)PySfView_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash */ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ - "This class defines a view (position, size, etc.) ; you can consider it as a 2D camera.", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - PySfView_methods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PySfView_new, /* tp_new */ -}; - -PySfView * -GetNewPySfView() -{ - return PyObject_New(PySfView, &PySfViewType); -} - diff --git a/bindings/python/src/View.hpp b/bindings/python/src/View.hpp deleted file mode 100644 index 98f12527..00000000 --- a/bindings/python/src/View.hpp +++ /dev/null @@ -1,43 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// PySFML - Python binding for SFML (Simple and Fast Multimedia Library) -// Copyright (C) 2007, 2008 Rémi Koenig (remi.k2620@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#ifndef __PYVIEW_HPP -#define __PYVIEW_HPP - -#include - -#include - -#include "Rect.hpp" - -typedef struct { - PyObject_HEAD - bool Owner; - sf::View *obj; -} PySfView; - -PySfView * -GetNewPySfView(); - -#endif diff --git a/bindings/python/src/Window.cpp b/bindings/python/src/Window.cpp deleted file mode 100644 index 542b8668..00000000 --- a/bindings/python/src/Window.cpp +++ /dev/null @@ -1,395 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// PySFML - Python binding for SFML (Simple and Fast Multimedia Library) -// Copyright (C) 2007, 2008 Rémi Koenig (remi.k2620@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#include "Window.hpp" - -#include "Event.hpp" -#include "VideoMode.hpp" -#include "Input.hpp" -#include "ContextSettings.hpp" - -#include - -#include "compat.hpp" - - -extern PyTypeObject PySfEventType; -extern PyTypeObject PySfContextSettingsType; -extern PyTypeObject PySfVideoModeType; - - -static void -PySfWindow_dealloc(PySfWindow* self) -{ - delete self->obj; - free_object(self); -} - -static PyObject * -PySfWindow_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - long Handle; - PySfContextSettings *Params=NULL; - PySfWindow *self; - self = (PySfWindow *)type->tp_alloc(type, 0); - if (self != NULL) - { - if (PyArg_ParseTuple(args, "l|O!:Window.__new__", &Handle, &PySfContextSettingsType, &Params)) - { - if (Params) - { - PySfContextSettingsUpdate(Params); - self->obj = new sf::Window((sf::WindowHandle)Handle, *(Params->obj)); - } - else - self->obj = new sf::Window((sf::WindowHandle)Handle); - } - else - { - PyErr_Clear(); - self->obj = new sf::Window(); - } - } - return (PyObject *)self; -} - - -static PyObject* -PySfWindow_GetEvent(PySfWindow *self, PyObject *args) -{ - PySfEvent *PyEvent = (PySfEvent *)args; - - if (! PyObject_TypeCheck(PyEvent, &PySfEventType)) - { - PyErr_SetString(PyExc_TypeError, "Window.GetEvent() Argument is not a sfEvent"); - return NULL; - } - - if (self->obj->GetEvent(*(PyEvent->obj))) - { - PyEvent->Type = PyEvent->obj->Type; - PyEvent->Text->Unicode = PyEvent->obj->Text.Unicode; - PyEvent->Key->Code = PyEvent->obj->Key.Code; - Py_DECREF(PyEvent->Key->Alt); - PyEvent->Key->Alt = PyBool_FromLong(PyEvent->obj->Key.Alt); - Py_DECREF(PyEvent->Key->Control); - PyEvent->Key->Control = PyBool_FromLong(PyEvent->obj->Key.Control); - Py_DECREF(PyEvent->Key->Shift); - PyEvent->Key->Shift = PyBool_FromLong(PyEvent->obj->Key.Shift); - PyEvent->MouseButton->Button = PyEvent->obj->MouseButton.Button; - PyEvent->MouseButton->X = PyEvent->obj->MouseButton.X; - PyEvent->MouseButton->Y = PyEvent->obj->MouseButton.Y; - PyEvent->MouseMove->X = PyEvent->obj->MouseMove.X; - PyEvent->MouseMove->Y = PyEvent->obj->MouseMove.Y; - PyEvent->JoyMove->JoystickId = PyEvent->obj->JoyMove.JoystickId; - PyEvent->JoyButton->JoystickId = PyEvent->obj->JoyButton.JoystickId; - PyEvent->JoyButton->Button = PyEvent->obj->JoyButton.Button; - PyEvent->JoyMove->Axis = PyEvent->obj->JoyMove.Axis; - PyEvent->JoyMove->Position = PyEvent->obj->JoyMove.Position; - PyEvent->Size->Width = PyEvent->obj->Size.Width; - PyEvent->Size->Height = PyEvent->obj->Size.Height; - PyEvent->MouseWheel->Delta = PyEvent->obj->MouseWheel.Delta; - Py_RETURN_TRUE; - } - else - Py_RETURN_FALSE; -} - - -PyObject* -PySfWindow_Create(PySfWindow* self, PyObject *args, PyObject *kwds) -{ - PyObject *VideoModeTmp=NULL; - sf::VideoMode *VideoMode; - char *Title=NULL; - unsigned long WindowStyle = sf::Style::Resize | sf::Style::Close; - PySfContextSettings *Params=NULL; - - const char *kwlist[] = {"VideoMode", "Title", "WindowStyle", "Params", NULL}; - - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!s|IO!:Window.Create", (char **)kwlist, &PySfVideoModeType, &VideoModeTmp, &Title, &WindowStyle, &PySfContextSettingsType, &Params)) - return NULL; - - VideoMode = ((PySfVideoMode *)VideoModeTmp)->obj; - - if (Params) - { - PySfContextSettingsUpdate(Params); - self->obj->Create(*VideoMode, Title, WindowStyle, *(Params->obj)); - } - else - self->obj->Create(*VideoMode, Title, WindowStyle); - - Py_RETURN_NONE; -} - -static int -PySfWindow_init(PySfWindow *self, PyObject *args, PyObject *kwds) -{ - long Handle; - PySfContextSettings *Params; - - if (args != NULL) - { - if (PyTuple_Size(args) == 0) - return 0; - if (PyArg_ParseTuple(args, "l|O!:Window.__new__", &Handle, &PySfContextSettingsType, &Params)) - return 0; - PyErr_Clear(); - if (PySfWindow_Create(self, args, kwds) == NULL) - return -1; - } - return 0; -} - -static PyObject * -PySfWindow_Close(PySfWindow *self) -{ - self->obj->Close(); - Py_RETURN_NONE; -} -static PyObject * -PySfWindow_IsOpened(PySfWindow *self) -{ - return PyBool_FromLong(self->obj->IsOpened()); -} -static PyObject * -PySfWindow_GetWidth(PySfWindow *self) -{ - return PyLong_FromUnsignedLong(self->obj->GetWidth()); -} -static PyObject * -PySfWindow_GetHeight(PySfWindow *self) -{ - return PyLong_FromUnsignedLong(self->obj->GetHeight()); -} - -static PyObject * -PySfWindow_UseVerticalSync(PySfWindow *self, PyObject *args) -{ - self->obj->UseVerticalSync(PyBool_AsBool(args)); - Py_RETURN_NONE; -} -static PyObject * -PySfWindow_ShowMouseCursor(PySfWindow *self, PyObject *args) -{ - self->obj->ShowMouseCursor(PyBool_AsBool(args)); - Py_RETURN_NONE; -} - -static PyObject * -PySfWindow_SetActive(PySfWindow *self, PyObject *args) -{ - return PyBool_FromLong(self->obj->SetActive(PyBool_AsBool(args))); -} -static PyObject * -PySfWindow_Display(PySfWindow *self) -{ - self->obj->Display(); - Py_RETURN_NONE; -} -static PyObject * -PySfWindow_GetFrameTime(PySfWindow *self) -{ - return PyFloat_FromDouble(self->obj->GetFrameTime()); -} - -static PyObject * -PySfWindow_GetInput(PySfWindow *self) -{ - PySfInput *Input; - Input = GetNewPySfInput(); - Input->obj = (sf::Input *)&self->obj->GetInput(); - return (PyObject *)Input; -} - -static PyObject * -PySfWindow_GetSettings(PySfWindow *self) -{ - PySfContextSettings *Settings; - Settings = GetNewPySfContextSettings(); - Settings->obj = new sf::ContextSettings(self->obj->GetSettings()); - Settings->DepthBits = Settings->obj->DepthBits; - Settings->StencilBits = Settings->obj->StencilBits; - Settings->AntialiasingLevel = Settings->obj->AntialiasingLevel; - return (PyObject *)Settings; -} - -static PyObject * -PySfWindow_SetPosition(PySfWindow* self, PyObject *args) -{ - int Left=0, Top=0; - if (!PyArg_ParseTuple(args, "ii:Window.SetPosition", &Left, &Top)) - return NULL; - self->obj->SetPosition(Left,Top); - Py_RETURN_NONE; -} - -static PyObject * -PySfWindow_SetFramerateLimit(PySfWindow *self, PyObject *args) -{ - self->obj->SetFramerateLimit(PyLong_AsUnsignedLong(args)); - Py_RETURN_NONE; -} - -static PyObject * -PySfWindow_Show(PySfWindow *self, PyObject *args) -{ - self->obj->Show(PyBool_AsBool(args)); - Py_RETURN_NONE; -} - -static PyObject * -PySfWindow_EnableKeyRepeat(PySfWindow *self, PyObject *args) -{ - self->obj->EnableKeyRepeat(PyBool_AsBool(args)); - Py_RETURN_NONE; -} - -static PyObject * -PySfWindow_SetCursorPosition(PySfWindow* self, PyObject *args) -{ - unsigned int Left=0, Top=0; - if (!PyArg_ParseTuple(args, "II:Window.SetCursorPosition", &Left, &Top)) - return NULL; - self->obj->SetCursorPosition(Left,Top); - Py_RETURN_NONE; -} - -static PyObject * -PySfWindow_SetSize(PySfWindow* self, PyObject *args) -{ - unsigned int Width=0, Height=0; - if (!PyArg_ParseTuple(args, "II:Window.SetSize", &Width, &Height)) - return NULL; - self->obj->SetSize(Width, Height); - Py_RETURN_NONE; -} - -static PyObject * -PySfWindow_SetJoystickThreshold(PySfWindow* self, PyObject *args) -{ - self->obj->SetJoystickThreshold(PyFloat_AsDouble(args)); - Py_RETURN_NONE; -} - -static PyObject * -PySfWindow_SetIcon(PySfWindow* self, PyObject *args) -{ - unsigned int Width, Height, Size; - char *Data; - - if (! PyArg_ParseTuple(args, "IIs#:Window.SetIcon", &Width, &Height, &Data, &Size)) - return NULL; - - self->obj->SetIcon(Width, Height, (sf::Uint8*) Data); - Py_RETURN_NONE; -} - -static PyMethodDef PySfWindow_methods[] = { - {"Close", (PyCFunction)PySfWindow_Close, METH_NOARGS, "Close()\nClose (destroy) the window. The sf.Window instance remains valid and you can call Create to recreate the window."}, - {"Create", (PyCFunction)PySfWindow_Create, METH_VARARGS | METH_KEYWORDS, "Create(Mode, Title, sf.Style.Resize | sf.Style.Close, Params = sf.ContextSettings())\n\ -Create a window.\n\ - Mode : Video mode to use (sf.VideoMode instance)\n\ - Title : Title of the window\n\ - WindowStyle : Window style (Resize | Close by default)\n\ - Params : Creation parameters (see default constructor for default values)"}, - {"Display", (PyCFunction)PySfWindow_Display, METH_NOARGS, "Display()\nDisplay the window on screen."}, - {"EnableKeyRepeat", (PyCFunction)PySfWindow_EnableKeyRepeat, METH_O, "EnableKeyRepeat(Enable)\nEnable or disable automatic key-repeat. Automatic key-repeat is enabled by default.\n Enabled : True to enable, false to disable"}, - {"GetEvent", (PyCFunction)PySfWindow_GetEvent, METH_O, "GetEvent(Event)\nGet the event on top of events stack, if any, and pop it. Returns True if an event was returned, False if events stack was empty.\n EventReceived : Event to fill, if any."}, - {"GetFrameTime", (PyCFunction)PySfWindow_GetFrameTime, METH_NOARGS, "GetFrameTime()\nGet time elapsed since last frame. Returns time elapsed, in seconds"}, - {"GetHeight", (PyCFunction)PySfWindow_GetHeight, METH_NOARGS, "GetHeight()\nGet the height of the rendering region of the window."}, - {"GetInput", (PyCFunction)PySfWindow_GetInput, METH_NOARGS, "GetInput()\nGet the input manager of the window."}, - {"GetSettings", (PyCFunction)PySfWindow_GetSettings, METH_NOARGS, "GetSettings()\nGet the creation settings of the window."}, - {"GetWidth", (PyCFunction)PySfWindow_GetWidth, METH_NOARGS, "GetWidth()\nGet the width of the rendering region of the window."}, - {"IsOpened", (PyCFunction)PySfWindow_IsOpened, METH_NOARGS, "IsOpened()\nTell whether or not the window is opened (ie. has been created). Note that a hidden window (Show(False)) will still return True."}, - {"SetActive", (PyCFunction)PySfWindow_SetActive, METH_O, "SetActive(Active)\nActivate of deactivate the window as the current target for rendering. Returns True if operation was successful, False otherwise.\n Active : True to activate, False to deactivate (True by default)"}, - {"SetCursorPosition", (PyCFunction)PySfWindow_SetCursorPosition, METH_VARARGS, "SetCursorPosition(Left, Top)\nChange the position of the mouse cursor.\n Left : Left coordinate of the cursor, relative to the window\n Top : Top coordinate of the cursor, relative to the window"}, - {"SetSize", (PyCFunction)PySfWindow_SetSize, METH_VARARGS, "SetSize(Width, Height)\nChange the size of the rendering region of the window.\n\ - Width : New width\n Height : New height"}, - {"SetFramerateLimit", (PyCFunction)PySfWindow_SetFramerateLimit, METH_O, "SetFramerateLimit(Limit)\nSet the framerate at a fixed frequency.\n Limit : Framerate limit, in frames per seconds (use 0 to disable limit)"}, - {"SetJoystickThreshold", (PyCFunction)PySfWindow_SetJoystickThreshold, METH_O, "SetJoystickThreshold(Threshold)\nChange the joystick threshold, ie. the value below which no move event will be generated.\n Threshold : New threshold, in range [0., 100.]"}, - {"SetPosition", (PyCFunction)PySfWindow_SetPosition, METH_VARARGS, "SetPosition(X, Y)\nChange the position of the window on screen. Only works for top-level windows\n Left : Left position\n Top : Top position"}, - {"Show", (PyCFunction)PySfWindow_Show, METH_O, "Show(State)\nShow or hide the window.\n State : True to show, false to hide."}, - {"ShowMouseCursor", (PyCFunction)PySfWindow_ShowMouseCursor, METH_O, "ShowMouseCursor(Show)\nShow or hide the mouse cursor.\n Show : True to show, false to hide."}, - {"UseVerticalSync", (PyCFunction)PySfWindow_UseVerticalSync, METH_O, "UseVerticalSync(Enabled)\nEnable / disable vertical synchronization.\n Enabled : True to enable v-sync, False to deactivate"}, - {"SetIcon", (PyCFunction)PySfWindow_SetIcon, METH_VARARGS, "SetIcon(Width, Height, Pixels)\n\ -Change the window's icon.\n\ - Width : Icon's width, in pixels\n\ - Height : Icon's height, in pixels\n\ - Pixels : Pointer to the pixels in memory, format must be RGBA 32 bits."}, - {NULL} /* Sentinel */ -}; - -PyTypeObject PySfWindowType = { - head_init - "Window", /*tp_name*/ - sizeof(PySfWindow), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - (destructor)PySfWindow_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash */ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ - "sf.Window is a rendering window ; it can create a new window or connect to an existing one.\n\ -Default constructor : sf.Window()\n\ -Construct a new window : sf.Window(Mode, Title, sf.Style.Resize | sf.Style.Close, Params = sf.ContextSettings())\n\ - Mode : Video mode to use (sf.VideoMode instance)\n\ - Title : Title of the window\n\ - WindowStyle : Window style (Resize | Close by default)\n\ - Params : Creation parameters (see default constructor for default values)\n\ -Construct the window from an existing control : sf.Window(Handle, Params)\n\ - Handle : Platform-specific handle of the control\n\ - Params : Creation parameters (see default constructor for default values)", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - PySfWindow_methods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc)PySfWindow_init, /* tp_init */ - 0, /* tp_alloc */ - PySfWindow_new, /* tp_new */ -}; - - diff --git a/bindings/python/src/Window.hpp b/bindings/python/src/Window.hpp deleted file mode 100644 index 5b26b519..00000000 --- a/bindings/python/src/Window.hpp +++ /dev/null @@ -1,41 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// PySFML - Python binding for SFML (Simple and Fast Multimedia Library) -// Copyright (C) 2007, 2008 Rémi Koenig (remi.k2620@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#ifndef __PYWINDOW_HPP -#define __PYWINDOW_HPP - -#include - -#include - - -typedef struct { - PyObject_HEAD - sf::Window *obj; -} PySfWindow; - -PyObject* -PySfWindow_Create(PySfWindow* self, PyObject *args, PyObject *kwds); - -#endif diff --git a/bindings/python/src/WindowStyle.cpp b/bindings/python/src/WindowStyle.cpp deleted file mode 100644 index 03976e50..00000000 --- a/bindings/python/src/WindowStyle.cpp +++ /dev/null @@ -1,103 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// PySFML - Python binding for SFML (Simple and Fast Multimedia Library) -// Copyright (C) 2007, 2008 Rémi Koenig (remi.k2620@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#include "WindowStyle.hpp" - -#include "compat.hpp" - - -static PyObject * -PySfStyle_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PySfStyle *self; - self = (PySfStyle *)type->tp_alloc(type, 0); - return (PyObject *)self; -} - -PyTypeObject PySfStyleType = { - head_init - "Style", /*tp_name*/ - sizeof(PySfStyle), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - 0, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash */ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ - "Enumeration of window creation styles.\n\ -None No border / title bar (this flag and all others are mutually exclusive).\n\ -Titlebar Title bar + fixed border.\n\ -Resize Titlebar + resizable border + maximize button.\n\ -Close Titlebar + close button.\n\ -Fullscreen Fullscreen mode (this flag and all others are mutually exclusive).", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PySfStyle_new, /* tp_new */ -}; - -void PySfStyle_InitConst() -{ - PyObject *obj; - obj = PyLong_FromLong(sf::Style::None); - PyDict_SetItemString(PySfStyleType.tp_dict, "None", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Style::Titlebar); - PyDict_SetItemString(PySfStyleType.tp_dict, "Titlebar", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Style::Resize); - PyDict_SetItemString(PySfStyleType.tp_dict, "Resize", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Style::Close); - PyDict_SetItemString(PySfStyleType.tp_dict, "Close", obj); - Py_DECREF(obj); - obj = PyLong_FromLong(sf::Style::Fullscreen); - PyDict_SetItemString(PySfStyleType.tp_dict, "Fullscreen", obj); - Py_DECREF(obj); -} - diff --git a/bindings/python/src/WindowStyle.hpp b/bindings/python/src/WindowStyle.hpp deleted file mode 100644 index d93516ef..00000000 --- a/bindings/python/src/WindowStyle.hpp +++ /dev/null @@ -1,39 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// PySFML - Python binding for SFML (Simple and Fast Multimedia Library) -// Copyright (C) 2007, 2008 Rémi Koenig (remi.k2620@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#ifndef __PYWINDOWSTYLE_HPP -#define __PYWINDOWSTYLE_HPP - -#include - -#include - -typedef struct { - PyObject_HEAD -} PySfStyle; - -void -PySfStyle_InitConst(); - -#endif diff --git a/bindings/python/src/compat.hpp b/bindings/python/src/compat.hpp deleted file mode 100644 index 4bbdc028..00000000 --- a/bindings/python/src/compat.hpp +++ /dev/null @@ -1,72 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// PySFML - Python binding for SFML (Simple and Fast Multimedia Library) -// Copyright (C) 2007, 2008 Rémi Koenig (remi.k2620@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#ifndef __PYCOMPAT_HPP -#define __PYCOMPAT_HPP - -#if PY_MAJOR_VERSION >= 3 - -#define IS_PY3K -#define head_init PyVarObject_HEAD_INIT(NULL, 0) - -#define save_to_file(self, args) \ - PyObject *string = PyUnicode_AsUTF8String(args); \ - if (string == NULL) return NULL; \ - char *path = PyBytes_AsString(string); \ - bool result = self->obj->SaveToFile(path); \ - Py_DECREF(string); \ - return PyBool_FromLong(result) - -#define load_from_file(self, args) \ - PyObject *string = PyUnicode_AsUTF8String(args); \ - if (string == NULL) return NULL; \ - char *path = PyBytes_AsString(string); \ - bool result = self->obj->LoadFromFile(path); \ - Py_DECREF(string); \ - return PyBool_FromLong(result) - -#else - -#define save_to_file(self, args) \ - return PyBool_FromLong(self->obj->SaveToFile(PyString_AsString(args))) -#define load_from_file(self, args) \ - return PyBool_FromLong(self->obj->LoadFromFile(PyString_AsString(args))) - -#define head_init PyObject_HEAD_INIT(NULL) 0, -#define PyBytes_FromStringAndSize PyString_FromStringAndSize - -#endif - -#ifndef Py_TYPE -#define Py_TYPE(a) a->ob_type -#endif - -#define free_object(a) Py_TYPE(a)->tp_free((PyObject*)a) - -#define PyBool_AsBool(a) ((PyObject_IsTrue(a))?true:false) - - - -#endif - diff --git a/bindings/python/src/main.cpp b/bindings/python/src/main.cpp deleted file mode 100644 index 8c531284..00000000 --- a/bindings/python/src/main.cpp +++ /dev/null @@ -1,304 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// PySFML - Python binding for SFML (Simple and Fast Multimedia Library) -// Copyright (C) 2007, 2008 Rémi Koenig (remi.k2620@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#include "main.hpp" - -#include "Color.hpp" -#include "Key.hpp" -#include "Joy.hpp" -#include "Event.hpp" -#include "Mouse.hpp" -#include "WindowStyle.hpp" -#include "ContextSettings.hpp" -#include "Blend.hpp" -#include "Sound.hpp" -#include "Text.hpp" -#include "SoundStream.hpp" - -#include "compat.hpp" - -extern PyTypeObject PySfClockType; - -extern PyTypeObject PySfEventType; -extern PyTypeObject PySfEventTextType; -extern PyTypeObject PySfEventKeyType; -extern PyTypeObject PySfEventMouseMoveType; -extern PyTypeObject PySfEventMouseButtonType; -extern PyTypeObject PySfEventMouseWheelType; -extern PyTypeObject PySfEventJoyMoveType; -extern PyTypeObject PySfEventJoyButtonType; -extern PyTypeObject PySfEventSizeType; -extern PyTypeObject PySfKeyType; -extern PyTypeObject PySfJoyType; -extern PyTypeObject PySfMouseType; - -extern PyTypeObject PySfVideoModeType; -extern PyTypeObject PySfWindowType; -extern PyTypeObject PySfStyleType; -extern PyTypeObject PySfContextSettingsType; -extern PyTypeObject PySfRenderWindowType; -extern PyTypeObject PySfViewType; -extern PyTypeObject PySfInputType; - -extern PyTypeObject PySfDrawableType; -extern PyTypeObject PySfBlendType; -extern PyTypeObject PySfSpriteType; -extern PyTypeObject PySfFontType; -extern PyTypeObject PySfGlyphType; -extern PyTypeObject PySfTextType; -//extern PyTypeObject PySfPostFXType; - -extern PyTypeObject PySfImageType; -extern PyTypeObject PySfColorType; - -extern PyTypeObject PySfShapeType; - -extern PyTypeObject PySfIntRectType; -extern PyTypeObject PySfFloatRectType; - -extern PyTypeObject PySfMusicType; -extern PyTypeObject PySfSoundType; -extern PyTypeObject PySfSoundBufferType; -extern PyTypeObject PySfSoundRecorderType; -extern PyTypeObject PySfSoundBufferRecorderType; -extern PyTypeObject PySfSoundStreamType; -extern PyTypeObject PySfListenerType; - - -static PyMethodDef module_methods[] = { - {"Sleep", (PyCFunction)PySFML_Sleep, METH_O, "Sleep(Duration)\nMake the current thread sleep for a given time.\n Duration : Time to sleep, in seconds"}, - {NULL} /* Sentinel */ -}; - -#ifdef IS_PY3K -#define INITERROR return NULL -static PyModuleDef module_def = { - PyModuleDef_HEAD_INIT, - "sf", - "Python binding for sfml (Simple Fast Media Library)", - -1, - module_methods, NULL, NULL, NULL, NULL -}; - -PyMODINIT_FUNC -PyInit_sf(void) -#else -#define INITERROR return - -#ifndef PyMODINIT_FUNC /* declarations for DLL import/export */ -#define PyMODINIT_FUNC void -#endif -PyMODINIT_FUNC -initsf(void) -#endif -{ - PyObject *m; - - if (PyType_Ready(&PySfClockType) < 0) - INITERROR; - - if (PyType_Ready(&PySfWindowType) < 0) - INITERROR; - if (PyType_Ready(&PySfStyleType) < 0) - INITERROR; - if (PyType_Ready(&PySfContextSettingsType) < 0) - INITERROR; - if (PyType_Ready(&PySfRenderWindowType) < 0) - INITERROR; - if (PyType_Ready(&PySfVideoModeType) < 0) - INITERROR; - if (PyType_Ready(&PySfViewType) < 0) - INITERROR; - if (PyType_Ready(&PySfInputType) < 0) - INITERROR; - - if (PyType_Ready(&PySfEventType) < 0) - INITERROR; - if (PyType_Ready(&PySfEventTextType) < 0) - INITERROR; - if (PyType_Ready(&PySfEventKeyType) < 0) - INITERROR; - if (PyType_Ready(&PySfEventMouseMoveType) < 0) - INITERROR; - if (PyType_Ready(&PySfEventMouseButtonType) < 0) - INITERROR; - if (PyType_Ready(&PySfEventMouseWheelType) < 0) - INITERROR; - if (PyType_Ready(&PySfEventJoyMoveType) < 0) - INITERROR; - if (PyType_Ready(&PySfEventJoyButtonType) < 0) - INITERROR; - if (PyType_Ready(&PySfEventSizeType) < 0) - INITERROR; - if (PyType_Ready(&PySfKeyType) < 0) - INITERROR; - if (PyType_Ready(&PySfJoyType) < 0) - INITERROR; - if (PyType_Ready(&PySfMouseType) < 0) - INITERROR; - - if (PyType_Ready(&PySfDrawableType) < 0) - INITERROR; - if (PyType_Ready(&PySfBlendType) < 0) - INITERROR; - if (PyType_Ready(&PySfSpriteType) < 0) - INITERROR; - if (PyType_Ready(&PySfFontType) < 0) - INITERROR; - if (PyType_Ready(&PySfGlyphType) < 0) - INITERROR; - if (PyType_Ready(&PySfTextType) < 0) - INITERROR; - /*if (PyType_Ready(&PySfPostFXType) < 0) - INITERROR; */ - - if (PyType_Ready(&PySfImageType) < 0) - INITERROR; - - if (PyType_Ready(&PySfShapeType) < 0) - INITERROR; - - if (PyType_Ready(&PySfColorType) < 0) - INITERROR; - - if (PyType_Ready(&PySfIntRectType) < 0) - INITERROR; - if (PyType_Ready(&PySfFloatRectType) < 0) - INITERROR; - - if (PyType_Ready(&PySfMusicType) < 0) - INITERROR; - if (PyType_Ready(&PySfSoundType) < 0) - INITERROR; - if (PyType_Ready(&PySfSoundBufferType) < 0) - INITERROR; - if (PyType_Ready(&PySfSoundBufferRecorderType) < 0) - INITERROR; - if (PyType_Ready(&PySfSoundRecorderType) < 0) - INITERROR; - if (PyType_Ready(&PySfSoundStreamType) < 0) - INITERROR; - if (PyType_Ready(&PySfListenerType) < 0) - INITERROR; - -#ifdef IS_PY3K - m = PyModule_Create(&module_def); -#else - m = Py_InitModule3("sf", module_methods, "Python binding for sfml (Simple Fast Media Library)"); -#endif - - if (m == NULL) - INITERROR; - - Py_INCREF(&PySfClockType); - PyModule_AddObject(m, "Clock", (PyObject *)&PySfClockType); - - Py_INCREF(&PySfWindowType); - PyModule_AddObject(m, "Window", (PyObject *)&PySfWindowType); - Py_INCREF(&PySfStyleType); - PyModule_AddObject(m, "Style", (PyObject *)&PySfStyleType); - Py_INCREF(&PySfContextSettingsType); - PyModule_AddObject(m, "ContextSettings", (PyObject *)&PySfContextSettingsType); - Py_INCREF(&PySfRenderWindowType); - PyModule_AddObject(m, "RenderWindow", (PyObject *)&PySfRenderWindowType); - Py_INCREF(&PySfVideoModeType); - PyModule_AddObject(m, "VideoMode", (PyObject *)&PySfVideoModeType); - Py_INCREF(&PySfViewType); - PyModule_AddObject(m, "View", (PyObject *)&PySfViewType); - Py_INCREF(&PySfInputType); - PyModule_AddObject(m, "Input", (PyObject *)&PySfInputType); - - Py_INCREF(&PySfDrawableType); - PyModule_AddObject(m, "Drawable", (PyObject *)&PySfDrawableType); - Py_INCREF(&PySfBlendType); - PyModule_AddObject(m, "Blend", (PyObject *)&PySfBlendType); - Py_INCREF(&PySfSpriteType); - PyModule_AddObject(m, "Sprite", (PyObject *)&PySfSpriteType); - Py_INCREF(&PySfFontType); - PyModule_AddObject(m, "Font", (PyObject *)&PySfFontType); - Py_INCREF(&PySfGlyphType); - PyModule_AddObject(m, "Glyph", (PyObject *)&PySfGlyphType); - Py_INCREF(&PySfTextType); - PyModule_AddObject(m, "Text", (PyObject *)&PySfTextType); - /*Py_INCREF(&PySfPostFXType); - PyModule_AddObject(m, "PostFX", (PyObject *)&PySfPostFXType); */ - - Py_INCREF(&PySfEventType); - PyModule_AddObject(m, "Event", (PyObject *)&PySfEventType); - Py_INCREF(&PySfKeyType); - PyModule_AddObject(m, "Key", (PyObject *)&PySfKeyType); - Py_INCREF(&PySfJoyType); - PyModule_AddObject(m, "Joy", (PyObject *)&PySfJoyType); - Py_INCREF(&PySfMouseType); - PyModule_AddObject(m, "Mouse", (PyObject *)&PySfMouseType); - - Py_INCREF(&PySfImageType); - PyModule_AddObject(m, "Image", (PyObject *)&PySfImageType); - - Py_INCREF(&PySfColorType); - PyModule_AddObject(m, "Color", (PyObject *)&PySfColorType); - - Py_INCREF(&PySfShapeType); - PyModule_AddObject(m, "Shape", (PyObject *)&PySfShapeType); - - Py_INCREF(&PySfIntRectType); - PyModule_AddObject(m, "IntRect", (PyObject *)&PySfIntRectType); - Py_INCREF(&PySfFloatRectType); - PyModule_AddObject(m, "FloatRect", (PyObject *)&PySfFloatRectType); - - Py_INCREF(&PySfMusicType); - PyModule_AddObject(m, "Music", (PyObject *)&PySfMusicType); - Py_INCREF(&PySfSoundType); - PyModule_AddObject(m, "Sound", (PyObject *)&PySfSoundType); - Py_INCREF(&PySfSoundBufferType); - PyModule_AddObject(m, "SoundBuffer", (PyObject *)&PySfSoundBufferType); - Py_INCREF(&PySfSoundRecorderType); - PyModule_AddObject(m, "SoundRecorder", (PyObject *)&PySfSoundRecorderType); - Py_INCREF(&PySfSoundBufferRecorderType); - PyModule_AddObject(m, "SoundBufferRecorder", (PyObject *)&PySfSoundBufferRecorderType); - Py_INCREF(&PySfSoundStreamType); - PyModule_AddObject(m, "SoundStream", (PyObject *)&PySfSoundStreamType); - Py_INCREF(&PySfListenerType); - PyModule_AddObject(m, "Listener", (PyObject *)&PySfListenerType); - - PyModule_AddStringConstant(m, "Version", "1.6"); - - PySfColor_InitConst(); - PySfKey_InitConst(); - PySfJoy_InitConst(); - PySfEvent_InitConst(); - PySfMouse_InitConst(); - PySfStyle_InitConst(); - PySfBlend_InitConst(); - PySfSound_InitConst(); - PySfSoundStream_InitConst(); - PySfText_InitConst(); - - PyEval_InitThreads(); - -#ifdef IS_PY3K - return m; -#endif -} - diff --git a/bindings/python/src/main.hpp b/bindings/python/src/main.hpp deleted file mode 100644 index dc4a5541..00000000 --- a/bindings/python/src/main.hpp +++ /dev/null @@ -1,37 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// PySFML - Python binding for SFML (Simple and Fast Multimedia Library) -// Copyright (C) 2007, 2008 Rémi Koenig (remi.k2620@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#ifndef __PYMAIN_HPP -#define __PYMAIN_HPP - -#include -#include - -#include -#include - -#include "Event.hpp" -#include "Sleep.hpp" - -#endif diff --git a/bindings/python/src/offsetof.hpp b/bindings/python/src/offsetof.hpp deleted file mode 100644 index 73de395a..00000000 --- a/bindings/python/src/offsetof.hpp +++ /dev/null @@ -1,32 +0,0 @@ -//////////////////////////////////////////////////////////// -// -// PySFML - Python binding for SFML (Simple and Fast Multimedia Library) -// Copyright (C) 2007, 2008 Rémi Koenig (remi.k2620@gmail.com) -// -// This software is provided 'as-is', without any express or implied warranty. -// In no event will the authors be held liable for any damages arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it freely, -// subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; -// you must not claim that you wrote the original software. -// If you use this software in a product, an acknowledgment -// in the product documentation would be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, -// and must not be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source distribution. -// -//////////////////////////////////////////////////////////// - -#ifndef __OFFSETOF_H -#define __OFFSETOF_H - -#undef offsetof -#define offsetof(TYPE, MEMBER) (reinterpret_cast \ - (&reinterpret_cast (static_cast (0)->MEMBER))) - -#endif