mirror of
https://github.com/bloeys/nmage.git
synced 2025-12-29 13:28:20 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e5ea6f986f | |||
| c4853792a5 | |||
| 8cf9be2830 |
@ -30,7 +30,28 @@ func (b *Buffer) SetData(values []float32) {
|
|||||||
gl.BindVertexArray(b.VAOID)
|
gl.BindVertexArray(b.VAOID)
|
||||||
gl.BindBuffer(gl.ARRAY_BUFFER, b.BufID)
|
gl.BindBuffer(gl.ARRAY_BUFFER, b.BufID)
|
||||||
|
|
||||||
gl.BufferData(gl.ARRAY_BUFFER, len(values)*4, gl.Ptr(values), BufUsage_Static.ToGL())
|
sizeInBytes := len(values) * 4
|
||||||
|
if sizeInBytes == 0 {
|
||||||
|
gl.BufferData(gl.ARRAY_BUFFER, 0, gl.Ptr(nil), BufUsage_Static.ToGL())
|
||||||
|
} else {
|
||||||
|
gl.BufferData(gl.ARRAY_BUFFER, sizeInBytes, gl.Ptr(&values[0]), BufUsage_Static.ToGL())
|
||||||
|
}
|
||||||
|
|
||||||
|
gl.BindVertexArray(0)
|
||||||
|
gl.BindBuffer(gl.ARRAY_BUFFER, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *Buffer) SetDataWithUsage(values []float32, usage BufUsage) {
|
||||||
|
|
||||||
|
gl.BindVertexArray(b.VAOID)
|
||||||
|
gl.BindBuffer(gl.ARRAY_BUFFER, b.BufID)
|
||||||
|
|
||||||
|
sizeInBytes := len(values) * 4
|
||||||
|
if sizeInBytes == 0 {
|
||||||
|
gl.BufferData(gl.ARRAY_BUFFER, 0, gl.Ptr(nil), usage.ToGL())
|
||||||
|
} else {
|
||||||
|
gl.BufferData(gl.ARRAY_BUFFER, sizeInBytes, gl.Ptr(&values[0]), usage.ToGL())
|
||||||
|
}
|
||||||
|
|
||||||
gl.BindVertexArray(0)
|
gl.BindVertexArray(0)
|
||||||
gl.BindBuffer(gl.ARRAY_BUFFER, 0)
|
gl.BindBuffer(gl.ARRAY_BUFFER, 0)
|
||||||
@ -42,7 +63,12 @@ func (b *Buffer) SetIndexBufData(values []uint32) {
|
|||||||
gl.BindVertexArray(b.VAOID)
|
gl.BindVertexArray(b.VAOID)
|
||||||
gl.BindBuffer(gl.ELEMENT_ARRAY_BUFFER, b.IndexBufID)
|
gl.BindBuffer(gl.ELEMENT_ARRAY_BUFFER, b.IndexBufID)
|
||||||
|
|
||||||
gl.BufferData(gl.ELEMENT_ARRAY_BUFFER, len(values)*4, gl.Ptr(values), BufUsage_Static.ToGL())
|
sizeInBytes := len(values) * 4
|
||||||
|
if sizeInBytes == 0 {
|
||||||
|
gl.BufferData(gl.ELEMENT_ARRAY_BUFFER, 0, gl.Ptr(nil), BufUsage_Static.ToGL())
|
||||||
|
} else {
|
||||||
|
gl.BufferData(gl.ELEMENT_ARRAY_BUFFER, sizeInBytes, gl.Ptr(&values[0]), BufUsage_Static.ToGL())
|
||||||
|
}
|
||||||
|
|
||||||
gl.BindVertexArray(0)
|
gl.BindVertexArray(0)
|
||||||
gl.BindBuffer(gl.ELEMENT_ARRAY_BUFFER, 0)
|
gl.BindBuffer(gl.ELEMENT_ARRAY_BUFFER, 0)
|
||||||
|
|||||||
@ -66,8 +66,7 @@ func (i *ImguiInfo) Render(winWidth, winHeight float32, fbWidth, fbHeight int32)
|
|||||||
// DisplayMin is typically (0,0) for single viewport apps.
|
// DisplayMin is typically (0,0) for single viewport apps.
|
||||||
|
|
||||||
i.Mat.Bind()
|
i.Mat.Bind()
|
||||||
|
i.Mat.SetUnifInt32("Texture", 0)
|
||||||
gl.Uniform1i(gl.GetUniformLocation(i.Mat.ShaderProg.ID, gl.Str("Texture\x00")), 0)
|
|
||||||
|
|
||||||
//PERF: only update the ortho matrix on window resize
|
//PERF: only update the ortho matrix on window resize
|
||||||
orthoMat := gglm.Ortho(0, float32(winWidth), 0, float32(winHeight), 0, 20)
|
orthoMat := gglm.Ortho(0, float32(winWidth), 0, float32(winHeight), 0, 20)
|
||||||
|
|||||||
Reference in New Issue
Block a user