Crystal Space
Welcome, Guest. Please login or register.
November 24, 2014, 01:25:45 pm

Login with username, password and session length
Search:     Advanced search
9022 Posts in 2050 Topics by 9104 Members
Latest Member: Moniterr
* Home Help Search Login Register
+  Crystal Space
|-+  Crystal Space Development
| |-+  Support
| | |-+  problem showing a splash screen
« previous next »
Pages: [1] Print
Author Topic: problem showing a splash screen  (Read 4199 times)
maharaja
Jr. Member
**
Posts: 52

t.javed@hotmail.com
View Profile Email
« on: November 25, 2007, 03:31:34 pm »

Hi,

Using CS-CEL 1.2 branch on windows:
What would be the best way (memory and resources wise) to show a splash screen from C++ code while the application is loading?

I tried doing it with CEGUI but problem is it would'nt show until the default Run() loop is running.. by which time there is no point to show a splash anyway.
I need to just load a static image and show it immediately as the application window opens.

Many thanks in advance!

/regards
Logged
maharaja
Jr. Member
**
Posts: 52

t.javed@hotmail.com
View Profile Email
« Reply #1 on: November 26, 2007, 02:13:51 pm »

Any suggestions please?

Still stuck with this problem, would appreciate a lot if someone could help out.


/regards
Logged
bookeater2
Newbie
*
Posts: 45


View Profile Email
« Reply #2 on: November 26, 2007, 03:42:34 pm »

If you are planning on being fullscreen you should be able to draw a fullscreen pixmap once when the plugins have loaded. This should stay until other loading is done, but if it is windowed it would need to be drawn periodically or with some kind of refresh system, I'm not clear on what that requires, there is a progress bar system in CS. I may be able to help more if you need it.
Logged
maharaja
Jr. Member
**
Posts: 52

t.javed@hotmail.com
View Profile Email
« Reply #3 on: November 26, 2007, 07:59:10 pm »

Hi,

Thanks for your response.
Yes, my app is not full-screen so I need to find a way how to do this in windowed mode.

So far, I have tried to do this using CEGUI in various ways but nothing works out.
This first splash screen needs to be shown immediately as the window opens, and before any 'world' or 'level' file starts loaded.

If you could help with any ideas how to achieve this I'd very much appreciate.

/regards
Logged
rvhaasen
Jr. Member
**
Posts: 62


View Profile
« Reply #4 on: November 27, 2007, 09:56:23 am »

After loading the plugins you could use the following code snippet:
Code:
  // We need a View to the virtual world.
  view.AttachNew(new csView (engine, g3d));

  iGraphics2D* g2d = g3d->GetDriver2D ();

  // We use the full window to draw the world.
  view->SetRectangle (0, 0, g2d->GetWidth (), g2d->GetHeight ());

  // Get splash image file from configuration file
  const char* splashFile = cfg->GetStr ("Credosim.Settings.SplashScreenFile","");

  if (splashFile)
  {
    // Load splash screen
    loader->LoadTexture ("splash", splashFile);

    // Create a 2D sprite
    iTextureWrapper *texWrapper;
    iTextureHandle* phTexHandle;

    csPixmap* csSplash;
    texWrapper = engine->GetTextureList ()->FindByName ("splash");
    if (texWrapper)
    {
      texWrapper->SetFlags (CS_TEXTURE_2D);
      phTexHandle = texWrapper->GetTextureHandle();
      if (phTexHandle)
      {
        csSplash = new csSimplePixmap (phTexHandle);
        g2d->BeginDraw();
        csSplash->DrawScaled (g3d, 0, 0, g2d->GetWidth(), g2d->GetHeight());
        g3d->FinishDraw();
        const csRect area;
        g3d->Print(&area);
      }
    }
  }
  // Here we load our world from a map file.
  if (!LoadMap ()) return false;
Logged
bookeater2
Newbie
*
Posts: 45


View Profile Email
« Reply #5 on: November 27, 2007, 04:35:57 pm »

I thought there was a way to repeatedly draw and update the image with iProgressMeter as certain loading operations continue, but now I am unable to figure how to do it...
there was a threaded map load function but I presume it also is not implemented. Other options like threads are pretty technical but possible.
Logged
res
Develazyoper
CS Developer
Full Member
*****
Posts: 206


View Profile Email
« Reply #6 on: November 27, 2007, 06:36:31 pm »

Just drawing a pixmap after initialization, like rvhaasen and others suggested, is simple yet should do the trick. Fullscreen or windowed doesn't really matter.
Logged
maharaja
Jr. Member
**
Posts: 52

t.javed@hotmail.com
View Profile Email
« Reply #7 on: November 28, 2007, 02:37:37 am »

Thanks a lot everyone. I got it working at last.

rvhaasen, you're a life-saver...owe you a beer next time you come over to Tallinn. Smiley

/cheers
Logged
rvhaasen
Jr. Member
**
Posts: 62


View Profile
« Reply #8 on: November 28, 2007, 11:02:08 am »

...a more likely opportunity for this will be the next cs conference in Aachen (unless  you can convince the cs-team to go to Talinn next year  smiley )
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 5.235 seconds with 16 queries.