ref: dx2: Move functions around

This commit is contained in:
lewa_j
2026-01-14 01:44:00 +03:00
parent a3c26affa3
commit 6a02b77163

View File

@@ -1,7 +1,7 @@
/*
r_context.c -- dx2 renderer context
Copyright (C) 2023-2024 a1batross
Copyright (C) 2025 lewa_j
Copyright (C) 2025-2026 lewa_j
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -51,16 +51,6 @@ static void R_SimpleStubBool( qboolean unused )
;
}
void R_AllowFog(qboolean allowed)
{
}
void GL_SetRenderMode(int mode)
{
dxc.renderMode = mode;
}
static const char *R_GetConfigName( void )
{
return "ref_dx2";
@@ -92,17 +82,104 @@ static qboolean R_SetDisplayTransform( ref_screen_rotation_t rotate, int offset_
return ret;
}
static void R_ClearScene(void)
{
tr.draw_list->num_solid_entities = 0;
tr.draw_list->num_trans_entities = 0;
tr.draw_list->num_beam_entities = 0;
// clear the scene befor start new frame
if (gEngfuncs.drawFuncs->R_ClearScene != NULL)
gEngfuncs.drawFuncs->R_ClearScene();
void R_BeginFrame( qboolean clearScene )
{
gEngfuncs.CL_ExtraUpdate();
}
static void R_RenderScene( void )
{
model_t *worldmodel = gp_cl->models[1];
if (!worldmodel && RI.drawWorld)
gEngfuncs.Host_Error("%s: NULL worldmodel\n", __func__);
// frametime is valid only for normal pass
if (FBitSet(RI.params, RP_ENVVIEW) == 0)
tr.frametime = gp_cl->time - gp_cl->oldtime;
else tr.frametime = 0.0;
// begin a new frame
tr.framecount++;
#if 0
R_PushDlights();
R_SetupFrustum();
R_SetupFrame();
R_SetupGL(true);
R_Clear(~0);
R_MarkLeaves();
R_DrawFog();
if (RI.drawWorld)
R_AnimateRipples();
R_CheckGLFog();
R_DrawWorld();
R_CheckFog();
gEngfuncs.CL_ExtraUpdate(); // don't let sound get messed up if going slow
R_DrawEntitiesOnList();
R_DrawWaterSurfaces();
#endif
}
void R_EndFrame( void )
{
//swap
if (!dxc.window)
return;
if (dxc.pddsBack)
{
RECT dstRect = {};
POINT point = { 0,0 };
ClientToScreen(dxc.window, &point);
GetClientRect(dxc.window, &dstRect);
OffsetRect(&dstRect, point.x, point.y);
RECT srcRect = { 0,0,dxc.windowWidth,dxc.windowHeight };
DXCheck(IDirectDrawSurface_Blt(dxc.pddsPrimary, &dstRect, dxc.pddsBack, &srcRect, DDBLT_WAIT, NULL));
}
//resize
RECT rect = {};
GetClientRect(dxc.window, &rect);
int w = rect.right - rect.left;
int h = rect.bottom - rect.top;
if (w != dxc.windowWidth || h != dxc.windowHeight)
{
D3D_Resize(w, h);
}
}
void GL_BackendStartFrame( void )
{
}
void GL_BackendEndFrame( void )
{
}
void R_AllowFog( qboolean allowed )
{
}
void GL_SetRenderMode( int mode )
{
dxc.renderMode = mode;
}
static qboolean R_AddEntity( struct cl_entity_s *clent, int type )
{
return true;
@@ -617,51 +694,6 @@ static struct mstudiotex_s *StudioGetTexture( struct cl_entity_s *e )
return NULL;
}
void R_BeginFrame(qboolean clearScene)
{
gEngfuncs.CL_ExtraUpdate();
}
void R_EndFrame(void)
{
//swap
if (!dxc.window)
return;
if( dxc.pddsBack )
{
RECT dstRect = {};
POINT point = { 0, 0 };
ClientToScreen( dxc.window, &point );
GetClientRect( dxc.window, &dstRect );
OffsetRect( &dstRect, point.x, point.y );
RECT srcRect = { 0, 0, dxc.windowWidth, dxc.windowHeight };
DXCheck( IDirectDrawSurface_Blt( dxc.pddsPrimary, &dstRect, dxc.pddsBack, &srcRect, DDBLT_WAIT, NULL ) );
}
//resize
RECT rect = {};
GetClientRect(dxc.window, &rect);
int w = rect.right - rect.left;
int h = rect.bottom - rect.top;
if (w != dxc.windowWidth || h != dxc.windowHeight)
{
D3D_Resize(w, h);
}
}
void GL_BackendStartFrame(void)
{
}
void GL_BackendEndFrame(void)
{
}
static void R_SetupRefParams( const ref_viewpass_t *rvp )
{
@@ -689,45 +721,6 @@ static void R_SetupRefParams(const ref_viewpass_t *rvp)
VectorCopy(rvp->vieworigin, RI.pvsorigin);
}
static void R_RenderScene(void)
{
model_t *worldmodel = gp_cl->models[1];
if (!worldmodel && RI.drawWorld)
gEngfuncs.Host_Error("%s: NULL worldmodel\n", __func__);
// frametime is valid only for normal pass
if (FBitSet(RI.params, RP_ENVVIEW) == 0)
tr.frametime = gp_cl->time - gp_cl->oldtime;
else tr.frametime = 0.0;
// begin a new frame
tr.framecount++;
#if 0
R_PushDlights();
R_SetupFrustum();
R_SetupFrame();
R_SetupGL(true);
R_Clear(~0);
R_MarkLeaves();
R_DrawFog();
if (RI.drawWorld)
R_AnimateRipples();
R_CheckGLFog();
R_DrawWorld();
R_CheckFog();
gEngfuncs.CL_ExtraUpdate(); // don't let sound get messed up if going slow
R_DrawEntitiesOnList();
R_DrawWaterSurfaces();
#endif
}
static void R_RenderFrame( const struct ref_viewpass_s *rvp )
{
if (r_norefresh->value)
@@ -780,6 +773,17 @@ static void R_NewMap(void)
gEngfuncs.drawFuncs->R_NewMap();
}
static void R_ClearScene( void )
{
tr.draw_list->num_solid_entities = 0;
tr.draw_list->num_trans_entities = 0;
tr.draw_list->num_beam_entities = 0;
// clear the scene befor start new frame
if (gEngfuncs.drawFuncs->R_ClearScene != NULL)
gEngfuncs.drawFuncs->R_ClearScene();
}
static void *R_GetProcAddress( const char *name )
{
return NULL;