Files
renderer/material.odin
2026-01-31 02:31:19 +01:00

41 lines
1.0 KiB
Odin

package renderer
import "core:log"
import "core:fmt"
MATERIAL_MAX_TEXTURES :: 32
Material :: struct {
// TODO: SS - 'Name'?
shader_program: ^Shader_Program,
textures: [MATERIAL_MAX_TEXTURES]^Texture,
texture_count: u8,
}
create_material :: proc(program: ^Shader_Program, textures: []^Texture) -> (Material, bool) {
m: Material
m.shader_program = program
for t, i in textures {
if t == nil {
log.warnf("Found nil texture at index %v in when creating material.", i)
continue
}
if m.texture_count >= MATERIAL_MAX_TEXTURES {
log.warnf("Too many textures passed when creating material. Max is %v.", MATERIAL_MAX_TEXTURES)
break
}
m.textures[m.texture_count] = t
m.texture_count += 1
}
if m.texture_count == 0 {
log.warn("No textures passed when creating material.")
// TODO: SS - Should we return false here?
}
return m, true
}