/** * @brief Reloads the glsl shaders */ void R_RestartPrograms_f (void) { if (r_programs->integer) { Com_Printf("glsl restart to a version of v%s\n", Cvar_Get("r_glsl_version", nullptr, 0, nullptr)->string); } else { Com_Printf("glsl shutdown\n"); } R_ShutdownPrograms(); R_InitPrograms(); R_InitFBObjects(); }
/* * @brief Shuts down the renderer, freeing all resources belonging to it, * including the GL context. */ void R_Shutdown(void) { Cmd_RemoveAll(CMD_RENDERER); R_ShutdownPrograms(); R_ShutdownContext(); R_ShutdownState(); Z_FreeTag(Z_TAG_RENDERER); }
/** * @sa R_Init */ void R_Shutdown (void) { const cmdList_t *commands; for (commands = r_commands; commands->name; commands++) Cmd_RemoveCommand(commands->name); R_ShutdownThreads(); R_ShutdownModels(true); R_ShutdownImages(); R_ShutdownPrograms(); R_FontShutdown(); R_ShutdownFBObjects(); /* shut down OS specific OpenGL stuff like contexts, etc. */ Rimp_Shutdown(); }
/** * @brief Re-initializes OpenGL state machine, all textures and renderer variables, this needed when application is put to background on Android. */ void R_ReinitOpenglContext (void) { /* De-allocate old GL state, these functinos will call glDeleteTexture(), so they should go before everything else */ R_FontCleanCache(); R_ShutdownFBObjects(); R_ShutdownPrograms(); R_BeginBuildingLightmaps(); /* This function will also call glDeleteTexture() */ /* Re-initialize GL state */ R_SetDefaultState(); R_InitPrograms(); /* Re-upload all textures */ R_InitMiscTexture(); R_ReloadImages(); /* Re-upload other GL stuff */ R_InitFBObjects(); R_UpdateDefaultMaterial("", "", "", NULL); /* Re-upload the battlescape terrain geometry */ if (!qglBindBuffer) return; for (int tile = 0; tile < r_numMapTiles; tile++) { model_t *mod = r_mapTiles[tile]; int vertind = 0, coordind = 0, tangind = 0; mBspSurface_t *surf = mod->bsp.surfaces; for (int i = 0; i < mod->bsp.numsurfaces; i++, surf++) { vertind += 3 * surf->numedges; coordind += 2 * surf->numedges; tangind += 4 * surf->numedges; } qglGenBuffers(1, &mod->bsp.vertex_buffer); qglBindBuffer(GL_ARRAY_BUFFER, mod->bsp.vertex_buffer); qglBufferData(GL_ARRAY_BUFFER, vertind * sizeof(GLfloat), mod->bsp.verts, GL_STATIC_DRAW); qglGenBuffers(1, &mod->bsp.texcoord_buffer); qglBindBuffer(GL_ARRAY_BUFFER, mod->bsp.texcoord_buffer); qglBufferData(GL_ARRAY_BUFFER, coordind * sizeof(GLfloat), mod->bsp.texcoords, GL_STATIC_DRAW); qglGenBuffers(1, &mod->bsp.lmtexcoord_buffer); qglBindBuffer(GL_ARRAY_BUFFER, mod->bsp.lmtexcoord_buffer); qglBufferData(GL_ARRAY_BUFFER, coordind * sizeof(GLfloat), mod->bsp.lmtexcoords, GL_STATIC_DRAW); qglGenBuffers(1, &mod->bsp.normal_buffer); qglBindBuffer(GL_ARRAY_BUFFER, mod->bsp.normal_buffer); qglBufferData(GL_ARRAY_BUFFER, vertind * sizeof(GLfloat), mod->bsp.normals, GL_STATIC_DRAW); qglGenBuffers(1, &mod->bsp.tangent_buffer); qglBindBuffer(GL_ARRAY_BUFFER, mod->bsp.tangent_buffer); qglBufferData(GL_ARRAY_BUFFER, tangind * sizeof(GLfloat), mod->bsp.tangents, GL_STATIC_DRAW); qglGenBuffers(1, &mod->bsp.index_buffer); qglBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mod->bsp.index_buffer); qglBufferData(GL_ELEMENT_ARRAY_BUFFER, mod->bsp.numIndexes * sizeof(GLushort), mod->bsp.indexes, GL_STATIC_DRAW); qglBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); for (int i = 0; i < mod->bsp.numsurfaces; i++) R_CreateSurfaceLightmap(&mod->bsp.surfaces[i]); } R_EndBuildingLightmaps(); qglBindBuffer(GL_ARRAY_BUFFER, 0); }