Jump to content
  • Advertisement
Sign in to follow this  
Hedanito

OpenGL Fastest way of getting image on screen

This topic is 2624 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

I am currently working on a software rasterizer as a school assignment.
I started with copying image buffers to the screen, but the performance is already terrible.
At the moment I tried both glDrawPixels and copying the data to a texture and then drawing a quad on screen with that texture.
Sending data to the GPU every frame is just so incredibly slow.
I've had this same problem before with a software raytracer and I'm getting tired of it.
Something so simple should not take up so much of your application's performance.

So here is my question: What is the fastest way of getting my image data on the screen?
I'm willing to go all out.
I don't care which API I have to use as long as it works on Windows.
So I don't mind whether it's OpenGL, DirectX or even the Windows API.

So the only restrictions are:
- Works on Windows
- Uses C++

So if you know a quick way of doing this, or even just an idea of something that might be worth a try, please tell me.

Share this post


Link to post
Share on other sites
Advertisement
How about drawing a fullscren quad? Dont have time to explain, but should be straigthforward to find information

Share this post


Link to post
Share on other sites
In terms of APIs, I like PixelToaster. It's extremely simple, and cross-platform. I'm not sure what it does under-the-hood, except that on Windows it uses DirectX 9.

Share this post


Link to post
Share on other sites
I would suggest using a GPU/CPU texture (Staging texture in DX10/11). I can explain how to do it in 11 because I've done something similar.

For DX11:

1) Map (Lock) the texture.
2) Write your data in one memset.
3) Unmap (Unlock) the texture.
4) Copy the resource to a render target. (You may be able to do this directly to the back buffer. I don't remember.) Use: CopyResource (or was it CopySubresource?)
5) Render the render target to the back buffer.

This is off the top of my head.

Share this post


Link to post
Share on other sites
Drawing a fiullscreen quad is one tried and trusted way. If the texture needs to change every frame (e.g. you're rendering video) you need to look into dynamic texture updates, of course.

With OpenGL you need to make sure that your glDrawPixels parameters match your framebuffer format, otherwise it will need to go through a software conversion layer. On Windows this typically means that format param needs to be GL_BGRA and the type param needs to be GL_UNSIGNED_INT_8_8_8_8_REV. The more typically seen GL_RGB/GL_UNSIGNED_BYTE combination will always be slow as framebuffers are typically 32-bit (with the extra 8 unused). The params I gave are good enough to run fullscreen video at fast framerates on most hardware.

With Direct3D 9 you could create a device with D3DPRESENTFLAG_LOCKABLE_BACKBUFFER in it's present parameters flags member, then lock the back buffer and write the image data directly in. This should be more than fast enough so long as that's all you're doing every frame.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!