ソースを参照

gl: destroy texture

Karl Zylinski 4 ヶ月 前
コミット
389f7888fe
1 ファイル変更7 行追加3 行削除
  1. 7 3
      render_backend_gl.odin

+ 7 - 3
render_backend_gl.odin

@@ -374,16 +374,20 @@ gl_update_texture :: proc(th: Texture_Handle, data: []u8, rect: Rect) -> bool {
 		return false
 	}
 
-	//pf := gl_translate_pixel_format(tex.format)
-
-
     gl.BindTexture(gl.TEXTURE_2D, tex.id)
 	gl.TexSubImage2D(gl.TEXTURE_2D, 0, i32(rect.x), i32(rect.y), i32(rect.w), i32(rect.h), gl.RGBA, gl.UNSIGNED_BYTE, raw_data(data))
 	return true
 }
 
 gl_destroy_texture :: proc(th: Texture_Handle) {
+	tex := hm.get(&s.textures, th)
+
+	if tex == nil {
+		return
+	}
 
+	gl.DeleteTextures(1, &tex.id)
+	hm.remove(&s.textures, th)
 }
 
 Shader_Compile_Result_OK :: struct {}