示例#1
0
    void ParticleManager::DrawParticles( float tween /*= 1.0f*/, int layer /*= -1*/ )
    {
        // tween origin
        _currentTween = tween;
        _camtx = -TweenValues(_oldOriginX, _originX, tween);
        _camty = -TweenValues(_oldOriginY, _originY, tween);
        _camtz =  TweenValues(_oldOriginZ, _originZ, tween);

        // record current GFX states
        /* not used
        float cAlpha = GetAlpha();
        float cRotation = GetRotation();
        float cScaleX = GetScaleX();
        float cScaleY = GetScaleY();
        int cRed = GetR();
        int cGreen = GetG();
        int cBlue = GetB();
        */

        // rendercount = 0
        if (_angle != 0)
        {
            _angleTweened = TweenValues(_oldAngle, _angle, tween);
            _matrix.Set(cosf(_angleTweened / 180.0f * (float)M_PI), sinf(_angleTweened / 180.0f * (float)M_PI), -sinf(_angleTweened / 180.0f * (float)M_PI), cosf(_angleTweened / 180.0f * (float)M_PI));
        }

        int layers = 0;
        int startLayer = 0;
        if (layer == -1 || layer >= _effectLayers)
        {
            layers = _effectLayers - 1;
        }
        else
        {
            layers = layer;
            startLayer = layer;
        }

        for (int el = startLayer; el <= layers; ++el)
        {
            for (int i = 0; i < 10; ++i)
            {
                auto& plist = _inUse[el][i];
                for (auto it = plist.begin(); it != plist.end(); ++it)
                {
                    DrawParticle(*it);
                }
            }
        }
        DrawEffects();

        // restore GFX states
        /* not used
        SetAlpha(cAlpha);
        SetRotation(cRotation);
        SetScale(cScaleX, cScaleY);
        SetColor(cR, cG, cB);
        */
    }
