many changes and refactoring

This commit is contained in:
Eduardo Bart
2011-07-13 18:12:36 -03:00
parent 6c05ee0e82
commit 8ef1b28546
120 changed files with 1545 additions and 1273 deletions

View File

@@ -25,8 +25,8 @@
#ifndef ANIMATEDTEXTURE_H
#define ANIMATEDTEXTURE_H
#include <prerequisites.h>
#include <graphics/texture.h>
#include <global.h>
#include <graphics/graphics.h>
class AnimatedTexture : public Texture
{

View File

@@ -22,7 +22,7 @@
*/
#include <prerequisites.h>
#include <global.h>
#include <graphics/borderedimage.h>
#include <graphics/graphics.h>
#include <graphics/textures.h>

View File

@@ -25,7 +25,7 @@
#ifndef BORDEREDIMAGE_H
#define BORDEREDIMAGE_H
#include <prerequisites.h>
#include <global.h>
#include <graphics/image.h>
#include <graphics/texture.h>

View File

@@ -22,11 +22,12 @@
*/
#include <prerequisites.h>
#include <global.h>
#include <core/resources.h>
#include <graphics/font.h>
#include <graphics/textures.h>
#include <graphics/graphics.h>
#include <otml/otml.h>
void Font::calculateGlyphsWidthsAutomatically(const Size& glyphSize)
{
@@ -70,7 +71,7 @@ bool Font::load(const std::string& file)
{
std::stringstream fin;
if(!g_resources.loadFile(file, fin)) {
flogError("ERROR: Coult not load font file \"%s", file.c_str());
error("ERROR: Coult not load font file '",file,"'");
return false;
}
@@ -78,8 +79,8 @@ bool Font::load(const std::string& file)
Size glyphSize;
try {
FML::Parser parser(fin, file);
FML::Node* doc = parser.getDocument();
OTMLParser parser(fin, file);
OTMLNode* doc = parser.getDocument();
// required values
textureName = doc->valueAt("image");
@@ -92,7 +93,7 @@ bool Font::load(const std::string& file)
// load texture
m_texture = g_textures.get(textureName);
if(!m_texture) {
flogError("ERROR: Failed to load image for font file \"%s\"", file.c_str());
error("ERROR: Failed to load image for font file '",file,"'");
return false;
}
@@ -115,8 +116,8 @@ bool Font::load(const std::string& file)
m_glyphsSize[glyph].width(),
m_glyphHeight);
}
} catch(FML::Exception e) {
flogError("ERROR: Malformed font file \"%s\":\n %s", file.c_str() % e.what());
} catch(OTMLException e) {
error("ERROR: Malformed font file \"", file.c_str(), "\":\n ", e.what());
return false;
}

View File

@@ -25,8 +25,8 @@
#ifndef FONT_H
#define FONT_H
#include <prerequisites.h>
#include <graphics/texture.h>
#include <global.h>
#include <graphics/graphics.h>
class Font
{

View File

@@ -22,10 +22,12 @@
*/
#include <prerequisites.h>
#include <global.h>
#include <core/resources.h>
#include <graphics/fonts.h>
#include <boost/algorithm/string.hpp>
Fonts g_fonts;
void Fonts::init()
@@ -55,7 +57,7 @@ FontPtr Fonts::get(const std::string& fontName)
return font;
}
flogFatal("ERROR: Font \"%s\" not found", fontName.c_str());
fatal("ERROR: Font '",fontName,"' not found");
return FontPtr();
}

View File

@@ -25,7 +25,7 @@
#ifndef FONTS_H
#define FONTS_H
#include <prerequisites.h>
#include <global.h>
#include <graphics/font.h>
class Fonts

View File

@@ -21,7 +21,7 @@
* THE SOFTWARE.
*/
#include <prerequisites.h>
#include <global.h>
#include <core/platform.h>
#include <graphics/framebuffer.h>
#include <graphics/graphics.h>

View File

@@ -25,7 +25,7 @@
#ifndef FRAMEBUFFER_H
#define FRAMEBUFFER_H
#include <prerequisites.h>
#include <global.h>
class FrameBuffer
{

View File

@@ -22,7 +22,7 @@
*/
#include <prerequisites.h>
#include <global.h>
#include <graphics/graphics.h>
Graphics g_graphics;
@@ -40,8 +40,8 @@ void Graphics::init()
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
flogInfo("GPU %s", (const char*)glGetString(GL_RENDERER));
flogInfo("OpenGL %s", (const char*)glGetString(GL_VERSION));
info("GPU ", glGetString(GL_RENDERER));
info("OpenGL ", glGetString(GL_VERSION));
}
void Graphics::terminate()

