scg3  0.6
GeometryCore.h
Go to the documentation of this file.
1 
9 /*
10  * Copyright 2014-2019 Volker Ahlers
11  *
12  * Licensed under the Apache License, Version 2.0 (the "License");
13  * you may not use this file except in compliance with the License.
14  * You may obtain a copy of the License at
15  *
16  * http://www.apache.org/licenses/LICENSE-2.0
17  *
18  * Unless required by applicable law or agreed to in writing, software
19  * distributed under the License is distributed on an "AS IS" BASIS,
20  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21  * See the License for the specific language governing permissions and
22  * limitations under the License.
23  */
24 
25 #ifndef GEOMETRYCORE_H_
26 #define GEOMETRYCORE_H_
27 
28 #include <functional>
29 #include <vector>
30 #include "scg_glew.h"
31 #include "Core.h"
32 #include "scg_internals.h"
33 
34 namespace scg {
35 
36 
40 enum class DrawMode {
41  ARRAYS,
42  ELEMENTS
43 };
44 
45 
53 class GeometryCore: public Core {
54 
55 public:
56 
64  GeometryCore(GLenum primitiveType, DrawMode drawMode);
65 
69  virtual ~GeometryCore();
70 
74  static GeometryCoreSP create(GLenum primitiveType, DrawMode drawMode);
75 
85  GeometryCore* addAttributeData(GLuint location, const GLfloat* data, GLsizeiptr size, GLint dim, GLenum usage);
86 
95  GeometryCore* setElementIndexData(const GLuint* data, GLsizeiptr size, GLenum usage);
96 
100  int getNTriangles() const;
101 
105  virtual void render(RenderState* renderState);
106 
107 protected:
108 
111  std::function<void(GLenum, GLsizei)> drawFunc_;
112  GLuint vao_;
113  std::vector<GLuint> vboAttributes_;
114  GLuint vboIndex_;
115  GLsizei nElements_;
116 
117 };
118 
119 
120 } /* namespace scg */
121 
122 #endif /* GEOMETRYCORE_H_ */
A core that contains geometry information to be rendered.
Definition: GeometryCore.h:53
virtual ~GeometryCore()
GeometryCore(GLenum primitiveType, DrawMode drawMode)
std::vector< GLuint > vboAttributes_
Definition: GeometryCore.h:113
Base class for all cores (abstract).
Definition: Core.h:36
static GeometryCoreSP create(GLenum primitiveType, DrawMode drawMode)
int getNTriangles() const
Local header file for GLEW library.
std::function< void(GLenum, GLsizei)> drawFunc_
Definition: GeometryCore.h:111
GeometryCore * addAttributeData(GLuint location, const GLfloat *data, GLsizeiptr size, GLint dim, GLenum usage)
The central render state that collects information about the current shader, transformations,...
Definition: RenderState.h:107
GeometryCore * setElementIndexData(const GLuint *data, GLsizeiptr size, GLenum usage)
virtual void render(RenderState *renderState)
DrawMode
Draw mode for vertex buffer objects.
Definition: GeometryCore.h:40
Definition: Animation.h:28
Internal definitions required by most classes.
Base class for all cores (abstract).