mirror of
https://github.com/glest/glest-source.git
synced 2025-08-17 13:50:43 +02:00
- added new commandline param --validate-techtrees which will be used to check for known problems in the techtrees for an installation
This commit is contained in:
@@ -280,6 +280,22 @@ void Game::load(){
|
|||||||
//tech, load before map because of resources
|
//tech, load before map because of resources
|
||||||
world.loadTech(config.getPathListForType(ptTechs,scenarioDir), techName, factions, &checksum);
|
world.loadTech(config.getPathListForType(ptTechs,scenarioDir), techName, factions, &checksum);
|
||||||
|
|
||||||
|
// Validate the faction setup to ensure we don't have any bad associations
|
||||||
|
/*
|
||||||
|
std::vector<std::string> results = world.validateFactionTypes();
|
||||||
|
if(results.size() > 0) {
|
||||||
|
// Display the validation errors
|
||||||
|
string errorText = "Errors were detected:\n";
|
||||||
|
for(int i = 0; i < results.size(); ++i) {
|
||||||
|
if(i > 0) {
|
||||||
|
errorText += "\n";
|
||||||
|
}
|
||||||
|
errorText += results[i];
|
||||||
|
}
|
||||||
|
throw runtime_error(errorText);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
// give CPU time to update other things to avoid apperance of hanging
|
// give CPU time to update other things to avoid apperance of hanging
|
||||||
sleep(0);
|
sleep(0);
|
||||||
SDL_PumpEvents();
|
SDL_PumpEvents();
|
||||||
|
@@ -156,6 +156,22 @@ const int MIN_FPS_NORMAL_RENDERING = 20;
|
|||||||
// ==================== constructor and destructor ====================
|
// ==================== constructor and destructor ====================
|
||||||
|
|
||||||
Renderer::Renderer(){
|
Renderer::Renderer(){
|
||||||
|
this->allowRenderUnitTitles = false;
|
||||||
|
this->menu = NULL;
|
||||||
|
this->game = NULL;
|
||||||
|
showDebugUI = false;
|
||||||
|
modelRenderer = NULL;
|
||||||
|
textRenderer = NULL;
|
||||||
|
particleRenderer = NULL;
|
||||||
|
|
||||||
|
//resources
|
||||||
|
for(int i=0; i<rsCount; ++i){
|
||||||
|
modelManager[i] = NULL;
|
||||||
|
textureManager[i] = NULL;
|
||||||
|
particleManager[i] = NULL;
|
||||||
|
fontManager[i] = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
GraphicsInterface &gi= GraphicsInterface::getInstance();
|
GraphicsInterface &gi= GraphicsInterface::getInstance();
|
||||||
FactoryRepository &fr= FactoryRepository::getInstance();
|
FactoryRepository &fr= FactoryRepository::getInstance();
|
||||||
Config &config= Config::getInstance();
|
Config &config= Config::getInstance();
|
||||||
@@ -163,15 +179,9 @@ Renderer::Renderer(){
|
|||||||
no2DMouseRendering = config.getBool("No2DMouseRendering","false");
|
no2DMouseRendering = config.getBool("No2DMouseRendering","false");
|
||||||
maxConsoleLines= config.getInt("ConsoleMaxLines");
|
maxConsoleLines= config.getInt("ConsoleMaxLines");
|
||||||
|
|
||||||
showDebugUI = false;
|
|
||||||
|
|
||||||
gi.setFactory(fr.getGraphicsFactory(config.getString("FactoryGraphics")));
|
gi.setFactory(fr.getGraphicsFactory(config.getString("FactoryGraphics")));
|
||||||
GraphicsFactory *graphicsFactory= GraphicsInterface::getInstance().getFactory();
|
GraphicsFactory *graphicsFactory= GraphicsInterface::getInstance().getFactory();
|
||||||
|
|
||||||
this->allowRenderUnitTitles = false;
|
|
||||||
this->menu = NULL;
|
|
||||||
this->game = NULL;
|
|
||||||
|
|
||||||
modelRenderer= graphicsFactory->newModelRenderer();
|
modelRenderer= graphicsFactory->newModelRenderer();
|
||||||
textRenderer= graphicsFactory->newTextRenderer2D();
|
textRenderer= graphicsFactory->newTextRenderer2D();
|
||||||
particleRenderer= graphicsFactory->newParticleRenderer();
|
particleRenderer= graphicsFactory->newParticleRenderer();
|
||||||
|
@@ -30,6 +30,7 @@
|
|||||||
#include "font.h"
|
#include "font.h"
|
||||||
#include <curl/curl.h>
|
#include <curl/curl.h>
|
||||||
#include "menu_state_masterserver.h"
|
#include "menu_state_masterserver.h"
|
||||||
|
#include "checksum.h"
|
||||||
|
|
||||||
#include "leak_dumper.h"
|
#include "leak_dumper.h"
|
||||||
|
|
||||||
@@ -415,7 +416,8 @@ int glestMain(int argc, char** argv){
|
|||||||
|
|
||||||
bool haveSpecialOutputCommandLineOption = false;
|
bool haveSpecialOutputCommandLineOption = false;
|
||||||
if( hasCommandArgument(argc, argv,"--opengl-info") == true ||
|
if( hasCommandArgument(argc, argv,"--opengl-info") == true ||
|
||||||
hasCommandArgument(argc, argv,"--version") == true) {
|
hasCommandArgument(argc, argv,"--version") == true ||
|
||||||
|
hasCommandArgument(argc, argv,"--validate-techtrees") == true) {
|
||||||
haveSpecialOutputCommandLineOption = true;
|
haveSpecialOutputCommandLineOption = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -430,7 +432,8 @@ int glestMain(int argc, char** argv){
|
|||||||
}
|
}
|
||||||
|
|
||||||
if( hasCommandArgument(argc, argv,"--version") == true &&
|
if( hasCommandArgument(argc, argv,"--version") == true &&
|
||||||
hasCommandArgument(argc, argv,"--opengl-info") == false) {
|
hasCommandArgument(argc, argv,"--opengl-info") == false &&
|
||||||
|
hasCommandArgument(argc, argv,"validate-factions") == false) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -582,6 +585,79 @@ int glestMain(int argc, char** argv){
|
|||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
if(hasCommandArgument(argc, argv,"--validate-techtrees") == true) {
|
||||||
|
|
||||||
|
Config &config = Config::getInstance();
|
||||||
|
vector<string> results;
|
||||||
|
findDirs(config.getPathListForType(ptTechs), results);
|
||||||
|
vector<string> techTreeFiles = results;
|
||||||
|
World world;
|
||||||
|
|
||||||
|
vector<string> techPaths = config.getPathListForType(ptTechs);
|
||||||
|
for(int idx = 0; idx < techPaths.size(); idx++) {
|
||||||
|
string &techPath = techPaths[idx];
|
||||||
|
for(int idx2 = 0; idx2 < techTreeFiles.size(); idx2++) {
|
||||||
|
string &techName = techTreeFiles[idx2];
|
||||||
|
|
||||||
|
vector<string> factionsList;
|
||||||
|
findAll(techPath + "/" + techName + "/factions/*.", factionsList, false, false);
|
||||||
|
|
||||||
|
if(factionsList.size() > 0) {
|
||||||
|
Checksum checksum;
|
||||||
|
set<string> factions;
|
||||||
|
for(int j = 0; j < factionsList.size(); ++j) {
|
||||||
|
factions.insert(factionsList[j]);
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("\nChecking techPath [%s] techName [%s] factionsList.size() = %d\n",techPath.c_str(), techName.c_str(),factionsList.size());
|
||||||
|
for(int j = 0; j < factionsList.size(); ++j) {
|
||||||
|
printf("Found faction [%s]\n",factionsList[j].c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
world.loadTech(config.getPathListForType(ptTechs,""), techName, factions, &checksum);
|
||||||
|
// Validate the faction setup to ensure we don't have any bad associations
|
||||||
|
std::vector<std::string> resultErrors = world.validateFactionTypes();
|
||||||
|
if(resultErrors.size() > 0) {
|
||||||
|
// Display the validation errors
|
||||||
|
string errorText = "\nErrors were detected:\n=====================\n";
|
||||||
|
for(int i = 0; i < resultErrors.size(); ++i) {
|
||||||
|
if(i > 0) {
|
||||||
|
errorText += "\n";
|
||||||
|
}
|
||||||
|
errorText += resultErrors[i];
|
||||||
|
}
|
||||||
|
errorText += "\n=====================\n";
|
||||||
|
//throw runtime_error(errorText);
|
||||||
|
printf("%s",errorText.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate the faction resource setup to ensure we don't have any bad associations
|
||||||
|
printf("\nChecking resources, count = %d\n",world.getTechTree()->getResourceTypeCount());
|
||||||
|
|
||||||
|
for(int i = 0; i < world.getTechTree()->getResourceTypeCount(); ++i) {
|
||||||
|
printf("Found techtree resource [%s]\n",world.getTechTree()->getResourceType(i)->getName().c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
resultErrors = world.validateResourceTypes();
|
||||||
|
if(resultErrors.size() > 0) {
|
||||||
|
// Display the validation errors
|
||||||
|
string errorText = "\nErrors were detected:\n=====================\n";
|
||||||
|
for(int i = 0; i < resultErrors.size(); ++i) {
|
||||||
|
if(i > 0) {
|
||||||
|
errorText += "\n";
|
||||||
|
}
|
||||||
|
errorText += resultErrors[i];
|
||||||
|
}
|
||||||
|
errorText += "\n=====================\n";
|
||||||
|
//throw runtime_error(errorText);
|
||||||
|
printf("%s",errorText.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if(config.getBool("AllowGameDataSynchCheck","false") == true) {
|
if(config.getBool("AllowGameDataSynchCheck","false") == true) {
|
||||||
vector<string> techDataPaths = config.getPathListForType(ptTechs);
|
vector<string> techDataPaths = config.getPathListForType(ptTechs);
|
||||||
|
@@ -138,6 +138,83 @@ void FactionType::load(const string &dir, const TechTree *techTree, Checksum* ch
|
|||||||
|
|
||||||
FactionType::~FactionType(){
|
FactionType::~FactionType(){
|
||||||
delete music;
|
delete music;
|
||||||
|
music = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> FactionType::validateFactionType() {
|
||||||
|
std::vector<std::string> results;
|
||||||
|
|
||||||
|
// Check every unit's commands to validate that for every upgrade-requirements
|
||||||
|
// upgrade we have a unit that can do the upgrade in the faction.
|
||||||
|
for(int i=0; i<unitTypes.size(); ++i){
|
||||||
|
UnitType &unitType = unitTypes[i];
|
||||||
|
for(int j = 0; j < unitType.getCommandTypeCount(); ++j) {
|
||||||
|
const CommandType *cmdType = unitType.getCommandType(j);
|
||||||
|
if(cmdType != NULL) {
|
||||||
|
for(int k = 0; k < cmdType->getUpgradeReqCount(); ++k) {
|
||||||
|
const UpgradeType *upgradeType = cmdType->getUpgradeReq(k);
|
||||||
|
|
||||||
|
if(upgradeType != NULL) {
|
||||||
|
// Now lets find a unit that can produced-upgrade this upgrade
|
||||||
|
bool foundUpgraderUnit = false;
|
||||||
|
for(int l=0; l<unitTypes.size() && foundUpgraderUnit == false; ++l){
|
||||||
|
UnitType &unitType2 = unitTypes[l];
|
||||||
|
for(int m = 0; m < unitType2.getCommandTypeCount() && foundUpgraderUnit == false; ++m) {
|
||||||
|
const CommandType *cmdType2 = unitType2.getCommandType(m);
|
||||||
|
if(cmdType2 != NULL && dynamic_cast<const UpgradeCommandType *>(cmdType2) != NULL) {
|
||||||
|
const UpgradeCommandType *uct = dynamic_cast<const UpgradeCommandType *>(cmdType2);
|
||||||
|
const UpgradeType *upgradeType2 = uct->getProducedUpgrade();
|
||||||
|
if(upgradeType2 != NULL && upgradeType2->getName() == upgradeType->getName()) {
|
||||||
|
foundUpgraderUnit = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(foundUpgraderUnit == false) {
|
||||||
|
char szBuf[4096]="";
|
||||||
|
sprintf(szBuf,"The Unit [%s] in Faction [%s] has the command [%s]\nwhich has upgrade requirement [%s] but there are no units able to perform the upgrade!",unitType.getName().c_str(),this->getName().c_str(),cmdType->getName().c_str(),upgradeType->getName().c_str());
|
||||||
|
results.push_back(szBuf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> FactionType::validateFactionTypeResourceTypes(vector<ResourceType> &resourceTypes) {
|
||||||
|
std::vector<std::string> results;
|
||||||
|
|
||||||
|
// Check every unit's commands to validate that for every upgrade-requirements
|
||||||
|
// upgrade we have a unit that can do the upgrade in the faction.
|
||||||
|
for(int i=0; i<unitTypes.size(); ++i){
|
||||||
|
UnitType &unitType = unitTypes[i];
|
||||||
|
for(int j = 0; j < unitType.getCostCount() ; ++j) {
|
||||||
|
const Resource *r = unitType.getCost(j);
|
||||||
|
if(r != NULL && r->getType() != NULL) {
|
||||||
|
bool foundResourceType = false;
|
||||||
|
// Now lets find a matching faction resource type for the unit
|
||||||
|
for(int k=0; k<resourceTypes.size(); ++k){
|
||||||
|
ResourceType &rt = resourceTypes[k];
|
||||||
|
|
||||||
|
if(r->getType()->getName() == rt.getName()) {
|
||||||
|
foundResourceType = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(foundResourceType == false) {
|
||||||
|
char szBuf[4096]="";
|
||||||
|
sprintf(szBuf,"The Unit [%s] in Faction [%s] has the resource req [%s]\nbut there are no such resources in this tech!",unitType.getName().c_str(),this->getName().c_str(),r->getType()->getName().c_str());
|
||||||
|
results.push_back(szBuf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==================== get ====================
|
// ==================== get ====================
|
||||||
|
@@ -64,6 +64,8 @@ public:
|
|||||||
int getStartingResourceAmount(const ResourceType *resourceType) const;
|
int getStartingResourceAmount(const ResourceType *resourceType) const;
|
||||||
|
|
||||||
std::string toString() const;
|
std::string toString() const;
|
||||||
|
std::vector<std::string> validateFactionType();
|
||||||
|
std::vector<std::string> validateFactionTypeResourceTypes(vector<ResourceType> &resourceTypes);
|
||||||
};
|
};
|
||||||
|
|
||||||
}}//end namespace
|
}}//end namespace
|
||||||
|
@@ -145,7 +145,6 @@ void TechTree::load(const string &dir, set<string> &factions, Checksum* checksum
|
|||||||
// give CPU time to update other things to avoid apperance of hanging
|
// give CPU time to update other things to avoid apperance of hanging
|
||||||
sleep(0);
|
sleep(0);
|
||||||
SDL_PumpEvents();
|
SDL_PumpEvents();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(const exception &e){
|
catch(const exception &e){
|
||||||
@@ -160,6 +159,24 @@ TechTree::~TechTree(){
|
|||||||
Logger::getInstance().add("Tech tree", true);
|
Logger::getInstance().add("Tech tree", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> TechTree::validateFactionTypes() {
|
||||||
|
std::vector<std::string> results;
|
||||||
|
for (int i = 0; i < factionTypes.size(); ++i) {
|
||||||
|
std::vector<std::string> factionResults = factionTypes[i].validateFactionType();
|
||||||
|
results.insert(results.end(), factionResults.begin(), factionResults.end());
|
||||||
|
}
|
||||||
|
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> TechTree::validateResourceTypes() {
|
||||||
|
std::vector<std::string> results;
|
||||||
|
for (int i = 0; i < factionTypes.size(); ++i) {
|
||||||
|
std::vector<std::string> factionResults = factionTypes[i].validateFactionTypeResourceTypes(resourceTypes);
|
||||||
|
results.insert(results.end(), factionResults.begin(), factionResults.end());
|
||||||
|
}
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
// ==================== get ====================
|
// ==================== get ====================
|
||||||
|
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
// ==============================================================
|
// ==============================================================
|
||||||
// This file is part of Glest (www.glest.org)
|
// This file is part of Glest (www.glest.org)
|
||||||
//
|
//
|
||||||
// Copyright (C) 2001-2008 Marti<EFBFBD>o Figueroa
|
// Copyright (C) 2001-2008 Martio Figueroa
|
||||||
//
|
//
|
||||||
// You can redistribute this code and/or modify it under
|
// You can redistribute this code and/or modify it under
|
||||||
// the terms of the GNU General Public License as published
|
// the terms of the GNU General Public License as published
|
||||||
@@ -60,6 +60,8 @@ public:
|
|||||||
const ArmorType *getArmorType(const string &name) const;
|
const ArmorType *getArmorType(const string &name) const;
|
||||||
const AttackType *getAttackType(const string &name) const;
|
const AttackType *getAttackType(const string &name) const;
|
||||||
float getDamageMultiplier(const AttackType *att, const ArmorType *art) const;
|
float getDamageMultiplier(const AttackType *att, const ArmorType *art) const;
|
||||||
|
std::vector<std::string> validateFactionTypes();
|
||||||
|
std::vector<std::string> validateResourceTypes();
|
||||||
};
|
};
|
||||||
|
|
||||||
}} //end namespace
|
}} //end namespace
|
||||||
|
@@ -190,6 +190,14 @@ void World::loadTech(const vector<string> pathList, const string &techName, set<
|
|||||||
//techCache[techName] = techTree;
|
//techCache[techName] = techTree;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> World::validateFactionTypes() {
|
||||||
|
return techTree->validateFactionTypes();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> World::validateResourceTypes() {
|
||||||
|
return techTree->validateResourceTypes();
|
||||||
|
}
|
||||||
|
|
||||||
//load map
|
//load map
|
||||||
void World::loadMap(const string &path, Checksum *checksum){
|
void World::loadMap(const string &path, Checksum *checksum){
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
@@ -182,6 +182,9 @@ public:
|
|||||||
|
|
||||||
Game * getGame() { return game; }
|
Game * getGame() { return game; }
|
||||||
|
|
||||||
|
std::vector<std::string> validateFactionTypes();
|
||||||
|
std::vector<std::string> validateResourceTypes();
|
||||||
|
|
||||||
void setFogOfWar(bool value);
|
void setFogOfWar(bool value);
|
||||||
std::string DumpWorldToLog(bool consoleBasicInfoOnly = false) const;
|
std::string DumpWorldToLog(bool consoleBasicInfoOnly = false) const;
|
||||||
|
|
||||||
|
49
source/shared_lib/include/graphics/font_manager.h
Normal file
49
source/shared_lib/include/graphics/font_manager.h
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
// ==============================================================
|
||||||
|
// This file is part of Glest Shared Library (www.glest.org)
|
||||||
|
//
|
||||||
|
// Copyright (C) 2001-2008 Martio 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
|
||||||
|
// ==============================================================
|
||||||
|
|
||||||
|
#ifndef _SHARED_GRAPHICS_FONTMANAGER_H_
|
||||||
|
#define _SHARED_GRAPHICS_FONTMANAGER_H_
|
||||||
|
|
||||||
|
#include "font.h"
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
namespace Shared{ namespace Graphics{
|
||||||
|
|
||||||
|
// =====================================================
|
||||||
|
// class FontManager
|
||||||
|
//
|
||||||
|
/// Creates, Intializes, Finalizes, and Deletes fonts
|
||||||
|
// =====================================================
|
||||||
|
|
||||||
|
class FontManager{
|
||||||
|
protected:
|
||||||
|
typedef vector<Font*> FontContainer;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
FontContainer fonts;
|
||||||
|
|
||||||
|
public:
|
||||||
|
FontManager();
|
||||||
|
virtual ~FontManager();
|
||||||
|
|
||||||
|
Font2D *newFont2D();
|
||||||
|
Font3D *newFont3D();
|
||||||
|
|
||||||
|
void init();
|
||||||
|
void end();
|
||||||
|
};
|
||||||
|
|
||||||
|
}}//end namespace
|
||||||
|
|
||||||
|
#endif
|
62
source/shared_lib/sources/graphics/font_manager.cpp
Normal file
62
source/shared_lib/sources/graphics/font_manager.cpp
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
// ==============================================================
|
||||||
|
// This file is part of Glest Shared Library (www.glest.org)
|
||||||
|
//
|
||||||
|
// Copyright (C) 2001-2008 Martio 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 "font_manager.h"
|
||||||
|
|
||||||
|
#include "graphics_interface.h"
|
||||||
|
#include "graphics_factory.h"
|
||||||
|
#include "leak_dumper.h"
|
||||||
|
|
||||||
|
namespace Shared{ namespace Graphics{
|
||||||
|
|
||||||
|
// =====================================================
|
||||||
|
// class FontManager
|
||||||
|
// =====================================================
|
||||||
|
FontManager::FontManager(){
|
||||||
|
fonts.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
FontManager::~FontManager(){
|
||||||
|
end();
|
||||||
|
}
|
||||||
|
|
||||||
|
Font2D *FontManager::newFont2D(){
|
||||||
|
Font2D *font= GraphicsInterface::getInstance().getFactory()->newFont2D();
|
||||||
|
fonts.push_back(font);
|
||||||
|
return font;
|
||||||
|
}
|
||||||
|
|
||||||
|
Font3D *FontManager::newFont3D(){
|
||||||
|
Font3D *font= GraphicsInterface::getInstance().getFactory()->newFont3D();
|
||||||
|
fonts.push_back(font);
|
||||||
|
return font;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FontManager::init(){
|
||||||
|
for(size_t i=0; i<fonts.size(); ++i){
|
||||||
|
if(fonts[i] != NULL) {
|
||||||
|
fonts[i]->init();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FontManager::end(){
|
||||||
|
for(size_t i=0; i<fonts.size(); ++i){
|
||||||
|
if(fonts[i] != NULL) {
|
||||||
|
fonts[i]->end();
|
||||||
|
delete fonts[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fonts.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}}//end namespace
|
77
source/shared_lib/sources/graphics/gl/font_gl.cpp
Normal file
77
source/shared_lib/sources/graphics/gl/font_gl.cpp
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
// ==============================================================
|
||||||
|
// This file is part of Glest Shared Library (www.glest.org)
|
||||||
|
//
|
||||||
|
// Copyright (C) 2001-2008 Martio 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 "font_gl.h"
|
||||||
|
|
||||||
|
#include "opengl.h"
|
||||||
|
#include "gl_wrap.h"
|
||||||
|
#include "leak_dumper.h"
|
||||||
|
|
||||||
|
namespace Shared{ namespace Graphics{ namespace Gl{
|
||||||
|
|
||||||
|
using namespace Platform;
|
||||||
|
|
||||||
|
// =====================================================
|
||||||
|
// class Font2DGl
|
||||||
|
// =====================================================
|
||||||
|
|
||||||
|
void Font2DGl::init(){
|
||||||
|
assertGl();
|
||||||
|
|
||||||
|
if(!inited){
|
||||||
|
handle= glGenLists(charCount);
|
||||||
|
createGlFontBitmaps(handle, type, size, width, charCount, metrics);
|
||||||
|
inited= true;
|
||||||
|
}
|
||||||
|
|
||||||
|
assertGl();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Font2DGl::end(){
|
||||||
|
assertGl();
|
||||||
|
|
||||||
|
if(inited){
|
||||||
|
//assert(glIsList(handle));
|
||||||
|
glDeleteLists(handle, 1);
|
||||||
|
inited= false;
|
||||||
|
}
|
||||||
|
|
||||||
|
assertGl();
|
||||||
|
}
|
||||||
|
|
||||||
|
// =====================================================
|
||||||
|
// class Font3DGl
|
||||||
|
// =====================================================
|
||||||
|
|
||||||
|
void Font3DGl::init(){
|
||||||
|
assertGl();
|
||||||
|
|
||||||
|
if(!inited){
|
||||||
|
handle= glGenLists(charCount);
|
||||||
|
createGlFontOutlines(handle, type, width, depth, charCount, metrics);
|
||||||
|
inited= true;
|
||||||
|
}
|
||||||
|
|
||||||
|
assertGl();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Font3DGl::end(){
|
||||||
|
assertGl();
|
||||||
|
|
||||||
|
if(inited){
|
||||||
|
assert(glIsList(handle));
|
||||||
|
glDeleteLists(handle, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
assertGl();
|
||||||
|
}
|
||||||
|
|
||||||
|
}}}//end namespace
|
Reference in New Issue
Block a user