mirror of
https://github.com/SFML/SFML.git
synced 2024-11-24 20:31:05 +08:00
Corrected the name of some functions/variable
This commit is contained in:
parent
c817f882e6
commit
aaa21dfaf6
@ -20,9 +20,9 @@ void PlaySound()
|
||||
|
||||
// Display sound informations
|
||||
std::cout << "canary.wav :" << std::endl;
|
||||
std::cout << " " << buffer.GetDuration() / 1000.f << " seconds" << std::endl;
|
||||
std::cout << " " << buffer.GetSampleRate() << " samples / sec" << std::endl;
|
||||
std::cout << " " << buffer.GetChannelsCount() << " channels" << std::endl;
|
||||
std::cout << " " << buffer.GetDuration() / 1000.f << " seconds" << std::endl;
|
||||
std::cout << " " << buffer.GetSampleRate() << " samples / sec" << std::endl;
|
||||
std::cout << " " << buffer.GetChannelCount() << " channels" << std::endl;
|
||||
|
||||
// Create a sound instance and play it
|
||||
sf::Sound sound(buffer);
|
||||
@ -57,7 +57,7 @@ void PlayMusic()
|
||||
std::cout << "orchestral.ogg :" << std::endl;
|
||||
std::cout << " " << music.GetDuration() / 1000.f << " seconds" << std::endl;
|
||||
std::cout << " " << music.GetSampleRate() << " samples / sec" << std::endl;
|
||||
std::cout << " " << music.GetChannelsCount() << " channels" << std::endl;
|
||||
std::cout << " " << music.GetChannelCount() << " channels" << std::endl;
|
||||
|
||||
// Play it
|
||||
music.Play();
|
||||
|
@ -46,9 +46,9 @@ int main()
|
||||
|
||||
// Display captured sound informations
|
||||
std::cout << "Sound information :" << std::endl;
|
||||
std::cout << " " << buffer.GetDuration() / 1000.f << " seconds" << std::endl;
|
||||
std::cout << " " << buffer.GetSampleRate() << " samples / seconds" << std::endl;
|
||||
std::cout << " " << buffer.GetChannelsCount() << " channels" << std::endl;
|
||||
std::cout << " " << buffer.GetDuration() / 1000.f << " seconds" << std::endl;
|
||||
std::cout << " " << buffer.GetSampleRate() << " samples / seconds" << std::endl;
|
||||
std::cout << " " << buffer.GetChannelCount() << " channels" << std::endl;
|
||||
|
||||
// Choose what to do with the recorded sound data
|
||||
char choice;
|
||||
|
@ -55,12 +55,12 @@ private :
|
||||
/// /see SoundRecorder::ProcessSamples
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual bool OnProcessSamples(const sf::Int16* samples, std::size_t samplesCount)
|
||||
virtual bool OnProcessSamples(const sf::Int16* samples, std::size_t sampleCount)
|
||||
{
|
||||
// Pack the audio samples into a network packet
|
||||
sf::Packet packet;
|
||||
packet << audioData;
|
||||
packet.Append(samples, samplesCount * sizeof(sf::Int16));
|
||||
packet.Append(samples, sampleCount * sizeof(sf::Int16));
|
||||
|
||||
// Send the audio packet to the server
|
||||
return mySocket.Send(packet) == sf::Socket::Done;
|
||||
|
@ -103,7 +103,7 @@ private :
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual void OnSeek(sf::Uint32 timeOffset)
|
||||
{
|
||||
myOffset = timeOffset * GetSampleRate() * GetChannelsCount() / 1000;
|
||||
myOffset = timeOffset * GetSampleRate() * GetChannelCount() / 1000;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
@ -129,7 +129,7 @@ private :
|
||||
const sf::Int16* samples = reinterpret_cast<const sf::Int16*>(packet.GetData() + 1);
|
||||
std::size_t nbSamples = (packet.GetDataSize() - 1) / sizeof(sf::Int16);
|
||||
|
||||
// Don't forget that the other thread can access the samples array at any time
|
||||
// Don't forget that the other thread can access the sample array at any time
|
||||
// (so we protect any operation on it with the mutex)
|
||||
{
|
||||
sf::Lock lock(myMutex);
|
||||
|
@ -127,17 +127,17 @@ public :
|
||||
/// The assumed format of the audio samples is 16 bits signed integer
|
||||
/// (sf::Int16).
|
||||
///
|
||||
/// \param samples Pointer to the array of samples in memory
|
||||
/// \param samplesCount Number of samples in the array
|
||||
/// \param channelsCount Number of channels (1 = mono, 2 = stereo, ...)
|
||||
/// \param sampleRate Sample rate (number of samples to play per second)
|
||||
/// \param samples Pointer to the array of samples in memory
|
||||
/// \param sampleCount Number of samples in the array
|
||||
/// \param channelCount Number of channels (1 = mono, 2 = stereo, ...)
|
||||
/// \param sampleRate Sample rate (number of samples to play per second)
|
||||
///
|
||||
/// \return True if loading succeeded, false if it failed
|
||||
///
|
||||
/// \see LoadFromFile, LoadFromMemory, SaveToFile
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool LoadFromSamples(const Int16* samples, std::size_t samplesCount, unsigned int channelsCount, unsigned int sampleRate);
|
||||
bool LoadFromSamples(const Int16* samples, std::size_t sampleCount, unsigned int channelCount, unsigned int sampleRate);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Save the sound buffer to an audio file
|
||||
@ -160,11 +160,11 @@ public :
|
||||
///
|
||||
/// The format of the returned samples is 16 bits signed integer
|
||||
/// (sf::Int16). The total number of samples in this array
|
||||
/// is given by the GetSamplesCount() function.
|
||||
/// is given by the GetSampleCount() function.
|
||||
///
|
||||
/// \return Read-only pointer to the array of sound samples
|
||||
///
|
||||
/// \see GetSamplesCount
|
||||
/// \see GetSampleCount
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
const Int16* GetSamples() const;
|
||||
@ -180,7 +180,7 @@ public :
|
||||
/// \see GetSamples
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
std::size_t GetSamplesCount() const;
|
||||
std::size_t GetSampleCount() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the sample rate of the sound
|
||||
@ -191,7 +191,7 @@ public :
|
||||
///
|
||||
/// \return Sample rate (number of samples per second)
|
||||
///
|
||||
/// \see GetChannelsCount, GetDuration
|
||||
/// \see GetChannelCount, GetDuration
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int GetSampleRate() const;
|
||||
@ -207,14 +207,14 @@ public :
|
||||
/// \see GetSampleRate, GetDuration
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int GetChannelsCount() const;
|
||||
unsigned int GetChannelCount() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the total duration of the sound
|
||||
///
|
||||
/// \return Sound duration, in milliseconds
|
||||
///
|
||||
/// \see GetSampleRate, GetChannelsCount
|
||||
/// \see GetSampleRate, GetChannelCount
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Uint32 GetDuration() const;
|
||||
@ -246,13 +246,13 @@ private :
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Update the internal buffer with the cached audio samples
|
||||
///
|
||||
/// \param channelsCount Number of channels
|
||||
/// \param sampleRate Sample rate (number of samples per second)
|
||||
/// \param channelCount Number of channels
|
||||
/// \param sampleRate Sample rate (number of samples per second)
|
||||
///
|
||||
/// \return True on success, false if any error happened
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool Update(unsigned int channelsCount, unsigned int sampleRate);
|
||||
bool Update(unsigned int channelCount, unsigned int sampleRate);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Add a sound to the list of sounds that use this buffer
|
||||
|
@ -70,13 +70,13 @@ private :
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Process a new chunk of recorded samples
|
||||
///
|
||||
/// \param samples Pointer to the new chunk of recorded samples
|
||||
/// \param samplesCount Number of samples pointed by \a samples
|
||||
/// \param samples Pointer to the new chunk of recorded samples
|
||||
/// \param sampleCount Number of samples pointed by \a samples
|
||||
///
|
||||
/// \return True to continue the capture, or false to stop it
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual bool OnProcessSamples(const Int16* samples, std::size_t samplesCount);
|
||||
virtual bool OnProcessSamples(const Int16* samples, std::size_t sampleCount);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Stop capturing audio data
|
||||
|
@ -131,13 +131,13 @@ private :
|
||||
/// whatever it wants with it (storing it, playing it, sending
|
||||
/// it over the network, etc.).
|
||||
///
|
||||
/// \param samples Pointer to the new chunk of recorded samples
|
||||
/// \param samplesCount Number of samples pointed by \a samples
|
||||
/// \param samples Pointer to the new chunk of recorded samples
|
||||
/// \param sampleCount Number of samples pointed by \a samples
|
||||
///
|
||||
/// \return True to continue the capture, or false to stop it
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual bool OnProcessSamples(const Int16* samples, std::size_t samplesCount) = 0;
|
||||
virtual bool OnProcessSamples(const Int16* samples, std::size_t sampleCount) = 0;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Stop capturing audio data
|
||||
@ -238,7 +238,7 @@ private :
|
||||
/// return true;
|
||||
/// }
|
||||
///
|
||||
/// virtual bool OnProcessSamples(const Int16* samples, std::size_t samplesCount)
|
||||
/// virtual bool OnProcessSamples(const Int16* samples, std::size_t sampleCount)
|
||||
/// {
|
||||
/// // Do something with the new chunk of samples (store them, send them, ...)
|
||||
/// ...
|
||||
|
@ -104,7 +104,7 @@ public :
|
||||
/// \return Number of channels
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int GetChannelsCount() const;
|
||||
unsigned int GetChannelCount() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the stream sample rate of the stream
|
||||
@ -193,11 +193,11 @@ protected :
|
||||
/// It can be called multiple times if the settings of the
|
||||
/// audio stream change, but only when the stream is stopped.
|
||||
///
|
||||
/// \param channelsCount Number of channels of the stream
|
||||
/// \param sampleRate Sample rate, in samples per second
|
||||
/// \param channelCount Number of channels of the stream
|
||||
/// \param sampleRate Sample rate, in samples per second
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Initialize(unsigned int channelsCount, unsigned int sampleRate);
|
||||
void Initialize(unsigned int channelCount, unsigned int sampleRate);
|
||||
|
||||
private :
|
||||
|
||||
@ -245,7 +245,7 @@ private :
|
||||
/// consumed; it fills it again and inserts it back into the
|
||||
/// playing queue.
|
||||
///
|
||||
/// \param buffer Number of the buffer to fill (in [0, BuffersCount])
|
||||
/// \param buffer Number of the buffer to fill (in [0, BufferCount])
|
||||
///
|
||||
/// \return True if the stream source has requested to stop, false otherwise
|
||||
///
|
||||
@ -273,21 +273,21 @@ private :
|
||||
|
||||
enum
|
||||
{
|
||||
BuffersCount = 3 ///< Number of audio buffers used by the streaming loop
|
||||
BufferCount = 3 ///< Number of audio buffers used by the streaming loop
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
Thread myThread; ///< Thread running the background tasks
|
||||
bool myIsStreaming; ///< Streaming state (true = playing, false = stopped)
|
||||
unsigned int myBuffers[BuffersCount]; ///< Sound buffers used to store temporary audio data
|
||||
unsigned int myChannelsCount; ///< Number of channels (1 = mono, 2 = stereo, ...)
|
||||
unsigned int mySampleRate; ///< Frequency (samples / second)
|
||||
Uint32 myFormat; ///< Format of the internal sound buffers
|
||||
bool myLoop; ///< Loop flag (true to loop, false to play once)
|
||||
Uint64 mySamplesProcessed; ///< Number of buffers processed since beginning of the stream
|
||||
bool myEndBuffers[BuffersCount]; ///< Each buffer is marked as "end buffer" or not, for proper duration calculation
|
||||
Thread myThread; ///< Thread running the background tasks
|
||||
bool myIsStreaming; ///< Streaming state (true = playing, false = stopped)
|
||||
unsigned int myBuffers[BufferCount]; ///< Sound buffers used to store temporary audio data
|
||||
unsigned int myChannelCount; ///< Number of channels (1 = mono, 2 = stereo, ...)
|
||||
unsigned int mySampleRate; ///< Frequency (samples / second)
|
||||
Uint32 myFormat; ///< Format of the internal sound buffers
|
||||
bool myLoop; ///< Loop flag (true to loop, false to play once)
|
||||
Uint64 mySamplesProcessed; ///< Number of buffers processed since beginning of the stream
|
||||
bool myEndBuffers[BufferCount]; ///< Each buffer is marked as "end buffer" or not, for proper duration calculation
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
@ -338,11 +338,11 @@ private :
|
||||
/// {
|
||||
/// // Open the source and get audio settings
|
||||
/// ...
|
||||
/// unsigned int channelsCount = ...;
|
||||
/// unsigned int channelCount = ...;
|
||||
/// unsigned int sampleRate = ...;
|
||||
///
|
||||
/// // Initialize the stream -- important!
|
||||
/// Initialize(channelsCount, sampleRate);
|
||||
/// Initialize(channelCount, sampleRate);
|
||||
/// }
|
||||
///
|
||||
/// private :
|
||||
|
@ -44,11 +44,11 @@ public :
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Default constructor
|
||||
///
|
||||
/// \param radius Radius of the circle
|
||||
/// \param pointsCount Number of points composing the circle
|
||||
/// \param radius Radius of the circle
|
||||
/// \param pointCount Number of points composing the circle
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
explicit CircleShape(float radius = 0, unsigned int pointsCount = 30);
|
||||
explicit CircleShape(float radius = 0, unsigned int pointCount = 30);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Set the radius of the circle
|
||||
@ -75,20 +75,20 @@ public :
|
||||
///
|
||||
/// \param count New number of points of the circle
|
||||
///
|
||||
/// \see GetPointsCount
|
||||
/// \see GetPointCount
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetPointsCount(unsigned int count);
|
||||
void SetPointCount(unsigned int count);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the number of points of the shape
|
||||
///
|
||||
/// \return Number of points of the shape
|
||||
///
|
||||
/// \see SetPointsCount
|
||||
/// \see SetPointCount
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual unsigned int GetPointsCount() const;
|
||||
virtual unsigned int GetPointCount() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get a point of the shape
|
||||
@ -105,8 +105,8 @@ private :
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
float myRadius; ///< Radius of the circle
|
||||
unsigned int myPointsCount; ///< Number of points composing the circle
|
||||
float myRadius; ///< Radius of the circle
|
||||
unsigned int myPointCount; ///< Number of points composing the circle
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
|
@ -45,30 +45,30 @@ public :
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Default constructor
|
||||
///
|
||||
/// \param pointsCount Number of points of the polygon
|
||||
/// \param pointCount Number of points of the polygon
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
explicit ConvexShape(unsigned int pointsCount = 0);
|
||||
explicit ConvexShape(unsigned int pointCount = 0);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Set the number of points of the polygon
|
||||
///
|
||||
/// \param count New number of points of the polygon
|
||||
///
|
||||
/// \see GetPointsCount
|
||||
/// \see GetPointCount
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void SetPointsCount(unsigned int count);
|
||||
void SetPointCount(unsigned int count);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the number of points of the polygon
|
||||
///
|
||||
/// \return Number of points of the polygon
|
||||
///
|
||||
/// \see SetPointsCount
|
||||
/// \see SetPointCount
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual unsigned int GetPointsCount() const;
|
||||
virtual unsigned int GetPointCount() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Set the position of a point
|
||||
@ -126,7 +126,7 @@ private :
|
||||
/// Usage example:
|
||||
/// \code
|
||||
/// sf::ConvexShape polygon;
|
||||
/// polygon.SetPointsCount(3);
|
||||
/// polygon.SetPointCount(3);
|
||||
/// polygon.SetPoint(0, sf::Vector2f(0, 0));
|
||||
/// polygon.SetPoint(1, sf::Vector2f(0, 10));
|
||||
/// polygon.SetPoint(2, sf::Vector2f(25, 5));
|
||||
|
@ -67,7 +67,7 @@ public :
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Create the image from an arry of pixels
|
||||
///
|
||||
/// The \a pixels array is assumed to contain 32-bits RGBA pixels,
|
||||
/// The \a pixel array is assumed to contain 32-bits RGBA pixels,
|
||||
/// and have the given \a width and \a height. If not, this is
|
||||
/// an undefined behaviour.
|
||||
/// If \a pixels is null, an empty image is created.
|
||||
|
@ -75,7 +75,7 @@ public :
|
||||
/// \return Number of points of the shape
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual unsigned int GetPointsCount() const;
|
||||
virtual unsigned int GetPointCount() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get a point of the shape
|
||||
|
@ -189,13 +189,13 @@ public :
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Draw primitives defined by an array of vertices
|
||||
///
|
||||
/// \param vertices Pointer to the vertices
|
||||
/// \param verticesCount Number of vertices in the array
|
||||
/// \param type Type of primitives to draw
|
||||
/// \param states Render states to use for drawing
|
||||
/// \param vertices Pointer to the vertices
|
||||
/// \param vertexCount Number of vertices in the array
|
||||
/// \param type Type of primitives to draw
|
||||
/// \param states Render states to use for drawing
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Draw(const Vertex* vertices, unsigned int verticesCount,
|
||||
void Draw(const Vertex* vertices, unsigned int vertexCount,
|
||||
PrimitiveType type, const RenderStates& states = RenderStates::Default);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
@ -190,12 +190,12 @@ public :
|
||||
/// \return Number of points of the shape
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual unsigned int GetPointsCount() const = 0;
|
||||
virtual unsigned int GetPointCount() const = 0;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get a point of the shape
|
||||
///
|
||||
/// \param index Index of the point to get, in range [0 .. GetPointsCount() - 1]
|
||||
/// \param index Index of the point to get, in range [0 .. GetPointCount() - 1]
|
||||
///
|
||||
/// \return Index-th point of the shape
|
||||
///
|
||||
@ -243,7 +243,7 @@ protected :
|
||||
///
|
||||
/// This function must be called by the derived class everytime
|
||||
/// the shape's points change (ie. the result of either
|
||||
/// GetPointsCount or GetPoint is different).
|
||||
/// GetPointCount or GetPoint is different).
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Update();
|
||||
@ -330,7 +330,7 @@ private :
|
||||
///
|
||||
/// You can write your own derived shape class, there are only
|
||||
/// two virtual functions to override:
|
||||
/// \li GetOutlinePointsCount must return the number of points of the shape
|
||||
/// \li GetOutlinePointCount must return the number of points of the shape
|
||||
/// \li GetOutlinePoint must return the points of the shape
|
||||
///
|
||||
/// \see sf::LineShape, sf::RectangleShape, sf::CircleShape, sf::ConvexShape, sf::Transformable
|
||||
|
@ -250,7 +250,7 @@ public :
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Update the whole texture from an array of pixels
|
||||
///
|
||||
/// The \a pixels array is assumed to have the same size as
|
||||
/// The \a pixel array is assumed to have the same size as
|
||||
/// the \a area rectangle, and to contain 32-bits RGBA pixels.
|
||||
///
|
||||
/// No additional check is performed on the size of the pixel
|
||||
@ -268,7 +268,7 @@ public :
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Update a part of the texture from an array of pixels
|
||||
///
|
||||
/// The size of the \a pixels array must match the \a width and
|
||||
/// The size of the \a pixel array must match the \a width and
|
||||
/// \a height arguments, and it must contain 32-bits RGBA pixels.
|
||||
///
|
||||
/// No additional check is performed on the size of the pixel
|
||||
|
@ -56,11 +56,11 @@ public :
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Construct the vertex array with a type and an initial number of vertices
|
||||
///
|
||||
/// \param type Type of primitives
|
||||
/// \param verticesCount Initial number of vertices in the array
|
||||
/// \param type Type of primitives
|
||||
/// \param vertexCount Initial number of vertices in the array
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
VertexArray(PrimitiveType type, unsigned int verticesCount = 0);
|
||||
VertexArray(PrimitiveType type, unsigned int vertexCount = 0);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Return the vertices count
|
||||
@ -68,19 +68,19 @@ public :
|
||||
/// \return Number of vertices in the array
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int GetVerticesCount() const;
|
||||
unsigned int GetVertexCount() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get a read-write access to a vertex by its index
|
||||
///
|
||||
/// This function doesn't check \a index, it must be in range
|
||||
/// [0, GetVerticesCount() - 1].
|
||||
/// [0, GetVertexCount() - 1].
|
||||
///
|
||||
/// \param index Index of the vertex to get
|
||||
///
|
||||
/// \return Reference to the index-th vertex
|
||||
///
|
||||
/// \see GetVerticesCount
|
||||
/// \see GetVertexCount
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Vertex& operator [](unsigned int index);
|
||||
@ -89,13 +89,13 @@ public :
|
||||
/// \brief Get a read-only access to a vertex by its index
|
||||
///
|
||||
/// This function doesn't check \a index, it must be in range
|
||||
/// [0, GetVerticesCount() - 1].
|
||||
/// [0, GetVertexCount() - 1].
|
||||
///
|
||||
/// \param index Index of the vertex to get
|
||||
///
|
||||
/// \return Const reference to the index-th vertex
|
||||
///
|
||||
/// \see GetVerticesCount
|
||||
/// \see GetVertexCount
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
const Vertex& operator [](unsigned int index) const;
|
||||
@ -120,10 +120,10 @@ public :
|
||||
/// If \a count is less than the current size, existing vertices
|
||||
/// are removed from the array.
|
||||
///
|
||||
/// \param verticesCount New size of the array (number of vertices)
|
||||
/// \param vertexCount New size of the array (number of vertices)
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Resize(unsigned int verticesCount);
|
||||
void Resize(unsigned int vertexCount);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Add a vertex to the array
|
||||
|
@ -99,12 +99,12 @@ bool AudioDevice::IsExtensionSupported(const std::string& extension)
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
int AudioDevice::GetFormatFromChannelsCount(unsigned int channelsCount)
|
||||
int AudioDevice::GetFormatFromChannelCount(unsigned int channelCount)
|
||||
{
|
||||
EnsureALInit();
|
||||
|
||||
// Find the good format according to the number of channels
|
||||
switch (channelsCount)
|
||||
switch (channelCount)
|
||||
{
|
||||
case 1 : return AL_FORMAT_MONO16;
|
||||
case 2 : return AL_FORMAT_STEREO16;
|
||||
|
@ -75,12 +75,12 @@ public :
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the OpenAL format that matches the given number of channels
|
||||
///
|
||||
/// \param channelsCount Number of channels
|
||||
/// \param channelCount Number of channels
|
||||
///
|
||||
/// \return Corresponding format
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static int GetFormatFromChannelsCount(unsigned int channelsCount);
|
||||
static int GetFormatFromChannelCount(unsigned int channelCount);
|
||||
};
|
||||
|
||||
} // namespace priv
|
||||
|
@ -139,14 +139,14 @@ void Music::OnSeek(Uint32 timeOffset)
|
||||
void Music::Initialize()
|
||||
{
|
||||
// Compute the music duration
|
||||
Uint64 samples = myFile->GetSamplesCount();
|
||||
myDuration = static_cast<Uint32>(1000 * samples / myFile->GetSampleRate() / myFile->GetChannelsCount());
|
||||
Uint64 samples = myFile->GetSampleCount();
|
||||
myDuration = static_cast<Uint32>(1000 * samples / myFile->GetSampleRate() / myFile->GetChannelCount());
|
||||
|
||||
// Resize the internal buffer so that it can contain 1 second of audio samples
|
||||
mySamples.resize(myFile->GetSampleRate() * myFile->GetChannelsCount());
|
||||
mySamples.resize(myFile->GetSampleRate() * myFile->GetChannelCount());
|
||||
|
||||
// Initialize the stream
|
||||
SoundStream::Initialize(myFile->GetChannelsCount(), myFile->GetSampleRate());
|
||||
SoundStream::Initialize(myFile->GetChannelCount(), myFile->GetSampleRate());
|
||||
}
|
||||
|
||||
} // namespace sf
|
||||
|
@ -59,7 +59,7 @@ mySounds () // don't copy the attached sounds
|
||||
ALCheck(alGenBuffers(1, &myBuffer));
|
||||
|
||||
// Update the internal buffer with the new samples
|
||||
Update(copy.GetChannelsCount(), copy.GetSampleRate());
|
||||
Update(copy.GetChannelCount(), copy.GetSampleRate());
|
||||
}
|
||||
|
||||
|
||||
@ -110,24 +110,24 @@ bool SoundBuffer::LoadFromStream(InputStream& stream)
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
bool SoundBuffer::LoadFromSamples(const Int16* samples, std::size_t samplesCount, unsigned int channelsCount, unsigned int sampleRate)
|
||||
bool SoundBuffer::LoadFromSamples(const Int16* samples, std::size_t sampleCount, unsigned int channelCount, unsigned int sampleRate)
|
||||
{
|
||||
if (samples && samplesCount && channelsCount && sampleRate)
|
||||
if (samples && sampleCount && channelCount && sampleRate)
|
||||
{
|
||||
// Copy the new audio samples
|
||||
mySamples.assign(samples, samples + samplesCount);
|
||||
mySamples.assign(samples, samples + sampleCount);
|
||||
|
||||
// Update the internal buffer with the new samples
|
||||
return Update(channelsCount, sampleRate);
|
||||
return Update(channelCount, sampleRate);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Error...
|
||||
Err() << "Failed to load sound buffer from samples ("
|
||||
<< "array: " << samples << ", "
|
||||
<< "count: " << samplesCount << ", "
|
||||
<< "channels: " << channelsCount << ", "
|
||||
<< "samplerate: " << sampleRate << ")"
|
||||
<< "array: " << samples << ", "
|
||||
<< "count: " << sampleCount << ", "
|
||||
<< "channels: " << channelCount << ", "
|
||||
<< "samplerate: " << sampleRate << ")"
|
||||
<< std::endl;
|
||||
|
||||
return false;
|
||||
@ -140,7 +140,7 @@ bool SoundBuffer::SaveToFile(const std::string& filename) const
|
||||
{
|
||||
// Create the sound file in write mode
|
||||
priv::SoundFile file;
|
||||
if (file.OpenWrite(filename, GetChannelsCount(), GetSampleRate()))
|
||||
if (file.OpenWrite(filename, GetChannelCount(), GetSampleRate()))
|
||||
{
|
||||
// Write the samples to the opened file
|
||||
file.Write(&mySamples[0], mySamples.size());
|
||||
@ -162,7 +162,7 @@ const Int16* SoundBuffer::GetSamples() const
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
std::size_t SoundBuffer::GetSamplesCount() const
|
||||
std::size_t SoundBuffer::GetSampleCount() const
|
||||
{
|
||||
return mySamples.size();
|
||||
}
|
||||
@ -179,12 +179,12 @@ unsigned int SoundBuffer::GetSampleRate() const
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int SoundBuffer::GetChannelsCount() const
|
||||
unsigned int SoundBuffer::GetChannelCount() const
|
||||
{
|
||||
ALint channelsCount;
|
||||
ALCheck(alGetBufferi(myBuffer, AL_CHANNELS, &channelsCount));
|
||||
ALint channelCount;
|
||||
ALCheck(alGetBufferi(myBuffer, AL_CHANNELS, &channelCount));
|
||||
|
||||
return channelsCount;
|
||||
return channelCount;
|
||||
}
|
||||
|
||||
|
||||
@ -213,16 +213,16 @@ SoundBuffer& SoundBuffer::operator =(const SoundBuffer& right)
|
||||
bool SoundBuffer::Initialize(priv::SoundFile& file)
|
||||
{
|
||||
// Retrieve the sound parameters
|
||||
std::size_t nbSamples = file.GetSamplesCount();
|
||||
unsigned int channelsCount = file.GetChannelsCount();
|
||||
unsigned int sampleRate = file.GetSampleRate();
|
||||
std::size_t nbSamples = file.GetSampleCount();
|
||||
unsigned int channelCount = file.GetChannelCount();
|
||||
unsigned int sampleRate = file.GetSampleRate();
|
||||
|
||||
// Read the samples from the provided file
|
||||
mySamples.resize(nbSamples);
|
||||
if (file.Read(&mySamples[0], nbSamples) == nbSamples)
|
||||
{
|
||||
// Update the internal buffer with the new samples
|
||||
return Update(channelsCount, sampleRate);
|
||||
return Update(channelCount, sampleRate);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -232,19 +232,19 @@ bool SoundBuffer::Initialize(priv::SoundFile& file)
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
bool SoundBuffer::Update(unsigned int channelsCount, unsigned int sampleRate)
|
||||
bool SoundBuffer::Update(unsigned int channelCount, unsigned int sampleRate)
|
||||
{
|
||||
// Check parameters
|
||||
if (!channelsCount || !sampleRate || mySamples.empty())
|
||||
if (!channelCount || !sampleRate || mySamples.empty())
|
||||
return false;
|
||||
|
||||
// Find the good format according to the number of channels
|
||||
ALenum format = priv::AudioDevice::GetFormatFromChannelsCount(channelsCount);
|
||||
ALenum format = priv::AudioDevice::GetFormatFromChannelCount(channelCount);
|
||||
|
||||
// Check if the format is valid
|
||||
if (format == 0)
|
||||
{
|
||||
Err() << "Failed to load sound buffer (unsupported number of channels: " << channelsCount << ")" << std::endl;
|
||||
Err() << "Failed to load sound buffer (unsupported number of channels: " << channelCount << ")" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -253,7 +253,7 @@ bool SoundBuffer::Update(unsigned int channelsCount, unsigned int sampleRate)
|
||||
ALCheck(alBufferData(myBuffer, format, &mySamples[0], size, sampleRate));
|
||||
|
||||
// Compute the duration
|
||||
myDuration = static_cast<Uint32>(1000 * mySamples.size() / sampleRate / channelsCount);
|
||||
myDuration = static_cast<Uint32>(1000 * mySamples.size() / sampleRate / channelCount);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -43,9 +43,9 @@ bool SoundBufferRecorder::OnStart()
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
bool SoundBufferRecorder::OnProcessSamples(const Int16* samples, std::size_t samplesCount)
|
||||
bool SoundBufferRecorder::OnProcessSamples(const Int16* samples, std::size_t sampleCount)
|
||||
{
|
||||
std::copy(samples, samples + samplesCount, std::back_inserter(mySamples));
|
||||
std::copy(samples, samples + sampleCount, std::back_inserter(mySamples));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -53,10 +53,10 @@ namespace priv
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
SoundFile::SoundFile() :
|
||||
myFile (NULL),
|
||||
myNbSamples (0),
|
||||
myChannelsCount(0),
|
||||
mySampleRate (0)
|
||||
myFile (NULL),
|
||||
myNbSamples (0),
|
||||
myChannelCount(0),
|
||||
mySampleRate (0)
|
||||
{
|
||||
|
||||
}
|
||||
@ -71,16 +71,16 @@ SoundFile::~SoundFile()
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
std::size_t SoundFile::GetSamplesCount() const
|
||||
std::size_t SoundFile::GetSampleCount() const
|
||||
{
|
||||
return myNbSamples;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int SoundFile::GetChannelsCount() const
|
||||
unsigned int SoundFile::GetChannelCount() const
|
||||
{
|
||||
return myChannelsCount;
|
||||
return myChannelCount;
|
||||
}
|
||||
|
||||
|
||||
@ -108,9 +108,9 @@ bool SoundFile::OpenRead(const std::string& filename)
|
||||
}
|
||||
|
||||
// Set the sound parameters
|
||||
myChannelsCount = fileInfos.channels;
|
||||
mySampleRate = fileInfos.samplerate;
|
||||
myNbSamples = static_cast<std::size_t>(fileInfos.frames) * myChannelsCount;
|
||||
myChannelCount = fileInfos.channels;
|
||||
mySampleRate = fileInfos.samplerate;
|
||||
myNbSamples = static_cast<std::size_t>(fileInfos.frames) * myChannelCount;
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -145,9 +145,9 @@ bool SoundFile::OpenRead(const void* data, std::size_t sizeInBytes)
|
||||
}
|
||||
|
||||
// Set the sound parameters
|
||||
myChannelsCount = fileInfos.channels;
|
||||
mySampleRate = fileInfos.samplerate;
|
||||
myNbSamples = static_cast<std::size_t>(fileInfos.frames) * myChannelsCount;
|
||||
myChannelCount = fileInfos.channels;
|
||||
mySampleRate = fileInfos.samplerate;
|
||||
myNbSamples = static_cast<std::size_t>(fileInfos.frames) * myChannelCount;
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -177,16 +177,16 @@ bool SoundFile::OpenRead(InputStream& stream)
|
||||
}
|
||||
|
||||
// Set the sound parameters
|
||||
myChannelsCount = fileInfos.channels;
|
||||
mySampleRate = fileInfos.samplerate;
|
||||
myNbSamples = static_cast<std::size_t>(fileInfos.frames) * myChannelsCount;
|
||||
myChannelCount = fileInfos.channels;
|
||||
mySampleRate = fileInfos.samplerate;
|
||||
myNbSamples = static_cast<std::size_t>(fileInfos.frames) * myChannelCount;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
bool SoundFile::OpenWrite(const std::string& filename, unsigned int channelsCount, unsigned int sampleRate)
|
||||
bool SoundFile::OpenWrite(const std::string& filename, unsigned int channelCount, unsigned int sampleRate)
|
||||
{
|
||||
// If the file is already opened, first close it
|
||||
if (myFile)
|
||||
@ -203,7 +203,7 @@ bool SoundFile::OpenWrite(const std::string& filename, unsigned int channelsCoun
|
||||
|
||||
// Fill the sound infos with parameters
|
||||
SF_INFO fileInfos;
|
||||
fileInfos.channels = channelsCount;
|
||||
fileInfos.channels = channelCount;
|
||||
fileInfos.samplerate = sampleRate;
|
||||
fileInfos.format = format | (format == SF_FORMAT_OGG ? SF_FORMAT_VORBIS : SF_FORMAT_PCM_16);
|
||||
|
||||
@ -216,9 +216,9 @@ bool SoundFile::OpenWrite(const std::string& filename, unsigned int channelsCoun
|
||||
}
|
||||
|
||||
// Set the sound parameters
|
||||
myChannelsCount = channelsCount;
|
||||
mySampleRate = sampleRate;
|
||||
myNbSamples = 0;
|
||||
myChannelCount = channelCount;
|
||||
mySampleRate = sampleRate;
|
||||
myNbSamples = 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ public :
|
||||
/// \return Number of samples
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
std::size_t GetSamplesCount() const;
|
||||
std::size_t GetSampleCount() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the number of channels used by the sound
|
||||
@ -73,7 +73,7 @@ public :
|
||||
/// \return Number of channels (1 = mono, 2 = stereo)
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int GetChannelsCount() const;
|
||||
unsigned int GetChannelCount() const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the sample rate of the sound
|
||||
@ -117,19 +117,19 @@ public :
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief a the sound file for writing
|
||||
///
|
||||
/// \param filename Path of the sound file to write
|
||||
/// \param channelsCount Number of channels in the sound
|
||||
/// \param sampleRate Sample rate of the sound
|
||||
/// \param filename Path of the sound file to write
|
||||
/// \param channelCount Number of channels in the sound
|
||||
/// \param sampleRate Sample rate of the sound
|
||||
///
|
||||
/// \return True if the file was successfully opened
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool OpenWrite(const std::string& filename, unsigned int channelsCount, unsigned int sampleRate);
|
||||
bool OpenWrite(const std::string& filename, unsigned int channelCount, unsigned int sampleRate);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Read audio samples from the loaded sound
|
||||
///
|
||||
/// \param data Pointer to the samples array to fill
|
||||
/// \param data Pointer to the sample array to fill
|
||||
/// \param nbSamples Number of samples to read
|
||||
///
|
||||
/// \return Number of samples actually read (may be less than \a nbSamples)
|
||||
@ -140,7 +140,7 @@ public :
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Write audio samples to the file
|
||||
///
|
||||
/// \param data Pointer to the samples array to write
|
||||
/// \param data Pointer to the sample array to write
|
||||
/// \param nbSamples Number of samples to write
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
@ -198,11 +198,11 @@ private :
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
SNDFILE* myFile; ///< File descriptor
|
||||
Memory myMemory; ///< Memory reading info
|
||||
std::size_t myNbSamples; ///< Total number of samples in the file
|
||||
unsigned int myChannelsCount; ///< Number of channels used by the sound
|
||||
unsigned int mySampleRate; ///< Number of samples per second
|
||||
SNDFILE* myFile; ///< File descriptor
|
||||
Memory myMemory; ///< Memory reading info
|
||||
std::size_t myNbSamples; ///< Total number of samples in the file
|
||||
unsigned int myChannelCount; ///< Number of channels used by the sound
|
||||
unsigned int mySampleRate; ///< Number of samples per second
|
||||
};
|
||||
|
||||
} // namespace priv
|
||||
|
@ -42,7 +42,7 @@ namespace sf
|
||||
SoundStream::SoundStream() :
|
||||
myThread (&SoundStream::Stream, this),
|
||||
myIsStreaming (false),
|
||||
myChannelsCount (0),
|
||||
myChannelCount (0),
|
||||
mySampleRate (0),
|
||||
myFormat (0),
|
||||
myLoop (false),
|
||||
@ -61,20 +61,20 @@ SoundStream::~SoundStream()
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void SoundStream::Initialize(unsigned int channelsCount, unsigned int sampleRate)
|
||||
void SoundStream::Initialize(unsigned int channelCount, unsigned int sampleRate)
|
||||
{
|
||||
myChannelsCount = channelsCount;
|
||||
mySampleRate = sampleRate;
|
||||
myChannelCount = channelCount;
|
||||
mySampleRate = sampleRate;
|
||||
|
||||
// Deduce the format from the number of channels
|
||||
myFormat = priv::AudioDevice::GetFormatFromChannelsCount(channelsCount);
|
||||
myFormat = priv::AudioDevice::GetFormatFromChannelCount(channelCount);
|
||||
|
||||
// Check if the format is valid
|
||||
if (myFormat == 0)
|
||||
{
|
||||
myChannelsCount = 0;
|
||||
mySampleRate = 0;
|
||||
Err() << "Unsupported number of channels (" << myChannelsCount << ")" << std::endl;
|
||||
myChannelCount = 0;
|
||||
mySampleRate = 0;
|
||||
Err() << "Unsupported number of channels (" << myChannelCount << ")" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -123,9 +123,9 @@ void SoundStream::Stop()
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int SoundStream::GetChannelsCount() const
|
||||
unsigned int SoundStream::GetChannelCount() const
|
||||
{
|
||||
return myChannelsCount;
|
||||
return myChannelCount;
|
||||
}
|
||||
|
||||
|
||||
@ -159,7 +159,7 @@ void SoundStream::SetPlayingOffset(Uint32 timeOffset)
|
||||
OnSeek(timeOffset);
|
||||
|
||||
// Restart streaming
|
||||
mySamplesProcessed = static_cast<Uint64>(timeOffset) * mySampleRate * myChannelsCount / 1000;
|
||||
mySamplesProcessed = static_cast<Uint64>(timeOffset) * mySampleRate * myChannelCount / 1000;
|
||||
myIsStreaming = true;
|
||||
myThread.Launch();
|
||||
}
|
||||
@ -171,7 +171,7 @@ Uint32 SoundStream::GetPlayingOffset() const
|
||||
ALfloat seconds = 0.f;
|
||||
ALCheck(alGetSourcef(mySource, AL_SEC_OFFSET, &seconds));
|
||||
|
||||
return static_cast<Uint32>(1000 * seconds + 1000 * mySamplesProcessed / mySampleRate / myChannelsCount);
|
||||
return static_cast<Uint32>(1000 * seconds + 1000 * mySamplesProcessed / mySampleRate / myChannelCount);
|
||||
}
|
||||
|
||||
|
||||
@ -193,8 +193,8 @@ bool SoundStream::GetLoop() const
|
||||
void SoundStream::Stream()
|
||||
{
|
||||
// Create the buffers
|
||||
ALCheck(alGenBuffers(BuffersCount, myBuffers));
|
||||
for (int i = 0; i < BuffersCount; ++i)
|
||||
ALCheck(alGenBuffers(BufferCount, myBuffers));
|
||||
for (int i = 0; i < BufferCount; ++i)
|
||||
myEndBuffers[i] = false;
|
||||
|
||||
// Fill the queue
|
||||
@ -232,7 +232,7 @@ void SoundStream::Stream()
|
||||
|
||||
// Find its number
|
||||
unsigned int bufferNum = 0;
|
||||
for (int i = 0; i < BuffersCount; ++i)
|
||||
for (int i = 0; i < BufferCount; ++i)
|
||||
if (myBuffers[i] == buffer)
|
||||
{
|
||||
bufferNum = i;
|
||||
@ -275,7 +275,7 @@ void SoundStream::Stream()
|
||||
|
||||
// Delete the buffers
|
||||
ALCheck(alSourcei(mySource, AL_BUFFER, 0));
|
||||
ALCheck(alDeleteBuffers(BuffersCount, myBuffers));
|
||||
ALCheck(alDeleteBuffers(BufferCount, myBuffers));
|
||||
}
|
||||
|
||||
|
||||
@ -332,7 +332,7 @@ bool SoundStream::FillQueue()
|
||||
{
|
||||
// Fill and enqueue all the available buffers
|
||||
bool requestStop = false;
|
||||
for (int i = 0; (i < BuffersCount) && !requestStop; ++i)
|
||||
for (int i = 0; (i < BufferCount) && !requestStop; ++i)
|
||||
{
|
||||
if (FillAndPushBuffer(i))
|
||||
requestStop = true;
|
||||
|
@ -32,9 +32,9 @@
|
||||
namespace sf
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
CircleShape::CircleShape(float radius, unsigned int pointsCount) :
|
||||
myRadius (radius),
|
||||
myPointsCount(pointsCount)
|
||||
CircleShape::CircleShape(float radius, unsigned int pointCount) :
|
||||
myRadius (radius),
|
||||
myPointCount(pointCount)
|
||||
{
|
||||
Update();
|
||||
}
|
||||
@ -56,16 +56,16 @@ float CircleShape::GetRadius() const
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void CircleShape::SetPointsCount(unsigned int count)
|
||||
void CircleShape::SetPointCount(unsigned int count)
|
||||
{
|
||||
myPointsCount = count;
|
||||
myPointCount = count;
|
||||
Update();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int CircleShape::GetPointsCount() const
|
||||
unsigned int CircleShape::GetPointCount() const
|
||||
{
|
||||
return myPointsCount;
|
||||
return myPointCount;
|
||||
}
|
||||
|
||||
|
||||
@ -74,7 +74,7 @@ Vector2f CircleShape::GetPoint(unsigned int index) const
|
||||
{
|
||||
static const float pi = 3.141592654f;
|
||||
|
||||
float angle = index * 2 * pi / myPointsCount - pi / 2;
|
||||
float angle = index * 2 * pi / myPointCount - pi / 2;
|
||||
float x = std::cos(angle) * myRadius;
|
||||
float y = std::sin(angle) * myRadius;
|
||||
|
||||
|
@ -31,14 +31,14 @@
|
||||
namespace sf
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
ConvexShape::ConvexShape(unsigned int pointsCount)
|
||||
ConvexShape::ConvexShape(unsigned int pointCount)
|
||||
{
|
||||
SetPointsCount(pointsCount);
|
||||
SetPointCount(pointCount);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void ConvexShape::SetPointsCount(unsigned int count)
|
||||
void ConvexShape::SetPointCount(unsigned int count)
|
||||
{
|
||||
myPoints.resize(count);
|
||||
Update();
|
||||
@ -46,7 +46,7 @@ void ConvexShape::SetPointsCount(unsigned int count)
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int ConvexShape::GetPointsCount() const
|
||||
unsigned int ConvexShape::GetPointCount() const
|
||||
{
|
||||
return myPoints.size();
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ const Vector2f& RectangleShape::GetSize() const
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int RectangleShape::GetPointsCount() const
|
||||
unsigned int RectangleShape::GetPointCount() const
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
@ -127,21 +127,21 @@ void RenderTarget::Draw(const Drawable& drawable, const RenderStates& states)
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void RenderTarget::Draw(const Vertex* vertices, unsigned int verticesCount,
|
||||
void RenderTarget::Draw(const Vertex* vertices, unsigned int vertexCount,
|
||||
PrimitiveType type, const RenderStates& states)
|
||||
{
|
||||
// Nothing to draw?
|
||||
if (!vertices || (verticesCount == 0))
|
||||
if (!vertices || (vertexCount == 0))
|
||||
return;
|
||||
|
||||
if (Activate(true))
|
||||
{
|
||||
// Check if the vertex count is low enough so that we can pre-transform them
|
||||
bool useVertexCache = (verticesCount <= StatesCache::VertexCacheSize);
|
||||
bool useVertexCache = (vertexCount <= StatesCache::VertexCacheSize);
|
||||
if (useVertexCache)
|
||||
{
|
||||
// Pre-transform the vertices and store them into the vertex cache
|
||||
for (unsigned int i = 0; i < verticesCount; ++i)
|
||||
for (unsigned int i = 0; i < vertexCount; ++i)
|
||||
{
|
||||
Vertex& vertex = myCache.VertexCache[i];
|
||||
vertex.Position = states.Transform * vertices[i].Position;
|
||||
@ -200,7 +200,7 @@ void RenderTarget::Draw(const Vertex* vertices, unsigned int verticesCount,
|
||||
GLenum mode = modes[type];
|
||||
|
||||
// Draw the primitives
|
||||
GLCheck(glDrawArrays(mode, 0, verticesCount));
|
||||
GLCheck(glDrawArrays(mode, 0, vertexCount));
|
||||
|
||||
// Unbind the shader, if any
|
||||
if (states.Shader)
|
||||
|
@ -169,7 +169,7 @@ myBounds ()
|
||||
void Shape::Update()
|
||||
{
|
||||
// Get the total number of points of the shape
|
||||
unsigned int count = GetPointsCount();
|
||||
unsigned int count = GetPointCount();
|
||||
if (count < 3)
|
||||
{
|
||||
myVertices.Resize(0);
|
||||
@ -227,7 +227,7 @@ void Shape::Draw(RenderTarget& target, RenderStates states) const
|
||||
////////////////////////////////////////////////////////////
|
||||
void Shape::UpdateFillColors()
|
||||
{
|
||||
for (unsigned int i = 0; i < myVertices.GetVerticesCount(); ++i)
|
||||
for (unsigned int i = 0; i < myVertices.GetVertexCount(); ++i)
|
||||
myVertices[i].Color = myFillColor;
|
||||
}
|
||||
|
||||
@ -235,7 +235,7 @@ void Shape::UpdateFillColors()
|
||||
////////////////////////////////////////////////////////////
|
||||
void Shape::UpdateTexCoords()
|
||||
{
|
||||
for (unsigned int i = 0; i < myVertices.GetVerticesCount(); ++i)
|
||||
for (unsigned int i = 0; i < myVertices.GetVertexCount(); ++i)
|
||||
{
|
||||
float xratio = (myVertices[i].Position.x - myInsideBounds.Left) / myInsideBounds.Width;
|
||||
float yratio = (myVertices[i].Position.y - myInsideBounds.Top) / myInsideBounds.Height;
|
||||
@ -248,7 +248,7 @@ void Shape::UpdateTexCoords()
|
||||
////////////////////////////////////////////////////////////
|
||||
void Shape::UpdateOutline()
|
||||
{
|
||||
unsigned int count = myVertices.GetVerticesCount() - 2;
|
||||
unsigned int count = myVertices.GetVertexCount() - 2;
|
||||
myOutlineVertices.Resize((count + 1) * 2);
|
||||
|
||||
for (unsigned int i = 0; i < count; ++i)
|
||||
@ -288,7 +288,7 @@ void Shape::UpdateOutline()
|
||||
////////////////////////////////////////////////////////////
|
||||
void Shape::UpdateOutlineColors()
|
||||
{
|
||||
for (unsigned int i = 0; i < myOutlineVertices.GetVerticesCount(); ++i)
|
||||
for (unsigned int i = 0; i < myOutlineVertices.GetVertexCount(); ++i)
|
||||
myOutlineVertices[i].Color = myOutlineColor;
|
||||
}
|
||||
|
||||
|
@ -106,7 +106,7 @@ void Text::SetColor(const Color& color)
|
||||
if (color != myColor)
|
||||
{
|
||||
myColor = color;
|
||||
for (unsigned int i = 0; i < myVertices.GetVerticesCount(); ++i)
|
||||
for (unsigned int i = 0; i < myVertices.GetVertexCount(); ++i)
|
||||
myVertices[i].Color = myColor;
|
||||
}
|
||||
}
|
||||
|
@ -40,15 +40,15 @@ myPrimitiveType(Points)
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
VertexArray::VertexArray(PrimitiveType type, unsigned int verticesCount) :
|
||||
myVertices (verticesCount),
|
||||
VertexArray::VertexArray(PrimitiveType type, unsigned int vertexCount) :
|
||||
myVertices (vertexCount),
|
||||
myPrimitiveType(type)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
unsigned int VertexArray::GetVerticesCount() const
|
||||
unsigned int VertexArray::GetVertexCount() const
|
||||
{
|
||||
return myVertices.size();
|
||||
}
|
||||
@ -76,9 +76,9 @@ void VertexArray::Clear()
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void VertexArray::Resize(unsigned int verticesCount)
|
||||
void VertexArray::Resize(unsigned int vertexCount)
|
||||
{
|
||||
myVertices.resize(verticesCount);
|
||||
myVertices.resize(vertexCount);
|
||||
}
|
||||
|
||||
|
||||
|
@ -290,7 +290,7 @@ void WindowImplWin32::SetIcon(unsigned int width, unsigned int height, const Uin
|
||||
iconPixels[i * 4 + 3] = pixels[i * 4 + 3];
|
||||
}
|
||||
|
||||
// Create the icon from the pixels array
|
||||
// Create the icon from the pixel array
|
||||
myIcon = CreateIcon(GetModuleHandle(NULL), width, height, 1, 32, NULL, &iconPixels[0]);
|
||||
|
||||
// Set it as both big and small icon of the window
|
||||
|
Loading…
Reference in New Issue
Block a user