fork download
  1.  
  2. ------------------------------------LOADER.h-------------------------------------------------------
  3. class Loader
  4. {
  5. public:
  6. Loader();
  7. ~Loader();
  8.  
  9. public:
  10. std::shared_ptr<RawModel> loadToVAO(const void *position, const void *color);
  11.  
  12. template<typename _Tp, std::size_t _Nm>
  13. std::shared_ptr<RawModel> loadToVAO(std::array<_Tp, _Nm>&, const void*);
  14.  
  15. private:
  16. VertexArray createVAO(const void *position, const void *color);
  17. };
  18.  
  19. template <typename V, typename... T>
  20. constexpr auto array_of(T &&... t)
  21. -> std::array<V, sizeof...(T)>
  22. {
  23. return {{std::forward<T>(t)...}};
  24. }
  25.  
  26. -----------------------------LOADER.cpp--------------------------
  27.  
  28.  
  29. #include "Loader.h"
  30.  
  31. std::shared_ptr<RawModel> Loader::loadToVAO(const void *position, const void *color)
  32. {
  33. VertexArray *vao = new VertexArray();
  34. vao->Bind();
  35. VertexBuffer *vbo = new VertexBuffer(position, sizeof(float) * 2 * 4);
  36. VertexBufferLayout layout;
  37. layout.Push<float>(2);
  38. vao->AddBuffer(vbo, layout);
  39. std::shared_ptr<RawModel> rawModel(new RawModel());
  40. rawModel->addVAO(vao);
  41. return rawModel;
  42. }
  43.  
  44. template<typename _Tp, std::size_t _Nm>
  45. std::shared_ptr<RawModel> Loader::loadToVAO(std::array<_Tp ,_Nm> &position, const void *color)
  46. {
  47. VertexArray *vao = new VertexArray();
  48. vao->Bind();
  49. VertexBuffer *vbo = new VertexBuffer(position._M_elems, sizeof(_Tp) * position.size());
  50. VertexBufferLayout layout;
  51. layout.Push<_Tp>(2);
  52. vao->AddBuffer(vbo, layout);
  53. std::shared_ptr<RawModel> rawModel(new RawModel());
  54. rawModel->addVAO(vao);
  55. return rawModel;
  56. }
  57.  
  58. Loader::Loader()
  59. {
  60. }
  61.  
  62. Loader::~Loader()
  63. {
  64. }
  65. ------------------------------------main-------------------------------
  66.  
  67.  
  68. auto arr = array_of<float>(
  69. -0.5f, //v0
  70. 0.5f,
  71.  
  72. -0.5f, //v1
  73. -0.5f,
  74.  
  75. 0.5f, //v2
  76. -0.5f,
  77.  
  78. 0.5f,
  79. 0.5f //v3
  80. );
  81.  
  82. (...)
  83.  
  84. Loader loader;
  85. std::shared_ptr<RawModel> rawModel = loader.loadToVAO<float>(arr, color);
  86.  
  87. ^^^^^ Ta linijka zglasz bląd : undefined reference to `std::shared_ptr<RawModel> Loader::loadToVAO<float, 8ull>(std::array<float, 8ull>&, void const*)'
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:29:20: fatal error: Loader.h: No such file or directory
 #include "Loader.h"
                    ^
compilation terminated.
stdout
Standard output is empty