ScummVM API documentation
VertexBufferVBO.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22/*
23 * Copyright (C) 2006-2010 - Frictional Games
24 *
25 * This file is part of HPL1 Engine.
26 */
27
28#ifndef HPL_VERTEXBUFFER_VBO_H
29#define HPL_VERTEXBUFFER_VBO_H
30
31#include "common/scummsys.h"
32#include "hpl1/engine/graphics/VertexBuffer.h"
33#include "hpl1/opengl.h"
34
35#ifdef HPL1_USE_OPENGL
36
37namespace hpl {
38
39class cVertexBufferVBO : public iVertexBuffer {
40public:
41 cVertexBufferVBO(iLowLevelGraphics *apLowLevelGraphics, tVertexFlag aFlags,
42 eVertexBufferDrawType aDrawType, eVertexBufferUsageType aUsageType,
43 int alReserveVtxSize, int alReserveIdxSize);
44 ~cVertexBufferVBO();
45
46 void AddVertex(tVertexFlag aType, const cVector3f &avVtx);
47 void AddColor(tVertexFlag aType, const cColor &aColor);
48 void AddIndex(unsigned int alIndex);
49
50 bool Compile(tVertexCompileFlag aFlags);
51 void UpdateData(tVertexFlag aTypes, bool abIndices);
52
53 void CreateShadowDouble(bool abUpdateData);
54
55 void Transform(const cMatrixf &mtxTransform);
56
57 void Draw(eVertexBufferDrawType aDrawType = eVertexBufferDrawType_LastEnum);
58 void DrawIndices(unsigned int *apIndices, int alCount,
59 eVertexBufferDrawType aDrawType = eVertexBufferDrawType_LastEnum);
60
61 void Bind();
62 void UnBind();
63
64 iVertexBuffer *CreateCopy(eVertexBufferUsageType aUsageType);
65
66 cBoundingVolume CreateBoundingVolume();
67
68 int GetVertexNum();
69 int GetIndexNum();
70
71 float *GetArray(tVertexFlag aType);
72 unsigned int *GetIndices();
73
74 void ResizeArray(tVertexFlag aType, int alSize);
75 void ResizeIndices(int alSize);
76
77 // For debugging purposes
78 cVector3f GetVector3(tVertexFlag aType, unsigned alIdx);
79 cVector3f GetVector4(tVertexFlag aType, unsigned alIdx);
80 cColor GetColor(tVertexFlag aType, unsigned alIdx);
81 unsigned int GetIndex(tVertexFlag aType, unsigned alIdx);
82
83private:
84 int GetElementNum(tVertexFlag aFlag);
85
86 void SetVertexStates(tVertexFlag aFlags);
87
88 unsigned int mlElementHandle;
89
90 tFloatVec mvVertexArray[klNumOfVertexFlags];
91
92 unsigned int mvArrayHandle[klNumOfVertexFlags];
93
94 tUIntVec mvIndexArray;
95
96 bool mbHasShadowDouble;
97
98 bool mbCompiled;
99};
100
101} // namespace hpl
102
103#endif // HPL1_USE_OPENGL
104#endif // HPL_RENDERER3D_VBO_H