writing a rasterizer

Member
Posts: 194
Joined: 2009.02
Post: #1
I'd like to write a simple rasterizer for fun as a learning experience without using any type of 3d library. After combing through a ton of apple documentation I can't seem to find any non-deprecated api calls that will either do what copybits() use to do, or that will give you some kind of pointer to the base address of a screen or window buffer. Might anyone have knowledge of how to achieve such a thing?
Quote this message in a reply
Member
Posts: 87
Joined: 2006.08
Post: #2
You can create a NSView, and override -drawRect:.

1) Allocate a buffer yourself.
2) Wrap the memory in a CGBitmapContextRef
3) Each frame, do the following in a [NSView drawRect;] method:
3a) draw the frame's content into your buffer
3b) get a CGImage with CGBitmapContextCreateImage()
3c) draw the CGImage into the Appkit provided CG context
3d) release the CGImage
Quote this message in a reply
Member
Posts: 269
Joined: 2005.04
Post: #3
Well QuickDraw and CopyBits are still around, but of course they're deprecated.

The replacement for QD is Quartz, which works a little differently. It's not as low-level so you can't draw directly into the screen/window buffer or whatever. However, you can just draw into an array of bits, create a CGBitmapContext out of that, and draw that to the screen. Some links:

http://developer.apple.com/reference/Gra...-date.html

http://developer.apple.com/documentation...TP40003853

http://developer.apple.com/documentation...-TPXREF101

Or....

You can use OpenGL for the final display. Render into an array, turn the array into a texture (FBOs, glTexSubImage2D, etc), and the have OGL draw the texture to the screen. You can still do all the rasterization into the array yourself. The extra benefit being that you can create a second OGL renderer for your scene using the same data structures for testing and comparison.
Quote this message in a reply
Moderator
Posts: 3,577
Joined: 2003.06
Post: #4
NelsonMandella Wrote:I'd like to write a simple rasterizer for fun as a learning experience without using any type of 3d library. ...

I love messing around with software rasterization once in a while. I learned a lot from Tricks of the 3D Game Programming Gurus (seems to be out of print). Here is a small site with very basic stuff you might check out. Also, you should definitely check out http://www.realtimerendering.com/ if you haven't already. If you happen to have any other good links, I'd be interested to see 'em myself.
Quote this message in a reply
Member
Posts: 194
Joined: 2009.02
Post: #5
AnotherJake Wrote:I love messing around with software rasterization once in a while. I learned a lot from Tricks of the 3D Game Programming Gurus (seems to be out of print). Here is a small site with very basic stuff you might check out. Also, you should definitely check out http://www.realtimerendering.com/ if you haven't already. If you happen to have any other good links, I'd be interested to see 'em myself.

Thanks for those links, they're quite interesting and helpful. The only book that I own on the subject is a very old book(I think from 1995) called Black Art of Macintosh Game Programming. The ladder half of the book focuses on building a 3d engine from the ground up- I highly recommend it. Rasterization is very interesting and educational stuff, I'd also love to build a simple 3d raytracer sometime.
Quote this message in a reply
Post Reply