Skip to content

Commit

Permalink
[Render/Renderer] Added sendImageSubDataND()
Browse files Browse the repository at this point in the history
- These can be used to send the portion of an ND image, and will be especially useful for 3D textures
  • Loading branch information
Razakhel committed Jan 28, 2024
1 parent b9fe4b1 commit 32c7492
Show file tree
Hide file tree
Showing 2 changed files with 112 additions and 0 deletions.
49 changes: 49 additions & 0 deletions include/RaZ/Render/Renderer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand All @@ -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);
Expand Down
63 changes: 63 additions & 0 deletions src/RaZ/Render/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<unsigned int>(type),
static_cast<int>(mipmapLevel),
static_cast<int>(offsetX),
static_cast<int>(width),
static_cast<unsigned int>(format),
static_cast<unsigned int>(dataType),
data);

printConditionalErrors();
}
#endif

void Renderer::sendImageData2D(TextureType type,
Expand All @@ -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<unsigned int>(type),
static_cast<int>(mipmapLevel),
static_cast<int>(offsetX),
static_cast<int>(offsetY),
static_cast<int>(width),
static_cast<int>(height),
static_cast<unsigned int>(format),
static_cast<unsigned int>(dataType),
data);

printConditionalErrors();
}

void Renderer::sendImageData3D(TextureType type,
unsigned int mipmapLevel,
TextureInternalFormat internalFormat,
Expand All @@ -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<unsigned int>(type),
static_cast<int>(mipmapLevel),
static_cast<int>(offsetX),
static_cast<int>(offsetY),
static_cast<int>(offsetZ),
static_cast<int>(width),
static_cast<int>(height),
static_cast<int>(depth),
static_cast<unsigned int>(format),
static_cast<unsigned int>(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());
Expand Down

0 comments on commit 32c7492

Please sign in to comment.