Sign in to follow this  
josemarin

OpenGL Render to buffer

Recommended Posts

Hi. I would like to set and get the buffer OpenGL uses to render the images. I will explain beter: 1) Create a buffer: an array of integers (ARGB) 2) Set this array as the render target 3) Render the scene 4) Read back the scene on the array This is possible?

Share this post


Link to post
Share on other sites
Are you trying read pixels off the screen? Or are you trying to create a pixel buffer? Yes, it is possible, but do you perfer to do it a special way? You can simply make an array and then use glReadPixels() to record screen data.

Share this post


Link to post
Share on other sites
I would like to use an array of integers as the render target of my OpenGL renderings.

I create the buffer with new int[width*height], for example, set as the render target, render the scene, and read back the result on the array.

This way, if I want to know tha value of the pixel at, say, (x = 10, y = 20), I could use the array like this:

int thePixel = array[width*20 + 10];



Share this post


Link to post
Share on other sites
You realease you can't use an integer, you'd have to use 3 char values for the RGB. You create the array of char values and then use glReadPixels() to take the current screen data and fill up the array. Also, are you trying to render to a texture?

EDIT: I don't know too much about render targets with OpenGL, so I'm doing some Googling.

Share this post


Link to post
Share on other sites
Ok, I'm reading here... If your making a render target, you obviousely don't want to display the scene, just render it to the frame buffer I believe. I'm trying to find out how to acess it...

Sorry buddy, I don't think I can help you on this.

Share this post


Link to post
Share on other sites
I would like to read the pixels on the screen to a buffer.
I my example, I could read the color components like this:

After reading the contents of the screen:

int thePixel = array[width*20 + 10];
byte alpha = thePixel & 0xFF000000 ;
byte red = thePixel & 0x00FF0000 ;
byte green = thePixel & 0x0000FF00 ;
byte blue = thePixel & 0x000000FF ;

It's possible to work like this?

Share this post


Link to post
Share on other sites
Oh, so you are rendering them to the screen! Yes I can help then. You would create your pointer and then call glReadPixels(0,0,width,height,GL_RGBA,GL_INT,array); Then you should be able to mess around with the pixels like you are. Sorry for the giant confusion.

Share this post


Link to post
Share on other sites
try the opengl extension EXT_framebuffer_object. using it you can set your array (a texture) as a rendering target and directly render to it - no pixel read back needed.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this