Merge branch 'master' of https://github.com/williame/megaglest-source
This commit is contained in:
commit
ad81692331
|
@ -6,19 +6,10 @@
|
||||||
# Vim
|
# Vim
|
||||||
*.un~
|
*.un~
|
||||||
Session.vim
|
Session.vim
|
||||||
.netrwhist
|
MegaGlest.kdev4
|
||||||
|
|
||||||
## OSX
|
## OSX
|
||||||
.DS_Store
|
|
||||||
.DS_Store?
|
|
||||||
.AppleDouble
|
|
||||||
.LSOverride
|
|
||||||
Icon
|
Icon
|
||||||
# Thumbnails
|
|
||||||
._*
|
|
||||||
# Files that might appear on external disk
|
|
||||||
.Spotlight-V100
|
|
||||||
.Trashes
|
|
||||||
|
|
||||||
## Windows
|
## Windows
|
||||||
# Windows image file caches
|
# Windows image file caches
|
||||||
|
|
|
@ -86,7 +86,7 @@ endif()
|
||||||
|
|
||||||
## Compiler flags
|
## Compiler flags
|
||||||
IF(APPLE)
|
IF(APPLE)
|
||||||
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++")
|
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++")
|
||||||
ENDIF(APPLE)
|
ENDIF(APPLE)
|
||||||
|
|
||||||
IF(CMAKE_COMPILER_IS_GNUCXX OR MINGW)
|
IF(CMAKE_COMPILER_IS_GNUCXX OR MINGW)
|
||||||
|
@ -223,7 +223,7 @@ IF(CMAKE_COMPILER_IS_GNUCXX OR MINGW)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
IF(APPLE)
|
IF(APPLE AND NOT CMAKE_COMPILER_IS_GNUCXX)
|
||||||
SET(GIT_VERSION_CMD "-DGITVERSION='\\\\'${GIT_COMMIT_COUNT}.${GIT_SHA1}\\\\''")
|
SET(GIT_VERSION_CMD "-DGITVERSION='\\\\'${GIT_COMMIT_COUNT}.${GIT_SHA1}\\\\''")
|
||||||
ELSE()
|
ELSE()
|
||||||
SET(GIT_VERSION_CMD "-DGITVERSION='\\\"${GIT_COMMIT_COUNT}.${GIT_SHA1}\\\"'")
|
SET(GIT_VERSION_CMD "-DGITVERSION='\\\"${GIT_COMMIT_COUNT}.${GIT_SHA1}\\\"'")
|
||||||
|
|
|
@ -1280,9 +1280,8 @@ void MainWindow::loadModel(string path) {
|
||||||
|
|
||||||
if(timer) timer->Stop();
|
if(timer) timer->Stop();
|
||||||
delete model;
|
delete model;
|
||||||
Model *tmpModel= new ModelGl();
|
model = NULL;
|
||||||
if(renderer) renderer->loadTheModel(tmpModel, modelPath);
|
model = renderer? renderer->newModel(rsGlobal, modelPath): NULL;
|
||||||
model= tmpModel;
|
|
||||||
|
|
||||||
statusbarText = getModelInfo();
|
statusbarText = getModelInfo();
|
||||||
string statusTextValue = statusbarText + " animation speed: " + floatToStr(speed * 1000.0) + " anim value: " + floatToStr(anim) + " zoom: " + floatToStr(zoom) + " rotX: " + floatToStr(rotX) + " rotY: " + floatToStr(rotY);
|
string statusTextValue = statusbarText + " animation speed: " + floatToStr(speed * 1000.0) + " anim value: " + floatToStr(anim) + " zoom: " + floatToStr(zoom) + " rotX: " + floatToStr(rotX) + " rotY: " + floatToStr(rotY);
|
||||||
|
|
|
@ -196,9 +196,8 @@ Texture2D * Renderer::getNewTexture2D() {
|
||||||
return newTexture;
|
return newTexture;
|
||||||
}
|
}
|
||||||
|
|
||||||
Model * Renderer::getNewModel() {
|
Model * Renderer::newModel(ResourceScope rs,const string &path,bool deletePixMapAfterLoad,std::map<string,vector<pair<string, string> > > *loadedFileList, string *sourceLoader) {
|
||||||
Model *newModel = modelManager->newModel();
|
return modelManager->newModel(path,deletePixMapAfterLoad,loadedFileList,sourceLoader);
|
||||||
return newModel;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::init() {
|
void Renderer::init() {
|
||||||
|
@ -416,13 +415,6 @@ void Renderer::toggleGrid() {
|
||||||
grid= grid? false: true;
|
grid= grid? false: true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::loadTheModel(Model *model, string file) {
|
|
||||||
model->setTextureManager(textureManager);
|
|
||||||
model->loadG3d(file);
|
|
||||||
textureManager->init();
|
|
||||||
modelManager->init();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Renderer::renderTheModel(Model *model, float f) {
|
void Renderer::renderTheModel(Model *model, float f) {
|
||||||
if(model != NULL){
|
if(model != NULL){
|
||||||
modelRenderer->begin(true, true, !wireframe, false, &meshCallbackTeamColor);
|
modelRenderer->begin(true, true, !wireframe, false, &meshCallbackTeamColor);
|
||||||
|
|
|
@ -137,7 +137,6 @@ public:
|
||||||
void toggleWireframe();
|
void toggleWireframe();
|
||||||
void toggleGrid();
|
void toggleGrid();
|
||||||
|
|
||||||
void loadTheModel(Model *model, string file);
|
|
||||||
void renderTheModel(Model *model, float f);
|
void renderTheModel(Model *model, float f);
|
||||||
|
|
||||||
void manageParticleSystem(ParticleSystem *particleSystem);
|
void manageParticleSystem(ParticleSystem *particleSystem);
|
||||||
|
@ -146,9 +145,8 @@ public:
|
||||||
Texture2D *getPlayerColorTexture(PlayerColor playerColor);
|
Texture2D *getPlayerColorTexture(PlayerColor playerColor);
|
||||||
|
|
||||||
Texture2D * getNewTexture2D();
|
Texture2D * getNewTexture2D();
|
||||||
Model * getNewModel();
|
|
||||||
|
|
||||||
Model *newModel(ResourceScope rs) { return getNewModel(); }
|
Model *newModel(ResourceScope rs,const string &path,bool deletePixMapAfterLoad=false,std::map<string,vector<pair<string, string> > > *loadedFileList=NULL, string *sourceLoader=NULL);
|
||||||
Texture2D *newTexture2D(ResourceScope rs) { return getNewTexture2D(); }
|
Texture2D *newTexture2D(ResourceScope rs) { return getNewTexture2D(); }
|
||||||
|
|
||||||
void initTextureManager();
|
void initTextureManager();
|
||||||
|
|
|
@ -29,12 +29,12 @@ namespace Glest { namespace Game {
|
||||||
const char *mailString = " http://bugs.megaglest.org";
|
const char *mailString = " http://bugs.megaglest.org";
|
||||||
const string glestVersionString = "v3.9.1-dev";
|
const string glestVersionString = "v3.9.1-dev";
|
||||||
#if defined(GITVERSION)
|
#if defined(GITVERSION)
|
||||||
const string GIT_RawRev = string(GITVERSION);
|
const string GIT_RawRev = string(GITVERSION);
|
||||||
const string GIT_Rev = string("Rev: ") + string(GITVERSION);
|
const string GIT_Rev = string("Rev: ") + string(GITVERSION);
|
||||||
#elif defined(GITVERSIONHEADER)
|
#elif defined(GITVERSIONHEADER)
|
||||||
#include "gitversion.h"
|
#include "gitversion.h"
|
||||||
const string GIT_RawRev = string(GITVERSION);
|
const string GIT_RawRev = string(GITVERSION);
|
||||||
const string GIT_Rev = string("Rev: ") + string(GITVERSION);
|
const string GIT_Rev = string("Rev: ") + string(GITVERSION);
|
||||||
#else
|
#else
|
||||||
const string GIT_RawRev = "$4446.1a8673f$";
|
const string GIT_RawRev = "$4446.1a8673f$";
|
||||||
const string GIT_Rev = "$Rev$";
|
const string GIT_Rev = "$Rev$";
|
||||||
|
|
|
@ -170,10 +170,7 @@ void ParticleSystemType::load(const XmlNode *particleSystemNode, const string &d
|
||||||
endPathWithSlash(currentPath);
|
endPathWithSlash(currentPath);
|
||||||
|
|
||||||
string path= modelNode->getAttribute("path")->getRestrictedValue(currentPath);
|
string path= modelNode->getAttribute("path")->getRestrictedValue(currentPath);
|
||||||
model= renderer->newModel(rsGame);
|
model= renderer->newModel(rsGame,path, false, &loadedFileList, &parentLoader);
|
||||||
if(model) {
|
|
||||||
model->load(path, false, &loadedFileList, &parentLoader);
|
|
||||||
}
|
|
||||||
loadedFileList[path].push_back(make_pair(parentLoader,modelNode->getAttribute("path")->getRestrictedValue()));
|
loadedFileList[path].push_back(make_pair(parentLoader,modelNode->getAttribute("path")->getRestrictedValue()));
|
||||||
|
|
||||||
if(modelNode->hasChild("cycles")) {
|
if(modelNode->hasChild("cycles")) {
|
||||||
|
|
|
@ -598,12 +598,10 @@ void Renderer::manageDeferredParticleSystems() {
|
||||||
if(dynamic_cast<GameParticleSystem *>(ps) != NULL) {
|
if(dynamic_cast<GameParticleSystem *>(ps) != NULL) {
|
||||||
GameParticleSystem *gps = dynamic_cast<GameParticleSystem *>(ps);
|
GameParticleSystem *gps = dynamic_cast<GameParticleSystem *>(ps);
|
||||||
if(gps->getModelFileLoadDeferred() != "" && gps->getModel() == NULL) {
|
if(gps->getModelFileLoadDeferred() != "" && gps->getModel() == NULL) {
|
||||||
Model *model= newModel(rsGame);
|
std::map<string,vector<pair<string, string> > > loadedFileList;
|
||||||
if(model) {
|
Model *model= newModel(rsGame, gps->getModelFileLoadDeferred(), false, &loadedFileList, NULL);
|
||||||
std::map<string,vector<pair<string, string> > > loadedFileList;
|
if(model)
|
||||||
model->load(gps->getModelFileLoadDeferred(), false, &loadedFileList, NULL);
|
gps->setModel(model);
|
||||||
gps->setModel(model);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
manageParticleSystem(ps, rs);
|
manageParticleSystem(ps, rs);
|
||||||
|
@ -886,12 +884,12 @@ void Renderer::endLastTexture(ResourceScope rs, bool mustExistInList) {
|
||||||
textureManager[rs]->endLastTexture(mustExistInList);
|
textureManager[rs]->endLastTexture(mustExistInList);
|
||||||
}
|
}
|
||||||
|
|
||||||
Model *Renderer::newModel(ResourceScope rs){
|
Model *Renderer::newModel(ResourceScope rs,const string &path,bool deletePixMapAfterLoad,std::map<string,vector<pair<string, string> > > *loadedFileList, string *sourceLoader){
|
||||||
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) {
|
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return modelManager[rs]->newModel();
|
return modelManager[rs]->newModel(path,deletePixMapAfterLoad,loadedFileList,sourceLoader);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::endModel(ResourceScope rs, Model *model,bool mustExistInList) {
|
void Renderer::endModel(ResourceScope rs, Model *model,bool mustExistInList) {
|
||||||
|
|
|
@ -458,7 +458,7 @@ public:
|
||||||
void endTexture(ResourceScope rs, Texture *texture,bool mustExistInList=false);
|
void endTexture(ResourceScope rs, Texture *texture,bool mustExistInList=false);
|
||||||
void endLastTexture(ResourceScope rs, bool mustExistInList=false);
|
void endLastTexture(ResourceScope rs, bool mustExistInList=false);
|
||||||
|
|
||||||
Model *newModel(ResourceScope rs);
|
Model *newModel(ResourceScope rs,const string &path,bool deletePixMapAfterLoad=false,std::map<string,vector<pair<string, string> > > *loadedFileList=NULL, string *sourceLoader=NULL);
|
||||||
void endModel(ResourceScope rs, Model *model, bool mustExistInList=false);
|
void endModel(ResourceScope rs, Model *model, bool mustExistInList=false);
|
||||||
void endLastModel(ResourceScope rs, bool mustExistInList=false);
|
void endLastModel(ResourceScope rs, bool mustExistInList=false);
|
||||||
|
|
||||||
|
|
|
@ -208,10 +208,9 @@ Intro::Intro(Program *program):
|
||||||
findAll(introPath, introModels, false, false);
|
findAll(introPath, introModels, false, false);
|
||||||
for(int i = 0; i < (int)introModels.size(); ++i) {
|
for(int i = 0; i < (int)introModels.size(); ++i) {
|
||||||
string logo = introModels[i];
|
string logo = introModels[i];
|
||||||
Model *model= renderer.newModel(rsMenu);
|
Model *model= renderer.newModel(rsMenu, getGameCustomCoreDataPath(data_path, "") + "data/core/menu/main_model/" + logo);
|
||||||
if(model) {
|
if(model) {
|
||||||
model->load(getGameCustomCoreDataPath(data_path, "") + "data/core/menu/main_model/" + logo);
|
models.push_back(model);
|
||||||
models.push_back(model);
|
|
||||||
//printf("#1 Intro model [%s]\n",model->getFileName().c_str());
|
//printf("#1 Intro model [%s]\n",model->getFileName().c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -222,9 +221,8 @@ Intro::Intro(Program *program):
|
||||||
findAll(introPath, introModels, false, false);
|
findAll(introPath, introModels, false, false);
|
||||||
for(int i = 0; i < (int)introModels.size(); ++i) {
|
for(int i = 0; i < (int)introModels.size(); ++i) {
|
||||||
string logo = introModels[i];
|
string logo = introModels[i];
|
||||||
Model *model= renderer.newModel(rsMenu);
|
Model *model= renderer.newModel(rsMenu, data_path + "data/core/menu/main_model/" + logo);
|
||||||
if(model) {
|
if(model) {
|
||||||
model->load(data_path + "data/core/menu/main_model/" + logo);
|
|
||||||
models.push_back(model);
|
models.push_back(model);
|
||||||
//printf("#2 Intro model [%s]\n",model->getFileName().c_str());
|
//printf("#2 Intro model [%s]\n",model->getFileName().c_str());
|
||||||
}
|
}
|
||||||
|
|
|
@ -5160,7 +5160,6 @@ int glestMain(int argc, char** argv) {
|
||||||
char szTextBuf[8096]="";
|
char szTextBuf[8096]="";
|
||||||
for(unsigned int i =0; i < models.size(); ++i) {
|
for(unsigned int i =0; i < models.size(); ++i) {
|
||||||
string &file = models[i];
|
string &file = models[i];
|
||||||
bool modelLoadedOk = false;
|
|
||||||
|
|
||||||
renderer.clearBuffers();
|
renderer.clearBuffers();
|
||||||
renderer.clearZBuffer();
|
renderer.clearZBuffer();
|
||||||
|
@ -5187,23 +5186,18 @@ int glestMain(int argc, char** argv) {
|
||||||
::Shared::Platform::Window::handleEvent();
|
::Shared::Platform::Window::handleEvent();
|
||||||
SDL_PumpEvents();
|
SDL_PumpEvents();
|
||||||
|
|
||||||
Model *model = renderer.newModel(rsGlobal);
|
|
||||||
try {
|
try {
|
||||||
printf("About to load model [%s] [%u of " MG_SIZE_T_SPECIFIER "]\n",file.c_str(),i,models.size());
|
printf("About to load model [%s] [%u of " MG_SIZE_T_SPECIFIER "]\n",file.c_str(),i,models.size());
|
||||||
model->load(file);
|
Model *model = renderer.newModel(rsGlobal, file);
|
||||||
modelLoadedOk = true;
|
printf("About to save converted model [%s]\n",file.c_str());
|
||||||
|
model->save(file,textureFormat,keepsmallest);
|
||||||
|
Renderer::getInstance().endModel(rsGlobal, model);
|
||||||
}
|
}
|
||||||
catch(const exception &ex) {
|
catch(const exception &ex) {
|
||||||
result = 1;
|
result = 1;
|
||||||
printf("ERROR loading model [%s] message [%s]\n",file.c_str(),ex.what());
|
printf("ERROR loading model [%s] message [%s]\n",file.c_str(),ex.what());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(modelLoadedOk == true) {
|
|
||||||
printf("About to save converted model [%s]\n",file.c_str());
|
|
||||||
model->save(file,textureFormat,keepsmallest);
|
|
||||||
}
|
|
||||||
|
|
||||||
Renderer::getInstance().endModel(rsGlobal, model);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
delete mainWindow;
|
delete mainWindow;
|
||||||
|
|
|
@ -98,23 +98,17 @@ MenuBackground::MenuBackground() : rps(NULL) {
|
||||||
degToRad(startRotation.z))));
|
degToRad(startRotation.z))));
|
||||||
|
|
||||||
//load main model
|
//load main model
|
||||||
mainModel= renderer.newModel(rsMenu);
|
string mainModelFile = "data/core/menu/main_model/menu_main.g3d";
|
||||||
if(mainModel) {
|
if(menuNode->hasChild("menu-background-model") == true) {
|
||||||
string mainModelFile = "data/core/menu/main_model/menu_main.g3d";
|
//mainModel->load(data_path + "data/core/menu/main_model/menu_main.g3d");
|
||||||
if(menuNode->hasChild("menu-background-model") == true) {
|
const XmlNode *mainMenuModelNode= menuNode->getChild("menu-background-model");
|
||||||
//mainModel->load(data_path + "data/core/menu/main_model/menu_main.g3d");
|
mainModelFile = mainMenuModelNode->getAttribute("value")->getRestrictedValue();
|
||||||
const XmlNode *mainMenuModelNode= menuNode->getChild("menu-background-model");
|
}
|
||||||
mainModelFile = mainMenuModelNode->getAttribute("value")->getRestrictedValue();
|
mainModel = renderer.newModel(rsMenu, getGameCustomCoreDataPath(data_path, mainModelFile));
|
||||||
}
|
|
||||||
mainModel->load(getGameCustomCoreDataPath(data_path, mainModelFile));
|
|
||||||
}
|
|
||||||
|
|
||||||
//models
|
//models
|
||||||
for(int i=0; i<5; ++i){
|
for(int i=0; i<5; ++i) {
|
||||||
characterModels[i]= renderer.newModel(rsMenu);
|
characterModels[i] = renderer.newModel(rsMenu, getGameCustomCoreDataPath(data_path, "data/core/menu/about_models/character"+intToStr(i)+".g3d"));
|
||||||
if(characterModels[i]) {
|
|
||||||
characterModels[i]->load(getGameCustomCoreDataPath(data_path, "data/core/menu/about_models/character"+intToStr(i)+".g3d"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//about position
|
//about position
|
||||||
|
|
|
@ -37,10 +37,7 @@ ObjectType::~ObjectType(){
|
||||||
|
|
||||||
TilesetModelType* ObjectType::loadModel(const string &path, std::map<string,vector<pair<string, string> > > *loadedFileList,
|
TilesetModelType* ObjectType::loadModel(const string &path, std::map<string,vector<pair<string, string> > > *loadedFileList,
|
||||||
string parentLoader) {
|
string parentLoader) {
|
||||||
Model *model= Renderer::getInstance().newModel(rsGame);
|
Model *model= Renderer::getInstance().newModel(rsGame, path, false, loadedFileList, &parentLoader);
|
||||||
if(model) {
|
|
||||||
model->load(path, false, loadedFileList, &parentLoader);
|
|
||||||
}
|
|
||||||
color= Vec3f(0.f);
|
color= Vec3f(0.f);
|
||||||
if(model && model->getMeshCount()>0 && model->getMesh(0)->getTexture(0) != NULL) {
|
if(model && model->getMeshCount()>0 && model->getMesh(0)->getTexture(0) != NULL) {
|
||||||
const Pixmap2D *p= model->getMesh(0)->getTexture(0)->getPixmapConst();
|
const Pixmap2D *p= model->getMesh(0)->getTexture(0)->getPixmapConst();
|
||||||
|
|
|
@ -110,10 +110,7 @@ void ResourceType::load(const string &dir, Checksum* checksum, Checksum *techtre
|
||||||
const XmlNode *modelNode= typeNode->getChild("model");
|
const XmlNode *modelNode= typeNode->getChild("model");
|
||||||
string modelPath= modelNode->getAttribute("path")->getRestrictedValue(currentPath);
|
string modelPath= modelNode->getAttribute("path")->getRestrictedValue(currentPath);
|
||||||
|
|
||||||
model= renderer.newModel(rsGame);
|
model= renderer.newModel(rsGame, modelPath, false, &loadedFileList, &sourceXMLFile);
|
||||||
if(model) {
|
|
||||||
model->load(modelPath, false, &loadedFileList, &sourceXMLFile);
|
|
||||||
}
|
|
||||||
loadedFileList[modelPath].push_back(make_pair(sourceXMLFile,modelNode->getAttribute("path")->getRestrictedValue()));
|
loadedFileList[modelPath].push_back(make_pair(sourceXMLFile,modelNode->getAttribute("path")->getRestrictedValue()));
|
||||||
|
|
||||||
if(modelNode->hasChild("particles")){
|
if(modelNode->hasChild("particles")){
|
||||||
|
|
|
@ -419,10 +419,7 @@ void SkillType::load(const XmlNode *sn, const XmlNode *attackBoostsNode,
|
||||||
for(unsigned int i = 0; i < animationList.size(); ++i) {
|
for(unsigned int i = 0; i < animationList.size(); ++i) {
|
||||||
string path= animationList[i]->getAttribute("path")->getRestrictedValue(currentPath);
|
string path= animationList[i]->getAttribute("path")->getRestrictedValue(currentPath);
|
||||||
if(fileExists(path) == true) {
|
if(fileExists(path) == true) {
|
||||||
Model *animation= Renderer::getInstance().newModel(rsGame);
|
Model *animation= Renderer::getInstance().newModel(rsGame, path, false, &loadedFileList, &parentLoader);
|
||||||
if(animation) {
|
|
||||||
animation->load(path, false, &loadedFileList, &parentLoader);
|
|
||||||
}
|
|
||||||
loadedFileList[path].push_back(make_pair(parentLoader,animationList[i]->getAttribute("path")->getRestrictedValue()));
|
loadedFileList[path].push_back(make_pair(parentLoader,animationList[i]->getAttribute("path")->getRestrictedValue()));
|
||||||
|
|
||||||
animations.push_back(animation);
|
animations.push_back(animation);
|
||||||
|
|
|
@ -33,7 +33,7 @@ public:
|
||||||
virtual TextRenderer3D *newTextRenderer3D() {return new TextRenderer3DGl();}
|
virtual TextRenderer3D *newTextRenderer3D() {return new TextRenderer3DGl();}
|
||||||
virtual ModelRenderer *newModelRenderer() {return new ModelRendererGl();}
|
virtual ModelRenderer *newModelRenderer() {return new ModelRendererGl();}
|
||||||
virtual Context *newContext() {return new ContextGl();}
|
virtual Context *newContext() {return new ContextGl();}
|
||||||
virtual Model *newModel() {return new ModelGl();}
|
virtual Model *newModel(const string &path,TextureManager* textureManager,bool deletePixMapAfterLoad,std::map<string,vector<pair<string, string> > > *loadedFileList, string *sourceLoader) { return new ModelGl(path,textureManager,deletePixMapAfterLoad,loadedFileList,sourceLoader); }
|
||||||
virtual Texture2D *newTexture2D() {return new Texture2DGl();}
|
virtual Texture2D *newTexture2D() {return new Texture2DGl();}
|
||||||
virtual Font2D *newFont2D() {return new Font2DGl();}
|
virtual Font2D *newFont2D() {return new Font2DGl();}
|
||||||
virtual Font3D *newFont3D() {return new Font3DGl();}
|
virtual Font3D *newFont3D() {return new Font3DGl();}
|
||||||
|
|
|
@ -47,7 +47,7 @@ public:
|
||||||
//models
|
//models
|
||||||
virtual ModelManager *newModelManager() {return new ModelManager();}
|
virtual ModelManager *newModelManager() {return new ModelManager();}
|
||||||
virtual ModelRenderer *newModelRenderer() {return new ModelRendererGl();}
|
virtual ModelRenderer *newModelRenderer() {return new ModelRendererGl();}
|
||||||
virtual Model *newModel() {return new ModelGl();}
|
virtual Model *newModel(const string &path,TextureManager* textureManager,bool deletePixMapAfterLoad,std::map<string,vector<pair<string, string> > > *loadedFileList, string *sourceLoader) { return new ModelGl(path,textureManager,deletePixMapAfterLoad,loadedFileList,sourceLoader); }
|
||||||
|
|
||||||
//text
|
//text
|
||||||
virtual FontManager *newFontManager() {return new FontManager();}
|
virtual FontManager *newFontManager() {return new FontManager();}
|
||||||
|
|
|
@ -22,6 +22,9 @@ namespace Shared{ namespace Graphics{ namespace Gl{
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
|
||||||
class ModelGl: public Model{
|
class ModelGl: public Model{
|
||||||
|
friend class GraphicsFactoryGl;
|
||||||
|
protected:
|
||||||
|
ModelGl(const string &path,TextureManager* textureManager,bool deletePixMapAfterLoad,std::map<string,vector<pair<string, string> > > *loadedFileList, string *sourceLoader);
|
||||||
public:
|
public:
|
||||||
virtual void init(){}
|
virtual void init(){}
|
||||||
virtual void end(){}
|
virtual void end(){}
|
||||||
|
|
|
@ -13,6 +13,11 @@
|
||||||
#define _SHARED_GRAPHICS_GRAPHICSFACTORY_H_
|
#define _SHARED_GRAPHICS_GRAPHICSFACTORY_H_
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
#include <string>
|
||||||
|
#include <map>
|
||||||
|
#include <vector>
|
||||||
|
using std::string;
|
||||||
|
|
||||||
#include "leak_dumper.h"
|
#include "leak_dumper.h"
|
||||||
|
|
||||||
namespace Shared{ namespace Graphics{
|
namespace Shared{ namespace Graphics{
|
||||||
|
@ -64,7 +69,7 @@ public:
|
||||||
//models
|
//models
|
||||||
virtual ModelManager *newModelManager() {return NULL;}
|
virtual ModelManager *newModelManager() {return NULL;}
|
||||||
virtual ModelRenderer *newModelRenderer() {return NULL;}
|
virtual ModelRenderer *newModelRenderer() {return NULL;}
|
||||||
virtual Model *newModel() {return NULL;}
|
virtual Model *newModel(const string &path,TextureManager* textureManager,bool deletePixMapAfterLoad,std::map<string,std::vector<std::pair<string, string> > > *loadedFileList, string *sourceLoader) {return NULL;}
|
||||||
|
|
||||||
//text
|
//text
|
||||||
virtual FontManager *newFontManager() {return NULL;}
|
virtual FontManager *newFontManager() {return NULL;}
|
||||||
|
|
|
@ -35,7 +35,7 @@ enum ResourceScope {
|
||||||
class RendererInterface {
|
class RendererInterface {
|
||||||
public:
|
public:
|
||||||
virtual Texture2D *newTexture2D(ResourceScope rs) = 0;
|
virtual Texture2D *newTexture2D(ResourceScope rs) = 0;
|
||||||
virtual Model *newModel(ResourceScope rs) = 0;
|
virtual Model *newModel(ResourceScope rs,const string &path,bool deletePixMapAfterLoad=false,std::map<string,vector<pair<string, string> > > *loadedFileList=NULL, string *sourceLoader=NULL) = 0;
|
||||||
|
|
||||||
virtual ~RendererInterface() {}
|
virtual ~RendererInterface() {}
|
||||||
};
|
};
|
||||||
|
|
|
@ -221,9 +221,7 @@ public:
|
||||||
uint32 getVertexCount() const;
|
uint32 getVertexCount() const;
|
||||||
|
|
||||||
//io
|
//io
|
||||||
void load(const string &path,bool deletePixMapAfterLoad=false,std::map<string,vector<pair<string, string> > > *loadedFileList=NULL, string *sourceLoader=NULL);
|
|
||||||
void save(const string &path, string convertTextureToFormat,bool keepsmallest);
|
void save(const string &path, string convertTextureToFormat,bool keepsmallest);
|
||||||
void loadG3d(const string &path,bool deletePixMapAfterLoad=false,std::map<string,vector<pair<string, string> > > *loadedFileList=NULL, string sourceLoader="");
|
|
||||||
void saveG3d(const string &path, string convertTextureToFormat,bool keepsmallest);
|
void saveG3d(const string &path, string convertTextureToFormat,bool keepsmallest);
|
||||||
|
|
||||||
void setTextureManager(TextureManager *textureManager) {this->textureManager= textureManager;}
|
void setTextureManager(TextureManager *textureManager) {this->textureManager= textureManager;}
|
||||||
|
@ -234,6 +232,11 @@ public:
|
||||||
void toEndian();
|
void toEndian();
|
||||||
void fromEndian();
|
void fromEndian();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void load(const string &path,bool deletePixMapAfterLoad=false,std::map<string,vector<pair<string, string> > > *loadedFileList=NULL, string *sourceLoader=NULL);
|
||||||
|
void loadG3d(const string &path,bool deletePixMapAfterLoad=false,std::map<string,vector<pair<string, string> > > *loadedFileList=NULL, string sourceLoader="");
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void buildInterpolationData() const;
|
void buildInterpolationData() const;
|
||||||
void autoJoinMeshFrames();
|
void autoJoinMeshFrames();
|
||||||
|
@ -292,7 +295,7 @@ private:
|
||||||
|
|
||||||
unsigned char uniqueColorID[COLOR_COMPONENTS];
|
unsigned char uniqueColorID[COLOR_COMPONENTS];
|
||||||
|
|
||||||
static unsigned char nextColorID[COLOR_COMPONENTS];
|
static unsigned char nextColorID[COLOR_COMPONENTS];
|
||||||
static unsigned int nextColorRGB;
|
static unsigned int nextColorRGB;
|
||||||
static const unsigned int k, p;
|
static const unsigned int k, p;
|
||||||
//static Mutex mutexNextColorID;
|
//static Mutex mutexNextColorID;
|
||||||
|
|
|
@ -38,7 +38,7 @@ public:
|
||||||
ModelManager();
|
ModelManager();
|
||||||
virtual ~ModelManager();
|
virtual ~ModelManager();
|
||||||
|
|
||||||
Model *newModel();
|
Model *newModel(const string &path,bool deletePixMapAfterLoad,std::map<string,vector<pair<string, string> > > *loadedFileList, string *sourceLoader);
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
void end();
|
void end();
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
// ==============================================================
|
||||||
|
// This file is part of Glest Shared Library (www.glest.org)
|
||||||
|
//
|
||||||
|
// Copyright (C) 2001-2008 Martiño Figueroa
|
||||||
|
//
|
||||||
|
// You can redistribute this code and/or modify it under
|
||||||
|
// the terms of the GNU General Public License as published
|
||||||
|
// by the Free Software Foundation; either version 2 of the
|
||||||
|
// License, or (at your option) any later version
|
||||||
|
// ==============================================================
|
||||||
|
|
||||||
|
#include "model_gl.h"
|
||||||
|
|
||||||
|
namespace Shared{ namespace Graphics{ namespace Gl{
|
||||||
|
|
||||||
|
ModelGl::ModelGl(const string &path,TextureManager* textureManager,bool deletePixMapAfterLoad,std::map<string,vector<pair<string, string> > > *loadedFileList, string *sourceLoader) {
|
||||||
|
setTextureManager(textureManager);
|
||||||
|
load(path,deletePixMapAfterLoad,loadedFileList,sourceLoader);
|
||||||
|
}
|
||||||
|
|
||||||
|
}}}//end namespace
|
|
@ -512,7 +512,7 @@ void Mesh::loadV2(int meshIndex, const string &dir, FILE *f, TextureManager *tex
|
||||||
}
|
}
|
||||||
fromEndianVecArray<Vec3f>(normals, frameCount*vertexCount);
|
fromEndianVecArray<Vec3f>(normals, frameCount*vertexCount);
|
||||||
|
|
||||||
if(textures[mtDiffuse] != NULL) {
|
if(textureFlags & (1<<mtDiffuse)) {
|
||||||
readBytes = fread(texCoords, sizeof(Vec2f)*vertexCount, 1, f);
|
readBytes = fread(texCoords, sizeof(Vec2f)*vertexCount, 1, f);
|
||||||
if(readBytes != 1 && vertexCount != 0) {
|
if(readBytes != 1 && vertexCount != 0) {
|
||||||
char szBuf[8096]="";
|
char szBuf[8096]="";
|
||||||
|
@ -650,7 +650,7 @@ void Mesh::loadV3(int meshIndex, const string &dir, FILE *f,
|
||||||
}
|
}
|
||||||
fromEndianVecArray<Vec3f>(normals, frameCount*vertexCount);
|
fromEndianVecArray<Vec3f>(normals, frameCount*vertexCount);
|
||||||
|
|
||||||
if(textures[mtDiffuse] != NULL) {
|
if(textureFlags & (1<<mtDiffuse)) {
|
||||||
for(unsigned int i=0; i<meshHeader.texCoordFrameCount; ++i){
|
for(unsigned int i=0; i<meshHeader.texCoordFrameCount; ++i){
|
||||||
readBytes = fread(texCoords, sizeof(Vec2f)*vertexCount, 1, f);
|
readBytes = fread(texCoords, sizeof(Vec2f)*vertexCount, 1, f);
|
||||||
if(readBytes != 1 && vertexCount != 0) {
|
if(readBytes != 1 && vertexCount != 0) {
|
||||||
|
@ -788,7 +788,7 @@ void Mesh::load(int meshIndex, const string &dir, FILE *f, TextureManager *textu
|
||||||
//maps
|
//maps
|
||||||
uint32 flag= 1;
|
uint32 flag= 1;
|
||||||
for(int i = 0; i < meshTextureCount; ++i) {
|
for(int i = 0; i < meshTextureCount; ++i) {
|
||||||
if((meshHeader.textures & flag) && textureManager != NULL) {
|
if(meshHeader.textures & flag) {
|
||||||
uint8 cMapPath[mapPathSize];
|
uint8 cMapPath[mapPathSize];
|
||||||
readBytes = fread(cMapPath, mapPathSize, 1, f);
|
readBytes = fread(cMapPath, mapPathSize, 1, f);
|
||||||
if(readBytes != 1 && mapPathSize != 0) {
|
if(readBytes != 1 && mapPathSize != 0) {
|
||||||
|
@ -804,13 +804,14 @@ void Mesh::load(int meshIndex, const string &dir, FILE *f, TextureManager *textu
|
||||||
|
|
||||||
string mapFullPath= dir;
|
string mapFullPath= dir;
|
||||||
if(mapFullPath != "") {
|
if(mapFullPath != "") {
|
||||||
endPathWithSlash(mapFullPath);
|
endPathWithSlash(mapFullPath);
|
||||||
}
|
}
|
||||||
mapFullPath += mapPath;
|
mapFullPath += mapPath;
|
||||||
|
if(textureManager) {
|
||||||
textures[i] = loadMeshTexture(meshIndex, i, textureManager, mapFullPath,
|
textures[i] = loadMeshTexture(meshIndex, i, textureManager, mapFullPath,
|
||||||
meshTextureChannelCount[i],texturesOwned[i],
|
meshTextureChannelCount[i],texturesOwned[i],
|
||||||
deletePixMapAfterLoad, loadedFileList, sourceLoader,modelFile);
|
deletePixMapAfterLoad, loadedFileList, sourceLoader,modelFile);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
flag *= 2;
|
flag *= 2;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,9 +40,8 @@ ModelManager::~ModelManager(){
|
||||||
end();
|
end();
|
||||||
}
|
}
|
||||||
|
|
||||||
Model *ModelManager::newModel(){
|
Model *ModelManager::newModel(const string &path,bool deletePixMapAfterLoad,std::map<string,vector<pair<string, string> > > *loadedFileList, string *sourceLoader){
|
||||||
Model *model= GraphicsInterface::getInstance().getFactory()->newModel();
|
Model *model= GraphicsInterface::getInstance().getFactory()->newModel(path,textureManager,deletePixMapAfterLoad,loadedFileList,sourceLoader);
|
||||||
model->setTextureManager(textureManager);
|
|
||||||
models.push_back(model);
|
models.push_back(model);
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,55 +121,60 @@ static int getFileAndLine(char *function, void *address, char *file, size_t flen
|
||||||
|
|
||||||
// prepare command to be executed
|
// prepare command to be executed
|
||||||
// our program need to be passed after the -e parameter
|
// our program need to be passed after the -e parameter
|
||||||
|
#if __APPLE_CC__
|
||||||
|
snprintf(buf, 8096,"xcrun atos -v -o %s %p",PlatformExceptionHandler::application_binary.c_str(),address);
|
||||||
|
fprintf(stderr,"> %s\n",buf);
|
||||||
|
#else
|
||||||
snprintf(buf, 8096,"addr2line -C -e %s -f -i %p",PlatformExceptionHandler::application_binary.c_str(),address);
|
snprintf(buf, 8096,"addr2line -C -e %s -f -i %p",PlatformExceptionHandler::application_binary.c_str(),address);
|
||||||
|
#endif
|
||||||
FILE* f = popen (buf, "r");
|
FILE* f = popen (buf, "r");
|
||||||
if (f == NULL) {
|
if (f == NULL) {
|
||||||
perror (buf);
|
perror (buf);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#if __APPLE_CC__
|
||||||
|
//### TODO Will: still working this out
|
||||||
|
int len = fread(buf,1,maxbufSize,f);
|
||||||
|
buf[len] = 0;
|
||||||
|
fprintf(stderr,"< %s",buf);
|
||||||
|
return -1;
|
||||||
|
#endif
|
||||||
|
for(;function != NULL && function[0] != '\0';) {
|
||||||
|
// get function name
|
||||||
|
char *ret = fgets (buf, maxbufSize, f);
|
||||||
|
if(ret == NULL) {
|
||||||
|
pclose(f);
|
||||||
|
return line;
|
||||||
|
}
|
||||||
|
//printf("Looking for [%s] Found [%s]\n",function,ret);
|
||||||
|
if(strstr(ret,function) != NULL) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// get file and line
|
||||||
|
ret = fgets (buf, maxbufSize, f);
|
||||||
|
if(ret == NULL) {
|
||||||
|
pclose(f);
|
||||||
|
return line;
|
||||||
|
}
|
||||||
|
|
||||||
if(function != NULL && function[0] != '\0') {
|
if(strlen(buf) > 0 && buf[0] != '?') {
|
||||||
line = 0;
|
//int l;
|
||||||
for(;function != NULL && function[0] != '\0';) {
|
char *p = buf;
|
||||||
// get function name
|
// file name is until ':'
|
||||||
char *ret = fgets (buf, maxbufSize, f);
|
while(*p != 0 && *p != ':') {
|
||||||
if(ret == NULL) {
|
p++;
|
||||||
pclose(f);
|
}
|
||||||
return line;
|
|
||||||
}
|
|
||||||
//printf("Looking for [%s] Found [%s]\n",function,ret);
|
|
||||||
if(strstr(ret,function) != NULL) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// get file and line
|
*p++ = 0;
|
||||||
ret = fgets (buf, maxbufSize, f);
|
// after file name follows line number
|
||||||
if(ret == NULL) {
|
strcpy (file , buf);
|
||||||
pclose(f);
|
sscanf (p,"%10d", &line);
|
||||||
return line;
|
}
|
||||||
}
|
else {
|
||||||
|
strcpy (file,"unknown");
|
||||||
if(strlen(buf) > 0 && buf[0] != '?') {
|
line = 0;
|
||||||
//int l;
|
}
|
||||||
char *p = buf;
|
}
|
||||||
|
|
||||||
// file name is until ':'
|
|
||||||
while(*p != 0 && *p != ':') {
|
|
||||||
p++;
|
|
||||||
}
|
|
||||||
|
|
||||||
*p++ = 0;
|
|
||||||
// after file name follows line number
|
|
||||||
strcpy (file , buf);
|
|
||||||
sscanf (p,"%10d", &line);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
strcpy (file,"unknown");
|
|
||||||
line = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// get file and line
|
// get file and line
|
||||||
char *ret = fgets (buf, maxbufSize, f);
|
char *ret = fgets (buf, maxbufSize, f);
|
||||||
|
|
Loading…
Reference in New Issue