PDA

View Full Version : Quickdraw question


xDexx
2002.10.09, 05:08 PM
im trying to write a game using Quickdraw, i know its the best graphics technology but its simple and i want to work my way up. so here is the question. lets say i have a line moving across the screen, the line leaves a trail. i do not want a trail. im assuming that the screen just isnt being cleared, how do i do this?
xDexx

Josh
2002.10.09, 06:26 PM
Is this Classic or Carbon? For Classic, you can call EraseRect(&theWindow->portRect) but for Carbon you probably have to call something else that I don't know off the top of my head.

w_reade
2002.10.10, 10:03 AM
GetPortBounds(yourPort, &someRect);
EraseRect(&someRect);

should do it.

Or you could draw the old line again in the background colour, effectively erasing everything you need to at the moment, and draw the new line in the foreground colour. Just a possibility.

xDexx
2002.10.10, 10:21 AM
ok so in order to do graphics properly i need to use an offscreen graphics port? right now its in classic but i want it to be carbon. is there a quickdraw website around that has totorials? apples site doesnt help too much. thanks
xDexx

cloke
2002.10.10, 04:49 PM
It might be worth a look to check out the MissleCommand Carbon from the source code section. I recently updated it to carbon and all the graphics are done using QuickDraw routines (ie, DrawLine, DrawOval, etc).

It is in straight C and is very simple.

xDexx
2002.10.11, 05:03 PM
this whole offscreen graphics port is just confusing! can someone write or point me toward some code that shows how to make an off screen graphics world, draw something simple on it, copy it to the window? thanks
xDexx

Taxxodium
2002.10.11, 06:26 PM
Aah the joy of offscreens. Don't feel bad, I used to have problems with the understanding of that but now I get it:

You make an offscreen by making a CGrafPort, here is how:

All you have to do to create the offscreen is do a call to NewGWorld() this will return a CGrafPtr (i think).

Save the current port by calling GetPort. Then, you just SetPort() to the offscreen you just created. Do your drawing and the LockPixels(). SetPort() to the screen (or to another offscreen) and then CopyBits() from the offscreen to the screen (or other offscreen). Don't forget to UnlockPixels and SetPort() to the old port and old Device.

Take a look at the functions I mentioned and you should get a basic understanding of how this works.

Josh
2002.10.11, 10:30 PM
Originally posted by xDexx
this whole offscreen graphics port is just confusing! can someone write or point me toward some code that shows how to make an off screen graphics world, draw something simple on it, copy it to the window? thanks
xDexx I have some very simple code that I made while teaching myself about offscreen ports. If you like, I will email it to you. It is not Carbonized but that should make little difference.