Index: source/renderer/SkyManager.h =================================================================== --- source/renderer/SkyManager.h +++ source/renderer/SkyManager.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2012 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -30,30 +30,28 @@ class SkyManager { public: - bool m_RenderSky; - float m_HorizonHeight; - -public: SkyManager(); /** - * RenderSky: Render the sky. + * Render the sky. */ void RenderSky(); /** - * GetSkySet(): Return the currently selected sky set name. + * Return the currently selected sky set name. */ - inline const CStrW& GetSkySet() const { + inline const CStrW& GetSkySet() const + { return m_SkySet; } - GLuint GetSkyCube() { + GLuint GetSkyCube() + { return m_SkyCubeMap; } /** - * GetSkySet(): Set the sky set name, potentially loading the textures. + * Set the sky set name, potentially loading the textures. */ void SetSkySet(const CStrW& name); @@ -63,9 +61,22 @@ */ std::vector GetSkySets() const; + bool GetRenderSky() const + { + return m_RenderSky; + } + + void SetRenderSky(bool value) + { + m_RenderSky = value; + } + private: void LoadSkyTextures(); + bool m_RenderSky; + float m_HorizonHeight; + /// Name of current skyset (a directory within art/textures/skies) CStrW m_SkySet; @@ -77,16 +88,13 @@ RIGHT, LEFT, TOP, - numTextures + NUMBER_OF_TEXTURES }; // Sky textures - CTexturePtr m_SkyTexture[numTextures]; + CTexturePtr m_SkyTexture[NUMBER_OF_TEXTURES]; GLuint m_SkyCubeMap; - - // Array of image names (defined in SkyManager.cpp), in the order of the IMG_ id's - static const wchar_t* s_imageNames[numTextures]; }; Index: source/renderer/SkyManager.cpp =================================================================== --- source/renderer/SkyManager.cpp +++ source/renderer/SkyManager.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2013 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -23,61 +23,41 @@ #include +#include "graphics/LightEnv.h" +#include "graphics/ShaderManager.h" +#include "graphics/Terrain.h" +#include "graphics/TextureManager.h" #include "lib/timer.h" #include "lib/tex/tex.h" #include "lib/res/graphics/ogl_tex.h" - #include "maths/MathUtil.h" - #include "ps/CStr.h" #include "ps/CLogger.h" #include "ps/Game.h" #include "ps/Loader.h" #include "ps/Filesystem.h" #include "ps/World.h" - #include "renderer/SkyManager.h" #include "renderer/Renderer.h" -#include "graphics/LightEnv.h" -#include "graphics/ShaderManager.h" -#include "graphics/Terrain.h" -#include "graphics/TextureManager.h" - - -/////////////////////////////////////////////////////////////////////////////////////////////// -// SkyManager implementation - -/////////////////////////////////////////////////////////////////// -// String names for each image, in order of the IMG_ constants -const wchar_t* SkyManager::s_imageNames[numTextures] = { - L"front", - L"back", - L"right", - L"left", - L"top" -}; - - -/////////////////////////////////////////////////////////////////// -// Construction/Destruction SkyManager::SkyManager() + : m_RenderSky(true), m_HorizonHeight(-150.0f), m_SkyCubeMap(0) { - m_RenderSky = true; - - m_SkySet = L""; - - m_HorizonHeight = -150.0f; - - m_SkyCubeMap = 0; } - /////////////////////////////////////////////////////////////////// // Load all sky textures void SkyManager::LoadSkyTextures() { + static const CStrW images[NUMBER_OF_TEXTURES + 1] = { + L"front", + L"back", + L"right", + L"left", + L"top", + L"top" + }; /*for (size_t i = 0; i < ARRAY_SIZE(m_SkyTexture); ++i) { VfsPath path = VfsPath("art/textures/skies") / m_SkySet / (Path::String(s_imageNames[i])+L".dds"); @@ -96,7 +76,7 @@ glGenTextures(1, &m_SkyCubeMap); glBindTexture(GL_TEXTURE_CUBE_MAP, m_SkyCubeMap); - int types[] = { + static const int types[] = { GL_TEXTURE_CUBE_MAP_POSITIVE_X, GL_TEXTURE_CUBE_MAP_NEGATIVE_X, GL_TEXTURE_CUBE_MAP_POSITIVE_Z, @@ -105,25 +85,16 @@ GL_TEXTURE_CUBE_MAP_NEGATIVE_Y }; - const wchar_t* images[numTextures+1] = { - L"front", - L"back", - L"right", - L"left", - L"top", - L"top" - }; - - for (size_t i = 0; i < numTextures+1; ++i) + for (size_t i = 0; i < NUMBER_OF_TEXTURES + 1; ++i) { VfsPath path = VfsPath("art/textures/skies") / m_SkySet / (Path::String(images[i])+L".dds"); shared_ptr file; size_t fileSize; - if (g_VFS->LoadFile(path, file, fileSize) < 0) + if (g_VFS->LoadFile(path, file, fileSize) != INFO::OK) { - VfsPath path2 = VfsPath("art/textures/skies") / m_SkySet / (Path::String(images[i])+L".dds.cached.dds"); - if (g_VFS->LoadFile(path2, file, fileSize) < 0) + path = VfsPath("art/textures/skies") / m_SkySet / (Path::String(images[i])+L".dds.cached.dds"); + if (g_VFS->LoadFile(path, file, fileSize) != INFO::OK) { glDeleteTextures(1, &m_SkyCubeMap); LOGERROR("Error creating sky cubemap."); @@ -179,9 +150,9 @@ /////////////////////////////////////////////////////////////////// // Switch to a different sky set (while the game is running) -void SkyManager::SetSkySet( const CStrW& newSet ) +void SkyManager::SetSkySet(const CStrW& newSet) { - if(newSet == m_SkySet) + if (newSet == m_SkySet) return; if (m_SkyCubeMap) @@ -205,7 +176,7 @@ const VfsPath path(L"art/textures/skies/"); DirectoryNames subdirectories; - if(g_VFS->GetDirectoryEntries(path, 0, &subdirectories) < 0) + if (g_VFS->GetDirectoryEntries(path, 0, &subdirectories) != INFO::OK) { LOGERROR("Error opening directory '%s'", path.string8()); return std::vector(1, GetSkySet()); // just return what we currently have Index: source/tools/atlas/GameInterface/ActorViewer.cpp =================================================================== --- source/tools/atlas/GameInterface/ActorViewer.cpp +++ source/tools/atlas/GameInterface/ActorViewer.cpp @@ -450,8 +450,8 @@ m.OldShadows = g_Renderer.GetOptionBool(CRenderer::OPT_SHADOWS); g_Renderer.SetOptionBool(CRenderer::OPT_SHADOWS, m.ShadowsEnabled); - m.OldSky = g_Renderer.GetSkyManager()->m_RenderSky; - g_Renderer.GetSkyManager()->m_RenderSky = false; + m.OldSky = g_Renderer.GetSkyManager()->GetRenderSky(); + g_Renderer.GetSkyManager()->SetRenderSky(false); m.OldWater = g_Renderer.GetWaterManager()->m_RenderWater; g_Renderer.GetWaterManager()->m_RenderWater = m.WaterEnabled; @@ -460,7 +460,7 @@ { // Restore the old renderer state g_Renderer.SetOptionBool(CRenderer::OPT_SHADOWS, m.OldShadows); - g_Renderer.GetSkyManager()->m_RenderSky = m.OldSky; + g_Renderer.GetSkyManager()->SetRenderSky(m.OldSky); g_Renderer.GetWaterManager()->m_RenderWater = m.OldWater; } }