I fixed the issue. it was a line that was cousing me to loose the reference to the shader.
I have a simple shaer that i am just trying to render and see if my mesh is loaded correctly. The problem is when i want to use the shader the program just exits without any warning or error code (the opengl context is closed). I have no idea how to firuge this out and i dont know what is causing it. I am sorry if i didnt provide enough information but i jsut dont understand what is happening.
I am having a hard time debugging because as far as i can see, i can not debug using bumblebee and qt creator. If anyone knows how to debug using bumblebee i might be able to find the error if there is something wrong when creating shaders and referencing them.
Also i do not have any error codes from opengl except for OSD. I disabled that and commented all OSD code but still the same.
Vertex shader
#version 400
#extension GL_ARB_separate_shader_objects : enable
uniform mat4 VP;
uniform mat4 P;
struct Texture {
sampler2D diffuse;
sampler2D specular;
sampler2D normal;
sampler2D ambient;
sampler2D height;
//vec2 texCoord;
};
struct Material {
vec3 ambient; // Ka
vec3 diffuse; // Kd
vec3 specular; // Ks
vec3 transmittance; // Tr
vec3 emission; // Ke
float shininess; // Ns
float ior; // Ni
float dissolve; // Dissolve
int illum; // Illum
Texture texture;
};
uniform Material material;
layout (location = 0) in vec3 position;
layout (location = 1) in vec2 texCoord;
layout (location = 2) in vec3 normal;
out vec3 Position;
out vec3 Normal;
out vec2 TexCoord;
void main(){
Position = position;
Normal = normal;
TexCoord = texCoord;
gl_Position = VP * vec4(position, 1.0);
}
Fragment shader
and
#version 400
#extension GL_ARB_separate_shader_objects : enable
uniform mat4 VP;
uniform mat4 P;
struct Texture {
sampler2D diffuse;
sampler2D specular;
sampler2D normal;
sampler2D ambient;
sampler2D height;
//vec2 texCoord;
};
struct Material {
vec3 ambient; // Ka
vec3 diffuse; // Kd
vec3 specular; // Ks
vec3 transmittance; // Tr
vec3 emission; // Ke
float shininess; // Ns
float ior; // Ni
float dissolve; // Dissolve
int illum; // Illum
Texture texture;
};
uniform Material material;
layout (location = 0) in vec3 position;
layout (location = 1) in vec2 texCoord;
layout (location = 2) in vec3 normal;
in vec3 Position;
in vec3 Normal;
in vec2 TexCoord;
out vec4 gl_FragColor;
void main(){
gl_FragColor = texture(material.texture.diffuse, TexCoord) * vec4(material.diffuse, 1.0f);
//gl_FragColor = vec4(1.0f);
}