mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-11 07:12:16 +00:00
Moved WriteSavePic implementation to FGLRenderer
This commit is contained in:
parent
64ce4d5072
commit
469c9241eb
3 changed files with 50 additions and 50 deletions
|
@ -361,14 +361,58 @@ void FGLRenderer::RenderTextureView(FCanvasTexture *tex, AActor *Viewpoint, doub
|
||||||
tex->SetUpdated();
|
tex->SetUpdated();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
//
|
||||||
|
// Render the view to a savegame picture
|
||||||
|
//
|
||||||
|
//===========================================================================
|
||||||
|
|
||||||
void FGLRenderer::WriteSavePic (player_t *player, FileWriter *file, int width, int height)
|
void FGLRenderer::WriteSavePic (player_t *player, FileWriter *file, int width, int height)
|
||||||
{
|
{
|
||||||
// Todo: This needs to call the software renderer and process the returned image, if so desired.
|
IntRect bounds;
|
||||||
// This also needs to take out parts of the scene drawer so they can be shared between renderers.
|
bounds.left = 0;
|
||||||
|
bounds.top = 0;
|
||||||
|
bounds.width = width;
|
||||||
|
bounds.height = height;
|
||||||
|
|
||||||
|
// if GLRenderer->mVBO is persistently mapped we must be sure the GPU finished reading from it before we fill it with new data.
|
||||||
|
glFinish();
|
||||||
|
|
||||||
|
// Switch to render buffers dimensioned for the savepic
|
||||||
|
mBuffers = mSaveBuffers;
|
||||||
|
|
||||||
|
P_FindParticleSubsectors(); // make sure that all recently spawned particles have a valid subsector.
|
||||||
|
gl_RenderState.SetVertexBuffer(mVBO);
|
||||||
|
mVBO->Reset();
|
||||||
|
mLights->Clear();
|
||||||
|
|
||||||
|
// This shouldn't overwrite the global viewpoint even for a short time.
|
||||||
GLSceneDrawer drawer;
|
GLSceneDrawer drawer;
|
||||||
drawer.WriteSavePic(player, file, width, height);
|
FRenderViewpoint savevp;
|
||||||
|
sector_t *viewsector = drawer.RenderViewpoint(savevp, players[consoleplayer].camera, &bounds, r_viewpoint.FieldOfView.Degrees, 1.6f, 1.6f, true, false);
|
||||||
|
glDisable(GL_STENCIL_TEST);
|
||||||
|
gl_RenderState.SetSoftLightLevel(-1);
|
||||||
|
CopyToBackbuffer(&bounds, false);
|
||||||
|
|
||||||
|
// strictly speaking not needed as the glReadPixels should block until the scene is rendered, but this is to safeguard against shitty drivers
|
||||||
|
glFinish();
|
||||||
|
|
||||||
|
uint8_t * scr = (uint8_t *)M_Malloc(width * height * 3);
|
||||||
|
glReadPixels(0,0,width, height,GL_RGB,GL_UNSIGNED_BYTE,scr);
|
||||||
|
M_CreatePNG (file, scr + ((height-1) * width * 3), NULL, SS_RGB, width, height, -width * 3, Gamma);
|
||||||
|
M_Free(scr);
|
||||||
|
|
||||||
|
// Switch back the screen render buffers
|
||||||
|
screen->SetViewportRects(nullptr);
|
||||||
|
mBuffers = mScreenBuffers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//===========================================================================
|
||||||
|
|
||||||
void FGLRenderer::BeginFrame()
|
void FGLRenderer::BeginFrame()
|
||||||
{
|
{
|
||||||
buffersActive = GLRenderer->mScreenBuffers->Setup(screen->mScreenViewport.width, screen->mScreenViewport.height, screen->mSceneViewport.width, screen->mSceneViewport.height);
|
buffersActive = GLRenderer->mScreenBuffers->Setup(screen->mScreenViewport.width, screen->mScreenViewport.height, screen->mSceneViewport.width, screen->mSceneViewport.height);
|
||||||
|
|
|
@ -545,47 +545,3 @@ sector_t * GLSceneDrawer::RenderViewpoint (FRenderViewpoint &mainvp, AActor * ca
|
||||||
return mainvp.sector;
|
return mainvp.sector;
|
||||||
}
|
}
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
//
|
|
||||||
// Render the view to a savegame picture
|
|
||||||
//
|
|
||||||
//===========================================================================
|
|
||||||
|
|
||||||
void GLSceneDrawer::WriteSavePic (player_t *player, FileWriter *file, int width, int height)
|
|
||||||
{
|
|
||||||
IntRect bounds;
|
|
||||||
bounds.left = 0;
|
|
||||||
bounds.top = 0;
|
|
||||||
bounds.width = width;
|
|
||||||
bounds.height = height;
|
|
||||||
|
|
||||||
// if GLRenderer->mVBO is persistently mapped we must be sure the GPU finished reading from it before we fill it with new data.
|
|
||||||
glFinish();
|
|
||||||
|
|
||||||
// Switch to render buffers dimensioned for the savepic
|
|
||||||
GLRenderer->mBuffers = GLRenderer->mSaveBuffers;
|
|
||||||
|
|
||||||
P_FindParticleSubsectors(); // make sure that all recently spawned particles have a valid subsector.
|
|
||||||
gl_RenderState.SetVertexBuffer(GLRenderer->mVBO);
|
|
||||||
GLRenderer->mVBO->Reset();
|
|
||||||
GLRenderer->mLights->Clear();
|
|
||||||
|
|
||||||
// This shouldn't overwrite the global viewpoint even for a short time.
|
|
||||||
FRenderViewpoint savevp;
|
|
||||||
sector_t *viewsector = RenderViewpoint(savevp, players[consoleplayer].camera, &bounds, r_viewpoint.FieldOfView.Degrees, 1.6f, 1.6f, true, false);
|
|
||||||
glDisable(GL_STENCIL_TEST);
|
|
||||||
gl_RenderState.SetSoftLightLevel(-1);
|
|
||||||
GLRenderer->CopyToBackbuffer(&bounds, false);
|
|
||||||
|
|
||||||
// strictly speaking not needed as the glReadPixels should block until the scene is rendered, but this is to safeguard against shitty drivers
|
|
||||||
glFinish();
|
|
||||||
|
|
||||||
uint8_t * scr = (uint8_t *)M_Malloc(width * height * 3);
|
|
||||||
glReadPixels(0,0,width, height,GL_RGB,GL_UNSIGNED_BYTE,scr);
|
|
||||||
M_CreatePNG (file, scr + ((height-1) * width * 3), NULL, SS_RGB, width, height, -width * 3, Gamma);
|
|
||||||
M_Free(scr);
|
|
||||||
|
|
||||||
// Switch back the screen render buffers
|
|
||||||
screen->SetViewportRects(nullptr);
|
|
||||||
GLRenderer->mBuffers = GLRenderer->mScreenBuffers;
|
|
||||||
}
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ enum area_t : int
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Global functions. Make them members of GLRenderer later?
|
// Global functions.
|
||||||
bool hw_CheckClip(side_t * sidedef, sector_t * frontsector, sector_t * backsector);
|
bool hw_CheckClip(side_t * sidedef, sector_t * frontsector, sector_t * backsector);
|
||||||
sector_t * hw_FakeFlat(sector_t * sec, sector_t * dest, area_t in_area, bool back);
|
sector_t * hw_FakeFlat(sector_t * sec, sector_t * dest, area_t in_area, bool back);
|
||||||
area_t hw_CheckViewArea(vertex_t *v1, vertex_t *v2, sector_t *frontsector, sector_t *backsector);
|
area_t hw_CheckViewArea(vertex_t *v1, vertex_t *v2, sector_t *frontsector, sector_t *backsector);
|
||||||
|
|
Loading…
Reference in a new issue