-
Notifications
You must be signed in to change notification settings - Fork 8
/
OpenGLRender.cpp
458 lines (391 loc) · 16.5 KB
/
OpenGLRender.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
#include "OpenGLRender.h"
#include <QOpenGLFunctions>
#include <QOpenGLShader>
#include <QOpenGLShaderProgram>
#include <QSurfaceFormat>
#include <QPainter>
#include <QDebug>
OpenGLRender::OpenGLRender(QWidget *parent)
: QOpenGLWidget(parent)
, m_YUVTransFormMatrix(1.0f, 1.0f, 1.0f, 0.0f, \
0.0f, -0.39465f, 2.03211, 0.0f, \
1.13983f, -0.58060f, 0.0f, 0.0f, \
0.0f, 0.0f, 0.0f, 0.0f)
{
this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
}
OpenGLRender::~OpenGLRender()
{
}
GLuint OpenGLRender::createGPUProgram(const QString& vertexShaderFile, const QString& fragmentShaderFile)
{
// load vertex shader
m_pVertexShader = new QOpenGLShader(QOpenGLShader::Vertex, this);
bool result = m_pVertexShader->compileSourceFile(vertexShaderFile);
if (!result)
{
//qDebug() << m_pVertexShader->log();
delete m_pVertexShader;
m_pVertexShader = nullptr;
}
// load fragment shader
m_pFragmentShader = new QOpenGLShader(QOpenGLShader::Fragment, this);
result = m_pFragmentShader->compileSourceFile(fragmentShaderFile);
if (!result)
{
//qDebug() << m_pFragmentShader->log();
delete m_pVertexShader;
m_pVertexShader = nullptr;
delete m_pFragmentShader;
m_pFragmentShader = nullptr;
}
// create shader program
m_pShaderProgram = new QOpenGLShaderProgram(this);
m_pShaderProgram->addShader(m_pVertexShader);
m_pShaderProgram->addShader(m_pFragmentShader);
m_pShaderProgram->link();
return m_pShaderProgram->programId();
}
void OpenGLRender::initializeGL(void)
{
m_pFunc = QOpenGLContext::currentContext()->functions();
m_pFunc->glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
GLuint programId = createGPUProgram(":/Resources/VertexShader.vert", ":/Resources/FragmentShader.frag");
// 获取Uniform ID & Attribute ID
m_mLocalMat = m_pFunc->glGetUniformLocation(programId, "M");
m_vLocalMat = m_pFunc->glGetUniformLocation(programId, "V");
m_pLocalMat = m_pFunc->glGetUniformLocation(programId, "P");
m_texture = m_pFunc->glGetUniformLocation(programId, "U_MainTexture");
m_posVector = m_pFunc->glGetAttribLocation(programId, "pos");
m_colorVector = m_pFunc->glGetAttribLocation(programId, "color");
m_coordVector = m_pFunc->glGetAttribLocation(programId, "coord");
// YUV About
m_textureY = m_pFunc->glGetUniformLocation(programId, "Tex_y");
m_textureU = m_pFunc->glGetUniformLocation(programId, "Tex_u");
m_textureV = m_pFunc->glGetUniformLocation(programId, "Tex_v");
m_yuvMat = m_pFunc->glGetUniformLocation(programId, "YUVMat");
// 创建VBO
VertexInfo nVertexInfo[4];
nVertexInfo[0].pos[0] = -1.0f;
nVertexInfo[0].pos[1] = 1.0f;
nVertexInfo[0].pos[2] = 0.0f;
nVertexInfo[0].color[0] = 0.0f;
nVertexInfo[0].color[1] = 0.0f;
nVertexInfo[0].color[2] = 0.0f;
nVertexInfo[0].color[3] = 0.0f;
nVertexInfo[0].coord[0] = 0.0f;
nVertexInfo[0].coord[1] = 0.0f;
nVertexInfo[1].pos[0] = -1.0f;
nVertexInfo[1].pos[1] = -1.0f;
nVertexInfo[1].pos[2] = 0.0f;
nVertexInfo[1].color[0] = 0.0f;
nVertexInfo[1].color[1] = 0.0f;
nVertexInfo[1].color[2] = 0.0f;
nVertexInfo[1].color[3] = 0.0f;
nVertexInfo[1].coord[0] = 0.0f;
nVertexInfo[1].coord[1] = 1.0f;
nVertexInfo[2].pos[0] = 1.0f;
nVertexInfo[2].pos[1] = 1.0f;
nVertexInfo[2].pos[2] = 0.0f;
nVertexInfo[2].color[0] = 0.0f;
nVertexInfo[2].color[1] = 0.0f;
nVertexInfo[2].color[2] = 0.0f;
nVertexInfo[2].color[3] = 0.0f;
nVertexInfo[2].coord[0] = 1.0f;
nVertexInfo[2].coord[1] = 0.0f;
nVertexInfo[3].pos[0] = 1.0f;
nVertexInfo[3].pos[1] = -1.0f;
nVertexInfo[3].pos[2] = -1.0f;
nVertexInfo[3].color[0] = 0.0f;
nVertexInfo[3].color[1] = 0.0f;
nVertexInfo[3].color[2] = 0.0f;
nVertexInfo[3].color[3] = 0.0f;
nVertexInfo[3].coord[0] = 1.0f;
nVertexInfo[3].coord[1] = 1.0f;
// Create VBO
m_pFunc->glGenBuffers(1, &m_vboId);
m_pFunc->glBindBuffer(GL_ARRAY_BUFFER, m_vboId);
m_pFunc->glBufferData(GL_ARRAY_BUFFER, sizeof(VertexInfo) * 4, nVertexInfo, GL_STATIC_DRAW);
m_pFunc->glBindBuffer(GL_ARRAY_BUFFER, 0);
// Create IBO
unsigned int index[6] = { 0, 1, 2, 1, 3, 2};
m_pFunc->glGenBuffers(1, &m_iboId);
m_pFunc->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_iboId);
m_pFunc->glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(index), index, GL_STATIC_DRAW);
m_pFunc->glBindBuffer(GL_ARRAY_BUFFER, 0);
// bind texture
//createTexture(m_textureId, ":/Resources/25.jpg");
createTexture(m_textureId, ":/Resources/25.jpg");
// bind YUV texture
createYUVTexture();
// bind VBO
m_pFunc->glBindBuffer(GL_ARRAY_BUFFER, m_vboId);
// 使用DrawArrays绘制
m_pFunc->glEnableVertexAttribArray(m_posVector);
m_pFunc->glVertexAttribPointer(m_posVector, 3, GL_FLOAT, GL_FALSE, sizeof(VertexInfo), (void*)0);
m_pFunc->glEnableVertexAttribArray(m_colorVector);
m_pFunc->glVertexAttribPointer(m_colorVector, 4, GL_FLOAT, GL_FALSE, sizeof(VertexInfo), (void*)(sizeof(float) * 3));
m_pFunc->glEnableVertexAttribArray(m_coordVector);
m_pFunc->glVertexAttribPointer(m_coordVector, 2, GL_FLOAT, GL_FALSE, sizeof(VertexInfo), (void*)(sizeof(float) * 7));
//OpenGLCore->glDrawArrays(GL_TRIANGLES, 0, 3);
m_pFunc->glBindBuffer(GL_ARRAY_BUFFER, 0);
m_pShaderProgram->bind();
}
void OpenGLRender::paintGL(void)
{
/*bool result = m_pShaderProgram->bind();
if (!result)
return;*/
QPainter painter(this);
painter.beginNativePainting();
m_pShaderProgram->bind();
QMatrix4x4 nMormalMat;
m_pFunc->glClearColor(41.0f / 255.0f, 71.0f / 255.0f, 121.0f / 255.0f, 1.0f);
m_pFunc->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
m_pFunc->glUniformMatrix4fv(m_mLocalMat, 1, GL_FALSE, nMormalMat.data());
m_pFunc->glUniformMatrix4fv(m_vLocalMat, 1, GL_FALSE, nMormalMat.data());
m_pFunc->glUniformMatrix4fv(m_pLocalMat, 1, GL_FALSE, nMormalMat.data());
m_pFunc->glUniformMatrix4fv(m_yuvMat, 1, GL_FALSE, m_YUVTransFormMatrix.data());
// for rgb 0Texture
if (m_isUsedRgbTexture)
{
m_pFunc->glActiveTexture(GL_TEXTURE0);
m_pFunc->glBindTexture(GL_TEXTURE_2D, m_textureId);
m_pFunc->glUniform1i(m_texture, 0);
}
else
{
// For YUV Texture
m_pFunc->glActiveTexture(GL_TEXTURE0);
m_pFunc->glBindTexture(GL_TEXTURE_2D, m_textureYId);
m_pFunc->glUniform1i(m_textureY, 0);
m_pFunc->glActiveTexture(GL_TEXTURE1);
m_pFunc->glBindTexture(GL_TEXTURE_2D, m_textureUId);
m_pFunc->glUniform1i(m_textureU, 1);
m_pFunc->glActiveTexture(GL_TEXTURE2);
m_pFunc->glBindTexture(GL_TEXTURE_2D, m_textureVId);
m_pFunc->glUniform1i(m_textureV, 2);
}
// bind VBO
m_pFunc->glBindBuffer(GL_ARRAY_BUFFER, m_vboId);
// 使用DrawArrays绘制
m_pFunc->glEnableVertexAttribArray(m_posVector);
m_pFunc->glVertexAttribPointer(m_posVector, 3, GL_FLOAT, GL_FALSE, sizeof(VertexInfo), (void*)0);
m_pFunc->glEnableVertexAttribArray(m_colorVector);
m_pFunc->glVertexAttribPointer(m_colorVector, 4, GL_FLOAT, GL_FALSE, sizeof(VertexInfo), (void*)(sizeof(float) * 3));
m_pFunc->glEnableVertexAttribArray(m_coordVector);
m_pFunc->glVertexAttribPointer(m_coordVector, 2, GL_FLOAT, GL_FALSE, sizeof(VertexInfo), (void*)(sizeof(float) * 7));
//OpenGLCore->glDrawArrays(GL_TRIANGLES, 0, 3);
m_pFunc->glBindBuffer(GL_ARRAY_BUFFER, 0);
// 使用DeawElement绘制
m_pFunc->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_iboId);
m_pFunc->glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);
m_pFunc->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
m_pShaderProgram->release();
painter.endNativePainting();
/*QPen nPen;
nPen.setColor(QColor(255, 0, 0));
QFont font = this->font();
font.setPixelSize(30);
painter.setFont(font);
painter.setPen(nPen);
painter.drawText(this->rect(), "Test Text");*/
customPainterEvent(&painter);
//m_pShaderProgram->release();
}
void OpenGLRender::resizeGL(int w, int h)
{
m_pFunc->glViewport(0, 0, w, h);
if (m_nWidth > 0 && m_nHeight > 0)
this->rebindVBO(m_nWidth, m_nHeight);
/*mProjectionMatrix.setToIdentity();
mProjectionMatrix.perspective(45.0f, w * 1.0f / h, 0.1f, 500.0f);*/
update();
}
void OpenGLRender::customPainterEvent(QPainter* painter)
{
Q_UNUSED(painter)
}
void OpenGLRender::createTexture(GLuint& textureId, const QString& imageFile)
{
QImage image(imageFile);
if (image.isNull())
return;
image = image.convertToFormat(QImage::Format_RGB888);
//image = image.mirrored();
m_pFunc->glGenTextures(1, &textureId);
m_pFunc->glBindTexture(GL_TEXTURE_2D, textureId);
m_pFunc->glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, image.width(), image.height(), 0, \
GL_RGB, GL_UNSIGNED_BYTE, image.bits());
m_pFunc->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
m_pFunc->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
m_pFunc->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
m_pFunc->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
m_pFunc->glBindTexture(GL_TEXTURE_2D, 0);
// rebind vbo
m_nWidth = image.width();
m_nHeight = image.height();
rebindVBO(m_nWidth, m_nHeight);
}
void OpenGLRender::createTexture(GLuint& textureId)
{
m_pFunc->glGenTextures(1, &textureId);
m_pFunc->glBindTexture(GL_TEXTURE_2D, textureId);
m_pFunc->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
m_pFunc->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
m_pFunc->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
m_pFunc->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
m_pFunc->glBindTexture(GL_TEXTURE_2D, 0);
}
void OpenGLRender::createYUVTexture(void)
{
// Create Y Texture
m_pFunc->glGenTextures(1, &m_textureYId);
m_pFunc->glBindTexture(GL_TEXTURE_2D, m_textureYId);
m_pFunc->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
m_pFunc->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
m_pFunc->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
m_pFunc->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
m_pFunc->glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, 1024, 768, 0, GL_RED, GL_UNSIGNED_BYTE, 0);
m_pFunc->glBindTexture(GL_TEXTURE_2D, 0);
// Create U Texture
m_pFunc->glGenTextures(1, &m_textureUId);
m_pFunc->glBindTexture(GL_TEXTURE_2D, m_textureUId);
m_pFunc->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
m_pFunc->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
m_pFunc->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
m_pFunc->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
m_pFunc->glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, 1024, 768, 0, GL_RED, GL_UNSIGNED_BYTE, 0);
m_pFunc->glBindTexture(GL_TEXTURE_2D, 0);
// Create V Texture
m_pFunc->glGenTextures(1, &m_textureVId);
m_pFunc->glBindTexture(GL_TEXTURE_2D, m_textureVId);
m_pFunc->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
m_pFunc->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
m_pFunc->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
m_pFunc->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
m_pFunc->glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, 1024, 768, 0, GL_RED, GL_UNSIGNED_BYTE, 0);
m_pFunc->glBindTexture(GL_TEXTURE_2D, 0);
}
void OpenGLRender::loadTexture(const uchar* pImageData, int width, int height)
{
m_pFunc->glBindTexture(GL_TEXTURE_2D, m_textureId);
m_pFunc->glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, \
GL_RGB, GL_UNSIGNED_BYTE, pImageData);
/*m_pFunc->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
m_pFunc->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
m_pFunc->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
m_pFunc->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);*/
m_pFunc->glBindTexture(GL_TEXTURE_2D, 0);
}
void OpenGLRender::loadYUVTexture(uchar* const pImageData[], int width, int height)
{
// Y
m_pFunc->glBindTexture(GL_TEXTURE_2D, m_textureYId);
m_pFunc->glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, width, height, 0, \
GL_RED, GL_UNSIGNED_BYTE, pImageData[0]);
/*m_pFunc->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
m_pFunc->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
m_pFunc->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
m_pFunc->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);*/
m_pFunc->glBindTexture(GL_TEXTURE_2D, 0);
// U
m_pFunc->glBindTexture(GL_TEXTURE_2D, m_textureUId);
m_pFunc->glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, width / 2, height / 2, 0, \
GL_RED, GL_UNSIGNED_BYTE, pImageData[1]);
/*m_pFunc->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
m_pFunc->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
m_pFunc->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
m_pFunc->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);*/
m_pFunc->glBindTexture(GL_TEXTURE_2D, 0);
// V
m_pFunc->glBindTexture(GL_TEXTURE_2D, m_textureVId);
m_pFunc->glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, width / 2, height / 2, 0, \
GL_RED, GL_UNSIGNED_BYTE, pImageData[2]);
/*m_pFunc->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
m_pFunc->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
m_pFunc->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
m_pFunc->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);*/
m_pFunc->glBindTexture(GL_TEXTURE_2D, 0);
}
void OpenGLRender::setRGBData(const uchar* pImageData, int width, int height)
{
// ReBind vbo
if (m_nWidth != width || m_nHeight != height)
{
m_nWidth = width;
m_nHeight = height;
rebindVBO(m_nWidth, m_nHeight);
}
// Rebind texture
loadTexture(pImageData, width, height);
m_isUsedRgbTexture = true;
this->update();
}
void OpenGLRender::setYUVData(uchar* const pImageData[], int width, int height)
{
// ReBind vbo
if (m_nWidth != width || m_nHeight != height)
{
m_nWidth = width;
m_nHeight = height;
rebindVBO(m_nWidth, m_nHeight);
}
loadYUVTexture(pImageData, width, height);
// changed YUV row 3 w value for YUV Transform
QVector4D vec4 = m_YUVTransFormMatrix.column(3);
vec4.setW(1.0);
m_YUVTransFormMatrix.setColumn(3, vec4);
m_isUsedRgbTexture = false;
this->update();
}
void OpenGLRender::rebindVBO(int width, int height)
{
float rx = this->width() * 1.0 / width;
float ry = this->height() * 1.0 / height;
float minr = qMin(rx, ry);
float x = width * minr / this->width();
float y = height * minr / this->height();
// 创建VBO
VertexInfo nVertexInfo[4];
nVertexInfo[0].pos[0] = -x;
nVertexInfo[0].pos[1] = y;
nVertexInfo[0].pos[2] = 0.0f;
nVertexInfo[0].color[0] = 1.0f;
nVertexInfo[0].color[1] = 0.0f;
nVertexInfo[0].color[2] = 0.0f;
nVertexInfo[0].color[3] = 1.0f;
nVertexInfo[0].coord[0] = 0.0f;
nVertexInfo[0].coord[1] = 0.0f;
nVertexInfo[1].pos[0] = -x;
nVertexInfo[1].pos[1] = -y;
nVertexInfo[1].pos[2] = 0.0f;
nVertexInfo[1].color[0] = 0.0f;
nVertexInfo[1].color[1] = 1.0f;
nVertexInfo[1].color[2] = 0.0f;
nVertexInfo[1].color[3] = 1.0f;
nVertexInfo[1].coord[0] = 0.0f;
nVertexInfo[1].coord[1] = 1.0f;
nVertexInfo[2].pos[0] = x;
nVertexInfo[2].pos[1] = y;
nVertexInfo[2].pos[2] = 0.0f;
nVertexInfo[2].color[0] = 0.0f;
nVertexInfo[2].color[1] = 0.0f;
nVertexInfo[2].color[2] = 1.0f;
nVertexInfo[2].color[3] = 1.0f;
nVertexInfo[2].coord[0] = 1.0f;
nVertexInfo[2].coord[1] = 0.0f;
nVertexInfo[3].pos[0] = x;
nVertexInfo[3].pos[1] = -y;
nVertexInfo[3].pos[2] = 0.0f;
nVertexInfo[3].color[0] = 1.0f;
nVertexInfo[3].color[1] = 0.0f;
nVertexInfo[3].color[2] = 1.0f;
nVertexInfo[3].color[3] = 1.0f;
nVertexInfo[3].coord[0] = 1.0f;
nVertexInfo[3].coord[1] = 1.0f;
// Create VBO
m_pFunc->glBindBuffer(GL_ARRAY_BUFFER, m_vboId);
m_pFunc->glBufferData(GL_ARRAY_BUFFER, sizeof(VertexInfo) * 4, nVertexInfo, GL_STATIC_DRAW);
m_pFunc->glBindBuffer(GL_ARRAY_BUFFER, 0);
}