|May 20, 2011, 04:55 AM||#1|
Fastest, simplest way to blit a block of memory to the screen
I'm in the process of writing a software 3d engine (just for fun, keeps my mind busy) and I would be very interested to know what the fastest way of blitting my rendered output to the screen would be (I'm of course aware that you can't ACTUALLY just blit something into screen memory directly) .
I'm currently using a few basic OpenGL / GLUT calls to create a large texture from my rendered bitmap data and then render it into a window (yes, I know, using OpenGL to render bitmap to the screen is a bit silly), updating the texture every frame.
My application is completely C based, although I would be happy to have one source file in (say) Objective-C if that file could handle the blitting side of things for me.
So what I need is the simplest way to:
*) Create a plain window at a specific (content) size (w,h)
*) Blit a block of memory to that window
The only user interaction I need is to handle the Quit command.
Any pointers would be really appreciated
Update:- Reading though some other forum posts it seems like OpenGL / Quartz is the way to do it, but with OpenGL insisting on power of two textures it seems wasteful to have to make and update a 1042 x 1024 texture to update a 600x600 window for example.
Last edited by Ian Moody; May 20, 2011 at 05:10 AM. Reason: Read some other posts in the forums :)
|May 20, 2011, 09:53 AM||#2|
One fast way is to assign your arbitrary sized block of memory to a CGBitmapContext, convert that bitmap context to an image, assign that image to the contents of a visible CALayer, then doing a CATransaction commit when the entire frame is ready. Helps to double (or triple) buffer all the bitmaps. But, under the hood, all this might get converted into Open GL texture loads to the GPU anyway; so if you've done that, you're done. All iOS device display memory appears to be on the other side of the GPU, so there's absolutely no way to write to iOS display without going through a GPU texture load or triangle fill.
One possible optimization for non-power-of-2 blits is to put multiple odd-sized bitmaps inside one larger 2^N texture map atlas.
Last edited by firewood; May 20, 2011 at 11:37 AM.
|May 20, 2011, 02:06 PM||#3|
Also, there is an extension that allows non-power of two textures. There is also a texture type - texture_rectangle that allows non-normalized texture coordinates. But I would recommend not using these.
If you really wanted to just blit to the screen, you can use glDrawPixels. This is a very simply function that just writes directly to the framebuffer.
glDrawPixels is probably the simplest way to achieve what you want, given that you already have an opengl window running.
|Thread Tools||Search this Thread|
|thread||Thread Starter||Forum||Replies||Last Post|
|Simplest way to block specific websites (& probs with multiple accounts)?||steveLONDON||OS X||8||Jan 6, 2014 08:48 AM|
|(Some results) What's the fastest stable memory for an early 2011 13" i7 MBPro?||adb1973||MacBook Pro||20||Jun 2, 2013 04:30 PM|
|iPhone doesn't block screen while charging||iphoneipoduser||iOS 6||0||Sep 22, 2012 04:31 PM|
All times are GMT -5. The time now is 05:20 PM.