O'Reilly logo

Mastering SFML Game Development by Raimondas Pupius

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required