Forum

Defeating the loading

Discuss programming topics for the various GPL'd game engine sources.

Moderator: InsideQC Admins

Defeating the loading

Postby behind_you » Wed Mar 02, 2011 12:18 pm

I'm trying to implement moving .lmps during loading times. Ive done this successfully, but the psp is busy loading instead of doing the lmp animation. I want it so that the psp animates the lmp while loading (ie animates the lmp as first priority). I know that this is highly unorthodox and may cause problems, but I want to test it out anyway. Any help is greatly appreciated.
User avatar
behind_you
 
Posts: 237
Joined: Sat Feb 05, 2011 6:57 am
Location: Tripoli, Libya

Re: Defeating the loading

Postby Baker » Wed Mar 02, 2011 1:16 pm

behind_you wrote:I'm trying to implement moving .lmps during loading times. Ive done this successfully, but the psp is busy loading instead of doing the lmp animation. I want it so that the psp animates the lmp while loading (ie animates the lmp as first priority). I know that this is highly unorthodox and may cause problems, but I want to test it out anyway. Any help is greatly appreciated.


When the PSP is loading, it is reading files and so forth. If you really wanted to, you could occasionally call SCR_Update (video_hardware_screen.cpp) from within video_hardware_model.cpp during the various stages of loading a map. You would run into numerous issues like "scr_disabled_for_loading" would be true would immediately exits SCR_Update but you could change that.

It'd be a lot of work and work poorly.
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Postby behind_you » Wed Mar 02, 2011 1:24 pm

i c. So kinda like a loading bar, right? Would it drastically increase loading times?
User avatar
behind_you
 
Posts: 237
Joined: Sat Feb 05, 2011 6:57 am
Location: Tripoli, Libya

Postby Baker » Wed Mar 02, 2011 1:34 pm

behind_you wrote:i c. So kinda like a loading bar, right? Would it drastically increase loading times?


Yeah. And you wouldn't get anything smooth out of the process at all.
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Postby behind_you » Wed Mar 02, 2011 2:04 pm

ok, thanks 4 sharing ur knowledge.

How about an lmp that doesn't animate but changes alpha every second or so during loading? Im thinking that its a similar technique to the one u described, but i only want it to change a few frames then stop.
User avatar
behind_you
 
Posts: 237
Joined: Sat Feb 05, 2011 6:57 am
Location: Tripoli, Libya

Postby Baker » Wed Mar 02, 2011 4:05 pm

(Now this isn't an answer to your question, but I'm showing you how and where the 2D drawing works. With this information, if you put your mind to it, you can begin experimentation.)

Look at the function SCR_Update in video_hardware_screen.cpp (I think that is the right file).

There is a line like this:

Code: Select all
   GL_Set2D ();


All the 2D drawing in a frame is done after that point in SCR_Update. (a frame is single drawing pass, like if you get 70 fps ... the screen is being drawing 70 times per second)

Depending on the engine, you'll have stuff like this ...

Code: Select all
   Draw_Crosshair ();
      SCR_DrawRam ();
      SCR_DrawNet ();
      SCR_DrawTurtle ();
      SCR_DrawPause ();
      SCR_CheckDrawCenterString ();
      SCR_DrawFPS ();
      SCR_DrawSpeed ();
      SCR_DrawVolume ();   //Baker: fix this
      Sbar_Draw ();
      SCR_DrawConsole ();
      M_Draw ();


All the 2D drawing is done either in SCR_Update or in the functions called by SCR_Update like, for instance, Sbar_Draw ... which draws the status bar.

Now when the engine starts the loading plaque (in Kurok this is a full screen black with the word "Loading..." at the bottom, but in standard Quake this is a little box that says "Loading" in the middle of the screen), it calls this

Code: Select all
void SCR_BeginLoadingPlaque (void)
{
   S_StopAllSounds (true);

   if (cls.state != ca_connected)
      return;
   if (cls.signon != SIGNONS)
      return;

// redraw with no console and the loading plaque
   Con_ClearNotify ();
   scr_centertime_off = 0;
   scr_con_current = 0;

   scr_drawloading = true;
   scr_fullupdate = 0;
   Sbar_Changed ();
   SCR_UpdateScreen ();
   scr_drawloading = false;

   scr_disabled_for_loading = true;
   scr_disabled_time = realtime;
   scr_fullupdate = 0;
}


Notice the SCR_Update () in the middle. Now the scr_drawloading is set to true BEFORE SCR_Update so that SCR_Update will draw the loading plague ... as such

Part of SCR_Update

Code: Select all
   else if (scr_drawloading) //loading
   {
      SCR_DrawLoading ();
   }


Which calls SCR_DrawLoading ...

Code: Select all
/*
==============
SCR_DrawLoading
==============
*/
void SCR_DrawLoading (void)
{
   qpic_t   *pic;

   if (!scr_drawloading)
      return;

   pic = Draw_CachePic ("gfx/loading.lmp");
   Draw_Pic ( (vid.width - pic->width)/2, (vid.height - 48 - pic->height)/2, pic);
}


Which is drawing the little "gfx/loading.lmp" box on the screen.

With this information, you should have enough to do your own experimentation and play around.

Engine coding is difficult to learn and I'd recommend you do a lot of tutorials. Only hands-on working with the engine code will give you enough experience to do any real engine modification.

Team XLink made this great reference:

viewtopic.php?t=2426

I'm just saying if you do some of the tutorials and spend a week or 2 doing your own experiments and tracing back code, you wouldn't even need to post this thread.

It's ok to ask very beginner questions several times, but you should do tutorials and/or read some of the engine threads.
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Postby Baker » Wed Mar 02, 2011 4:32 pm

More information ...

If you are changing the alpha of an image, you are still drawing a frame because you have to draw a new frame with a different alpha. It is no different than doing an animation which is also a drawing frame.

If you wanted to change the loading plaque above to have an alpha value ... instead of Draw_Pic use Draw_AlphaPic which has a final value of the range 0 to 1 (0 = invisible, .5 = half alpha, 1 = fully solid).

Example

Code: Select all
void SCR_DrawLoading (void)
{
   qpic_t   *pic;

   if (!scr_drawloading)
      return;

   pic = Draw_CachePic ("gfx/loading.lmp");
   Draw_AlphaPic ( (vid.width - pic->width)/2, (vid.height - 48 - pic->height)/2, pic, 0.5 /* Half translucent */);
}
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Postby behind_you » Wed Mar 02, 2011 4:35 pm

This is an awesome in depth tutorial! I've learned a lot after reading this over 3 times. Thanks a lot, especially knowing how busy you are.

I'm actually learning source code quite quickly. I only post a question after trying until im 100 percent stuck. Honestly, I learned how to draw_transpic all on my own, along with changing death rotation screen, screen flashing, weapon bobbing, and i even replaced the health number with a health bar(not with draw fill, but with actual lmps). I know that most of these often only include changing one variable, but to me its a big deal. Make fun if u like, bt im proud of myself.

One little q. How do i make a function 'stall' before being done?
User avatar
behind_you
 
Posts: 237
Joined: Sat Feb 05, 2011 6:57 am
Location: Tripoli, Libya

Postby Baker » Wed Mar 02, 2011 5:18 pm

behind_you wrote:One little q. How do i make a function 'stall' before being done?


Code: Select all
   SCR_ModalMessage ("Press Y or N to continue");
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Postby behind_you » Wed Mar 02, 2011 5:59 pm

ok thats cool because i was wondering about that as well. But i meant like stall 2 seconds, not until keypress
User avatar
behind_you
 
Posts: 237
Joined: Sat Feb 05, 2011 6:57 am
Location: Tripoli, Libya

Postby Baker » Wed Mar 02, 2011 7:16 pm

Code: Select all
   float time1 = Sys_DoubleTime (); /* save old time*/
   float time2 = 0.0f;
   float timeout = 2.0f; // 2 second timeout

   do {
      time2 = Sys_DoubleTime (); // Get current time
   } while (time2 <= time1 + timeout); // Wait for 2 seconds to elapse
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Postby behind_you » Wed Mar 02, 2011 7:46 pm

thanks!
User avatar
behind_you
 
Posts: 237
Joined: Sat Feb 05, 2011 6:57 am
Location: Tripoli, Libya


Return to Engine Programming

Who is online

Users browsing this forum: No registered users and 1 guest