Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions include/CSFML/Graphics/CoordinateType.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
//
// 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.
//
////////////////////////////////////////////////////////////

#pragma once

////////////////////////////////////////////////////////////
/// \brief Types of texture coordinates that can be used for rendering.
///
////////////////////////////////////////////////////////////
typedef enum
{
sfCoordinateTypeNormalized, ///< sfTexture coordinates in range [0 .. 1].
sfCoordinateTypePixels ///< sfTexture coordinates in range [0 .. size].
} sfCoordinateType;
12 changes: 8 additions & 4 deletions include/CSFML/Graphics/RenderStates.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
#include <CSFML/Graphics/Export.h>

#include <CSFML/Graphics/BlendMode.h>
#include <CSFML/Graphics/CoordinateType.h>
#include <CSFML/Graphics/StencilMode.h>
#include <CSFML/Graphics/Transform.h>
#include <CSFML/Graphics/Types.h>

Expand All @@ -40,10 +42,12 @@
////////////////////////////////////////////////////////////
typedef struct
{
sfBlendMode blendMode; ///< Blending mode
sfTransform transform; ///< Transform
const sfTexture* texture; ///< Texture
const sfShader* shader; ///< Shader
sfBlendMode blendMode; ///< Blending mode
sfStencilMode stencilMode; //!< Stencil mode
sfTransform transform; ///< Transform
sfCoordinateType coordinateType; //!< Texture coordinate type
const sfTexture* texture; ///< Texture
const sfShader* shader; ///< Shader
} sfRenderStates;

////////////////////////////////////////////////////////////
Expand Down
13 changes: 2 additions & 11 deletions include/CSFML/Graphics/Texture.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
////////////////////////////////////////////////////////////
#include <CSFML/Graphics/Export.h>

#include <CSFML/Graphics/CoordinateType.h>
#include <CSFML/Graphics/Rect.h>
#include <CSFML/Graphics/Types.h>
#include <CSFML/System/InputStream.h>
Expand All @@ -37,16 +38,6 @@

#include <stddef.h>

////////////////////////////////////////////////////////////
/// \brief Types of texture coordinates that can be used for rendering.
///
////////////////////////////////////////////////////////////
typedef enum
{
sfTextureNormalized, ///< sfTexture coordinates in range [0 .. 1].
sfTexturePixels ///< sfTexture coordinates in range [0 .. size].
} sfTextureCoordinateType;

////////////////////////////////////////////////////////////
/// \brief Create a new texture
///
Expand Down Expand Up @@ -400,7 +391,7 @@ CSFML_GRAPHICS_API unsigned int sfTexture_getNativeHandle(const sfTexture* textu
/// \param type Type of texture coordinates to use
///
////////////////////////////////////////////////////////////
CSFML_GRAPHICS_API void sfTexture_bind(const sfTexture* texture, sfTextureCoordinateType type);
CSFML_GRAPHICS_API void sfTexture_bind(const sfTexture* texture, sfCoordinateType type);

////////////////////////////////////////////////////////////
/// \brief Get the maximum texture size allowed
Expand Down
1 change: 1 addition & 0 deletions src/CSFML/Graphics/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ set(SRC
${SRCROOT}/ConvexShape.cpp
${SRCROOT}/ConvexShapeStruct.hpp
${INCROOT}/ConvexShape.h
${INCROOT}/CoordinateType.h
${SRCROOT}/Font.cpp
${SRCROOT}/FontStruct.hpp
${INCROOT}/Font.h
Expand Down
25 changes: 16 additions & 9 deletions src/CSFML/Graphics/ConvertRenderStates.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,21 @@
return {};

sf::RenderStates renderStates;
renderStates.blendMode.colorSrcFactor = static_cast<sf::BlendMode::Factor>(states->blendMode.colorSrcFactor);
renderStates.blendMode.colorDstFactor = static_cast<sf::BlendMode::Factor>(states->blendMode.colorDstFactor);
renderStates.blendMode.colorEquation = static_cast<sf::BlendMode::Equation>(states->blendMode.colorEquation);
renderStates.blendMode.alphaSrcFactor = static_cast<sf::BlendMode::Factor>(states->blendMode.alphaSrcFactor);
renderStates.blendMode.alphaDstFactor = static_cast<sf::BlendMode::Factor>(states->blendMode.alphaDstFactor);
renderStates.blendMode.alphaEquation = static_cast<sf::BlendMode::Equation>(states->blendMode.alphaEquation);
renderStates.transform = convertTransform(states->transform);
renderStates.texture = states->texture ? states->texture->This : nullptr;
renderStates.shader = states->shader;
renderStates.blendMode.colorSrcFactor = static_cast<sf::BlendMode::Factor>(states->blendMode.colorSrcFactor);
renderStates.blendMode.colorDstFactor = static_cast<sf::BlendMode::Factor>(states->blendMode.colorDstFactor);
renderStates.blendMode.colorEquation = static_cast<sf::BlendMode::Equation>(states->blendMode.colorEquation);
renderStates.blendMode.alphaSrcFactor = static_cast<sf::BlendMode::Factor>(states->blendMode.alphaSrcFactor);
renderStates.blendMode.alphaDstFactor = static_cast<sf::BlendMode::Factor>(states->blendMode.alphaDstFactor);
renderStates.blendMode.alphaEquation = static_cast<sf::BlendMode::Equation>(states->blendMode.alphaEquation);
renderStates.stencilMode.stencilComparison = static_cast<sf::StencilComparison>(states->stencilMode.stencilComparison);
renderStates.stencilMode.stencilUpdateOperation = static_cast<sf::StencilUpdateOperation>(
states->stencilMode.stencilUpdateOperation);
renderStates.stencilMode.stencilReference.value = states->stencilMode.stencilReference.value;
renderStates.stencilMode.stencilMask.value = states->stencilMode.stencilMask.value;
renderStates.stencilMode.stencilOnly = states->stencilMode.stencilOnly;
renderStates.transform = convertTransform(states->transform);
renderStates.coordinateType = static_cast<sf::CoordinateType>(states->coordinateType);
renderStates.texture = states->texture ? states->texture->This : nullptr;
renderStates.shader = states->shader;
return renderStates;
}
2 changes: 2 additions & 0 deletions src/CSFML/Graphics/RenderStates.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
////////////////////////////////////////////////////////////
const sfRenderStates sfRenderStates_default = {
sfBlendAlpha,
sfStencilMode_default,
sfTransform_Identity,
sfCoordinateTypePixels,
nullptr,
nullptr,
};
2 changes: 1 addition & 1 deletion src/CSFML/Graphics/Texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ unsigned int sfTexture_getNativeHandle(const sfTexture* texture)


////////////////////////////////////////////////////////////
void sfTexture_bind(const sfTexture* texture, sfTextureCoordinateType type)
void sfTexture_bind(const sfTexture* texture, sfCoordinateType type)
{
sf::Texture::bind(texture ? texture->This : nullptr, static_cast<sf::CoordinateType>(type));
}
Expand Down