summaryrefslogtreecommitdiffstats
path: root/src/graphics
diff options
context:
space:
mode:
Diffstat (limited to 'src/graphics')
-rw-r--r--src/graphics/engine/cloud.cpp6
-rw-r--r--src/graphics/engine/engine.cpp49
-rw-r--r--src/graphics/engine/lightning.cpp2
-rw-r--r--src/graphics/engine/modelfile.cpp20
-rw-r--r--src/graphics/engine/modelmanager.cpp7
-rw-r--r--src/graphics/engine/particle.cpp8
-rw-r--r--src/graphics/engine/planet.cpp4
-rw-r--r--src/graphics/engine/pyro.cpp4
-rw-r--r--src/graphics/engine/terrain.cpp19
-rw-r--r--src/graphics/engine/text.cpp22
-rw-r--r--src/graphics/engine/water.cpp6
11 files changed, 71 insertions, 76 deletions
diff --git a/src/graphics/engine/cloud.cpp b/src/graphics/engine/cloud.cpp
index d3e40cf..7ec0d9e 100644
--- a/src/graphics/engine/cloud.cpp
+++ b/src/graphics/engine/cloud.cpp
@@ -127,8 +127,8 @@ void CCloud::Draw()
material.ambient = m_ambient;
m_engine->SetMaterial(material);
- m_engine->SetTexture(m_fileName, 0);
- m_engine->SetTexture(m_fileName, 1);
+ m_engine->SetTexture("textures/"+m_fileName, 0);
+ m_engine->SetTexture("textures/"+m_fileName, 1);
m_engine->SetState(ENG_RSTATE_TTEXTURE_BLACK | ENG_RSTATE_FOG | ENG_RSTATE_WRAP);
@@ -220,7 +220,7 @@ void CCloud::Create(const std::string& fileName,
m_fileName = fileName;
if (! m_fileName.empty())
- m_engine->LoadTexture(m_fileName);
+ m_engine->LoadTexture("textures/"+m_fileName);
if (m_terrain == nullptr)
m_terrain = CRobotMain::GetInstancePointer()->GetTerrain();
diff --git a/src/graphics/engine/engine.cpp b/src/graphics/engine/engine.cpp
index 6766a27..2c412ec 100644
--- a/src/graphics/engine/engine.cpp
+++ b/src/graphics/engine/engine.cpp
@@ -21,7 +21,6 @@
#include "graphics/engine/engine.h"
#include "app/app.h"
-#include "app/gamedata.h"
#include "common/image.h"
#include "common/key.h"
@@ -285,7 +284,7 @@ bool CEngine::Create()
params.minFilter = TEX_MIN_FILTER_NEAREST;
params.magFilter = TEX_MAG_FILTER_NEAREST;
params.mipmap = false;
- m_miceTexture = LoadTexture("mouse.png", params);
+ m_miceTexture = LoadTexture("textures/interface/mouse.png", params);
GetSystemUtils()->GetCurrentTimeStamp(m_currentFrameTime);
GetSystemUtils()->GetCurrentTimeStamp(m_lastFrameTime);
@@ -1126,10 +1125,10 @@ void CEngine::ChangeSecondTexture(int objRank, const std::string& tex2Name)
p1.next[l2].next.clear();
if (!newP2.tex1.Valid())
- newP2.tex1 = LoadTexture(newP2.tex1Name);
+ newP2.tex1 = LoadTexture("textures/"+newP2.tex1Name);
if (!newP2.tex2.Valid())
- newP2.tex2 = LoadTexture(newP2.tex2Name);
+ newP2.tex2 = LoadTexture("textures/"+newP2.tex2Name);
}
}
@@ -2260,7 +2259,7 @@ Texture CEngine::CreateTexture(const std::string& texName, const TextureCreatePa
if (image == nullptr)
{
- if (! img.Load(CGameData::GetInstancePointer()->GetFilePath(DIR_TEXTURE, texName)))
+ if (!img.Load(texName))
{
std::string error = img.GetError();
GetLogger()->Error("Couldn't load texture '%s': %s, blacklisting\n", texName.c_str(), error.c_str());
@@ -2311,27 +2310,27 @@ Texture CEngine::LoadTexture(const std::string& name, const TextureCreateParams&
bool CEngine::LoadAllTextures()
{
- LoadTexture("text.png");
- m_miceTexture = LoadTexture("mouse.png");
- LoadTexture("button1.png");
- LoadTexture("button2.png");
- LoadTexture("button3.png");
- LoadTexture("effect00.png");
- LoadTexture("effect01.png");
- LoadTexture("effect02.png");
- LoadTexture("map.png");
+ LoadTexture("textures/interface/text.png");
+ m_miceTexture = LoadTexture("textures/interface/mouse.png");
+ LoadTexture("textures/interface/button1.png");
+ LoadTexture("textures/interface/button2.png");
+ LoadTexture("textures/interface/button3.png");
+ LoadTexture("textures/effect00.png");
+ LoadTexture("textures/effect01.png");
+ LoadTexture("textures/effect02.png");
+ LoadTexture("textures/interface/map.png");
if (! m_backgroundName.empty())
{
TextureCreateParams params = m_defaultTexParams;
params.padToNearestPowerOfTwo = true;
- m_backgroundTex = LoadTexture(m_backgroundName, params);
+ m_backgroundTex = LoadTexture("textures/"+m_backgroundName, params);
}
else
m_backgroundTex.SetInvalid();
if (! m_foregroundName.empty())
- m_foregroundTex = LoadTexture(m_foregroundName);
+ m_foregroundTex = LoadTexture("textures/"+m_foregroundName);
else
m_foregroundTex.SetInvalid();
@@ -2365,9 +2364,9 @@ bool CEngine::LoadAllTextures()
if (! p2.tex1Name.empty())
{
if (terrain)
- p2.tex1 = LoadTexture(p2.tex1Name, m_terrainTexParams);
+ p2.tex1 = LoadTexture("textures/"+p2.tex1Name, m_terrainTexParams);
else
- p2.tex1 = LoadTexture(p2.tex1Name);
+ p2.tex1 = LoadTexture("textures/"+p2.tex1Name);
if (! p2.tex1.Valid())
ok = false;
@@ -2376,9 +2375,9 @@ bool CEngine::LoadAllTextures()
if (! p2.tex2Name.empty())
{
if (terrain)
- p2.tex2 = LoadTexture(p2.tex2Name, m_terrainTexParams);
+ p2.tex2 = LoadTexture("textures/"+p2.tex2Name, m_terrainTexParams);
else
- p2.tex2 = LoadTexture(p2.tex2Name);
+ p2.tex2 = LoadTexture("textures/"+p2.tex2Name);
if (! p2.tex2.Valid())
ok = false;
@@ -2428,7 +2427,7 @@ bool CEngine::ChangeTextureColor(const std::string& texName,
CImage img;
- if (! img.Load(CGameData::GetInstancePointer()->GetFilePath(DIR_TEXTURE, texName)))
+ if (!img.Load(texName))
{
std::string error = img.GetError();
GetLogger()->Error("Couldn't load texture '%s': %s, blacklisting\n", texName.c_str(), error.c_str());
@@ -2773,7 +2772,7 @@ void CEngine::SetBackground(const std::string& name, Color up, Color down,
{
TextureCreateParams params = m_defaultTexParams;
params.padToNearestPowerOfTwo = true;
- m_backgroundTex = LoadTexture(m_backgroundName, params);
+ m_backgroundTex = LoadTexture("textures/"+m_backgroundName, params);
}
}
@@ -2799,7 +2798,7 @@ void CEngine::SetForegroundName(const std::string& name)
m_foregroundName = name;
if (! m_foregroundName.empty())
- m_foregroundTex = LoadTexture(m_foregroundName);
+ m_foregroundTex = LoadTexture("textures/"+m_foregroundName);
}
void CEngine::SetOverFront(bool front)
@@ -3738,7 +3737,7 @@ void CEngine::UpdateGroundSpotTextures()
}
std::stringstream str;
- str << "shadow" << std::setfill('0') << std::setw(2) << s << ".png";
+ str << "textures/shadow" << std::setfill('0') << std::setw(2) << s << ".png";
std::string texName = str.str();
DeleteTexture(texName);
@@ -3787,7 +3786,7 @@ void CEngine::DrawShadow()
SetMaterial(material);
// TODO: create a separate texture
- SetTexture("text.png");
+ SetTexture("textures/interface/text.png");
Math::Point ts, ti;
diff --git a/src/graphics/engine/lightning.cpp b/src/graphics/engine/lightning.cpp
index 373a35c..be76b2f 100644
--- a/src/graphics/engine/lightning.cpp
+++ b/src/graphics/engine/lightning.cpp
@@ -237,7 +237,7 @@ void CLightning::Draw()
mat.LoadIdentity();
device->SetTransform(TRANSFORM_WORLD, mat);
- m_engine->SetTexture("effect00.png");
+ m_engine->SetTexture("textures/effect00.png");
m_engine->SetState(ENG_RSTATE_TTEXTURE_BLACK);
Math::Point texInf;
diff --git a/src/graphics/engine/modelfile.cpp b/src/graphics/engine/modelfile.cpp
index ba7c1d6..09c7bbd 100644
--- a/src/graphics/engine/modelfile.cpp
+++ b/src/graphics/engine/modelfile.cpp
@@ -24,6 +24,8 @@
#include "common/logger.h"
#include "common/stringutils.h"
+#include "common/resources/inputstream.h"
+
#include "graphics/engine/engine.h"
#include "math/geometry.h"
@@ -434,9 +436,9 @@ bool CModelFile::ReadModel(const std::string& fileName)
{
m_triangles.clear();
- std::ifstream stream;
- stream.open(fileName.c_str(), std::ios_base::in | std::ios_base::binary);
- if (!stream.good())
+ CInputStream stream;
+ stream.open(fileName.c_str());
+ if (!stream.is_open())
{
GetLogger()->Error("Could not open file '%s'\n", fileName.c_str());
return false;
@@ -825,9 +827,9 @@ struct NewModelTriangle1
bool CModelFile::ReadTextModel(const std::string& fileName)
{
- std::ifstream stream;
- stream.open(fileName.c_str(), std::ios_base::in);
- if (!stream.good())
+ CInputStream stream;
+ stream.open(fileName.c_str());
+ if (!stream.is_open())
{
GetLogger()->Error("Could not open file '%s'\n", fileName.c_str());
return false;
@@ -1022,9 +1024,9 @@ bool CModelFile::WriteTextModel(std::ostream& stream)
bool CModelFile::ReadBinaryModel(const std::string& fileName)
{
- std::ifstream stream;
- stream.open(fileName.c_str(), std::ios_base::in | std::ios_base::binary);
- if (!stream.good())
+ CInputStream stream;
+ stream.open(fileName.c_str());
+ if (!stream.is_open())
{
GetLogger()->Error("Could not open file '%s'\n", fileName.c_str());
return false;
diff --git a/src/graphics/engine/modelmanager.cpp b/src/graphics/engine/modelmanager.cpp
index 25f6d35..ec104d0 100644
--- a/src/graphics/engine/modelmanager.cpp
+++ b/src/graphics/engine/modelmanager.cpp
@@ -20,7 +20,6 @@
#include "graphics/engine/modelmanager.h"
#include "app/app.h"
-#include "app/gamedata.h"
#include "common/logger.h"
@@ -50,11 +49,9 @@ bool CModelManager::LoadModel(const std::string& fileName, bool mirrored)
if (CApplication::GetInstance().IsDebugModeActive(DEBUG_MODELS))
modelFile.SetPrintDebugInfo(true);
- std::string filePath = CGameData::GetInstancePointer()->GetFilePath(DIR_MODEL, fileName);
-
- if (!modelFile.ReadModel(filePath))
+ if (!modelFile.ReadModel("models/" + fileName))
{
- GetLogger()->Error("Loading model '%s' failed\n", filePath.c_str());
+ GetLogger()->Error("Loading model '%s' failed\n", fileName.c_str());
return false;
}
diff --git a/src/graphics/engine/particle.cpp b/src/graphics/engine/particle.cpp
index beb4a02..d038322 100644
--- a/src/graphics/engine/particle.cpp
+++ b/src/graphics/engine/particle.cpp
@@ -203,7 +203,7 @@ void NameParticle(std::string &name, int num)
if (num == 1) name = "effect00.png";
else if (num == 2) name = "effect01.png";
else if (num == 3) name = "effect02.png";
- else if (num == 4) name = "text.png";
+ else if (num == 4) name = "interface/text.png";
else name = "";
}
@@ -3534,7 +3534,7 @@ void CParticle::DrawParticle(int sheet)
if (m_particle[i].sheet != sheet) continue;
if (m_particle[i].type == PARTIPART) continue;
- m_engine->SetTexture(m_triangle[i].tex1Name);
+ m_engine->SetTexture("textures/"+m_triangle[i].tex1Name);
m_engine->SetMaterial(m_triangle[i].material);
m_engine->SetState(m_triangle[i].state);
DrawParticleTriangle(i);
@@ -3553,7 +3553,7 @@ void CParticle::DrawParticle(int sheet)
// Draw tire marks.
if (m_wheelTraceTotal > 0 && sheet == SH_WORLD)
{
- m_engine->SetTexture("text.png");
+ m_engine->SetTexture("textures/interface/text.png");
m_engine->SetState(ENG_RSTATE_TTEXTURE_WHITE);
Math::Matrix matrix;
matrix.LoadIdentity();
@@ -3584,7 +3584,7 @@ void CParticle::DrawParticle(int sheet)
{
std::string name;
NameParticle(name, t);
- m_engine->SetTexture(name);
+ m_engine->SetTexture("textures/"+name);
loadTexture = true;
}
diff --git a/src/graphics/engine/planet.cpp b/src/graphics/engine/planet.cpp
index 66eecca..df34fbc 100644
--- a/src/graphics/engine/planet.cpp
+++ b/src/graphics/engine/planet.cpp
@@ -88,7 +88,7 @@ void CPlanet::LoadTexture()
{
for (int i = 0; i < static_cast<int>( m_planet[j].size() ); i++)
{
- m_engine->LoadTexture(m_planet[j][i].name);
+ m_engine->LoadTexture("textures/"+m_planet[j][i].name);
}
}
}
@@ -104,7 +104,7 @@ void CPlanet::Draw()
for (int i = 0; i < static_cast<int>( m_planet[m_mode].size() ); i++)
{
- m_engine->SetTexture(m_planet[m_mode][i].name);
+ m_engine->SetTexture("textures/"+m_planet[m_mode][i].name);
if (m_planet[m_mode][i].transparent)
m_engine->SetState(ENG_RSTATE_WRAP | ENG_RSTATE_ALPHA);
diff --git a/src/graphics/engine/pyro.cpp b/src/graphics/engine/pyro.cpp
index 9dfc5a4..42f0e84 100644
--- a/src/graphics/engine/pyro.cpp
+++ b/src/graphics/engine/pyro.cpp
@@ -1596,7 +1596,7 @@ void CPyro::ExploStart()
if (channel != -1)
m_object->SetMasterParticle(i, channel);
}
- m_engine->LoadTexture("dirty04.png");
+ m_engine->LoadTexture("textures/dirty04.png");
DeleteObject(false, true); // destroys the object transported + the battery
}
@@ -1639,7 +1639,7 @@ void CPyro::BurnStart()
m_engine->ChangeSecondTexture(objRank, "dirty04.png");
}
}
- m_engine->LoadTexture("dirty04.png");
+ m_engine->LoadTexture("textures/dirty04.png");
m_burnPartTotal = 0;
diff --git a/src/graphics/engine/terrain.cpp b/src/graphics/engine/terrain.cpp
index 6dc8708..21d7446 100644
--- a/src/graphics/engine/terrain.cpp
+++ b/src/graphics/engine/terrain.cpp
@@ -21,7 +21,6 @@
#include "graphics/engine/terrain.h"
#include "app/app.h"
-#include "app/gamedata.h"
#include "common/image.h"
#include "common/logger.h"
@@ -192,10 +191,10 @@ void CTerrain::AddMaterial(int id, const std::string& texName, const Math::Point
bool CTerrain::LoadResources(const std::string& fileName)
{
CImage img;
- std::string path = CGameData::GetInstancePointer()->GetFilePath(DIR_TEXTURE, fileName);
- if (! img.Load(path))
+
+ if (! img.Load(fileName))
{
- GetLogger()->Error("Cannot load resource file: '%s'\n", path.c_str());
+ GetLogger()->Error("Cannot load resource file: '%s'\n", fileName.c_str());
return false;
}
@@ -289,10 +288,10 @@ bool CTerrain::LoadRelief(const std::string &fileName, float scaleRelief,
m_scaleRelief = scaleRelief;
CImage img;
- std::string path = CGameData::GetInstancePointer()->GetFilePath(DIR_TEXTURE, fileName);
- if (! img.Load(path))
+
+ if (! img.Load(fileName))
{
- GetLogger()->Error("Could not load relief file: '%s'!\n", path.c_str());
+ GetLogger()->Error("Could not load relief file: '%s'!\n", fileName.c_str());
return false;
}
@@ -368,17 +367,11 @@ bool CTerrain::RandomizeRelief()
double xi, yi, a, b;
a = modf(x * (rozmiar_oktawy-1), &xi);
b = modf(y * (rozmiar_oktawy-1), &yi);
- /*int xi = floor(x * (rozmiar_oktawy-1));
- int yi = floor(y * (rozmiar_oktawy-1));
- float a = (x * (rozmiar_oktawy-1)) - xi;
- float b = (y * (rozmiar_oktawy-1)) - yi;*/
- //CLogger::GetInstancePointer()->Error("%f %f %f %f\n", xi, yi, a, b);
float lg = oktawy[i][static_cast<int>(yi * rozmiar_oktawy + xi)];
float pg = oktawy[i][static_cast<int>(yi * rozmiar_oktawy + xi + 1)];
float ld = oktawy[i][static_cast<int>((yi+1) * rozmiar_oktawy + xi)];
float pd = oktawy[i][static_cast<int>((yi+1) * rozmiar_oktawy + xi + 1)];
- //CLogger::GetInstancePointer()->Error("%f %f %f %f\n", lg, pg, ld, pd);
float g = pg * a + lg * (1-a);
float d = pd * a + ld * (1-a);
diff --git a/src/graphics/engine/text.cpp b/src/graphics/engine/text.cpp
index ea7fd14..bebf30c 100644
--- a/src/graphics/engine/text.cpp
+++ b/src/graphics/engine/text.cpp
@@ -21,11 +21,11 @@
#include "graphics/engine/text.h"
#include "app/app.h"
-#include "app/gamedata.h"
#include "common/image.h"
#include "common/logger.h"
#include "common/stringutils.h"
+#include "common/resources/resourcemanager.h"
#include "math/func.h"
@@ -80,12 +80,12 @@ bool CText::Create()
return false;
}
- m_fonts[FONT_COLOBOT] = new MultisizeFont("dvu_sans.ttf");
- m_fonts[FONT_COLOBOT_BOLD] = new MultisizeFont("dvu_sans_bold.ttf");
- m_fonts[FONT_COLOBOT_ITALIC] = new MultisizeFont("dvu_sans_italic.ttf");
+ m_fonts[FONT_COLOBOT] = new MultisizeFont("fonts/dvu_sans.ttf");
+ m_fonts[FONT_COLOBOT_BOLD] = new MultisizeFont("fonts/dvu_sans_bold.ttf");
+ m_fonts[FONT_COLOBOT_ITALIC] = new MultisizeFont("fonts/dvu_sans_italic.ttf");
- m_fonts[FONT_COURIER] = new MultisizeFont("dvu_sans_mono.ttf");
- m_fonts[FONT_COURIER_BOLD] = new MultisizeFont("dvu_sans_mono_bold.ttf");
+ m_fonts[FONT_COURIER] = new MultisizeFont("fonts/dvu_sans_mono.ttf");
+ m_fonts[FONT_COURIER_BOLD] = new MultisizeFont("fonts/dvu_sans_mono_bold.ttf");
for (auto it = m_fonts.begin(); it != m_fonts.end(); ++it)
{
@@ -868,10 +868,14 @@ CachedFont* CText::GetOrOpenFont(FontType font, float size)
return m_lastCachedFont;
}
- std::string path = CGameData::GetInstancePointer()->GetFilePath(DIR_FONT, mf->fileName);
-
m_lastCachedFont = new CachedFont();
- m_lastCachedFont->font = TTF_OpenFont(path.c_str(), pointSize);
+ SDL_RWops* file = CResourceManager::GetSDLFileHandler(mf->fileName);
+ if(file == nullptr)
+ {
+ m_error = std::string("Unable to open file");
+ return nullptr;
+ }
+ m_lastCachedFont->font = TTF_OpenFontRW(file, 1, pointSize);
if (m_lastCachedFont->font == nullptr)
m_error = std::string("TTF_OpenFont error ") + std::string(TTF_GetError());
diff --git a/src/graphics/engine/water.cpp b/src/graphics/engine/water.cpp
index d4c7d11..8a396a8 100644
--- a/src/graphics/engine/water.cpp
+++ b/src/graphics/engine/water.cpp
@@ -350,8 +350,8 @@ void CWater::DrawSurf()
material.ambient = m_ambient;
m_engine->SetMaterial(material);
- m_engine->SetTexture(m_fileName, 0);
- m_engine->SetTexture(m_fileName, 1);
+ m_engine->SetTexture("textures/"+m_fileName, 0);
+ m_engine->SetTexture("textures/"+m_fileName, 1);
if (m_type[rankview] == WATER_TT)
m_engine->SetState(ENG_RSTATE_TTEXTURE_BLACK | ENG_RSTATE_DUAL_WHITE | ENG_RSTATE_WRAP, m_color);
@@ -494,7 +494,7 @@ void CWater::Create(WaterType type1, WaterType type2, const std::string& fileNam
VaporFlush();
if (! m_fileName.empty())
- m_engine->LoadTexture(m_fileName);
+ m_engine->LoadTexture("textures/"+m_fileName);
if (m_terrain == nullptr)
m_terrain = CRobotMain::GetInstancePointer()->GetTerrain();