🔒 Locked
Render to buffer
Advertisement
Original Post
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.
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];
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];
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.
EDIT: I don't know too much about render targets with OpenGL, so I'm doing some Googling.
Ah, I'll take a look. I'm going to grab my OpenGL book quickly! ;)
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.
Sorry buddy, I don't think I can help you on this.
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?
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?
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.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement