mirror of
https://github.com/SFML/CSFML.git
synced 2026-10-24 21:53:37 +02:00
Align sfRenderStates with sf::RenderStates
This commit is contained in:
1 parent
884dcde3c3
commit
fd8e6a0364
7 files changed
+65
-25
No files matched your search
@@ -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;
|
||||
@@ -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>
|
||||
|
||||
@@ -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;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -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>
|
||||
@@ -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
|
||||
///
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -31,7 +31,9 @@
|
||||
////////////////////////////////////////////////////////////
|
||||
const sfRenderStates sfRenderStates_default = {
|
||||
sfBlendAlpha,
|
||||
sfStencilMode_default,
|
||||
sfTransform_Identity,
|
||||
sfCoordinateTypePixels,
|
||||
nullptr,
|
||||
nullptr,
|
||||
};
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user