Skip to content

Commit

Permalink
more efficient clearing of gl frame buffer
Browse files Browse the repository at this point in the history
approximately 8% performance improvement
  • Loading branch information
JetSetIlly committed Nov 23, 2024
1 parent 6728d37 commit c32645f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
5 changes: 1 addition & 4 deletions gui/sdlimgui/framebuffer/flip.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,7 @@ func (fb *Flip) Process(draw func()) uint32 {
gl.FramebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, id, 0)

if fb.clearOnRender {
gl.TexImage2D(gl.TEXTURE_2D, 0,
gl.RGBA, fb.width, fb.height, 0,
gl.RGBA, gl.UNSIGNED_BYTE,
gl.Ptr(fb.emptyPixels))
gl.Clear(gl.COLOR_BUFFER_BIT)
}

draw()
Expand Down
7 changes: 1 addition & 6 deletions gui/sdlimgui/framebuffer/single.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,9 @@ func (fb *Single) Texture() uint32 {
func (fb *Single) Process(draw func()) uint32 {
gl.BindTexture(gl.TEXTURE_2D, fb.texture)
gl.FramebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, fb.texture, 0)

if fb.clearOnRender {
gl.TexImage2D(gl.TEXTURE_2D, 0,
gl.RGBA, fb.width, fb.height, 0,
gl.RGBA, gl.UNSIGNED_BYTE,
gl.Ptr(fb.emptyPixels))
gl.Clear(gl.COLOR_BUFFER_BIT)
}

draw()

return fb.texture
Expand Down

0 comments on commit c32645f

Please sign in to comment.