resources.cpp 861 B

12345678910111213141516171819202122232425262728293031
  1. #include "resources.h"
  2. #include "gl/mesh.h"
  3. #include "gl/texture.h"
  4. #include "render_constants.h"
  5. #include <GL/gl.h>
  6. #include <QVector3D>
  7. #include <cmath>
  8. #include <memory>
  9. namespace Render::GL {
  10. using namespace Render::GL::Geometry;
  11. using namespace Render::GL::RGBA;
  12. auto ResourceManager::initialize() -> bool {
  13. initializeOpenGLFunctions();
  14. m_quadMesh.reset(createQuadMesh());
  15. m_groundMesh.reset(createPlaneMesh(1.0F, 1.0F, GroundPlaneSubdivisions));
  16. m_unitMesh.reset(createCubeMesh());
  17. m_whiteTexture = std::make_unique<Texture>();
  18. m_whiteTexture->createEmpty(1, 1, Texture::Format::RGBA);
  19. unsigned char white_pixel[4] = {MaxValue, MaxValue, MaxValue, MaxValue};
  20. m_whiteTexture->bind();
  21. glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE,
  22. white_pixel);
  23. return true;
  24. }
  25. } // namespace Render::GL