diego.martinez
Posts: 8
Joined: Mon Mar 24, 2014 11:59 am

Capture Rendered Pixels to memory

Wed Jul 09, 2014 10:00 am

Hi!

Im trying to capture the back buffer pixels to a memory buffer for capturing the rendered image.

I have a working code in Windows and im trying to port it to Raspberry Pi.

I do:

Code: Select all

		GLenum status;
	
	glGenFramebuffers(1, &framebufferID);  //i create framebuffer
	OGLERROR(__L("glGenFramebuffers")); //check error 

	glBindFramebuffer(GL_FRAMEBUFFER, framebufferID); //i bind the framebuffer
	OGLERROR(__L("glBindFramebuffer")); 

	glGenRenderbuffers(1,	&colorbufferID);	//Create and attach a color buffer
	OGLERROR(__L("glGenRenderbuffers"));

	// We must bind color_rb before we call glRenderbufferStorage
	glBindRenderbuffer(GL_RENDERBUFFER, colorbufferID);
	OGLERROR(__L("glBindRenderbuffer"));

	//The storage format is RGBA8
	glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA,	width,	height);
	OGLERROR(__L("glRenderbufferStorage"));

	//Attach color buffer to FBO
	glFramebufferRenderbuffer(GL_FRAMEBUFFER,	GL_COLOR_ATTACHMENT0,	GL_RENDERBUFFER,	colorbufferID);
	OGLERROR(__L("glFramebufferRenderbuffer"));
	
	glGenRenderbuffers(1,	&depthbufferID);
	OGLERROR(__L("glGenRenderbuffers"));

	glBindRenderbuffer(GL_RENDERBUFFER, depthbufferID);
	OGLERROR(__L("glBindRenderbuffer"));
				
	glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, width, height);
	OGLERROR(__L("glRenderbufferStorage"));

	//-------------------------
	//Attach depth buffer to FBO
	glFramebufferRenderbuffer(GL_FRAMEBUFFER,	GL_DEPTH_ATTACHMENT,	GL_RENDERBUFFER, depthbufferID);
	OGLERROR(__L("glFramebufferRenderbuffer"));
						

	glBindFramebuffer(GL_FRAMEBUFFER,framebufferID);

	//-------------------------
	//Does the GPU support current FBO configuration?
	status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
	
	if(status != GL_FRAMEBUFFER_COMPLETE)
		{
				switch(status)
					{	
					case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
						XDEBUG_PRINTCOLOR(0,__L("GRPBUFFEROPENGLRENDER::Ini Unable to create Framebuffer : GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT"));
						break;
					case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
						XDEBUG_PRINTCOLOR(0,__L("GRPBUFFEROPENGLRENDER::Ini Unable to create Framebuffer : GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT"));						
						break;
					case GL_FRAMEBUFFER_UNSUPPORTED:
						XDEBUG_PRINTCOLOR(0,__L("GRPBUFFEROPENGLRENDER::Ini Unable to create Framebuffer : GL_FRAMEBUFFER_UNSUPPORTED"));						
						break;
					default:
						XDEBUG_PRINTCOLOR(0,__L("GRPBUFFEROPENGLRENDER::Ini Unable to create Framebuffer : Unknown Reason"));
						break;						
					}
[...] stripped code here [...]

It returns GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT in Raspberry, but not in Windows.
What I should do?

User avatar
Paeryn
Posts: 2057
Joined: Wed Nov 23, 2011 1:10 am
Location: Sheffield, England

Re: Capture Rendered Pixels to memory

Wed Jul 09, 2014 9:03 pm

Code: Select all

   //The storage format is RGBA8
   glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA,   width,   height);
   OGLERROR(__L("glRenderbufferStorage"));
Your OGLERROR isn't working - trying to call glRenderbufferStorage() with GL_RGBA should be giving you a GL_INVALID_ENUM. You need to change it to GL_RGBA8_OES (and don't forget to #include "GLES/glext.h" or "GLES2/gl2ext.h" depending on which you are using).
She who travels light — forgot something.

User avatar
johannesl
Posts: 14
Joined: Thu May 23, 2013 8:38 pm

Re: Capture Rendered Pixels to memory

Thu Oct 23, 2014 8:26 am

Hi Diego!
Did you get this working?

Return to “OpenGLES”

Who is online

Users browsing this forum: No registered users and 1 guest