mirror of
https://github.com/SFML/SFML.git
synced 2024-11-25 04:41:05 +08:00
Strategic use of '[[nodiscard]]' in 'Graphics' module
This commit is contained in:
parent
d02d3590fd
commit
363e964acc
@ -10,13 +10,15 @@
|
|||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// Initialize OpenGL states into the specified view
|
/// Initialize OpenGL states into the specified view
|
||||||
///
|
///
|
||||||
/// \param Window Target window to initialize
|
/// \param Window Target window to initialize
|
||||||
///
|
///
|
||||||
|
/// \return True if operation was successful, false otherwise
|
||||||
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
[[nodiscard]] bool initialize(sf::Window& window)
|
[[nodiscard]] bool initialize(sf::Window& window)
|
||||||
{
|
{
|
||||||
@ -68,6 +70,8 @@
|
|||||||
/// \param window Target window for rendering
|
/// \param window Target window for rendering
|
||||||
/// \param elapsedTime Time elapsed since the last draw
|
/// \param elapsedTime Time elapsed since the last draw
|
||||||
///
|
///
|
||||||
|
/// \return True if operation was successful, false otherwise
|
||||||
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
[[nodiscard]] bool draw(sf::Window& window, float elapsedTime)
|
[[nodiscard]] bool draw(sf::Window& window, float elapsedTime)
|
||||||
{
|
{
|
||||||
@ -261,7 +265,6 @@ int main()
|
|||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Display the views on screen
|
// Display the views on screen
|
||||||
sfmlView1.display();
|
sfmlView1.display();
|
||||||
sfmlView2.display();
|
sfmlView2.display();
|
||||||
|
@ -4,13 +4,18 @@
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#define STB_PERLIN_IMPLEMENTATION
|
#define STB_PERLIN_IMPLEMENTATION
|
||||||
#include <stb_perlin.h>
|
#include <stb_perlin.h>
|
||||||
|
|
||||||
#include <SFML/Graphics.hpp>
|
#include <SFML/Graphics.hpp>
|
||||||
#include <vector>
|
|
||||||
#include <deque>
|
|
||||||
#include <sstream>
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cstring>
|
#include <deque>
|
||||||
|
#include <iostream>
|
||||||
|
#include <sstream>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
@ -136,7 +141,11 @@ int main()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create our VertexBuffer with enough space to hold all the terrain geometry
|
// Create our VertexBuffer with enough space to hold all the terrain geometry
|
||||||
terrain.create(resolutionX * resolutionY * 6);
|
if (!terrain.create(resolutionX * resolutionY * 6))
|
||||||
|
{
|
||||||
|
std::cerr << "Failed to create vertex buffer" << std::endl;
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
// Resize the staging buffer to be able to hold all the terrain geometry
|
// Resize the staging buffer to be able to hold all the terrain geometry
|
||||||
terrainStagingBuffer.resize(resolutionX * resolutionY * 6);
|
terrainStagingBuffer.resize(resolutionX * resolutionY * 6);
|
||||||
@ -215,7 +224,12 @@ int main()
|
|||||||
// If there is new data pending to be uploaded to the VertexBuffer, do it now
|
// If there is new data pending to be uploaded to the VertexBuffer, do it now
|
||||||
if (bufferUploadPending)
|
if (bufferUploadPending)
|
||||||
{
|
{
|
||||||
terrain.update(terrainStagingBuffer.data());
|
if (!terrain.update(terrainStagingBuffer.data()))
|
||||||
|
{
|
||||||
|
std::cerr << "Failed to update vertex buffer" << std::endl;
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
bufferUploadPending = false;
|
bufferUploadPending = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Graphics.hpp>
|
#include <SFML/Graphics.hpp>
|
||||||
|
#include <iostream>
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
#define GLAD_GL_IMPLEMENTATION
|
#define GLAD_GL_IMPLEMENTATION
|
||||||
#include <gl.h>
|
#include <gl.h>
|
||||||
@ -57,6 +59,7 @@ int main()
|
|||||||
sf::Font font;
|
sf::Font font;
|
||||||
if (!font.loadFromFile(resourcesDir() + "tuffy.ttf"))
|
if (!font.loadFromFile(resourcesDir() + "tuffy.ttf"))
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
sf::Text text("SFML / OpenGL demo", font);
|
sf::Text text("SFML / OpenGL demo", font);
|
||||||
sf::Text sRgbInstructions("Press space to toggle sRGB conversion", font);
|
sf::Text sRgbInstructions("Press space to toggle sRGB conversion", font);
|
||||||
sf::Text mipmapInstructions("Press return to toggle mipmapping", font);
|
sf::Text mipmapInstructions("Press return to toggle mipmapping", font);
|
||||||
@ -75,10 +78,14 @@ int main()
|
|||||||
// Attempt to generate a mipmap for our cube texture
|
// Attempt to generate a mipmap for our cube texture
|
||||||
// We don't check the return value here since
|
// We don't check the return value here since
|
||||||
// mipmapping is purely optional in this example
|
// mipmapping is purely optional in this example
|
||||||
texture.generateMipmap();
|
(void) texture.generateMipmap();
|
||||||
|
|
||||||
// Make the window the active window for OpenGL calls
|
// Make the window the active window for OpenGL calls
|
||||||
window.setActive(true);
|
if (!window.setActive(true))
|
||||||
|
{
|
||||||
|
std::cerr << "Failed to set window to active" << std::endl;
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
// Load OpenGL or OpenGL ES entry points using glad
|
// Load OpenGL or OpenGL ES entry points using glad
|
||||||
#ifdef SFML_OPENGL_ES
|
#ifdef SFML_OPENGL_ES
|
||||||
@ -174,7 +181,11 @@ int main()
|
|||||||
glDisableClientState(GL_COLOR_ARRAY);
|
glDisableClientState(GL_COLOR_ARRAY);
|
||||||
|
|
||||||
// Make the window no longer the active window for OpenGL calls
|
// Make the window no longer the active window for OpenGL calls
|
||||||
window.setActive(false);
|
if (!window.setActive(false))
|
||||||
|
{
|
||||||
|
std::cerr << "Failed to set window to inactive" << std::endl;
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
// Create a clock for measuring the time elapsed
|
// Create a clock for measuring the time elapsed
|
||||||
sf::Clock clock;
|
sf::Clock clock;
|
||||||
@ -214,10 +225,8 @@ int main()
|
|||||||
|
|
||||||
mipmapEnabled = false;
|
mipmapEnabled = false;
|
||||||
}
|
}
|
||||||
else
|
else if (texture.generateMipmap())
|
||||||
{
|
{
|
||||||
texture.generateMipmap();
|
|
||||||
|
|
||||||
mipmapEnabled = true;
|
mipmapEnabled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -235,7 +244,11 @@ int main()
|
|||||||
sf::Vector2u textureSize = backgroundTexture.getSize();
|
sf::Vector2u textureSize = backgroundTexture.getSize();
|
||||||
|
|
||||||
// Make the window the active window for OpenGL calls
|
// Make the window the active window for OpenGL calls
|
||||||
window.setActive(true);
|
if (!window.setActive(true))
|
||||||
|
{
|
||||||
|
std::cerr << "Failed to set window to active" << std::endl;
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
glViewport(0, 0, static_cast<GLsizei>(event.size.width), static_cast<GLsizei>(event.size.height));
|
glViewport(0, 0, static_cast<GLsizei>(event.size.width), static_cast<GLsizei>(event.size.height));
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
@ -248,7 +261,11 @@ int main()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Make the window no longer the active window for OpenGL calls
|
// Make the window no longer the active window for OpenGL calls
|
||||||
window.setActive(false);
|
if (!window.setActive(false))
|
||||||
|
{
|
||||||
|
std::cerr << "Failed to set window to inactive" << std::endl;
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
sf::View view;
|
sf::View view;
|
||||||
view.setSize(sf::Vector2f(textureSize));
|
view.setSize(sf::Vector2f(textureSize));
|
||||||
@ -263,7 +280,11 @@ int main()
|
|||||||
window.popGLStates();
|
window.popGLStates();
|
||||||
|
|
||||||
// Make the window the active window for OpenGL calls
|
// Make the window the active window for OpenGL calls
|
||||||
window.setActive(true);
|
if (!window.setActive(true))
|
||||||
|
{
|
||||||
|
std::cerr << "Failed to set window to active" << std::endl;
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
// Clear the depth buffer
|
// Clear the depth buffer
|
||||||
glClear(GL_DEPTH_BUFFER_BIT);
|
glClear(GL_DEPTH_BUFFER_BIT);
|
||||||
@ -292,7 +313,11 @@ int main()
|
|||||||
glDrawArrays(GL_TRIANGLES, 0, 36);
|
glDrawArrays(GL_TRIANGLES, 0, 36);
|
||||||
|
|
||||||
// Make the window no longer the active window for OpenGL calls
|
// Make the window no longer the active window for OpenGL calls
|
||||||
window.setActive(false);
|
if (!window.setActive(false))
|
||||||
|
{
|
||||||
|
std::cerr << "Failed to set window to inactive" << std::endl;
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
// Draw some text on top of our OpenGL object
|
// Draw some text on top of our OpenGL object
|
||||||
window.pushGLStates();
|
window.pushGLStates();
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// Entry point of application
|
/// Entry point of application
|
||||||
|
@ -104,7 +104,7 @@ public:
|
|||||||
/// \see loadFromMemory, loadFromStream
|
/// \see loadFromMemory, loadFromStream
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool loadFromFile(const std::string& filename);
|
[[nodiscard]] bool loadFromFile(const std::string& filename);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Load the font from a file in memory
|
/// \brief Load the font from a file in memory
|
||||||
@ -125,7 +125,7 @@ public:
|
|||||||
/// \see loadFromFile, loadFromStream
|
/// \see loadFromFile, loadFromStream
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool loadFromMemory(const void* data, std::size_t sizeInBytes);
|
[[nodiscard]] bool loadFromMemory(const void* data, std::size_t sizeInBytes);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Load the font from a custom stream
|
/// \brief Load the font from a custom stream
|
||||||
@ -147,7 +147,7 @@ public:
|
|||||||
/// \see loadFromFile, loadFromMemory
|
/// \see loadFromFile, loadFromMemory
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool loadFromStream(InputStream& stream);
|
[[nodiscard]] bool loadFromStream(InputStream& stream);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Get the font information
|
/// \brief Get the font information
|
||||||
@ -382,7 +382,7 @@ private:
|
|||||||
/// \return True on success, false if any error happened
|
/// \return True on success, false if any error happened
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool setCurrentSize(unsigned int characterSize) const;
|
[[nodiscard]] bool setCurrentSize(unsigned int characterSize) const;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Types
|
// Types
|
||||||
|
@ -101,7 +101,7 @@ public:
|
|||||||
/// \see loadFromMemory, loadFromStream, saveToFile
|
/// \see loadFromMemory, loadFromStream, saveToFile
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool loadFromFile(const std::string& filename);
|
[[nodiscard]] bool loadFromFile(const std::string& filename);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Load the image from a file in memory
|
/// \brief Load the image from a file in memory
|
||||||
@ -119,7 +119,7 @@ public:
|
|||||||
/// \see loadFromFile, loadFromStream
|
/// \see loadFromFile, loadFromStream
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool loadFromMemory(const void* data, std::size_t size);
|
[[nodiscard]] bool loadFromMemory(const void* data, std::size_t size);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Load the image from a custom stream
|
/// \brief Load the image from a custom stream
|
||||||
@ -136,7 +136,7 @@ public:
|
|||||||
/// \see loadFromFile, loadFromMemory
|
/// \see loadFromFile, loadFromMemory
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool loadFromStream(InputStream& stream);
|
[[nodiscard]] bool loadFromStream(InputStream& stream);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Save the image to a file on disk
|
/// \brief Save the image to a file on disk
|
||||||
@ -153,7 +153,7 @@ public:
|
|||||||
/// \see create, loadFromFile, loadFromMemory
|
/// \see create, loadFromFile, loadFromMemory
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool saveToFile(const std::string& filename) const;
|
[[nodiscard]] bool saveToFile(const std::string& filename) const;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Save the image to a buffer in memory
|
/// \brief Save the image to a buffer in memory
|
||||||
@ -171,7 +171,7 @@ public:
|
|||||||
/// \see create, loadFromFile, loadFromMemory, saveToFile
|
/// \see create, loadFromFile, loadFromMemory, saveToFile
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool saveToMemory(std::vector<sf::Uint8>& output, const std::string& format) const;
|
[[nodiscard]] bool saveToMemory(std::vector<sf::Uint8>& output, const std::string& format) const;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Return the size (width and height) of the image
|
/// \brief Return the size (width and height) of the image
|
||||||
|
@ -304,7 +304,7 @@ public:
|
|||||||
/// \return True if operation was successful, false otherwise
|
/// \return True if operation was successful, false otherwise
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
virtual bool setActive(bool active = true);
|
[[nodiscard]] virtual bool setActive(bool active = true);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Save the current OpenGL render states and matrices
|
/// \brief Save the current OpenGL render states and matrices
|
||||||
|
@ -84,7 +84,7 @@ public:
|
|||||||
/// \return True if creation has been successful
|
/// \return True if creation has been successful
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool create(unsigned int width, unsigned int height, const ContextSettings& settings = ContextSettings());
|
[[nodiscard]] bool create(unsigned int width, unsigned int height, const ContextSettings& settings = ContextSettings());
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Get the maximum anti-aliasing level supported by the system
|
/// \brief Get the maximum anti-aliasing level supported by the system
|
||||||
@ -154,7 +154,7 @@ public:
|
|||||||
/// \return True if mipmap generation was successful, false if unsuccessful
|
/// \return True if mipmap generation was successful, false if unsuccessful
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool generateMipmap();
|
[[nodiscard]] bool generateMipmap();
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Activate or deactivate the render-texture for rendering
|
/// \brief Activate or deactivate the render-texture for rendering
|
||||||
@ -171,7 +171,7 @@ public:
|
|||||||
/// \return True if operation was successful, false otherwise
|
/// \return True if operation was successful, false otherwise
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool setActive(bool active = true) override;
|
[[nodiscard]] bool setActive(bool active = true) override;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Update the contents of the target texture
|
/// \brief Update the contents of the target texture
|
||||||
|
@ -139,7 +139,7 @@ public:
|
|||||||
/// \return True if operation was successful, false otherwise
|
/// \return True if operation was successful, false otherwise
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool setActive(bool active = true) override;
|
[[nodiscard]] bool setActive(bool active = true) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ public:
|
|||||||
/// \see loadFromMemory, loadFromStream
|
/// \see loadFromMemory, loadFromStream
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool loadFromFile(const std::string& filename, Type type);
|
[[nodiscard]] bool loadFromFile(const std::string& filename, Type type);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Load both the vertex and fragment shaders from files
|
/// \brief Load both the vertex and fragment shaders from files
|
||||||
@ -137,7 +137,7 @@ public:
|
|||||||
/// \see loadFromMemory, loadFromStream
|
/// \see loadFromMemory, loadFromStream
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool loadFromFile(const std::string& vertexShaderFilename, const std::string& fragmentShaderFilename);
|
[[nodiscard]] bool loadFromFile(const std::string& vertexShaderFilename, const std::string& fragmentShaderFilename);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Load the vertex, geometry and fragment shaders from files
|
/// \brief Load the vertex, geometry and fragment shaders from files
|
||||||
@ -159,7 +159,7 @@ public:
|
|||||||
/// \see loadFromMemory, loadFromStream
|
/// \see loadFromMemory, loadFromStream
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool loadFromFile(const std::string& vertexShaderFilename, const std::string& geometryShaderFilename, const std::string& fragmentShaderFilename);
|
[[nodiscard]] bool loadFromFile(const std::string& vertexShaderFilename, const std::string& geometryShaderFilename, const std::string& fragmentShaderFilename);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Load the vertex, geometry or fragment shader from a source code in memory
|
/// \brief Load the vertex, geometry or fragment shader from a source code in memory
|
||||||
@ -179,7 +179,7 @@ public:
|
|||||||
/// \see loadFromFile, loadFromStream
|
/// \see loadFromFile, loadFromStream
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool loadFromMemory(const std::string& shader, Type type);
|
[[nodiscard]] bool loadFromMemory(const std::string& shader, Type type);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Load both the vertex and fragment shaders from source codes in memory
|
/// \brief Load both the vertex and fragment shaders from source codes in memory
|
||||||
@ -200,7 +200,7 @@ public:
|
|||||||
/// \see loadFromFile, loadFromStream
|
/// \see loadFromFile, loadFromStream
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool loadFromMemory(const std::string& vertexShader, const std::string& fragmentShader);
|
[[nodiscard]] bool loadFromMemory(const std::string& vertexShader, const std::string& fragmentShader);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Load the vertex, geometry and fragment shaders from source codes in memory
|
/// \brief Load the vertex, geometry and fragment shaders from source codes in memory
|
||||||
@ -222,7 +222,7 @@ public:
|
|||||||
/// \see loadFromFile, loadFromStream
|
/// \see loadFromFile, loadFromStream
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool loadFromMemory(const std::string& vertexShader, const std::string& geometryShader, const std::string& fragmentShader);
|
[[nodiscard]] bool loadFromMemory(const std::string& vertexShader, const std::string& geometryShader, const std::string& fragmentShader);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Load the vertex, geometry or fragment shader from a custom stream
|
/// \brief Load the vertex, geometry or fragment shader from a custom stream
|
||||||
@ -242,7 +242,7 @@ public:
|
|||||||
/// \see loadFromFile, loadFromMemory
|
/// \see loadFromFile, loadFromMemory
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool loadFromStream(InputStream& stream, Type type);
|
[[nodiscard]] bool loadFromStream(InputStream& stream, Type type);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Load both the vertex and fragment shaders from custom streams
|
/// \brief Load both the vertex and fragment shaders from custom streams
|
||||||
@ -263,7 +263,7 @@ public:
|
|||||||
/// \see loadFromFile, loadFromMemory
|
/// \see loadFromFile, loadFromMemory
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool loadFromStream(InputStream& vertexShaderStream, InputStream& fragmentShaderStream);
|
[[nodiscard]] bool loadFromStream(InputStream& vertexShaderStream, InputStream& fragmentShaderStream);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Load the vertex, geometry and fragment shaders from custom streams
|
/// \brief Load the vertex, geometry and fragment shaders from custom streams
|
||||||
@ -285,7 +285,7 @@ public:
|
|||||||
/// \see loadFromFile, loadFromMemory
|
/// \see loadFromFile, loadFromMemory
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool loadFromStream(InputStream& vertexShaderStream, InputStream& geometryShaderStream, InputStream& fragmentShaderStream);
|
[[nodiscard]] bool loadFromStream(InputStream& vertexShaderStream, InputStream& geometryShaderStream, InputStream& fragmentShaderStream);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Specify value for \p float uniform
|
/// \brief Specify value for \p float uniform
|
||||||
@ -626,7 +626,7 @@ private:
|
|||||||
/// \return True on success, false if any error happened
|
/// \return True on success, false if any error happened
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool compile(const char* vertexShaderCode, const char* geometryShaderCode, const char* fragmentShaderCode);
|
[[nodiscard]] bool compile(const char* vertexShaderCode, const char* geometryShaderCode, const char* fragmentShaderCode);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Bind all the textures used by the shader
|
/// \brief Bind all the textures used by the shader
|
||||||
|
@ -94,7 +94,7 @@ public:
|
|||||||
/// \return True if creation was successful
|
/// \return True if creation was successful
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool create(unsigned int width, unsigned int height);
|
[[nodiscard]] bool create(unsigned int width, unsigned int height);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Load the texture from a file on disk
|
/// \brief Load the texture from a file on disk
|
||||||
@ -125,7 +125,7 @@ public:
|
|||||||
/// \see loadFromMemory, loadFromStream, loadFromImage
|
/// \see loadFromMemory, loadFromStream, loadFromImage
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool loadFromFile(const std::string& filename, const IntRect& area = IntRect());
|
[[nodiscard]] bool loadFromFile(const std::string& filename, const IntRect& area = IntRect());
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Load the texture from a file in memory
|
/// \brief Load the texture from a file in memory
|
||||||
@ -157,7 +157,7 @@ public:
|
|||||||
/// \see loadFromFile, loadFromStream, loadFromImage
|
/// \see loadFromFile, loadFromStream, loadFromImage
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool loadFromMemory(const void* data, std::size_t size, const IntRect& area = IntRect());
|
[[nodiscard]] bool loadFromMemory(const void* data, std::size_t size, const IntRect& area = IntRect());
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Load the texture from a custom stream
|
/// \brief Load the texture from a custom stream
|
||||||
@ -188,7 +188,7 @@ public:
|
|||||||
/// \see loadFromFile, loadFromMemory, loadFromImage
|
/// \see loadFromFile, loadFromMemory, loadFromImage
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool loadFromStream(InputStream& stream, const IntRect& area = IntRect());
|
[[nodiscard]] bool loadFromStream(InputStream& stream, const IntRect& area = IntRect());
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Load the texture from an image
|
/// \brief Load the texture from an image
|
||||||
@ -212,7 +212,7 @@ public:
|
|||||||
/// \see loadFromFile, loadFromMemory
|
/// \see loadFromFile, loadFromMemory
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool loadFromImage(const Image& image, const IntRect& area = IntRect());
|
[[nodiscard]] bool loadFromImage(const Image& image, const IntRect& area = IntRect());
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Return the size of the texture
|
/// \brief Return the size of the texture
|
||||||
@ -506,7 +506,7 @@ public:
|
|||||||
/// \return True if mipmap generation was successful, false if unsuccessful
|
/// \return True if mipmap generation was successful, false if unsuccessful
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool generateMipmap();
|
[[nodiscard]] bool generateMipmap();
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Overload of assignment operator
|
/// \brief Overload of assignment operator
|
||||||
|
@ -134,7 +134,7 @@ public:
|
|||||||
/// \return True if creation was successful
|
/// \return True if creation was successful
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool create(std::size_t vertexCount);
|
[[nodiscard]] bool create(std::size_t vertexCount);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Return the vertex count
|
/// \brief Return the vertex count
|
||||||
@ -162,7 +162,7 @@ public:
|
|||||||
/// \return True if the update was successful
|
/// \return True if the update was successful
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool update(const Vertex* vertices);
|
[[nodiscard]] bool update(const Vertex* vertices);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Update a part of the buffer from an array of vertices
|
/// \brief Update a part of the buffer from an array of vertices
|
||||||
@ -195,7 +195,7 @@ public:
|
|||||||
/// \return True if the update was successful
|
/// \return True if the update was successful
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool update(const Vertex* vertices, std::size_t vertexCount, unsigned int offset);
|
[[nodiscard]] bool update(const Vertex* vertices, std::size_t vertexCount, unsigned int offset);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Copy the contents of another buffer into this buffer
|
/// \brief Copy the contents of another buffer into this buffer
|
||||||
@ -205,7 +205,7 @@ public:
|
|||||||
/// \return True if the copy was successful
|
/// \return True if the copy was successful
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool update(const VertexBuffer& vertexBuffer);
|
[[nodiscard]] bool update(const VertexBuffer& vertexBuffer);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Overload of assignment operator
|
/// \brief Overload of assignment operator
|
||||||
|
@ -770,7 +770,12 @@ IntRect Font::findGlyphRect(Page& page, unsigned int width, unsigned int height)
|
|||||||
{
|
{
|
||||||
// Make the texture 2 times bigger
|
// Make the texture 2 times bigger
|
||||||
Texture newTexture;
|
Texture newTexture;
|
||||||
newTexture.create(textureWidth * 2, textureHeight * 2);
|
if (!newTexture.create(textureWidth * 2, textureHeight * 2))
|
||||||
|
{
|
||||||
|
err() << "Failed to create new page texture" << std::endl;
|
||||||
|
return IntRect(0, 0, 2, 2);
|
||||||
|
}
|
||||||
|
|
||||||
newTexture.setSmooth(m_isSmooth);
|
newTexture.setSmooth(m_isSmooth);
|
||||||
newTexture.update(page.texture);
|
newTexture.update(page.texture);
|
||||||
page.texture.swap(newTexture);
|
page.texture.swap(newTexture);
|
||||||
@ -854,7 +859,11 @@ nextRow(3)
|
|||||||
image.setPixel(x, y, Color(255, 255, 255, 255));
|
image.setPixel(x, y, Color(255, 255, 255, 255));
|
||||||
|
|
||||||
// Create the texture
|
// Create the texture
|
||||||
texture.loadFromImage(image);
|
if (!texture.loadFromImage(image))
|
||||||
|
{
|
||||||
|
err() << "Failed to load font page texture" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
texture.setSmooth(true);
|
texture.setSmooth(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,13 +143,11 @@ bool RenderTexture::generateMipmap()
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool RenderTexture::setActive(bool active)
|
bool RenderTexture::setActive(bool active)
|
||||||
{
|
{
|
||||||
bool result = m_impl && m_impl->activate(active);
|
|
||||||
|
|
||||||
// Update RenderTarget tracking
|
// Update RenderTarget tracking
|
||||||
if (result)
|
if (m_impl && m_impl->activate(active))
|
||||||
RenderTarget::setActive(active);
|
return RenderTarget::setActive(active);
|
||||||
|
|
||||||
return result;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ bool RenderWindow::setActive(bool active)
|
|||||||
|
|
||||||
// Update RenderTarget tracking
|
// Update RenderTarget tracking
|
||||||
if (result)
|
if (result)
|
||||||
RenderTarget::setActive(active);
|
result = RenderTarget::setActive(active);
|
||||||
|
|
||||||
// If FBOs are available, make sure none are bound when we
|
// If FBOs are available, make sure none are bound when we
|
||||||
// try to draw to the default framebuffer of the RenderWindow
|
// try to draw to the default framebuffer of the RenderWindow
|
||||||
|
Loading…
Reference in New Issue
Block a user