Jump to content
  • Advertisement
Sign in to follow this  
KiroNeem

OpenGL Fast blit using GDI and PBO

This topic is 3253 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

This seems like the most appropriate place to ask this question, though it involved two different APIs, OpenGL and Windows GDI. I'm attempting to improve speed in a custom operation that I'm doing. The speed of my implementation is fast, but at the resolution it's a bit too slow. Using a unseen OpenGL context to render my scene, reading back the data with glReadPixels into a DIB, then using that to BitBlt to a window. - Render scene - glReadPixels into DIB data - BitBlit into window For a 2560x1600 size the glReadPixels takes about 33ms and the BitBlit takes 3-4ms. I did some research and learned that PBO might be able to speed up my operation. I tested the speed and the actual readback was about 10ms faster, but the problem is that the PBO puts the data into it's own memory location. I can copy the data from here to the DIB, but then I loose the speed up I just gained. I would copy the PBO data directly to the window, but the GDI does not seem to give a good function to do so. So here are some specific questions I have to anyone who might know. - Is there a way to have a PBO map into my own allocated memory? I assume not. - Is there a better way to blit the data to the window? - Is there a way to directly change the bits pointer of a DIB bitmap? Is so this might also solve the issue, as I can intelligently change them around.

Share this post


Link to post
Share on other sites
Advertisement
Setup a child window and use opengl on that like you would making any other opengl application. Check out frame buffer objects, I beleive they do rpetty much the same thing just faster.

Share this post


Link to post
Share on other sites
Note that you can have OpenGL render to anything with an HWND. This includes Pictureboxes and many other Windows Controls.

Share this post


Link to post
Share on other sites
Quote:
Original post by AndyEsser
Why not use OpenGL to render direct into the Window?


Good question. I wish that were possible for my situation, as it would make things much simpler. I will be happy to explain.

- The offscreen OpenGL context is being used for rendering different scenes to multiple windows. This is a requirement of the application.

- Some Non-OpenGL windows in the application are created with WS_EX_LAYERED. Which I was disturbed to find does not interact well with standard OpenGL windows. You get horrible flickering and incorrect layering of windows when the two touch each other.

Quote:
Setup a child window and use opengl on that like you would making any other opengl application. Check out frame buffer objects, I beleive they do rpetty much the same thing just faster.


The child window idea wouldn't work for what I need. The issue is not embedding OpenGL in another window, but instead of transferring the data more efficiently.

Frame buffer objects allow you to render OpenGL to a offscreen buffer of memory on the GPU. I actually already use them in the application, but not for the purpose above. At the end of the day I still need to abstractly get the data from the GPU and into the CPU.

Quote:
Note that you can have OpenGL render to anything with an HWND. This includes Pictureboxes and many other Windows Controls.


Maybe I'm confused on your response, though I'm unsure how that would help. Rendering to a window is not an issue. There are several reasons I'm unable to use the standard WGL implementation.

Share this post


Link to post
Share on other sites
Quote:
Original post by KiroNeem
- Is there a way to have a PBO map into my own allocated memory? I assume not.


No, but you can create the buffer, glBufferData it with a NULL pointer (which creates the GPU side backing store), write the data to the buffer using glReadPixels, and then map the buffer (glMapBuffer) which will give you a pointer to give to GDI to draw to the window. That's only 1 data copy.

Share this post


Link to post
Share on other sites
Thanks for responding to my questions.

Just a thought. You can create a memory DC and have OpenGL render into that (which would effectively render into RAM), and then read the contents.

Not sure if that would work at all, but would avoid any copies.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!