Enable GLSL by default on OpenGL 3+.

This doesn't override any user setting, it just changes the default when
no preferglsl setting is specified.

Fixes #3641.
Refs #145.

This was SVN commit r17338.
This commit is contained in:
fabio 2015-11-30 10:51:02 +00:00
parent f8f8a1eb6a
commit fa9c8e061b
5 changed files with 24 additions and 2 deletions

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2013 Wildfire Games
/* Copyright (c) 2015 Wildfire Games
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
@ -180,6 +180,7 @@ function RunDetection(settings)
var disable_shadowpcf = undefined;
var disable_allwater = undefined;
var disable_fancywater = undefined;
var enable_glsl = undefined;
var override_renderpath = undefined;
// TODO: add some mechanism for setting config values
@ -209,6 +210,10 @@ function RunDetection(settings)
var GL_VERSION = settings.GL_VERSION;
var GL_EXTENSIONS = settings.GL_EXTENSIONS.split(" ");
// enable GLSL on OpenGL 3+, which should be able to properly manage
// GLSL shaders, needed for effects like windy tree
if (GL_VERSION.match(/^[3-9]/))
enable_glsl = true;
// NVIDIA 260.19.* UNIX drivers cause random crashes soon after startup.
// http://www.wildfiregames.com/forum/index.php?showtopic=13668
@ -293,6 +298,7 @@ function RunDetection(settings)
"disable_shadowpcf": disable_shadowpcf,
"disable_allwater": disable_allwater,
"disable_fancywater": disable_fancywater,
"enable_glsl": enable_glsl,
"override_renderpath": override_renderpath,
};
}
@ -332,6 +338,9 @@ global.RunHardwareDetection = function(settings)
if (output.disable_fancywater !== undefined)
Engine.SetDisableFancyWater(output.disable_fancywater);
if (output.enable_glsl !== undefined)
Engine.SetEnableGLSL(output.enable_glsl);
if (output.override_renderpath !== undefined)
Engine.SetRenderPath(output.override_renderpath);
};

View File

@ -51,6 +51,8 @@ bool g_Particles = false;
bool g_Silhouettes = false;
bool g_ShowSky = false;
bool g_PreferGLSL = false;
float g_Gamma = 1.0f;
CStr g_RenderPath = "default";

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2012 Wildfire Games.
/* Copyright (C) 2015 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -72,6 +72,9 @@ extern bool g_Silhouettes;
// flag to switch on sky rendering
extern bool g_ShowSky;
// Prefer GLSL shaders over ARB shaders
extern bool g_PreferGLSL;
extern float g_Gamma;
// name of configured render path (depending on OpenGL extensions, this may not be
// the render path that is actually in use right now)

View File

@ -617,6 +617,7 @@ static void InitRenderer()
g_Renderer.SetOptionBool(CRenderer::OPT_PARTICLES, g_Particles);
g_Renderer.SetOptionBool(CRenderer::OPT_SILHOUETTES, g_Silhouettes);
g_Renderer.SetOptionBool(CRenderer::OPT_SHOWSKY, g_ShowSky);
g_Renderer.SetOptionBool(CRenderer::OPT_PREFERGLSL, g_PreferGLSL);
// create terrain related stuff
new CTerrainTextureManager;

View File

@ -172,6 +172,12 @@ void SetDisableFancyWater(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), bool d
g_WaterShadows = !disabled;
}
void SetEnableGLSL(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), bool enabled)
{
if (!IsOverridden("preferglsl"))
g_PreferGLSL = enabled;
}
void SetRenderPath(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), std::string renderpath)
{
g_RenderPath = renderpath;
@ -191,6 +197,7 @@ void RunHardwareDetection()
scriptInterface.RegisterFunction<void, bool, &SetDisableShadowPCF>("SetDisableShadowPCF");
scriptInterface.RegisterFunction<void, bool, &SetDisableAllWater>("SetDisableAllWater");
scriptInterface.RegisterFunction<void, bool, &SetDisableFancyWater>("SetDisableFancyWater");
scriptInterface.RegisterFunction<void, bool, &SetEnableGLSL>("SetEnableGLSL");
scriptInterface.RegisterFunction<void, std::string, &SetRenderPath>("SetRenderPath");
// Load the detection script: