Kaydet (Commit) 6be20258 authored tarafından Zolnai Tamás's avatar Zolnai Tamás

libgltf: check for #version string in the shader before add an own one.

Change-Id: I69dbbabc5774cbce7943e77f41bb42ed7a118bcf
üst e3794016
diff -ur libgltf.org/src/Shaders.cpp libgltf/src/Shaders.cpp diff -ur libgltf.org/src/Shaders.cpp libgltf/src/Shaders.cpp
--- libgltf.org/src/Shaders.cpp 2014-08-17 09:15:17.379255115 +0200 --- libgltf.org/src/Shaders.cpp 2014-08-18 09:19:48.323955939 +0200
+++ libgltf/src/Shaders.cpp 2014-08-17 09:16:43.323258781 +0200 +++ libgltf/src/Shaders.cpp 2014-08-18 09:20:46.711953465 +0200
@@ -11,6 +11,7 @@ @@ -11,6 +11,7 @@
#include <GL/glew.h> #include <GL/glew.h>
...@@ -9,22 +9,29 @@ diff -ur libgltf.org/src/Shaders.cpp libgltf/src/Shaders.cpp ...@@ -9,22 +9,29 @@ diff -ur libgltf.org/src/Shaders.cpp libgltf/src/Shaders.cpp
namespace libgltf namespace libgltf
{ {
@@ -166,7 +167,17 @@ @@ -166,7 +167,24 @@
unsigned int shaderId) unsigned int shaderId)
{ {
GLint iGLSize = iSize; GLint iGLSize = iSize;
- glShaderSource(shaderId, 1, &pShader, &iGLSize); - glShaderSource(shaderId, 1, &pShader, &iGLSize);
+ const GLchar* aSources[] = { + if( strstr(pShader,"#version") == 0 )
+ "#version 130\n", + {
+ pShader, + const GLchar* aSources[] = {
+ }; + "#version 130\n",
+ pShader,
+ };
+ +
+ const GLint aSizes[] = { + const GLint aSizes[] = {
+ strlen("#version 130\n"), + strlen("#version 130\n"),
+ iGLSize, + iGLSize,
+ }; + };
+ +
+ glShaderSource(shaderId, 2, &aSources[0], &aSizes[0]); + glShaderSource(shaderId, 2, &aSources[0], &aSizes[0]);
+ }
+ else
+ {
+ glShaderSource(shaderId, 1, &pShader, &iGLSize);
+ }
glCompileShader(shaderId); glCompileShader(shaderId);
int iStatus = 0; int iStatus = 0;
glGetShaderiv(shaderId, GL_COMPILE_STATUS, &iStatus); glGetShaderiv(shaderId, GL_COMPILE_STATUS, &iStatus);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment