|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|
|Addition of Memory to the Air?||Yankee125xt||MacBook Air||5||Sep 16, 2011 10:12 AM|
|Safari (any way to move the Safari address bar to the bottom?)||JRoDDz||iPad||19||Apr 3, 2011 04:25 PM|
|Is There Any Way to Move the Menu Toolbars up to the Menu Bar?||gtr053||Mac Basics and Help||2||Sep 20, 2010 03:29 PM|
|Any way to change the icon of CLP-50 in the Print Utility for a OS X 10.6 Printer?||henryseiden||OS X||0||Apr 10, 2010 11:27 AM|
|Best way to transfer data from original MacBook to the Air?||thechungster||MacBook Air||7||Feb 19, 2009 06:41 AM|
All times are GMT -5. The time now is 07:47 AM.