static void SCR_TimeRefresh_f (void) { int i; int start, stop; float time; if (cls.state != ca_active) return; start = Sys_Milliseconds(); if (Cmd_Argc() == 2) { /* run without page flipping */ R_BeginFrame(); for (i = 0; i < 128; i++) { refdef.viewAngles[1] = i / 128.0 * 360.0; r_threadstate.state = THREAD_BSP; R_RenderFrame(); } R_EndFrame(); } else { for (i = 0; i < 128; i++) { refdef.viewAngles[1] = i / 128.0 * 360.0; R_BeginFrame(); r_threadstate.state = THREAD_BSP; R_RenderFrame(); R_EndFrame(); } } stop = Sys_Milliseconds(); time = (stop - start) / 1000.0; Com_Printf("%f seconds (%f fps)\n", time, 128 / time); }
void SCR_TimeRefresh_f(void) { int i; int start, stop; float time; if (cls.state != ca_active) { return; } start = Sys_Milliseconds(); if (Cmd_Argc() == 2) { /* run without page flipping */ int j; for (j = 0; j < 1000; j++) { R_BeginFrame(0); for (i = 0; i < 128; i++) { cl.refdef.viewangles[1] = i / 128.0f * 360.0f; R_RenderFrame(&cl.refdef); } GLimp_EndFrame(); } } else { for (i = 0; i < 128; i++) { cl.refdef.viewangles[1] = i / 128.0f * 360.0f; R_BeginFrame(0); R_RenderFrame(&cl.refdef); GLimp_EndFrame(); } } stop = Sys_Milliseconds(); time = (stop - start) / 1000.0f; Com_Printf("%f seconds (%f fps)\n", time, 128 / time); }
// For program optimization static void VQH_TimeRefresh_f() { int i; float start, stop, time; if ( cls.state != CA_ACTIVE ) { common->Printf( "Not connected to a server\n" ); return; } start = Sys_DoubleTime(); vec3_t viewangles; viewangles[ 0 ] = 0; viewangles[ 1 ] = 0; viewangles[ 2 ] = 0; for ( i = 0; i < 128; i++ ) { viewangles[ 1 ] = i / 128.0 * 360.0; AnglesToAxis( viewangles, cl.refdef.viewaxis ); R_BeginFrame( STEREO_CENTER ); VQH_RenderScene(); R_EndFrame( NULL, NULL ); } stop = Sys_DoubleTime(); time = stop - start; common->Printf( "%f seconds (%f fps)\n", time, 128 / time ); }
/* ================== V_PreRender ================== */ qboolean V_PreRender( void ) { // too early if( !glw_state.initialized ) return false; if( host.state == HOST_NOFOCUS ) return false; if( host.state == HOST_SLEEP ) return false; // if the screen is disabled (loading plaque is up) if( cls.disable_screen ) { if(( host.realtime - cls.disable_screen ) > cl_timeout->value ) { MsgDev( D_NOTE, "V_PreRender: loading plaque timed out.\n" ); cls.disable_screen = 0.0f; } return false; } R_BeginFrame( !cl.refdef.paused ); return true; }
/* ================ SCR_TimeRefresh_f timerefresh [noflip] ================ */ void SCR_TimeRefresh_f( void ) { int i; double start, stop; double time; if( cls.state != ca_active ) return; start = Sys_DoubleTime(); if( Cmd_Argc() == 2 ) { // run without page flipping R_BeginFrame( false ); for( i = 0; i < 128; i++ ) { cl.refdef.viewangles[1] = i / 128.0 * 360.0f; R_RenderFrame( &cl.refdef, true ); } R_EndFrame(); } else { for( i = 0; i < 128; i++ ) { cl.refdef.viewangles[1] = i / 128.0 * 360.0f; R_BeginFrame( true ); R_RenderFrame( &cl.refdef, true ); R_EndFrame(); } } stop = Sys_DoubleTime (); time = (stop - start); Msg( "%f seconds (%f fps)\n", time, 128 / time ); }
/** * @brief This is called every frame, and can also be called explicitly to flush text to the screen * @sa UI_Draw * @sa CL_ViewRender * @sa SCR_DrawConsole * @sa SCR_DrawCursor */ void SCR_UpdateScreen (void) { if (cls.waitingForStart) return; /* if the screen is disabled (loading plaque is up, or vid mode changing) * do nothing at all */ if (cls.disableScreen) { if (CL_Milliseconds() - cls.disableScreen > 120000 && refdef.ready) { cls.disableScreen = 0; Com_Printf("Loading plaque timed out.\n"); return; } } /* not initialized yet */ if (!screenInitialized) return; R_BeginFrame(); /* draw scene, if it is need */ CL_ViewRender(); /* draw the ui on top of the render view */ UI_Draw(); SCR_DrawConsole(); if (cl_fps->integer) SCR_DrawString(viddef.context.width - 20 - con_fontWidth * 10, 0, va("fps: %3.1f", cls.framerate)); if (scr_rspeed->integer) { if (CL_OnBattlescape()) SCR_DrawString(viddef.context.width - 20 - con_fontWidth * 30, 80, va("brushes: %6i alias: %6i\n", refdef.brushCount, refdef.aliasCount)); else SCR_DrawString(viddef.context.width - 20 - con_fontWidth * 30, 80, va("alias: %6i\n", refdef.aliasCount)); SCR_DrawString(viddef.context.width - 20 - con_fontWidth * 30, 80 + con_fontHeight, va("batches: %6i\n", refdef.batchCount)); if (r_programs->integer) { SCR_DrawString(viddef.context.width - 20 - con_fontWidth * 30, 80 + con_fontHeight * 2, va("FFP->shader switches: %6i\n", refdef.FFPToShaderCount)); SCR_DrawString(viddef.context.width - 20 - con_fontWidth * 30, 80 + con_fontHeight * 3, va("shader->shader switches: %6i\n", refdef.shaderToShaderCount)); SCR_DrawString(viddef.context.width - 20 - con_fontWidth * 30, 80 + con_fontHeight * 4, va("shader->FFP switches: %6i\n", refdef.shaderToFFPCount)); } } SCR_DrawCursor(); R_EndFrame(); }
/** * @brief Precache and loading screen at startup * @sa CL_InitAfter * @param[in] string Draw the loading string - if the scripts are not parsed, this is * not possible, so use qfalse for very early calls */ void SCR_DrawLoadingScreen (qboolean string, int percent) { const image_t *image; R_BeginFrame(); image = R_FindImage("pics/background/loading", it_pic); if (image) R_DrawImage(viddef.virtualWidth / 2 - image->width / 2, viddef.virtualHeight / 2 - image->height / 2, image); if (string) { /* Not used with gettext because it would make removing it too easy. */ UI_DrawString("f_menubig", ALIGN_UC, (int)(viddef.virtualWidth / 2), 30, 0, viddef.virtualWidth, 50, "Download this game for free at http://ufoai.sf.net", 0, 0, NULL, qfalse, 0); } SCR_DrawLoadingBar((int)(viddef.virtualWidth / 2) - 300, viddef.virtualHeight - 30, 600, 20, percent); R_EndFrame(); }
/* * @brief This is called every frame, and can also be called explicitly to flush * text to the screen. */ void Cl_UpdateScreen(void) { R_BeginFrame(); if (cls.state == CL_ACTIVE && !cls.loading) { Cl_UpdateView(); R_Setup3D(); R_DrawView(); R_Setup2D(); if (cls.key_state.dest != KEY_CONSOLE && cls.key_state.dest != KEY_UI) { Cl_DrawNetGraph(); Cl_DrawCounters(); Cl_DrawNotify(); Cl_DrawRendererStats(); Cl_DrawSoundStats(); cls.cgame->DrawFrame(&cl.frame); } } else { R_Setup2D(); } Cl_DrawConsole(); R_Draw2D(); // draw all 2D geometry for the frame Ui_Draw(); Cl_DrawCursor(); R_EndFrame(); }
/** * @brief Draws the current loading pic of the map from base/pics/maps/loading * @sa SCR_DrawLoadingBar */ void SCR_DrawLoading (int percent, const char *loadingMessages) { const image_t* loadingPic; const vec4_t color = {0.0, 0.7, 0.0, 0.8}; char *mapmsg; if (cls.downloadName[0]) { SCR_DrawDownloading(); return; } loadingPic = SCR_SetLoadingBackground(CL_GetConfigString(CS_MAPTITLE)); R_BeginFrame(); /* center loading screen */ R_DrawImage(viddef.virtualWidth / 2 - loadingPic->width / 2, viddef.virtualHeight / 2 - loadingPic->height / 2, loadingPic); R_Color(color); if (CL_GetConfigString(CS_TILES)[0] != '\0') { mapmsg = va(_("Loading Map [%s]"), _(CL_GetConfigString(CS_MAPTITLE))); UI_DrawString("f_menubig", ALIGN_UC, (int)(viddef.virtualWidth / 2), (int)(viddef.virtualHeight / 2 - 60), (int)(viddef.virtualWidth / 2), viddef.virtualWidth, 50, mapmsg, 1, 0, NULL, qfalse, 0); } UI_DrawString("f_menu", ALIGN_UC, (int)(viddef.virtualWidth / 2), (int)(viddef.virtualHeight / 2), (int)(viddef.virtualWidth / 2), viddef.virtualWidth, 50, loadingMessages, 1, 0, NULL, qfalse, 0); SCR_DrawLoadingBar((int)(viddef.virtualWidth / 2) - 300, viddef.virtualHeight - 30, 600, 20, percent); R_EndFrame(); }
/* ================== SCR_UpdateScreen This is called every frame, and can also be called explicitly to flush text to the screen. ================== */ void SCR_UpdateScreen( void ) { static dynvar_t *updatescreen = NULL; int numframes; int i; float separation[2]; if( !updatescreen ) updatescreen = Dynvar_Create( "updatescreen", qfalse, DYNVAR_WRITEONLY, DYNVAR_READONLY ); // if the screen is disabled (loading plaque is up, or vid mode changing) // do nothing at all if( cls.disable_screen ) { if( Sys_Milliseconds() - cls.disable_screen > 120000 ) { cls.disable_screen = 0; Com_Printf( "Loading plaque timed out.\n" ); } return; } if( !scr_initialized || !con_initialized || !cls.mediaInitialized ) return; // not initialized yet /* ** range check cl_camera_separation so we don't inadvertently fry someone's ** brain */ if( cl_stereo_separation->value > 1.0 ) Cvar_SetValue( "cl_stereo_separation", 1.0 ); else if( cl_stereo_separation->value < 0 ) Cvar_SetValue( "cl_stereo_separation", 0.0 ); if( cl_stereo->integer ) { numframes = 2; separation[0] = -cl_stereo_separation->value / 2; separation[1] = cl_stereo_separation->value / 2; } else { separation[0] = 0; separation[1] = 0; numframes = 1; } for( i = 0; i < numframes; i++ ) { R_BeginFrame( separation[i], scr_forceclear->integer ? qtrue : qfalse ); if( scr_draw_loading == 2 ) { // loading plaque over black screen scr_draw_loading = 0; CL_UIModule_DrawConnectScreen( qtrue ); } // if a cinematic is supposed to be running, handle menus // and console specially else if( SCR_GetCinematicTime() > 0 ) { SCR_DrawCinematic(); } else if( cls.state == CA_DISCONNECTED ) { CL_UIModule_Refresh( qtrue ); SCR_DrawConsole(); } else if( cls.state == CA_CONNECTING || cls.state == CA_CONNECTED || cls.state == CA_HANDSHAKE ) { CL_UIModule_DrawConnectScreen( qtrue ); } else if( cls.state == CA_LOADING ) { SCR_RenderView( separation[i] ); CL_UIModule_DrawConnectScreen( qfalse ); } else if( cls.state == CA_ACTIVE ) { SCR_RenderView( separation[i] ); CL_UIModule_Refresh( qfalse ); if( scr_timegraph->integer ) SCR_DebugGraph( cls.frametime*300, 1, 1, 1 ); if( scr_debuggraph->integer || scr_timegraph->integer || scr_netgraph->integer ) SCR_DrawDebugGraph(); SCR_DrawConsole(); } // wsw : aiwa : call any listeners so they can draw their stuff Dynvar_CallListeners( updatescreen, NULL ); R_EndFrame(); } }
/* * SCR_UpdateScreen * * This is called every frame, and can also be called explicitly to flush * text to the screen. */ void SCR_UpdateScreen( void ) { static dynvar_t *updatescreen = NULL; int numframes; int i; float separation[2]; qboolean scr_cinematic; if( !updatescreen ) updatescreen = Dynvar_Create( "updatescreen", qfalse, DYNVAR_WRITEONLY, DYNVAR_READONLY ); // if the screen is disabled (loading plaque is up, or vid mode changing) // do nothing at all if( cls.disable_screen ) { if( Sys_Milliseconds() - cls.disable_screen > 120000 ) { cls.disable_screen = 0; Com_Printf( "Loading plaque timed out.\n" ); } return; } if( !scr_initialized || !con_initialized || !cls.mediaInitialized ) return; // not initialized yet Con_CheckResize(); /* ** range check cl_camera_separation so we don't inadvertently fry someone's ** brain */ if( cl_stereo_separation->value > 1.0 ) Cvar_SetValue( "cl_stereo_separation", 1.0 ); else if( cl_stereo_separation->value < 0 ) Cvar_SetValue( "cl_stereo_separation", 0.0 ); if( cl_stereo->integer ) { numframes = 2; separation[0] = -cl_stereo_separation->value / 2; separation[1] = cl_stereo_separation->value / 2; } else { separation[0] = 0; separation[1] = 0; numframes = 1; } // avoid redrawing fullscreen cinematics unless damaged by console drawing scr_cinematic = cls.state == CA_CINEMATIC ? qtrue : qfalse; // if( scr_cinematic && !cl.cin.redraw && !scr_con_current && !scr_con_previous ) { // return; // } if( cls.cgameActive && cls.state < CA_LOADING ) { // this is when we've finished loading cgame media and are waiting // for the first valid snapshot to arrive. keep the loading screen untouched return; } for( i = 0; i < numframes; i++ ) { R_BeginFrame( separation[i], scr_cinematic || scr_forceclear->integer ? qtrue : qfalse ); if( scr_draw_loading == 2 ) { // loading plaque over black screen scr_draw_loading = 0; CL_UIModule_UpdateConnectScreen( qtrue ); } // if a cinematic is supposed to be running, handle menus // and console specially else if( scr_cinematic ) { SCR_DrawCinematic(); SCR_DrawConsole(); } else if( cls.state == CA_DISCONNECTED ) { CL_UIModule_Refresh( qtrue, qtrue ); SCR_DrawConsole(); } else if( cls.state == CA_GETTING_TICKET || cls.state == CA_CONNECTING || cls.state == CA_CONNECTED || cls.state == CA_HANDSHAKE ) { CL_UIModule_UpdateConnectScreen( qtrue ); } else if( cls.state == CA_LOADING ) { SCR_RenderView( separation[i] ); CL_UIModule_UpdateConnectScreen( qfalse ); } else if( cls.state == CA_ACTIVE ) { SCR_RenderView( separation[i] ); CL_UIModule_Refresh( qfalse, qtrue ); if( scr_timegraph->integer ) SCR_DebugGraph( cls.frametime*300, 1, 1, 1 ); if( scr_debuggraph->integer || scr_timegraph->integer || scr_netgraph->integer ) SCR_DrawDebugGraph(); SCR_DrawConsole(); } // wsw : aiwa : call any listeners so they can draw their stuff Dynvar_CallListeners( updatescreen, NULL ); R_EndFrame(); } }
void __cdecl R_GenerateReflectionRawData(DiskGfxReflectionProbe* probeRawData) { if (!*g_ffDir) { sprintf_s(g_ffDir, "%s/%s/", Dvar_GetString("fs_basepath"), Dvar_GetString("fs_game")); } refdef_s refdef; char* ptr = *((char**)0x02FF5354); refdef_s* refsrc = (refdef_s*)(ptr + 0x8C100); memcpy(&refdef, refsrc, sizeof(refdef_s)); refdef.vieworg[1] = probeRawData->origin[0]; refdef.vieworg[2] = probeRawData->origin[1]; refdef.yaw = probeRawData->origin[2]; R_InitPrimaryLights(refdef.primaryLights[0].dir); for (int cubemapShot = 1; cubemapShot < 7; cubemapShot++) { R_BeginCubemapShot(256, 0); R_BeginFrame(); GfxCmdArray* s_cmdList = *(GfxCmdArray**)0x03B370C0; GfxBackEndData* frontEndDataOut = *(GfxBackEndData**)0x03B3708C; frontEndDataOut->cmds = &s_cmdList->cmds[s_cmdList->usedTotal]; frontEndDataOut->viewInfo[frontEndDataOut->viewInfoCount].cmds = NULL; R_ClearScene(0); FX_BeginUpdate(0); R_CalcCubeMapViewValues(&refdef, cubemapShot, 256); float* vec = (float*)0x3AC3060; vec[0] = refdef.vieworg[0]; vec[1] = refdef.vieworg[1]; vec[2] = refdef.vieworg[2]; int* unk1 = (int*)0x3AC3058; *unk1 = refdef.time; float* unk2 = (float*)0x3AC305C; *unk2 = refdef.time * 0.001f; R_UpdateFrameFog(refdef.localClientNum); R_UpdateFrameSun(); float zFar = R_GetFarPlaneDist(); FxCameraUpdate fxUpdateCmd; memset(&fxUpdateCmd, 0, sizeof(FxCameraUpdate)); FxCmd cmd; memset(&cmd, 0, sizeof(FxCmd)); FX_GetCameraUpdateFromRefdefAndZFar(&fxUpdateCmd, &refdef, zFar); FX_SetNextUpdateCamera(0, &fxUpdateCmd); FX_FillUpdateCmd(0, &cmd); Sys_ResetUpdateSpotLightEffectEvent(); Sys_AddWorkerCmdInternal((void*)0x00BA5420, &cmd, 0); Sys_ResetUpdateNonDependentEffectsEvent(); Sys_AddWorkerCmdInternal((void*)0x00BA52E0, &cmd, 0); Sys_AddWorkerCmdInternal((void*)0x00BA5300, &cmd, 0); Sys_AddWorkerCmdInternal((void*)0x00BA5330, &cmd, 0); R_RenderScene(&refdef, 0); R_EndFrame(); R_IssueRenderCommands(3); R_EndCubemapShot(cubemapShot); } R_CreateReflectionRawDataFromCubemapShot(probeRawData); }