#RastPort access
9 messages in this thread
OK, I have only just managed to get a copy of the v2.0 RKMs, so I am a
mere beginner at Amiga-specific programming.
I have a question about getting at the RastPort structure of the
current window.
I have a custom screen and a simple window fire up fine, the problem is
when I try to use some of the graphics drawing primitives on that RastPort.
Any time I've tried to execute a routine (a Move, Draw, Circle, etc. ).
into the port, it crashes. I've tried it with both LONGs and SHORTs as the
position parameters with no luck (I've seen examples of this done both ways).
Any clues? How obvious is the mistake? 🙂
I have made sure that the values places in the position parameters are
all within the window in question. (I eventually want to see how well the
clipping routines can fit to the job I intend to use this for.
Since I am at such a beginner stage, I'm sure to be pestering you all
quite a bit in the next few weeks (at least).
Thanks in advance.
Joe
struct Screen *my_screen; struct Window *my_window; struct RastPort *rastPort;
WORD x, y, z; LONG result;
rastPort = my_window->RPort;
Delay( 50 * 3 );
DrawCircle( &rastPort, x, y, z );
Joe.
> rastPort = my_window->RPort;
> Delay( 50 * 3 );
> DrawCircle( &rastPort, x, y, z );
^^^^^^^^
You are passing the address of the address of the rastPort when you just want
to pass the address, like so:
DrawCircle( rastPort, x, y, z );
ie. without the "&". (I assume you are also opening the graphics library).
Regards,
David Benn
David,
Yes, I'm pretty sure it is simply a point/address problem.
To make things worse, I'm pretty sure that I've tried that, too.
I have it listed this way, as per p.587, RKM Libraries.
I'll try it again.
Thanks.
Joe
Joe,
I just checked out the page 587 reference in the RKM and this sure looks like a
typo.
Let me know if I can help any further.
Rgds,
David Benn
David,
Sorry for the delay, I've been busy lately.
As mentioned in another reply here, I've been wondering if it might be
a library problem. I'll be trying Derek's suggestion and get back to you two
soon.
With a hurdle like this at this early stage, I'm sure to have many more
in the near future.
Thanks.
Joe
David,
Do I feel like a clown…
After reading Derek's message I checked to see about opening the
graphics.library and I found that I wasn't.
I also *reread* the first message you posted to me and saw that you had
also mentioned that as well and I missed it.
It turns out that following Derek's suggestion about opening the
graphics.library was just the thing to cure my ills.
I should also quote my code a bit more fully in the future.
Thanks to you two, I can get going again.
This is exactly the type of problem that I will be having in the near
future – deciding what libraries need opening for the things I need done. I
completely missed needing graphics.library.
BTW, just how robust is the window clipping? I intend to use this (and
a borderless window) to clip while developing, then try to whip up some of my
own clipping routines after getting somewhere.
Thanks, again.
Joe
No problem. Glad you fixed it.
Rgds,
David Benn
Hi Joe,
I don't know just how much of a beginner you are so please don't take
my comments the wrong way, I just want to help you out, okay?
I suspect that the problem is the way you've used the rastport
variable. Instead of …
> DrawCircle( &rastPort, x, y, z );
use …
DrawCircle( rastPort, x, y, z );
that is, the same except for the '&'. Using the '&' means that you will pass
the address of the RastPort structure's address, instead of just the address of
the RastPort structure.
Also, if you haven't opened the graphics library, you will crash too.
Use something like this…
struct GfxBase *GfxBase = 0;
int main(….) {
GfxBase = (struct GfxBase *)OpenLibrary("graphics.library", 0L);
.
.
. }
You should also close the library just before your program ends. And just to
help make your software a bit more bulletproof, check the value of the GfxBase
after you've opened the library. If it is NULL then something bad happened and
the library didn't open!
—Derek [from Melbourne using Golden Compass]
Derek,
Actually, when it comes to C programming, I am not a beginner at all,
just when it comes to programming Amiga-specific code.
As for my ego? I think it would take a bit more than that to bruise
it. Don't worry about it!
I have tried the line with and without the '&', as well as using SHORTs
and LONGs for the Drawxxx parameters. I haven't had the chance to get in to
thins forum for a while (hence the delay in my reply), but I have already
started wondering if it might be open library related.
Opening the graphics.library, eh? Well, if that would crash it, then
it may be the problem, since all I have open is the intuition.library.
Thanks for the tip, I'll try it out today, to see what happens.
Joe