コード例 #1
0
void SpectralEffect::InitInGame()
{
	test.LoadFiles("Data.zip", d3dd);

	while (test.GetProgress() != 100)
	{
		Sleep (100);
	}
	
	string temp[1];
	temp[0] = "YellowBall.png";
	testpipe.SetPipeType(d3dd, 100, 100, 280, 5, 1, temp, 1, "Pipe.png");
	testcannons.InitCannonType(&testpipe, 30, 20, 100, 15, "Cannon.png");
	int time = 0, speed = 1;
	SetFPS(30);
	while (gameRunning)
	{
		StartFrame();
		BeginRender();
		testcannons.Render();
		testpipe.Render();
		EndRender();
		if (time > 500)
		{
			speed ++;
			testpipe.SetSpeed(speed);
			time = 0;
		}
		time ++;
		EndFrame();
	}

	gameRunning = true;
}
コード例 #2
0
ファイル: ANIM.CPP プロジェクト: CGSG/TLR
/* Timer event handle function.
 * ARGUMENTS: None.
 * RETURNS: None.
 */
VOID tlr::anim::Timer( VOID )
{
  /* Handle timer */
  timer::Response();
  static CHAR Buf[100];
  sprintf(Buf, "fps: %.5f", FPS);
  SetWindowText(win::hWnd, Buf);

  /* Handle input system */
  input::Response();

  /* Hanlde animation objects */
  for (INT i = 0; i < Units.Size(); i++)
    Units[i]->Response(this);

  StartFrame();
  for (INT i = 0; i < Units.Size(); i++)
  {
    glPushAttrib(GL_ALL_ATTRIB_BITS);
    Units[i]->Render(this);
    glPopAttrib();
  }
  EndFrame();
  CopyFrame();
  IncrFrameCount();
} /* End of 'tlr::anim::Timer' function */
コード例 #3
0
void UIDirect3D9Window::MainLoop(void)
{
    quint64 timestamp = StartFrame();

    CheckForNewTheme();
    UpdateImages();

    if (m_d3dDevice)
    {
        HRESULT result = m_d3dDevice->TestCooperativeLevel();

        if (SUCCEEDED(result))
        {
            m_d3dDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_ARGB(0, 0, 0, 0), 1.0f, 0);

            if (m_theme && m_d3dDevice && SUCCEEDED(m_d3dDevice->BeginScene()))
            {
                m_theme->Refresh(timestamp);
                m_theme->Draw(timestamp, this, 0.0, 0.0);

                m_d3dDevice->EndScene();
                m_d3dDevice->Present(NULL, NULL, NULL, NULL);
                SetThreadExecutionState(ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED);
            }
        }
        else
        {
            switch (result)
            {
                case D3DERR_DEVICELOST:
                    if (D3DERR_DEVICELOST != m_deviceState)
                        LOG(VB_GENERAL, LOG_ERR, "Device lost");
                    m_deviceState = D3DERR_DEVICELOST;
                    break;
                case D3DERR_DRIVERINTERNALERROR:
                    LOG(VB_GENERAL, LOG_ERR, "Driver error - quiting");
                    m_deviceState = D3DERR_DRIVERINTERNALERROR;
                    qApp->exit();
                    break;
                case D3DERR_DEVICENOTRESET:
                    if (D3DERR_DEVICENOTRESET != m_deviceState)
                        LOG(VB_GENERAL, LOG_ERR, "Device needs reset");
                     m_deviceState = D3DERR_DEVICENOTRESET;
                     HandleDeviceReset();
                default:
                    break;
            }
        }
    }

    FinishDrawing();

    if (m_timer)
    {
        m_timer->Wait();
        m_timer->Start();
    }
}
コード例 #4
0
ファイル: animation.cpp プロジェクト: vasiliycheptsov/physic
/* Redraw window content function.
 * ARGUMENTS:
 *   - window device context:
 *       HDC hDC;
 * RETURNS: None.
 */
VOID physic::anim::Paint( HDC hDC )
{
  StartFrame();
  glPushAttrib(GL_ALL_ATTRIB_BITS);
  Navigation.Render(this);
  glPopAttrib();
  World.ModelUpdate(this);
  World.Render(this);
  EndFrame();
  CopyFrame();
  IncrFrameCount();
} /* End of 'physic::anim::Paint' function */
コード例 #5
0
void eae6320::Graphics::Render()
{
	ClearFrame();
	StartFrame();

	// Drawing Opaque list
	s_boxes_obj->DrawObject();
	s_ceiling_obj->DrawObject();
	s_floor_obj->DrawObject();
	s_innerWalls_obj->DrawObject();
	s_metal_obj->DrawObject();
	s_outerWalls_obj->DrawObject();
	s_railing_obj->DrawObject();

	// Drawing Transparent list
	//


	// Drawing Debug Shapes
#ifdef _DEBUG
	s_debugLine1.DrawLine();
	s_debugLine2.DrawLine();
	s_snowmanLine->DrawLine();
	s_debugBox1.DrawBox();
	s_debugBox2.DrawBox();

	if (s_debugMenuCheckBox->m_isChecked)
	{
		s_debugSphere1->DrawSphere();
		//s_debugSphere2.DrawSphere();
	}

	Graphics::GetLocalDirect3dDevice()->SetRenderState(D3DRS_FILLMODE, D3DFILL_WIREFRAME);
	s_debugCylinder1->DrawObject();
	s_debugCylinder2->DrawObject();
	Graphics::GetLocalDirect3dDevice()->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID);
#endif

	// Drawing Game Sprites
	//s_logo.Draw();
	s_numbers->Draw();

	// Drawing third person snowman
	s_snowman->DrawObject();
	s_snowmanClient->DrawObject();

	// Draw Capture the Flag Stuff
	s_flag1->DrawObject();
	s_flag2->DrawObject();
	if(s_bullet1->m_isActive)
		s_bullet1->DrawObject();
	if (s_bullet2->m_isActive)
		s_bullet2->DrawObject();
	s_sprintBar->DrawDebugBar(150);
	s_snowmanScore->DrawDebugText(100);
	if(s_clientJoined)
		s_snowmanClientScore->DrawDebugText(100);

	// Drawing Debug Menu Items
#ifdef _DEBUG
	if (s_debugMenuEnabled)
	{
		float fpsCount = 1 / Time::GetSecondsElapsedThisFrame();
		s_debugMenuTextFPS.SetFPS(fpsCount);

		switch (s_activeMenuItem)
		{
		case DebugMenuSelection::Text:
			s_debugMenuTextFPS.DrawDebugText(255);
			s_debugMenuCheckBox->DrawDebugCheckBox(0);
			s_debugMenuSlider->DrawDebugSlider(0);
			s_debugMenuButton->DrawDebugButton(0);
			s_toggleFPSCheckBox->DrawDebugCheckBox(0);
			break;

		case DebugMenuSelection::CheckBox:
			s_debugMenuTextFPS.DrawDebugText(0);
			s_debugMenuCheckBox->DrawDebugCheckBox(255);
			s_debugMenuSlider->DrawDebugSlider(0);
			s_debugMenuButton->DrawDebugButton(0);
			s_toggleFPSCheckBox->DrawDebugCheckBox(0);
			break;

		case DebugMenuSelection::Slider:
			s_debugMenuTextFPS.DrawDebugText(0);
			s_debugMenuCheckBox->DrawDebugCheckBox(0);
			s_debugMenuSlider->DrawDebugSlider(255);
			s_debugMenuButton->DrawDebugButton(0);
			s_toggleFPSCheckBox->DrawDebugCheckBox(0);
			break;

		case DebugMenuSelection::Button:
			s_debugMenuTextFPS.DrawDebugText(0);
			s_debugMenuCheckBox->DrawDebugCheckBox(0);
			s_debugMenuSlider->DrawDebugSlider(0);
			s_debugMenuButton->DrawDebugButton(255);
			s_toggleFPSCheckBox->DrawDebugCheckBox(0);
			break;

		case DebugMenuSelection::ToggleCam:
			s_debugMenuTextFPS.DrawDebugText(0);
			s_debugMenuCheckBox->DrawDebugCheckBox(0);
			s_debugMenuSlider->DrawDebugSlider(0);
			s_debugMenuButton->DrawDebugButton(0);
			s_toggleFPSCheckBox->DrawDebugCheckBox(255);
			break;

		default:
			break;
		}
	}
