thanks for the help allready
if used the coded exunit and their are no active uniforms.
I am using opengl version 3.00 can this be a problem to?
I have added my shader files.
i have changed something in my shader loading function can this be the problem ?
the change is this:
//added by me because i got a error he coulden't parse it to const glchar *
glsl_source_gl=glsl_source;
this is my leader function
GLuint LoadShader(const char* filename, GLenum shader_type)
{
GLuint shader_id = 0;
FILE* file;
long file_size = -1;
GLchar* glsl_source;
//added by me
const GLchar* glsl_source_gl;
if (NULL != (file = fopen(filename, "rb")) &&
0 == fseek(file, 0, SEEK_END) &&
-1 != (file_size = ftell(file)))
{
rewind(file);
if (NULL != (glsl_source = (char*)malloc(file_size + 1)))
{
if (file_size == (long)fread(glsl_source, sizeof(char), file_size, file))
{
//added by me because i got a error he coulden't parse it to const glchar *
glsl_source_gl=glsl_source;
glsl_source[file_size] = '\0';
if (0 != (shader_id = glCreateShader(shader_type)))
{
glShaderSource(shader_id, 1, (&glsl_source_gl), NULL);
glCompileShader(shader_id);
ExitOnGLError("Could not compile a shader");
}
else
fprintf(stderr, "ERROR: Could not create a shader.\n");
}
else
fprintf(stderr, "ERROR: Could not read file %s\n", filename);
free(glsl_source);
}
else
fprintf(stderr, "ERROR: Could not allocate %i bytes.\n", file_size);
fclose(file);
}
else
fprintf(stderr, "ERROR: Could not open file %s\n", filename);
return shader_id;
}
And this is my drawcube method:
void CreateCube(void)
{
const Vertex VERTICES[8] =
{
{ { -.5f, -.5f, .5f, 1 }, { 0, 0, 1, 1 } },
{ { -.5f, .5f, .5f, 1 }, { 1, 0, 0, 1 } },
{ { .5f, .5f, .5f, 1 }, { 0, 1, 0, 1 } },
{ { .5f, -.5f, .5f, 1 }, { 1, 1, 0, 1 } },
{ { -.5f, -.5f, -.5f, 1 }, { 1, 1, 1, 1 } },
{ { -.5f, .5f, -.5f, 1 }, { 1, 0, 0, 1 } },
{ { .5f, .5f, -.5f, 1 }, { 1, 0, 1, 1 } },
{ { .5f, -.5f, -.5f, 1 }, { 0, 0, 1, 1 } }
};
const GLuint INDICES[36] =
{
0,2,1, 0,3,2,
4,3,0, 4,7,3,
4,1,5, 4,0,1,
3,6,2, 3,7,6,
1,6,5, 1,2,6,
7,5,6, 7,4,5
};
ShaderIds[0] = glCreateProgram();
ExitOnGLError("ERROR: Could not create the shader program");
ShaderIds[1] = LoadShader("c:\\SimpleShader.fragment.glsl", GL_FRAGMENT_SHADER);
ShaderIds[2] = LoadShader("c:\\SimpleShader.vertex.glsl", GL_VERTEX_SHADER);
glAttachShader(ShaderIds[0], ShaderIds[1]);
glAttachShader(ShaderIds[0], ShaderIds[2]);
glLinkProgram(ShaderIds[0]);
ExitOnGLError("ERROR: Could not link the shader program");
ModelMatrixUniformLocation = glGetUniformLocation(ShaderIds[0], "ModelMatrix");
ExitOnGLError("ERROR: Could not get the shader uniform locations for modelmatrix");
ViewMatrixUniformLocation = glGetUniformLocation(ShaderIds[0], "ViewMatrix");
ExitOnGLError("ERROR: Could not get the shader uniform locations for viewmatrix");
ProjectionMatrixUniformLocation = glGetUniformLocation(ShaderIds[0], "ProjectionMatrix");
ExitOnGLError("ERROR: Could not get the shader uniform locations for projectionMatrix");
glGenVertexArrays(1, &BufferIds[0]);
ExitOnGLError("ERROR: Could not generate the VAO");
glBindVertexArray(BufferIds[0]);
ExitOnGLError("ERROR: Could not bind the VAO");
glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1);
ExitOnGLError("ERROR: Could not enable vertex attributes");
glBindBuffer(GL_ARRAY_BUFFER, BufferIds[1]);
glBufferData(GL_ARRAY_BUFFER, sizeof(VERTICES), VERTICES, GL_STATIC_DRAW);
ExitOnGLError("ERROR: Could not bind the VBO to the VAO");
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(VERTICES[0]), (GLvoid*)0);
glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, sizeof(VERTICES[0]), (GLvoid*)sizeof(VERTICES[0].Position));
ExitOnGLError("ERROR: Could not set VAO attributes");
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, BufferIds[2]);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(INDICES), INDICES, GL_STATIC_DRAW);
ExitOnGLError("ERROR: Could not bind the IBO to the VAO");
glBindVertexArray(0);
}