Advertisement

glDrawPixels alternative

Started by April 27, 2020 01:31 AM
10 comments, last by taby 4 years, 9 months ago

So my code relying on glDrawPixels breaks when using GLFW. What is the best alternative? I'm basically wanting to read the framebuffer, make some changes to it, then write back to the framebuffer.

Once you read it to uchar buffer you could glTexSubImage2D it

Advertisement

Can you do your changes in a shader instead? ?

pcmaster said:
Can you do your changes in a shader instead? ?

Probably the idea is to prototype shaders with comfort of CPU and C++? And then port to shader when done?

… wonderful idea i've never had! :D

I'm halfway there LOL. I have it reading the framebuffer to a vector<GLubyte>, now I just have to do the opposite – i'm assuming that this will take a fullscreen quad to do the job.

I'm ¾ of the way there. How does one copy a texture to the framebuffer?

Advertisement

There are different ways, depending on what you're up to, from directly writing to it or a renderbuffer over blitting to atomic operations. The documentation has all the details.

taby said:

So my code relying on glDrawPixels breaks when using GLFW. What is the best alternative? I'm basically wanting to read the framebuffer, make some changes to it, then write back to the framebuffer.

What exactly are you trying to do? Reading back anything from the GPU, changing it, then using it in the same frame is generally terrible for performance. Using shaders sounds like a much better way.

I'm reading the framebuffer, altering it using OpenCV, then trying to write it back to the framebuffer.

I've tried glFramebufferTexture2D. Am I close?

Cool, a guessing game. My gues is “no” because you can't read or write a framebuffer, only its attachments.

This topic is closed to new replies.

Advertisement