GlistEngine
Loading...
Searching...
No Matches
gVbo.h
Go to the documentation of this file.
1/*
2 * gVbo.h
3 *
4 * Created on: 25 Kas 2020
5 * Author: Acer
6 */
7
8#ifndef GRAPHICS_GVBO_H_
9#define GRAPHICS_GVBO_H_
10
11#include "gRenderObject.h"
12
13
14struct gVertex {
15 // position
16 glm::vec3 position{0};
17 // normal
18 glm::vec3 normal{0};
19 // texCoords
20 glm::vec2 texcoords{0};
21 // tangent
22 glm::vec3 tangent{0};
23 // bitangent
24 glm::vec3 bitangent{0};
25 // color
26 glm::vec3 color{0};
27};
28
29
30class gVbo : public gRenderObject {
31public:
33 virtual ~gVbo();
34
35 gVbo(const gVbo&) = delete;
36 gVbo& operator=(const gVbo& other) = delete;
37
38 void setVertexData(const gVertex* vertices, int coordNum, int total);
39 void setIndexData(const gIndex* indices, int total);
40 void clear();
41
42 void bind() const;
43 void unbind() const;
44
45 void enable();
46 void disable();
47 bool isEnabled() const;
50
51// void setMesh(const gMesh* mesh, int usage);
52 void setVertexData(const glm::vec3* vertices, int total, int usage = GL_STATIC_DRAW);
53 void setVertexData(const glm::vec2* vertices, int total, int usage = GL_STATIC_DRAW);
54 void setVertexData(const float* verticesptr, int coordNum, int total, int usage, int stride = 0);
55 void setColorData(const gColor* colors, int total, int usage);
56 void setColorData(const float* color0r, int total, int usage, int stride = 0);
57 void setTexCoordData(const glm::vec2* texCoords, int total, int usage);
58 void setTexCoordData(const float* texCoord0x, int total, int usage, int stride = 0);
59 void setNormalData(const glm::vec3* normals, int total, int usage = GL_STATIC_DRAW);
60 void setNormalData(const float* normal0x, int total, int usage, int stride = 0);
61 void setIndexData(const int* indices, int total, int usage);
62
63 int getVAOid() const;
64 int getVerticesNum() const;
65 int getIndicesNum() const;
66
67
68private:
69 GLuint vao;
70 GLuint vbo, ebo;
71 bool isenabled;
72
73 bool isvertexdataallocated;
74 int vertexdatacoordnum, totalvertexnum;
75 int vertexusage, vertexstride;
76
77 bool isindexdataallocated;
78 int totalindexnum;
79
80};
81
82#endif /* GRAPHICS_GVBO_H_ */
Definition gColor.h:17
Definition gRenderObject.h:25
Definition gVbo.h:30
void setVertexData(const gVertex *vertices, int coordNum, int total)
void setIndexData(const int *indices, int total, int usage)
int getIndicesNum() const
void setVertexData(const float *verticesptr, int coordNum, int total, int usage, int stride=0)
bool isIndexDataAllocated() const
void enable()
void setVertexData(const glm::vec2 *vertices, int total, int usage=GL_STATIC_DRAW)
void setTexCoordData(const float *texCoord0x, int total, int usage, int stride=0)
virtual ~gVbo()
void setColorData(const gColor *colors, int total, int usage)
void unbind() const
gVbo(const gVbo &)=delete
int getVerticesNum() const
void setIndexData(const gIndex *indices, int total)
int getVAOid() const
void setTexCoordData(const glm::vec2 *texCoords, int total, int usage)
void disable()
void setNormalData(const glm::vec3 *normals, int total, int usage=GL_STATIC_DRAW)
void setNormalData(const float *normal0x, int total, int usage, int stride=0)
void bind() const
void setVertexData(const glm::vec3 *vertices, int total, int usage=GL_STATIC_DRAW)
bool isVertexDataAllocated() const
void clear()
void setColorData(const float *color0r, int total, int usage, int stride=0)
gVbo & operator=(const gVbo &other)=delete
bool isEnabled() const
unsigned int gIndex
Definition gRenderObject.h:19
Definition gVbo.h:14
glm::vec3 position
Definition gVbo.h:16
glm::vec3 color
Definition gVbo.h:26
glm::vec3 bitangent
Definition gVbo.h:24
glm::vec3 tangent
Definition gVbo.h:22
glm::vec3 normal
Definition gVbo.h:18
glm::vec2 texcoords
Definition gVbo.h:20