Skip to content

Commit 2b26057

Browse files
committed
bindUniformBuffer
1 parent 44e8675 commit 2b26057

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/fidget/opengl/buffers.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func size*(componentType: GLenum): Positive =
1717
1
1818
of cGL_SHORT, cGL_UNSIGNED_SHORT:
1919
2
20-
of GL_UNSIGNED_INT, cGL_FLOAT:
20+
of cGL_INT, GL_UNSIGNED_INT, cGL_FLOAT:
2121
4
2222
else:
2323
raise newException(Exception, "Unexpected componentType")

src/fidget/opengl/shaders.nim

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,14 @@ proc bindUniforms*(shader: Shader) =
430430

431431
uniform.changed = false
432432

433+
proc bindUniformBuffer*(
434+
shader: Shader, name: string, buffer: Buffer, binding: GLuint
435+
) =
436+
assert buffer.target == GL_UNIFORM_BUFFER
437+
let index = glGetUniformBlockIndex(shader.programId, name)
438+
glBindBufferBase(GL_UNIFORM_BUFFER, binding, buffer.bufferId)
439+
glUniformBlockBinding(shader.programId, index, binding)
440+
433441
proc bindAttrib*(
434442
shader: Shader,
435443
name: string,

0 commit comments

Comments
 (0)