Crystal Space
Welcome, Guest. Please login or register.
September 21, 2014, 01:09:35 pm

Login with username, password and session length
Search:     Advanced search
9018 Posts in 2051 Topics by 8494 Members
Latest Member: Onapthanh
* Home Help Search Login Register
+  Crystal Space
|-+  Crystal Space Development
| |-+  Support
| | |-+  Global Access for iView
« previous next »
Pages: [1] Print
Author Topic: Global Access for iView  (Read 666 times)
Crystalfur
Newbie
*
Posts: 30


View Profile Email
« on: July 18, 2010, 05:01:19 am »

Hallo,

As you know, iView/iCamera are special of the cs modules. It is a curious thing, and causes a bit of trouble.
Take this for instance,

setupModules()
{
  engine = csQueryRegister<iEngine>(object_reg);
  if(!engine)
    ...do some error stuff...
  loader = ...
  ...etc...


// But when we get to iView, things change.

...
  view.AttachNew(new csView (engine, g3d));
  iGraphics2D* g2d = g3d->GetDriver2D ();
  view->SetRectangle (0, 0, g2d->GetWidth (), g2d->GetHeight ());
  ...
  view->GetCamera ()->SetSector (room);
  view->GetCamera ()->GetTransform ().SetOrigin (csVector3 (0, 5, -3));
}

Ok, so for some reason iView is different. That doesn't matter except when it comes to having a global point of access.
That is to say, if I need a handle to the engine, all I need is the app's object registry and I can get it via the same mechanism as before: csRef<iEngine> engine = csQueryRegistery<iEngine>(app->GetObjectRegistery()); and I've got it.

Is there a way to access the current view/camera from anywhere? I suppose I could make a Singleton that holds the view/camera if I needed to. Oh, and I do realize that I could do the whole 'pass the app and use an inline function like app->getView()... But I'm trying to avoid having to send my app around everywhere.

Oh, and if any of the devs are reading this, THANKYOU for documenting! I would have had a hell of a time figuring out why my CS_IMPLEMENT_FOREIGN_DLL wasn't working if you had not specifically stated that I needed to set iSCF::SCF.
« Last Edit: July 18, 2010, 05:04:25 am by Crystalfur » Logged
res
Develazyoper
CS Developer
Full Member
*****
Posts: 206


View Profile Email
« Reply #1 on: July 20, 2010, 12:13:36 am »

Is there a way to access the current view/camera from anywhere? I suppose I could make a Singleton that holds the view/camera if I needed to. Oh, and I do realize that I could do the whole 'pass the app and use an inline function like app->getView()... But I'm trying to avoid having to send my app around everywhere.

There is no “current view” as such: it's perfectly possible multiple iView implementations are instantiated at the same time and multiple, different views can be rendered in one frame. CS doesn't provide access to the “currently” or “last” used view (which might be some internally-used view anyway, and not the one you expect).
Logged
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 4.199 seconds with 15 queries.