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
|
diff -ur libgltf.org/src/Shaders.cpp libgltf/src/Shaders.cpp
--- libgltf.org/src/Shaders.cpp 2014-08-18 09:19:48.323955939 +0200
+++ libgltf/src/Shaders.cpp 2014-08-18 09:20:46.711953465 +0200
@@ -11,6 +11,7 @@
#include <GL/glew.h>
#include <cstdio>
+#include <cstring>
namespace libgltf
{
@@ -166,7 +167,24 @@
unsigned int shaderId)
{
GLint iGLSize = iSize;
- glShaderSource(shaderId, 1, &pShader, &iGLSize);
+ if( strstr(pShader,"#version") == 0 )
+ {
+ const GLchar* aSources[] = {
+ "#version 130\n",
+ pShader,
+ };
+
+ const GLint aSizes[] = {
+ strlen("#version 130\n"),
+ iGLSize,
+ };
+
+ glShaderSource(shaderId, 2, &aSources[0], &aSizes[0]);
+ }
+ else
+ {
+ glShaderSource(shaderId, 1, &pShader, &iGLSize);
+ }
glCompileShader(shaderId);
int iStatus = 0;
glGetShaderiv(shaderId, GL_COMPILE_STATUS, &iStatus);
|