I was working on a text rendering program in C when suddenly one of my shaders started failing when one of my shaders started failing at the glLinkProgram step. This was strange to me as I had not touched that part of the code in a while and the code ran with no problems on another machine. I messed around with my shaders and it seemed to fail when one of my uniform floats like “total_time” was called used in a sin() or abs() call. This shader was a quick one I wrote to make the glyphs wiggle and change color so it is a little weird, but I don’t see any problems with it. Could this be a driver error or am I missing something more obvious? It mentions stack overflow in the error message, but I don’t understand what would cause this. I have an Intel graphics card.
Error message:
Unhandled exception at 0x00007FF8EB655ED7 (ig7icd64.dll) in win32_main.exe: 0xC00000FD: Stack overflow (parameters: 0x0000000000000001, 0x000000DA846C3000).
Shader code:
const char* vs_selected =
"#version 330 core\n"
"layout (location = 0) in vec3 vec_pos;"
"layout (location = 1) in vec3 aColor;"
"layout (location = 2) in vec2 tex_coord;"
"uniform mat4 view_mat;"
"uniform mat4 proj_mat;"
"uniform vec2 image_offset;"
"uniform vec2 image_scale;"
"uniform float total_time;"
"uniform float char_num;"
"out vec2 pass_tex_coord;"
"void main()"
"{"
"pass_tex_coord = vec2(tex_coord.s * image_scale.s , tex_coord.t * image_scale.t) + image_offset;"
"gl_Position = vec4(vec_pos , 1.0f);"
"gl_Position.x += abs(sin(3*total_time)) / 50.0;"
"gl_Position.y += abs(sin(char_num + 10*total_time))/40.0;"
"}";
const char* fs_selected =
"#version 330 core\n"
"out vec4 frag_color;"
"in vec2 pass_tex_coord;"
"uniform sampler2D our_texture;"
"uniform float total_time;"
"void main()"
"{"
" vec4 color = texture(our_texture, pass_tex_coord) * vec4(abs(sin(2*total_time)), 0, 1, 1.0);"
" if(color.a == 0.0) discard;"
" frag_color = color;"
"}";
Create shader code:
GLuint create_shader_gl(const char* vertex_shader, const char* fragment_shader)
{
GLenum err = GL_NO_ERROR;
err = glGetError();
GLuint vert_shader, frag_shader, shader_id;
vert_shader = glCreateShader(GL_VERTEX_SHADER);
glShaderSource( vert_shader, 1, &vertex_shader, NULL);
glCompileShader(vert_shader);
GLint success = 0;
glGetShaderiv(vert_shader, GL_COMPILE_STATUS, &success);
Assert(success != GL_FALSE);
frag_shader = glCreateShader(GL_FRAGMENT_SHADER);
glShaderSource( frag_shader, 1, &fragment_shader, NULL);
glCompileShader(frag_shader);
glGetShaderiv(frag_shader, GL_COMPILE_STATUS, &success);
Assert(success != GL_FALSE);
shader_id = glCreateProgram();
glAttachShader(shader_id, vert_shader);
glAttachShader(shader_id, frag_shader);
glLinkProgram(shader_id);
glGetProgramiv(shader_id, GL_LINK_STATUS, &success);
Assert(success != GL_FALSE);
return shader_id;
}