Ticket #3641: glsl-detect.2.patch

File glsl-detect.2.patch, 4.3 KB (added by fabio, 8 years ago)

enable GLSL with OpenGL3+ - rebased after #2506

  • binaries/data/mods/mod/hwdetect/hwdetect.js

     
    1 /* Copyright (c) 2013 Wildfire Games
     1/* Copyright (c) 2015 Wildfire Games
    22 *
    33 * Permission is hereby granted, free of charge, to any person obtaining
    44 * a copy of this software and associated documentation files (the
     
    180180    var disable_shadowpcf = undefined;
    181181    var disable_allwater = undefined;
    182182    var disable_fancywater = undefined;
     183    var enable_glsl = undefined;
    183184    var override_renderpath = undefined;
    184185
    185186    // TODO: add some mechanism for setting config values
     
    209210    var GL_VERSION = settings.GL_VERSION;
    210211    var GL_EXTENSIONS = settings.GL_EXTENSIONS.split(" ");
    211212
     213    // enable GLSL on OpenGL 3+
     214    if (GL_VERSION.match(/^[3-9]/))
     215        enable_glsl = true;
    212216
    213217    // NVIDIA 260.19.* UNIX drivers cause random crashes soon after startup.
    214218    // http://www.wildfiregames.com/forum/index.php?showtopic=13668
     
    293297        "disable_shadowpcf": disable_shadowpcf,
    294298        "disable_allwater": disable_allwater,
    295299        "disable_fancywater": disable_fancywater,
     300        "enable_glsl": enable_glsl,
    296301        "override_renderpath": override_renderpath,
    297302    };
    298303}
     
    332337    if (output.disable_fancywater !== undefined)
    333338        Engine.SetDisableFancyWater(output.disable_fancywater);
    334339
     340    if (output.enable_glsl !== undefined)
     341        Engine.SetEnableGLSL(output.enable_glsl);
     342
    335343    if (output.override_renderpath !== undefined)
    336344        Engine.SetRenderPath(output.override_renderpath);
    337345};
  • source/ps/GameSetup/Config.cpp

     
    5151bool g_Silhouettes = false;
    5252bool g_ShowSky = false;
    5353
     54bool g_PreferGLSL = false;
     55
    5456float g_Gamma = 1.0f;
    5557
    5658CStr g_RenderPath = "default";
  • source/ps/GameSetup/Config.h

     
    1 /* Copyright (C) 2012 Wildfire Games.
     1/* Copyright (C) 2015 Wildfire Games.
    22 * This file is part of 0 A.D.
    33 *
    44 * 0 A.D. is free software: you can redistribute it and/or modify
     
    7272// flag to switch on sky rendering
    7373extern bool g_ShowSky;
    7474
     75// Prefer GLSL shaders over ARB shaders
     76extern bool g_PreferGLSL;
     77
    7578extern float g_Gamma;
    7679// name of configured render path (depending on OpenGL extensions, this may not be
    7780// the render path that is actually in use right now)
  • source/ps/GameSetup/GameSetup.cpp

     
    617617    g_Renderer.SetOptionBool(CRenderer::OPT_PARTICLES, g_Particles);
    618618    g_Renderer.SetOptionBool(CRenderer::OPT_SILHOUETTES, g_Silhouettes);
    619619    g_Renderer.SetOptionBool(CRenderer::OPT_SHOWSKY, g_ShowSky);
     620    g_Renderer.SetOptionBool(CRenderer::OPT_PREFERGLSL, g_PreferGLSL);
    620621
    621622    // create terrain related stuff
    622623    new CTerrainTextureManager;
  • source/ps/GameSetup/HWDetect.cpp

     
    172172        g_WaterShadows = !disabled;
    173173}
    174174
     175void SetEnableGLSL(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), bool enabled)
     176{
     177    if (!IsOverridden("preferglsl"))
     178        g_PreferGLSL = enabled;
     179}
     180
    175181void SetRenderPath(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), std::string renderpath)
    176182{
    177183    g_RenderPath = renderpath;
     
    191197    scriptInterface.RegisterFunction<void, bool, &SetDisableShadowPCF>("SetDisableShadowPCF");
    192198    scriptInterface.RegisterFunction<void, bool, &SetDisableAllWater>("SetDisableAllWater");
    193199    scriptInterface.RegisterFunction<void, bool, &SetDisableFancyWater>("SetDisableFancyWater");
     200    scriptInterface.RegisterFunction<void, bool, &SetEnableGLSL>("SetEnableGLSL");
    194201    scriptInterface.RegisterFunction<void, std::string, &SetRenderPath>("SetRenderPath");
    195202
    196203    // Load the detection script: