How to debug

Hi all

I’ve got an application in opengl 2.x that used to work. But now i don’t see nothing.

In this application I update a VBO via a fragment shader via


gl_FragData[0] = vec4(x_i,1.0);

In the c++ code I draw a quad in which I make some calculation via the fragment shader
then I read back the buffer
and finally update my VBO and draw elements

the code is as follow:

	SetOrthographicProjection();
	glViewport(0,0,texture_size_x, texture_size_y); //64x64

		glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fboID[writeID]);	
		glDrawBuffers(3, mrt);	

		glActiveTexture(GL_TEXTURE0);
		glBindTexture(GL_TEXTURE_2D, attachID[2*readID]);

		glClear(GL_COLOR_BUFFER_BIT);
		glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
		verletShader.begin();	
			DrawFullScreenQuad();
		verletShader.end();
		//swap read/write pathways
		int tmp = readID;
		readID  = writeID;
		writeID = tmp;
	glFlush();


	ResetPerspectiveProjection();

	///////////read back the results into the VBO
	glBindFramebuffer(GL_READ_FRAMEBUFFER, fboID[readID]);


	glReadBuffer(GL_COLOR_ATTACHMENT0); 			
	glBindBuffer(GL_PIXEL_PACK_BUFFER, vboID); 			
	glReadPixels(0, 0, texture_size_x, texture_size_y, GL_RGBA, GL_FLOAT, 0); 

	glReadBuffer(GL_NONE); 
	glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);

	//reset default framebuffer
	glBindFramebuffer( GL_FRAMEBUFFER, 0 );
    glReadBuffer(GL_BACK);
    glDrawBuffer(GL_BACK); 
	
	//restore the rendering modes and viewport
	glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
	glViewport(0,0,width, height); // 1024x1024

	//////////////// draw 
	glEnableClientState(GL_VERTEX_ARRAY);
	glBindBuffer(GL_ARRAY_BUFFER, vboID);
	glVertexPointer(4, GL_FLOAT, 0,0);
	
	glDrawElements(GL_TRIANGLES, (GLsizei)indices.size(), GL_UNSIGNED_SHORT, &(indices[0]));

Question : How can I debug this code ? How can I make sure there is something in the COLOR_ATTACHMENT0 ? How can I see if something has been updated from my shader to the buffer ?

thanks a lot for help

[QUOTE=superseed77;1255664]Hi all

I’ve got an application in opengl 2.x that used to work. But now i don’t see nothing.

In this application I update a VBO via a fragment shader via


gl_FragData[0] = vec4(x_i,1.0);

In the c++ code I draw a quad in which I make some calculation via the fragment shader
then I read back the buffer
and finally update my VBO and draw elements

the code is as follow:

	SetOrthographicProjection();
	glViewport(0,0,texture_size_x, texture_size_y); //64x64

		glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fboID[writeID]);	
		glDrawBuffers(3, mrt);	

		glActiveTexture(GL_TEXTURE0);
		glBindTexture(GL_TEXTURE_2D, attachID[2*readID]);

		glClear(GL_COLOR_BUFFER_BIT);
		glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
		verletShader.begin();	
			DrawFullScreenQuad();
		verletShader.end();
		//swap read/write pathways
		int tmp = readID;
		readID  = writeID;
		writeID = tmp;
	glFlush();


	ResetPerspectiveProjection();

	///////////read back the results into the VBO
	glBindFramebuffer(GL_READ_FRAMEBUFFER, fboID[readID]);


	glReadBuffer(GL_COLOR_ATTACHMENT0); 			
	glBindBuffer(GL_PIXEL_PACK_BUFFER, vboID); 			
	glReadPixels(0, 0, texture_size_x, texture_size_y, GL_RGBA, GL_FLOAT, 0); 

	glReadBuffer(GL_NONE); 
	glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);

	//reset default framebuffer
	glBindFramebuffer( GL_FRAMEBUFFER, 0 );
    glReadBuffer(GL_BACK);
    glDrawBuffer(GL_BACK); 
	
	//restore the rendering modes and viewport
	glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
	glViewport(0,0,width, height); // 1024x1024

	//////////////// draw 
	glEnableClientState(GL_VERTEX_ARRAY);
	glBindBuffer(GL_ARRAY_BUFFER, vboID);
	glVertexPointer(4, GL_FLOAT, 0,0);
	
	glDrawElements(GL_TRIANGLES, (GLsizei)indices.size(), GL_UNSIGNED_SHORT, &(indices[0]));

Question : How can I debug this code ? How can I make sure there is something in the COLOR_ATTACHMENT0 ? How can I see if something has been updated from my shader to the buffer ?

thanks a lot for help[/QUOTE]

Alternate question
what is the opengl3+ way to write that ?
thanx