Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement isSrgb #309

Merged
merged 1 commit into from
Jul 28, 2023
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
5 changes: 5 additions & 0 deletions CSFML/src/Graphics/RenderTexture.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "Graphics/Rect.h"
#include "Graphics/Vertex.h"
#include <SFML/Graphics/RenderTarget.hpp>
#include <SFML/Graphics/CircleShape.hpp>
#include <SFML/Graphics/ConvexShape.hpp>
#include <SFML/Graphics/RectangleShape.hpp>
Expand All @@ -23,6 +24,10 @@ extern "C" sfVector2u sfRenderTexture_getSize(const sf::RenderTexture *renderTex
return {size.x, size.y};
}

extern "C" bool sfRenderTexture_isSrgb(const sf::RenderTarget *renderTexture) {
return renderTexture->isSrgb();
}

extern "C" bool sfRenderTexture_setActive(sf::RenderTexture *renderTexture, bool active) {
return renderTexture->setActive(active);
}
Expand Down
5 changes: 5 additions & 0 deletions CSFML/src/Graphics/RenderWindow.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "Graphics/Rect.h"
#include "Graphics/Vertex.h"
#include "Window/VideoMode.h"
#include <SFML/Graphics/RenderTarget.hpp>
#include <SFML/Graphics/CircleShape.hpp>
#include <SFML/Graphics/ConvexShape.hpp>
#include <SFML/Graphics/RectangleShape.hpp>
Expand Down Expand Up @@ -72,6 +73,10 @@ extern "C" void sfRenderWindow_setSize(sf::RenderWindow *renderWindow, sfVector2
renderWindow->setSize(sf::Vector2u(size.x, size.y));
}

extern "C" bool sfRenderWindow_isSrgb(const sf::RenderWindow *renderWindow) {
return renderWindow->isSrgb();
}

extern "C" void sfRenderWindow_setUnicodeTitle(sf::RenderWindow *renderWindow, const uint32_t *title) {
renderWindow->setTitle(title);
}
Expand Down
2 changes: 2 additions & 0 deletions src/ffi/graphics_bindgen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ pub fn sfRectangleShape_getGlobalBounds(shape: *const sfRectangleShape) -> sfFlo
pub fn sfRenderTexture_createWithSettings(width: c_uint, height: c_uint, settings: *const sfContextSettings) -> *mut sfRenderTexture;
pub fn sfRenderTexture_destroy(renderTexture: *mut sfRenderTexture);
pub fn sfRenderTexture_getSize(renderTexture: *const sfRenderTexture) -> sfVector2u;
pub fn sfRenderTexture_isSrgb(renderTexture: *const sfRenderTexture) -> bool;
pub fn sfRenderTexture_setActive(renderTexture: *mut sfRenderTexture, active: bool) -> bool;
pub fn sfRenderTexture_display(renderTexture: *mut sfRenderTexture);
pub fn sfRenderTexture_clear(renderTexture: *mut sfRenderTexture, color: sfColor);
Expand Down Expand Up @@ -183,6 +184,7 @@ pub fn sfRenderWindow_getPosition(renderWindow: *const sfRenderWindow) -> sfVect
pub fn sfRenderWindow_setPosition(renderWindow: *mut sfRenderWindow, position: sfVector2i);
pub fn sfRenderWindow_getSize(renderWindow: *const sfRenderWindow) -> sfVector2u;
pub fn sfRenderWindow_setSize(renderWindow: *mut sfRenderWindow, size: sfVector2u);
pub fn sfRenderWindow_isSrgb(renderWindow: *const sfRenderWindow) -> bool;
pub fn sfRenderWindow_setUnicodeTitle(renderWindow: *mut sfRenderWindow, title: *const u32);
pub fn sfRenderWindow_setIcon(renderWindow: *mut sfRenderWindow, width: c_uint, height: c_uint, pixels: *const u8);
pub fn sfRenderWindow_setVisible(renderWindow: *mut sfRenderWindow, visible: bool);
Expand Down
8 changes: 8 additions & 0 deletions src/graphics/render_texture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ impl RenderTexture {
unsafe { ffi::sfRenderTexture_display(self.render_texture) }
}

/// Tell if the render texture will use sRGB encoding when drawing it
///
/// Returns true if sRGB encoding is enabled, false if sRGB encoding is disabled
#[must_use]
pub fn is_srgb(&self) -> bool {
unsafe { ffi::sfRenderTexture_isSrgb(self.render_texture) }
}

/// Activate or deactivate a render texture as the current target for rendering
///
/// # Arguments
Expand Down
8 changes: 8 additions & 0 deletions src/graphics/render_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,14 @@ impl RenderWindow {
unsafe { &*ffi::sfRenderWindow_getSettings(self.render_window.as_ptr()) }
}

/// Tell if the render texture will use sRGB encoding when drawing it
///
/// Returns true if sRGB encoding is enabled, false if sRGB encoding is disabled
#[must_use]
pub fn is_srgb(&self) -> bool {
unsafe { ffi::sfRenderWindow_isSrgb(self.render_window.as_ptr()) }
}

/// Change the title of a window
///
/// # Arguments
Expand Down
Loading