Restructured passes
This commit is contained in:
@@ -1,16 +1,41 @@
|
||||
package renderer
|
||||
|
||||
import "core:log"
|
||||
import "core:fmt"
|
||||
|
||||
MATERIAL_MAX_TEXTURES :: 32
|
||||
|
||||
Material :: struct {
|
||||
// 'Name'?
|
||||
// TODO: SS - 'Name'?
|
||||
shader_program: ^Shader_Program,
|
||||
texture: ^Texture, // Diffuse, normal etc later.
|
||||
// uniforms, textures, etc.
|
||||
|
||||
textures: [MATERIAL_MAX_TEXTURES]^Texture,
|
||||
texture_count: u8,
|
||||
}
|
||||
|
||||
create_material :: proc(program: ^Shader_Program, texture0: ^Texture) -> (Material, bool) {
|
||||
create_material :: proc(program: ^Shader_Program, textures: []^Texture) -> (Material, bool) {
|
||||
m: Material
|
||||
m.shader_program = program
|
||||
m.texture = texture0
|
||||
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user