summaryrefslogtreecommitdiffstats
path: root/src/graphics/common
diff options
context:
space:
mode:
authorPiotr Dziwinski <piotrdz@gmail.com>2012-07-16 19:17:26 +0200
committerPiotr Dziwinski <piotrdz@gmail.com>2012-07-16 19:17:26 +0200
commit68a7bafe37adef0e5ef12c2d0e8461a21e05363b (patch)
treef0185e459ea0c5638fca7bada5f2e440fd9eda51 /src/graphics/common
parent54f4da87923465a5387e2e854b58616647deb7af (diff)
downloadcolobot-68a7bafe37adef0e5ef12c2d0e8461a21e05363b.tar.gz
colobot-68a7bafe37adef0e5ef12c2d0e8461a21e05363b.tar.bz2
colobot-68a7bafe37adef0e5ef12c2d0e8461a21e05363b.zip
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
Diffstat (limited to 'src/graphics/common')
-rw-r--r--src/graphics/common/texture.cpp43
-rw-r--r--src/graphics/common/texture.h38
2 files changed, 34 insertions, 47 deletions
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
@@ -21,6 +21,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*/