setting ResolutionCap to limit the actual screen resolution
This commit is contained in:
parent
8e1801a702
commit
e1fb42b75b
|
@ -47,7 +47,7 @@ GlideSettings::IOErr GlideSettingsFSp::makeSettingsFolderFileSpec(const char* pa
|
|||
|
||||
/**
|
||||
* Find/Create settings folder
|
||||
* @return fnfErr means the CLassic environment wasn't found
|
||||
* @return fnfErr means the Classic environment wasn't found
|
||||
*/
|
||||
GlideSettings::IOErr GlideSettingsFSp::init(const char* applicationname)
|
||||
{
|
||||
|
@ -71,6 +71,7 @@ GlideSettings::IOErr GlideSettingsFSp::init(const char* applicationname)
|
|||
}
|
||||
}
|
||||
// Make references to various files
|
||||
m_fsSettingsFile.vRefNum = 0;
|
||||
if (err == noErr)
|
||||
{
|
||||
err = makeSettingsFolderFileSpec(&s_SettingsFolderName[1], s_LogFileName, &m_fsLogFile);
|
||||
|
@ -79,7 +80,6 @@ GlideSettings::IOErr GlideSettingsFSp::init(const char* applicationname)
|
|||
err = makeSettingsFolderFileSpec(&s_SettingsFolderName[1], s_DefaultSettingsFileName, &m_fsDefaultSettingsFile);
|
||||
if (err == noErr)
|
||||
{
|
||||
m_fsSettingsFile.vRefNum = 0;
|
||||
if (applicationname)
|
||||
{
|
||||
err = makeSettingsFolderFileSpec(&s_SettingsFolderName[1], applicationname, &m_fsSettingsFile);
|
||||
|
@ -143,7 +143,7 @@ GlideSettings::IOErr GlideSettingsFSp::read_settings_from_file(FSSpec* file, Gli
|
|||
err = save();
|
||||
if (err == noErr)
|
||||
{
|
||||
// Now we have o load the file into memory to make the settings reader happy
|
||||
// Now we have to load the file into memory to make the settings reader happy
|
||||
err = read_file(file, &m_FileBuffer, &m_FileBufferSize, &m_SettingsFileRefnum);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,6 @@ protected:
|
|||
IOErr create();
|
||||
IOErr read_defaults();
|
||||
IOErr read();
|
||||
inline bool isApplicationSpecific() {return m_fsSettingsFile.vRefNum != 0;};
|
||||
IOErr put_raw(const char* string);
|
||||
IOErr close();
|
||||
const unsigned char* PascalString(char* string);
|
||||
|
|
|
@ -63,6 +63,11 @@ bool GlideSettings::get(const char* setting, const char** value)
|
|||
sscanf(v, "%255s", buffer);
|
||||
found = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Wrong match, maybe a comment
|
||||
v++;
|
||||
}
|
||||
}
|
||||
}
|
||||
*value = buffer;
|
||||
|
@ -127,6 +132,7 @@ void GlideSettings::defaults()
|
|||
// OpenGL extensions that can be disabled via the config file must be set to
|
||||
// true in order to become enabled in ValidateUserConfig()
|
||||
Resolution = 1;
|
||||
ResolutionCap = 0;
|
||||
MonitorRefreshRate = 0;
|
||||
DepthBufferBits = 0;
|
||||
FullSceneAntiAliasing = 0;
|
||||
|
@ -140,29 +146,29 @@ void GlideSettings::defaults()
|
|||
#endif
|
||||
ColorAlphaRenderMode = OpenGLideColorAlphaRenderMode_Automatic;
|
||||
PrecisionFix = 1;
|
||||
|
||||
/*
|
||||
// Not bad
|
||||
GapFix = static_cast<OpenGLideGapFixFlags>(OpenGLideGapFixFlag_Enabled |
|
||||
OpenGLideGapFixFlag_IncircleOr |
|
||||
GapFix = static_cast<OpenGLideGapFixFlags>(OpenGLideGapFixFlag_IncircleOr |
|
||||
OpenGLideGapFixFlag_DepthFactor);
|
||||
GapFixParam1 = 3.0f;
|
||||
GapFixParam2 = 10.0f;
|
||||
GapFixParam3 = 3.0f;
|
||||
GapFixDepthFactor = 3.3f;
|
||||
*/
|
||||
|
||||
/*
|
||||
// But this one is better
|
||||
GapFix = static_cast<OpenGLideGapFixFlags>(OpenGLideGapFixFlag_Enabled |
|
||||
OpenGLideGapFixFlag_VertexLengthSecondRadius |
|
||||
GapFix = static_cast<OpenGLideGapFixFlags>(OpenGLideGapFixFlag_VertexLengthSecondRadius |
|
||||
OpenGLideGapFixFlag_DepthFactor);
|
||||
GapFixParam1 = 3.0f;
|
||||
GapFixParam2 = 25.0f;
|
||||
GapFixParam3 = 0.9f;
|
||||
GapFixDepthFactor = 3.3f;
|
||||
*/
|
||||
// @todo: Let's make this even more better
|
||||
GapFix = static_cast<OpenGLideGapFixFlags>(/*OpenGLideGapFixFlag_Enabled |*/
|
||||
OpenGLideGapFixFlag_VertexLengthSecondRadius |
|
||||
|
||||
// @todo: Let's improve these default values even more
|
||||
GapFix = static_cast<OpenGLideGapFixFlags>(OpenGLideGapFixFlag_VertexLengthSecondRadius |
|
||||
OpenGLideGapFixFlag_DepthFactor);
|
||||
GapFixParam1 = 3.0f;
|
||||
GapFixParam2 = 25.0f;
|
||||
|
@ -215,11 +221,11 @@ GlideSettings::IOErr GlideSettings::read_settings()
|
|||
#ifdef OGL_DEBUG
|
||||
GlideMsg("Reading values...\n");
|
||||
#endif
|
||||
GlideSettings::IOErr err = noErr;
|
||||
unsigned long value;
|
||||
get("DisplayMode", &value);
|
||||
DisplayMode = static_cast<OpenGLideDisplayMode>(value);
|
||||
get("Resolution", &Resolution);
|
||||
get("ResolutionCap", &ResolutionCap);
|
||||
get("MonitorRefreshRate", &MonitorRefreshRate);
|
||||
get("DepthBufferBits", &DepthBufferBits);
|
||||
get("Mipmapping", &Mipmapping);
|
||||
|
@ -257,7 +263,7 @@ GlideSettings::IOErr GlideSettings::read_settings()
|
|||
get("ShamelessPlug", &ShamelessPlug);
|
||||
get("UseApplicationSpecificSettings", &UseApplicationSpecificSettings);
|
||||
get("AutoEnableGameSpecificSettings", &AutoEnableGameSpecificSettings);
|
||||
return err;
|
||||
return noErr;
|
||||
}
|
||||
|
||||
GlideSettings::IOErr GlideSettings::load()
|
||||
|
@ -279,29 +285,35 @@ GlideSettings::IOErr GlideSettings::load()
|
|||
}
|
||||
if (success && strcmp(version, prefs_version) == 0)
|
||||
{
|
||||
// Version match
|
||||
err = read_settings();
|
||||
}
|
||||
else if (!success)
|
||||
{
|
||||
GlideMsg(version_complaint, "default");
|
||||
// Unable to read settings file version information - somethings seriously wrong
|
||||
GlideError(version_complaint, "default");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Write new settings file after settings file version change
|
||||
GlideMsg("Configuration outdated - Creating new default settings %s...\n", prefs_version);
|
||||
defaults();
|
||||
err = create_defaults();
|
||||
if (err == noErr)
|
||||
{
|
||||
err = saveSettings();
|
||||
err = save();
|
||||
}
|
||||
}
|
||||
if (err == noErr)
|
||||
{
|
||||
if (isApplicationSpecific() && UseApplicationSpecificSettings)
|
||||
// Default or application specific config?
|
||||
if (UseApplicationSpecificSettings)
|
||||
{
|
||||
// Read application specific config
|
||||
err = read();
|
||||
if (err == noErr)
|
||||
{
|
||||
// Version check
|
||||
success = get("Version", &version);
|
||||
if (success && strcmp(version, prefs_version) == 0)
|
||||
{
|
||||
|
@ -314,16 +326,18 @@ GlideSettings::IOErr GlideSettings::load()
|
|||
}
|
||||
else if (!success)
|
||||
{
|
||||
GlideMsg(version_complaint, "application specific");
|
||||
// Unable to read settings file version information - somethings seriously wrong
|
||||
GlideError(version_complaint, "application specific");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Write new settings file after settings file version change
|
||||
GlideMsg("Configuration outdated - Creating new application specific settings %s...\n", prefs_version);
|
||||
defaults();
|
||||
err = create();
|
||||
if (err == noErr)
|
||||
{
|
||||
err = saveSettings();
|
||||
err = save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -338,7 +352,9 @@ GlideSettings::IOErr GlideSettings::saveSettings()
|
|||
#ifdef OGL_DEBUG
|
||||
GlideMsg("Saving...\n");
|
||||
#endif
|
||||
put("Configuration File for MacGLide");
|
||||
IOErr err = put("Configuration File for MacGLide");
|
||||
if (err == noErr)
|
||||
{
|
||||
put();
|
||||
put();
|
||||
put("Current version number of the settings file:" );
|
||||
|
@ -354,11 +370,18 @@ GlideSettings::IOErr GlideSettings::saveSettings()
|
|||
put("DisplayMode", static_cast<unsigned long>(DisplayMode));
|
||||
put();
|
||||
put("Display resolution:");
|
||||
put("0: Always use the resolution denoted by the ResolutionCap settings");
|
||||
put("1-8: Multiplier for Glide resolution as requested by the");
|
||||
put("game/application. Any value equal or greater than 512:");
|
||||
put("fixed x resolution (y is computed for a 4/3 aspect ratio)");
|
||||
put("Resolution", Resolution);
|
||||
put();
|
||||
put("Display resolution cap:");
|
||||
put("0 to disable, otherwise the maximum");
|
||||
put("x resolution to use for the Glide display");
|
||||
put("(y is computed for a 4/3 aspect ratio)");
|
||||
put("ResolutionCap", ResolutionCap);
|
||||
put();
|
||||
put("Refresh rate of the monitor:");
|
||||
put("0 to use the Glide refresh rate as requested by the game/");
|
||||
put("application. Any other value equal or greater than 60(Hz):");
|
||||
|
@ -502,7 +525,9 @@ GlideSettings::IOErr GlideSettings::saveSettings()
|
|||
put();
|
||||
put("Shows the 3Dfx logo in the lower right corner of the screen");
|
||||
put("ShamelessPlug", ShamelessPlug);
|
||||
GlideSettings::IOErr err = close();
|
||||
// Get the error code of the last write in order to catch errors like "Disk full" etc.
|
||||
err = put();
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
|
@ -616,19 +641,14 @@ GlideSettings::IOErr GlideSettings::put(const char* setting, bool value)
|
|||
|
||||
GlideSettings::IOErr GlideSettings::save()
|
||||
{
|
||||
IOErr err = noErr;
|
||||
if (isApplicationSpecific())
|
||||
IOErr err = saveSettings();
|
||||
if (err == noErr)
|
||||
{
|
||||
err = create();
|
||||
err = close();
|
||||
}
|
||||
else
|
||||
{
|
||||
err = create_defaults();
|
||||
}
|
||||
if (err == noErr)
|
||||
{
|
||||
err = saveSettings();
|
||||
}
|
||||
close();
|
||||
return noErr;
|
||||
}
|
||||
return err;
|
||||
}
|
|
@ -69,6 +69,7 @@ struct ConfigStruct
|
|||
{
|
||||
OpenGLideDisplayMode DisplayMode;
|
||||
unsigned long Resolution;
|
||||
unsigned long ResolutionCap;
|
||||
unsigned long MonitorRefreshRate;
|
||||
unsigned long DepthBufferBits;
|
||||
unsigned long FullSceneAntiAliasing;
|
||||
|
@ -143,7 +144,6 @@ protected:
|
|||
void defaults();
|
||||
virtual IOErr read_defaults()=0;
|
||||
virtual IOErr read()=0;
|
||||
virtual bool isApplicationSpecific()=0;
|
||||
IOErr read_settings();
|
||||
IOErr saveSettings();
|
||||
bool get(const char* setting, const char** value);
|
||||
|
|
|
@ -225,13 +225,13 @@ grSstWinOpen(FxU32 hwnd,
|
|||
}
|
||||
#endif
|
||||
|
||||
Glide.WindowWidth = windowDimensions[ Glide.Resolution ].width;
|
||||
Glide.WindowHeight = windowDimensions[ Glide.Resolution ].height;
|
||||
Glide.WindowWidth = windowDimensions[Glide.Resolution].width;
|
||||
Glide.WindowHeight = windowDimensions[Glide.Resolution].height;
|
||||
// Set the size of the opengl window (might be different from Glide window size)
|
||||
if (UserConfig.Resolution == 0)
|
||||
{
|
||||
// Does only work if the library is loaded at startup, before the game changes the screen resolution
|
||||
if (DisplayManager_GetDesktopDisplayResolution(OpenGL.WindowWidth, OpenGL.WindowHeight) != noErr)
|
||||
if (!DisplayManager_GetDesktopDisplayResolution(OpenGL.WindowWidth, OpenGL.WindowHeight))
|
||||
{
|
||||
// Use the resuolution requested by the game
|
||||
OpenGL.WindowWidth = Glide.WindowWidth;
|
||||
|
@ -244,18 +244,20 @@ grSstWinOpen(FxU32 hwnd,
|
|||
OpenGL.WindowWidth = Glide.WindowWidth * UserConfig.Resolution;
|
||||
OpenGL.WindowHeight = Glide.WindowHeight * UserConfig.Resolution;
|
||||
}
|
||||
else if (UserConfig.Resolution >= 512)
|
||||
else
|
||||
{
|
||||
// override the resolution
|
||||
OpenGL.WindowWidth = UserConfig.Resolution;
|
||||
// Glide games have a fixed 4/3 aspect ratio
|
||||
OpenGL.WindowHeight = UserConfig.Resolution * 3 / 4;
|
||||
}
|
||||
else
|
||||
// Limit the display size to the max allowed screen resolution
|
||||
if (UserConfig.ResolutionCap)
|
||||
{
|
||||
// Use the resuolution requested by the game
|
||||
OpenGL.WindowWidth = Glide.WindowWidth;
|
||||
OpenGL.WindowHeight = Glide.WindowHeight;
|
||||
OpenGL.WindowWidth = min(OpenGL.WindowWidth,
|
||||
UserConfig.ResolutionCap);
|
||||
OpenGL.WindowHeight = min(OpenGL.WindowHeight,
|
||||
UserConfig.ResolutionCap * 3 / 4);
|
||||
}
|
||||
Glide.WindowTotalPixels = Glide.WindowWidth * Glide.WindowHeight;
|
||||
Glide.Refresh = ref;
|
||||
|
|
Loading…
Reference in New Issue