glReadPixels is an OpenGL API function to read pixels data from source framebuffer to destination memory buffer. When FBO is supported, the source could be FBO; when PBO is supported, the destination could be PBO.
Questions tagged [glreadpixels]
200 questions
2
votes
1 answer
Reading depth buffer using OpenGLES3
In OpenGL I am able to read the z-buffer values, using glReadPixels, like so:
glReadPixels(scrx, scry, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &depth);
If I do the same in OpenGL ES 3.2 I get a GL_INVALID_OPERATION error.
Checking the specification, I…

Bram
- 7,440
- 3
- 52
- 94
2
votes
2 answers
Reading depth value of transparent plane with glReadPixels and gluUnProject
I am trying to create a billiards simulation and have been using glReadPixels along with gluUnProject to project my mouse pointer into the scene.
This works fine if the mouse is pointing at an object in the scene (the table for instance) but when it…

Andrew
- 21
- 2
2
votes
0 answers
Iphone saving a slow video with open gl filter
I am using avcapturesession with a preset AVCaptureSessionPresetMedium to capture video, i am applying effect on this video with opengl using shaders.
I use assetWriter to write the video to an mp4 file. The problem is that the resulted video is…

Mirka_09
- 21
- 1
2
votes
0 answers
glReadPixels() burns up all CPU cycles of a single core
I have an SDL2 app with an OpenGL window, and it is well behaved: When it runs, the app gets synchronized with my 60Hz display, and I see 12% CPU Usage for the app.
So far so good.
But when I add 3D picking by reading a single (!) depth value from…

Bram
- 7,440
- 3
- 52
- 94
2
votes
2 answers
How to use glReadPixels in Python and OpenGL?
How can I get the value of pixel color using glReadPixels()? I did so many try but getting wrong value.
My background color is blue(0,1,1) and I have drawn a circle with boundary color red(1,0,0) and I want to get the color of any of boundary point.…

MONA MINOR
- 29
- 3
2
votes
0 answers
Black screen using glReadPixels(...) on Samsung s9
For app reason I need to retrieve a screenshot of the screen, or to better say only the OpenGL drawn section. In all other devices my function works and uses the OpenGL primitive: "glReadPixels(...)"
On Galazy S9 the result is a buffer completely…

user1254938
- 81
- 9
2
votes
1 answer
Couldn't create HBITMAP from glReadpixels
So here's a part of my code, what I'm trying to do is to make a HBITMAP from a OpenGl frame capture.
unsigned char *output = 0;
output = new unsigned char[WINDOW_WIDTH * WINDOW_HEIGHT * 3];
glReadPixels(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT, GL_RGB,…

anako
- 125
- 7
2
votes
1 answer
OpenGL + SDL + Cannot Draw to Offscreen FBO
I have 2 programs - both OpenGL 3.x:
one is a Win32 program (a modified NeHe tutorial) which creates a Window and GL context via wglCreateContext() and wlgMakeCurrent()
one is an SDL2 progam
Both programs call this function:
int DrawGLScene(…

SparkyNZ
- 6,266
- 7
- 39
- 80
2
votes
1 answer
glReadPixels returns more data than expected
I want to save a video of what I am showing with openGL using JOGL. To do this, I am writing my frames to pictures as follows and then, once I have saved all frames I'll use ffmpeg. I know that this is not the best approach but I still don't have…

Learning from masters
- 2,032
- 3
- 29
- 42
2
votes
0 answers
glReadPixels always returns a black image
Some times ago I wrote a code to draw an OpenGL scene to a bitmap in Delphi RAD Studio XE7, that worked well. This code draw and finalize a scene, then get the pixels using the glReadPixels function. I recently tried to compile the exactly same code…

Jean-Milost Reymond
- 1,833
- 1
- 15
- 36
2
votes
1 answer
glReadPixels without loss of precision (Android)
I'm having a lot of trouble converting unique integers (index numbers) into unique float colours that are interpretable by an RGB565 OpenGL surface. When I assign unique colours, more often than not they are drawn as slightly different values due to…

STT
- 35
- 7
2
votes
1 answer
Weak precision when reading framebuffer with glReadPixels(...)
I want to leverage OpenGL to sample a discrete scalar map. The scalar map is given on per-triangle basis, i.e. one scalar per triangle.
First, I draw each triangle with flat shading and a color value corresponding to the scalar map. Then, I read the…

user1086105
- 247
- 4
- 11
2
votes
1 answer
Call glReadPixels Within display() JOGL
I am trying to implement object picking. I have code to render the objects as solid, unlit colors, then I read the pixels in the screen buffer. I interpret the readings from glReadPixels() to determine which object the cursor is currently on.…

Joshua Hyatt
- 1,300
- 2
- 11
- 22
2
votes
1 answer
How to render into FBO after "direct rendering to texture" without affecting the texture
I'm attempting to re-use FBO I have previously used for direct rendering into a texture.
I want to render into this FBO, without affecting the texture and grab the pixels using glReadPixels.
Normally, I would render anything and get the pixels using…

Jayco
- 185
- 2
- 10
2
votes
2 answers
Reading data from Three.js RenderToTarget gives unexpected results
Ok so I am trying to use WebGL's readPixels method to get the data rendered to a framebuffer from my shaders. The technique is simple enough:
renderer.render(sceneRTT, cameraRTT, rtTexture, true);
var pixels = new self.Uint8Array(width * height *…

Aleksandr Albert
- 1,777
- 1
- 19
- 26