View Full Version : Program crashing on draw call with very basic shaders

06-21-2014, 03:07 AM
I'm trying to implement shadow maps in my system. When I try to render them with the following:

for(unsigned int i=0; i<NUMBER_OF_SHADOW_MAP_TO_RENDER; i++){
glBindFramebuffer(GL_FRAMEBUFFER, Shadow_i_FBO);
for each Mesh to draw
const glm::mat4 MVP = currMesh.getModelMatrix() *
LIGHT_i_VIEW_PERSPECTIVE_MATRIX; // this is fine, could be identity and still don't work.
shadowprogram.setUniformMatrix4fv(MVP_MATRIX_UNIFO RM,1,&(MVP[0][0]));
glBindBuffer(GL_ARRAY_BUFFER, currMesh.positionBuffer);
shadowprogram.vertexAttribPointer(POSITION_ATTRIBU TE,3,GL_FLOAT,GL_FALSE,0,(void*)0);
glDrawArrays(GL_TRIANGLES,0,currMesh.positions.siz e());

Everything that here is abstracted is working singularly (works in other cases).

The shader program shadowprogram is EXTREMELY basic and is:

Vertex Shader

#version 330
layout(location=0) in vec3 aVertexPosition;
uniform mat4 mvpMatrix;
void main(void){
gl_Position = mvpMatrix*vec4(aVertexPosition,1.0);
Fragment Shader

#version 330
void main(void){

There is NO error if I call glGetError() in any part above, but when it reach the draw call (it print before, but not after), the program crashes (violation of access). Also the program links perfectly.
The thread where it "stops" indicates nvoglv32. To be precise the exception risen says "access violation while reading address 0x00000000." which seemed rather strange to me.
The same data if called in another way work perfectly.
On the VS stack call I just have an hexadecimal and nothing else (it says, roughly translated from my french vs, "other frames are missing or wrong").

It is literally driving me mad, what can be the problem?
Any help will be GREATLY appreciated

EDIT: Here the call stack from gDebugger, but still can't understand:


Keep working with gDebugger I also verified that the correct data are in the VBO that is bind (currMesh.positionBuffer) and has the form that is indicated in the vertexAttribPointer call. But still, the crash occurs anyway. Any indication of what to look for?

Evidently one vertex attribute was enabled and shouldn't be, so now is fixed.

06-22-2014, 10:15 AM
Does ur program work without using a shader? opengl should draw with a default color , for example if i draw without shader it draws white.
If without shader works well then you are 100% sure the problem is in the shader.
Also what if you try in the framgent shader to pass over the color?
#version 330
out vec4 colorOut;

void main()
colorOut = vec4(1.0, 0.0, 0.0, 1.0);