diff --git a/include/RaZ/Render/Renderer.hpp b/include/RaZ/Render/Renderer.hpp index ea30da67..bb4d6b9b 100644 --- a/include/RaZ/Render/Renderer.hpp +++ b/include/RaZ/Render/Renderer.hpp @@ -1050,6 +1050,21 @@ class Renderer { unsigned int width, TextureFormat format, PixelDataType dataType, const void* data); + /// Sends the image's sub-data corresponding to the currently bound 1D texture. + /// \note Unavailable with OpenGL ES; use a Nx1 2D texture instead. + /// \param type Type of the texture. + /// \param mipmapLevel Mipmap (level of detail) of the texture. 0 is the most detailed. + /// \param offsetX Width offset. + /// \param width Image width. + /// \param format Image format. + /// \param dataType Type of the data to be sent. + /// \param data Data to be sent. + static void sendImageSubData1D(TextureType type, + unsigned int mipmapLevel, + unsigned int offsetX, + unsigned int width, + TextureFormat format, + PixelDataType dataType, const void* data); #endif /// Sends the image's data corresponding to the currently bound 2D texture. /// \param type Type of the texture. @@ -1066,6 +1081,22 @@ class Renderer { unsigned int width, unsigned int height, TextureFormat format, PixelDataType dataType, const void* data); + /// Sends the image's sub-data corresponding to the currently bound 2D texture. + /// \param type Type of the texture. + /// \param mipmapLevel Mipmap (level of detail) of the texture. 0 is the most detailed. + /// \param offsetX Width offset. + /// \param offsetY Height offset. + /// \param width Image width. + /// \param height Image height. + /// \param format Image format. + /// \param dataType Type of the data to be sent. + /// \param data Data to be sent. + static void sendImageSubData2D(TextureType type, + unsigned int mipmapLevel, + unsigned int offsetX, unsigned int offsetY, + unsigned int width, unsigned int height, + TextureFormat format, + PixelDataType dataType, const void* data); /// Sends the image's data corresponding to the currently bound 3D texture. /// \param type Type of the texture. /// \param mipmapLevel Mipmap (level of detail) of the texture. 0 is the most detailed. @@ -1082,6 +1113,24 @@ class Renderer { unsigned int width, unsigned int height, unsigned depth, TextureFormat format, PixelDataType dataType, const void* data); + /// Sends the image's sub-data corresponding to the currently bound 3D texture. + /// \param type Type of the texture. + /// \param mipmapLevel Mipmap (level of detail) of the texture. 0 is the most detailed. + /// \param offsetX Width offset. + /// \param offsetY Height offset. + /// \param offsetZ Depth offset. + /// \param width Image width. + /// \param height Image height. + /// \param depth Image depth. + /// \param format Image format. + /// \param dataType Type of the data to be sent. + /// \param data Data to be sent. + static void sendImageSubData3D(TextureType type, + unsigned int mipmapLevel, + unsigned int offsetX, unsigned int offsetY, unsigned int offsetZ, + unsigned int width, unsigned int height, unsigned depth, + TextureFormat format, + PixelDataType dataType, const void* data); #if !defined(USE_OPENGL_ES) static void recoverTextureAttribute(TextureType type, unsigned int mipmapLevel, TextureAttribute attribute, int* values); static void recoverTextureAttribute(TextureType type, unsigned int mipmapLevel, TextureAttribute attribute, float* values); diff --git a/src/RaZ/Render/Renderer.cpp b/src/RaZ/Render/Renderer.cpp index e6cc0a4d..6c3d05d7 100644 --- a/src/RaZ/Render/Renderer.cpp +++ b/src/RaZ/Render/Renderer.cpp @@ -625,6 +625,25 @@ void Renderer::sendImageData1D(TextureType type, printConditionalErrors(); } + +void Renderer::sendImageSubData1D(TextureType type, + unsigned int mipmapLevel, + unsigned int offsetX, + unsigned int width, + TextureFormat format, + PixelDataType dataType, const void* data) { + assert("Error: The Renderer must be initialized before calling its functions." && isInitialized()); + + glTexSubImage1D(static_cast(type), + static_cast(mipmapLevel), + static_cast(offsetX), + static_cast(width), + static_cast(format), + static_cast(dataType), + data); + + printConditionalErrors(); +} #endif void Renderer::sendImageData2D(TextureType type, @@ -648,6 +667,27 @@ void Renderer::sendImageData2D(TextureType type, printConditionalErrors(); } +void Renderer::sendImageSubData2D(TextureType type, + unsigned int mipmapLevel, + unsigned int offsetX, unsigned int offsetY, + unsigned int width, unsigned int height, + TextureFormat format, + PixelDataType dataType, const void* data) { + assert("Error: The Renderer must be initialized before calling its functions." && isInitialized()); + + glTexSubImage2D(static_cast(type), + static_cast(mipmapLevel), + static_cast(offsetX), + static_cast(offsetY), + static_cast(width), + static_cast(height), + static_cast(format), + static_cast(dataType), + data); + + printConditionalErrors(); +} + void Renderer::sendImageData3D(TextureType type, unsigned int mipmapLevel, TextureInternalFormat internalFormat, @@ -670,6 +710,29 @@ void Renderer::sendImageData3D(TextureType type, printConditionalErrors(); } +void Renderer::sendImageSubData3D(TextureType type, + unsigned int mipmapLevel, + unsigned int offsetX, unsigned int offsetY, unsigned int offsetZ, + unsigned int width, unsigned int height, unsigned int depth, + TextureFormat format, + PixelDataType dataType, const void* data) { + assert("Error: The Renderer must be initialized before calling its functions." && isInitialized()); + + glTexSubImage3D(static_cast(type), + static_cast(mipmapLevel), + static_cast(offsetX), + static_cast(offsetY), + static_cast(offsetZ), + static_cast(width), + static_cast(height), + static_cast(depth), + static_cast(format), + static_cast(dataType), + data); + + printConditionalErrors(); +} + #if !defined(USE_OPENGL_ES) void Renderer::recoverTextureAttribute(TextureType type, unsigned int mipmapLevel, TextureAttribute attribute, int* values) { assert("Error: The Renderer must be initialized before calling its functions." && isInitialized());