Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make more info available to cgame in glconfig #1161

Merged
merged 2 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 4 additions & 20 deletions src/engine/renderer/tr_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

glstate_t glState;

float displayAspect = 0.0f;

static void GfxInfo_f();

cvar_t *r_glMajorVersion;
Expand Down Expand Up @@ -922,24 +920,10 @@ ScreenshotCmd screenshotPNGRegistration("screenshotPNG", ssFormat_t::SSF_PNG, "p

Log::Notice("PIXELFORMAT: color(%d-bits)", glConfig.colorBits );

{
std::string out;
if ( glConfig.displayFrequency )
{
out = Str::Format("%d", glConfig.displayFrequency );
}
else
{
out = "N/A";
}

Log::Notice("MODE: %d, %d x %d %s hz: %s",
r_mode->integer,
glConfig.vidWidth, glConfig.vidHeight,
fsstrings[ +r_fullscreen.Get() ],
out
);
}
Log::Notice("MODE: %d, %d x %d %s",
r_mode->integer,
glConfig.vidWidth, glConfig.vidHeight,
fsstrings[ +r_fullscreen.Get() ] );

if ( !!r_glExtendedValidation->integer )
{
Expand Down
2 changes: 0 additions & 2 deletions src/engine/renderer/tr_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -2796,8 +2796,6 @@ enum class realtimeLightingRenderer_t { LEGACY, TILED };

extern glstate_t glState; // outside of TR since it shouldn't be cleared during ref re-init

extern float displayAspect; // FIXME

//
// cvars
//
Expand Down
10 changes: 4 additions & 6 deletions src/engine/renderer/tr_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -351,13 +351,11 @@ struct glconfig_t
glHardwareType_t hardwareType;

textureCompression_t textureCompression;
bool8_t textureEnvAddAvailable;
bool8_t anisotropicAvailable; //----(SA) added
float maxAnisotropy; //----(SA) added

int vidWidth, vidHeight;

int displayFrequency;
int displayIndex;
float displayAspect;
int displayWidth, displayHeight; // the entire monitor (the one indicated by displayIndex)
int vidWidth, vidHeight; // what the game is using

bool8_t smpActive; // dual processor
};
Expand Down
15 changes: 9 additions & 6 deletions src/engine/sys/sdl_glimp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -567,8 +567,8 @@ static int GLimp_CompareModes( const void *a, const void *b )
float aspectB = ( float ) modeB->w / ( float ) modeB->h;
int areaA = modeA->w * modeA->h;
int areaB = modeB->w * modeB->h;
float aspectDiffA = fabsf( aspectA - displayAspect );
float aspectDiffB = fabsf( aspectB - displayAspect );
float aspectDiffA = fabsf( aspectA - glConfig.displayAspect );
float aspectDiffB = fabsf( aspectB - glConfig.displayAspect );
float aspectDiffsDiff = aspectDiffA - aspectDiffB;

if ( aspectDiffsDiff > ASPECT_EPSILON )
Expand Down Expand Up @@ -960,16 +960,18 @@ static rserr_t GLimp_SetModeAndResolution( const int mode )

if ( SDL_GetDesktopDisplayMode( r_displayIndex->integer, &desktopMode ) == 0 )
{
displayAspect = ( float ) desktopMode.w / ( float ) desktopMode.h;
glConfig.displayAspect = ( float ) desktopMode.w / ( float ) desktopMode.h;
logger.Notice( "Display aspect: %.3f", glConfig.displayAspect );
}
else
{
memset( &desktopMode, 0, sizeof( SDL_DisplayMode ) );
displayAspect = 1.333f;
logger.Warn("Cannot determine display aspect, assuming %.3f: %s", displayAspect, SDL_GetError() );
glConfig.displayAspect = 1.333f;
logger.Warn("Cannot determine display aspect, assuming %.3f: %s", glConfig.displayAspect, SDL_GetError() );
}

logger.Notice("Display aspect: %.3f", displayAspect );
glConfig.displayWidth = desktopMode.w;
glConfig.displayHeight = desktopMode.h;

if ( mode == -2 )
{
Expand Down Expand Up @@ -1616,6 +1618,7 @@ static bool GLimp_StartDriverAndSetMode( int mode, bool fullscreen, bool bordere
#endif

AssertCvarRange( r_displayIndex, 0, numDisplays - 1, true );
glConfig.displayIndex = r_displayIndex->integer;

rserr_t err = GLimp_SetMode(mode, fullscreen, bordered);

Expand Down