diff --git a/src/graphics/texture.nim b/src/graphics/texture.nim index c4cedec..c1638d4 100644 --- a/src/graphics/texture.nim +++ b/src/graphics/texture.nim @@ -329,8 +329,9 @@ proc unbindAllTextures*() = next_texture = 0 proc destroy*(texture: Texture) = - texture.unbind() - texture.freeTextureStorage() + if texture.storage != nil: + texture.unbind() + texture.freeTextureStorage() proc loadFromPixelsPointer*(self: Texture, pixels: pointer) = let ts = self.storage @@ -467,7 +468,7 @@ proc newTexture*(engine: MyouEngine, name: string, file_name: string, is_sRGB: b # TODO: Api that stores the LoadableResource so it can be re-loaded later # note: format does not matter at this point, will be replaced later - let self = engine.newTexture(name, 0, 0, filter=filter, format=RGBA_u8) + let self = engine.newTexture(name, 0, 0, filter=filter, format=RGBA_u8, tex_type=tex_type) self.is_sRGB = is_sRGB var res: LoadableResource proc load(ok: bool, err: string, data: SliceMem[byte]) =