mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-13 12:32:05 +01:00
Delete a texture when deleting the render target
This commit is contained in:
parent
92b2e0d948
commit
a9711cd509
@ -85,13 +85,17 @@ func (i *ids) CreateRenderTarget(width, height int, filter graphics.Filter) (
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (i *ids) DeleteRenderTarget(id graphics.RenderTargetId) {
|
func (i *ids) DeleteRenderTarget(id graphics.RenderTargetId) {
|
||||||
renderTarget := i.renderTargets[id]
|
|
||||||
renderTarget.Dispose()
|
|
||||||
|
|
||||||
i.lock.Lock()
|
i.lock.Lock()
|
||||||
defer i.lock.Unlock()
|
defer i.lock.Unlock()
|
||||||
|
|
||||||
|
renderTarget := i.renderTargets[id]
|
||||||
|
textureId := i.renderTargetToTexture[id]
|
||||||
|
texture := i.textures[textureId]
|
||||||
|
|
||||||
|
renderTarget.Dispose()
|
||||||
|
texture.Dispose()
|
||||||
|
|
||||||
delete(i.renderTargets, id)
|
delete(i.renderTargets, id)
|
||||||
|
delete(i.renderTargetToTexture, id)
|
||||||
// TODO: Remove the related texture
|
delete(i.textures, textureId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,6 +77,5 @@ func (r *RenderTarget) ProjectionMatrix() [4][4]float64 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r *RenderTarget) Dispose() {
|
func (r *RenderTarget) Dispose() {
|
||||||
f := C.GLuint(r.framebuffer)
|
C.glDeleteFramebuffers(1, &r.framebuffer)
|
||||||
C.glDeleteFramebuffers(1, &f)
|
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ func createNativeTexture(textureWidth, textureHeight int, pixels []uint8,
|
|||||||
filter graphics.Filter) C.GLuint {
|
filter graphics.Filter) C.GLuint {
|
||||||
nativeTexture := C.GLuint(0)
|
nativeTexture := C.GLuint(0)
|
||||||
|
|
||||||
C.glGenTextures(1, (*C.GLuint)(&nativeTexture))
|
C.glGenTextures(1, &nativeTexture)
|
||||||
if nativeTexture < 0 {
|
if nativeTexture < 0 {
|
||||||
panic("glGenTexture failed")
|
panic("glGenTexture failed")
|
||||||
}
|
}
|
||||||
@ -87,3 +87,7 @@ func (t *Texture) DrawParts(parts []graphics.TexturePart, projectionMatrix [16]f
|
|||||||
projectionMatrix, quads,
|
projectionMatrix, quads,
|
||||||
geometryMatrix, colorMatrix)
|
geometryMatrix, colorMatrix)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t *Texture) Dispose() {
|
||||||
|
C.glDeleteTextures(1, &t.native)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user