//-----------------------------------------------------------------------------
// Purpose: First-person function call after viewmodel has been drawn
//-----------------------------------------------------------------------------
void C_WeaponPortalgun::ViewModelDrawn( C_BaseViewModel *pBaseViewModel )
{
	// Render our effects
	DrawEffects( false );

	// Pass this back up
	BaseClass::ViewModelDrawn( pBaseViewModel );
}
示例#3
0
//-----------------------------------------------------------------------------
// Purpose: Viewmodel was drawn
//-----------------------------------------------------------------------------
void C_WeaponStunStick::ViewModelDrawn( C_BaseViewModel *pBaseViewModel )
{
	// Don't bother when we're not deployed
	if ( IsWeaponVisible() )
	{
		// Do all our special effects
		DrawEffects();
	}

	BaseClass::ViewModelDrawn( pBaseViewModel );
}
示例#4
0
//-----------------------------------------------------------------------------
// Purpose: Draws the stunstick model (with extra effects)
//-----------------------------------------------------------------------------
int C_WeaponStunStick::DrawModel( int flags )
{
	if ( ShouldDraw() == false )
		return 0;

	// Only render these on the transparent pass
	if ( flags & STUDIO_TRANSPARENCY )
	{
		DrawEffects();
		return 1;
	}

	return BaseClass::DrawModel( flags );
}
//-----------------------------------------------------------------------------
// Purpose: Third-person function call to render world model
//-----------------------------------------------------------------------------
int C_WeaponPortalgun::DrawModel( int flags )
{
	// Only render these on the transparent pass
	/*if ( flags & STUDIO_TRANSPARENCY )
	{
		DrawEffects( true );
		return 1;
	}*/

	int iRetValue = BaseClass::DrawModel( flags );

	if ( iRetValue )
	{
		DrawEffects( true );
	}

	return iRetValue;
}
示例#6
0
static void DisplayCallback(void)
{
    unsigned int MAXLATENCY=2000*1000; //2seconds rendering time is terrible

    //If we were Paused ( a.k.a. economy mode )
    //All the time passed since the last draw operation could lead to jerky movement
    //So we won't track time as we do regularly but "pretend" the last frame was 1ms ago
    //This will ensure smoothness and eye-candy for the user :)
    if (frame.onNextDrawAssumeWeWerePaused)
    {
      gettimeofday(&last_frame,0x0);
      time_passed_microseconds = 1000;
      frame.onNextDrawAssumeWeWerePaused = 0;
    } else
    {
    // Regular per frame time keeping
    /*KEEP TRACK OF TIME -----------------*/
    gettimeofday(&this_frame,0x0);
    time_passed_microseconds = timeval_diff(&difference,&this_frame,&last_frame);
    if (time_passed_microseconds>MAXLATENCY)
     {
      fprintf(stderr,"FRAME DELAYED %u msecs\n",time_passed_microseconds/1000);
      fprintf(stderr,"to keep things from freaking out we will pretend We were paused and only 1 ms passed\n");
      time_passed_microseconds=1000;
     }
    last_frame = this_frame;
    /*---------------------------------------*/
    }



    /* FRAME RATE COUNTING
       >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
	framecount+=1;
	timenow=glutGet(GLUT_ELAPSED_TIME);
	frame.tick_count=timenow; // <- Slideshow triggering
	if (timenow - timebase>1000)
	{
	    float real_fps = (framecount * 1000.0) / (timenow-timebase);
	    fps = (unsigned int) real_fps ;
	    frame.fps=fps; // <- Store in slideshow
	 	timebase = timenow;
		framecount = 0;
	}
    /*   >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/

    /*   >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
   /* Texture binding via OpenGL , it can only be done in this thread , before actually rendering  >>>>>>>>>>>>>>>>>>>>>>*/
   /* This code only counts textures to be created , they are actually loaded on the end of this function >>>>>>>>>>>>>>>*/

   /*   >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> */


    /* OPEN GL DRAWING >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> */
   // glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); // <- This causes screen tearing..! | GL_DEPTH_BUFFER_BIT
	  glPushMatrix();
       //glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();

          glRotatef(frame.angle_x,-1.0,0,0); // Peristrofi gyrw apo ton x
          glRotatef(frame.angle_y,0,-1.0,0); // Peristrofi gyrw apo ton y
          glRotatef(frame.angle_z,0,0,-1.0);
          glTranslatef(-frame.vx, -frame.vy, -frame.vz);

             MainDisplayFunction();

             Render_3DObjects();

             DrawEffects();

          glTranslatef(frame.vx,frame.vy,frame.vz);
       glPopMatrix();
     /*   >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> */


   /* DRAW APPLICATION HUD */
        if (frame.show_time>0)
        {
           unsigned int diff_ms=time_passed_microseconds/1000;
           if (frame.show_time>diff_ms) { frame.show_time-=diff_ms; } else
                                        { frame.show_time=0; }
          DisplayHUD(2);
        }else
        if (frame.show_information>0)
        {
           unsigned int diff_ms=time_passed_microseconds/1000;
           if (frame.show_information>diff_ms) { frame.show_information-=diff_ms; } else
                                               { frame.show_information=0; }
          DisplayHUD(1);
        }else
        if ( frame.distance_barrier_after_considered_close<frame.desired_z )
        {
          /* Display HUD only if not zoomed */
          DisplayHUD(0);
        }
   /* -  -  -  -  -  -  -  */
   glFinish(); // Thats all the drawing
   glutSwapBuffers();

   /*STATE MANAGMENT ----------------------------------------------------*/
   AutomaticSlideShowControl_if_needed(); /* if automatic slide show is enabled it will relay commands */

   /*  THIS COMMAND MOVES THE CAMERA ACCORDING TO THE USER/COMPUTER INPUT*/
   PerformCameraMovement(time_passed_microseconds);
   PerformPicturesMovement(time_passed_microseconds);

   Run3DObjects(time_passed_microseconds);


   /* Texture binding via OpenGL , it can only be done in this thread , while not rendering
        >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> */
   ManageCreatingTexturesMemory_OpenGLThread(0);
   /*   >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> */




  /* Changes on display behaviour  >>>>>>>>>>>>>>>>>>>>>>*/
  if ( !framerate_limiter() ) /* helps smoothing out framerate */
    {
      usleep(10); /*Some dead time */
    }


    glFlush(); //This is needed for Discrete GPU / ( Optimus ) to be working (!)
}