2
* (c) Copyright 1993, Silicon Graphics, Inc.
3
* Copyright � 2012 Linaro Limited
5
* This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
7
* glmark2 is free software: you can redistribute it and/or modify it under the
8
* terms of the GNU General Public License as published by the Free Software
9
* Foundation, either version 3 of the License, or (at your option) any later
12
* glmark2 is distributed in the hope that it will be useful, but WITHOUT ANY
13
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17
* You should have received a copy of the GNU General Public License along with
18
* glmark2. If not, see <http://www.gnu.org/licenses/>.
28
#include "gl-headers.h"
33
PrimitiveState(unsigned int type, unsigned int count, unsigned int offset) :
36
bufferOffset_(offset) {}
40
glDrawElements(type_, count_, GL_UNSIGNED_SHORT,
41
reinterpret_cast<const GLvoid*>(bufferOffset_));
45
unsigned int type_; // Primitive type (e.g. GL_TRIANGLE_STRIP)
46
unsigned int count_; // Number of primitives
47
unsigned int bufferOffset_; // Offset into the element array buffer
54
glBindBuffer(GL_ARRAY_BUFFER, bufferObjects_[0]);
55
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferObjects_[1]);
56
glVertexAttribPointer(vertexIndex_, 2, GL_FLOAT, GL_FALSE, 0, 0);
57
glEnableVertexAttribArray(vertexIndex_);
58
for (std::vector<PrimitiveState>::const_iterator primIt = primVec_.begin();
59
primIt != primVec_.end();
64
glBindBuffer(GL_ARRAY_BUFFER, 0);
65
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
67
void init(int vertexAttribIndex)
69
vertexIndex_ = vertexAttribIndex;
71
// We need 2 buffers for our work here. One for the vertex data.
72
// and one for the index data.
73
glGenBuffers(2, &bufferObjects_[0]);
75
// First, setup the vertex data by binding the first buffer object,
76
// allocating its data store, and filling it in with our vertex data.
77
glBindBuffer(GL_ARRAY_BUFFER, bufferObjects_[0]);
78
glBufferData(GL_ARRAY_BUFFER, vertexData_.size() * sizeof(LibMatrix::vec2),
79
&vertexData_.front(), GL_STATIC_DRAW);
81
// Finally, setup the pointer to our vertex data and enable this
83
glVertexAttribPointer(vertexIndex_, 2, GL_FLOAT, GL_FALSE, 0, 0);
84
glEnableVertexAttribArray(vertexIndex_);
86
// Now repeat for our index data.
87
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferObjects_[1]);
88
glBufferData(GL_ELEMENT_ARRAY_BUFFER,
89
indexData_.size() * sizeof(unsigned short), &indexData_.front(),
92
// Unbind our vertex buffer objects so that their state isn't affected
94
glBindBuffer(GL_ARRAY_BUFFER, 0);
95
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
99
glDeleteBuffers(2, &bufferObjects_[0]);
104
unsigned int bufferObjects_[2];
105
std::vector<LibMatrix::vec2> vertexData_;
106
std::vector<unsigned short> indexData_;
108
unsigned int vertexArray_;
109
std::vector<PrimitiveState> primVec_;
112
struct LetterI : Character
117
struct LetterD : Character
122
struct LetterE : Character
127
struct LetterA : Character
132
struct LetterS : Character
137
struct LetterN : Character
142
struct LetterM : Character
147
struct LetterO : Character
152
struct LetterT : Character
157
#endif // CHARACTERS_H_