Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
144 user(s) are online (128 user(s) are browsing Forums)

Members: 0
Guests: 144

more...

Support us!

Headlines

 
  Register To Post  

getting screen from rastport ?
Home away from home
Home away from home


See User information
Is it possible to get screen from rastport ? I mean something like:

struct RastPort *rp;

rp = blbalbalb;

GetScreenDrawInfo(rp->Layer->Window->WScreen);

Last one didn't works, just as example.


Edited by kas1e on 2017/1/15 8:21:06
Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: getting screen from rastport ?
Just can't stay away
Just can't stay away


See User information
@kas1e

Where does the rastport come from?

If it's not a layered (window) rastport then rp->Layer will be NULL so rp->Layer->Window->WScreen won't work.

If you know it's the screen rastport (the one embedded in the Screen structure) there is some pointer arithmetic you could do to get back the screen pointer, but if you know this then you might as well pass the screen pointer directly to your function instead of just the rastport.

Go to top
Re: getting screen from rastport ?
Just can't stay away
Just can't stay away


See User information
And something like:

struct RastPort *rp = blbalbalb;
struct Layer *layer = rp->Layer;
struct Screen *scr = ((struct Window *)(layer->Window))->WScreen;

But as salas00 pointed out it could be that 'layer->Window == NULL'.

Go to top
Re: getting screen from rastport ?
Home away from home
Home away from home


See User information
@all
Quote:

If you know it's the screen rastport (the one embedded in the Screen structure) there is some pointer arithmetic you could do to get back the screen pointer, but if you know this then you might as well pass the screen pointer directly to your function instead of just the rastport.


Yep, its the screen rastpot. It was situation when i have function (in one of many source files) which have only rastport as parametr, and no window/screen. And i was in hope somehow got screen from rastport without needs to rewrite function to get also screen parametr (and without needs to rewrite all parts in whole programm where happens call to that function).

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: getting screen from rastport ?
Just can't stay away
Just can't stay away


See User information
@kas1e

In that case using container_of macro:

#ifdef __GNUC__
#define container_of(ptr, type, member) ({ \
    
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
    
(type *)( (char *)__mptr offsetof(typemember) );})
#else
#define container_of(ptr, type, member) ( (type *)( (char *)(ptr) - offsetof(type, member) ) )
#endif


You can do:

struct RastPort *rp;
struct Screen *screen;

screen container_of(rpstruct ScreenRastPort);

Go to top

  Register To Post

 




Currently Active Users Viewing This Thread: 2 ( 0 members and 2 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2024 The XOOPS Project