void Object_draw(Object *obj){ if(obj->mesh==NULL){ printf("Object not assigned any mesh. Using default mesh\n"); Object_attachMesh(obj, default_mesh); } if(current_shader!=obj->shader){ current_shader=obj->shader; Shader_bind(current_shader); } Shader_update(current_shader, obj->model); glBindVertexArray(obj->vao); glDrawElements(GL_TRIANGLES, obj->mesh->drawCount, GL_UNSIGNED_INT, (void *)0); glBindVertexArray(0); }
void Object_render(Object *obj){ Mat4 mvp; if(obj->mesh==NULL){ printf("Object not assigned any mesh. Using default mesh\n"); Object_attachMesh(obj, default_mesh); } if(current_shader!=obj->shader){ current_shader=obj->shader; Shader_bind(current_shader); } mvp=GLM_mulMat4Mat4(GLM_rotateMat4(GLM_createVec3(0, 0, 1),obj->theta), obj->model); mvp=GLM_mulMat4Mat4(GLM_translateMat4(obj->pos), mvp); mvp=GLM_mulMat4Mat4(VP, mvp); Shader_update(current_shader, mvp); glBindVertexArray(obj->vao); glDrawElements(GL_TRIANGLES, obj->mesh->drawCount, GL_UNSIGNED_INT, (void *)0); glBindVertexArray(0); }
void Renderer_useShader( int pShader ) { if( renderer && pShader < renderer->mShaders.cpt && pShader != renderer->mCurrentShader ) { renderer->mCurrentShader = pShader; Shader_bind( pShader < 0 ? 0 : renderer->mShaders.data[pShader] ); } }