package renderer import "core:strings" import "core:c" import "vendor:stb/image" import "core:fmt" Texture :: struct { width, height, channels, depth: u32, backend: Texture_Backend, } create_texture :: proc { create_texture_from_path, } create_texture_from_path :: proc(renderer: ^Renderer, path: string) -> (Texture, bool) { width, height, depth, channels: c.int path_cstr := strings.clone_to_cstring(path) defer delete(path_cstr) image.set_flip_vertically_on_load(1) // NOTE: SS - This should not necessarily happen on all graphics-apis. data := image.load(path_cstr, &width, &height, &channels, desired_channels = 0) if data == nil { return {}, false } depth = 8 t: Texture t.width = u32(width) t.height = u32(height) t.channels = u32(channels) t.depth = u32(depth) when RENDER_BACKEND_OPENGL { if !opengl_load_texture(renderer, &t, data) { return {}, false } } else { #assert(false) } return t, true } delete_texture :: proc(renderer: ^Renderer, texture: ^Texture) { when RENDER_BACKEND_OPENGL { opengl_delete_texture(renderer, texture) } else { #assert(false) } }