Updated to the new graphics API

This commit is contained in:
Laurent Gomila committed 2012-01-29 11:29:09 +01:00
1 parent 06997db9e8
commit 44670984af
51 files changed
+4607 -2573

No files matched your search

+2 -2
View File
@@ -125,9 +125,9 @@ void sfMusic_Stop(sfMusic* music)
////////////////////////////////////////////////////////////
unsigned int sfMusic_GetChannelsCount(const sfMusic* music)
unsigned int sfMusic_GetChannelCount(const sfMusic* music)
{
CSFML_CALL_RETURN(music, GetChannelsCount(), 0);
CSFML_CALL_RETURN(music, GetChannelCount(), 0);
}
+6 -6
View File
@@ -80,11 +80,11 @@ CSFML_API sfSoundBuffer* sfSoundBuffer_CreateFromStream(sfInputStream* stream)
////////////////////////////////////////////////////////////
sfSoundBuffer* sfSoundBuffer_CreateFromSamples(const sfInt16* samples, size_t samplesCount, unsigned int channelsCount, unsigned int sampleRate)
sfSoundBuffer* sfSoundBuffer_CreateFromSamples(const sfInt16* samples, size_t sampleCount, unsigned int channelsCount, unsigned int sampleRate)
{
sfSoundBuffer* buffer = new sfSoundBuffer;
if (!buffer->This.LoadFromSamples(samples, samplesCount, channelsCount, sampleRate))
if (!buffer->This.LoadFromSamples(samples, sampleCount, channelsCount, sampleRate))
{
delete buffer;
buffer = NULL;
@@ -125,9 +125,9 @@ const sfInt16* sfSoundBuffer_GetSamples(const sfSoundBuffer* soundBuffer)
////////////////////////////////////////////////////////////
size_t sfSoundBuffer_GetSamplesCount(const sfSoundBuffer* soundBuffer)
size_t sfSoundBuffer_GetSampleCount(const sfSoundBuffer* soundBuffer)
{
CSFML_CALL_RETURN(soundBuffer, GetSamplesCount(), 0)
CSFML_CALL_RETURN(soundBuffer, GetSampleCount(), 0)
}
@@ -139,9 +139,9 @@ unsigned int sfSoundBuffer_GetSampleRate(const sfSoundBuffer* soundBuffer)
////////////////////////////////////////////////////////////
unsigned int sfSoundBuffer_GetChannelsCount(const sfSoundBuffer* soundBuffer)
unsigned int sfSoundBuffer_GetChannelCount(const sfSoundBuffer* soundBuffer)
{
CSFML_CALL_RETURN(soundBuffer, GetChannelsCount(), 0)
CSFML_CALL_RETURN(soundBuffer, GetChannelCount(), 0)
}
+15 -15
View File
@@ -40,14 +40,14 @@ class sfSoundRecorderImpl : public sf::SoundRecorder
{
public :
sfSoundRecorderImpl(sfSoundRecorderStartCallback OnStart,
sfSoundRecorderProcessCallback OnProcess,
sfSoundRecorderStopCallback OnStop,
void* UserData) :
myStartCallback (OnStart),
myProcessCallback(OnProcess),
myStopCallback (OnStop),
myUserData (UserData)
sfSoundRecorderImpl(sfSoundRecorderStartCallback onStart,
sfSoundRecorderProcessCallback onProcess,
sfSoundRecorderStopCallback onStop,
void* userData) :
myStartCallback (onStart),
myProcessCallback(onProcess),
myStopCallback (onStop),
myUserData (userData)
{
}
@@ -61,10 +61,10 @@ private :
return true;
}
virtual bool OnProcessSamples(const sf::Int16* Samples, std::size_t SamplesCount)
virtual bool OnProcessSamples(const sf::Int16* samples, std::size_t sampleCount)
{
if (myProcessCallback)
return myProcessCallback(Samples, SamplesCount, myUserData) == sfTrue;
return myProcessCallback(samples, sampleCount, myUserData) == sfTrue;
else
return true;
}
@@ -87,11 +87,11 @@ private :
////////////////////////////////////////////////////////////
struct sfSoundRecorder
{
sfSoundRecorder(sfSoundRecorderStartCallback OnStart,
sfSoundRecorderProcessCallback OnProcess,
sfSoundRecorderStopCallback OnStop,
void* UserData) :
This(OnStart, OnProcess, OnStop, UserData)
sfSoundRecorder(sfSoundRecorderStartCallback onStart,
sfSoundRecorderProcessCallback onProcess,
sfSoundRecorderStopCallback onStop,
void* userData) :
This(onStart, onProcess, onStop, userData)
{
}
+4 -4
View File
@@ -33,11 +33,11 @@
////////////////////////////////////////////////////////////
sfSoundStream* sfSoundStream_Create(sfSoundStreamGetDataCallback onGetData,
sfSoundStreamSeekCallback onSeek,
unsigned int channelsCount,
unsigned int channelCount,
unsigned int sampleRate,
void* userData)
{
return new sfSoundStream(onGetData, onSeek, channelsCount, sampleRate, userData);
return new sfSoundStream(onGetData, onSeek, channelCount, sampleRate, userData);
}
@@ -79,9 +79,9 @@ sfSoundStatus sfSoundStream_GetStatus(const sfSoundStream* soundStream)
////////////////////////////////////////////////////////////
unsigned int sfSoundStream_GetChannelsCount(const sfSoundStream* soundStream)
unsigned int sfSoundStream_GetChannelCount(const sfSoundStream* soundStream)
{
CSFML_CALL_RETURN(soundStream, GetChannelsCount(), 0);
CSFML_CALL_RETURN(soundStream, GetChannelCount(), 0);
}
+23 -23
View File
@@ -39,35 +39,35 @@ class sfSoundStreamImpl : public sf::SoundStream
{
public :
sfSoundStreamImpl(sfSoundStreamGetDataCallback OnGetData,
sfSoundStreamSeekCallback OnSeek,
unsigned int ChannelsCount,
unsigned int SampleRate,
void* UserData) :
myGetDataCallback(OnGetData),
mySeekCallback (OnSeek),
myUserData (UserData)
sfSoundStreamImpl(sfSoundStreamGetDataCallback onGetData,
sfSoundStreamSeekCallback onSeek,
unsigned int channelCount,
unsigned int sampleRate,
void* userData) :
myGetDataCallback(onGetData),
mySeekCallback (onSeek),
myUserData (userData)
{
Initialize(ChannelsCount, SampleRate);
Initialize(channelCount, sampleRate);
}
private :
virtual bool OnGetData(Chunk& Data)
virtual bool OnGetData(Chunk& data)
{
sfSoundStreamChunk Chunk = {NULL, 0};
bool Continue = (myGetDataCallback(&Chunk, myUserData) == sfTrue);
sfSoundStreamChunk chunk = {NULL, 0};
bool ok = (myGetDataCallback(&chunk, myUserData) == sfTrue);
Data.Samples = Chunk.Samples;
Data.NbSamples = Chunk.NbSamples;
data.Samples = chunk.Samples;
data.SampleCount = chunk.SampleCount;
return Continue;
return ok;
}
virtual void OnSeek(sfUint32 TimeOffset)
virtual void OnSeek(sfUint32 timeOffset)
{
if (mySeekCallback)
mySeekCallback(TimeOffset, myUserData);
mySeekCallback(timeOffset, myUserData);
}
sfSoundStreamGetDataCallback myGetDataCallback;
@@ -81,12 +81,12 @@ private :
////////////////////////////////////////////////////////////
struct sfSoundStream
{
sfSoundStream(sfSoundStreamGetDataCallback OnGetData,
sfSoundStreamSeekCallback OnSeek,
unsigned int ChannelsCount,
unsigned int SampleRate,
void* UserData) :
This(OnGetData, OnSeek, ChannelsCount, SampleRate, UserData)
sfSoundStream(sfSoundStreamGetDataCallback onGetData,
sfSoundStreamSeekCallback onSeek,
unsigned int channelCount,
unsigned int sampleRate,
void* userData) :
This(onGetData, onSeek, channelCount, sampleRate, userData)
{
}
+17 -3
View File
@@ -5,8 +5,15 @@ set(SRCROOT ${CMAKE_SOURCE_DIR}/src/SFML/Graphics)
# all source files
set(SRC
${INCROOT}/BlendMode.h
${SRCROOT}/CircleShape.cpp
${SRCROOT}/CircleShapeStruct.h
${INCROOT}/CircleShape.h
${SRCROOT}/Color.cpp
${INCROOT}/Color.h
${SRCROOT}/ConvertRenderStates.hpp
${SRCROOT}/ConvexShape.cpp
${SRCROOT}/ConvexShapeStruct.h
${INCROOT}/ConvexShape.h
${SRCROOT}/Font.cpp
${SRCROOT}/FontStruct.h
${INCROOT}/Font.h
@@ -16,6 +23,9 @@ set(SRC
${INCROOT}/Image.h
${SRCROOT}/Rect.cpp
${INCROOT}/Rect.h
${SRCROOT}/RectangleShape.cpp
${SRCROOT}/RectangleShapeStruct.h
${INCROOT}/RectangleShape.h
${SRCROOT}/RenderTexture.cpp
${SRCROOT}/RenderTextureStruct.h
${INCROOT}/RenderTexture.h
@@ -25,9 +35,6 @@ set(SRC
${SRCROOT}/Shader.cpp
${SRCROOT}/ShaderStruct.h
${INCROOT}/Shader.h
${SRCROOT}/Shape.cpp
${SRCROOT}/ShapeStruct.h
${INCROOT}/Shape.h
${SRCROOT}/Sprite.cpp
${SRCROOT}/SpriteStruct.h
${INCROOT}/Sprite.h
@@ -37,7 +44,14 @@ set(SRC
${SRCROOT}/Texture.cpp
${SRCROOT}/TextureStruct.h
${INCROOT}/Texture.h
${SRCROOT}/Transform.cpp
${SRCROOT}/TransformStruct.h
${INCROOT}/Transform.h
${INCROOT}/Types.h
${INCROOT}/Vertex.h
${SRCROOT}/VertexArray.cpp
${SRCROOT}/VertexArrayStruct.h
${INCROOT}/VertexArray.h
${SRCROOT}/View.cpp
${SRCROOT}/ViewStruct.h
${INCROOT}/View.h
+316
View File
@@ -0,0 +1,316 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// 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.
//
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics/CircleShape.h>
#include <SFML/Graphics/CircleShapeStruct.h>
#include <SFML/Graphics/Color.hpp>
#include <SFML/Internal.h>
////////////////////////////////////////////////////////////
sfCircleShape* sfCircleShape_Create(void)
{
sfCircleShape* shape = new sfCircleShape;
shape->Texture = NULL;
return shape;
}
////////////////////////////////////////////////////////////
sfCircleShape* sfCircleShape_Copy(sfCircleShape* shape)
{
CSFML_CHECK_RETURN(shape, NULL);
return new sfCircleShape(*shape);
}
////////////////////////////////////////////////////////////
void sfCircleShape_Destroy(sfCircleShape* shape)
{
delete shape;
}
////////////////////////////////////////////////////////////
void sfCircleShape_SetPosition(sfCircleShape* shape, float x, float y)
{
CSFML_CALL(shape, SetPosition(x, y));
}
////////////////////////////////////////////////////////////
void sfCircleShape_SetRotation(sfCircleShape* shape, float angle)
{
CSFML_CALL(shape, SetRotation(angle));
}
////////////////////////////////////////////////////////////
void sfCircleShape_SetScale(sfCircleShape* shape, float factorX, float factorY)
{
CSFML_CALL(shape, SetScale(factorX, factorY));
}
////////////////////////////////////////////////////////////
void sfCircleShape_SetOrigin(sfCircleShape* shape, float x, float y)
{
CSFML_CALL(shape, SetOrigin(x, y));
}
////////////////////////////////////////////////////////////
void sfCircleShape_GetPosition(const sfCircleShape* shape, float* x, float* y)
{
CSFML_CHECK(shape);
sf::Vector2f point = shape->This.GetPosition();
if (x)
*x = point.x;
if (y)
*y = point.y;
}
////////////////////////////////////////////////////////////
float sfCircleShape_GetRotation(const sfCircleShape* shape)
{
CSFML_CALL_RETURN(shape, GetRotation(), 0.f);
}
////////////////////////////////////////////////////////////
void sfCircleShape_GetScale(const sfCircleShape* shape, float* x, float* y)
{
CSFML_CHECK(shape);
sf::Vector2f point = shape->This.GetScale();
if (x)
*x = point.x;
if (y)
*y = point.y;
}
////////////////////////////////////////////////////////////
void sfCircleShape_GetOrigin(const sfCircleShape* shape, float* x, float* y)
{
CSFML_CHECK(shape);
sf::Vector2f point = shape->This.GetOrigin();
if (x)
*x = point.x;
if (y)
*y = point.y;
}
////////////////////////////////////////////////////////////
void sfCircleShape_Move(sfCircleShape* shape, float offsetX, float offsetY)
{
CSFML_CALL(shape, Move(offsetX, offsetY));
}
////////////////////////////////////////////////////////////
void sfCircleShape_Rotate(sfCircleShape* shape, float angle)
{
CSFML_CALL(shape, Rotate(angle));
}
////////////////////////////////////////////////////////////
void sfCircleShape_Scale(sfCircleShape* shape, float factorX, float factorY)
{
CSFML_CALL(shape, Scale(factorX, factorY));
}
////////////////////////////////////////////////////////////
const sfTransform* sfCircleShape_GetTransform(const sfCircleShape* shape)
{
CSFML_CHECK_RETURN(shape, NULL);
shape->Transform.This = shape->This.GetTransform();
return &shape->Transform;
}
////////////////////////////////////////////////////////////
const sfTransform* sfCircleShape_GetInverseTransform(const sfCircleShape* shape)
{
CSFML_CHECK_RETURN(shape, NULL);
shape->InverseTransform.This = shape->This.GetInverseTransform();
return &shape->InverseTransform;
}
////////////////////////////////////////////////////////////
void sfCircleShape_SetTexture(sfCircleShape* shape, const sfTexture* texture, sfBool resetRect)
{
CSFML_CALL(shape, SetTexture(texture ? texture->This : NULL, resetRect == sfTrue))
shape->Texture = texture;
}
////////////////////////////////////////////////////////////
void sfCircleShape_SetTextureRect(sfCircleShape* shape, sfIntRect rect)
{
CSFML_CALL(shape, SetTextureRect(sf::IntRect(rect.Left, rect.Top, rect.Width, rect.Height)))
}
////////////////////////////////////////////////////////////
void sfCircleShape_SetFillColor(sfCircleShape* shape, sfColor color)
{
CSFML_CALL(shape, SetFillColor(sf::Color(color.r, color.g, color.b, color.a)));
}
////////////////////////////////////////////////////////////
void sfCircleShape_SetOutlineColor(sfCircleShape* shape, sfColor color)
{
CSFML_CALL(shape, SetOutlineColor(sf::Color(color.r, color.g, color.b, color.a)));
}
////////////////////////////////////////////////////////////
void sfCircleShape_SetOutlineThickness(sfCircleShape* shape, float thickness)
{
CSFML_CALL(shape, SetOutlineThickness(thickness));
}
////////////////////////////////////////////////////////////
const sfTexture* sfCircleShape_GetTexture(const sfCircleShape* shape)
{
CSFML_CHECK_RETURN(shape, NULL)
return shape->Texture;
}
////////////////////////////////////////////////////////////
sfIntRect sfCircleShape_GetTextureRect(const sfCircleShape* shape)
{
sfIntRect rect = {0, 0, 0, 0};
CSFML_CHECK_RETURN(sprite, rect)
sf::IntRect sfmlRect = shape->This.GetTextureRect();
rect.Left = sfmlRect.Left;
rect.Top = sfmlRect.Top;
rect.Width = sfmlRect.Width;
rect.Height = sfmlRect.Height;
return rect;
}
////////////////////////////////////////////////////////////
sfColor sfCircleShape_GetFillColor(const sfCircleShape* shape)
{
sfColor color = {0, 0, 0, 0};
CSFML_CHECK_RETURN(shape, color);
sf::Color sfmlColor = shape->This.GetFillColor();
color.r = sfmlColor.r;
color.g = sfmlColor.g;
color.b = sfmlColor.b;
color.a = sfmlColor.a;
return color;
}
////////////////////////////////////////////////////////////
sfColor sfCircleShape_GetOutlineColor(const sfCircleShape* shape)
{
sfColor color = {0, 0, 0, 0};
CSFML_CHECK_RETURN(shape, color);
sf::Color sfmlColor = shape->This.GetOutlineColor();
color.r = sfmlColor.r;
color.g = sfmlColor.g;
color.b = sfmlColor.b;
color.a = sfmlColor.a;
return color;
}
////////////////////////////////////////////////////////////
float sfCircleShape_GetOutlineThickness(const sfCircleShape* shape)
{
CSFML_CALL_RETURN(shape, GetOutlineThickness(), 0.f);
}
////////////////////////////////////////////////////////////
unsigned int sfCircleShape_GetPointCount(const sfCircleShape* shape)
{
CSFML_CALL_RETURN(shape, GetPointCount(), 0);
}
////////////////////////////////////////////////////////////
void sfCircleShape_GetPoint(const sfCircleShape* shape, unsigned int index, float* x, float* y)
{
CSFML_CHECK(shape);
sf::Vector2f point = shape->This.GetPoint(index);
if (x)
*x = point.x;
if (y)
*y = point.y;
}
////////////////////////////////////////////////////////////
void sfCircleShape_SetRadius(sfCircleShape* shape, float radius)
{
CSFML_CALL(shape, SetRadius(radius));
}
////////////////////////////////////////////////////////////
float sfCircleShape_GetRadius(const sfCircleShape* shape)
{
CSFML_CALL_RETURN(shape, GetRadius(), 0.f);
}
////////////////////////////////////////////////////////////
void sfCircleShape_SetPointCount(sfCircleShape* shape, unsigned int count)
{
CSFML_CALL(shape, SetPointCount(count));
}
+48
View File
@@ -0,0 +1,48 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// 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 SFML_CIRCLESHAPESTRUCT_H
#define SFML_CIRCLESHAPESTRUCT_H
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics/CircleShape.hpp>
#include <SFML/Graphics/TextureStruct.h>
#include <SFML/Graphics/TransformStruct.h>
////////////////////////////////////////////////////////////
// Internal structure of sfCircleShape
////////////////////////////////////////////////////////////
struct sfCircleShape
{
sf::CircleShape This;
const sfTexture* Texture;
mutable sfTransform Transform;
mutable sfTransform InverseTransform;
};
#endif // SFML_CIRCLESHAPESTRUCT_H
+60
View File
@@ -0,0 +1,60 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// 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 SFML_CONVERTRENDERSTATES_H
#define SFML_CONVERTRENDERSTATES_H
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics/RenderStates.h>
#include <SFML/Graphics/RenderStates.hpp>
#include <SFML/Graphics/TransformStruct.h>
#include <SFML/Graphics/TextureStruct.h>
#include <SFML/Graphics/ShaderStruct.h>
////////////////////////////////////////////////////////////
// Convert sfRenderStates* to sf::RenderStates
////////////////////////////////////////////////////////////
inline sf::RenderStates ConvertRenderStates(const sfRenderStates* states)
{
if (!states)
{
return sf::RenderStates::Default;
}
else
{
sf::RenderStates sfmlStates;
sfmlStates.BlendMode = static_cast<sf::BlendMode>(states->BlendMode);
sfmlStates.Transform = states->Transform ? states->Transform->This : sf::Transform::Identity;
sfmlStates.Texture = states->Texture ? states->Texture->This : NULL;
sfmlStates.Shader = states->Shader ? &states->Shader->This : NULL;
return sfmlStates;
}
}
#endif // SFML_CONVERTRENDERSTATES_H
+306
View File
@@ -0,0 +1,306 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// 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.
//
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics/ConvexShape.h>
#include <SFML/Graphics/ConvexShapeStruct.h>
#include <SFML/Graphics/Color.hpp>
#include <SFML/Internal.h>
////////////////////////////////////////////////////////////
sfConvexShape* sfConvexShape_Create(void)
{
return new sfConvexShape;
}
////////////////////////////////////////////////////////////
sfConvexShape* sfConvexShape_Copy(sfConvexShape* shape)
{
CSFML_CHECK_RETURN(shape, NULL);
return new sfConvexShape(*shape);
}
////////////////////////////////////////////////////////////
void sfConvexShape_Destroy(sfConvexShape* shape)
{
delete shape;
}
////////////////////////////////////////////////////////////
void sfConvexShape_SetPosition(sfConvexShape* shape, float x, float y)
{
CSFML_CALL(shape, SetPosition(x, y));
}
////////////////////////////////////////////////////////////
void sfConvexShape_SetRotation(sfConvexShape* shape, float angle)
{
CSFML_CALL(shape, SetRotation(angle));
}
////////////////////////////////////////////////////////////
void sfConvexShape_SetScale(sfConvexShape* shape, float factorX, float factorY)
{
CSFML_CALL(shape, SetScale(factorX, factorY));
}
////////////////////////////////////////////////////////////
void sfConvexShape_SetOrigin(sfConvexShape* shape, float x, float y)
{
CSFML_CALL(shape, SetOrigin(x, y));
}
////////////////////////////////////////////////////////////
void sfConvexShape_GetPosition(const sfConvexShape* shape, float* x, float* y)
{
CSFML_CHECK(shape);
sf::Vector2f point = shape->This.GetPosition();
if (x)
*x = point.x;
if (y)
*y = point.y;
}
////////////////////////////////////////////////////////////
float sfConvexShape_GetRotation(const sfConvexShape* shape)
{
CSFML_CALL_RETURN(shape, GetRotation(), 0.f);
}
////////////////////////////////////////////////////////////
void sfConvexShape_GetScale(const sfConvexShape* shape, float* x, float* y)
{
CSFML_CHECK(shape);
sf::Vector2f point = shape->This.GetScale();
if (x)
*x = point.x;
if (y)
*y = point.y;
}
////////////////////////////////////////////////////////////
void sfConvexShape_GetOrigin(const sfConvexShape* shape, float* x, float* y)
{
CSFML_CHECK(shape);
sf::Vector2f point = shape->This.GetOrigin();
if (x)
*x = point.x;
if (y)
*y = point.y;
}
////////////////////////////////////////////////////////////
void sfConvexShape_Move(sfConvexShape* shape, float offsetX, float offsetY)
{
CSFML_CALL(shape, Move(offsetX, offsetY));
}
////////////////////////////////////////////////////////////
void sfConvexShape_Rotate(sfConvexShape* shape, float angle)
{
CSFML_CALL(shape, Rotate(angle));
}
////////////////////////////////////////////////////////////
void sfConvexShape_Scale(sfConvexShape* shape, float factorX, float factorY)
{
CSFML_CALL(shape, Scale(factorX, factorY));
}
////////////////////////////////////////////////////////////
const sfTransform* sfConvexShape_GetTransform(const sfConvexShape* shape)
{
CSFML_CHECK_RETURN(shape, NULL);
shape->Transform.This = shape->This.GetTransform();
return &shape->Transform;
}
////////////////////////////////////////////////////////////
const sfTransform* sfConvexShape_GetInverseTransform(const sfConvexShape* shape)
{
CSFML_CHECK_RETURN(shape, NULL);
shape->InverseTransform.This = shape->This.GetInverseTransform();
return &shape->InverseTransform;
}
////////////////////////////////////////////////////////////
void sfConvexShape_SetTexture(sfConvexShape* shape, const sfTexture* texture, sfBool resetRect)
{
CSFML_CALL(shape, SetTexture(texture ? texture->This : NULL, resetRect == sfTrue))
shape->Texture = texture;
}
////////////////////////////////////////////////////////////
void sfConvexShape_SetTextureRect(sfConvexShape* shape, sfIntRect rect)
{
CSFML_CALL(shape, SetTextureRect(sf::IntRect(rect.Left, rect.Top, rect.Width, rect.Height)))
}
////////////////////////////////////////////////////////////
void sfConvexShape_SetFillColor(sfConvexShape* shape, sfColor color)
{
CSFML_CALL(shape, SetFillColor(sf::Color(color.r, color.g, color.b, color.a)));
}
////////////////////////////////////////////////////////////
void sfConvexShape_SetOutlineColor(sfConvexShape* shape, sfColor color)
{
CSFML_CALL(shape, SetOutlineColor(sf::Color(color.r, color.g, color.b, color.a)));
}
////////////////////////////////////////////////////////////
void sfConvexShape_SetOutlineThickness(sfConvexShape* shape, float thickness)
{
CSFML_CALL(shape, SetOutlineThickness(thickness));
}
////////////////////////////////////////////////////////////
const sfTexture* sfConvexShape_GetTexture(const sfConvexShape* shape)
{
CSFML_CHECK_RETURN(shape, NULL)
return shape->Texture;
}
////////////////////////////////////////////////////////////
sfIntRect sfConvexShape_GetTextureRect(const sfConvexShape* shape)
{
sfIntRect rect = {0, 0, 0, 0};
CSFML_CHECK_RETURN(sprite, rect)
sf::IntRect sfmlRect = shape->This.GetTextureRect();
rect.Left = sfmlRect.Left;
rect.Top = sfmlRect.Top;
rect.Width = sfmlRect.Width;
rect.Height = sfmlRect.Height;
return rect;
}
////////////////////////////////////////////////////////////
sfColor sfConvexShape_GetFillColor(const sfConvexShape* shape)
{
sfColor color = {0, 0, 0, 0};
CSFML_CHECK_RETURN(shape, color);
sf::Color sfmlColor = shape->This.GetFillColor();
color.r = sfmlColor.r;
color.g = sfmlColor.g;
color.b = sfmlColor.b;
color.a = sfmlColor.a;
return color;
}
////////////////////////////////////////////////////////////
sfColor sfConvexShape_GetOutlineColor(const sfConvexShape* shape)
{
sfColor color = {0, 0, 0, 0};
CSFML_CHECK_RETURN(shape, color);
sf::Color sfmlColor = shape->This.GetOutlineColor();
color.r = sfmlColor.r;
color.g = sfmlColor.g;
color.b = sfmlColor.b;
color.a = sfmlColor.a;
return color;
}
////////////////////////////////////////////////////////////
float sfConvexShape_GetOutlineThickness(const sfConvexShape* shape)
{
CSFML_CALL_RETURN(shape, GetOutlineThickness(), 0.f);
}
////////////////////////////////////////////////////////////
unsigned int sfConvexShape_GetPointCount(const sfConvexShape* shape)
{
CSFML_CALL_RETURN(shape, GetPointCount(), 0);
}
////////////////////////////////////////////////////////////
void sfConvexShape_GetPoint(const sfConvexShape* shape, unsigned int index, float* x, float* y)
{
CSFML_CHECK(shape);
sf::Vector2f point = shape->This.GetPoint(index);
if (x)
*x = point.x;
if (y)
*y = point.y;
}
////////////////////////////////////////////////////////////
void sfConvexShape_SetPointCount(sfConvexShape* shape, unsigned int count)
{
CSFML_CALL(shape, SetPointCount(count));
}
////////////////////////////////////////////////////////////
void sfConvexShape_SetPoint(sfConvexShape* shape, unsigned int index, float x, float y)
{
CSFML_CALL(shape, SetPoint(index, sf::Vector2f(x, y)));
}
+48
View File
@@ -0,0 +1,48 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// 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 SFML_CONVEXSHAPESTRUCT_H
#define SFML_CONVEXSHAPESTRUCT_H
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics/ConvexShape.hpp>
#include <SFML/Graphics/TextureStruct.h>
#include <SFML/Graphics/TransformStruct.h>
////////////////////////////////////////////////////////////
// Internal structure of sfConvexShape
////////////////////////////////////////////////////////////
struct sfConvexShape
{
sf::ConvexShape This;
const sfTexture* Texture;
mutable sfTransform Transform;
mutable sfTransform InverseTransform;
};
#endif // SFML_CONVEXSHAPESTRUCT_H
+9 -9
View File
@@ -112,15 +112,15 @@ sfGlyph sfFont_GetGlyph(sfFont* font, sfUint32 codePoint, unsigned int character
sf::Glyph SFMLGlyph = font->This.GetGlyph(codePoint, characterSize, bold == sfTrue);
glyph.Advance = SFMLGlyph.Advance;
glyph.Bounds.Left = SFMLGlyph.Bounds.Left;
glyph.Bounds.Top = SFMLGlyph.Bounds.Top;
glyph.Bounds.Width = SFMLGlyph.Bounds.Width;
glyph.Bounds.Height = SFMLGlyph.Bounds.Height;
glyph.SubRect.Left = SFMLGlyph.SubRect.Left;
glyph.SubRect.Top = SFMLGlyph.SubRect.Top;
glyph.SubRect.Width = SFMLGlyph.SubRect.Width;
glyph.SubRect.Height = SFMLGlyph.SubRect.Height;
glyph.Advance = SFMLGlyph.Advance;
glyph.Bounds.Left = SFMLGlyph.Bounds.Left;
glyph.Bounds.Top = SFMLGlyph.Bounds.Top;
glyph.Bounds.Width = SFMLGlyph.Bounds.Width;
glyph.Bounds.Height = SFMLGlyph.Bounds.Height;
glyph.TextureRect.Left = SFMLGlyph.TextureRect.Left;
glyph.TextureRect.Top = SFMLGlyph.TextureRect.Top;
glyph.TextureRect.Width = SFMLGlyph.TextureRect.Width;
glyph.TextureRect.Height = SFMLGlyph.TextureRect.Height;
return glyph;
}
+312
View File
@@ -0,0 +1,312 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// 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.
//
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics/RectangleShape.h>
#include <SFML/Graphics/RectangleShapeStruct.h>
#include <SFML/Graphics/Color.hpp>
#include <SFML/Internal.h>
////////////////////////////////////////////////////////////
sfRectangleShape* sfRectangleShape_Create(void)
{
return new sfRectangleShape;
}
////////////////////////////////////////////////////////////
sfRectangleShape* sfRectangleShape_Copy(sfRectangleShape* shape)
{
CSFML_CHECK_RETURN(shape, NULL);
return new sfRectangleShape(*shape);
}
////////////////////////////////////////////////////////////
void sfRectangleShape_Destroy(sfRectangleShape* shape)
{
delete shape;
}
////////////////////////////////////////////////////////////
void sfRectangleShape_SetPosition(sfRectangleShape* shape, float x, float y)
{
CSFML_CALL(shape, SetPosition(x, y));
}
////////////////////////////////////////////////////////////
void sfRectangleShape_SetRotation(sfRectangleShape* shape, float angle)
{
CSFML_CALL(shape, SetRotation(angle));
}
////////////////////////////////////////////////////////////
void sfRectangleShape_SetScale(sfRectangleShape* shape, float factorX, float factorY)
{
CSFML_CALL(shape, SetScale(factorX, factorY));
}
////////////////////////////////////////////////////////////
void sfRectangleShape_SetOrigin(sfRectangleShape* shape, float x, float y)
{
CSFML_CALL(shape, SetOrigin(x, y));
}
////////////////////////////////////////////////////////////
void sfRectangleShape_GetPosition(const sfRectangleShape* shape, float* x, float* y)
{
CSFML_CHECK(shape);
sf::Vector2f point = shape->This.GetPosition();
if (x)
*x = point.x;
if (y)
*y = point.y;
}
////////////////////////////////////////////////////////////
float sfRectangleShape_GetRotation(const sfRectangleShape* shape)
{
CSFML_CALL_RETURN(shape, GetRotation(), 0.f);
}
////////////////////////////////////////////////////////////
void sfRectangleShape_GetScale(const sfRectangleShape* shape, float* x, float* y)
{
CSFML_CHECK(shape);
sf::Vector2f point = shape->This.GetScale();
if (x)
*x = point.x;
if (y)
*y = point.y;
}
////////////////////////////////////////////////////////////
void sfRectangleShape_GetOrigin(const sfRectangleShape* shape, float* x, float* y)
{
CSFML_CHECK(shape);
sf::Vector2f point = shape->This.GetOrigin();
if (x)
*x = point.x;
if (y)
*y = point.y;
}
////////////////////////////////////////////////////////////
void sfRectangleShape_Move(sfRectangleShape* shape, float offsetX, float offsetY)
{
CSFML_CALL(shape, Move(offsetX, offsetY));
}
////////////////////////////////////////////////////////////
void sfRectangleShape_Rotate(sfRectangleShape* shape, float angle)
{
CSFML_CALL(shape, Rotate(angle));
}
////////////////////////////////////////////////////////////
void sfRectangleShape_Scale(sfRectangleShape* shape, float factorX, float factorY)
{
CSFML_CALL(shape, Scale(factorX, factorY));
}
////////////////////////////////////////////////////////////
const sfTransform* sfRectangleShape_GetTransform(const sfRectangleShape* shape)
{
CSFML_CHECK_RETURN(shape, NULL);
shape->Transform.This = shape->This.GetTransform();
return &shape->Transform;
}
////////////////////////////////////////////////////////////
const sfTransform* sfRectangleShape_GetInverseTransform(const sfRectangleShape* shape)
{
CSFML_CHECK_RETURN(shape, NULL);
shape->InverseTransform.This = shape->This.GetInverseTransform();
return &shape->InverseTransform;
}
////////////////////////////////////////////////////////////
void sfRectangleShape_SetTexture(sfRectangleShape* shape, const sfTexture* texture, sfBool resetRect)
{
CSFML_CALL(shape, SetTexture(texture ? texture->This : NULL, resetRect == sfTrue))
shape->Texture = texture;
}
////////////////////////////////////////////////////////////
void sfRectangleShape_SetTextureRect(sfRectangleShape* shape, sfIntRect rect)
{
CSFML_CALL(shape, SetTextureRect(sf::IntRect(rect.Left, rect.Top, rect.Width, rect.Height)))
}
////////////////////////////////////////////////////////////
void sfRectangleShape_SetFillColor(sfRectangleShape* shape, sfColor color)
{
CSFML_CALL(shape, SetFillColor(sf::Color(color.r, color.g, color.b, color.a)));
}
////////////////////////////////////////////////////////////
void sfRectangleShape_SetOutlineColor(sfRectangleShape* shape, sfColor color)
{
CSFML_CALL(shape, SetOutlineColor(sf::Color(color.r, color.g, color.b, color.a)));
}
////////////////////////////////////////////////////////////
void sfRectangleShape_SetOutlineThickness(sfRectangleShape* shape, float thickness)
{
CSFML_CALL(shape, SetOutlineThickness(thickness));
}
////////////////////////////////////////////////////////////
const sfTexture* sfRectangleShape_GetTexture(const sfRectangleShape* shape)
{
CSFML_CHECK_RETURN(shape, NULL)
return shape->Texture;
}
////////////////////////////////////////////////////////////
sfIntRect sfRectangleShape_GetTextureRect(const sfRectangleShape* shape)
{
sfIntRect rect = {0, 0, 0, 0};
CSFML_CHECK_RETURN(sprite, rect)
sf::IntRect sfmlRect = shape->This.GetTextureRect();
rect.Left = sfmlRect.Left;
rect.Top = sfmlRect.Top;
rect.Width = sfmlRect.Width;
rect.Height = sfmlRect.Height;
return rect;
}
////////////////////////////////////////////////////////////
sfColor sfRectangleShape_GetFillColor(const sfRectangleShape* shape)
{
sfColor color = {0, 0, 0, 0};
CSFML_CHECK_RETURN(shape, color);
sf::Color sfmlColor = shape->This.GetFillColor();
color.r = sfmlColor.r;
color.g = sfmlColor.g;
color.b = sfmlColor.b;
color.a = sfmlColor.a;
return color;
}
////////////////////////////////////////////////////////////
sfColor sfRectangleShape_GetOutlineColor(const sfRectangleShape* shape)
{
sfColor color = {0, 0, 0, 0};
CSFML_CHECK_RETURN(shape, color);
sf::Color sfmlColor = shape->This.GetOutlineColor();
color.r = sfmlColor.r;
color.g = sfmlColor.g;
color.b = sfmlColor.b;
color.a = sfmlColor.a;
return color;
}
////////////////////////////////////////////////////////////
float sfRectangleShape_GetOutlineThickness(const sfRectangleShape* shape)
{
CSFML_CALL_RETURN(shape, GetOutlineThickness(), 0.f);
}
////////////////////////////////////////////////////////////
unsigned int sfRectangleShape_GetPointCount(const sfRectangleShape* shape)
{
CSFML_CALL_RETURN(shape, GetPointCount(), 0);
}
////////////////////////////////////////////////////////////
void sfRectangleShape_GetPoint(const sfRectangleShape* shape, unsigned int index, float* x, float* y)
{
CSFML_CHECK(shape);
sf::Vector2f point = shape->This.GetPoint(index);
if (x)
*x = point.x;
if (y)
*y = point.y;
}
////////////////////////////////////////////////////////////
void sfRectangleShape_SetSize(sfRectangleShape* shape, float width, float height)
{
CSFML_CALL(shape, SetSize(sf::Vector2f(width, height)));
}
////////////////////////////////////////////////////////////
void sfRectangleShape_GetSize(const sfRectangleShape* shape, float* width, float* height)
{
CSFML_CHECK(shape);
sf::Vector2f size = shape->This.GetSize();
if (width)
*width = size.x;
if (height)
*height = size.y;
}
+48
View File
@@ -0,0 +1,48 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// 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 SFML_RECTANGLESHAPESTRUCT_H
#define SFML_RECTANGLESHAPESTRUCT_H
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics/RectangleShape.hpp>
#include <SFML/Graphics/TextureStruct.h>
#include <SFML/Graphics/TransformStruct.h>
////////////////////////////////////////////////////////////
// Internal structure of sfRectangleShape
////////////////////////////////////////////////////////////
struct sfRectangleShape
{
sf::RectangleShape This;
const sfTexture* Texture;
mutable sfTransform Transform;
mutable sfTransform InverseTransform;
};
#endif // SFML_RECTANGLESHAPESTRUCT_H
+68 -88
View File
@@ -27,15 +27,16 @@
////////////////////////////////////////////////////////////
#include <SFML/Graphics/RenderTexture.h>
#include <SFML/Graphics/RenderTextureStruct.h>
#include <SFML/Graphics/ShapeStruct.h>
#include <SFML/Graphics/ShaderStruct.h>
#include <SFML/Graphics/SpriteStruct.h>
#include <SFML/Graphics/TextStruct.h>
#include <SFML/Graphics/CircleShapeStruct.h>
#include <SFML/Graphics/ConvexShapeStruct.h>
#include <SFML/Graphics/RectangleShapeStruct.h>
#include <SFML/Graphics/VertexArrayStruct.h>
#include <SFML/Graphics/ConvertRenderStates.hpp>
#include <SFML/Internal.h>
////////////////////////////////////////////////////////////
/// Construct a new rendertexture
////////////////////////////////////////////////////////////
sfRenderTexture* sfRenderTexture_Create(unsigned int width, unsigned int height, sfBool depthBuffer)
{
@@ -49,8 +50,6 @@ sfRenderTexture* sfRenderTexture_Create(unsigned int width, unsigned int height,
}
////////////////////////////////////////////////////////////
/// Destroy an existing rendertexture
////////////////////////////////////////////////////////////
void sfRenderTexture_Destroy(sfRenderTexture* renderTexture)
{
@@ -59,8 +58,6 @@ void sfRenderTexture_Destroy(sfRenderTexture* renderTexture)
}
////////////////////////////////////////////////////////////
/// Get the width of the rendering region of a rendertexture
////////////////////////////////////////////////////////////
unsigned int sfRenderTexture_GetWidth(const sfRenderTexture* renderTexture)
{
@@ -68,8 +65,6 @@ unsigned int sfRenderTexture_GetWidth(const sfRenderTexture* renderTexture)
}
////////////////////////////////////////////////////////////
/// Get the height of the rendering region of a rendertexture
////////////////////////////////////////////////////////////
unsigned int sfRenderTexture_GetHeight(const sfRenderTexture* renderTexture)
{
@@ -77,8 +72,6 @@ unsigned int sfRenderTexture_GetHeight(const sfRenderTexture* renderTexture)
}
////////////////////////////////////////////////////////////
/// Set a rendertexture as the current target for rendering
////////////////////////////////////////////////////////////
sfBool sfRenderTexture_SetActive(sfRenderTexture* renderTexture, sfBool active)
{
@@ -86,26 +79,6 @@ sfBool sfRenderTexture_SetActive(sfRenderTexture* renderTexture, sfBool active)
}
////////////////////////////////////////////////////////////
/// Save the current OpenGL render states and matrices
////////////////////////////////////////////////////////////
void sfRenderTexture_SaveGLStates(sfRenderTexture* renderTexture)
{
CSFML_CALL(renderTexture, SaveGLStates());
}
////////////////////////////////////////////////////////////
/// Restore the previously saved OpenGL render states and matrices
////////////////////////////////////////////////////////////
void sfRenderTexture_RestoreGLStates(sfRenderTexture* renderTexture)
{
CSFML_CALL(renderTexture, RestoreGLStates());
}
////////////////////////////////////////////////////////////
/// Update the contents of the target texture
////////////////////////////////////////////////////////////
void sfRenderTexture_Display(sfRenderTexture* renderTexture)
{
@@ -113,51 +86,6 @@ void sfRenderTexture_Display(sfRenderTexture* renderTexture)
}
////////////////////////////////////////////////////////////
/// Draw something on a rendertexture
////////////////////////////////////////////////////////////
void sfRenderTexture_DrawSprite(sfRenderTexture* renderTexture, const sfSprite* sprite)
{
CSFML_CHECK(sprite);
CSFML_CALL(renderTexture, Draw(sprite->This));
}
void sfRenderTexture_DrawShape(sfRenderTexture* renderTexture, const sfShape* shape)
{
CSFML_CHECK(shape);
CSFML_CALL(renderTexture, Draw(shape->This));
}
void sfRenderTexture_DrawText(sfRenderTexture* renderTexture, const sfText* text)
{
CSFML_CHECK(text);
CSFML_CALL(renderTexture, Draw(text->This));
}
////////////////////////////////////////////////////////////
/// Draw something on a rendertexture with a shader
////////////////////////////////////////////////////////////
void sfRenderTexture_DrawSpriteWithShader(sfRenderTexture* renderTexture, const sfSprite* sprite, const sfShader* shader)
{
CSFML_CHECK(sprite);
CSFML_CHECK(shader);
CSFML_CALL(renderTexture, Draw(sprite->This, shader->This));
}
void sfRenderTexture_DrawShapeWithShader(sfRenderTexture* renderTexture, const sfShape* shape, const sfShader* shader)
{
CSFML_CHECK(shape);
CSFML_CHECK(shader);
CSFML_CALL(renderTexture, Draw(shape->This, shader->This));
}
void sfRenderTexture_DrawTextWithShader(sfRenderTexture* renderTexture, const sfText* text, const sfShader* shader)
{
CSFML_CHECK(text);
CSFML_CHECK(shader);
CSFML_CALL(renderTexture, Draw(text->This, shader->This));
}
////////////////////////////////////////////////////////////
/// Clear the rendertexture with the given color
////////////////////////////////////////////////////////////
void sfRenderTexture_Clear(sfRenderTexture* renderTexture, sfColor color)
{
@@ -167,8 +95,6 @@ void sfRenderTexture_Clear(sfRenderTexture* renderTexture, sfColor color)
}
////////////////////////////////////////////////////////////
/// Change the current active view of a rendertexture
////////////////////////////////////////////////////////////
void sfRenderTexture_SetView(sfRenderTexture* renderTexture, const sfView* view)
{
@@ -178,8 +104,6 @@ void sfRenderTexture_SetView(sfRenderTexture* renderTexture, const sfView* view)
}
////////////////////////////////////////////////////////////
/// Get the current active view of a rendertexture
////////////////////////////////////////////////////////////
const sfView* sfRenderTexture_GetView(const sfRenderTexture* renderTexture)
{
@@ -189,8 +113,6 @@ const sfView* sfRenderTexture_GetView(const sfRenderTexture* renderTexture)
}
////////////////////////////////////////////////////////////
/// Get the default view of a rendertexture
////////////////////////////////////////////////////////////
const sfView* sfRenderTexture_GetDefaultView(const sfRenderTexture* renderTexture)
{
@@ -200,8 +122,6 @@ const sfView* sfRenderTexture_GetDefaultView(const sfRenderTexture* renderTextur
}
////////////////////////////////////////////////////////////
/// Get the viewport of a view applied to this target
////////////////////////////////////////////////////////////
sfIntRect sfRenderTexture_GetViewport(const sfRenderTexture* renderTexture, const sfView* view)
{
@@ -219,8 +139,6 @@ sfIntRect sfRenderTexture_GetViewport(const sfRenderTexture* renderTexture, cons
}
////////////////////////////////////////////////////////////
/// Convert a point in texture coordinates into view coordinates
////////////////////////////////////////////////////////////
void sfRenderTexture_ConvertCoords(const sfRenderTexture* renderTexture, unsigned int textureX, unsigned int textureY, float* viewX, float* viewY, const sfView* targetView)
{
@@ -238,7 +156,69 @@ void sfRenderTexture_ConvertCoords(const sfRenderTexture* renderTexture, unsigne
////////////////////////////////////////////////////////////
/// Get the target texture
void sfRenderTexture_DrawSprite(sfRenderTexture* renderTexture, const sfSprite* object, const sfRenderStates* states)
{
CSFML_CHECK(object);
CSFML_CALL(renderTexture, Draw(object->This, ConvertRenderStates(states)));
}
void sfRenderTexture_DrawText(sfRenderTexture* renderTexture, const sfText* object, const sfRenderStates* states)
{
CSFML_CHECK(object);
CSFML_CALL(renderTexture, Draw(object->This, ConvertRenderStates(states)));
}
void sfRenderTexture_DrawCircleShape(sfRenderTexture* renderTexture, const sfCircleShape* object, const sfRenderStates* states)
{
CSFML_CHECK(object);
CSFML_CALL(renderTexture, Draw(object->This, ConvertRenderStates(states)));
}
void sfRenderTexture_DrawConvexShape(sfRenderTexture* renderTexture, const sfConvexShape* object, const sfRenderStates* states)
{
CSFML_CHECK(object);
CSFML_CALL(renderTexture, Draw(object->This, ConvertRenderStates(states)));
}
void sfRenderTexture_DrawRectangleShape(sfRenderTexture* renderTexture, const sfRectangleShape* object, const sfRenderStates* states)
{
CSFML_CHECK(object);
CSFML_CALL(renderTexture, Draw(object->This, ConvertRenderStates(states)));
}
void sfRenderTexture_DrawVertexArray(sfRenderTexture* renderTexture, const sfVertexArray* object, const sfRenderStates* states)
{
CSFML_CHECK(object);
CSFML_CALL(renderTexture, Draw(object->This, ConvertRenderStates(states)));
}
////////////////////////////////////////////////////////////
CSFML_API void sfRenderTexture_DrawPrimitives(sfRenderTexture* renderTexture,
const sfVertex* vertices, unsigned int vertexCount,
sfPrimitiveType type, const sfRenderStates* states)
{
CSFML_CALL(renderTexture, Draw(reinterpret_cast<const sf::Vertex*>(vertices), vertexCount,
static_cast<sf::PrimitiveType>(type), ConvertRenderStates(states)));
}
////////////////////////////////////////////////////////////
CSFML_API void sfRenderTexture_PushGLStates(sfRenderTexture* renderTexture)
{
CSFML_CALL(renderTexture, PushGLStates());
}
////////////////////////////////////////////////////////////
CSFML_API void sfRenderTexture_PopGLStates(sfRenderTexture* renderTexture)
{
CSFML_CALL(renderTexture, PopGLStates());
}
////////////////////////////////////////////////////////////
CSFML_API void sfRenderTexture_ResetGLStates(sfRenderTexture* renderTexture)
{
CSFML_CALL(renderTexture, ResetGLStates());
}
////////////////////////////////////////////////////////////
const sfTexture* sfRenderTexture_GetTexture(const sfRenderTexture* renderTexture)
{
+72 -136
View File
@@ -27,17 +27,18 @@
////////////////////////////////////////////////////////////
#include <SFML/Graphics/RenderWindow.h>
#include <SFML/Graphics/RenderWindowStruct.h>
#include <SFML/Graphics/ShapeStruct.h>
#include <SFML/Graphics/ShaderStruct.h>
#include <SFML/Graphics/ImageStruct.h>
#include <SFML/Graphics/SpriteStruct.h>
#include <SFML/Graphics/TextStruct.h>
#include <SFML/Graphics/CircleShapeStruct.h>
#include <SFML/Graphics/ConvexShapeStruct.h>
#include <SFML/Graphics/RectangleShapeStruct.h>
#include <SFML/Graphics/VertexArrayStruct.h>
#include <SFML/Graphics/ConvertRenderStates.hpp>
#include <SFML/Internal.h>
#include <SFML/ConvertEvent.h>
////////////////////////////////////////////////////////////
/// Construct a new renderwindow
////////////////////////////////////////////////////////////
sfRenderWindow* sfRenderWindow_Create(sfVideoMode mode, const char* title, sfUint32 style, const sfContextSettings* settings)
{
@@ -65,8 +66,6 @@ sfRenderWindow* sfRenderWindow_Create(sfVideoMode mode, const char* title, sfUin
}
////////////////////////////////////////////////////////////
/// Construct a renderwindow from an existing control
////////////////////////////////////////////////////////////
sfRenderWindow* sfRenderWindow_CreateFromHandle(sfWindowHandle handle, const sfContextSettings* settings)
{
@@ -91,16 +90,13 @@ sfRenderWindow* sfRenderWindow_CreateFromHandle(sfWindowHandle handle, const sfC
}
////////////////////////////////////////////////////////////
/// Destroy an existing renderwindow
////////////////////////////////////////////////////////////
void sfRenderWindow_Destroy(sfRenderWindow* renderWindow)
{
delete renderWindow;
}
////////////////////////////////////////////////////////////
/// Close a renderwindow (but doesn't destroy the internal data)
////////////////////////////////////////////////////////////
void sfRenderWindow_Close(sfRenderWindow* renderWindow)
{
@@ -109,16 +105,12 @@ void sfRenderWindow_Close(sfRenderWindow* renderWindow)
////////////////////////////////////////////////////////////
/// Tell whether or not a renderwindow is opened
////////////////////////////////////////////////////////////
sfBool sfRenderWindow_IsOpened(const sfRenderWindow* renderWindow)
sfBool sfRenderWindow_IsOpen(const sfRenderWindow* renderWindow)
{
CSFML_CALL_RETURN(renderWindow, IsOpened(), sfFalse);
CSFML_CALL_RETURN(renderWindow, IsOpen(), sfFalse);
}
////////////////////////////////////////////////////////////
/// Get the width of the rendering region of a window
////////////////////////////////////////////////////////////
unsigned int sfRenderWindow_GetWidth(const sfRenderWindow* renderWindow)
{
@@ -126,8 +118,6 @@ unsigned int sfRenderWindow_GetWidth(const sfRenderWindow* renderWindow)
}
////////////////////////////////////////////////////////////
/// Get the height of the rendering region of a window
////////////////////////////////////////////////////////////
unsigned int sfRenderWindow_GetHeight(const sfRenderWindow* renderWindow)
{
@@ -135,8 +125,6 @@ unsigned int sfRenderWindow_GetHeight(const sfRenderWindow* renderWindow)
}
////////////////////////////////////////////////////////////
/// Get the creation settings of a window
////////////////////////////////////////////////////////////
sfContextSettings sfRenderWindow_GetSettings(const sfRenderWindow* renderWindow)
{
@@ -152,9 +140,6 @@ sfContextSettings sfRenderWindow_GetSettings(const sfRenderWindow* renderWindow)
}
////////////////////////////////////////////////////////////
/// Get the event on top of events stack of a window, if any, and pop it
////////////////////////////////////////////////////////////
sfBool sfRenderWindow_PollEvent(sfRenderWindow* renderWindow, sfEvent* event)
{
@@ -176,8 +161,6 @@ sfBool sfRenderWindow_PollEvent(sfRenderWindow* renderWindow, sfEvent* event)
}
////////////////////////////////////////////////////////////
/// Wait for an event and return it
////////////////////////////////////////////////////////////
sfBool sfRenderWindow_WaitEvent(sfRenderWindow* renderWindow, sfEvent* event)
{
@@ -199,8 +182,6 @@ sfBool sfRenderWindow_WaitEvent(sfRenderWindow* renderWindow, sfEvent* event)
}
////////////////////////////////////////////////////////////
/// Enable / disable vertical synchronization on a window
////////////////////////////////////////////////////////////
void sfRenderWindow_EnableVerticalSync(sfRenderWindow* renderWindow, sfBool enabled)
{
@@ -208,8 +189,6 @@ void sfRenderWindow_EnableVerticalSync(sfRenderWindow* renderWindow, sfBool enab
}
////////////////////////////////////////////////////////////
/// Show or hide the mouse cursor on a window
////////////////////////////////////////////////////////////
void sfRenderWindow_ShowMouseCursor(sfRenderWindow* renderWindow, sfBool show)
{
@@ -217,9 +196,6 @@ void sfRenderWindow_ShowMouseCursor(sfRenderWindow* renderWindow, sfBool show)
}
////////////////////////////////////////////////////////////
/// Change the position of a window on screen.
/// Only works for top-level windows
////////////////////////////////////////////////////////////
void sfRenderWindow_SetPosition(sfRenderWindow* renderWindow, int left, int top)
{
@@ -227,8 +203,6 @@ void sfRenderWindow_SetPosition(sfRenderWindow* renderWindow, int left, int top)
}
////////////////////////////////////////////////////////////
/// Change the size of the rendering region of a window
////////////////////////////////////////////////////////////
void sfRenderWindow_SetSize(sfRenderWindow* renderWindow, unsigned int width, unsigned int height)
{
@@ -236,8 +210,6 @@ void sfRenderWindow_SetSize(sfRenderWindow* renderWindow, unsigned int width, un
}
////////////////////////////////////////////////////////////
/// Change the title of a window
////////////////////////////////////////////////////////////
void sfRenderWindow_SetTitle(sfRenderWindow* renderWindow, const char* title)
{
@@ -245,8 +217,6 @@ void sfRenderWindow_SetTitle(sfRenderWindow* renderWindow, const char* title)
}
////////////////////////////////////////////////////////////
/// Show or hide a window
////////////////////////////////////////////////////////////
void sfRenderWindow_Show(sfRenderWindow* renderWindow, sfBool show)
{
@@ -254,9 +224,6 @@ void sfRenderWindow_Show(sfRenderWindow* renderWindow, sfBool show)
}
////////////////////////////////////////////////////////////
/// Enable or disable automatic key-repeat for keydown events.
/// Automatic key-repeat is enabled by default
////////////////////////////////////////////////////////////
void sfRenderWindow_EnableKeyRepeat(sfRenderWindow* renderWindow, sfBool enabled)
{
@@ -264,8 +231,6 @@ void sfRenderWindow_EnableKeyRepeat(sfRenderWindow* renderWindow, sfBool enabled
}
////////////////////////////////////////////////////////////
/// Change the window's icon
////////////////////////////////////////////////////////////
void sfRenderWindow_SetIcon(sfRenderWindow* renderWindow, unsigned int width, unsigned int height, const sfUint8* pixels)
{
@@ -273,8 +238,6 @@ void sfRenderWindow_SetIcon(sfRenderWindow* renderWindow, unsigned int width, un
}
////////////////////////////////////////////////////////////
/// Set a window as the current target for rendering
////////////////////////////////////////////////////////////
sfBool sfRenderWindow_SetActive(sfRenderWindow* renderWindow, sfBool active)
{
@@ -282,26 +245,6 @@ sfBool sfRenderWindow_SetActive(sfRenderWindow* renderWindow, sfBool active)
}
////////////////////////////////////////////////////////////
/// Save the current OpenGL render states and matrices
////////////////////////////////////////////////////////////
void sfRenderWindow_SaveGLStates(sfRenderWindow* renderWindow)
{
CSFML_CALL(renderWindow, SaveGLStates());
}
////////////////////////////////////////////////////////////
/// Restore the previously saved OpenGL render states and matrices
////////////////////////////////////////////////////////////
void sfRenderWindow_RestoreGLStates(sfRenderWindow* renderWindow)
{
CSFML_CALL(renderWindow, RestoreGLStates());
}
////////////////////////////////////////////////////////////
/// Display a window on screen
////////////////////////////////////////////////////////////
void sfRenderWindow_Display(sfRenderWindow* renderWindow)
{
@@ -309,8 +252,6 @@ void sfRenderWindow_Display(sfRenderWindow* renderWindow)
}
////////////////////////////////////////////////////////////
/// Limit the framerate to a maximum fixed frequency for a window
////////////////////////////////////////////////////////////
void sfRenderWindow_SetFramerateLimit(sfRenderWindow* renderWindow, unsigned int limit)
{
@@ -318,18 +259,6 @@ void sfRenderWindow_SetFramerateLimit(sfRenderWindow* renderWindow, unsigned int
}
////////////////////////////////////////////////////////////
/// Get time elapsed since last frame of a window
////////////////////////////////////////////////////////////
sfUint32 sfRenderWindow_GetFrameTime(const sfRenderWindow* renderWindow)
{
CSFML_CALL_RETURN(renderWindow, GetFrameTime(), 0);
}
////////////////////////////////////////////////////////////
/// Change the joystick threshold, ie. the value below which
/// no move event will be generated
////////////////////////////////////////////////////////////
void sfRenderWindow_SetJoystickThreshold(sfRenderWindow* renderWindow, float threshold)
{
@@ -337,8 +266,6 @@ void sfRenderWindow_SetJoystickThreshold(sfRenderWindow* renderWindow, float thr
}
////////////////////////////////////////////////////////////
/// Retrieve the Os-specific handle of a window
////////////////////////////////////////////////////////////
sfWindowHandle sfRenderWindow_GetSystemHandle(const sfRenderWindow* renderWindow)
{
@@ -348,51 +275,6 @@ sfWindowHandle sfRenderWindow_GetSystemHandle(const sfRenderWindow* renderWindow
}
////////////////////////////////////////////////////////////
/// Draw something on a renderwindow
////////////////////////////////////////////////////////////
void sfRenderWindow_DrawSprite(sfRenderWindow* renderWindow, const sfSprite* sprite)
{
CSFML_CHECK(sprite);
CSFML_CALL(renderWindow, Draw(sprite->This));
}
void sfRenderWindow_DrawShape(sfRenderWindow* renderWindow, const sfShape* shape)
{
CSFML_CHECK(shape);
CSFML_CALL(renderWindow, Draw(shape->This));
}
void sfRenderWindow_DrawText(sfRenderWindow* renderWindow, const sfText* text)
{
CSFML_CHECK(text);
CSFML_CALL(renderWindow, Draw(text->This));
}
////////////////////////////////////////////////////////////
/// Draw something on a renderwindow with a shader
////////////////////////////////////////////////////////////
void sfRenderWindow_DrawSpriteWithShader(sfRenderWindow* renderWindow, const sfSprite* sprite, const sfShader* shader)
{
CSFML_CHECK(sprite);
CSFML_CHECK(shader);
CSFML_CALL(renderWindow, Draw(sprite->This, shader->This));
}
void sfRenderWindow_DrawShapeWithShader(sfRenderWindow* renderWindow, const sfShape* shape, const sfShader* shader)
{
CSFML_CHECK(shape);
CSFML_CHECK(shader);
CSFML_CALL(renderWindow, Draw(shape->This, shader->This));
}
void sfRenderWindow_DrawTextWithShader(sfRenderWindow* renderWindow, const sfText* text, const sfShader* shader)
{
CSFML_CHECK(text);
CSFML_CHECK(shader);
CSFML_CALL(renderWindow, Draw(text->This, shader->This));
}
////////////////////////////////////////////////////////////
/// Clear the screen with the given color
////////////////////////////////////////////////////////////
void sfRenderWindow_Clear(sfRenderWindow* renderWindow, sfColor color)
{
@@ -402,8 +284,6 @@ void sfRenderWindow_Clear(sfRenderWindow* renderWindow, sfColor color)
}
////////////////////////////////////////////////////////////
/// Change the current active view of a renderwindow
////////////////////////////////////////////////////////////
void sfRenderWindow_SetView(sfRenderWindow* renderWindow, const sfView* view)
{
@@ -413,8 +293,6 @@ void sfRenderWindow_SetView(sfRenderWindow* renderWindow, const sfView* view)
}
////////////////////////////////////////////////////////////
/// Get the current active view of a renderwindow
////////////////////////////////////////////////////////////
const sfView* sfRenderWindow_GetView(const sfRenderWindow* renderWindow)
{
@@ -424,8 +302,6 @@ const sfView* sfRenderWindow_GetView(const sfRenderWindow* renderWindow)
}
////////////////////////////////////////////////////////////
/// Get the default view of a renderwindow
////////////////////////////////////////////////////////////
const sfView* sfRenderWindow_GetDefaultView(const sfRenderWindow* renderWindow)
{
@@ -435,8 +311,6 @@ const sfView* sfRenderWindow_GetDefaultView(const sfRenderWindow* renderWindow)
}
////////////////////////////////////////////////////////////
/// Get the viewport of a view applied to this target
////////////////////////////////////////////////////////////
sfIntRect sfRenderWindow_GetViewport(const sfRenderWindow* renderWindow, const sfView* view)
{
@@ -454,8 +328,6 @@ sfIntRect sfRenderWindow_GetViewport(const sfRenderWindow* renderWindow, const s
}
////////////////////////////////////////////////////////////
/// Convert a point in window coordinates into view coordinates
////////////////////////////////////////////////////////////
void sfRenderWindow_ConvertCoords(const sfRenderWindow* renderWindow, unsigned int windowX, unsigned int windowY, float* viewX, float* viewY, const sfView* targetView)
{
@@ -472,6 +344,70 @@ void sfRenderWindow_ConvertCoords(const sfRenderWindow* renderWindow, unsigned i
}
////////////////////////////////////////////////////////////
void sfRenderWindow_DrawSprite(sfRenderWindow* renderWindow, const sfSprite* object, const sfRenderStates* states)
{
CSFML_CHECK(object);
CSFML_CALL(renderWindow, Draw(object->This, ConvertRenderStates(states)));
}
void sfRenderWindow_DrawText(sfRenderWindow* renderWindow, const sfText* object, const sfRenderStates* states)
{
CSFML_CHECK(object);
CSFML_CALL(renderWindow, Draw(object->This, ConvertRenderStates(states)));
}
void sfRenderWindow_DrawCircleShape(sfRenderWindow* renderWindow, const sfCircleShape* object, const sfRenderStates* states)
{
CSFML_CHECK(object);
CSFML_CALL(renderWindow, Draw(object->This, ConvertRenderStates(states)));
}
void sfRenderWindow_DrawConvexShape(sfRenderWindow* renderWindow, const sfConvexShape* object, const sfRenderStates* states)
{
CSFML_CHECK(object);
CSFML_CALL(renderWindow, Draw(object->This, ConvertRenderStates(states)));
}
void sfRenderWindow_DrawRectangleShape(sfRenderWindow* renderWindow, const sfRectangleShape* object, const sfRenderStates* states)
{
CSFML_CHECK(object);
CSFML_CALL(renderWindow, Draw(object->This, ConvertRenderStates(states)));
}
void sfRenderWindow_DrawVertexArray(sfRenderWindow* renderWindow, const sfVertexArray* object, const sfRenderStates* states)
{
CSFML_CHECK(object);
CSFML_CALL(renderWindow, Draw(object->This, ConvertRenderStates(states)));
}
////////////////////////////////////////////////////////////
CSFML_API void sfRenderWindow_DrawPrimitives(sfRenderWindow* renderWindow,
const sfVertex* vertices, unsigned int vertexCount,
sfPrimitiveType type, const sfRenderStates* states)
{
CSFML_CALL(renderWindow, Draw(reinterpret_cast<const sf::Vertex*>(vertices), vertexCount,
static_cast<sf::PrimitiveType>(type), ConvertRenderStates(states)));
}
////////////////////////////////////////////////////////////
CSFML_API void sfRenderWindow_PushGLStates(sfRenderWindow* renderWindow)
{
CSFML_CALL(renderWindow, PushGLStates());
}
////////////////////////////////////////////////////////////
CSFML_API void sfRenderWindow_PopGLStates(sfRenderWindow* renderWindow)
{
CSFML_CALL(renderWindow, PopGLStates());
}
////////////////////////////////////////////////////////////
CSFML_API void sfRenderWindow_ResetGLStates(sfRenderWindow* renderWindow)
{
CSFML_CALL(renderWindow, ResetGLStates());
}
////////////////////////////////////////////////////////////
/// Copy the current contents of a window to an image
////////////////////////////////////////////////////////////
+89 -53
View File
@@ -28,18 +28,36 @@
#include <SFML/Graphics/Shader.h>
#include <SFML/Graphics/ShaderStruct.h>
#include <SFML/Graphics/TextureStruct.h>
#include <SFML/Graphics/TransformStruct.h>
#include <SFML/Internal.h>
#include <SFML/CallbackStream.h>
////////////////////////////////////////////////////////////
/// Create a new shader from a file
////////////////////////////////////////////////////////////
sfShader* sfShader_CreateFromFile(const char* filename)
sfShader* sfShader_CreateFromFile(const char* vertexShaderFilename, const char* fragmentShaderFilename)
{
bool success = false;
sfShader* shader = new sfShader;
if (vertexShaderFilename || fragmentShaderFilename)
{
if (!vertexShaderFilename)
{
// fragment shader only
success = shader->This.LoadFromFile(fragmentShaderFilename, sf::Shader::Fragment);
}
else if (!fragmentShaderFilename)
{
// vertex shader only
success = shader->This.LoadFromFile(vertexShaderFilename, sf::Shader::Vertex);
}
else
{
// vertex + fragment shaders
success = shader->This.LoadFromFile(vertexShaderFilename, fragmentShaderFilename);
}
}
if (!shader->This.LoadFromFile(filename))
if (!success)
{
delete shader;
shader = NULL;
@@ -50,13 +68,30 @@ sfShader* sfShader_CreateFromFile(const char* filename)
////////////////////////////////////////////////////////////
/// Create a new shader from an effect source code
////////////////////////////////////////////////////////////
sfShader* sfShader_CreateFromMemory(const char* effect)
sfShader* sfShader_CreateFromMemory(const char* vertexShader, const char* fragmentShader)
{
bool success = false;
sfShader* shader = new sfShader;
if (vertexShader || fragmentShader)
{
if (!vertexShader)
{
// fragment shader only
success = shader->This.LoadFromMemory(fragmentShader, sf::Shader::Fragment);
}
else if (!fragmentShader)
{
// vertex shader only
success = shader->This.LoadFromMemory(vertexShader, sf::Shader::Vertex);
}
else
{
// vertex + fragment shaders
success = shader->This.LoadFromMemory(vertexShader, fragmentShader);
}
}
if (!shader->This.LoadFromMemory(effect))
if (!success)
{
delete shader;
shader = NULL;
@@ -67,16 +102,34 @@ sfShader* sfShader_CreateFromMemory(const char* effect)
////////////////////////////////////////////////////////////
/// Create a new shader from a custom stream
////////////////////////////////////////////////////////////
sfShader* sfShader_CreateFromStream(sfInputStream* stream)
sfShader* sfShader_CreateFromStream(sfInputStream* vertexShaderStream, sfInputStream* fragmentShaderStream)
{
CSFML_CHECK_RETURN(stream, NULL);
bool success = false;
sfShader* shader = new sfShader;
if (vertexShaderStream || fragmentShaderStream)
{
if (!vertexShaderStream)
{
// fragment shader only
CallbackStream stream(fragmentShaderStream);
success = shader->This.LoadFromStream(stream, sf::Shader::Fragment);
}
else if (!fragmentShaderStream)
{
// vertex shader only
CallbackStream stream(vertexShaderStream);
success = shader->This.LoadFromStream(stream, sf::Shader::Vertex);
}
else
{
// vertex + fragment shaders
CallbackStream vertexStream(vertexShaderStream);
CallbackStream fragmentStream(fragmentShaderStream);
success = shader->This.LoadFromStream(vertexStream, fragmentStream);
}
}
CallbackStream sfmlStream(stream);
if (!shader->This.LoadFromStream(sfmlStream))
if (!success)
{
delete shader;
shader = NULL;
@@ -86,19 +139,6 @@ sfShader* sfShader_CreateFromStream(sfInputStream* stream)
}
////////////////////////////////////////////////////////////
/// Copy an existing clock
////////////////////////////////////////////////////////////
sfShader* sfShader_Copy(sfShader* shader)
{
CSFML_CHECK_RETURN(shader, NULL);
return new sfShader(*shader);
}
////////////////////////////////////////////////////////////
/// Destroy an existing shader
////////////////////////////////////////////////////////////
void sfShader_Destroy(sfShader* shader)
{
@@ -107,62 +147,62 @@ void sfShader_Destroy(sfShader* shader)
////////////////////////////////////////////////////////////
/// Change a parameter of a shader (1 float)
////////////////////////////////////////////////////////////
void sfShader_SetParameter1(sfShader* shader, const char* name, float x)
void sfShader_SetFloatParameter(sfShader* shader, const char* name, float x)
{
CSFML_CALL(shader, SetParameter(name, x))
}
////////////////////////////////////////////////////////////
/// Change a parameter of a shader (2 floats)
////////////////////////////////////////////////////////////
void sfShader_SetParameter2(sfShader* shader, const char* name, float x, float y)
void sfShader_SetFloat2Parameter(sfShader* shader, const char* name, float x, float y)
{
CSFML_CALL(shader, SetParameter(name, x, y))
}
////////////////////////////////////////////////////////////
/// Change a parameter of a shader (3 floats)
////////////////////////////////////////////////////////////
void sfShader_SetParameter3(sfShader* shader, const char* name, float x, float y, float z)
void sfShader_SetFloat3Parameter(sfShader* shader, const char* name, float x, float y, float z)
{
CSFML_CALL(shader, SetParameter(name, x, y, z))
}
////////////////////////////////////////////////////////////
/// Change a parameter of a shader (4 floats)
////////////////////////////////////////////////////////////
void sfShader_SetParameter4(sfShader* shader, const char* name, float x, float y, float z, float w)
void sfShader_SetFloat4Parameter(sfShader* shader, const char* name, float x, float y, float z, float w)
{
CSFML_CALL(shader, SetParameter(name, x, y, z, w))
}
////////////////////////////////////////////////////////////
/// Set a texture parameter in a shader
void sfShader_SetColorParameter(sfShader* shader, const char* name, sfColor color)
{
CSFML_CALL(shader, SetParameter(name, sf::Color(color.r, color.g, color.b, color.a)))
}
////////////////////////////////////////////////////////////
void sfShader_SetTexture(sfShader* shader, const char* name, const sfTexture* texture)
void sfShader_SetTransformParameter(sfShader* shader, const char* name, const sfTransform* transform)
{
CSFML_CALL(shader, SetParameter(name, transform ? transform->This : sf::Transform::Identity))
}
////////////////////////////////////////////////////////////
void sfShader_SetTextureParameter(sfShader* shader, const char* name, const sfTexture* texture)
{
CSFML_CHECK(texture);
CSFML_CALL(shader, SetTexture(name, *texture->This))
CSFML_CALL(shader, SetParameter(name, *texture->This))
}
////////////////////////////////////////////////////////////
/// Set the current texture parameter in a shader
////////////////////////////////////////////////////////////
void sfShader_SetCurrentTexture(sfShader* shader, const char* name)
void sfShader_SetCurrentTextureParameter(sfShader* shader, const char* name)
{
CSFML_CALL(shader, SetCurrentTexture(name))
CSFML_CALL(shader, SetParameter(name, sf::Shader::CurrentTexture))
}
////////////////////////////////////////////////////////////
/// Bind a shader for rendering
////////////////////////////////////////////////////////////
void sfShader_Bind(const sfShader* shader)
{
@@ -170,8 +210,6 @@ void sfShader_Bind(const sfShader* shader)
}
////////////////////////////////////////////////////////////
/// Unbind a shader
////////////////////////////////////////////////////////////
void sfShader_Unbind(const sfShader* shader)
{
@@ -179,8 +217,6 @@ void sfShader_Unbind(const sfShader* shader)
}
////////////////////////////////////////////////////////////
/// Tell whether or not the system supports shaders
////////////////////////////////////////////////////////////
sfBool sfShader_IsAvailable(void)
{
-469
View File
@@ -1,469 +0,0 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// 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.
//
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics/Shape.h>
#include <SFML/Graphics/ShapeStruct.h>
#include <SFML/Graphics/Color.hpp>
#include <SFML/Internal.h>
////////////////////////////////////////////////////////////
/// Create a new shape
////////////////////////////////////////////////////////////
sfShape* sfShape_Create(void)
{
return new sfShape;
}
////////////////////////////////////////////////////////////
/// Create a new shape made of a single line
////////////////////////////////////////////////////////////
sfShape* sfShape_CreateLine(float p1x, float p1y, float p2x, float p2y, float thickness, sfColor color, float outline, sfColor outlineColor)
{
sf::Color SFMLColor(color.r, color.g, color.b, color.a);
sf::Color SFMLOutlineColor(outlineColor.r, outlineColor.g, outlineColor.b, outlineColor.a);
sfShape* shape = new sfShape;
shape->This = sf::Shape::Line(p1x, p1y, p2x, p2y, thickness, SFMLColor, outline, SFMLOutlineColor);
return shape;
}
////////////////////////////////////////////////////////////
/// Create a new shape made of a single rectangle
////////////////////////////////////////////////////////////
sfShape* sfShape_CreateRectangle(float left, float top, float width, float height, sfColor color, float outline, sfColor outlineColor)
{
sf::Color SFMLColor(color.r, color.g, color.b, color.a);
sf::Color SFMLOutlineColor(outlineColor.r, outlineColor.g, outlineColor.b, outlineColor.a);
sfShape* shape = new sfShape;
shape->This = sf::Shape::Rectangle(left, top, width, height, SFMLColor, outline, SFMLOutlineColor);
return shape;
}
////////////////////////////////////////////////////////////
/// Create a new shape made of a single circle
////////////////////////////////////////////////////////////
sfShape* sfShape_CreateCircle(float x, float y, float radius, sfColor color, float outline, sfColor outlineColor)
{
sf::Color SFMLColor(color.r, color.g, color.b, color.a);
sf::Color SFMLOutlineColor(outlineColor.r, outlineColor.g, outlineColor.b, outlineColor.a);
sfShape* shape = new sfShape;
shape->This = sf::Shape::Circle(x, y, radius, SFMLColor, outline, SFMLOutlineColor);
return shape;
}
////////////////////////////////////////////////////////////
/// Copy an existing shape
////////////////////////////////////////////////////////////
sfShape* sfShape_Copy(sfShape* shape)
{
CSFML_CHECK_RETURN(shape, NULL);
return new sfShape(*shape);
}
////////////////////////////////////////////////////////////
/// Destroy an existing shape
////////////////////////////////////////////////////////////
void sfShape_Destroy(sfShape* shape)
{
delete shape;
}
////////////////////////////////////////////////////////////
/// Set the X position of a shape
////////////////////////////////////////////////////////////
void sfShape_SetX(sfShape* shape, float x)
{
CSFML_CALL(shape, SetX(x))
}
////////////////////////////////////////////////////////////
/// Set the Y position of a shape
////////////////////////////////////////////////////////////
void sfShape_SetY(sfShape* shape, float y)
{
CSFML_CALL(shape, SetY(y))
}
////////////////////////////////////////////////////////////
/// Set the position of a shape
////////////////////////////////////////////////////////////
void sfShape_SetPosition(sfShape* shape, float x, float y)
{
CSFML_CALL(shape, SetPosition(sf::Vector2f(x, y)))
}
////////////////////////////////////////////////////////////
/// Set the horizontal scale of a shape
////////////////////////////////////////////////////////////
void sfShape_SetScaleX(sfShape* shape, float scale)
{
CSFML_CALL(shape, SetScaleX(scale))
}
////////////////////////////////////////////////////////////
/// Set the vertical scale of a shape
////////////////////////////////////////////////////////////
void sfShape_SetScaleY(sfShape* shape, float scale)
{
CSFML_CALL(shape, SetScaleY(scale))
}
////////////////////////////////////////////////////////////
/// Set the scale of a shape
////////////////////////////////////////////////////////////
void sfShape_SetScale(sfShape* shape, float scaleX, float scaleY)
{
CSFML_CALL(shape, SetScale(sf::Vector2f(scaleX, scaleY)))
}
////////////////////////////////////////////////////////////
/// Set the orientation of a shape
////////////////////////////////////////////////////////////
void sfShape_SetRotation(sfShape* shape, float rotation)
{
CSFML_CALL(shape, SetRotation(rotation))
}
////////////////////////////////////////////////////////////
/// Set the local origin of a shape, in coordinates
/// relative to its left-top corner
////////////////////////////////////////////////////////////
void sfShape_SetOrigin(sfShape* shape, float x, float y)
{
CSFML_CALL(shape, SetOrigin(sf::Vector2f(x, y)))
}
////////////////////////////////////////////////////////////
/// Set the color of a shape
////////////////////////////////////////////////////////////
void sfShape_SetColor(sfShape* shape, sfColor color)
{
CSFML_CALL(shape, SetColor(sf::Color(color.r, color.g, color.b, color.a)))
}
////////////////////////////////////////////////////////////
/// Set the blending mode for a shape
////////////////////////////////////////////////////////////
void sfShape_SetBlendMode(sfShape* shape, sfBlendMode mode)
{
CSFML_CALL(shape, SetBlendMode(static_cast<sf::Blend::Mode>(mode)))
}
////////////////////////////////////////////////////////////
/// Get the X position of a shape
////////////////////////////////////////////////////////////
float sfShape_GetX(const sfShape* shape)
{
CSFML_CALL_RETURN(shape, GetPosition().x, 0.f)
}
////////////////////////////////////////////////////////////
/// Get the Y position of a shape
////////////////////////////////////////////////////////////
float sfShape_GetY(const sfShape* shape)
{
CSFML_CALL_RETURN(shape, GetPosition().y, 0.f)
}
////////////////////////////////////////////////////////////
/// Get the horizontal scale of a shape
////////////////////////////////////////////////////////////
float sfShape_GetScaleX(const sfShape* shape)
{
CSFML_CALL_RETURN(shape, GetScale().x, 0.f)
}
////////////////////////////////////////////////////////////
/// Get the vertical scale of a shape
////////////////////////////////////////////////////////////
float sfShape_GetScaleY(const sfShape* shape)
{
CSFML_CALL_RETURN(shape, GetScale().y, 0.f)
}
////////////////////////////////////////////////////////////
/// Get the orientation of a shape
////////////////////////////////////////////////////////////
float sfShape_GetRotation(const sfShape* shape)
{
CSFML_CALL_RETURN(shape, GetRotation(), 0.f)
}
////////////////////////////////////////////////////////////
/// Get the X position of the origin a shape
////////////////////////////////////////////////////////////
float sfShape_GetOriginX(const sfShape* shape)
{
CSFML_CALL_RETURN(shape, GetOrigin().x, 0.f)
}
////////////////////////////////////////////////////////////
/// Get the Y position of the origin a shape
////////////////////////////////////////////////////////////
float sfShape_GetOriginY(const sfShape* shape)
{
CSFML_CALL_RETURN(shape, GetOrigin().y, 0.f)
}
////////////////////////////////////////////////////////////
/// Get the color of a shape
////////////////////////////////////////////////////////////
sfColor sfShape_GetColor(const sfShape* shape)
{
sfColor color = {0, 0, 0, 0};
CSFML_CHECK_RETURN(shape, color)
sf::Color SFMLColor = shape->This.GetColor();
return sfColor_FromRGBA(SFMLColor.r, SFMLColor.g, SFMLColor.b, SFMLColor.a);
}
////////////////////////////////////////////////////////////
/// Get the current blending mode of a shape
////////////////////////////////////////////////////////////
sfBlendMode sfShape_GetBlendMode(const sfShape* shape)
{
CSFML_CHECK_RETURN(shape, sfBlendNone)
return static_cast<sfBlendMode>(shape->This.GetBlendMode());
}
////////////////////////////////////////////////////////////
/// Move a shape
////////////////////////////////////////////////////////////
void sfShape_Move(sfShape* shape, float offsetX, float offsetY)
{
CSFML_CALL(shape, Move(sf::Vector2f(offsetX, offsetY)))
}
////////////////////////////////////////////////////////////
/// Scale a shape
////////////////////////////////////////////////////////////
void sfShape_Scale(sfShape* shape, float factorX, float factorY)
{
CSFML_CALL(shape, Scale(sf::Vector2f(factorX, factorY)))
}
////////////////////////////////////////////////////////////
/// Rotate a shape
////////////////////////////////////////////////////////////
void sfShape_Rotate(sfShape* shape, float angle)
{
CSFML_CALL(shape, Rotate(angle))
}
////////////////////////////////////////////////////////////
/// Transform a point from global coordinates into the shape's local coordinates
/// (ie it applies the inverse of object's origin, translation, rotation and scale to the point)
////////////////////////////////////////////////////////////
void sfShape_TransformToLocal(const sfShape* shape, float pointX, float pointY, float* x, float* y)
{
CSFML_CHECK(shape)
sf::Vector2f point = shape->This.TransformToLocal(sf::Vector2f(pointX, pointY));
if (x) *x = point.x;
if (y) *y = point.y;
}
////////////////////////////////////////////////////////////
/// Transform a point from the shape's local coordinates into global coordinates
/// (ie it applies the object's origin, translation, rotation and scale to the point)
////////////////////////////////////////////////////////////
void sfShape_TransformToGlobal(const sfShape* shape, float pointX, float pointY, float* x, float* y)
{
CSFML_CHECK(shape)
sf::Vector2f point = shape->This.TransformToGlobal(sf::Vector2f(pointX, pointY));
if (x) *x = point.x;
if (y) *y = point.y;
}
////////////////////////////////////////////////////////////
/// Add a point to a shape
////////////////////////////////////////////////////////////
void sfShape_AddPoint(sfShape* shape, float x, float y, sfColor color, sfColor outlineColor)
{
sf::Color SFMLColor(color.r, color.g, color.b, color.a);
sf::Color SFMLOutlineColor(outlineColor.r, outlineColor.g, outlineColor.b, outlineColor.a);
CSFML_CALL(shape, AddPoint(x, y, SFMLColor, SFMLOutlineColor))
}
////////////////////////////////////////////////////////////
/// Enable or disable filling a shape.
/// Fill is enabled by default
////////////////////////////////////////////////////////////
void sfShape_EnableFill(sfShape* shape, sfBool enable)
{
CSFML_CALL(shape, EnableFill(enable == sfTrue))
}
////////////////////////////////////////////////////////////
/// Enable or disable drawing a shape outline.
/// Outline is enabled by default
////////////////////////////////////////////////////////////
void sfShape_EnableOutline(sfShape* shape, sfBool enable)
{
CSFML_CALL(shape, EnableOutline(enable == sfTrue))
}
////////////////////////////////////////////////////////////
/// Change the thickness of a shape outline
////////////////////////////////////////////////////////////
void sfShape_SetOutlineThickness(sfShape* shape, float thickness)
{
CSFML_CALL(shape, SetOutlineThickness(thickness))
}
////////////////////////////////////////////////////////////
/// Get the thickness of a shape outline
////////////////////////////////////////////////////////////
float sfShape_GetOutlineThickness(const sfShape* shape)
{
CSFML_CALL_RETURN(shape, GetOutlineThickness(), 0.f)
}
////////////////////////////////////////////////////////////
/// Get the number of points composing a shape
////////////////////////////////////////////////////////////
unsigned int sfShape_GetPointsCount(const sfShape* shape)
{
CSFML_CALL_RETURN(shape, GetPointsCount(), 0)
}
////////////////////////////////////////////////////////////
/// Get a point of a shape
////////////////////////////////////////////////////////////
void sfShape_GetPointPosition(const sfShape* shape, unsigned int index, float* x, float* y)
{
CSFML_CHECK(shape)
sf::Vector2f point = shape->This.GetPointPosition(index);
if (x) *x = point.x;
if (y) *y = point.y;
}
////////////////////////////////////////////////////////////
/// Get a the color of a shape's point
////////////////////////////////////////////////////////////
sfColor sfShape_GetPointColor(const sfShape* shape, unsigned int index)
{
sfColor color = {255, 255, 255, 255};
CSFML_CHECK_RETURN(shape, color)
const sf::Color& SFMLColor = shape->This.GetPointColor(index);
color.r = SFMLColor.r;
color.g = SFMLColor.g;
color.b = SFMLColor.b;
color.a = SFMLColor.a;
return color;
}
////////////////////////////////////////////////////////////
/// Get a the outline color of a shape's point
////////////////////////////////////////////////////////////
sfColor sfShape_GetPointOutlineColor(const sfShape* shape, unsigned int index)
{
sfColor color = {255, 255, 255, 255};
CSFML_CHECK_RETURN(shape, color)
const sf::Color& SFMLColor = shape->This.GetPointOutlineColor(index);
color.r = SFMLColor.r;
color.g = SFMLColor.g;
color.b = SFMLColor.b;
color.a = SFMLColor.a;
return color;
}
////////////////////////////////////////////////////////////
/// Set a the position of a shape's point
////////////////////////////////////////////////////////////
void sfShape_SetPointPosition(sfShape* shape, unsigned int index, float x, float y)
{
CSFML_CALL(shape, SetPointPosition(index, x, y));
}
////////////////////////////////////////////////////////////
/// Set a the color of a shape's point
////////////////////////////////////////////////////////////
void sfShape_SetPointColor(sfShape* shape, unsigned int index, sfColor color)
{
CSFML_CALL(shape, SetPointColor(index, sf::Color(color.r, color.g, color.b, color.a)));
}
////////////////////////////////////////////////////////////
/// Set a the outline color of a shape's point
////////////////////////////////////////////////////////////
void sfShape_SetPointOutlineColor(sfShape* shape, unsigned int index, sfColor color)
{
CSFML_CALL(shape, SetPointOutlineColor(index, sf::Color(color.r, color.g, color.b, color.a)));
}
+68 -220
View File
@@ -32,8 +32,6 @@
#include <SFML/Internal.h>
////////////////////////////////////////////////////////////
/// Create a new sprite
////////////////////////////////////////////////////////////
sfSprite* sfSprite_Create(void)
{
@@ -44,8 +42,6 @@ sfSprite* sfSprite_Create(void)
}
////////////////////////////////////////////////////////////
/// Copy an existing sprite
////////////////////////////////////////////////////////////
sfSprite* sfSprite_Copy(sfSprite* sprite)
{
@@ -55,8 +51,6 @@ sfSprite* sfSprite_Copy(sfSprite* sprite)
}
////////////////////////////////////////////////////////////
/// Destroy an existing sprite
////////////////////////////////////////////////////////////
void sfSprite_Destroy(sfSprite* sprite)
{
@@ -64,290 +58,149 @@ void sfSprite_Destroy(sfSprite* sprite)
}
////////////////////////////////////////////////////////////
/// Set the X position of a sprite
////////////////////////////////////////////////////////////
void sfSprite_SetX(sfSprite* sprite, float x)
{
CSFML_CALL(sprite, SetX(x))
}
////////////////////////////////////////////////////////////
/// Set the Y position of a sprite
////////////////////////////////////////////////////////////
void sfSprite_SetY(sfSprite* sprite, float y)
{
CSFML_CALL(sprite, SetY(y))
}
////////////////////////////////////////////////////////////
/// Set the position of a sprite
////////////////////////////////////////////////////////////
void sfSprite_SetPosition(sfSprite* sprite, float x, float y)
{
CSFML_CALL(sprite, SetPosition(sf::Vector2f(x, y)))
CSFML_CALL(sprite, SetPosition(x, y));
}
////////////////////////////////////////////////////////////
/// Set the horizontal scale of a sprite
////////////////////////////////////////////////////////////
void sfSprite_SetScaleX(sfSprite* sprite, float scale)
void sfSprite_SetRotation(sfSprite* sprite, float angle)
{
CSFML_CALL(sprite, SetScaleX(scale))
CSFML_CALL(sprite, SetRotation(angle));
}
////////////////////////////////////////////////////////////
/// Set the vertical scale of a sprite
////////////////////////////////////////////////////////////
void sfSprite_SetScaleY(sfSprite* sprite, float scale)
void sfSprite_SetScale(sfSprite* sprite, float factorX, float factorY)
{
CSFML_CALL(sprite, SetScaleY(scale))
CSFML_CALL(sprite, SetScale(factorX, factorY));
}
////////////////////////////////////////////////////////////
/// Set the scale of a sprite
////////////////////////////////////////////////////////////
void sfSprite_SetScale(sfSprite* sprite, float scaleX, float scaleY)
{
CSFML_CALL(sprite, SetScale(sf::Vector2f(scaleX, scaleY)))
}
////////////////////////////////////////////////////////////
/// Set the orientation of a sprite
////////////////////////////////////////////////////////////
void sfSprite_SetRotation(sfSprite* sprite, float rotation)
{
CSFML_CALL(sprite, SetRotation(rotation))
}
////////////////////////////////////////////////////////////
/// Set the local origin of a sprite, in coordinates
/// relative to its left-top corner
////////////////////////////////////////////////////////////
void sfSprite_SetOrigin(sfSprite* sprite, float x, float y)
{
CSFML_CALL(sprite, SetOrigin(sf::Vector2f(x, y)))
CSFML_CALL(sprite, SetOrigin(x, y));
}
////////////////////////////////////////////////////////////
/// Set the color of a sprite
////////////////////////////////////////////////////////////
void sfSprite_SetColor(sfSprite* sprite, sfColor color)
void sfSprite_GetPosition(const sfSprite* sprite, float* x, float* y)
{
CSFML_CALL(sprite, SetColor(sf::Color(color.r, color.g, color.b, color.a)))
CSFML_CHECK(sprite);
sf::Vector2f point = sprite->This.GetPosition();
if (x)
*x = point.x;
if (y)
*y = point.y;
}
////////////////////////////////////////////////////////////
/// Set the blending mode for a sprite
////////////////////////////////////////////////////////////
void sfSprite_SetBlendMode(sfSprite* sprite, sfBlendMode mode)
{
CSFML_CALL(sprite, SetBlendMode(static_cast<sf::Blend::Mode>(mode)))
}
////////////////////////////////////////////////////////////
/// Get the X position of a sprite
////////////////////////////////////////////////////////////
float sfSprite_GetX(const sfSprite* sprite)
{
CSFML_CALL_RETURN(sprite, GetPosition().x, 0.f)
}
////////////////////////////////////////////////////////////
/// Get the Y position of a sprite
////////////////////////////////////////////////////////////
float sfSprite_GetY(const sfSprite* sprite)
{
CSFML_CALL_RETURN(sprite, GetPosition().y, 0.f)
}
////////////////////////////////////////////////////////////
/// Get the horizontal scale of a sprite
////////////////////////////////////////////////////////////
float sfSprite_GetScaleX(const sfSprite* sprite)
{
CSFML_CALL_RETURN(sprite, GetScale().x, 0.f)
}
////////////////////////////////////////////////////////////
/// Get the vertical scale of a sprite
////////////////////////////////////////////////////////////
float sfSprite_GetScaleY(const sfSprite* sprite)
{
CSFML_CALL_RETURN(sprite, GetScale().y, 0.f)
}
////////////////////////////////////////////////////////////
/// Get the orientation of a sprite
////////////////////////////////////////////////////////////
float sfSprite_GetRotation(const sfSprite* sprite)
{
CSFML_CALL_RETURN(sprite, GetRotation(), 0.f)
CSFML_CALL_RETURN(sprite, GetRotation(), 0.f);
}
////////////////////////////////////////////////////////////
/// Get the X position of the origin a sprite
////////////////////////////////////////////////////////////
float sfSprite_GetOriginX(const sfSprite* sprite)
void sfSprite_GetScale(const sfSprite* sprite, float* x, float* y)
{
CSFML_CALL_RETURN(sprite, GetOrigin().x, 0.f)
CSFML_CHECK(sprite);
sf::Vector2f point = sprite->This.GetScale();
if (x)
*x = point.x;
if (y)
*y = point.y;
}
////////////////////////////////////////////////////////////
/// Get the Y position of the origin a sprite
////////////////////////////////////////////////////////////
float sfSprite_GetOriginY(const sfSprite* sprite)
void sfSprite_GetOrigin(const sfSprite* sprite, float* x, float* y)
{
CSFML_CALL_RETURN(sprite, GetOrigin().y, 0.f)
CSFML_CHECK(sprite);
sf::Vector2f point = sprite->This.GetOrigin();
if (x)
*x = point.x;
if (y)
*y = point.y;
}
////////////////////////////////////////////////////////////
/// Get the color of a sprite
////////////////////////////////////////////////////////////
sfColor sfSprite_GetColor(const sfSprite* sprite)
{
sfColor color = {0, 0, 0, 0};
CSFML_CHECK_RETURN(sprite, color)
sf::Color SFMLColor = sprite->This.GetColor();
return sfColor_FromRGBA(SFMLColor.r, SFMLColor.g, SFMLColor.b, SFMLColor.a);
}
////////////////////////////////////////////////////////////
/// Get the current blending mode of a sprite
////////////////////////////////////////////////////////////
sfBlendMode sfSprite_GetBlendMode(const sfSprite* sprite)
{
CSFML_CHECK_RETURN(sprite, sfBlendNone)
return static_cast<sfBlendMode>(sprite->This.GetBlendMode());
}
////////////////////////////////////////////////////////////
/// Move a sprite
////////////////////////////////////////////////////////////
void sfSprite_Move(sfSprite* sprite, float offsetX, float offsetY)
{
CSFML_CALL(sprite, Move(sf::Vector2f(offsetX, offsetY)))
CSFML_CALL(sprite, Move(offsetX, offsetY));
}
////////////////////////////////////////////////////////////
/// Scale a sprite
////////////////////////////////////////////////////////////
void sfSprite_Scale(sfSprite* sprite, float factorX, float factorY)
{
CSFML_CALL(sprite, Scale(sf::Vector2f(factorX, factorY)))
}
////////////////////////////////////////////////////////////
/// Rotate a sprite
////////////////////////////////////////////////////////////
void sfSprite_Rotate(sfSprite* sprite, float angle)
{
CSFML_CALL(sprite, Rotate(angle))
CSFML_CALL(sprite, Rotate(angle));
}
////////////////////////////////////////////////////////////
/// Transform a point from global coordinates into the sprite's local coordinates
/// (ie it applies the inverse of object's origin, translation, rotation and scale to the point)
////////////////////////////////////////////////////////////
void sfSprite_TransformToLocal(const sfSprite* sprite, float pointX, float pointY, float* x, float* y)
void sfSprite_Scale(sfSprite* sprite, float factorX, float factorY)
{
CSFML_CHECK(sprite)
sf::Vector2f point = sprite->This.TransformToLocal(sf::Vector2f(pointX, pointY));
if (x) *x = point.x;
if (y) *y = point.y;
CSFML_CALL(sprite, Scale(factorX, factorY));
}
////////////////////////////////////////////////////////////
/// Transform a point from the sprite's local coordinates into global coordinates
/// (ie it applies the object's origin, translation, rotation and scale to the point)
////////////////////////////////////////////////////////////
void sfSprite_TransformToGlobal(const sfSprite* sprite, float pointX, float pointY, float* x, float* y)
const sfTransform* sfSprite_GetTransform(const sfSprite* sprite)
{
CSFML_CHECK(sprite)
CSFML_CHECK_RETURN(sprite, NULL);
sf::Vector2f point = sprite->This.TransformToGlobal(sf::Vector2f(pointX, pointY));
if (x) *x = point.x;
if (y) *y = point.y;
sprite->Transform.This = sprite->This.GetTransform();
return &sprite->Transform;
}
////////////////////////////////////////////////////////////
/// Change the texture of a sprite
const sfTransform* sfSprite_GetInverseTransform(const sfSprite* sprite)
{
CSFML_CHECK_RETURN(sprite, NULL);
sprite->InverseTransform.This = sprite->This.GetInverseTransform();
return &sprite->InverseTransform;
}
////////////////////////////////////////////////////////////
void sfSprite_SetTexture(sfSprite* sprite, const sfTexture* texture, sfBool adjustToNewSize)
void sfSprite_SetTexture(sfSprite* sprite, const sfTexture* texture, sfBool resetRect)
{
if (texture && texture->This)
{
CSFML_CALL(sprite, SetTexture(*texture->This, adjustToNewSize == sfTrue))
CSFML_CALL(sprite, SetTexture(*texture->This, resetRect == sfTrue))
sprite->Texture = texture;
}
}
////////////////////////////////////////////////////////////
/// Set the sub-rectangle of a sprite inside the source image
////////////////////////////////////////////////////////////
void sfSprite_SetSubRect(sfSprite* sprite, sfIntRect rectangle)
void sfSprite_SetTextureRect(sfSprite* sprite, sfIntRect rectangle)
{
CSFML_CALL(sprite, SetSubRect(sf::IntRect(rectangle.Left, rectangle.Top, rectangle.Width, rectangle.Height)))
CSFML_CALL(sprite, SetTextureRect(sf::IntRect(rectangle.Left, rectangle.Top, rectangle.Width, rectangle.Height)))
}
////////////////////////////////////////////////////////////
/// Resize a sprite (by changing its scale factors)
////////////////////////////////////////////////////////////
void sfSprite_Resize(sfSprite* sprite, float width, float height)
void sfSprite_SetColor(sfSprite* sprite, sfColor color)
{
CSFML_CALL(sprite, Resize(sf::Vector2f(width, height)))
CSFML_CALL(sprite, SetColor(sf::Color(color.r, color.g, color.b, color.a)));
}
////////////////////////////////////////////////////////////
/// Flip a sprite horizontally
////////////////////////////////////////////////////////////
void sfSprite_FlipX(sfSprite* sprite, sfBool flipped)
{
CSFML_CALL(sprite, FlipX(flipped == sfTrue))
}
////////////////////////////////////////////////////////////
/// Flip a sprite vertically
////////////////////////////////////////////////////////////
void sfSprite_FlipY(sfSprite* sprite, sfBool flipped)
{
CSFML_CALL(sprite, FlipY(flipped == sfTrue))
}
////////////////////////////////////////////////////////////
/// Get the source texture of a sprite
////////////////////////////////////////////////////////////
const sfTexture* sfSprite_GetTexture(const sfSprite* sprite)
{
@@ -358,15 +211,12 @@ const sfTexture* sfSprite_GetTexture(const sfSprite* sprite)
////////////////////////////////////////////////////////////
/// Get the sub-rectangle of a sprite inside the source image
////////////////////////////////////////////////////////////
sfIntRect sfSprite_GetSubRect(const sfSprite* sprite)
sfIntRect sfSprite_GetTextureRect(const sfSprite* sprite)
{
sfIntRect rect = {0, 0, 0, 0};
CSFML_CHECK_RETURN(sprite, rect)
sf::IntRect sfmlRect = sprite->This.GetSubRect();
sf::IntRect sfmlRect = sprite->This.GetTextureRect();
rect.Left = sfmlRect.Left;
rect.Top = sfmlRect.Top;
rect.Width = sfmlRect.Width;
@@ -377,18 +227,16 @@ sfIntRect sfSprite_GetSubRect(const sfSprite* sprite)
////////////////////////////////////////////////////////////
/// Get a sprite width
////////////////////////////////////////////////////////////
float sfSprite_GetWidth(const sfSprite* sprite)
sfColor sfSprite_GetColor(const sfSprite* sprite)
{
CSFML_CALL_RETURN(sprite, GetSize().x, 0.f)
}
sfColor color = {0, 0, 0, 0};
CSFML_CHECK_RETURN(sprite, color);
sf::Color sfmlColor = sprite->This.GetColor();
color.r = sfmlColor.r;
color.g = sfmlColor.g;
color.b = sfmlColor.b;
color.a = sfmlColor.a;
////////////////////////////////////////////////////////////
/// Get a sprite height
////////////////////////////////////////////////////////////
float sfSprite_GetHeight(const sfSprite* sprite)
{
CSFML_CALL_RETURN(sprite, GetSize().y, 0.f)
return color;
}
+5 -2
View File
@@ -30,6 +30,7 @@
////////////////////////////////////////////////////////////
#include <SFML/Graphics/Sprite.hpp>
#include <SFML/Graphics/TextureStruct.h>
#include <SFML/Graphics/TransformStruct.h>
////////////////////////////////////////////////////////////
@@ -37,8 +38,10 @@
////////////////////////////////////////////////////////////
struct sfSprite
{
sf::Sprite This;
const sfTexture* Texture;
sf::Sprite This;
const sfTexture* Texture;
mutable sfTransform Transform;
mutable sfTransform InverseTransform;
};
+65 -226
View File
@@ -32,8 +32,6 @@
#include <SFML/Internal.h>
////////////////////////////////////////////////////////////
/// Create a new text
////////////////////////////////////////////////////////////
sfText* sfText_Create(void)
{
@@ -44,8 +42,6 @@ sfText* sfText_Create(void)
}
////////////////////////////////////////////////////////////
/// Copy an existing text
////////////////////////////////////////////////////////////
sfText* sfText_Copy(sfText* text)
{
@@ -55,8 +51,6 @@ sfText* sfText_Copy(sfText* text)
}
////////////////////////////////////////////////////////////
/// Destroy an existing text
////////////////////////////////////////////////////////////
void sfText_Destroy(sfText* text)
{
@@ -64,241 +58,124 @@ void sfText_Destroy(sfText* text)
}
////////////////////////////////////////////////////////////
/// Set the X position of a text
////////////////////////////////////////////////////////////
void sfText_SetX(sfText* text, float x)
{
CSFML_CALL(text, SetX(x))
}
////////////////////////////////////////////////////////////
/// Set the Y position of a text
////////////////////////////////////////////////////////////
void sfText_SetY(sfText* text, float y)
{
CSFML_CALL(text, SetY(y))
}
////////////////////////////////////////////////////////////
/// Set the position of a text
////////////////////////////////////////////////////////////
void sfText_SetPosition(sfText* text, float x, float y)
{
CSFML_CALL(text, SetPosition(sf::Vector2f(x, y)))
CSFML_CALL(text, SetPosition(x, y));
}
////////////////////////////////////////////////////////////
/// Set the horizontal scale of a text
////////////////////////////////////////////////////////////
void sfText_SetScaleX(sfText* text, float scale)
void sfText_SetRotation(sfText* text, float angle)
{
CSFML_CALL(text, SetScaleX(scale))
CSFML_CALL(text, SetRotation(angle));
}
////////////////////////////////////////////////////////////
/// Set the vertical scale of a text
////////////////////////////////////////////////////////////
void sfText_SetScaleY(sfText* text, float scale)
void sfText_SetScale(sfText* text, float factorX, float factorY)
{
CSFML_CALL(text, SetScaleY(scale))
CSFML_CALL(text, SetScale(factorX, factorY));
}
////////////////////////////////////////////////////////////
/// Set the scale of a text
////////////////////////////////////////////////////////////
void sfText_SetScale(sfText* text, float scaleX, float scaleY)
{
CSFML_CALL(text, SetScale(sf::Vector2f(scaleX, scaleY)))
}
////////////////////////////////////////////////////////////
/// Set the orientation of a text
////////////////////////////////////////////////////////////
void sfText_SetRotation(sfText* text, float rotation)
{
CSFML_CALL(text, SetRotation(rotation))
}
////////////////////////////////////////////////////////////
/// Set the local origin of a text, in coordinates
/// relative to its left-top corner
////////////////////////////////////////////////////////////
void sfText_SetOrigin(sfText* text, float x, float y)
{
CSFML_CALL(text, SetOrigin(sf::Vector2f(x, y)))
CSFML_CALL(text, SetOrigin(x, y));
}
////////////////////////////////////////////////////////////
/// Set the color of a text
////////////////////////////////////////////////////////////
void sfText_SetColor(sfText* text, sfColor color)
void sfText_GetPosition(const sfText* text, float* x, float* y)
{
CSFML_CALL(text, SetColor(sf::Color(color.r, color.g, color.b, color.a)))
CSFML_CHECK(text);
sf::Vector2f point = text->This.GetPosition();
if (x)
*x = point.x;
if (y)
*y = point.y;
}
////////////////////////////////////////////////////////////
/// Set the blending mode for a text
////////////////////////////////////////////////////////////
void sfText_SetBlendMode(sfText* text, sfBlendMode mode)
{
CSFML_CALL(text, SetBlendMode(static_cast<sf::Blend::Mode>(mode)))
}
////////////////////////////////////////////////////////////
/// Get the X position of a text
////////////////////////////////////////////////////////////
float sfText_GetX(const sfText* text)
{
CSFML_CALL_RETURN(text, GetPosition().x, 0.f)
}
////////////////////////////////////////////////////////////
/// Get the Y position of a text
////////////////////////////////////////////////////////////
float sfText_GetY(const sfText* text)
{
CSFML_CALL_RETURN(text, GetPosition().y, 0.f)
}
////////////////////////////////////////////////////////////
/// Get the horizontal scale of a text
////////////////////////////////////////////////////////////
float sfText_GetScaleX(const sfText* text)
{
CSFML_CALL_RETURN(text, GetScale().x, 0.f)
}
////////////////////////////////////////////////////////////
/// Get the vertical scale of a text
////////////////////////////////////////////////////////////
float sfText_GetScaleY(const sfText* text)
{
CSFML_CALL_RETURN(text, GetScale().y, 0.f)
}
////////////////////////////////////////////////////////////
/// Get the orientation of a text
////////////////////////////////////////////////////////////
float sfText_GetRotation(const sfText* text)
{
CSFML_CALL_RETURN(text, GetRotation(), 0.f)
CSFML_CALL_RETURN(text, GetRotation(), 0.f);
}
////////////////////////////////////////////////////////////
/// Get the X position of the origin a text
////////////////////////////////////////////////////////////
float sfText_GetOriginX(const sfText* text)
void sfText_GetScale(const sfText* text, float* x, float* y)
{
CSFML_CALL_RETURN(text, GetOrigin().x, 0.f)
CSFML_CHECK(text);
sf::Vector2f point = text->This.GetScale();
if (x)
*x = point.x;
if (y)
*y = point.y;
}
////////////////////////////////////////////////////////////
/// Get the top Y of the origin of a text
////////////////////////////////////////////////////////////
float sfText_GetOriginY(const sfText* text)
void sfText_GetOrigin(const sfText* text, float* x, float* y)
{
CSFML_CALL_RETURN(text, GetOrigin().y, 0.f)
CSFML_CHECK(text);
sf::Vector2f point = text->This.GetOrigin();
if (x)
*x = point.x;
if (y)
*y = point.y;
}
////////////////////////////////////////////////////////////
/// Get the color of a text
////////////////////////////////////////////////////////////
sfColor sfText_GetColor(const sfText* text)
{
sfColor color = {0, 0, 0, 0};
CSFML_CHECK_RETURN(text, color)
sf::Color SFMLColor = text->This.GetColor();
return sfColor_FromRGBA(SFMLColor.r, SFMLColor.g, SFMLColor.b, SFMLColor.a);
}
////////////////////////////////////////////////////////////
/// Get the current blending mode of a text
////////////////////////////////////////////////////////////
sfBlendMode sfText_GetBlendMode(const sfText* text)
{
CSFML_CHECK_RETURN(text, sfBlendNone)
return static_cast<sfBlendMode>(text->This.GetBlendMode());
}
////////////////////////////////////////////////////////////
/// Move a text
////////////////////////////////////////////////////////////
void sfText_Move(sfText* text, float offsetX, float offsetY)
{
CSFML_CALL(text, Move(sf::Vector2f(offsetX, offsetY)))
CSFML_CALL(text, Move(offsetX, offsetY));
}
////////////////////////////////////////////////////////////
/// Scale a text
////////////////////////////////////////////////////////////
void sfText_Scale(sfText* text, float factorX, float factorY)
{
CSFML_CALL(text, Scale(sf::Vector2f(factorX, factorY)))
}
////////////////////////////////////////////////////////////
/// Rotate a text
////////////////////////////////////////////////////////////
void sfText_Rotate(sfText* text, float angle)
{
CSFML_CALL(text, Rotate(angle))
CSFML_CALL(text, Rotate(angle));
}
////////////////////////////////////////////////////////////
/// Transform a point from global coordinates into the text's local coordinates
/// (ie it applies the inverse of object's origin, translation, rotation and scale to the point)
////////////////////////////////////////////////////////////
void sfText_TransformToLocal(const sfText* text, float pointX, float pointY, float* x, float* y)
void sfText_Scale(sfText* text, float factorX, float factorY)
{
CSFML_CHECK(text)
sf::Vector2f point = text->This.TransformToLocal(sf::Vector2f(pointX, pointY));
if (x) *x = point.x;
if (y) *y = point.y;
CSFML_CALL(text, Scale(factorX, factorY));
}
////////////////////////////////////////////////////////////
/// Transform a point from the text's local coordinates into global coordinates
/// (ie it applies the object's origin, translation, rotation and scale to the point)
////////////////////////////////////////////////////////////
void sfText_TransformToGlobal(const sfText* text, float pointX, float pointY, float* x, float* y)
const sfTransform* sfText_GetTransform(const sfText* text)
{
CSFML_CHECK(text)
CSFML_CHECK_RETURN(text, NULL);
sf::Vector2f point = text->This.TransformToGlobal(sf::Vector2f(pointX, pointY));
if (x) *x = point.x;
if (y) *y = point.y;
text->Transform.This = text->This.GetTransform();
return &text->Transform;
}
////////////////////////////////////////////////////////////
/// Set the string of a text (from a multibyte string)
const sfTransform* sfText_GetInverseTransform(const sfText* text)
{
CSFML_CHECK_RETURN(text, NULL);
text->InverseTransform.This = text->This.GetInverseTransform();
return &text->InverseTransform;
}
////////////////////////////////////////////////////////////
void sfText_SetString(sfText* text, const char* string)
{
@@ -306,8 +183,6 @@ void sfText_SetString(sfText* text, const char* string)
}
////////////////////////////////////////////////////////////
/// Set the string of a text (from a unicode string)
////////////////////////////////////////////////////////////
void sfText_SetUnicodeString(sfText* text, const sfUint32* string)
{
@@ -316,8 +191,6 @@ void sfText_SetUnicodeString(sfText* text, const sfUint32* string)
}
////////////////////////////////////////////////////////////
/// Set the font of a string
////////////////////////////////////////////////////////////
void sfText_SetFont(sfText* text, const sfFont* font)
{
@@ -328,8 +201,6 @@ void sfText_SetFont(sfText* text, const sfFont* font)
}
////////////////////////////////////////////////////////////
/// Set the size of a string
////////////////////////////////////////////////////////////
void sfText_SetCharacterSize(sfText* text, unsigned int size)
{
@@ -337,8 +208,6 @@ void sfText_SetCharacterSize(sfText* text, unsigned int size)
}
////////////////////////////////////////////////////////////
/// Set the style of a string
////////////////////////////////////////////////////////////
void sfText_SetStyle(sfText* text, sfUint32 style)
{
@@ -346,19 +215,6 @@ void sfText_SetStyle(sfText* text, sfUint32 style)
}
////////////////////////////////////////////////////////////
/// Get the string of a text (returns a unicode string)
////////////////////////////////////////////////////////////
const sfUint32* sfText_GetUnicodeString(const sfText* text)
{
CSFML_CHECK_RETURN(text, NULL)
return text->This.GetString().GetData();
}
////////////////////////////////////////////////////////////
/// Get the string of a text (returns an ANSI string)
////////////////////////////////////////////////////////////
const char* sfText_GetString(const sfText* text)
{
@@ -371,7 +227,14 @@ const char* sfText_GetString(const sfText* text)
////////////////////////////////////////////////////////////
/// Get the font used by a text
const sfUint32* sfText_GetUnicodeString(const sfText* text)
{
CSFML_CHECK_RETURN(text, NULL)
return text->This.GetString().GetData();
}
////////////////////////////////////////////////////////////
const sfFont* sfText_GetFont(const sfText* text)
{
@@ -381,8 +244,6 @@ const sfFont* sfText_GetFont(const sfText* text)
}
////////////////////////////////////////////////////////////
/// Get the size of the characters of a text
////////////////////////////////////////////////////////////
unsigned int sfText_GetCharacterSize(const sfText* text)
{
@@ -390,8 +251,6 @@ unsigned int sfText_GetCharacterSize(const sfText* text)
}
////////////////////////////////////////////////////////////
/// Get the style of a text
////////////////////////////////////////////////////////////
sfUint32 sfText_GetStyle(const sfText* text)
{
@@ -400,33 +259,13 @@ sfUint32 sfText_GetStyle(const sfText* text)
////////////////////////////////////////////////////////////
/// Return the visual position of the Index-th character of the text,
/// in coordinates relative to the text
/// (note : translation, origin, rotation and scale are not applied)
////////////////////////////////////////////////////////////
void sfText_GetCharacterPos(const sfText* text, size_t index, float* x, float* y)
void sfText_FindCharacterPos(const sfText* text, size_t index, float* x, float* y)
{
CSFML_CHECK(text);
sf::Vector2f pos = text->This.GetCharacterPos(index);
if (x) *x = pos.x;
if (y) *y = pos.y;
}
////////////////////////////////////////////////////////////
/// Get the bounding rectangle of a text on screen
////////////////////////////////////////////////////////////
sfFloatRect sfText_GetRect(const sfText* text)
{
sfFloatRect rect = {0.f, 0.f, 0.f, 0.f};
CSFML_CHECK_RETURN(text, rect)
sf::FloatRect SFMLRect = text->This.GetRect();
text->Rect.Left = SFMLRect.Left;
text->Rect.Top = SFMLRect.Top;
text->Rect.Width = SFMLRect.Width;
text->Rect.Height = SFMLRect.Height;
return text->Rect;
sf::Vector2f pos = text->This.FindCharacterPos(index);
if (x)
*x = pos.x;
if (y)
*y = pos.y;
}
+3 -1
View File
@@ -31,6 +31,7 @@
#include <SFML/Graphics/Text.hpp>
#include <SFML/Graphics/FontStruct.h>
#include <SFML/Graphics/Rect.h>
#include <SFML/Graphics/TransformStruct.h>
#include <string>
@@ -42,7 +43,8 @@ struct sfText
sf::Text This;
const sfFont* Font;
mutable std::string String;
mutable sfFloatRect Rect;
mutable sfTransform Transform;
mutable sfTransform InverseTransform;
};
+16 -37
View File
@@ -34,8 +34,6 @@
#include <SFML/CallbackStream.h>
////////////////////////////////////////////////////////////
/// Create a new texture
////////////////////////////////////////////////////////////
sfTexture* sfTexture_Create(unsigned int width, unsigned int height)
{
@@ -51,8 +49,6 @@ sfTexture* sfTexture_Create(unsigned int width, unsigned int height)
}
////////////////////////////////////////////////////////////
/// Create a new texture from a file
////////////////////////////////////////////////////////////
sfTexture* sfTexture_CreateFromFile(const char* filename, const sfIntRect* area)
{
@@ -72,8 +68,6 @@ sfTexture* sfTexture_CreateFromFile(const char* filename, const sfIntRect* area)
}
////////////////////////////////////////////////////////////
/// Create a new texture from a file in memory
////////////////////////////////////////////////////////////
sfTexture* sfTexture_CreateFromMemory(const void* data, size_t sizeInBytes, const sfIntRect* area)
{
@@ -93,8 +87,6 @@ sfTexture* sfTexture_CreateFromMemory(const void* data, size_t sizeInBytes, cons
}
////////////////////////////////////////////////////////////
/// Create a new texture from a custom stream
////////////////////////////////////////////////////////////
sfTexture* sfTexture_CreateFromStream(sfInputStream* stream, const sfIntRect* area)
{
@@ -117,8 +109,6 @@ sfTexture* sfTexture_CreateFromStream(sfInputStream* stream, const sfIntRect* ar
}
////////////////////////////////////////////////////////////
/// Create a new texture from an image
////////////////////////////////////////////////////////////
sfTexture* sfTexture_CreateFromImage(const sfImage* image, const sfIntRect* area)
{
@@ -140,8 +130,6 @@ sfTexture* sfTexture_CreateFromImage(const sfImage* image, const sfIntRect* area
}
////////////////////////////////////////////////////////////
/// Copy an existing texture
////////////////////////////////////////////////////////////
sfTexture* sfTexture_Copy(sfTexture* texture)
{
@@ -151,8 +139,6 @@ sfTexture* sfTexture_Copy(sfTexture* texture)
}
////////////////////////////////////////////////////////////
/// Destroy an existing texture
////////////////////////////////////////////////////////////
void sfTexture_Destroy(sfTexture* texture)
{
@@ -160,8 +146,6 @@ void sfTexture_Destroy(sfTexture* texture)
}
////////////////////////////////////////////////////////////
/// Return the width of the texture
////////////////////////////////////////////////////////////
unsigned int sfTexture_GetWidth(const sfTexture* texture)
{
@@ -169,8 +153,6 @@ unsigned int sfTexture_GetWidth(const sfTexture* texture)
}
////////////////////////////////////////////////////////////
/// Return the height of the texture
////////////////////////////////////////////////////////////
unsigned int sfTexture_GetHeight(const sfTexture* texture)
{
@@ -178,8 +160,6 @@ unsigned int sfTexture_GetHeight(const sfTexture* texture)
}
////////////////////////////////////////////////////////////
/// Copy a texture's pixels to an image
////////////////////////////////////////////////////////////
sfImage* sfTexture_CopyToImage(const sfTexture* texture)
{
@@ -193,8 +173,6 @@ sfImage* sfTexture_CopyToImage(const sfTexture* texture)
}
////////////////////////////////////////////////////////////
/// Update a texture from an array of pixels
////////////////////////////////////////////////////////////
void sfTexture_UpdateFromPixels(sfTexture* texture, const sfUint8* pixels, unsigned int width, unsigned int height, unsigned int x, unsigned int y)
{
@@ -202,8 +180,6 @@ void sfTexture_UpdateFromPixels(sfTexture* texture, const sfUint8* pixels, unsig
}
////////////////////////////////////////////////////////////
/// Update a texture from an image
////////////////////////////////////////////////////////////
void sfTexture_UpdateFromImage(sfTexture* texture, const sfImage* image, unsigned int x, unsigned int y)
{
@@ -213,8 +189,6 @@ void sfTexture_UpdateFromImage(sfTexture* texture, const sfImage* image, unsigne
}
////////////////////////////////////////////////////////////
/// Update a texture from the contents of a window
////////////////////////////////////////////////////////////
void sfTexture_UpdateFromWindow(sfTexture* texture, const sfWindow* window, unsigned int x, unsigned int y)
{
@@ -224,8 +198,6 @@ void sfTexture_UpdateFromWindow(sfTexture* texture, const sfWindow* window, unsi
}
////////////////////////////////////////////////////////////
/// Update a texture from the contents of a render-window
////////////////////////////////////////////////////////////
void sfTexture_UpdateFromRenderWindow(sfTexture* texture, const sfRenderWindow* renderWindow, unsigned int x, unsigned int y)
{
@@ -235,8 +207,6 @@ void sfTexture_UpdateFromRenderWindow(sfTexture* texture, const sfRenderWindow*
}
////////////////////////////////////////////////////////////
/// Activate a texture for rendering
////////////////////////////////////////////////////////////
void sfTexture_Bind(const sfTexture* texture)
{
@@ -244,8 +214,6 @@ void sfTexture_Bind(const sfTexture* texture)
}
////////////////////////////////////////////////////////////
/// Enable or disable the smooth filter on a texture
////////////////////////////////////////////////////////////
void sfTexture_SetSmooth(sfTexture* texture, sfBool smooth)
{
@@ -253,8 +221,6 @@ void sfTexture_SetSmooth(sfTexture* texture, sfBool smooth)
}
////////////////////////////////////////////////////////////
/// Tell whether the smooth filter is enabled or not for a texture
////////////////////////////////////////////////////////////
sfBool sfTexture_IsSmooth(const sfTexture* texture)
{
@@ -266,7 +232,22 @@ sfBool sfTexture_IsSmooth(const sfTexture* texture)
////////////////////////////////////////////////////////////
/// Convert a rectangle of pixels into texture coordinates
void sfTexture_SetRepeated(sfTexture* texture, sfBool repeated)
{
CSFML_CALL_PTR(texture, SetRepeated(repeated == sfTrue));
}
////////////////////////////////////////////////////////////
sfBool sfTexture_IsRepeated(const sfTexture* texture)
{
CSFML_CHECK_RETURN(texture, sfFalse);
CSFML_CHECK_RETURN(texture->This, sfFalse);
return texture->This->IsRepeated();
}
////////////////////////////////////////////////////////////
sfFloatRect sfTexture_GetTexCoords(const sfTexture* texture, sfIntRect rectangle)
{
@@ -286,8 +267,6 @@ sfFloatRect sfTexture_GetTexCoords(const sfTexture* texture, sfIntRect rectangle
}
////////////////////////////////////////////////////////////
/// Get the maximum texture size allowed
////////////////////////////////////////////////////////////
unsigned int sfTexture_GetMaximumSize()
{
+158
View File
@@ -0,0 +1,158 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// 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.
//
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics/Transform.h>
#include <SFML/Graphics/TransformStruct.h>
#include <SFML/Internal.h>
////////////////////////////////////////////////////////////
sfTransform* sfTransform_Create(void)
{
return new sfTransform;
}
////////////////////////////////////////////////////////////
sfTransform* sfTransform_CreateFromMatrix(float a00, float a01, float a02,
float a10, float a11, float a12,
float a20, float a21, float a22)
{
sfTransform* transform = new sfTransform;
transform->This = sf::Transform(a00, a01, a02, a10, a11, a12, a20, a21, a22);
return transform;
}
////////////////////////////////////////////////////////////
sfTransform* sfTransform_Copy(sfTransform* transform)
{
CSFML_CHECK_RETURN(transform, NULL);
return new sfTransform(*transform);
}
////////////////////////////////////////////////////////////
void sfTransform_Destroy(sfTransform* transform)
{
delete transform;
}
////////////////////////////////////////////////////////////
const float* sfTransform_GetMatrix(const sfTransform* transform)
{
CSFML_CALL_RETURN(transform, GetMatrix(), NULL);
}
////////////////////////////////////////////////////////////
void sfTransform_GetInverse(const sfTransform* transform, sfTransform* result)
{
CSFML_CHECK(transform);
if (result)
result->This = transform->This.GetInverse();
}
////////////////////////////////////////////////////////////
void sfTransform_TransformPoint(const sfTransform* transform, float x, float y, float* transformedX, float* transformedY)
{
CSFML_CHECK(transform);
sf::Vector2f point = transform->This.TransformPoint(x, y);
if (transformedX)
*transformedX = point.x;
if (transformedY)
*transformedY = point.y;
}
////////////////////////////////////////////////////////////
void sfTransform_TransformRect(const sfTransform* transform, sfFloatRect rectangle, sfFloatRect* transformedRectangle)
{
CSFML_CHECK(transform);
sf::FloatRect rect = transform->This.TransformRect(sf::FloatRect(rectangle.Left, rectangle.Top, rectangle.Width, rectangle.Height));
if (transformedRectangle)
{
transformedRectangle->Left = rect.Left;
transformedRectangle->Top = rect.Top;
transformedRectangle->Width = rect.Width;
transformedRectangle->Height = rect.Height;
}
}
////////////////////////////////////////////////////////////
void sfTransform_Combine(const sfTransform* left, const sfTransform* right, sfTransform* result)
{
CSFML_CHECK(left);
CSFML_CHECK(right);
if (result)
result->This = left->This.Combine(right->This);
}
////////////////////////////////////////////////////////////
void sfTransform_Translate(sfTransform* transform, float x, float y)
{
CSFML_CALL(transform, Translate(x, y));
}
////////////////////////////////////////////////////////////
void sfTransform_Rotate(sfTransform* transform, float angle)
{
CSFML_CALL(transform, Rotate(angle));
}
////////////////////////////////////////////////////////////
void sfTransform_RotateWithCenter(sfTransform* transform, float angle, float centerX, float centerY)
{
CSFML_CALL(transform, Rotate(angle, centerX, centerY));
}
////////////////////////////////////////////////////////////
void sfTransform_Scale(sfTransform* transform, float scaleX, float scaleY)
{
CSFML_CALL(transform, Scale(scaleX, scaleY));
}
////////////////////////////////////////////////////////////
void sfTransform_ScaleWithCenter(sfTransform* transform, float scaleX, float scaleY, float centerX, float centerY)
{
CSFML_CALL(transform, Scale(scaleX, scaleY, centerX, centerY));
}
@@ -22,22 +22,22 @@
//
////////////////////////////////////////////////////////////
#ifndef SFML_SHAPESTRUCT_H
#define SFML_SHAPESTRUCT_H
#ifndef SFML_TRANSFORMSTRUCT_H
#define SFML_TRANSFORMSTRUCT_H
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics/Shape.hpp>
#include <SFML/Graphics/Transform.hpp>
////////////////////////////////////////////////////////////
// Internal structure of sfShape
// Internal structure of sfTransform
////////////////////////////////////////////////////////////
struct sfShape
struct sfTransform
{
sf::Shape This;
sf::Transform This;
};
#endif // SFML_SHAPESTRUCT_H
#endif // SFML_TRANSFORMSTRUCT_H
+121
View File
@@ -0,0 +1,121 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// 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.
//
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics/VertexArray.h>
#include <SFML/Graphics/VertexArrayStruct.h>
#include <SFML/Internal.h>
////////////////////////////////////////////////////////////
sfVertexArray* sfVertexArray_Create(void)
{
return new sfVertexArray;
}
////////////////////////////////////////////////////////////
sfVertexArray* sfTransform_Copy(sfVertexArray* vertexArray)
{
CSFML_CHECK_RETURN(vertexArray, NULL);
return new sfVertexArray(*vertexArray);
}
////////////////////////////////////////////////////////////
void sfVertexArray_Destroy(sfVertexArray* vertexArray)
{
delete vertexArray;
}
////////////////////////////////////////////////////////////
unsigned int sfVertexArray_GetVertexCount(const sfVertexArray* vertexArray)
{
CSFML_CALL_RETURN(vertexArray, GetVertexCount(), 0);
}
////////////////////////////////////////////////////////////
sfVertex* sfVertexArray_At(sfVertexArray* vertexArray, unsigned int index)
{
CSFML_CHECK_RETURN(vertexArray, NULL);
// the cast is safe, sfVertex has to be binary compatible with sf::Vertex
return reinterpret_cast<sfVertex*>(&vertexArray->This[index]);
}
////////////////////////////////////////////////////////////
void sfVertexArray_Clear(sfVertexArray* vertexArray)
{
CSFML_CALL(vertexArray, Clear());
}
////////////////////////////////////////////////////////////
void sfVertexArray_Resize(sfVertexArray* vertexArray, unsigned int vertexCount)
{
CSFML_CALL(vertexArray, Resize(vertexCount));
}
////////////////////////////////////////////////////////////
void sfVertexArray_Append(sfVertexArray* vertexArray, sfVertex vertex)
{
// the cast is safe, sfVertex has to be binary compatible with sf::Vertex
CSFML_CALL(vertexArray, Append(reinterpret_cast<sf::Vertex&>(vertex)));
}
////////////////////////////////////////////////////////////
void sfVertexArray_SetPrimitiveType(sfVertexArray* vertexArray, sfPrimitiveType type)
{
CSFML_CALL(vertexArray, SetPrimitiveType(static_cast<sf::PrimitiveType>(type)));
}
////////////////////////////////////////////////////////////
sfPrimitiveType sfVertexArray_GetPrimitiveType(sfVertexArray* vertexArray)
{
CSFML_CHECK_RETURN(vertexArray, sfPoints);
return static_cast<sfPrimitiveType>(vertexArray->This.GetPrimitiveType());
}
////////////////////////////////////////////////////////////
sfFloatRect sfVertexArray_GetBounds(sfVertexArray* vertexArray)
{
sfFloatRect rect = {0, 0, 0, 0};
CSFML_CHECK_RETURN(vertexArray, rect);
sf::FloatRect sfmlRect = vertexArray->This.GetBounds();
rect.Left = sfmlRect.Left;
rect.Top = sfmlRect.Top;
rect.Width = sfmlRect.Width;
rect.Height = sfmlRect.Height;
}
+43
View File
@@ -0,0 +1,43 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// 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 SFML_VERTEXARRAYSTRUCT_H
#define SFML_VERTEXARRAYSTRUCT_H
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics/VertexArray.hpp>
////////////////////////////////////////////////////////////
// Internal structure of sfVertexArray
////////////////////////////////////////////////////////////
struct sfVertexArray
{
sf::VertexArray This;
};
#endif // SFML_VERTEXARRAYSTRUCT_H
+2 -9
View File
@@ -92,9 +92,9 @@ void sfWindow_Close(sfWindow* window)
////////////////////////////////////////////////////////////
sfBool sfWindow_IsOpened(const sfWindow* window)
sfBool sfWindow_IsOpen(const sfWindow* window)
{
CSFML_CALL_RETURN(window, IsOpened(), sfFalse);
CSFML_CALL_RETURN(window, IsOpen(), sfFalse);
}
@@ -248,13 +248,6 @@ void sfWindow_SetFramerateLimit(sfWindow* window, unsigned int limit)
}
////////////////////////////////////////////////////////////
sfUint32 sfWindow_GetFrameTime(const sfWindow* window)
{
CSFML_CALL_RETURN(window, GetFrameTime(), 0)
}
////////////////////////////////////////////////////////////
void sfWindow_SetJoystickThreshold(sfWindow* window, float threshold)
{