mirror of
https://github.com/glest/glest-source.git
synced 2025-08-28 18:29:48 +02:00
Start to abstract model
This commit is contained in:
@@ -33,7 +33,7 @@ public:
|
||||
virtual TextRenderer3D *newTextRenderer3D() {return new TextRenderer3DGl();}
|
||||
virtual ModelRenderer *newModelRenderer() {return new ModelRendererGl();}
|
||||
virtual Context *newContext() {return new ContextGl();}
|
||||
virtual Model *newModel() {return new ModelGl();}
|
||||
virtual Model *newModel(const string &path,bool deletePixMapAfterLoad,std::map<string,vector<pair<string, string> > > *loadedFileList, string *sourceLoader) { return new ModelGl(path,deletePixMapAfterLoad,loadedFileList,sourceLoader); }
|
||||
virtual Texture2D *newTexture2D() {return new Texture2DGl();}
|
||||
virtual Font2D *newFont2D() {return new Font2DGl();}
|
||||
virtual Font3D *newFont3D() {return new Font3DGl();}
|
||||
|
@@ -47,7 +47,7 @@ public:
|
||||
//models
|
||||
virtual ModelManager *newModelManager() {return new ModelManager();}
|
||||
virtual ModelRenderer *newModelRenderer() {return new ModelRendererGl();}
|
||||
virtual Model *newModel() {return new ModelGl();}
|
||||
virtual Model *newModel(const string &path,bool deletePixMapAfterLoad,std::map<string,vector<pair<string, string> > > *loadedFileList, string *sourceLoader) { return new ModelGl(path,deletePixMapAfterLoad,loadedFileList,sourceLoader); }
|
||||
|
||||
//text
|
||||
virtual FontManager *newFontManager() {return new FontManager();}
|
||||
|
@@ -22,6 +22,9 @@ namespace Shared{ namespace Graphics{ namespace Gl{
|
||||
// =====================================================
|
||||
|
||||
class ModelGl: public Model{
|
||||
friend class GraphicsFactoryGl;
|
||||
protected:
|
||||
ModelGl(const string &path,bool deletePixMapAfterLoad,std::map<string,vector<pair<string, string> > > *loadedFileList, string *sourceLoader);
|
||||
public:
|
||||
virtual void init(){}
|
||||
virtual void end(){}
|
||||
|
@@ -13,6 +13,11 @@
|
||||
#define _SHARED_GRAPHICS_GRAPHICSFACTORY_H_
|
||||
|
||||
#include <cstdlib>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
using std::string;
|
||||
|
||||
#include "leak_dumper.h"
|
||||
|
||||
namespace Shared{ namespace Graphics{
|
||||
@@ -64,7 +69,7 @@ public:
|
||||
//models
|
||||
virtual ModelManager *newModelManager() {return NULL;}
|
||||
virtual ModelRenderer *newModelRenderer() {return NULL;}
|
||||
virtual Model *newModel() {return NULL;}
|
||||
virtual Model *newModel(const string &path,bool deletePixMapAfterLoad,std::map<string,std::vector<std::pair<string, string> > > *loadedFileList, string *sourceLoader) {return NULL;}
|
||||
|
||||
//text
|
||||
virtual FontManager *newFontManager() {return NULL;}
|
||||
|
@@ -35,7 +35,7 @@ enum ResourceScope {
|
||||
class RendererInterface {
|
||||
public:
|
||||
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() {}
|
||||
};
|
||||
|
@@ -221,9 +221,7 @@ public:
|
||||
uint32 getVertexCount() const;
|
||||
|
||||
//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 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 setTextureManager(TextureManager *textureManager) {this->textureManager= textureManager;}
|
||||
@@ -234,6 +232,11 @@ public:
|
||||
void toEndian();
|
||||
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:
|
||||
void buildInterpolationData() const;
|
||||
void autoJoinMeshFrames();
|
||||
|
@@ -38,7 +38,7 @@ public:
|
||||
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 end();
|
||||
|
20
source/shared_lib/sources/graphics/gl/model_gl.cpp
Normal file
20
source/shared_lib/sources/graphics/gl/model_gl.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
// ==============================================================
|
||||
// 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,bool deletePixMapAfterLoad,std::map<string,vector<pair<string, string> > > *loadedFileList, string *sourceLoader) {
|
||||
load(path,deletePixMapAfterLoad,loadedFileList,sourceLoader);
|
||||
}
|
||||
|
||||
}}}//end namespace
|
@@ -40,8 +40,8 @@ ModelManager::~ModelManager(){
|
||||
end();
|
||||
}
|
||||
|
||||
Model *ModelManager::newModel(){
|
||||
Model *model= GraphicsInterface::getInstance().getFactory()->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(path,deletePixMapAfterLoad,loadedFileList,sourceLoader);
|
||||
model->setTextureManager(textureManager);
|
||||
models.push_back(model);
|
||||
return model;
|
||||
|
@@ -121,55 +121,60 @@ static int getFileAndLine(char *function, void *address, char *file, size_t flen
|
||||
|
||||
// prepare command to be executed
|
||||
// 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);
|
||||
|
||||
#endif
|
||||
FILE* f = popen (buf, "r");
|
||||
if (f == NULL) {
|
||||
perror (buf);
|
||||
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') {
|
||||
line = 0;
|
||||
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;
|
||||
}
|
||||
if(strlen(buf) > 0 && buf[0] != '?') {
|
||||
//int l;
|
||||
char *p = buf;
|
||||
// file name is until ':'
|
||||
while(*p != 0 && *p != ':') {
|
||||
p++;
|
||||
}
|
||||
|
||||
// get file and line
|
||||
ret = fgets (buf, maxbufSize, f);
|
||||
if(ret == NULL) {
|
||||
pclose(f);
|
||||
return line;
|
||||
}
|
||||
|
||||
if(strlen(buf) > 0 && buf[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;
|
||||
}
|
||||
}
|
||||
}
|
||||
*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
|
||||
char *ret = fgets (buf, maxbufSize, f);
|
||||
|
Reference in New Issue
Block a user