I'm trying to create a little shader for brightness and contrast of the window (that I've seen here).
I can load the file, and compile the shader successfully. But I fail to link it. My problem is that the log has no output, so I can't see what's wrong with it. How can I check the linking problem? Where can I find informations about linking failing, and check why linking can fail (I'm new to shaders).
I'm using Ubuntu 12.04.
This is the initialization code
if (GLEW_ARB_fragment_shader) {
// I enter here so I suppose that shader is enabled for
// my graphics card
std::cout << "arb shader enabled" << std::endl;
}
// Loading shader
string fragmentShaderSource;
GLint len;
std::ifstream in("/path/to/file.glsl");
fragmentShaderSource = std::string((std::istreambuf_iterator<char>(in)), std::istreambuf_iterator<char>());
len = fragmentShaderSource->size();
// I've checked the string and file seems to be loaded properly.
// Creating shader
GLint flength;
GLuint fragmentShader;
fragmentShader = glCreateShader(GL_FRAGMENT_SHADER);
GLcharARB** text = new (GLcharARB*);
text[0] = (char*)fragmentShaderSource.c_str();
glShaderSourceARB(fragmentShader, 1, (const GLcharARB**) text, &flength);
// Compile shader
glCompileShaderARB(fragmentShader);
GLint compiled;
glGetObjectParameteriv(ShaderObject, GL_COMPILE_STATUS, &compiled);
if (compiled)
{
// I enter here so I suppose that compilation is ok.
std::cout << "shader compiled" << std::endl;
}
// Attaching to program
GLuint program;
program = glCreateProgram();
glAttachShader(program, fragmentShader);
// Linking
glLinkProgram(program);
// Link check
GLint linked;
glGetProgramivARB(program, GL_LINK_STATUS, &linked);
if (linked) {
std::cout << "linked" << std::endl;
} else {
// I enter here so linking is failed
std::cout << "not linked" << std::endl;
GLint blen = 0;
GLsizei slen = 0;
glGetShaderiv(program, GL_INFO_LOG_LENGTH, &blen);
// blen is equal to zero so I cannot print the log message
// because it's absent
if (blen > 1) {
GLchar* linking_log = (GLchar*) malloc(blen);
glGetProgramInfoLog(program, blen, &slen, linking_log);
glGetInfoLogARB(program, blen, &slen, linking_log);
std::cout << "compiler_log:\n" << linking_log << std::endl;
free(linking_log);
}
}
And this is the glsl code that I load
uniform float Brightness : register(C0);
uniform float Contrast : register(C1);
sampler2D Texture1Sampler : register(S0);
float4 main(float2 uv : TEXCOORD) : COLOR
{
float4 pixelColor = tex2D(Texture1Sampler, uv);
pixelColor.rgb /= pixelColor.a;
// Apply contrast.
pixelColor.rgb = ((pixelColor.rgb - 0.5f) * max(Contrast, 0)) + 0.5f;
// Apply brightness.
pixelColor.rgb += Brightness;
// Return final pixel color.
pixelColor.rgb *= pixelColor.a;
return pixelColor;
}
EDIT:
I fixed log, when linking fails, I obtain following output:
Fragment info
-------------
0(1) : warning C7557: OpenGL does not allow Cg-style semantics
0(2) : warning C7557: OpenGL does not allow Cg-style semantics
0(4) : warning C7557: OpenGL does not allow Cg-style semantics
0(4) : warning C7554: OpenGL requires sampler variables to be explicitly declared as uniform
0(6) : warning C7506: OpenGL does not define the global type float4
0(6) : warning C7506: OpenGL does not define the global type float2
0(6) : warning C7557: OpenGL does not allow Cg-style semantics
0(6) : warning C7557: OpenGL does not allow Cg-style semantics
0(6) : warning C7527: OpenGL requires main to take no parameters
0(6) : warning C7530: OpenGL requires main to return void
0(9) : warning C7506: OpenGL does not define the global function tex2D
0(13) : warning C7502: OpenGL does not allow type suffix 'f' on constant literals in versions below 120
0(13) : warning C7011: implicit cast from "int" to "float"
0(13) : warning C7502: OpenGL does not allow type suffix 'f' on constant literals in versions below 120
EDIT2:
I've fixed fragment shader
uniform float Brightness;
uniform float Contrast;
uniform vec2 vTextureCoord;
uniform sampler2D Texture1Sampler;
void main() {
vec4 textureColor = texture2D(Texture1Sampler, vTextureCoord);
vec3 fragRGB = textureColor.rgb / textureColor.a;
fragRGB.rgb = ((fragRGB.rgb - 0.5) * max(Contrast, 0.0)) + 0.5;
fragRGB.rgb += Brightness;
fragRGB.rgb *= textureColor.a;
gl_FragColor = vec4(fragRGB, textureColor.a);
}
And I've added a basic vertex shader
attribute vec4 gl_Vertex;
void main(){
gl_Position = gl_Vertex;
}
I've added them to program. Now all compilation warning disappeared, but linking fails again.
program = glCreateProgram();
glAttachShader(program, fragmentShader); // fragment shader compiled. No warnings
glAttachShader(program, vertexShader); // vertex shader compiled. No warnings
glLinkProgram(program);
GLint linked;
glGetProgramivARB(program, GL_LINK_STATUS, &linked); // linked != GL_TRUE. Linking failed.
What I'm yet doing wrong?
You are only attaching a fragment shader and not a vertex shader. In fully programmable openGL both are required. Your code should be:
glAttachShader(program, fragmentShader);
glAttachShader(program, vertexShader);
Linking happens after shaders are attached to a program, and since both vertex and fragment shaders are required linking failed.
Moreover you are basically writing Cg in GLSL.
float4 main(float2 uv : TEXCOORD) : COLOR // These Cg semantics are not accepted in GLSL
The point is that GLSL doen't use Cg like semantics and you need to use GLSL special out variables. Check the following psudo-GLSL code.
in vec3 vertex;
//vertex shader.
void main() // write a main and output should be done using special variables
{
// output using special variables.
gl_Position = vertex;
}
//fragment shader.
uniform vec4 color;
void main() // write a main and output should be done using special variables
{
// output using special variables.
gl_FragColor = color;
}
I actually recommend that you pick a GLSL language tutorial like this one.
Related
I've a weird problem with GLSL shaders. My program seems to not launch or launch successfully depending on the size of my shader files. If I only write a few lines of code in shader files, the program works fine. For example, the program launches successfully with this much code:
vertex.vs:
#version 460 core
layout (location = 0) in vec2 coords;
uniform float u_time;
out vec3 result_color;
void main()
{
vec3 colorA = vec3(0.514f, 0.179f, 0.900f);
vec3 colorB = vec3(0.895f, 0.359f, 0.488f);
gl_Position = vec4(coords, 0.0f, 1.0f);
result_color = colorA;
}
fragment.fs:
#version 460 core
in vec3 result_color;
out vec4 color;
void main()
{
color = vec4(result_color, 1.0f);
}
If I add more code to any of my shader files it only launches about 50% of the time:
vertex.vs:
#version 460 core
layout (location = 0) in vec2 coords;
uniform float u_time;
out vec3 result_color;
// float wave(float x)
// {
// return min(2.0f - 2.0f * fract(x / 2.0f),
// 2.0f * fract(x / 2.0f));
// }
void main()
{
vec3 colorA = vec3(0.514f, 0.179f, 0.900f);
vec3 colorB = vec3(0.895f, 0.359f, 0.488f);
// float frequency = 15.0f;
// float y = wave(coords.x * frequency + cos(u_time) * 5.0f);
// float fr_y = fract(coords.y * frequency + u_time);
gl_Position = vec4(coords, 0.0f, 1.0f);
result_color = colorA;
}
Note that the code I added is commented out but still the error occurs. And the more code I add the less is the chance it works.
Here's the class I use to read shaders from files and create a shader program:
#include <iostream>
#include <fstream>
#include <sstream>
#include <glad/glad.h>
#include "shader_program.h"
ShaderProgram::ShaderProgram(std::string vertexShaderPath, std::string fragmentShaderPath)
{
std::ifstream vShaderFile;
std::ifstream fShaderFile;
std::stringstream vShaderStream;
std::stringstream fShaderStream;
vShaderFile.exceptions(std::ifstream::failbit | std::ifstream::badbit);
fShaderFile.exceptions(std::ifstream::failbit | std::ifstream::badbit);
try
{
vShaderFile.open(vertexShaderPath);
vShaderStream << vShaderFile.rdbuf();
}
catch(std::ifstream::failure e)
{
std::cout << "ERROR: FAILED TO READ SHADER FILE: VERTEX SHADER" << std::endl;
}
try
{
fShaderFile.open(fragmentShaderPath);
fShaderStream << fShaderFile.rdbuf();
}
catch(std::ifstream::failure e)
{
std::cout << "ERROR: FAILED TO READ SHADER FILE: FRAGMENT SHADER" << std::endl;
}
const char* vertexShaderSource = vShaderStream.str().c_str();
const char* fragmentShaderSource = fShaderStream.str().c_str();
CreateShaderProgram(vertexShaderSource, fragmentShaderSource);
}
unsigned int ShaderProgram::GetProgram()
{
return program;
}
void ShaderProgram::CreateShaderProgram(const char* vertexShaderSource, const char* fragmentShaderSource)
{
program = glCreateProgram();
unsigned int vertexShader = CompileShader(GL_VERTEX_SHADER, vertexShaderSource);
unsigned int fragmentShader = CompileShader(GL_FRAGMENT_SHADER, fragmentShaderSource);
glAttachShader(program, vertexShader);
glAttachShader(program, fragmentShader);
glLinkProgram(program);
int linkingResult;
glGetProgramiv(program, GL_LINK_STATUS, &linkingResult);
if (linkingResult == GL_FALSE)
{
char infoLog[512];
glGetProgramInfoLog(program, 512, NULL, infoLog);
std::cout << "ERROR: FAILED TO LINK PROGRAM\n" << infoLog << std::endl;
}
}
unsigned int ShaderProgram::CompileShader(GLuint type, const char* source)
{
unsigned int shader = glCreateShader(type);
glShaderSource(shader, 1, &source, NULL);
glCompileShader(shader);
int compilationResult;
glGetShaderiv(shader, GL_COMPILE_STATUS, &compilationResult);
if (compilationResult == GL_FALSE)
{
char infoLog[512];
glGetShaderInfoLog(shader, 512, NULL, infoLog);
std::cout << "ERROR: FAILED TO COMPILE SHADER: "
<< (type == GL_VERTEX_SHADER ? "VERTEX" : "FRAGMENT")
<< " SHADER\n" << infoLog << std::endl;
}
return shader;
}
The error message I get sometimes seems random. Most of the time it's this:
ERROR: FAILED TO LINK PROGRAM
Vertex shader(s) failed to link, fragment shader(s) failed to link.
Vertex link error: INVALID_OPERATION.
ERROR: error(#97) No program main found
fragment link error: INVALID_OPERATION.
ERROR: error(#97) No program main found
But sometimes it's about a syntax error which is nowhere to be found really:
ERROR: FAILED TO COMPILE SHADER: VERTEX SHADER
Vertex shader failed to compile with the following errors:
ERROR: 0:1: error(#132) Syntax error: "0" parse error
ERROR: error(#273) 1 compilation errors. No code generated
ERROR: FAILED TO LINK PROGRAM
Vertex shader(s) were not successfully compiled before glLinkProgram() was called. Link failed.
I use GLFW 3.3.8 and Glad. I started with OpenGL version 3.3 and tried switching to 4.6 which had no effect. Also tried to update my GPU drivers to no success either. I really have no idea where this behaviour may be coming from.
You have undefined behaviour.
vShaderStream.str().c_str();
str() returns string by value. So this temporary string object is destroyed at the end of full expression, and the pointer obtained by c_str() is dangling. As a solution you could do:
CreateShaderProgram(vShaderStream.str().c_str(), fShaderStream.str().c_str());
in case above, string temporaries are still alive when CreateShaderProgram is called.
I'm trying to learn how to use tesselation to render simple polygons, and for a starter I'm trying to write a simple program that essentially would just draw whatever vertices it's given, without any extra logic. My three shaders compile without error, but when I try to apply the program OpenGL returns error 1282. Based on the documentation for glUseProgram my best guess is that OpenGL is in a state where the program cannot be used, but I'm not able to tell why. If I don't include the TES in the program my code runs just fine, so I'm sure I'm not trying to apply the wrong program ID.
Since I know with fairly good confidence that my vertex and fragment shader are working correctly, the issue must be with the TES, which in my eyes will only put out the control points as vertices.
Is it not possible to simply pass control points through the shader as vertices?
My Tesselation Evaluation Shader:
#version 440 core
layout(triangles, equal_spacing, ccw) in;
in vec4 positionIn[];
void main()
{
gl_Position = positionIn[0];
}
Vertex Shader:
#version 440 core
layout(location = 0) in vec4 position;
uniform mat4 u_MVP;
void main()
{
gl_Position = u_MVP * position;
}
Fragment Shader:
#version 440 core
layout(location = 0) out vec4 colour;
uniform vec4 u_Colour;
void main()
{
colour = u_Colour;
}
Rest of the code that handles the compilation and setup:
int compileShader(unsigned int type, const std::string& source)
{
unsigned int id = glCreateShader(type);
const char* src = source.c_str();
glShaderSource(id, 1, &src, nullptr);
glCompileShader(id);
int result;
glGetShaderiv(id, GL_COMPILE_STATUS, &result);
if (result == GL_FALSE)
{
int length;
glGetShaderiv(id, GL_INFO_LOG_LENGTH, &length);
char* message = (char*)alloca(length * sizeof(char));
glGetShaderInfoLog(id, length, &length, message);
std::cout << message << std::endl;
glDeleteShader(id);
return 0;
}
return id;
}
void setUpProgram()
{
unsigned int program = glCreateProgram();
unsigned int vs = compileShader(GL_VERTEX_SHADER, vertexShader);
unsigned int fs = compileShader(GL_FRAGMENT_SHADER, fragmentShader);
unsigned int es = compileShader(GL_TESS_EVALUATION_SHADER, tesselationEvaluationShader);
glAttachShader(program, vs);
glAttachShader(program, fs);
glAttachShader(program, es);
glLinkProgram(program);
glValidateProgram(program);
GLenum error = glGetError();
while (error != GL_NO_ERROR)
{
std::cout << "Error: " << error << std::endl;
GLenum error = glGetError();
}
glUseProgram(program);
error = glGetError();
std::cout << "Error: " << error << std::endl;
}
There are two problems.
The first is that the vertex shader output is not being consumed by the tessellation evaluation shader. The VS outputs gl_Position, but the TES doesn't read gl_Position. It instead reads a user-defined input positionIn, which has no linkage to the value of gl_Position. Indeed, it has no value at all, and your shader linking process would have told you that if you checked whether your program successfully linked.
The corresponding TES input for the gl_Position output is, cleverly named, gl_Position. However, since this is the same name as the output you intend to write to, it is defined within an input interface block gl_PerVertex. So if you want to access it, you need to declare this interface block appropriately:
in gl_PerVertex
{
vec4 gl_Position;
} gl_in[gl_MaxPatchVertices];
You can then use gl_in[ix].gl_Position to access the position for that vertex. Speaking of array indexing...
The second problem is that [0] is the wrong index. The job of the TES is to compute the attributes for a vertex within the tessellated abstract patch. To do that job, the TES is given all of the vertices for the patch. So each TES invocation for a patch gets the same set of inputs, in the same order.
So doing gl_in[0].gl_Position would yield the same value for each vertex in the patch. That's a triangle with zero area, and thus isn't helpful in displaying anything.
The only thing the TES invocations get which are different is the input value vertexTexCoord, which is the coordinate of this TES invocation within the abstract patch. This is a vec3, and for triangle tessellation, represents the barycentric coordinate of the vertex within the abstract patch.
So you need to convert this vec3 into an index. If you aren't doing any tessellation at all, then the barycentric coordinate will have one of the values at 1.0, with the other values being zero. So you can use that to tell you which index you should use.
I'm building a game using OpenGL and C++. I'm using GLFW and GLAD. I'm currently in the process of setting up simple shaders, but I'm completely roadblocked by a compilation problem. In a nutshell, shader compilation fails with no error message.
Here's my vertex shader (it's meant to draw 2D images and text):
#version 330 core
layout (location = 0) in vec2 vPosition;
layout (location = 1) in vec2 vTexCoords;
layout (location = 2) in vec4 vColor;
out vec4 fColor;
out vec2 fTexCoords;
uniform mat4 mvp;
void main()
{
vec4 position = mvp * vec4(vPosition, 0, 1);
position.y *= -1;
gl_Position = position;
fColor = vColor;
fTexCoords = vTexCoords;
}
And here's the relevant code to create the shader, load the shader source, compile the shader, and check for errors.
GLuint shaderId = glCreateShader(GL_VERTEX_SHADER);
std::string source = FileUtilities::ReadAllText(Paths::Shaders + filename);
GLchar const* file = source.c_str();
GLint length = static_cast<GLint>(source.size());
glShaderSource(shaderId, 0, &file, &length);
glCompileShader(shaderId);
GLint status;
glGetShaderiv(shaderId, GL_COMPILE_STATUS, &status);
if (status == GL_FALSE)
{
GLint logSize = 0;
glGetShaderiv(shaderId, GL_INFO_LOG_LENGTH, &logSize);
std::vector<GLchar> message = std::vector<GLchar>(logSize);
glGetShaderInfoLog(shaderId, logSize, nullptr, &message[0]);
glDeleteShader(shaderId);
std::cout << std::string(message.begin(), message.end());
}
Using that code, logSize is returned as 1, meaning that I'm unable to access the error message provided by GL. From what I can tell, the message doesn't exist at all. I've already seen the question posted here, in which the issue was a missing call to glCompileShader. As you can see, my code does call that function.
In attempting to solve this problem, I've already confirmed a few things.
My shader source (a string) is being read correctly. The source is a single string that, as far as I can tell, exactly matches the actual shader file.
There are no casting issues from the string source to GLchar const* or GLint (the variables file and length). Both look correct.
If I artificially inflate the value of logSize (to, say, 1000), the resulting message is nothing but zeroes. No error message exists.
I am calling glfwInit() and related functions before reaching this point in the code. Querying glGetString(GL_VERSION) does correctly return the target version (3.3.0).
Does anyone know how to fix this? As I said, my progress is completely blocked since I can't render anything (2D or 3D) without working shaders.
Thank you!
The problem is that you never upload any shader source to the shader.
The second parameter in this line:
glShaderSource(shaderId, 0, &file, &length);
tells OpenGL to load 0 code strings to the shader (nothing). Change this to 1, and it should work.
I'm using xcode to make a game with OpenGL. I have used GLUT to initialise a window. I have shaders that I wish to implement but when I try to compile them, I get two compile errors in the info log. My shaders look like this:
//FirstShader.vsh
#version 150 core
in vec3 position;
void main()
{
gl_Position = vec4(position, 1.0);
}
//FirstShader.fsh
#version 150 core
out vec4 fragData;
void main()
{
fragData = vec4(0.0, 0.0, 1.0, 1.0);
}
I'm reading the file and compiling it with this code:
GLuint createShaderFromFile(const GLchar *path, GLenum shaderType){
GLuint shaderID = glCreateShader(shaderType);
std::ifstream fin;
fin.open(path);
if(!fin.is_open()){
fin.close();
std::cout << "Shader Not Found" << std:: endl;
return 0;
}
std::string source((std::istreambuf_iterator<GLchar>(fin)),std::istreambuf_iterator<GLchar> ());
fin.close();
const GLchar* shaderSource = source.c_str();
glShaderSource(shaderID, 1, &shaderSource, NULL);
glCompileShader(shaderID);
GLint compileStatus;
glGetShaderiv(shaderID, GL_COMPILE_STATUS, &compileStatus);
if (compileStatus != GL_TRUE) {
std::cout << "Shader failed to compile" << std::endl;
GLint infoLoglength;
glGetShaderiv(shaderID, GL_INFO_LOG_LENGTH, &infoLoglength);
GLchar* infoLog = new GLchar[infoLoglength + 1];
glGetShaderInfoLog(shaderID, infoLoglength, NULL, infoLog);
std::cout << infoLog << std::endl;
delete infoLog;
return 0;
}
return shaderID;
}
Im getting these errors:
ERROR: 0:1: '' : version '150' is not supported
ERROR: 0:1: '' : syntax error #version
My OpenGL version is 2.1 and my glsl version is 1.20. Does anybody know how I can fix this?
You can tell OSX to use a newer version of OpenGL by setting it in your pixel format when you create the context. Here is an example of how to set it up.
Or if you're using glut, I think you want glutInitContextVersion(x, y); where x and y are the major and minor version numbers. GLSL 1.5 is supported in OpenGL 3.2, I think. (And you might also want glutInitContextProfile(GLUT_CORE_PROFILE);, I think.)
I re-wrote your shaders in a way that they will actually work in GLSL 1.20.
in must be replaced with attribute in a GLSL 1.20 vertex shader
out for fragment shader output is invalid, use gl_FragColor or gl_FragData [n] instead
Declaring a vertex attribute as vec3 and then doing something like vec4 (vtx, 1.0) is completely redundant
If you declare the attribute as vec4 and give it data using fewer than 4 components GLSL will automatically fill-in the attribute's missing components this way: vec4 (0.0, 0.0, 0.0, 1.0).
Fragment Shader:
#version 120
attribute vec4 position;
void main()
{
gl_Position = position;
}
Vertex Shader:
#version 120
void main()
{
gl_FragColor = vec4(0.0, 0.0, 1.0, 1.0);
}
Of course this does not really solve your problem, because if you have a version of OS X 10.7 or newer, it supports OpenGL 3.2 and therefore GLSL 1.50 core. You need to request a core profile context for this to work, however - otherwise you will get OpenGL 2.1 and GLSL 1.20.
I'm making a crossplatform OpenGL program. However, I've encountered a problem, where glGetUniformLocation, which should return the location of a uniform variable in my shader program, returns -1, and it only occurs on Linux (Raspbian distro, ran on Raspberry PI), and on Windows the same code works perfectly! Here's my code:
Load Shader program function:
int shader, status;
programID = glCreateProgram();
// Load vertex shader
shader = LoadShaderFromString(GL_VERTEX_SHADER, Tools::GetFileAsString("VertexShader.glsl"), "Unable to compile vertex shader.\n");
glAttachShader(programID, shader);
// Load pixel shader
shader = LoadShaderFromString(GL_FRAGMENT_SHADER, Tools::GetFileAsString("FilterPixelShader.glsl"), "Unable to compile pixel shader.\n");
glAttachShader(programID, shader);
// Link the program
glLinkProgram(programID);
glGetProgramiv(programID, GL_LINK_STATUS, &status);
if (status == 0)
{
Log("Unable to link filter shader program.\n");
PrintProgramLog(programID);
Fail(); // Quits program
}
// returns -1 here!
frameTextureLocation = glGetUniformLocation(programID, "FrameTextureUnit");
if (frameTextureLocation == -1)
{
int errorCode = glGetError();
Log(string("Error retrieving variable frameTextureLocation from shader program: "));
Log((const char*)glewGetErrorString(errorCode))
Log("!\n");
Fail();
}
LoadShaderFromString:
int Shader::LoadShaderFromString(int type, const string& shaderSource, const string& errorMessage)
{
int shader, status;
const char* programSource;
shader = glCreateShader(type);
programSource = shaderSource.c_str();
glShaderSource(shader, 1, &programSource, nullptr);
glCompileShader(shader);
glGetShaderiv(shader, GL_COMPILE_STATUS, &status);
if (status == 0)
{
Log(errorMessage);
PrintShaderLog(shader);
Fail();
}
return shader;
}
Lastly, the shader itself:
uniform sampler2D FrameTextureUnit;
uniform sampler2D BackgroundTextureUnit;
#if __VERSION__ >= 130
// Texture coordinate
in vec2 texCoord;
// Final color
out vec4 gl_FragColor;
#else
// Texture coordinate
varying vec2 texCoord;
#endif
uniform float Tolerance; // Tolerance for color difference
uniform vec4 FilterColor; // Color of the filter
void main()
{
vec4 pixel = texture2D(FrameTextureUnit, texCoord);
vec4 background = texture2D(BackgroundTextureUnit, texCoord);
float difference = abs(background.x - pixel.x)
+ abs(background.y - pixel.y)
+ abs(background.z - pixel.z);
if (difference > Tolerance)
{
gl_FragColor = FilterColor;
}
else
{
// Y = 0.2126 R + 0.7152 G + 0.0722 B
float gray = pixel.x * 0.2126 + pixel.y * 0.7152 + pixel.z * 0.0722;
gl_FragColor = vec4(gray, gray, gray, 1);
}
}
Does anyone know why this might be happening? :( It's worth adding that the error handling code:
int errorCode = glGetError();
Log(string("Error retrieving variable frameTextureLocation from shader program: "));
Log((const char*)glewGetErrorString(errorCode));
Prints "Error retrieving variable frameTextureLocation from shader program: No error".
Always specify GLSL version at the top of your shaders, otherwise it defaults to a very old version. It must be the first line. It will also eliminate the need for version checking inline.
#version 150
// rest of shader here