diff --git a/source/configurator/configuration.cpp b/source/configurator/configuration.cpp index 0d94ab37..ef51fa3a 100644 --- a/source/configurator/configuration.cpp +++ b/source/configurator/configuration.cpp @@ -19,7 +19,7 @@ namespace Configurator{ Configuration::~Configuration(){ - for(int i= 0; igetChildCount()); - for(int i=0; igetChild("field-group", i); FieldGroup *fieldGroup= new FieldGroup(); fieldGroup->load(fieldGroupNode); @@ -73,9 +73,9 @@ void Configuration::loadValues(const string &path){ properties.load(path); - for(int i=0; igetFieldCount(); ++j){ + for(unsigned int j=0; jgetFieldCount(); ++j){ Field *f= fg->getField(j); f->setValue(properties.getString(f->getVariableName(),"")); } @@ -87,9 +87,9 @@ void Configuration::save(){ properties.load(fileName); - for(int i=0; igetFieldCount(); ++j){ + for(unsigned int j=0; jgetFieldCount(); ++j){ Field *f= fg->getField(j); f->updateValue(); if(!f->isValueValid(f->getValue())){ @@ -112,7 +112,7 @@ string Field::getInfo() const{ // =============================================== FieldGroup::~FieldGroup(){ - for(int i= 0; igetAttribute("name")->getValue(); fields.resize(groupNode->getChildCount()); - for(int i=0; igetChild("field", i); Field *f= newField(fieldNode->getAttribute("type")->getValue()); @@ -290,7 +290,7 @@ bool StringField::isValueValid(const string &value){ void EnumField::createControl(wxWindow *parent, wxSizer *sizer){ comboBox= new wxComboBox(parent, -1, Configuration::ToUnicode(""), wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY); - for(int i=0; iAppend(Configuration::ToUnicode(enumerants[i].c_str())); } comboBox->SetValue(Configuration::ToUnicode(value.c_str())); @@ -311,7 +311,7 @@ bool EnumField::isValueValid(const string &value){ void EnumField::loadSpecific(const XmlNode *fieldNode){ const XmlNode *enumsNode= fieldNode->getChild("enums"); - for(int i=0; igetChildCount(); ++i){ + for(unsigned int i=0; igetChildCount(); ++i){ const XmlNode *enumNode= enumsNode->getChild("enum", i); enumerants.push_back(enumNode->getAttribute("value")->getValue()); } diff --git a/source/configurator/configuration.h b/source/configurator/configuration.h index 60359d22..21b48b33 100644 --- a/source/configurator/configuration.h +++ b/source/configurator/configuration.h @@ -52,7 +52,7 @@ public: bool getIcon() const {return icon;} const string &getIconPath() const {return iconPath;} - int getFieldGroupCount() const {return fieldGroups.size();} + size_t getFieldGroupCount() const {return fieldGroups.size();} FieldGroup *getFieldGroup(int i) const {return fieldGroups[i];} static wxString ToUnicode(const char* str) { @@ -80,7 +80,7 @@ private: public: ~FieldGroup(); - int getFieldCount() const {return fields.size();} + size_t getFieldCount() const {return fields.size();} Field *getField(int i) const {return fields[i];} const string &getName() const {return name;} diff --git a/source/configurator/main.cpp b/source/configurator/main.cpp index 7e0e8d2f..74226d2e 100644 --- a/source/configurator/main.cpp +++ b/source/configurator/main.cpp @@ -54,7 +54,7 @@ MainWindow::MainWindow() : topSizer->Add(notebook, 0, wxALL, 0); mainSizer->Add(topSizer, 0, wxALL, margin); - for(int i=0; iAdd(gridSizer, 0, wxALL, panelMargin); panel->SetSizer(panelSizer); - for(int j=0; jgetFieldCount(); ++j){ + for(unsigned int j=0; jgetFieldCount(); ++j){ Field *f= fg->getField(j); FieldText *staticText= new FieldText(panel, this, f); staticText->SetAutoLayout(true); @@ -120,9 +120,9 @@ void MainWindow::onButtonCancel(wxCommandEvent &event){ } void MainWindow::onButtonDefault(wxCommandEvent &event){ - for(int i=0; igetFieldCount(); ++j){ + for(unsigned int j=0; jgetFieldCount(); ++j){ Field *f= fg->getField(j); f->setValue(f->getDefaultValue()); f->updateControl(); diff --git a/source/g3d_viewer/main.cpp b/source/g3d_viewer/main.cpp index 7dc95335..fbcebc60 100644 --- a/source/g3d_viewer/main.cpp +++ b/source/g3d_viewer/main.cpp @@ -281,7 +281,7 @@ void MainWindow::loadModel(string path) { this->modelPathList.push_back(path); } - for(int idx =0; idx < this->modelPathList.size(); idx++) { + for(unsigned int idx =0; idx < this->modelPathList.size(); idx++) { string modelPath = this->modelPathList[idx]; timer->Stop(); @@ -313,7 +313,7 @@ void MainWindow::loadParticle(string path) { } if(this->particlePathList.size() > 0) { - for(int idx = 0; idx < this->particlePathList.size(); idx++) { + for(unsigned int idx = 0; idx < this->particlePathList.size(); idx++) { string particlePath = this->particlePathList[idx]; string dir= extractDirectoryPathFromFile(particlePath); @@ -392,7 +392,7 @@ void MainWindow::loadProjectileParticle(string path) { if(this->particleProjectilePathList.size() > 0) { - for(int idx = 0; idx < this->particleProjectilePathList.size(); idx++) { + for(unsigned int idx = 0; idx < this->particleProjectilePathList.size(); idx++) { string particlePath = this->particleProjectilePathList[idx]; string dir= extractDirectoryPathFromFile(particlePath); diff --git a/source/glest_game/global/core_data.h b/source/glest_game/global/core_data.h index dcea3412..e3b5f3cc 100644 --- a/source/glest_game/global/core_data.h +++ b/source/glest_game/global/core_data.h @@ -76,7 +76,7 @@ public: Texture2D *getButtonSmallTexture() const {return buttonSmallTexture;} Texture2D *getButtonBigTexture() const {return buttonBigTexture;} - int getLogoTextureExtraCount() const {return logoTextureList.size();} + size_t getLogoTextureExtraCount() const {return logoTextureList.size();} Texture2D *getLogoTextureExtra(int idx) const {return logoTextureList[idx];} StrSound *getIntroMusic() {return &introMusic;} diff --git a/source/glest_map_editor/map.cpp b/source/glest_map_editor/map.cpp index 9509c5a4..677d497a 100644 --- a/source/glest_map_editor/map.cpp +++ b/source/glest_map_editor/map.cpp @@ -76,8 +76,8 @@ int Map::getStartLocationY(int index) const { } static int get_dist(int delta_x, int delta_y) { - float dx = delta_x; - float dy = delta_y; + float dx = (float) delta_x; + float dy = (float)delta_y; return static_cast(sqrtf(dx * dx + dy * dy)); } @@ -127,7 +127,7 @@ void Map::pirateChangeHeight(int x, int y, int height, int radius) { // If the radius is 1 don't bother doing any calculations if (radius == 1) { if(inside(x, y)){ - cells[x][y].height = goalAlt; + cells[x][y].height = (float)goalAlt; } return; } diff --git a/source/glest_map_editor/program.cpp b/source/glest_map_editor/program.cpp index 5b68d522..c3969b14 100644 --- a/source/glest_map_editor/program.cpp +++ b/source/glest_map_editor/program.cpp @@ -159,7 +159,7 @@ int Program::getObject(int x, int y) { int i=(x - ofsetX) / cellSize; int j= (y + ofsetY) / cellSize; if (map->inside(i, j)) { - map->getObject(i,j); + return map->getObject(i,j); } else{ return 0; @@ -170,7 +170,7 @@ int Program::getResource(int x, int y) { int i=(x - ofsetX) / cellSize; int j= (y + ofsetY) / cellSize; if (map->inside(i, j)) { - map->getResource(i,j); + return map->getResource(i,j); } else{ return 0; diff --git a/source/shared_lib/include/graphics/FileReader.h b/source/shared_lib/include/graphics/FileReader.h index 9f832a01..b186ca64 100644 --- a/source/shared_lib/include/graphics/FileReader.h +++ b/source/shared_lib/include/graphics/FileReader.h @@ -242,7 +242,7 @@ FileReader::FileReader(std::vector extensions): extensions(extensions //string const * nextExtension = extensions; std::vector nextExtension = extensions; //while (((*nextExtension) != "")) { - for(int i = 0; i < nextExtension.size(); ++i) { + for(unsigned int i = 0; i < nextExtension.size(); ++i) { //vector const* >* curPossibleReaders = (getFileReadersMap())[*nextExtension]; vector const* >* curPossibleReaders = (getFileReadersMap())[nextExtension[i]]; if (curPossibleReaders == NULL) { @@ -264,7 +264,7 @@ bool FileReader::canRead(const string& filepath) const { //const string* haveExtension = extensions; std::vector haveExtension = extensions; //while (*haveExtension != "") { - for(int i = 0; i < haveExtension.size(); ++i) { + for(unsigned int i = 0; i < haveExtension.size(); ++i) { //if (realExtension == *haveExtension) { if (realExtension == haveExtension[i]) { return true; diff --git a/source/shared_lib/include/util/properties.h b/source/shared_lib/include/util/properties.h index 568abaf2..64224c4e 100644 --- a/source/shared_lib/include/util/properties.h +++ b/source/shared_lib/include/util/properties.h @@ -49,7 +49,7 @@ public: void load(const string &path); void save(const string &path); - int getPropertyCount() {return propertyVector.size();} + int getPropertyCount() {return (int)propertyVector.size();} string getKey(int i) {return propertyVector[i].first;} string getString(int i) {return propertyVector[i].second;} diff --git a/source/shared_lib/include/xml/xml_parser.h b/source/shared_lib/include/xml/xml_parser.h index ecfb850e..7dd962dd 100644 --- a/source/shared_lib/include/xml/xml_parser.h +++ b/source/shared_lib/include/xml/xml_parser.h @@ -105,10 +105,10 @@ public: size_t getAttributeCount() const {return attributes.size();} const string &getText() const {return text;} - XmlAttribute *getAttribute(int i) const; + XmlAttribute *getAttribute(unsigned int i) const; XmlAttribute *getAttribute(const string &name) const; - XmlNode *getChild(int i) const; - XmlNode *getChild(const string &childName, int childIndex=0) const; + XmlNode *getChild(unsigned int i) const; + XmlNode *getChild(const string &childName, unsigned int childIndex=0) const; bool hasChildAtIndex(const string &childName, int childIndex=0) const; bool hasChild(const string &childName) const; XmlNode *getParent() const; diff --git a/source/shared_lib/sources/graphics/JPGReader.cpp b/source/shared_lib/sources/graphics/JPGReader.cpp index a940b7f8..52d15bf7 100644 --- a/source/shared_lib/sources/graphics/JPGReader.cpp +++ b/source/shared_lib/sources/graphics/JPGReader.cpp @@ -79,7 +79,7 @@ Pixmap2D* JPGReader::read(ifstream& is, const string& path, Pixmap2D* ret) const } is.seekg(0, ios::beg); uint8 *buffer = new uint8[length]; - is.read((char*)buffer, length); + is.read((char*)buffer, (std::streamsize)length); //Check buffer (weak jpeg check) //if (buffer[0] != 0x46 || buffer[1] != 0xA0) { // Proper header check found from: http://www.fastgraph.com/help/jpeg_header_format.html diff --git a/source/shared_lib/sources/graphics/PNGReader.cpp b/source/shared_lib/sources/graphics/PNGReader.cpp index d62d7f4c..8833a2d8 100644 --- a/source/shared_lib/sources/graphics/PNGReader.cpp +++ b/source/shared_lib/sources/graphics/PNGReader.cpp @@ -32,7 +32,7 @@ namespace Shared{ namespace Graphics{ static void user_read_data(png_structp read_ptr, png_bytep data, png_size_t length) { ifstream& is = *((ifstream*)png_get_io_ptr(read_ptr)); - is.read((char*)data,length); + is.read((char*)data,(std::streamsize)length); if (!is.good()) { png_error(read_ptr,"Could not read from png-file"); } @@ -120,21 +120,21 @@ Pixmap2D* PNGReader::read(ifstream& is, const string& path, Pixmap2D* ret) const row_pointers[y] = new png_byte[info_ptr->rowbytes]; } png_read_image(png_ptr, row_pointers); - int fileComponents = info_ptr->rowbytes/info_ptr->width; - int picComponents = (ret->getComponents()==-1)?fileComponents:ret->getComponents(); + size_t fileComponents = info_ptr->rowbytes/info_ptr->width; + size_t picComponents = (ret->getComponents()==-1)?fileComponents:ret->getComponents(); //std::cout << "PNG-Components: Pic: " << picComponents << " old: " << (ret->getComponents()) << " File: " << fileComponents << std::endl; //picComponents = 4; //Copy image - ret->init(width,height,picComponents); + ret->init(width,height,(int)picComponents); uint8* pixels = ret->getPixels(); - const int rowbytes = info_ptr->rowbytes; - int location = 0; + const size_t rowbytes = info_ptr->rowbytes; + size_t location = 0; for (int y = height-1; y >= 0; --y) { //you have to somehow invert the lines if (picComponents == fileComponents) { memcpy(pixels+location,row_pointers[y],rowbytes); } else { int r,g,b,a,l; - for (int xPic = 0, xFile = 0; xFile < rowbytes; xPic+= picComponents, xFile+= fileComponents) { + for (size_t xPic = 0, xFile = 0; xFile < rowbytes; xPic+= picComponents, xFile+= fileComponents) { switch(fileComponents) { case 3: r = row_pointers[y][xFile]; @@ -170,14 +170,14 @@ Pixmap2D* PNGReader::read(ifstream& is, const string& path, Pixmap2D* ret) const break; default: //just so at least something works - for (int i = 0; i < picComponents; ++i) { + for (unsigned int i = 0; i < picComponents; ++i) { pixels[location+xPic+i] = l; } //TODO: Error } } } - location+=picComponents*width; + location += picComponents * width; } for (int y = 0; y < height; ++y) { diff --git a/source/shared_lib/sources/graphics/font.cpp b/source/shared_lib/sources/graphics/font.cpp index 59ad0a5c..ff470b78 100644 --- a/source/shared_lib/sources/graphics/font.cpp +++ b/source/shared_lib/sources/graphics/font.cpp @@ -42,7 +42,7 @@ FontMetrics::~FontMetrics(){ float FontMetrics::getTextWidth(const string &str) const{ float width= 0.f; - for(unsigned int i=0; i< str.size() && i < Font::charCount; ++i){ + for(unsigned int i=0; i< str.size() && (int)i < Font::charCount; ++i){ if(str[i] >= Font::charCount) { string sError = "str[i] >= Font::charCount, [" + str + "] i = " + intToStr(i); throw runtime_error(sError); diff --git a/source/shared_lib/sources/graphics/gl/context_gl.cpp b/source/shared_lib/sources/graphics/gl/context_gl.cpp index 50de09c9..f0f16eb0 100644 --- a/source/shared_lib/sources/graphics/gl/context_gl.cpp +++ b/source/shared_lib/sources/graphics/gl/context_gl.cpp @@ -33,7 +33,7 @@ ContextGl::ContextGl() : Context() { void ContextGl::init(){ //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); - pcgl.init(colorBits, depthBits, stencilBits, hardware_acceleration, fullscreen_anti_aliasing); + pcgl.init(colorBits, depthBits, stencilBits, (hardware_acceleration != 0), (fullscreen_anti_aliasing != 0)); //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); } diff --git a/source/shared_lib/sources/graphics/gl/model_renderer_gl.cpp b/source/shared_lib/sources/graphics/gl/model_renderer_gl.cpp index 77d9bf07..d6665f30 100644 --- a/source/shared_lib/sources/graphics/gl/model_renderer_gl.cpp +++ b/source/shared_lib/sources/graphics/gl/model_renderer_gl.cpp @@ -214,7 +214,7 @@ void ModelRendererGl::renderMesh(const Mesh *mesh){ void ModelRendererGl::renderMeshNormals(const Mesh *mesh){ glBegin(GL_LINES); - for(int i= 0; igetIndexCount(); ++i){ + for(unsigned int i= 0; igetIndexCount(); ++i){ const Vec3f &vertex= mesh->getInterpolationData()->getVertices()[mesh->getIndices()[i]]; const Vec3f &normal= vertex + mesh->getInterpolationData()->getNormals()[mesh->getIndices()[i]]; diff --git a/source/shared_lib/sources/graphics/gl/opengl.cpp b/source/shared_lib/sources/graphics/gl/opengl.cpp index 85bb0cbc..12d8e38f 100644 --- a/source/shared_lib/sources/graphics/gl/opengl.cpp +++ b/source/shared_lib/sources/graphics/gl/opengl.cpp @@ -28,12 +28,9 @@ namespace Shared{ namespace Graphics{ namespace Gl{ // ===================================================== bool isGlExtensionSupported(const char *extensionName){ - const char *s; - GLint len; const GLubyte *extensionStr= glGetString(GL_EXTENSIONS); - - s= reinterpret_cast(extensionStr); - len= strlen(extensionName); + const char *s= reinterpret_cast(extensionStr); + size_t len= strlen(extensionName); if(s != NULL) { while ((s = strstr (s, extensionName)) != NULL) { diff --git a/source/shared_lib/sources/graphics/gl/shader_gl.cpp b/source/shared_lib/sources/graphics/gl/shader_gl.cpp new file mode 100755 index 00000000..a592d528 --- /dev/null +++ b/source/shared_lib/sources/graphics/gl/shader_gl.cpp @@ -0,0 +1,246 @@ +// ============================================================== +// 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 "shader_gl.h" + +#include + +#include "opengl.h" +#include "leak_dumper.h" + +using namespace std; + +namespace Shared{ namespace Graphics{ namespace Gl{ + +// ===================================================== +// class ShaderProgramGl +// ===================================================== + +ShaderProgramGl::ShaderProgramGl(){ + inited= false; +} + +void ShaderProgramGl::init(){ + if(!inited){ + assertGl(); + handle= glCreateProgramObjectARB(); + assertGl(); + inited= true; + } +} + +void ShaderProgramGl::end(){ + if(inited){ + assertGl(); + glDeleteObjectARB(handle); + assertGl(); + inited= false; + } +} + +void ShaderProgramGl::attach(VertexShader *vertexShader, FragmentShader *fragmentShader){ + this->vertexShader= vertexShader; + this->fragmentShader= fragmentShader; +} + +bool ShaderProgramGl::link(string &messages){ + assertGl(); + + VertexShaderGl *vertexShaderGl= static_cast(vertexShader); + FragmentShaderGl *fragmentShaderGl= static_cast(fragmentShader); + + const ShaderSource *vss= vertexShaderGl->getSource(); + const ShaderSource *fss= fragmentShaderGl->getSource(); + messages= "Linking program: " + vss->getPathInfo() + ", " + fss->getPathInfo() + "\n"; + + //attach + glAttachObjectARB(handle, vertexShaderGl->getHandle()); + glAttachObjectARB(handle, fragmentShaderGl->getHandle()); + + assertGl(); + + //bind attributes + for(unsigned int i=0; i 0) { found = true; - int index = models.size()-1; + size_t index = models.size()-1; Model *curModel = models[index]; models.erase(models.begin() + index); diff --git a/source/shared_lib/sources/graphics/particle.cpp b/source/shared_lib/sources/graphics/particle.cpp index d6323f58..c3074a3d 100644 --- a/source/shared_lib/sources/graphics/particle.cpp +++ b/source/shared_lib/sources/graphics/particle.cpp @@ -74,7 +74,7 @@ ParticleSystem::~ParticleSystem(){ //updates all living particles and creates new ones void ParticleSystem::update() { - if(aliveParticleCount > particles.size()) { + if(aliveParticleCount > (int)particles.size()) { throw runtime_error("aliveParticleCount >= particles.size()"); } @@ -96,7 +96,7 @@ void ParticleSystem::update() { if(state != ParticleSystem::sFade){ emissionState=emissionState+emissionRate; - int emissionIntValue=emissionState; + int emissionIntValue=(int)emissionState; for(int i = 0; i < emissionIntValue; i++){ Particle *p = createParticle(); initParticle(p, i); @@ -931,7 +931,7 @@ ParticleManager::~ParticleManager(){ } void ParticleManager::render(ParticleRenderer *pr, ModelRenderer *mr) const{ - for (int i = 0; i < particleSystems.size(); i++) { + for (unsigned int i = 0; i < particleSystems.size(); i++) { ParticleSystem *ps = particleSystems[i]; if(ps != NULL && ps->getVisible()) { ps->render(pr, mr); @@ -943,11 +943,11 @@ void ParticleManager::update(int renderFps) { Chrono chrono; chrono.start(); - int particleSystemCount = particleSystems.size(); + size_t particleSystemCount = particleSystems.size(); int currentParticleCount = 0; vector cleanupParticleSystemsList; - for (int i = 0; i < particleSystems.size(); i++) { + for (unsigned int i = 0; i < particleSystems.size(); i++) { ParticleSystem *ps = particleSystems[i]; if(ps != NULL) { currentParticleCount += ps->getAliveParticleCount(); @@ -980,7 +980,7 @@ bool ParticleManager::validateParticleSystemStillExists(ParticleSystem * particl int ParticleManager::findParticleSystems(ParticleSystem *psFind, const vector &particleSystems) const { int result = -1; - for (int i = 0; i < particleSystems.size(); i++) { + for (unsigned int i = 0; i < particleSystems.size(); i++) { ParticleSystem *ps = particleSystems[i]; if(ps != NULL && psFind != NULL && psFind == ps) { result = i; @@ -1001,7 +1001,7 @@ void ParticleManager::cleanupParticleSystems(ParticleSystem *ps) { void ParticleManager::cleanupParticleSystems(vector &particleSystems) { - for (int i = 0; i < particleSystems.size(); i++) { + for (unsigned int i = 0; i < particleSystems.size(); i++) { ParticleSystem *ps = particleSystems[i]; cleanupParticleSystems(ps); } @@ -1012,7 +1012,7 @@ void ParticleManager::cleanupParticleSystems(vector &particleS void ParticleManager::cleanupUnitParticleSystems(vector &particleSystems) { - for (int i = 0; i < particleSystems.size(); i++) { + for (unsigned int i = 0; i < particleSystems.size(); i++) { ParticleSystem *ps = particleSystems[i]; cleanupParticleSystems(ps); } diff --git a/source/shared_lib/sources/graphics/shader_manager.cpp b/source/shared_lib/sources/graphics/shader_manager.cpp new file mode 100644 index 00000000..588b3c60 --- /dev/null +++ b/source/shared_lib/sources/graphics/shader_manager.cpp @@ -0,0 +1,75 @@ +// ============================================================== +// 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 "shader_manager.h" + +#include + +#include "graphics_interface.h" +#include "graphics_factory.h" +#include "leak_dumper.h" + +namespace Shared{ namespace Graphics{ + +// ===================================================== +// class ShaderManager +// ===================================================== + +ShaderManager::~ShaderManager(){ +} + +void ShaderManager::init(){ + for(unsigned int i=0; iinit(); + if(!shaders[i]->compile(logString)){ + throw runtime_error("Can't compile shader\n"); + } + } + for(unsigned int i=0; iinit(); + if(!shaderPrograms[i]->link(logString)){ + throw runtime_error("Can't link shader\n"); + } + } +} + +void ShaderManager::end(){ + for(unsigned int i=0; iend(); + delete shaderPrograms[i]; + } + shaderPrograms.clear(); + for(unsigned int i=0; iend(); + delete shaders[i]; + } + shaders.clear(); +} + +ShaderProgram *ShaderManager::newShaderProgram(){ + ShaderProgram *sp= GraphicsInterface::getInstance().getFactory()->newShaderProgram(); + shaderPrograms.push_back(sp); + return sp; +} + +VertexShader *ShaderManager::newVertexShader(){ + VertexShader *vs= GraphicsInterface::getInstance().getFactory()->newVertexShader(); + shaders.push_back(vs); + return vs; +} + +FragmentShader *ShaderManager::newFragmentShader(){ + FragmentShader *fs= GraphicsInterface::getInstance().getFactory()->newFragmentShader(); + shaders.push_back(fs); + return fs; +} + +}}//end namespace diff --git a/source/shared_lib/sources/graphics/texture_manager.cpp b/source/shared_lib/sources/graphics/texture_manager.cpp index 3325c16a..98854db2 100644 --- a/source/shared_lib/sources/graphics/texture_manager.cpp +++ b/source/shared_lib/sources/graphics/texture_manager.cpp @@ -43,7 +43,7 @@ void TextureManager::initTexture(Texture *texture) { void TextureManager::endTexture(Texture *texture,bool mustExistInList) { if(texture != NULL) { bool found = false; - for(int idx = 0; idx < textures.size(); idx++) { + for(unsigned int idx = 0; idx < textures.size(); idx++) { Texture *curTexture = textures[idx]; if(curTexture == texture) { found = true; @@ -63,7 +63,7 @@ void TextureManager::endLastTexture(bool mustExistInList) { bool found = false; if(textures.size() > 0) { found = true; - int index = textures.size()-1; + int index = (int)textures.size()-1; Texture *curTexture = textures[index]; textures.erase(textures.begin() + index); @@ -76,7 +76,7 @@ void TextureManager::endLastTexture(bool mustExistInList) { } void TextureManager::init(bool forceInit) { - for(int i=0; iend(); delete textures[i]; @@ -107,7 +107,7 @@ void TextureManager::setMaxAnisotropy(int maxAnisotropy){ } Texture *TextureManager::getTexture(const string &path){ - for(int i=0; igetPath()==path){ return textures[i]; } diff --git a/source/shared_lib/sources/map/map_preview.cpp b/source/shared_lib/sources/map/map_preview.cpp index 20c897e8..02c3a28e 100644 --- a/source/shared_lib/sources/map/map_preview.cpp +++ b/source/shared_lib/sources/map/map_preview.cpp @@ -81,8 +81,8 @@ int MapPreview::getStartLocationY(int index) const { } static int get_dist(int delta_x, int delta_y) { - float dx = delta_x; - float dy = delta_y; + float dx = (float)delta_x; + float dy = (float)delta_y; return static_cast(sqrtf(dx * dx + dy * dy)); } @@ -131,7 +131,7 @@ void MapPreview::pirateChangeHeight(int x, int y, int height, int radius) { // If the radius is 1 don't bother doing any calculations if (radius == 1) { if(inside(x, y)){ - cells[x][y].height = goalAlt; + cells[x][y].height = (float)goalAlt; } return; } diff --git a/source/shared_lib/sources/platform/posix/socket.cpp b/source/shared_lib/sources/platform/posix/socket.cpp index 1cc36112..a4d92033 100644 --- a/source/shared_lib/sources/platform/posix/socket.cpp +++ b/source/shared_lib/sources/platform/posix/socket.cpp @@ -980,7 +980,7 @@ int Socket::getDataToRead(bool wantImmediateReply) { int Socket::send(const void *data, int dataSize) { //SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); - ssize_t bytesSent= 0; + int bytesSent= 0; if(isSocketValid() == true) { //SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); errno = 0; @@ -1035,7 +1035,7 @@ int Socket::send(const void *data, int dataSize) { SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] need to send more data, trying again getLastSocketError() = %d, bytesSent = %d, dataSize = %d\n",__FILE__,__FUNCTION__,__LINE__,getLastSocketError(),bytesSent,dataSize); MutexSafeWrapper safeMutex(&dataSynchAccessor); - ssize_t totalBytesSent = bytesSent; + int totalBytesSent = bytesSent; int attemptCount = 0; time_t tStartTimer = time(NULL); while(((bytesSent > 0 && totalBytesSent < dataSize) || diff --git a/source/shared_lib/sources/sound/ds8/sound_player_ds8.cpp b/source/shared_lib/sources/sound/ds8/sound_player_ds8.cpp index 5fbd25a0..9353bfda 100644 --- a/source/shared_lib/sources/sound/ds8/sound_player_ds8.cpp +++ b/source/shared_lib/sources/sound/ds8/sound_player_ds8.cpp @@ -420,7 +420,7 @@ void SoundPlayerDs8::play(StrSound *strSound, int64 fadeOn){ void SoundPlayerDs8::stop(StrSound *strSound, int64 fadeOff){ if(initOk == false) return; //find the buffer with this sound and stop it - for(int i= 0; ipath= path; diff --git a/source/shared_lib/sources/xml/xml_parser.cpp b/source/shared_lib/sources/xml/xml_parser.cpp index 25241b61..cd302dcd 100644 --- a/source/shared_lib/sources/xml/xml_parser.cpp +++ b/source/shared_lib/sources/xml/xml_parser.cpp @@ -233,7 +233,7 @@ XmlNode::~XmlNode(){ } } -XmlAttribute *XmlNode::getAttribute(int i) const{ +XmlAttribute *XmlNode::getAttribute(unsigned int i) const{ if(i>=attributes.size()){ throw runtime_error(getName()+" node doesn't have "+intToStr(i)+" attributes"); } @@ -249,14 +249,14 @@ XmlAttribute *XmlNode::getAttribute(const string &name) const{ throw runtime_error("\"" + getName() + "\" node doesn't have a attribute named \"" + name + "\""); } -XmlNode *XmlNode::getChild(int i) const { +XmlNode *XmlNode::getChild(unsigned int i) const { if(i>=children.size()) throw runtime_error("\"" + getName()+"\" node doesn't have "+intToStr(i+1)+" children"); return children[i]; } -XmlNode *XmlNode::getChild(const string &childName, int i) const{ +XmlNode *XmlNode::getChild(const string &childName, unsigned int i) const{ if(i>=children.size()){ throw runtime_error("\"" + name + "\" node doesn't have "+intToStr(i+1)+" children named \"" + childName + "\"\n\nTree: "+getTreeString()); }