From 68a7bafe37adef0e5ef12c2d0e8461a21e05363b Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Mon, 16 Jul 2012 19:17:26 +0200 Subject: Fixes in texture loading - added other texture formats: BGR and BGRA - fixed texture loading in model viewer - moved code from texture.cpp module to texture.h --- src/graphics/common/texture.cpp | 43 ----------------------------------------- src/graphics/common/texture.h | 38 ++++++++++++++++++++++++++++++++---- 2 files changed, 34 insertions(+), 47 deletions(-) delete mode 100644 src/graphics/common/texture.cpp (limited to 'src/graphics/common') diff --git a/src/graphics/common/texture.cpp b/src/graphics/common/texture.cpp deleted file mode 100644 index 50e71cd..0000000 --- a/src/graphics/common/texture.cpp +++ /dev/null @@ -1,43 +0,0 @@ -// * This file is part of the COLOBOT source code -// * Copyright (C) 2012, Polish Portal of Colobot (PPC) -// * -// * 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 http://www.gnu.org/licenses/. - -// texture.cpp - -#include "graphics/common/texture.h" - - -void Gfx::TextureCreateParams::LoadDefault() -{ - alpha = false; - mipmap = false; - - minFilter = Gfx::TEX_MIN_FILTER_NEAREST; - magFilter = Gfx::TEX_MAG_FILTER_NEAREST; - - wrapS = Gfx::TEX_WRAP_REPEAT; - wrapT = Gfx::TEX_WRAP_REPEAT; -} - -void Gfx::TextureParams::LoadDefault() -{ - colorOperation = Gfx::TEX_MIX_OPER_MODULATE; - colorArg1 = Gfx::TEX_MIX_ARG_CURRENT; - colorArg2 = Gfx::TEX_MIX_ARG_TEXTURE; - - alphaOperation = Gfx::TEX_MIX_OPER_MODULATE; - alphaArg1 = Gfx::TEX_MIX_ARG_CURRENT; - alphaArg2 = Gfx::TEX_MIX_ARG_TEXTURE; -} diff --git a/src/graphics/common/texture.h b/src/graphics/common/texture.h index 55b2fc2..fa374ac 100644 --- a/src/graphics/common/texture.h +++ b/src/graphics/common/texture.h @@ -20,6 +20,17 @@ namespace Gfx { +/** + \enum TexImgFormat + \brief Format of image data */ +enum TexImgFormat +{ + TEX_IMG_RGB, + TEX_IMG_BGR, + TEX_IMG_RGBA, + TEX_IMG_BGRA +}; + /** \enum TexMinFilter \brief Minification texture filter @@ -81,10 +92,10 @@ enum TexMixArgument */ struct TextureCreateParams { - //! Whether the texture image contains alpha - bool alpha; //! Whether to generate mipmaps bool mipmap; + //! Format of source image data + Gfx::TexImgFormat format; //! Minification filter Gfx::TexMinFilter minFilter; //! Magnification filter @@ -99,7 +110,17 @@ struct TextureCreateParams { LoadDefault(); } //! Loads the default values - void LoadDefault(); + inline void LoadDefault() + { + format = Gfx::TEX_IMG_RGB; + mipmap = false; + + minFilter = Gfx::TEX_MIN_FILTER_NEAREST; + magFilter = Gfx::TEX_MAG_FILTER_NEAREST; + + wrapS = Gfx::TEX_WRAP_REPEAT; + wrapT = Gfx::TEX_WRAP_REPEAT; + } }; /** @@ -126,7 +147,16 @@ struct TextureParams { LoadDefault(); } //! Loads the default values - void LoadDefault(); + inline void LoadDefault() + { + colorOperation = Gfx::TEX_MIX_OPER_MODULATE; + colorArg1 = Gfx::TEX_MIX_ARG_CURRENT; + colorArg2 = Gfx::TEX_MIX_ARG_TEXTURE; + + alphaOperation = Gfx::TEX_MIX_OPER_MODULATE; + alphaArg1 = Gfx::TEX_MIX_ARG_CURRENT; + alphaArg2 = Gfx::TEX_MIX_ARG_TEXTURE; + } }; /** \struct Texture*/ -- cgit v1.2.3-1-g7c22