Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: How to debug

  1. #1
    Junior Member Newbie
    Join Date
    Jul 2012
    Posts
    3

    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


    Code :
    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:

    Code :
    	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

  2. #2
    Junior Member Newbie
    Join Date
    Jul 2012
    Posts
    3
    Quote Originally Posted by superseed77 View Post
    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


    Code :
    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:

    Code :
    	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
    Alternate question
    what is the opengl3+ way to write that ?
    thanx

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •