Fix some textures not being destroyed when it should.
This commit is contained in:
parent
01229cc2b5
commit
1640040f93
|
@ -406,7 +406,7 @@ when compileOption("threads"):
|
||||||
proc workerThreadProc() {.thread.} =
|
proc workerThreadProc() {.thread.} =
|
||||||
# TODO: handle errors
|
# TODO: handle errors
|
||||||
while true:
|
while true:
|
||||||
let to_decode = decode_chan.recv()
|
var to_decode = decode_chan.recv()
|
||||||
if to_decode.tex == nil:
|
if to_decode.tex == nil:
|
||||||
break
|
break
|
||||||
proc cb(tex: Texture, data: SliceMem[byte]) =
|
proc cb(tex: Texture, data: SliceMem[byte]) =
|
||||||
|
@ -415,7 +415,7 @@ when compileOption("threads"):
|
||||||
compressed_return_chan.send((callback: to_decode.callback_compressed, tex: tex, data: data, refdata: refdata))
|
compressed_return_chan.send((callback: to_decode.callback_compressed, tex: tex, data: data, refdata: refdata))
|
||||||
let cb_out = if to_decode.callback_uncompressed != nil: cb else: nil
|
let cb_out = if to_decode.callback_uncompressed != nil: cb else: nil
|
||||||
let cbc_out = if to_decode.callback_compressed != nil: cbc else: nil
|
let cbc_out = if to_decode.callback_compressed != nil: cbc else: nil
|
||||||
loadOptimized(to_decode.tex, to_decode.slices, cb_out, cbc_out,
|
loadOptimized(move to_decode.tex, to_decode.slices, cb_out, cbc_out,
|
||||||
to_decode.flip, to_decode.min_channels)
|
to_decode.flip, to_decode.min_channels)
|
||||||
|
|
||||||
decode_chan.open()
|
decode_chan.open()
|
||||||
|
|
|
@ -260,7 +260,7 @@ proc bind_it*(texture: Texture, reserve_slot: static[int32] = -1, needs_active_t
|
||||||
# if old_tex.sampler_object != 0:
|
# if old_tex.sampler_object != 0:
|
||||||
# glBindSampler(cast[GLuint](bound_unit), 0)
|
# glBindSampler(cast[GLuint](bound_unit), 0)
|
||||||
bound_textures[bound_unit] = nil
|
bound_textures[bound_unit] = nil
|
||||||
glBindTexture(texture.storage.target, texture.storage.tex.GLuint)
|
glBindTexture(texture.storage.target, GLuint(texture.storage.tex))
|
||||||
# if texture.sampler_object != 0:
|
# if texture.sampler_object != 0:
|
||||||
# glBindSampler(bound_unit.GLuint, texture.sampler_object)
|
# glBindSampler(bound_unit.GLuint, texture.sampler_object)
|
||||||
bound_textures[bound_unit] = texture
|
bound_textures[bound_unit] = texture
|
||||||
|
@ -554,8 +554,8 @@ proc getTexturePixels*(self: Texture): TexturePixels =
|
||||||
proc setMipmapRange*(self: Texture, first = 0, last = 1000) {.gcsafe.} =
|
proc setMipmapRange*(self: Texture, first = 0, last = 1000) {.gcsafe.} =
|
||||||
self.bind_it(needs_active_texture=true)
|
self.bind_it(needs_active_texture=true)
|
||||||
self.mipmap_range = (first, last)
|
self.mipmap_range = (first, last)
|
||||||
glTexParameteri(self.storage.target.GLenum, GL_TEXTURE_BASE_LEVEL, first.GLint);
|
glTexParameteri(self.storage.target, GL_TEXTURE_BASE_LEVEL, first.GLint);
|
||||||
glTexParameteri(self.storage.target.GLenum, GL_TEXTURE_MAX_LEVEL, last.GLint);
|
glTexParameteri(self.storage.target, GL_TEXTURE_MAX_LEVEL, last.GLint);
|
||||||
|
|
||||||
func vec3size*(self: Texture, mip_level = -1): Vec3 =
|
func vec3size*(self: Texture, mip_level = -1): Vec3 =
|
||||||
let depth = if self.tex_type == Tex2DArray: 1 else: self.depth
|
let depth = if self.tex_type == Tex2DArray: 1 else: self.depth
|
||||||
|
|
|
@ -342,6 +342,13 @@ proc set_objects_auto_update_matrix*(self: Scene, objects: seq[GameObject], auto
|
||||||
self.children_are_ordered = false
|
self.children_are_ordered = false
|
||||||
|
|
||||||
proc destroy*(self: Scene) =
|
proc destroy*(self: Scene) =
|
||||||
|
# This may not be necessary. TODO: test
|
||||||
|
for ob in self.children:
|
||||||
|
if ob.is_mesh:
|
||||||
|
for m in ob.get_mesh.materials:
|
||||||
|
if m != nil:
|
||||||
|
for tex in m.textures.mvalues:
|
||||||
|
tex.destroy()
|
||||||
for ob in reversed(self.children):
|
for ob in reversed(self.children):
|
||||||
ob.destroy(recursive=false)
|
ob.destroy(recursive=false)
|
||||||
self.world.destroy()
|
self.world.destroy()
|
||||||
|
@ -357,6 +364,7 @@ proc destroy*(self: Scene) =
|
||||||
cube.destroy()
|
cube.destroy()
|
||||||
self.cubemaps = @[]
|
self.cubemaps = @[]
|
||||||
self.engine.scenes.del(self.name)
|
self.engine.scenes.del(self.name)
|
||||||
|
self.engine.new_scenes.del(self.name)
|
||||||
# bound textures can linger
|
# bound textures can linger
|
||||||
unbindAllTextures()
|
unbindAllTextures()
|
||||||
# probably none of this is actually necessary
|
# probably none of this is actually necessary
|
||||||
|
|
Loading…
Reference in a new issue