mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-28 12:30:46 +00:00
- made savepic work with new renderer.
This commit is contained in:
parent
98a9963bb5
commit
b8f9bdb7c1
3 changed files with 52 additions and 18 deletions
|
@ -60,7 +60,6 @@ static VRMode vrmi_checker = { 2, isqrt2, isqrt2, 1.f,{ { -.5f, 1.f },{ .5f, 1.f
|
||||||
|
|
||||||
const VRMode *VRMode::GetVRMode(bool toscreen)
|
const VRMode *VRMode::GetVRMode(bool toscreen)
|
||||||
{
|
{
|
||||||
#ifdef VR3D_ENABLED
|
|
||||||
int mode = !toscreen || (sysCallbacks.DisableTextureFilter && sysCallbacks.DisableTextureFilter()) ? 0 : vr_mode;
|
int mode = !toscreen || (sysCallbacks.DisableTextureFilter && sysCallbacks.DisableTextureFilter()) ? 0 : vr_mode;
|
||||||
|
|
||||||
switch (mode)
|
switch (mode)
|
||||||
|
@ -96,9 +95,6 @@ const VRMode *VRMode::GetVRMode(bool toscreen)
|
||||||
case VR_CHECKERINTERLEAVED:
|
case VR_CHECKERINTERLEAVED:
|
||||||
return &vrmi_checker;
|
return &vrmi_checker;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
return &vrmi_mono;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VRMode::AdjustViewport(DFrameBuffer *screen) const
|
void VRMode::AdjustViewport(DFrameBuffer *screen) const
|
||||||
|
|
|
@ -50,6 +50,7 @@
|
||||||
#include "gamecvars.h"
|
#include "gamecvars.h"
|
||||||
#include "render.h"
|
#include "render.h"
|
||||||
#include "gamestruct.h"
|
#include "gamestruct.h"
|
||||||
|
#include "gamehud.h"
|
||||||
|
|
||||||
EXTERN_CVAR(Bool, cl_capfps)
|
EXTERN_CVAR(Bool, cl_capfps)
|
||||||
|
|
||||||
|
@ -198,7 +199,7 @@ FRenderViewpoint SetupViewpoint(spritetype* cam, const vec3_t& position, int sec
|
||||||
|
|
||||||
void DoWriteSavePic(FileWriter* file, uint8_t* scr, int width, int height, bool upsidedown)
|
void DoWriteSavePic(FileWriter* file, uint8_t* scr, int width, int height, bool upsidedown)
|
||||||
{
|
{
|
||||||
int pixelsize = 1;
|
int pixelsize = 3;
|
||||||
|
|
||||||
int pitch = width * pixelsize;
|
int pitch = width * pixelsize;
|
||||||
if (upsidedown)
|
if (upsidedown)
|
||||||
|
@ -214,10 +215,44 @@ void DoWriteSavePic(FileWriter* file, uint8_t* scr, int width, int height, bool
|
||||||
//
|
//
|
||||||
// Render the view to a savegame picture
|
// Render the view to a savegame picture
|
||||||
//
|
//
|
||||||
|
// Currently a bit messy because the game side still needs to be able to
|
||||||
|
// handle Polymost.
|
||||||
|
//
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
bool writingsavepic;
|
||||||
|
FileWriter* savefile;
|
||||||
|
int savewidth, saveheight;
|
||||||
|
void PM_WriteSavePic(FileWriter* file, int width, int height);
|
||||||
|
EXTERN_CVAR(Bool, testnewrenderer);
|
||||||
|
|
||||||
#if 0
|
void WriteSavePic(FileWriter* file, int width, int height)
|
||||||
void WriteSavePic(player_t* player, FileWriter* file, int width, int height)
|
{
|
||||||
|
if (!testnewrenderer)
|
||||||
|
{
|
||||||
|
PM_WriteSavePic(file, width, height);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int oldx = xdim;
|
||||||
|
int oldy = ydim;
|
||||||
|
auto oldwindowxy1 = windowxy1;
|
||||||
|
auto oldwindowxy2 = windowxy2;
|
||||||
|
|
||||||
|
xdim = width;
|
||||||
|
ydim = height;
|
||||||
|
videoSetViewableArea(0, 0, width - 1, height - 1);
|
||||||
|
|
||||||
|
writingsavepic = true;
|
||||||
|
savefile = file;
|
||||||
|
savewidth = width;
|
||||||
|
saveheight = height;
|
||||||
|
bool didit = gi->GenerateSavePic();
|
||||||
|
writingsavepic = false;
|
||||||
|
xdim = oldx;
|
||||||
|
ydim = oldy;
|
||||||
|
videoSetViewableArea(oldwindowxy1.x, oldwindowxy1.y, oldwindowxy2.x, oldwindowxy2.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RenderToSavePic(FRenderViewpoint& vp, FileWriter* file, int width, int height)
|
||||||
{
|
{
|
||||||
IntRect bounds;
|
IntRect bounds;
|
||||||
bounds.left = 0;
|
bounds.left = 0;
|
||||||
|
@ -233,30 +268,27 @@ void WriteSavePic(player_t* player, FileWriter* file, int width, int height)
|
||||||
screen->SetSaveBuffers(true);
|
screen->SetSaveBuffers(true);
|
||||||
screen->ImageTransitionScene(true);
|
screen->ImageTransitionScene(true);
|
||||||
|
|
||||||
hw_ClearFakeFlat();
|
|
||||||
RenderState.SetVertexBuffer(screen->mVertexData);
|
RenderState.SetVertexBuffer(screen->mVertexData);
|
||||||
screen->mVertexData->Reset();
|
screen->mVertexData->Reset();
|
||||||
screen->mLights->Clear();
|
screen->mLights->Clear();
|
||||||
screen->mViewpoints->Clear();
|
screen->mViewpoints->Clear();
|
||||||
|
|
||||||
// This shouldn't overwrite the global viewpoint even for a short time.
|
twodpsp.Clear();
|
||||||
FRenderViewpoint savevp;
|
|
||||||
sector_t* viewsector = RenderViewpoint(savevp, players[consoleplayer].camera, &bounds, r_viewpoint.FieldOfView.Degrees, 1.6f, 1.6f, true, false);
|
RenderViewpoint(vp, &bounds, vp.FieldOfView.Degrees, 1.333f, 1.333f, true, false);
|
||||||
RenderState.EnableStencil(false);
|
|
||||||
RenderState.SetNoSoftLightLevel();
|
|
||||||
|
|
||||||
int numpixels = width * height;
|
int numpixels = width * height;
|
||||||
uint8_t* scr = (uint8_t*)M_Malloc(numpixels * 3);
|
uint8_t* scr = (uint8_t*)M_Malloc(numpixels * 3);
|
||||||
screen->CopyScreenToBuffer(width, height, scr);
|
screen->CopyScreenToBuffer(width, height, scr);
|
||||||
|
|
||||||
DoWriteSavePic(file, SS_RGB, scr, width, height, viewsector, screen->FlipSavePic());
|
DoWriteSavePic(file, scr, width, height, screen->FlipSavePic());
|
||||||
M_Free(scr);
|
M_Free(scr);
|
||||||
|
|
||||||
// Switch back the screen render buffers
|
// Switch back the screen render buffers
|
||||||
screen->SetViewportRects(nullptr);
|
screen->SetViewportRects(nullptr);
|
||||||
screen->SetSaveBuffers(false);
|
screen->SetSaveBuffers(false);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
|
@ -301,6 +333,12 @@ void render_drawrooms(spritetype* playersprite, const vec3_t& position, int sect
|
||||||
screen->mViewpoints->Clear();
|
screen->mViewpoints->Clear();
|
||||||
screen->mVertexData->Reset();
|
screen->mVertexData->Reset();
|
||||||
|
|
||||||
|
if (writingsavepic) // hack alert! The save code should not go through render_drawrooms, but we can only clean up the game side when Polymost is gone for good.
|
||||||
|
{
|
||||||
|
RenderToSavePic(r_viewpoint, savefile, savewidth, saveheight);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Shader start time does not need to be handled per level. Just use the one from the camera to render from.
|
// Shader start time does not need to be handled per level. Just use the one from the camera to render from.
|
||||||
auto RenderState = screen->RenderState();
|
auto RenderState = screen->RenderState();
|
||||||
CheckTimer(*RenderState, 0/*ShaderStartTime*/);
|
CheckTimer(*RenderState, 0/*ShaderStartTime*/);
|
||||||
|
|
|
@ -268,7 +268,7 @@ bool PolymostRenderState::Apply(FRenderState& state, GLState& oldState)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DoWriteSavePic(FileWriter* file, ESSType ssformat, uint8_t* scr, int width, int height, bool upsidedown)
|
static void PM_DoWriteSavePic(FileWriter* file, ESSType ssformat, uint8_t* scr, int width, int height, bool upsidedown)
|
||||||
{
|
{
|
||||||
int pixelsize = 3;
|
int pixelsize = 3;
|
||||||
int pitch = width * pixelsize;
|
int pitch = width * pixelsize;
|
||||||
|
@ -287,7 +287,7 @@ void DoWriteSavePic(FileWriter* file, ESSType ssformat, uint8_t* scr, int width,
|
||||||
//
|
//
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
|
||||||
void WriteSavePic(FileWriter* file, int width, int height)
|
void PM_WriteSavePic(FileWriter* file, int width, int height)
|
||||||
{
|
{
|
||||||
IntRect bounds;
|
IntRect bounds;
|
||||||
bounds.left = 0;
|
bounds.left = 0;
|
||||||
|
@ -344,7 +344,7 @@ void WriteSavePic(FileWriter* file, int width, int height)
|
||||||
uint8_t* scr = (uint8_t*)M_Malloc(numpixels * 3);
|
uint8_t* scr = (uint8_t*)M_Malloc(numpixels * 3);
|
||||||
screen->CopyScreenToBuffer(width, height, scr);
|
screen->CopyScreenToBuffer(width, height, scr);
|
||||||
|
|
||||||
DoWriteSavePic(file, SS_RGB, scr, width, height, screen->FlipSavePic());
|
PM_DoWriteSavePic(file, SS_RGB, scr, width, height, screen->FlipSavePic());
|
||||||
M_Free(scr);
|
M_Free(scr);
|
||||||
|
|
||||||
// Switch back the screen render buffers
|
// Switch back the screen render buffers
|
||||||
|
|
Loading…
Reference in a new issue