summaryrefslogtreecommitdiff
path: root/src/ral/backends
diff options
context:
space:
mode:
authoromniscient <17525998+omnisci3nce@users.noreply.github.com>2024-08-10 23:18:22 +1000
committeromniscient <17525998+omnisci3nce@users.noreply.github.com>2024-08-10 23:18:22 +1000
commitee1b7fd3bc66501b252ce9e3e5ba89ac9aa54632 (patch)
tree47b9b1916933d76bfcc327ad2f39370833bd3712 /src/ral/backends
parent8dc076e714fad6ee6fb493360e094c4002b1584a (diff)
more work on bindings and ral
Diffstat (limited to 'src/ral/backends')
-rw-r--r--src/ral/backends/opengl/backend_opengl.c11
-rw-r--r--src/ral/backends/opengl/opengl_helpers.h2
2 files changed, 12 insertions, 1 deletions
diff --git a/src/ral/backends/opengl/backend_opengl.c b/src/ral/backends/opengl/backend_opengl.c
index f971568..6c1a301 100644
--- a/src/ral/backends/opengl/backend_opengl.c
+++ b/src/ral/backends/opengl/backend_opengl.c
@@ -416,6 +416,17 @@ void GPU_EncodeDrawIndexed(GPU_CmdEncoder* encoder, u64 index_count) {
glDrawElements(GL_TRIANGLES, index_count, GL_UNSIGNED_INT, 0);
}
+PUB void GPU_WriteTextureRegion(GPU_CmdEncoder* encoder, TextureHandle dst, u32 x_offset,
+ u32 y_offset, u32 width, u32 height, const void* data) {
+ CASSERT_MSG(data, "const void* data must not be NULL");
+
+ GPU_Texture* tex = TEXTURE_GET(dst);
+
+ glBindTexture(GL_TEXTURE_2D, tex->id);
+ glTexSubImage2D(GL_TEXTURE_2D, 0, x_offset, y_offset, width, height, GL_RGBA, GL_UNSIGNED_BYTE,
+ data);
+}
+
bool GPU_Backend_BeginFrame() {
glViewport(0, 0, context.swapchain.dimensions.x * 2, context.swapchain.dimensions.y * 2);
glClearColor(0.8f, 0.8f, 0.8f, 1.0f);
diff --git a/src/ral/backends/opengl/opengl_helpers.h b/src/ral/backends/opengl/opengl_helpers.h
index f240050..0450c74 100644
--- a/src/ral/backends/opengl/opengl_helpers.h
+++ b/src/ral/backends/opengl/opengl_helpers.h
@@ -59,7 +59,7 @@ static u32 opengl_bindcreate_vao(GPU_Buffer* buf, VertexDescription desc) {
u32 attr_count = desc.attributes_count;
printf("N attributes %d\n", attr_count);
u64 offset = 0;
- size_t vertex_size = desc.use_full_vertex_size ? sizeof(Vertex) : desc.stride;
+ size_t vertex_size = desc.use_full_vertex_size ? sizeof(Vertex) : VertexDesc_CalcStride(&desc);
for (u32 i = 0; i < desc.attributes_count; i++) {
opengl_vertex_attr format = format_from_vertex_attr(desc.attributes[i]);
glVertexAttribPointer(i, format.count, format.data_type, GL_FALSE, vertex_size, (void*)offset);