A 2D tile-based sandbox game.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Renderer.cc 904B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #include "Renderer.h"
  2. #include "shaders.h"
  3. #include "Program.h"
  4. #include "TileAtlas.h"
  5. #include "util.h"
  6. namespace Cygnet {
  7. struct TexturedProg: public GlProgram {
  8. using GlProgram::GlProgram;
  9. GlLoc position = attribLoc("position");
  10. GlLoc texCoord = attribLoc("texCoord");
  11. GlLoc tex = uniformLoc("tex");
  12. };
  13. struct SolidColorProg: public GlProgram {
  14. using GlProgram::GlProgram;
  15. GlLoc position = attribLoc("position");
  16. GlLoc color = uniformLoc("color");
  17. };
  18. struct RendererState {
  19. GlVxShader basicVx{Shaders::basicVx};
  20. GlVxShader texturedVx{Shaders::texturedVx};
  21. GlFrShader solidColorFr{Shaders::solidColorFr};
  22. GlFrShader texturedFr{Shaders::texturedFr};
  23. TexturedProg texturedProg{texturedVx, texturedFr};
  24. SolidColorProg solidColorProg{basicVx, solidColorFr};
  25. TileAtlas atlas;
  26. };
  27. Renderer::Renderer(): state_(std::make_unique<RendererState>()) {}
  28. Renderer::~Renderer() = default;
  29. }