Ejemplo n.º 1
0
void Material::DrawVertices(PrimitiveTypes pType, const RenderInfo & rInfo, const VertexIndexData & vid)
{
	RenderArgs ra(pType, rInfo, vid);

	InitializeRendering(ra);

	SetUpTextures(ra);

	RenderDataHandler::BindVertexBuffer(vid.GetVerticesHandle());

	if (vid.UsesIndices())
	{
		DH::BindIndexBuffer(vid.GetIndicesHandle());

		EnableAttributes(ra);

		ShaderHandler::DrawIndexedVertices(pType, vid.GetIndicesCount());
	}
	else
	{
		EnableAttributes(ra);

		ShaderHandler::DrawVertices(pType, vid.GetVerticesCount(), vid.GetFirstVertex());
	}

	DisableAttributes(ra);
}
Ejemplo n.º 2
0
    // Draws the mesh into the draw buffer
    void Mesh::Draw(const glm::mat4& projection_matrix, const glm::mat4& view_matrix, const LightingBuffer& lights)
    {
        shaders.UseThisShader();

        // Matrices
        MVP = projection_matrix * view_matrix * model_matrix;
        
        DrawUniforms(projection_matrix, view_matrix, lights);
        DrawTextures();

        EnableAttributes();
        DrawAttributes();
        
        glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elementBuffer);
        //             |Mode         |Count         |Type             |Array buff offset
        glDrawElements(GL_TRIANGLES, indices.size(), GL_UNSIGNED_SHORT, (void*)0);

        DisableAttributes();

        // We can store now the actual MVP as the previous one
        oldMVP = MVP;
    }