Drawing our first triangle
We have our model class that handles all of the geometry data, as well as the shader class, which deals with processing our data at various points of the programmable rendering pipeline. With that out of the way, all we have left to do is actually set up and use these classes. Let us start by adding them as data members to the Game
object:
class Game{ ... private: ... std::unique_ptr<GL_Shader> m_shader; std::unique_ptr<GL_Model> m_model; ... };
They can then be set up in the constructor of our Game
class:
Game::Game() ... { ... m_shader = std::make_unique<GL_Shader>( Utils::GetWorkingDirectory() + "GL/basic"); GL_Vertex vertices[] = { // |-----POSITION----| // X Y Z GL_Vertex({ -0.5, -0.5, 0.5 }, // 0 GL_Vertex({ -0.5, 0.5, 0.5 }, // 1 GL_Vertex({ 0.5, 0.5, 0.5 }, // 2 }; m_model = std::make_unique<GL_Model>(vertices, 3); }
First, the shader class...