GlobeEngine
DrawCommand.h
Go to the documentation of this file.
1 
12 #ifndef GlobeEngine_DrawCommand_h
13 #define GlobeEngine_DrawCommand_h
14 
15 #include "OpenGL_Includes.h"
16 
17 namespace ge {
18  typedef struct {
19  GLuint count;
20  GLuint instanceCount;
21  GLuint firstIndex;
22  GLuint baseVertex;
23  GLuint baseInstance;
25 
26  typedef struct {
27  GLuint count;
28  GLuint instanceCount;
29  GLuint first;
30  GLuint baseInstance;
32 
34  {
35  public:
36  DrawArraysCommand(GLenum _mode, GLint _first, GLsizei _count) {
37  mode = _mode;
38  count = _count;
39  first = _first;
40  };
41 
42  void draw() {
43  glDrawArrays(mode, first, count);
44  }
45 
46  protected:
47  GLenum mode;
48  GLsizei count;
49  GLint first;
50  };
51 
53  {
54  public:
55  DrawArraysInstancedCommand(GLenum _mode, GLint _first, GLsizei _count, GLsizei _instanceCount) : DrawArraysCommand(_mode, _first,_count) {
56  this->instanceCount = _instanceCount;
57  };
58 
59  void draw() {
60  glDrawArraysInstanced(this->mode, this->first, this->count, this->instanceCount);
61  }
62 
63  private:
64  GLsizei instanceCount;
65  };
66 
67  template <int TYPE> class DrawElementsCommand
68  {
69  public:
70  DrawElementsCommand(GLenum _mode, GLsizei _count, const GLvoid * _indices) {
71  mode = _mode;
72  count = _count;
73  indices = _indices;
74  };
75 
76  void draw() {
77  glDrawElements(mode, count, TYPE, indices);
78  }
79 
80  protected:
81  GLenum mode;
82  GLsizei count;
83  const GLvoid* indices;
84  };
85 
86  template <int TYPE> class DrawElementsInstancedCommand : public DrawElementsCommand<TYPE>
87  {
88  public:
89  DrawElementsInstancedCommand(GLenum _mode, GLsizei _count, const GLvoid * _indices, GLsizei _instanceCount ) : DrawElementsCommand<TYPE>(_mode, _count, _indices) {
90  this->instanceCount = _instanceCount;
91  };
92 
93  void draw() {
94  glDrawElementsInstanced(this->mode, this->count, TYPE, this->indices,this->instanceCount);
95  }
96 
97  private:
98  GLsizei instanceCount;
99  };
100 
103 
106 
107 }
108 #endif
DrawArraysInstancedCommand(GLenum _mode, GLint _first, GLsizei _count, GLsizei _instanceCount)
Definition: DrawCommand.h:55
GLsizei count
Definition: DrawCommand.h:82
void draw()
Definition: DrawCommand.h:93
GLenum mode
Definition: DrawCommand.h:81
Definition: DrawCommand.h:33
GLuint first
Definition: DrawCommand.h:29
void glDrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount)
DrawArraysCommand(GLenum _mode, GLint _first, GLsizei _count)
Definition: DrawCommand.h:36
DrawElementsCommand< GL_UNSIGNED_SHORT > DrawElementsCommandUShort
Definition: DrawCommand.h:102
GLuint instanceCount
Definition: DrawCommand.h:28
GLint first
Definition: DrawCommand.h:49
GLenum mode
Definition: DrawCommand.h:47
DrawElementsInstancedCommand< GL_UNSIGNED_INT > DrawElementsInstancedCommandUInt
Definition: DrawCommand.h:104
DrawElementsCommand< GL_UNSIGNED_INT > DrawElementsCommandUInt
Definition: DrawCommand.h:101
Definition: DrawCommand.h:52
DrawElementsCommand(GLenum _mode, GLsizei _count, const GLvoid *_indices)
Definition: DrawCommand.h:70
Definition: DrawCommand.h:86
void draw()
Definition: DrawCommand.h:42
DrawElementsInstancedCommand(GLenum _mode, GLsizei _count, const GLvoid *_indices, GLsizei _instanceCount)
Definition: DrawCommand.h:89
GLuint count
Definition: DrawCommand.h:27
void draw()
Definition: DrawCommand.h:59
Definition: DrawCommand.h:67
GLuint instanceCount
Definition: DrawCommand.h:20
Definition: DrawCommand.h:18
GLuint baseInstance
Definition: DrawCommand.h:30
const GLvoid * indices
Definition: DrawCommand.h:83
Definition: AvalancheTrainingSimulationEngine.h:28
Definition: DrawCommand.h:26
GLuint baseInstance
Definition: DrawCommand.h:23
GLuint count
Definition: DrawCommand.h:19
GLuint firstIndex
Definition: DrawCommand.h:21
GLuint baseVertex
Definition: DrawCommand.h:22
void draw()
Definition: DrawCommand.h:76
GLsizei count
Definition: DrawCommand.h:48
DrawElementsInstancedCommand< GL_UNSIGNED_SHORT > DrawElementsInstancedCommandUShort
Definition: DrawCommand.h:105