#endif

	EndFrame();
	ShowFrame();
}
コード例 #6
0
ファイル: g_main.c プロジェクト: angeld29/TF2003-qvm
int vmMain( int command, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5,
            int arg6, int arg7, int arg8, int arg9, int arg10, int arg11 )
{
    ClearGlobals();
    switch ( command )
    {
    case GAME_INIT:
        api_ver = trap_GetApiVersion();
        if ( api_ver < MIN_API_VERSION )
        {
            G_conprintf("Mod requried API_VERSION %d or higher, server have %d\n", MIN_API_VERSION, api_ver);
            return 0;
        }
        if( api_ver >= MIN_API_VERSION && api_ver <= GAME_API_VERSION )
        {
            gamedata.APIversion = api_ver;
        }
        G_InitGame( arg0, arg1 );
        return ( int ) ( &gamedata );

    case GAME_LOADENTS:
        G_SpawnEntitiesFromString();
        return 1;

    case GAME_START_FRAME:
        StartFrame( arg0 );
        return 1;

    case GAME_CLIENT_CONNECT:
        self = PROG_TO_EDICT( g_globalvars.self );
        self->auth_time = g_globalvars.time + 10.0;
        self->isSpectator = arg0?1:0;
        if ( arg0 )
            SpectatorConnect();
        else
            ClientConnect();
        return 1;

    case GAME_PUT_CLIENT_IN_SERVER:
        self = PROG_TO_EDICT( g_globalvars.self );
        if ( !arg0 )
            PutClientInServer();
        return 1;

    case GAME_CLIENT_DISCONNECT:
        self = PROG_TO_EDICT( g_globalvars.self );
        if ( arg0 )
            SpectatorDisconnect();
        else
            ClientDisconnect();
        return 1;

    case GAME_SETNEWPARMS:
        SetNewParms();
        return 1;

    case GAME_CLIENT_PRETHINK:
        self = PROG_TO_EDICT( g_globalvars.self );
        if ( !arg0 )
            PlayerPreThink();
        return 1;

    case GAME_CLIENT_POSTTHINK:
        self = PROG_TO_EDICT( g_globalvars.self );
        if ( !arg0 )
            PlayerPostThink();
        else
            SpectatorThink();
        return 1;

    case GAME_EDICT_TOUCH:
        G_EdictTouch();
        return 1;

    case GAME_EDICT_THINK:
        G_EdictThink();
        return 1;

    case GAME_EDICT_BLOCKED:
        G_EdictBlocked();
        return 1;

    case GAME_SETCHANGEPARMS: //called before spawn new server for save client params
        self = PROG_TO_EDICT( g_globalvars.self );
        SetChangeParms();
        return 1;

    case GAME_CLIENT_COMMAND:
        self = PROG_TO_EDICT( g_globalvars.self );
        return ClientCommand();

    case GAME_CLIENT_USERINFO_CHANGED:
        // called on user /cmd setinfo	if value changed
        // return not zero dont allow change
        // params like GAME_CLIENT_COMMAND, but argv(0) always "setinfo" and argc always 3

        self = PROG_TO_EDICT( g_globalvars.self );
        return ClientUserInfoChanged();

    case GAME_SHUTDOWN:
        return 0;

    case GAME_CONSOLE_COMMAND:

        // called on server console command "mod"
        // params like GAME_CLIENT_COMMAND, but argv(0) always "mod"
        // self - rconner if can detect else world
        // other
        //SV_CMD_CONSOLE		0
        //SV_CMD_RCON			1
        //SV_CMD_MASTER		2
        //SV_CMD_BOT			3
        self = PROG_TO_EDICT( g_globalvars.self );
        ModCommand();
        return 0;
    }

    return 0;
}
コード例 #7
0
ファイル: g_main.c プロジェクト: stayoutEE/qwprogs-qvm
/*
================
vmMain

This is the only way control passes into the module.
This must be the very first function compiled into the .q3vm file
================
*/
int vmMain( int command, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5,
	    int arg6, int arg7, int arg8, int arg9, int arg10, int arg11 )
{
	ClearGlobals();
	switch ( command )
	{
	case GAME_INIT:
		if ( trap_GetApiVersion() < GAME_API_VERSION )
			return 0;

		G_InitGame( arg0, arg1 );
		return ( int ) ( &gamedata );

	case GAME_LOADENTS:
		G_SpawnEntitiesFromString();
		return 1;

	case GAME_START_FRAME:
		StartFrame( arg0 );
		return 1;

	case GAME_CLIENT_CONNECT:
		self = PROG_TO_EDICT( g_globalvars.self );
		if ( arg0 )
			SpectatorConnect();
		else
			ClientConnect();
		return 1;

	case GAME_PUT_CLIENT_IN_SERVER:
		self = PROG_TO_EDICT( g_globalvars.self );
		if ( !arg0 )
			PutClientInServer();
		return 1;

	case GAME_CLIENT_DISCONNECT:
		self = PROG_TO_EDICT( g_globalvars.self );
		if ( arg0 )
			SpectatorDisconnect();
		else
			ClientDisconnect();
		return 1;

	case GAME_SETNEWPARMS:
		SetNewParms();
		return 1;

	case GAME_CLIENT_PRETHINK:
		self = PROG_TO_EDICT( g_globalvars.self );
		if ( !arg0 )
			PlayerPreThink();
		return 1;

	case GAME_CLIENT_POSTTHINK:
		self = PROG_TO_EDICT( g_globalvars.self );
		if ( !arg0 )
			PlayerPostThink();
		else
			SpectatorThink();
		return 1;

	case GAME_EDICT_TOUCH:
		G_EdictTouch();
		return 1;

	case GAME_EDICT_THINK:
		G_EdictThink();
		return 1;

	case GAME_EDICT_BLOCKED:
		G_EdictBlocked();
		return 1;

	case GAME_SETCHANGEPARMS:
		self = PROG_TO_EDICT( g_globalvars.self );
		SetChangeParms();
		return 1;

	case GAME_CLIENT_COMMAND:

		return ClientCommand();

/*	case GAME_SHUTDOWN:
		G_ShutdownGame( arg0 );
		return 0;
	case GAME_CLIENT_USERINFO_CHANGED:
		ClientUserinfoChanged( arg0 );
		return 0;
	case GAME_CONSOLE_COMMAND:
		return ConsoleCommand();*/
	}

	return 0;
}
コード例 #8
0
ファイル: Main.cpp プロジェクト: jbehjohn/TerrainViewer
int main(int argc, char *argv[])
{
	//Make sure the program waits for a quit
	bool running = true;
	bool step = false;
	bool quit = false;
	SDL_MouseMotionEvent mme;
	init();
	Render *pRender = Render::GetInstance();
	pRender->init_GL();

	// We grab the input so that we receive mouse movement
	// even when the mouse is beyond the edge of the screen
	SDL_ShowCursor(0);
	SDL_WM_GrabInput( SDL_GRAB_ON );

#if TWEAK_MENU
	TwInit(TW_OPENGL, NULL);
	TwWindowSize(SCREEN_W, SCREEN_H);
	myBar = TwNewBar("Tweak");
#endif // TWEAK_MENU

	// Initialize the FPS tracking variables
	Uint32 nextFPSCount = SDL_GetTicks() + 1000;
	int frames = 0;
	int prevTime = SDL_GetTicks();

	Simulation *pSimulation = Simulation::GetSimulation();
	pSimulation->Init();
	while( quit == false )
	{
		while( SDL_PollEvent( &event ) )
		{
#if TWEAK_MENU
			int handled = TwEventSDL(&event, SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
			if( handled )
				continue;
#endif // TWEAK_MENU
			switch( event.type )
			{
			case SDL_QUIT:
				quit = true;
				break;

			case SDL_MOUSEMOTION:
				mme = event.motion;
				pSimulation->UpdateMouseMotion( mme );
				break;

			case SDL_KEYDOWN:
				pSimulation->UpdateKeys(event.key.keysym.sym, true);
				switch( event.key.keysym.sym )
				{
				case SDLK_1:
					break;
				case SDLK_RIGHT:
					step = true;
					break;
				case SDLK_ESCAPE:
					quit=true;
					break;
				}
				break;
			case SDL_KEYUP:
				pSimulation->UpdateKeys(event.key.keysym.sym, false);
				switch( event.key.keysym.sym )
				{
				case SDLK_RIGHT:
					break;
				}
				break;
			}
		}

		if( running || step )
		{
			step = false;
			StartFrame();

			int newTime = SDL_GetTicks();
			float elapsed = (float)(newTime - prevTime) / 1000.0f;
			if( elapsed > 0.05f )
				elapsed = 0.05f;	// Clamp long dt's down
			if( elapsed < 0.001f)
				continue;			// dt too short. Skip to next frame (without updating prevTime so dt grows).
			prevTime = newTime;

			pSimulation->DrawFrame();				// Render all sprites

			const int subSteps = 1;
			for( int i=0; i<subSteps; i++ )
			{
				pSimulation->SimulateOneFrame(elapsed / subSteps);	// Logic update for Simulation
			}

#if TWEAK_MENU
			TwDraw();
#endif // TWEAK_MENU

			EndFrame();

			// Once per second, show the FPS
			frames++;
			if( SDL_GetTicks() >  nextFPSCount )
			{
				char buffer[256];
				sprintf_s(buffer, "FPS: %d", frames );
				SDL_WM_SetCaption( buffer, NULL );
				nextFPSCount = SDL_GetTicks() + 1000;
				frames = 0;
			}
		}
	}
	pSimulation->Shutdown();
	clean_up();
	return 0;
}