Apr 17 update.
Nothing but frustration for days. Many, many hours of failures and almost successes.
The issue: CGrafPtrs and CopyBits !!
My new nemesis, uugh.
Let me summarize my failures to hopefully illuminate for you something(s) I have missed so that you can aid me in resolution.
Goal: I already successfully load a PICT resource and draw it to the game Window. What I am trying to do is to change this to drawing the PICT over to an offScreen PixMap, do this for several PICTS is various positions, then use CopyBits to transfer the entire offScreen PixMap to the game Window.
1) tried creating & using GWorlds. Tried code sample on page 21-7 of InsideMac VI. Difficult turned to nightmare with all of the dependancies, that once added ended up causing previously working code to generate compilation errors (for Toolbox functions like GetDItem & Alert) claiming to be type discrepancies. Again previously compiling and running fine, add dependacies to the uses section, and suddenly broken.
2) tried creating a CGrafPtr using "OpenCPort". It immediately crashed until I followed it with SetPort(newCGrafPtr) then it seemed to work better. Seemed like no matter how many variations I tried at this point to use CopyBits, using this OpenCPort as my offScreen PixMap it either crashed or gave my compile errors as I was attempting type coercion and other tricks to code something I didn't understand much at all about.
3) tried creating new PixMaps, point them to loaded PICT resources, and use CopyBits to draw them onto the offscreenPixMap. No luck. Evidently strong-typed Pascal is making it impossible for me to do what the Inside Mac docs state (InsideMac V-66): "Most routines that accept bitMaps as parameters also accept pixMaps (not PixMapHandles)." I tried type coercion BitMap(myPixMapHandle^^) to no avail. And the QuickDraw.p file only includes:
Code:
procedure CopyBits ({CONST}
var srcBits: BitMap; {CONST}
var dstBits: BitMap; {CONST}
var srcRect: Rect; {CONST}
var dstRect: Rect; mode: INTEGER; maskRgn: RgnHandle);
4) what I have tried most recently that is sorta working but still has some issues I cannot work out: loading a 2nd WIND resource and using it as my "offScreen" PixMap. I have 2 windows loading now, drawing PICTs onto the "offScreen" one (that is still on the screen), then using CopyBits to copy that PixMap over to the main "game" window. Works great, mostly, but then when I try moving the window to the right, even mostly off the screen, the CopyBits starts buggering up the resulting image. I believe this is due to the WindowMgr handling the "invisible/hidden" visRgn & updateRgns. I have never dealt with those Regions, only just let the WindowMgr to it all for me, so I'm not sure if/how to manually adjust those so that my offScreen window can truly be well off the sides of the screen, allow me to draw onto them, then use CopyBits to get a complete render on the game window.
So I am stuck.
Hours of failed attempts.
So little sample code found when searching for it.
Sure would love StackOverflow for THINK Pascal lol.
So ahow about it 68kmla peeps? Got some guidance for me?
If I cannot get this to work I guess I'll be left with old-fashioned animation by erasing old position and drawing in new position animation in the game window, with some obvious flickering probably.