|
@@ -246,6 +246,7 @@ std::string Shader::getVersion(bool linked) {
|
246
|
246
|
|
247
|
247
|
Shader Shader::textureShader;
|
248
|
248
|
Shader Shader::colorShader;
|
|
249
|
+Shader Shader::transformedColorShader;
|
249
|
250
|
unsigned int Shader::vertexArrayID = 0;
|
250
|
251
|
bool Shader::lastBufferWasNotFramebuffer = true;
|
251
|
252
|
|
|
@@ -276,6 +277,9 @@ int Shader::initialize() {
|
276
|
277
|
if (colorShader.addUniform("MVP") < 0)
|
277
|
278
|
return -5;
|
278
|
279
|
|
|
280
|
+ if (transformedColorShader.compile(transformedColorShaderVertex, transformedColorShaderFragment) < 0)
|
|
281
|
+ return -6;
|
|
282
|
+
|
279
|
283
|
return 0;
|
280
|
284
|
}
|
281
|
285
|
|
|
@@ -402,6 +406,43 @@ void Shader::drawGL(std::vector<glm::vec3>& vertices, std::vector<glm::vec3>& co
|
402
|
406
|
shader.otherBuffer.unbind(1);
|
403
|
407
|
}
|
404
|
408
|
|
|
409
|
+void Shader::drawGL(std::vector<glm::vec4>& vertices, std::vector<glm::vec3>& colors,
|
|
410
|
+ gl::GLenum mode, ShaderTexture* target, Shader& shader) {
|
|
411
|
+ bindProperBuffer(target);
|
|
412
|
+
|
|
413
|
+ shader.use();
|
|
414
|
+ shader.vertexBuffer.bufferData(vertices);
|
|
415
|
+ shader.otherBuffer.bufferData(colors);
|
|
416
|
+
|
|
417
|
+ shader.vertexBuffer.bindBuffer(0, 4);
|
|
418
|
+ shader.otherBuffer.bindBuffer(1, 3);
|
|
419
|
+
|
|
420
|
+ gl::glDrawArrays(mode, 0, shader.vertexBuffer.getSize());
|
|
421
|
+
|
|
422
|
+ shader.vertexBuffer.unbind(0);
|
|
423
|
+ shader.otherBuffer.unbind(0);
|
|
424
|
+}
|
|
425
|
+
|
|
426
|
+void Shader::drawGL(std::vector<glm::vec4>& vertices, std::vector<glm::vec3>& colors,
|
|
427
|
+ std::vector<unsigned short>& indices, gl::GLenum mode,
|
|
428
|
+ ShaderTexture* target, Shader& shader) {
|
|
429
|
+ bindProperBuffer(target);
|
|
430
|
+
|
|
431
|
+ shader.use();
|
|
432
|
+ shader.vertexBuffer.bufferData(vertices);
|
|
433
|
+ shader.otherBuffer.bufferData(colors);
|
|
434
|
+ shader.indexBuffer.bufferData(indices);
|
|
435
|
+
|
|
436
|
+ shader.vertexBuffer.bindBuffer(0, 4);
|
|
437
|
+ shader.otherBuffer.bindBuffer(1, 3);
|
|
438
|
+ shader.indexBuffer.bindBuffer();
|
|
439
|
+
|
|
440
|
+ gl::glDrawElements(mode, shader.indexBuffer.getSize(), gl::GL_UNSIGNED_SHORT, nullptr);
|
|
441
|
+
|
|
442
|
+ shader.vertexBuffer.unbind(0);
|
|
443
|
+ shader.otherBuffer.unbind(0);
|
|
444
|
+}
|
|
445
|
+
|
405
|
446
|
// --------------------------------------
|
406
|
447
|
// *INDENT-OFF*
|
407
|
448
|
|
|
@@ -468,5 +509,33 @@ void main() {
|
468
|
509
|
)!?!";
|
469
|
510
|
|
470
|
511
|
// --------------------------------------
|
|
512
|
+
|
|
513
|
+const char* Shader::transformedColorShaderVertex = R"!?!(
|
|
514
|
+#version 330 core
|
|
515
|
+
|
|
516
|
+layout(location = 0) in vec4 vertexPosition;
|
|
517
|
+layout(location = 1) in vec3 vertexColor;
|
|
518
|
+
|
|
519
|
+out vec3 color;
|
|
520
|
+
|
|
521
|
+void main() {
|
|
522
|
+ gl_Position = vertexPosition;
|
|
523
|
+ color = vertexColor;
|
|
524
|
+}
|
|
525
|
+)!?!";
|
|
526
|
+
|
|
527
|
+const char* Shader::transformedColorShaderFragment = R"!?!(
|
|
528
|
+#version 330 core
|
|
529
|
+
|
|
530
|
+in vec3 color;
|
|
531
|
+
|
|
532
|
+layout(location = 0) out vec4 color_out;
|
|
533
|
+
|
|
534
|
+void main() {
|
|
535
|
+ color_out = vec4(color, 1);
|
|
536
|
+}
|
|
537
|
+)!?!";
|
|
538
|
+
|
|
539
|
+// --------------------------------------
|
471
|
540
|
// *INDENT-ON*
|
472
|
541
|
|