Voxellancer  0.3
A game about voxels in space
 All Classes Functions Pages
voxelparticlerenderer.h
1 #pragma once
2 
3 #include <string>
4 
5 #include <GL/glew.h>
6 
7 #include "etc/contextdependant.h"
8 #include "property/property.h"
9 
10 #include "voxelparticledata.h"
11 
12 
13 namespace glow {
14  class Buffer;
15  class Program;
16  class VertexArrayObject;
17 }
18 
19 class Camera;
20 class VoxelMesh;
22 
23 /*
24  Component of a VoxelParticleEngine responsible for rendering the particles
25  It holds its own GPU-Buffer and receives updates for the particles by updateBuffer()
26 */
28 public:
31 
32  void updateBuffer(int begin, int end, VoxelParticleData* data);
33 
34  void draw(const Camera& camera);
35 
36 
37 protected:
38  std::unique_ptr<VoxelMesh> m_voxelMesh;
39 
40  bool m_initialized;
41  VoxelParticleEngine* m_engine;
42  int m_bufferSize;
43 
44  Property<glm::vec3> m_defaultLightDir;
45 
46  glow::ref_ptr<glow::Buffer> m_gpuParticleBuffer;
47  glow::ref_ptr<glow::Program> m_program;
48  glow::ref_ptr<glow::VertexArrayObject> m_vertexArrayObject;
49 
50 
51  void initialize();
52  void loadProgram();
53  void setupVertexAttributes();
54  void setupVertexAttribute(GLint offset, const std::string& name, int numPerVertex, GLenum type, GLboolean normalised, int bindingNum);
55  void setupVertexAttribDivisors();
56  void setBufferSize(int bufferSize);
57 
58  virtual void beforeContextDestroy() override;
59  virtual void afterContextRebuild() override;
60 };
61 
Definition: voxelparticledata.h:7
Definition: contextdependant.h:7
Definition: voxelparticleengine.h:23
Definition: voxelparticlerenderer.h:27
Definition: camera.h:10
Definition: voxelmesh.h:21