Skip to content

Commit fd8e6a0

Browse files
MarioalexsanChrisThrasher
authored andcommitted
Align sfRenderStates with sf::RenderStates
1 parent 884dcde commit fd8e6a0

File tree

7 files changed

+65
-25
lines changed

7 files changed

+65
-25
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
////////////////////////////////////////////////////////////
2+
//
3+
// SFML - Simple and Fast Multimedia Library
4+
// Copyright (C) 2007-2024 Laurent Gomila ([email protected])
5+
//
6+
// This software is provided 'as-is', without any express or implied warranty.
7+
// In no event will the authors be held liable for any damages arising from the use of this software.
8+
//
9+
// Permission is granted to anyone to use this software for any purpose,
10+
// including commercial applications, and to alter it and redistribute it freely,
11+
// subject to the following restrictions:
12+
//
13+
// 1. The origin of this software must not be misrepresented;
14+
// you must not claim that you wrote the original software.
15+
// If you use this software in a product, an acknowledgment
16+
// in the product documentation would be appreciated but is not required.
17+
//
18+
// 2. Altered source versions must be plainly marked as such,
19+
// and must not be misrepresented as being the original software.
20+
//
21+
// 3. This notice may not be removed or altered from any source distribution.
22+
//
23+
////////////////////////////////////////////////////////////
24+
25+
#pragma once
26+
27+
////////////////////////////////////////////////////////////
28+
/// \brief Types of texture coordinates that can be used for rendering.
29+
///
30+
////////////////////////////////////////////////////////////
31+
typedef enum
32+
{
33+
sfCoordinateTypeNormalized, ///< sfTexture coordinates in range [0 .. 1].
34+
sfCoordinateTypePixels ///< sfTexture coordinates in range [0 .. size].
35+
} sfCoordinateType;

include/CSFML/Graphics/RenderStates.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
#include <CSFML/Graphics/Export.h>
3131

3232
#include <CSFML/Graphics/BlendMode.h>
33+
#include <CSFML/Graphics/CoordinateType.h>
34+
#include <CSFML/Graphics/StencilMode.h>
3335
#include <CSFML/Graphics/Transform.h>
3436
#include <CSFML/Graphics/Types.h>
3537

@@ -40,10 +42,12 @@
4042
////////////////////////////////////////////////////////////
4143
typedef struct
4244
{
43-
sfBlendMode blendMode; ///< Blending mode
44-
sfTransform transform; ///< Transform
45-
const sfTexture* texture; ///< Texture
46-
const sfShader* shader; ///< Shader
45+
sfBlendMode blendMode; ///< Blending mode
46+
sfStencilMode stencilMode; //!< Stencil mode
47+
sfTransform transform; ///< Transform
48+
sfCoordinateType coordinateType; //!< Texture coordinate type
49+
const sfTexture* texture; ///< Texture
50+
const sfShader* shader; ///< Shader
4751
} sfRenderStates;
4852

4953
////////////////////////////////////////////////////////////

include/CSFML/Graphics/Texture.h

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
////////////////////////////////////////////////////////////
3030
#include <CSFML/Graphics/Export.h>
3131

32+
#include <CSFML/Graphics/CoordinateType.h>
3233
#include <CSFML/Graphics/Rect.h>
3334
#include <CSFML/Graphics/Types.h>
3435
#include <CSFML/System/InputStream.h>
@@ -37,16 +38,6 @@
3738

3839
#include <stddef.h>
3940

