|
|
|
|
@ -259,37 +259,44 @@ loadScene(RenderState* rs)
|
|
|
|
|
|
|
|
|
|
shader_program* s_default = getShaderByName("default", rs->gl_ctx); |
|
|
|
|
shader_program* s_debug = getShaderByName("debug", rs->gl_ctx); |
|
|
|
|
|
|
|
|
|
if (!s_default || !s_debug) |
|
|
|
|
return false; |
|
|
|
|
if (!s_default || !s_debug) return false; |
|
|
|
|
|
|
|
|
|
// TODO: full lighting model
|
|
|
|
|
model* tex_cube = getModel(rs, "../data/textured_cube.gltf"); |
|
|
|
|
assert(tex_cube != nullptr && tex_cube->num_meshes > 0); |
|
|
|
|
GLmesh* texmesh = getFreeGLMesh(rs); |
|
|
|
|
if (!texmesh) return false; |
|
|
|
|
|
|
|
|
|
if (texmesh) { |
|
|
|
|
*texmesh = loadGLMesh(s_debug, tex_cube->meshes[0], |
|
|
|
|
GL_TRIANGLES, glm::vec3(0, 0, 0)); |
|
|
|
|
*texmesh->model_xform = glm::mat4(1.f); |
|
|
|
|
if (texmesh->vao_id == 0) return false; |
|
|
|
|
|
|
|
|
|
if (texmesh->vao_id == 0) |
|
|
|
|
return false; |
|
|
|
|
// ========
|
|
|
|
|
// NOTE: testing new loadGLMesh interface
|
|
|
|
|
texmesh = getFreeGLMesh(rs); |
|
|
|
|
if (!texmesh) return false; |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
GLVertexAttrib* pos_attrib = getVertexAttribByName(s_debug, "position"); |
|
|
|
|
GLVertexAttrib* normal_attrib = getVertexAttribByName(s_debug, "normal"); |
|
|
|
|
if (!pos_attrib || !normal_attrib) return false; |
|
|
|
|
|
|
|
|
|
GLBufferToAttribMapping attrib_mappings[2] = { |
|
|
|
|
{ "position", nullptr, pos_attrib }, |
|
|
|
|
{ "normal", nullptr, normal_attrib } |
|
|
|
|
}; |
|
|
|
|
*texmesh = loadGLMesh(s_debug, tex_cube->meshes[0], |
|
|
|
|
GL_TRIANGLES, glm::vec3(10, 0, 0), |
|
|
|
|
2, attrib_mappings); |
|
|
|
|
if (texmesh->vao_id == 0) return false; |
|
|
|
|
//
|
|
|
|
|
// ========
|
|
|
|
|
|
|
|
|
|
for (u32 i = 0; i < NUM_CUBES; i++) { |
|
|
|
|
GLmesh* gmesh = getFreeGLMesh(rs); |
|
|
|
|
|
|
|
|
|
if (!gmesh) |
|
|
|
|
return false; |
|
|
|
|
if (!gmesh) return false; |
|
|
|
|
|
|
|
|
|
*gmesh = loadGLMesh(s_default, cube, GL_TRIANGLES, cube_locs[i]); |
|
|
|
|
|
|
|
|
|
if (gmesh->vao_id == 0) |
|
|
|
|
return false; |
|
|
|
|
if (gmesh->vao_id == 0) return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
|