MCPcopy Create free account
hub / github.com/WolfireGames/overgrowth / DrawModel

Method DrawModel

Source/Objects/riggedobject.cpp:2278–2485  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2276}
2277
2278void RiggedObject::DrawModel(Model* model, int lod_level) {
2279 PROFILER_ZONE(g_profiler_ctx, "RiggedObject::DrawModel()");
2280 Graphics* graphics = Graphics::Instance();
2281 Shaders* shaders = Shaders::Instance();
2282
2283 if (!model->vbo_loaded) {
2284 PROFILER_ENTER(g_profiler_ctx, "Create VBO");
2285 model->createVBO();
2286 PROFILER_LEAVE(g_profiler_ctx);
2287 }
2288
2289 PROFILER_ENTER(g_profiler_ctx, "Get shader attributes");
2290 CHECK_GL_ERROR();
2291 int shader = shaders->bound_program;
2292 int vertex_attrib_id = shaders->returnShaderAttrib("vertex_attrib", shader);
2293 int tangent_attrib_id = shaders->returnShaderAttrib("tangent_attrib", shader);
2294 int bitangent_attrib_id = shaders->returnShaderAttrib("bitangent_attrib", shader);
2295 int normal_attrib_id = shaders->returnShaderAttrib("normal_attrib", shader);
2296 int tex_coord_attrib_id = shaders->returnShaderAttrib("tex_coord_attrib", shader);
2297 int morph_tex_offset_attrib_id = shaders->returnShaderAttrib("morph_tex_offset_attrib", shader);
2298 int fur_tex_coord_attrib_id = shaders->returnShaderAttrib("fur_tex_coord_attrib", shader);
2299 int bone_ids_id = shaders->returnShaderAttrib("bone_ids", shader);
2300 int bone_weights_id = shaders->returnShaderAttrib("bone_weights", shader);
2301 int morph_offsets_id = shaders->returnShaderAttrib("morph_offsets", shader);
2302 int transform_mat_column_a_id = shaders->returnShaderAttrib("transform_mat_column_a", shader);
2303 int transform_mat_column_b_id = shaders->returnShaderAttrib("transform_mat_column_b", shader);
2304 int transform_mat_column_c_id = shaders->returnShaderAttrib("transform_mat_column_c", shader);
2305 int vel_id = shaders->returnShaderAttrib("vel_attrib", shader);
2306 PROFILER_LEAVE(g_profiler_ctx);
2307
2308 PROFILER_ENTER(g_profiler_ctx, "Enable shader attributes");
2309 CHECK_GL_ERROR();
2310 if (vertex_attrib_id != -1) {
2311 graphics->EnableVertexAttribArray(vertex_attrib_id);
2312 model->VBO_vertices.Bind();
2313 glVertexAttribPointer(vertex_attrib_id, 3, GL_FLOAT, false, 0, 0);
2314 }
2315 if (tangent_attrib_id != -1) {
2316 graphics->EnableVertexAttribArray(tangent_attrib_id);
2317 model->VBO_tangents.Bind();
2318 glVertexAttribPointer(tangent_attrib_id, 3, GL_FLOAT, false, 0, 0);
2319 }
2320 if (bitangent_attrib_id != -1) {
2321 graphics->EnableVertexAttribArray(bitangent_attrib_id);
2322 model->VBO_bitangents.Bind();
2323 glVertexAttribPointer(bitangent_attrib_id, 3, GL_FLOAT, false, 0, 0);
2324 }
2325 if (normal_attrib_id != -1) {
2326 graphics->EnableVertexAttribArray(normal_attrib_id);
2327 model->VBO_normals.Bind();
2328 glVertexAttribPointer(normal_attrib_id, 3, GL_FLOAT, false, 0, 0);
2329 }
2330 if (tex_coord_attrib_id != -1) {
2331 graphics->EnableVertexAttribArray(tex_coord_attrib_id);
2332 model->VBO_tex_coords.Bind();
2333 glVertexAttribPointer(tex_coord_attrib_id, 2, GL_FLOAT, false, 0, 0);
2334 }
2335

Callers

nothing calls this directly

Calls 13

createVBOMethod · 0.80
returnShaderAttribMethod · 0.80
bindTextureMethod · 0.80
setCullFaceMethod · 0.80
SetBlendFuncMethod · 0.80
setBlendMethod · 0.80
BindMethod · 0.45
offsetMethod · 0.45
DrawElementsMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected