Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions src/lib/graphics/TwkGLF/BasicGLProgram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,32 @@ namespace TwkGLF
}
}

namespace
{
// Returns "#version 150\n" for GL3+, empty string for GL2.
// Must be called after a GL context is current.
const char* basicGLVersionHeader()
{
const char* glVersion = (const char*)glGetString(GL_VERSION);
if (glVersion && glVersion[0] >= '3')
return "#version 150\n";
return "";
}
} // namespace

bool BasicGLProgram::compile()
{
GLuint v, f;
m_programId = glCreateProgram();
v = glCreateShader(GL_VERTEX_SHADER);
f = glCreateShader(GL_FRAGMENT_SHADER);
const char* vcode = m_vertexCode.c_str();
glShaderSource(v, 1, &vcode, NULL);

const char* versionHeader = basicGLVersionHeader();
const char* vsrc[2] = {versionHeader, m_vertexCode.c_str()};
glShaderSource(v, 2, vsrc, NULL);
glCompileShader(v);
const char* fcode = m_fragmentCode.c_str();
glShaderSource(f, 1, &fcode, NULL);
const char* fsrc[2] = {versionHeader, m_fragmentCode.c_str()};
glShaderSource(f, 2, fsrc, NULL);
glCompileShader(f);

GLint status = GL_TRUE;
Expand Down
1 change: 0 additions & 1 deletion src/lib/graphics/TwkGLF/glsl/CheckerboardBGFrag.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// SPDX-License-Identifier: Apache-2.0
//
#if __VERSION__ >= 150
#version 150
out vec4 FragColor;
#define FRAGCOLOR FragColor
#else
Expand Down
1 change: 0 additions & 1 deletion src/lib/graphics/TwkGLF/glsl/CloneFrag.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// SPDX-License-Identifier: Apache-2.0
//
#if __VERSION__ >= 150
#version 150
out vec4 FragColor;
#define FRAGCOLOR FragColor
#else
Expand Down
1 change: 0 additions & 1 deletion src/lib/graphics/TwkGLF/glsl/CloneVertex.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// SPDX-License-Identifier: Apache-2.0
//
#if __VERSION__ >= 150
#version 150
#else
#define in attribute
#define out varying
Expand Down
1 change: 0 additions & 1 deletion src/lib/graphics/TwkGLF/glsl/CrosshatchBGFrag.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// SPDX-License-Identifier: Apache-2.0
//
#if __VERSION__ >= 150
#version 150
out vec4 FragColor;
#define FRAGCOLOR FragColor
#else
Expand Down
1 change: 0 additions & 1 deletion src/lib/graphics/TwkGLF/glsl/DefaultFrag.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// SPDX-License-Identifier: Apache-2.0
//
#if __VERSION__ >= 150
#version 150
out vec4 FragColor;
#define FRAGCOLOR FragColor
#else
Expand Down
1 change: 0 additions & 1 deletion src/lib/graphics/TwkGLF/glsl/DefaultVertex.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// SPDX-License-Identifier: Apache-2.0
//
#if __VERSION__ >= 150
#version 150
#else
#define in attribute
#endif
Expand Down
1 change: 0 additions & 1 deletion src/lib/graphics/TwkGLF/glsl/DirectionPaintFrag.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// SPDX-License-Identifier: Apache-2.0
//
#if __VERSION__ >= 150
#version 150
out vec4 FragColor;
#define FRAGCOLOR FragColor
#else
Expand Down
1 change: 0 additions & 1 deletion src/lib/graphics/TwkGLF/glsl/DirectionPaintVertex.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// SPDX-License-Identifier: Apache-2.0
//
#if __VERSION__ >= 150
#version 150
#else
#define in attribute
#define out varying
Expand Down
1 change: 0 additions & 1 deletion src/lib/graphics/TwkGLF/glsl/EraseFrag.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// SPDX-License-Identifier: Apache-2.0
//
#if __VERSION__ >= 150
#version 150
out vec4 FragColor;
#define FRAGCOLOR FragColor
#else
Expand Down
1 change: 0 additions & 1 deletion src/lib/graphics/TwkGLF/glsl/EraseVertex.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// SPDX-License-Identifier: Apache-2.0
//
#if __VERSION__ >= 150
#version 150
#else
#define in attribute
#define out varying
Expand Down
1 change: 0 additions & 1 deletion src/lib/graphics/TwkGLF/glsl/OldReplaceFrag.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// SPDX-License-Identifier: Apache-2.0
//
#if __VERSION__ >= 150
#version 150
out vec4 FragColor;
#define FRAGCOLOR FragColor
#else
Expand Down
1 change: 0 additions & 1 deletion src/lib/graphics/TwkGLF/glsl/PaintColoredFrag.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// SPDX-License-Identifier: Apache-2.0
//
#if __VERSION__ >= 150
#version 150
out vec4 FragColor;
#define FRAGCOLOR FragColor
#else
Expand Down
1 change: 0 additions & 1 deletion src/lib/graphics/TwkGLF/glsl/ReplaceColoredVertex.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// SPDX-License-Identifier: Apache-2.0
//
#if __VERSION__ >= 150
#version 150
#else
#define in attribute
#define out varying
Expand Down
1 change: 0 additions & 1 deletion src/lib/graphics/TwkGLF/glsl/ReplaceFrag.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// SPDX-License-Identifier: Apache-2.0
//
#if __VERSION__ >= 150
#version 150
out vec4 FragColor;
#define FRAGCOLOR FragColor
#else
Expand Down
1 change: 0 additions & 1 deletion src/lib/graphics/TwkGLF/glsl/ReplaceVertex.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// SPDX-License-Identifier: Apache-2.0
//
#if __VERSION__ >= 150
#version 150
#else
#define in attribute
#define out varying
Expand Down
1 change: 0 additions & 1 deletion src/lib/graphics/TwkGLF/glsl/ScaleFrag.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// SPDX-License-Identifier: Apache-2.0
//
#if __VERSION__ >= 150
#version 150
out vec4 FragColor;
#define FRAGCOLOR FragColor
#else
Expand Down
1 change: 0 additions & 1 deletion src/lib/graphics/TwkGLF/glsl/ScaleVertex.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// SPDX-License-Identifier: Apache-2.0
//
#if __VERSION__ >= 150
#version 150
#else
#define in attribute
#define out varying
Expand Down
1 change: 0 additions & 1 deletion src/lib/graphics/TwkGLF/glsl/SoftCloneFrag.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// SPDX-License-Identifier: Apache-2.0
//
#if __VERSION__ >= 150
#version 150
out vec4 FragColor;
#define FRAGCOLOR FragColor
#else
Expand Down
1 change: 0 additions & 1 deletion src/lib/graphics/TwkGLF/glsl/SoftDirectionPaintFrag.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// SPDX-License-Identifier: Apache-2.0
//
#if __VERSION__ >= 150
#version 150
out vec4 FragColor;
#define FRAGCOLOR FragColor
#else
Expand Down
1 change: 0 additions & 1 deletion src/lib/graphics/TwkGLF/glsl/SoftEraseFrag.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// SPDX-License-Identifier: Apache-2.0
//
#if __VERSION__ >= 150
#version 150
out vec4 FragColor;
#define FRAGCOLOR FragColor
#else
Expand Down
1 change: 0 additions & 1 deletion src/lib/graphics/TwkGLF/glsl/SoftOldReplaceFrag.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// SPDX-License-Identifier: Apache-2.0
//
#if __VERSION__ >= 150
#version 150
out vec4 FragColor;
#define FRAGCOLOR FragColor
#else
Expand Down
1 change: 0 additions & 1 deletion src/lib/graphics/TwkGLF/glsl/SoftPaintFrag.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// SPDX-License-Identifier: Apache-2.0
//
#if __VERSION__ >= 150
#version 150
out vec4 FragColor;
#define FRAGCOLOR FragColor
#else
Expand Down
1 change: 0 additions & 1 deletion src/lib/graphics/TwkGLF/glsl/SoftReplaceFrag.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// SPDX-License-Identifier: Apache-2.0
//
#if __VERSION__ >= 150
#version 150
out vec4 FragColor;
#define FRAGCOLOR FragColor
#else
Expand Down
1 change: 0 additions & 1 deletion src/lib/graphics/TwkGLF/glsl/SoftScaleFrag.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// SPDX-License-Identifier: Apache-2.0
//
#if __VERSION__ >= 150
#version 150
out vec4 FragColor;
#define FRAGCOLOR FragColor
#else
Expand Down
1 change: 0 additions & 1 deletion src/lib/graphics/TwkGLF/glsl/StereoCheckerFrag.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// SPDX-License-Identifier: Apache-2.0
//
#if __VERSION__ >= 150
#version 150
out vec4 FragColor;
#define FRAGCOLOR FragColor
#else
Expand Down
1 change: 0 additions & 1 deletion src/lib/graphics/TwkGLF/glsl/StereoScanlineFrag.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// SPDX-License-Identifier: Apache-2.0
//
#if __VERSION__ >= 150
#version 150
out vec4 FragColor;
#define FRAGCOLOR FragColor
#else
Expand Down
1 change: 0 additions & 1 deletion src/lib/graphics/TwkGLF/glsl/TexRectFrag.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// SPDX-License-Identifier: Apache-2.0
//
#if __VERSION__ >= 150
#version 150
out vec4 FragColor;
#define FRAGCOLOR FragColor
#else
Expand Down
1 change: 0 additions & 1 deletion src/lib/graphics/TwkGLF/glsl/TextureFrag.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// SPDX-License-Identifier: Apache-2.0
//
#if __VERSION__ >= 150
#version 150
out vec4 FragColor;
#define FRAGCOLOR FragColor
#else
Expand Down
1 change: 0 additions & 1 deletion src/lib/graphics/TwkGLF/glsl/TextureVertex.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// SPDX-License-Identifier: Apache-2.0
//
#if __VERSION__ >= 150
#version 150
#else
#define in attribute
#define out varying
Expand Down
Loading