From deae751f9fd5e44f9c9a582d1b0841247cc24df9 Mon Sep 17 00:00:00 2001 From: Nick Gasson Date: Fri, 5 Jun 2009 14:56:17 +0100 Subject: [PATCH] Finally get rid of the LOAD_ONCE macro --- src/LoadOnce.hpp | 39 --------------------------------------- src/Main.cpp | 4 ---- src/Missile.cpp | 1 - src/Texture.cpp | 6 +----- 4 files changed, 1 insertion(+), 49 deletions(-) delete mode 100644 src/LoadOnce.hpp diff --git a/src/LoadOnce.hpp b/src/LoadOnce.hpp deleted file mode 100644 index 2b41df0..0000000 --- a/src/LoadOnce.hpp +++ /dev/null @@ -1,39 +0,0 @@ -// LoadOnce.hpp -- Macros for static initialisation. -// Copyright (C) 2008 Nick Gasson -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -// - -#ifndef INC_LOADONCE_HPP -#define INC_LOADONCE_HPP - -// -// The global variable _forceReload can be used to force all images -// to reload. This works around an SDL bug (?) on Windows where all -// texture information is lost after the resolution is changed. -// -// This is really a bit of a hack, but quite cool, eh? The variable -// _forceReload gets incremented each time we have to reload the -// images, and the static variable _hasLoaded in each constructor -// stores the value of _forceReload the last time the images were -// loaded -- we reload if the values differ. -// - -extern int _forceReload; - -#define LOAD_ONCE \ - static int _hasLoaded = 0; \ - if ((_forceReload > _hasLoaded) && (_hasLoaded = _forceReload)) - -#endif diff --git a/src/Main.cpp b/src/Main.cpp index 92353eb..0d98d88 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -55,9 +55,6 @@ namespace { } } -// See LoadOnce.hpp -int _forceReload = 1; - // // Recreate all the screens. After a resolution switch for // example. @@ -66,7 +63,6 @@ void RecreateScreens() { DestroyScreens(); - _forceReload++; menu = new MainMenu(); game = new Game(); scores = new HighScores(); diff --git a/src/Missile.cpp b/src/Missile.cpp index 5345b98..26b8524 100644 --- a/src/Missile.cpp +++ b/src/Missile.cpp @@ -18,7 +18,6 @@ #include "Platform.hpp" #include "Missile.hpp" -#include "LoadOnce.hpp" #include "Image.hpp" #include "ObjectGrid.hpp" #include "Ship.hpp" diff --git a/src/Texture.cpp b/src/Texture.cpp index 09397f8..5e025b5 100644 --- a/src/Texture.cpp +++ b/src/Texture.cpp @@ -33,12 +33,9 @@ namespace { Texture* LoadTexture(const string& fileName) { TextureCache::iterator it = theCache.find(fileName); - if (it != theCache.end()) { - cout << "Reading from cache: " << fileName << endl; + if (it != theCache.end()) return (*it).second; - } else { - cout << "Loading from file: " << fileName << endl; Texture* tex = new Texture(fileName.c_str()); theCache[fileName] = tex; return tex; @@ -104,7 +101,6 @@ Texture::~Texture() glDeleteTextures(1, &texture); } - bool Texture::IsPowerOfTwo(int n) { int pop = 0; -- 2.39.2