View File

@@ -25,8 +25,12 @@
#ifndef GRAPHICS_H
#define GRAPHICS_H
#include <prerequisites.h>
#include <graphics/texture.h>
#include <global.h>
#include <graphics/textures.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glext.h>
class Graphics
{

View File

@@ -22,7 +22,7 @@
*/
#include <prerequisites.h>
#include <global.h>
#include <graphics/image.h>
#include <graphics/graphics.h>
#include <graphics/textures.h>

View File

@@ -25,7 +25,7 @@
#ifndef IMAGE_H
#define IMAGE_H
#include <prerequisites.h>
#include <global.h>
#include <graphics/texture.h>
class Image

View File

@@ -22,7 +22,7 @@
*/
#include <prerequisites.h>
#include <global.h>
#include <core/engine.h>
#include <graphics/textarea.h>
#include <graphics/graphics.h>

View File

@@ -25,7 +25,7 @@
#ifndef TEXTAREA_H
#define TEXTAREA_H
#include <prerequisites.h>
#include <global.h>
#include "font.h"
class TextArea

View File

@@ -22,7 +22,7 @@
*/
#include <prerequisites.h>
#include <global.h>
#include <graphics/texture.h>
#include "graphics.h"
@@ -37,7 +37,7 @@ uint Texture::internalLoadGLTexture(uchar *pixels, int channels, int width, int
GLint texSize;
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &texSize);
if(width > texSize || height > texSize) {
flogError("loading texture with size %dx%d failed, the maximum size is %dx%d", width % height % texSize % texSize);
error("loading texture with size ",width,"x",height," failed, the maximum size is ",texSize,"x",texSize);
return 0;
}

View File

@@ -25,7 +25,7 @@
#ifndef TEXTURE_H
#define TEXTURE_H
#include <prerequisites.h>
#include <global.h>
class Texture : public boost::enable_shared_from_this<Texture>
{

View File

@@ -22,7 +22,7 @@
*/
#include <prerequisites.h>
#include <global.h>
#include <graphics/textureloader.h>
#include <graphics/texture.h>
#include <util/apngloader.h>

View File

@@ -25,7 +25,7 @@
#ifndef TEXTURELOADER_H
#define TEXTURELOADER_H
#include <prerequisites.h>
#include <global.h>
#include <graphics/texture.h>
class TextureLoader

View File

@@ -22,12 +22,14 @@
*/
#include <prerequisites.h>
#include <global.h>
#include <core/resources.h>
#include <graphics/textures.h>
#include <graphics/textureloader.h>
#include <core/dispatcher.h>
#include <boost/algorithm/string.hpp>
Textures g_textures;
TexturePtr Textures::get(const std::string& textureFile)
@@ -47,14 +49,14 @@ TexturePtr Textures::get(const std::string& textureFile)
if(!texture) {
// currently only png textures are supported
if(!boost::ends_with(textureFile, ".png")) {
flogError("ERROR: Unable to load texture %s, file format no supported.", textureFile.c_str());
error("ERROR: Unable to load texture '",textureFile,"', file format no supported.");
return texture;
}
// load texture file data
std::stringstream fin;
if(!g_resources.loadFile(textureFile, fin)) {
flogError("ERROR: Unable to load texture %s, file could not be read.", textureFile.c_str());
error("ERROR: Unable to load texture '",textureFile,"', file could not be read.");
return texture;
}
@@ -62,7 +64,7 @@ TexturePtr Textures::get(const std::string& textureFile)
// load the texture
texture = TexturePtr(TextureLoader::loadPNG(fin));
if(!texture)
flogError("ERROR: Unable to load texture %s", textureFile.c_str());
error("ERROR: Unable to load texture '",textureFile,"'");
}
return texture;
}

View File

@@ -25,9 +25,8 @@
#ifndef TEXTURES_H
#define TEXTURES_H
#include <prerequisites.h>
#include <global.h>
#include <graphics/texture.h>
#include <graphics/animatedtexture.h>
class Textures
{