40-
////////////////////////////////////////////////////////////
41-
/// \brief Types of texture coordinates that can be used for rendering.
42-
///
43-
////////////////////////////////////////////////////////////
44-
typedef enum
45-
{
46-
sfTextureNormalized, ///< sfTexture coordinates in range [0 .. 1].
47-
sfTexturePixels ///< sfTexture coordinates in range [0 .. size].
48-
} sfTextureCoordinateType;
49-
5041
////////////////////////////////////////////////////////////
5142
/// \brief Create a new texture
5243
///
@@ -400,7 +391,7 @@ CSFML_GRAPHICS_API unsigned int sfTexture_getNativeHandle(const sfTexture* textu
400391
/// \param type Type of texture coordinates to use
401392
///
402393
////////////////////////////////////////////////////////////
403-
CSFML_GRAPHICS_API void sfTexture_bind(const sfTexture* texture, sfTextureCoordinateType type);
394+
CSFML_GRAPHICS_API void sfTexture_bind(const sfTexture* texture, sfCoordinateType type);
404395

405396
////////////////////////////////////////////////////////////
406397
/// \brief Get the maximum texture size allowed

src/CSFML/Graphics/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ set(SRC
1919
${SRCROOT}/ConvexShape.cpp
2020
${SRCROOT}/ConvexShapeStruct.hpp
2121
${INCROOT}/ConvexShape.h
22+
${INCROOT}/CoordinateType.h
2223
${SRCROOT}/Font.cpp
2324
${SRCROOT}/FontStruct.hpp
2425
${INCROOT}/Font.h

src/CSFML/Graphics/ConvertRenderStates.hpp

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,21 @@
4444
return {};
4545

4646
sf::RenderStates renderStates;
47-
renderStates.blendMode.colorSrcFactor = static_cast<sf::BlendMode::Factor>(states->blendMode.colorSrcFactor);
48-
renderStates.blendMode.colorDstFactor = static_cast<sf::BlendMode::Factor>(states->blendMode.colorDstFactor);
49-
renderStates.blendMode.colorEquation = static_cast<sf::BlendMode::Equation>(states->blendMode.colorEquation);
50-
renderStates.blendMode.alphaSrcFactor = static_cast<sf::BlendMode::Factor>(states->blendMode.alphaSrcFactor);
51-
renderStates.blendMode.alphaDstFactor = static_cast<sf::BlendMode::Factor>(states->blendMode.alphaDstFactor);
52-
renderStates.blendMode.alphaEquation = static_cast<sf::BlendMode::Equation>(states->blendMode.alphaEquation);
53-
renderStates.transform = convertTransform(states->transform);
54-
renderStates.texture = states->texture ? states->texture->This : nullptr;
55-
renderStates.shader = states->shader;
47+
renderStates.blendMode.colorSrcFactor = static_cast<sf::BlendMode::Factor>(states->blendMode.colorSrcFactor);
48+
renderStates.blendMode.colorDstFactor = static_cast<sf::BlendMode::Factor>(states->blendMode.colorDstFactor);
49+
renderStates.blendMode.colorEquation = static_cast<sf::BlendMode::Equation>(states->blendMode.colorEquation);
50+
renderStates.blendMode.alphaSrcFactor = static_cast<sf::BlendMode::Factor>(states->blendMode.alphaSrcFactor);
51+
renderStates.blendMode.alphaDstFactor = static_cast<sf::BlendMode::Factor>(states->blendMode.alphaDstFactor);
52+
renderStates.blendMode.alphaEquation = static_cast<sf::BlendMode::Equation>(states->blendMode.alphaEquation);
53+
renderStates.stencilMode.stencilComparison = static_cast<sf::StencilComparison>(states->stencilMode.stencilComparison);
54+
renderStates.stencilMode.stencilUpdateOperation = static_cast<sf::StencilUpdateOperation>(
55+
states->stencilMode.stencilUpdateOperation);
56+
renderStates.stencilMode.stencilReference.value = states->stencilMode.stencilReference.value;
57+
renderStates.stencilMode.stencilMask.value = states->stencilMode.stencilMask.value;
58+
renderStates.stencilMode.stencilOnly = states->stencilMode.stencilOnly;
59+
renderStates.transform = convertTransform(states->transform);
60+
renderStates.coordinateType = static_cast<sf::CoordinateType>(states->coordinateType);
61+
renderStates.texture = states->texture ? states->texture->This : nullptr;
62+
renderStates.shader = states->shader;
5663
return renderStates;
5764
}

src/CSFML/Graphics/RenderStates.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@
3131
////////////////////////////////////////////////////////////
3232
const sfRenderStates sfRenderStates_default = {
3333
sfBlendAlpha,
34+
sfStencilMode_default,
3435
sfTransform_Identity,
36+
sfCoordinateTypePixels,
3537
nullptr,
3638
nullptr,
3739
};

src/CSFML/Graphics/Texture.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ unsigned int sfTexture_getNativeHandle(const sfTexture* texture)
299299

300300

301301
////////////////////////////////////////////////////////////
302-
void sfTexture_bind(const sfTexture* texture, sfTextureCoordinateType type)
302+
void sfTexture_bind(const sfTexture* texture, sfCoordinateType type)
303303
{
304304
sf::Texture::bind(texture ? texture->This : nullptr, static_cast<sf::CoordinateType>(type));
305305
}

0 commit comments

Comments
 (0)