mirror of
https://github.com/glest/glest-source.git
synced 2025-08-13 20:03:58 +02:00
- added leak_dumper header all over the place (not yet functional in linux)
- Bugfix for particle cleanup
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
|
||||
#include "FileReader.h"
|
||||
#include "pixmap.h"
|
||||
#include "leak_dumper.h"
|
||||
|
||||
namespace Shared{ namespace Graphics{
|
||||
|
||||
|
@@ -13,7 +13,6 @@
|
||||
#define FILE_READER_H
|
||||
|
||||
#include "platform_util.h"
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@@ -21,6 +20,7 @@
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
#include <typeinfo>
|
||||
#include "leak_dumper.h"
|
||||
|
||||
using std::map;
|
||||
using std::string;
|
||||
|
@@ -17,6 +17,7 @@
|
||||
#include "JPGReader.h"
|
||||
#include "PNGReader.h"
|
||||
#include "TGAReader.h"
|
||||
#include "leak_dumper.h"
|
||||
|
||||
//Initialize some objects
|
||||
namespace Shared{ namespace Graphics{
|
||||
|
@@ -18,6 +18,7 @@
|
||||
|
||||
#include "FileReader.h"
|
||||
#include "pixmap.h"
|
||||
#include "leak_dumper.h"
|
||||
|
||||
namespace Shared{ namespace Graphics{
|
||||
|
||||
|
@@ -18,6 +18,7 @@
|
||||
|
||||
#include "FileReader.h"
|
||||
#include "pixmap.h"
|
||||
#include "leak_dumper.h"
|
||||
|
||||
namespace Shared{ namespace Graphics{
|
||||
|
||||
|
@@ -18,6 +18,7 @@
|
||||
|
||||
#include "FileReader.h"
|
||||
#include "pixmap.h"
|
||||
#include "leak_dumper.h"
|
||||
|
||||
namespace Shared{ namespace Graphics{
|
||||
|
||||
|
62
source/shared_lib/include/graphics/buffer.h
Normal file
62
source/shared_lib/include/graphics/buffer.h
Normal file
@@ -0,0 +1,62 @@
|
||||
#ifndef _SHARED_GRAPHICS_BUFFER_H_
|
||||
#define _SHARED_GRAPHICS_BUFFER_H_
|
||||
|
||||
#include <string>
|
||||
#include "leak_dumper.h"
|
||||
|
||||
using std::string;
|
||||
|
||||
namespace Shared{ namespace Graphics{
|
||||
|
||||
// =====================================================
|
||||
// class VertexBuffer
|
||||
// =====================================================
|
||||
|
||||
class VertexBuffer{
|
||||
private:
|
||||
static const int texCoordCount = 8;
|
||||
static const int attribCount = 8;
|
||||
|
||||
private:
|
||||
void *positionPointer;
|
||||
void *normalPointer;
|
||||
|
||||
void *texCoordPointers[texCoordCount];
|
||||
int texCoordCoordCounts[texCoordCount];
|
||||
|
||||
void *attribPointers[attribCount];
|
||||
int attribCoordCounts[attribCount];
|
||||
string attribNames[attribCount];
|
||||
|
||||
public:
|
||||
VertexBuffer();
|
||||
virtual ~VertexBuffer(){};
|
||||
|
||||
virtual void init(int size)= 0;
|
||||
|
||||
void setPositionPointer(void *pointer);
|
||||
void setNormalPointer(void *pointer);
|
||||
void setTexCoordPointer(void *pointer, int texCoordIndex, int coordCount);
|
||||
void setAttribPointer(void *pointer, int attribIndex, int coordCount, const string &name);
|
||||
};
|
||||
|
||||
// =====================================================
|
||||
// class IndexBuffer
|
||||
// =====================================================
|
||||
|
||||
class IndexBuffer{
|
||||
private:
|
||||
void *indexPointer;
|
||||
|
||||
public:
|
||||
IndexBuffer();
|
||||
virtual ~IndexBuffer(){}
|
||||
|
||||
virtual void init(int size)= 0;
|
||||
|
||||
void setIndexPointer(void *pointer);
|
||||
};
|
||||
|
||||
}}//end namespace
|
||||
|
||||
#endif
|
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "vec.h"
|
||||
#include "quaternion.h"
|
||||
#include "leak_dumper.h"
|
||||
|
||||
namespace Shared{ namespace Graphics{
|
||||
|
||||
|
@@ -13,6 +13,7 @@
|
||||
#define _SHARED_GRAPHICS_CONTEXT_H_
|
||||
|
||||
#include "types.h"
|
||||
#include "leak_dumper.h"
|
||||
|
||||
namespace Shared{ namespace Graphics{
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
// ==============================================================
|
||||
// This file is part of Glest Shared Library (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
|
||||
// the terms of the GNU General Public License as published
|
||||
@@ -13,6 +13,7 @@
|
||||
#define _SHARED_GRAPHICS_FONT_H_
|
||||
|
||||
#include <string>
|
||||
#include "leak_dumper.h"
|
||||
|
||||
using std::string;
|
||||
|
||||
|
@@ -13,8 +13,8 @@
|
||||
#define _SHARED_GRAPHICS_FONTMANAGER_H_
|
||||
|
||||
#include "font.h"
|
||||
|
||||
#include <vector>
|
||||
#include "leak_dumper.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
44
source/shared_lib/include/graphics/gl/context_gl.h
Normal file
44
source/shared_lib/include/graphics/gl/context_gl.h
Normal file
@@ -0,0 +1,44 @@
|
||||
// ==============================================================
|
||||
// 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_GL_CONTEXTGL_H_
|
||||
#define _SHARED_GRAPHICS_GL_CONTEXTGL_H_
|
||||
|
||||
#include "context.h"
|
||||
#include "gl_wrap.h"
|
||||
#include "leak_dumper.h"
|
||||
|
||||
namespace Shared{ namespace Graphics{ namespace Gl{
|
||||
|
||||
using Platform::PlatformContextGl;
|
||||
|
||||
// =====================================================
|
||||
// class ContextGl
|
||||
// =====================================================
|
||||
|
||||
class ContextGl: public Context{
|
||||
protected:
|
||||
PlatformContextGl pcgl;
|
||||
|
||||
public:
|
||||
virtual void init();
|
||||
virtual void end();
|
||||
virtual void reset(){};
|
||||
|
||||
virtual void makeCurrent();
|
||||
virtual void swapBuffers();
|
||||
|
||||
const PlatformContextGl *getPlatformContextGl() const {return &pcgl;}
|
||||
};
|
||||
|
||||
}}}//end namespace
|
||||
|
||||
#endif
|
59
source/shared_lib/include/graphics/gl/font_gl.h
Normal file
59
source/shared_lib/include/graphics/gl/font_gl.h
Normal file
@@ -0,0 +1,59 @@
|
||||
// ==============================================================
|
||||
// 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_GL_FONTGL_H_
|
||||
#define _SHARED_GRAPHICS_GL_FONTGL_H_
|
||||
|
||||
#include "font.h"
|
||||
#include "opengl.h"
|
||||
#include "leak_dumper.h"
|
||||
|
||||
namespace Shared{ namespace Graphics{ namespace Gl{
|
||||
|
||||
// =====================================================
|
||||
// class FontGl
|
||||
// =====================================================
|
||||
|
||||
class FontGl{
|
||||
protected:
|
||||
GLuint handle;
|
||||
|
||||
public:
|
||||
GLuint getHandle() const {return handle;}
|
||||
};
|
||||
|
||||
// =====================================================
|
||||
// class Font2DGl
|
||||
//
|
||||
/// OpenGL bitmap font
|
||||
// =====================================================
|
||||
|
||||
class Font2DGl: public Font2D, public FontGl{
|
||||
public:
|
||||
virtual void init();
|
||||
virtual void end();
|
||||
};
|
||||
|
||||
// =====================================================
|
||||
// class Font3DGl
|
||||
//
|
||||
/// OpenGL outline font
|
||||
// =====================================================
|
||||
|
||||
class Font3DGl: public Font3D, public FontGl{
|
||||
public:
|
||||
virtual void init();
|
||||
virtual void end();
|
||||
};
|
||||
|
||||
}}}//end namespace
|
||||
|
||||
#endif
|
@@ -0,0 +1,44 @@
|
||||
// ==============================================================
|
||||
// This file is part of Glest Shared Library (www.glest.org)
|
||||
//
|
||||
// Copyright (C) 2001-2005 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_GL_GRAPHICSFACTORYBASICGL_H_
|
||||
#define _SHARED_GRAPHICS_GL_GRAPHICSFACTORYBASICGL_H_
|
||||
|
||||
#include "graphics_factory.h"
|
||||
#include "text_renderer_gl.h"
|
||||
#include "model_renderer_gl.h"
|
||||
#include "context_gl.h"
|
||||
#include "model_gl.h"
|
||||
#include "texture_gl.h"
|
||||
#include "font_gl.h"
|
||||
#include "leak_dumper.h"
|
||||
|
||||
namespace Shared{ namespace Graphics{ namespace Gl{
|
||||
|
||||
// =====================================================
|
||||
// class GraphicsFactoryBasicGl
|
||||
// =====================================================
|
||||
|
||||
class GraphicsFactoryBasicGl: public GraphicsFactory{
|
||||
public:
|
||||
virtual TextRenderer2D *newTextRenderer2D() {return new TextRenderer2DGl();}
|
||||
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 Texture2D *newTexture2D() {return new Texture2DGl();}
|
||||
virtual Font2D *newFont2D() {return new Font2DGl();}
|
||||
virtual Font3D *newFont3D() {return new Font3DGl();}
|
||||
};
|
||||
|
||||
}}}//end namespace
|
||||
|
||||
#endif
|
66
source/shared_lib/include/graphics/gl/graphics_factory_gl.h
Normal file
66
source/shared_lib/include/graphics/gl/graphics_factory_gl.h
Normal file
@@ -0,0 +1,66 @@
|
||||
// ==============================================================
|
||||
// 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_GL_GRAPHICSFACTORYGL_H_
|
||||
#define _SHARED_GRAPHICS_GL_GRAPHICSFACTORYGL_H_
|
||||
|
||||
#include "texture_manager.h"
|
||||
#include "model_manager.h"
|
||||
#include "particle.h"
|
||||
#include "font_manager.h"
|
||||
#include "graphics_factory.h"
|
||||
#include "text_renderer_gl.h"
|
||||
#include "model_renderer_gl.h"
|
||||
#include "particle_renderer_gl.h"
|
||||
#include "context_gl.h"
|
||||
#include "model_gl.h"
|
||||
#include "texture_gl.h"
|
||||
#include "font_gl.h"
|
||||
#include "leak_dumper.h"
|
||||
|
||||
namespace Shared{ namespace Graphics{ namespace Gl{
|
||||
|
||||
// =====================================================
|
||||
// class GraphicsFactoryGl
|
||||
// =====================================================
|
||||
|
||||
class GraphicsFactoryGl: public GraphicsFactory{
|
||||
public:
|
||||
//context
|
||||
virtual Context *newContext() {return new ContextGl();}
|
||||
|
||||
//textures
|
||||
virtual TextureManager *newTextureManager() {return new TextureManager();}
|
||||
virtual Texture1D *newTexture1D() {return new Texture1DGl();}
|
||||
virtual Texture2D *newTexture2D() {return new Texture2DGl();}
|
||||
virtual Texture3D *newTexture3D() {return new Texture3DGl();}
|
||||
virtual TextureCube *newTextureCube() {return new TextureCubeGl();}
|
||||
|
||||
//models
|
||||
virtual ModelManager *newModelManager() {return new ModelManager();}
|
||||
virtual ModelRenderer *newModelRenderer() {return new ModelRendererGl();}
|
||||
virtual Model *newModel() {return new ModelGl();}
|
||||
|
||||
//text
|
||||
virtual FontManager *newFontManager() {return new FontManager();}
|
||||
virtual TextRenderer2D *newTextRenderer2D() {return new TextRenderer2DGl();}
|
||||
virtual TextRenderer3D *newTextRenderer3D() {return new TextRenderer3DGl();}
|
||||
virtual Font2D *newFont2D() {return new Font2DGl();}
|
||||
virtual Font3D *newFont3D() {return new Font3DGl();}
|
||||
|
||||
//particles
|
||||
virtual ParticleManager *newParticleManager() {return new ParticleManager();}
|
||||
virtual ParticleRenderer *newParticleRenderer() {return new ParticleRendererGl();}
|
||||
};
|
||||
|
||||
}}}//end namespace
|
||||
|
||||
#endif
|
63
source/shared_lib/include/graphics/gl/graphics_factory_gl2.h
Normal file
63
source/shared_lib/include/graphics/gl/graphics_factory_gl2.h
Normal file
@@ -0,0 +1,63 @@
|
||||
#ifndef _SHARED_GRAPHICS_GL_GRAPHICSFACTORYGL2_H_
|
||||
#define _SHARED_GRAPHICS_GL_GRAPHICSFACTORYGL2_H_
|
||||
|
||||
#include "texture_manager.h"
|
||||
#include "model_manager.h"
|
||||
#include "font_manager.h"
|
||||
#include "particle.h"
|
||||
#include "graphics_factory.h"
|
||||
#include "text_renderer_gl.h"
|
||||
#include "model_renderer_gl.h"
|
||||
#include "particle_renderer_gl.h"
|
||||
#include "context_gl.h"
|
||||
#include "model_gl.h"
|
||||
#include "texture_gl.h"
|
||||
#include "font_gl.h"
|
||||
#include "shader_gl.h"
|
||||
#include "shader_manager.h"
|
||||
#include "leak_dumper.h"
|
||||
|
||||
namespace Shared{ namespace Graphics{ namespace Gl{
|
||||
|
||||
// =====================================================
|
||||
// class GraphicsFactoryGl
|
||||
// =====================================================
|
||||
|
||||
class GraphicsFactoryGl2: public GraphicsFactory{
|
||||
public:
|
||||
//context
|
||||
virtual Context *newContext() {return new ContextGl();}
|
||||
|
||||
//textures
|
||||
virtual TextureManager *newTextureManager() {return new TextureManager();}
|
||||
virtual Texture1D *newTexture1D() {return new Texture1DGl();}
|
||||
virtual Texture2D *newTexture2D() {return new Texture2DGl();}
|
||||
virtual Texture3D *newTexture3D() {return new Texture3DGl();}
|
||||
virtual TextureCube *newTextureCube() {return new TextureCubeGl();}
|
||||
|
||||
//models
|
||||
virtual ModelManager *newModelManager() {return new ModelManager();}
|
||||
virtual ModelRenderer *newModelRenderer() {return new ModelRendererGl();}
|
||||
virtual Model *newModel() {return new ModelGl();}
|
||||
|
||||
//text
|
||||
virtual FontManager *newFontManager() {return new FontManager();}
|
||||
virtual TextRenderer2D *newTextRenderer2D() {return new TextRenderer2DGl();}
|
||||
virtual TextRenderer3D *newTextRenderer3D() {return new TextRenderer3DGl();}
|
||||
virtual Font2D *newFont2D() {return new Font2DGl();}
|
||||
virtual Font3D *newFont3D() {return new Font3DGl();}
|
||||
|
||||
//particles
|
||||
virtual ParticleManager *newParticleManager() {return new ParticleManager();}
|
||||
virtual ParticleRenderer *newParticleRenderer() {return new ParticleRendererGl();}
|
||||
|
||||
//shaders
|
||||
virtual ShaderManager *newShaderManager() {return new ShaderManager();}
|
||||
virtual ShaderProgram *newShaderProgram() {return new ShaderProgramGl();}
|
||||
virtual VertexShader *newVertexShader() {return new VertexShaderGl();}
|
||||
virtual FragmentShader *newFragmentShader() {return new FragmentShaderGl();}
|
||||
};
|
||||
|
||||
}}}//end namespace
|
||||
|
||||
#endif
|
32
source/shared_lib/include/graphics/gl/model_gl.h
Normal file
32
source/shared_lib/include/graphics/gl/model_gl.h
Normal file
@@ -0,0 +1,32 @@
|
||||
// ==============================================================
|
||||
// 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_GL_MODELGL_H_
|
||||
#define _SHARED_GRAPHICS_GL_MODELGL_H_
|
||||
|
||||
#include "model.h"
|
||||
#include "leak_dumper.h"
|
||||
|
||||
namespace Shared{ namespace Graphics{ namespace Gl{
|
||||
|
||||
// =====================================================
|
||||
// class ModelGl
|
||||
// =====================================================
|
||||
|
||||
class ModelGl: public Model{
|
||||
public:
|
||||
virtual void init(){}
|
||||
virtual void end(){}
|
||||
};
|
||||
|
||||
}}}//end namespace
|
||||
|
||||
#endif
|
51
source/shared_lib/include/graphics/gl/model_renderer_gl.h
Normal file
51
source/shared_lib/include/graphics/gl/model_renderer_gl.h
Normal file
@@ -0,0 +1,51 @@
|
||||
// ==============================================================
|
||||
// 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_GL_MODELRENDERERGL_H_
|
||||
#define _SHARED_GRAPHICS_GL_MODELRENDERERGL_H_
|
||||
|
||||
#include "model_renderer.h"
|
||||
#include "model.h"
|
||||
#include "opengl.h"
|
||||
#include "leak_dumper.h"
|
||||
|
||||
namespace Shared{ namespace Graphics{ namespace Gl{
|
||||
|
||||
// =====================================================
|
||||
// class ModelRendererGl
|
||||
// =====================================================
|
||||
|
||||
class ModelRendererGl: public ModelRenderer{
|
||||
private:
|
||||
bool rendering;
|
||||
bool duplicateTexCoords;
|
||||
int secondaryTexCoordUnit;
|
||||
GLuint lastTexture;
|
||||
|
||||
public:
|
||||
ModelRendererGl();
|
||||
virtual void begin(bool renderNormals, bool renderTextures, bool renderColors, MeshCallback *meshCallback);
|
||||
virtual void end();
|
||||
virtual void render(const Model *model);
|
||||
virtual void renderNormalsOnly(const Model *model);
|
||||
|
||||
void setDuplicateTexCoords(bool duplicateTexCoords) {this->duplicateTexCoords= duplicateTexCoords;}
|
||||
void setSecondaryTexCoordUnit(int secondaryTexCoordUnit) {this->secondaryTexCoordUnit= secondaryTexCoordUnit;}
|
||||
|
||||
private:
|
||||
|
||||
void renderMesh(const Mesh *mesh);
|
||||
void renderMeshNormals(const Mesh *mesh);
|
||||
};
|
||||
|
||||
}}}//end namespace
|
||||
|
||||
#endif
|
69
source/shared_lib/include/graphics/gl/opengl.h
Normal file
69
source/shared_lib/include/graphics/gl/opengl.h
Normal file
@@ -0,0 +1,69 @@
|
||||
// ==============================================================
|
||||
// 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_GL_OPENGL_H_
|
||||
#define _SHARED_GRAPHICS_GL_OPENGL_H_
|
||||
|
||||
#include <cassert>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include "conversion.h"
|
||||
#include "gl_wrap.h"
|
||||
#include "leak_dumper.h"
|
||||
|
||||
using std::runtime_error;
|
||||
using std::string;
|
||||
|
||||
namespace Shared{ namespace Graphics{ namespace Gl{
|
||||
|
||||
using Util::intToStr;
|
||||
|
||||
// =====================================================
|
||||
// Globals
|
||||
// =====================================================
|
||||
|
||||
bool isGlExtensionSupported(const char *extensionName);
|
||||
bool isGlVersionSupported(int major, int minor, int release);
|
||||
const char *getGlVersion();
|
||||
const char *getGlRenderer();
|
||||
const char *getGlVendor();
|
||||
const char *getGlExtensions();
|
||||
const char *getGlPlatformExtensions();
|
||||
int getGlMaxLights();
|
||||
int getGlMaxTextureSize();
|
||||
int getGlMaxTextureUnits();
|
||||
int getGlModelviewMatrixStackDepth();
|
||||
int getGlProjectionMatrixStackDepth();
|
||||
void checkGlExtension(const char *extensionName);
|
||||
|
||||
void inline _assertGl(const char *file, int line){
|
||||
|
||||
GLenum error= glGetError();
|
||||
|
||||
if(error != GL_NO_ERROR){
|
||||
const char *errorString= reinterpret_cast<const char*>(gluErrorString(error));
|
||||
throw runtime_error("OpenGL error: "+string(errorString)+" at file: "+string(file)+", line "+intToStr(line));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#ifdef NDEBUG
|
||||
#define assertGl() ((void) 0);
|
||||
|
||||
#else
|
||||
|
||||
#define assertGl() _assertGl(__FILE__, __LINE__);
|
||||
|
||||
#endif
|
||||
|
||||
}}}//end namespace
|
||||
|
||||
#endif
|
51
source/shared_lib/include/graphics/gl/particle_renderer_gl.h
Normal file
51
source/shared_lib/include/graphics/gl/particle_renderer_gl.h
Normal file
@@ -0,0 +1,51 @@
|
||||
// ==============================================================
|
||||
// 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_GL_PARTICLERENDERERGL_H_
|
||||
#define _SHARED_GRAPHICS_GL_PARTICLERENDERERGL_H_
|
||||
|
||||
#include "particle_renderer.h"
|
||||
#include "leak_dumper.h"
|
||||
|
||||
namespace Shared{ namespace Graphics{ namespace Gl{
|
||||
|
||||
// =====================================================
|
||||
// class ParticleRendererGl
|
||||
// =====================================================
|
||||
|
||||
class ParticleRendererGl: public ParticleRenderer{
|
||||
public:
|
||||
static const int bufferSize = 1024;
|
||||
|
||||
private:
|
||||
bool rendering;
|
||||
Vec3f vertexBuffer[bufferSize];
|
||||
Vec2f texCoordBuffer[bufferSize];
|
||||
Vec4f colorBuffer[bufferSize];
|
||||
|
||||
public:
|
||||
//particles
|
||||
ParticleRendererGl();
|
||||
virtual void renderManager(ParticleManager *pm, ModelRenderer *mr);
|
||||
virtual void renderSystem(ParticleSystem *ps);
|
||||
virtual void renderSystemLine(ParticleSystem *ps);
|
||||
virtual void renderSystemLineAlpha(ParticleSystem *ps);
|
||||
virtual void renderSingleModel(AttackParticleSystem *ps, ModelRenderer *mr);
|
||||
|
||||
protected:
|
||||
void renderBufferQuads(int quadCount);
|
||||
void renderBufferLines(int lineCount);
|
||||
void setBlendMode(ParticleSystem::BlendMode blendMode);
|
||||
};
|
||||
|
||||
}}}//end namespace
|
||||
|
||||
#endif
|
111
source/shared_lib/include/graphics/gl/shader_gl.h
Normal file
111
source/shared_lib/include/graphics/gl/shader_gl.h
Normal file
@@ -0,0 +1,111 @@
|
||||
// ==============================================================
|
||||
// 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_GL_SHADERGL_H_
|
||||
#define _SHARED_GRAPHICS_GL_SHADERGL_H_
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include "shader.h"
|
||||
#include "opengl.h"
|
||||
#include "leak_dumper.h"
|
||||
|
||||
using std::vector;
|
||||
using std::string;
|
||||
using std::pair;
|
||||
|
||||
namespace Shared{ namespace Graphics{ namespace Gl{
|
||||
|
||||
// =====================================================
|
||||
// class ShaderProgramGl
|
||||
// =====================================================
|
||||
|
||||
class ShaderProgramGl: public ShaderProgram{
|
||||
private:
|
||||
typedef pair<string, int> AttributePair;
|
||||
typedef vector<AttributePair> Attributes;
|
||||
|
||||
private:
|
||||
Attributes attributes;
|
||||
GLhandleARB handle;
|
||||
VertexShader *vertexShader;
|
||||
FragmentShader *fragmentShader;
|
||||
bool inited;
|
||||
|
||||
public:
|
||||
ShaderProgramGl();
|
||||
|
||||
GLhandleARB getHandle() const {return handle;}
|
||||
|
||||
virtual void init();
|
||||
virtual void end();
|
||||
|
||||
virtual void attach(VertexShader *vertexShader, FragmentShader *fragmentShader);
|
||||
virtual bool link(string &messages);
|
||||
virtual void activate();
|
||||
virtual void deactivate();
|
||||
|
||||
virtual void setUniform(const string &name, int value);
|
||||
virtual void setUniform(const string &name, float value);
|
||||
virtual void setUniform(const string &name, const Vec2f &value);
|
||||
virtual void setUniform(const string &name, const Vec3f &value);
|
||||
virtual void setUniform(const string &name, const Vec4f &value);
|
||||
virtual void setUniform(const string &name, const Matrix3f &value);
|
||||
virtual void setUniform(const string &name, const Matrix4f &value);
|
||||
|
||||
void bindAttribute(const string &name, int index);
|
||||
|
||||
private:
|
||||
GLint getLocation(const string &name);
|
||||
};
|
||||
|
||||
// =====================================================
|
||||
// class ShaderGl
|
||||
// =====================================================
|
||||
|
||||
class ShaderGl: virtual public Shader{
|
||||
protected:
|
||||
GLhandleARB handle;
|
||||
ShaderSource source;
|
||||
bool inited;
|
||||
|
||||
public:
|
||||
ShaderGl();
|
||||
|
||||
const ShaderSource *getSource() const {return &source;}
|
||||
GLhandleARB getHandle() const {return handle;}
|
||||
|
||||
virtual void load(const string &path);
|
||||
virtual bool compile(string &messages);
|
||||
virtual void end();
|
||||
};
|
||||
|
||||
// =====================================================
|
||||
// class VertexShaderGl
|
||||
// =====================================================
|
||||
|
||||
class VertexShaderGl: public VertexShader, public ShaderGl{
|
||||
public:
|
||||
virtual void init();
|
||||
};
|
||||
|
||||
// =====================================================
|
||||
// class FragmentShaderGl
|
||||
// =====================================================
|
||||
|
||||
class FragmentShaderGl: public FragmentShader, public ShaderGl{
|
||||
public:
|
||||
virtual void init();
|
||||
};
|
||||
|
||||
}}}//end namespace
|
||||
|
||||
#endif
|
@@ -13,6 +13,7 @@
|
||||
#define _SHARED_GRAPHICS_GL_TEXTRENDERERGL_H_
|
||||
|
||||
#include "text_renderer.h"
|
||||
#include "leak_dumper.h"
|
||||
|
||||
namespace Shared{ namespace Graphics{ namespace Gl{
|
||||
|
||||
|
75
source/shared_lib/include/graphics/gl/texture_gl.h
Normal file
75
source/shared_lib/include/graphics/gl/texture_gl.h
Normal file
@@ -0,0 +1,75 @@
|
||||
// ==============================================================
|
||||
// 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_GL_TEXTUREGL_H_
|
||||
#define _SHARED_GRAPHICS_GL_TEXTUREGL_H_
|
||||
|
||||
#include "texture.h"
|
||||
#include "opengl.h"
|
||||
#include "leak_dumper.h"
|
||||
|
||||
namespace Shared{ namespace Graphics{ namespace Gl{
|
||||
|
||||
// =====================================================
|
||||
// class TextureGl
|
||||
// =====================================================
|
||||
|
||||
class TextureGl{
|
||||
protected:
|
||||
GLuint handle;
|
||||
|
||||
public:
|
||||
GLuint getHandle() const {return handle;}
|
||||
};
|
||||
|
||||
// =====================================================
|
||||
// class Texture1DGl
|
||||
// =====================================================
|
||||
|
||||
class Texture1DGl: public Texture1D, public TextureGl{
|
||||
public:
|
||||
virtual void init(Filter filter, int maxAnisotropy= 1);
|
||||
virtual void end();
|
||||
};
|
||||
|
||||
// =====================================================
|
||||
// class Texture2DGl
|
||||
// =====================================================
|
||||
|
||||
class Texture2DGl: public Texture2D, public TextureGl{
|
||||
public:
|
||||
virtual void init(Filter filter, int maxAnisotropy= 1);
|
||||
virtual void end();
|
||||
};
|
||||
|
||||
// =====================================================
|
||||
// class Texture3DGl
|
||||
// =====================================================
|
||||
|
||||
class Texture3DGl: public Texture3D, public TextureGl{
|
||||
public:
|
||||
virtual void init(Filter filter, int maxAnisotropy= 1);
|
||||
virtual void end();
|
||||
};
|
||||
|
||||
// =====================================================
|
||||
// class TextureCubeGl
|
||||
// =====================================================
|
||||
|
||||
class TextureCubeGl: public TextureCube, public TextureGl{
|
||||
public:
|
||||
virtual void init(Filter filter, int maxAnisotropy= 1);
|
||||
virtual void end();
|
||||
};
|
||||
|
||||
}}}//end namespace
|
||||
|
||||
#endif
|
89
source/shared_lib/include/graphics/graphics_factory.h
Normal file
89
source/shared_lib/include/graphics/graphics_factory.h
Normal file
@@ -0,0 +1,89 @@
|
||||
// ==============================================================
|
||||
// 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_GRAPHICSFACTORY_H_
|
||||
#define _SHARED_GRAPHICS_GRAPHICSFACTORY_H_
|
||||
|
||||
#include <cstdlib>
|
||||
#include "leak_dumper.h"
|
||||
|
||||
namespace Shared{ namespace Graphics{
|
||||
|
||||
class Context;
|
||||
|
||||
class TextureManager;
|
||||
class Texture1D;
|
||||
class Texture2D;
|
||||
class Texture3D;
|
||||
class TextureCube;
|
||||
|
||||
class ModelManager;
|
||||
class ModelRenderer;
|
||||
class Model;
|
||||
|
||||
class FontManager;
|
||||
class TextRenderer2D;
|
||||
class TextRenderer3D;
|
||||
class Font2D;
|
||||
class Font3D;
|
||||
|
||||
class ParticleManager;
|
||||
class ParticleRenderer;
|
||||
|
||||
class ShaderManager;
|
||||
class ShaderProgram;
|
||||
class VertexShader;
|
||||
class FragmentShader;
|
||||
|
||||
// =====================================================
|
||||
// class GraphicsFactory
|
||||
// =====================================================
|
||||
|
||||
class GraphicsFactory{
|
||||
public:
|
||||
virtual ~GraphicsFactory(){}
|
||||
|
||||
//context
|
||||
virtual Context *newContext() {return NULL;}
|
||||
|
||||
//textures
|
||||
virtual TextureManager *newTextureManager() {return NULL;}
|
||||
virtual Texture1D *newTexture1D() {return NULL;}
|
||||
virtual Texture2D *newTexture2D() {return NULL;}
|
||||
virtual Texture3D *newTexture3D() {return NULL;}
|
||||
virtual TextureCube *newTextureCube() {return NULL;}
|
||||
|
||||
//models
|
||||
virtual ModelManager *newModelManager() {return NULL;}
|
||||
virtual ModelRenderer *newModelRenderer() {return NULL;}
|
||||
virtual Model *newModel() {return NULL;}
|
||||
|
||||
//text
|
||||
virtual FontManager *newFontManager() {return NULL;}
|
||||
virtual TextRenderer2D *newTextRenderer2D() {return NULL;}
|
||||
virtual TextRenderer3D *newTextRenderer3D() {return NULL;}
|
||||
virtual Font2D *newFont2D() {return NULL;}
|
||||
virtual Font3D *newFont3D() {return NULL;}
|
||||
|
||||
//particles
|
||||
virtual ParticleManager *newParticleManager() {return NULL;}
|
||||
virtual ParticleRenderer *newParticleRenderer() {return NULL;}
|
||||
|
||||
//shaders
|
||||
virtual ShaderManager *newShaderManager() {return NULL;}
|
||||
virtual ShaderProgram *newShaderProgram() {return NULL;}
|
||||
virtual VertexShader *newVertexShader() {return NULL;}
|
||||
virtual FragmentShader *newFragmentShader() {return NULL;}
|
||||
};
|
||||
|
||||
}}//end namespace
|
||||
|
||||
#endif
|
@@ -12,6 +12,8 @@
|
||||
#ifndef _SHARED_GRAPHICS_GRAPHICSINTERFACE_H_
|
||||
#define _SHARED_GRAPHICS_GRAPHICSINTERFACE_H_
|
||||
|
||||
#include "leak_dumper.h"
|
||||
|
||||
namespace Shared{ namespace Graphics{
|
||||
|
||||
class GraphicsFactory;
|
||||
|
@@ -15,6 +15,7 @@
|
||||
#include "vec.h"
|
||||
#include "model.h"
|
||||
#include <map>
|
||||
#include "leak_dumper.h"
|
||||
|
||||
namespace Shared{ namespace Graphics{
|
||||
|
||||
|
@@ -13,6 +13,7 @@
|
||||
#define _SHARED_GRAPHICS_MATHUTIL_H_
|
||||
|
||||
#include "vec.h"
|
||||
#include "leak_dumper.h"
|
||||
|
||||
namespace Shared{ namespace Graphics{
|
||||
|
||||
|
@@ -13,6 +13,7 @@
|
||||
#define _SHARED_GRAPHICS_MATRIX_H_
|
||||
|
||||
#include "vec.h"
|
||||
#include "leak_dumper.h"
|
||||
|
||||
namespace Shared{ namespace Graphics{
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
// ==============================================================
|
||||
// This file is part of Glest Shared Library (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
|
||||
// the terms of the GNU General Public License as published
|
||||
@@ -14,12 +14,12 @@
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
#include "types.h"
|
||||
#include "pixmap.h"
|
||||
#include "texture_manager.h"
|
||||
#include "texture.h"
|
||||
#include "model_header.h"
|
||||
#include "leak_dumper.h"
|
||||
|
||||
using std::string;
|
||||
using std::map;
|
||||
|
119
source/shared_lib/include/graphics/model_header.h
Normal file
119
source/shared_lib/include/graphics/model_header.h
Normal file
@@ -0,0 +1,119 @@
|
||||
// ==============================================================
|
||||
// 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_GRAPHICTYPES_MODELHEADER_H_
|
||||
#define _SHARED_GRAPHICTYPES_MODELHEADER_H_
|
||||
|
||||
#include "types.h"
|
||||
#include "leak_dumper.h"
|
||||
|
||||
using Shared::Platform::uint8;
|
||||
using Shared::Platform::uint16;
|
||||
using Shared::Platform::uint32;
|
||||
using Shared::Platform::float32;
|
||||
|
||||
namespace Shared{ namespace Graphics{
|
||||
|
||||
#pragma pack(push, 1)
|
||||
|
||||
struct FileHeader{
|
||||
uint8 id[3];
|
||||
uint8 version;
|
||||
};
|
||||
|
||||
//version 4
|
||||
|
||||
struct ModelHeader{
|
||||
uint16 meshCount;
|
||||
uint8 type;
|
||||
};
|
||||
|
||||
enum ModelType{
|
||||
mtMorphMesh
|
||||
};
|
||||
|
||||
enum MeshPropertyFlag{
|
||||
mpfCustomColor= 1,
|
||||
mpfTwoSided= 2
|
||||
};
|
||||
|
||||
enum MeshTexture{
|
||||
mtDiffuse,
|
||||
mtSpecular,
|
||||
mtNormal,
|
||||
mtReflection,
|
||||
mtColorMask,
|
||||
|
||||
meshTextureCount
|
||||
};
|
||||
|
||||
const int meshTextureChannelCount[]= {-1, 1, 3, 1, 1};
|
||||
|
||||
const uint32 meshNameSize= 64;
|
||||
const uint32 mapPathSize= 64;
|
||||
|
||||
struct MeshHeader{
|
||||
uint8 name[meshNameSize];
|
||||
uint32 frameCount;
|
||||
uint32 vertexCount;
|
||||
uint32 indexCount;
|
||||
float32 diffuseColor[3];
|
||||
float32 specularColor[3];
|
||||
float32 specularPower;
|
||||
float32 opacity;
|
||||
uint32 properties;
|
||||
uint32 textures;
|
||||
};
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
//version 3
|
||||
|
||||
//front faces are clockwise faces
|
||||
struct ModelHeaderV3{
|
||||
uint32 meshCount;
|
||||
};
|
||||
|
||||
enum MeshPropertyV3{
|
||||
mp3NoTexture= 1,
|
||||
mp3TwoSided= 2,
|
||||
mp3CustomColor= 4
|
||||
};
|
||||
|
||||
struct MeshHeaderV3{
|
||||
uint32 vertexFrameCount;
|
||||
uint32 normalFrameCount;
|
||||
uint32 texCoordFrameCount;
|
||||
uint32 colorFrameCount;
|
||||
uint32 pointCount;
|
||||
uint32 indexCount;
|
||||
uint32 properties;
|
||||
uint8 texName[64];
|
||||
};
|
||||
|
||||
//version 2
|
||||
|
||||
struct MeshHeaderV2{
|
||||
uint32 vertexFrameCount;
|
||||
uint32 normalFrameCount;
|
||||
uint32 texCoordFrameCount;
|
||||
uint32 colorFrameCount;
|
||||
uint32 pointCount;
|
||||
uint32 indexCount;
|
||||
uint8 hasTexture;
|
||||
uint8 primitive;
|
||||
uint8 cullFace;
|
||||
uint8 texName[64];
|
||||
};
|
||||
|
||||
}}//end namespace
|
||||
|
||||
#endif
|
@@ -13,8 +13,8 @@
|
||||
#define _SHARED_GRAPHICS_MODELMANAGER_H_
|
||||
|
||||
#include "model.h"
|
||||
|
||||
#include <vector>
|
||||
#include "leak_dumper.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@@ -14,6 +14,7 @@
|
||||
#define _SHARED_GRAPHICS_MODELRENDERER_H_
|
||||
|
||||
#include "model.h"
|
||||
#include "leak_dumper.h"
|
||||
|
||||
namespace Shared{ namespace Graphics{
|
||||
|
||||
|
@@ -14,11 +14,11 @@
|
||||
|
||||
#include <list>
|
||||
#include <cassert>
|
||||
|
||||
#include "vec.h"
|
||||
#include "pixmap.h"
|
||||
#include "texture_manager.h"
|
||||
#include "randomgen.h"
|
||||
#include "leak_dumper.h"
|
||||
|
||||
using std::list;
|
||||
using Shared::Util::RandomGen;
|
||||
|
39
source/shared_lib/include/graphics/particle_renderer.h
Normal file
39
source/shared_lib/include/graphics/particle_renderer.h
Normal file
@@ -0,0 +1,39 @@
|
||||
// ==============================================================
|
||||
// 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_PARTICLERENDERER_H_
|
||||
#define _SHARED_GRAPHICS_PARTICLERENDERER_H_
|
||||
|
||||
#include "particle.h"
|
||||
#include "leak_dumper.h"
|
||||
|
||||
namespace Shared{ namespace Graphics{
|
||||
|
||||
class ModelRenderer;
|
||||
|
||||
// =====================================================
|
||||
// class ParticleRenderer
|
||||
// =====================================================
|
||||
|
||||
class ParticleRenderer{
|
||||
public:
|
||||
//particles
|
||||
virtual ~ParticleRenderer(){};
|
||||
virtual void renderManager(ParticleManager *pm, ModelRenderer *mr)=0;
|
||||
virtual void renderSystem(ParticleSystem *ps)=0;
|
||||
virtual void renderSystemLine(ParticleSystem *ps)=0;
|
||||
virtual void renderSystemLineAlpha(ParticleSystem *ps)=0;
|
||||
virtual void renderSingleModel(AttackParticleSystem *ps, ModelRenderer *mr)=0;
|
||||
};
|
||||
|
||||
}}//end namespace
|
||||
|
||||
#endif
|
@@ -1,7 +1,7 @@
|
||||
// ==============================================================
|
||||
// This file is part of Glest Shared Library (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
|
||||
// the terms of the GNU General Public License as published
|
||||
@@ -13,9 +13,9 @@
|
||||
#define _SHARED_GRAPHICS_PIXMAP_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "vec.h"
|
||||
#include "types.h"
|
||||
#include "leak_dumper.h"
|
||||
|
||||
using std::string;
|
||||
using Shared::Platform::int8;
|
||||
|
98
source/shared_lib/include/graphics/quaternion.h
Normal file
98
source/shared_lib/include/graphics/quaternion.h
Normal file
@@ -0,0 +1,98 @@
|
||||
// ==============================================================
|
||||
// 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_QUATERNION_H_
|
||||
#define _SHARED_GRAPHICS_QUATERNION_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "vec.h"
|
||||
#include "matrix.h"
|
||||
#include "leak_dumper.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace Shared{ namespace Graphics{
|
||||
|
||||
// =====================================================
|
||||
// class AxisAngle
|
||||
// =====================================================
|
||||
|
||||
class AxisAngle{
|
||||
public:
|
||||
Vec3f axis;
|
||||
float angle;
|
||||
|
||||
AxisAngle(){};
|
||||
AxisAngle(const Vec3f &axis, float angle);
|
||||
};
|
||||
|
||||
// =====================================================
|
||||
// class EulerAngles
|
||||
// =====================================================
|
||||
|
||||
class EulerAngles{
|
||||
public:
|
||||
float x, y, z;
|
||||
|
||||
EulerAngles(){};
|
||||
EulerAngles(float x, float y, float z);
|
||||
};
|
||||
|
||||
// =====================================================
|
||||
// class Quaternion
|
||||
// =====================================================
|
||||
|
||||
class Quaternion{
|
||||
private:
|
||||
float w;
|
||||
Vec3f v;
|
||||
|
||||
public:
|
||||
Quaternion();
|
||||
Quaternion(float w, const Vec3f &v);
|
||||
Quaternion(const EulerAngles &eulerAngles);
|
||||
Quaternion(const AxisAngle &axisAngle);
|
||||
|
||||
//initializers
|
||||
void setMultIdentity();
|
||||
void setAddIdentity();
|
||||
void setAxisAngle(const AxisAngle &axisAngle);
|
||||
void setEuler(const EulerAngles &eulerAngles);
|
||||
|
||||
//unary operators
|
||||
float length();
|
||||
Quaternion conjugate();
|
||||
void normalize();
|
||||
|
||||
//binary operators
|
||||
Quaternion operator + (const Quaternion &q) const;
|
||||
Quaternion operator * (const Quaternion &q) const;
|
||||
void operator += (const Quaternion &q);
|
||||
void operator *= (const Quaternion &q);
|
||||
|
||||
//ternary operators
|
||||
Quaternion lerp(float t, const Quaternion &q) const;
|
||||
|
||||
//conversions
|
||||
Matrix3f toMatrix3() const;
|
||||
Matrix4f toMatrix4() const;
|
||||
AxisAngle toAxisAngle() const;
|
||||
|
||||
//local axis
|
||||
Vec3f getLocalXAxis() const;
|
||||
Vec3f getLocalYAxis() const;
|
||||
Vec3f getLocalZAxis() const;
|
||||
};
|
||||
|
||||
}}//end namespace
|
||||
|
||||
#endif
|
87
source/shared_lib/include/graphics/shader.h
Normal file
87
source/shared_lib/include/graphics/shader.h
Normal file
@@ -0,0 +1,87 @@
|
||||
// ==============================================================
|
||||
// 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_SHADER_H_
|
||||
#define _SHARED_GRAPHICS_SHADER_H_
|
||||
|
||||
#include "vec.h"
|
||||
#include "matrix.h"
|
||||
#include "texture.h"
|
||||
#include "leak_dumper.h"
|
||||
|
||||
namespace Shared{ namespace Graphics{
|
||||
|
||||
// =====================================================
|
||||
// class ShaderProgram
|
||||
// =====================================================
|
||||
|
||||
class VertexShader;
|
||||
class FragmentShader;
|
||||
|
||||
class ShaderProgram{
|
||||
public:
|
||||
virtual ~ShaderProgram(){}
|
||||
virtual void init()= 0;
|
||||
virtual void end()= 0;
|
||||
|
||||
virtual void attach(VertexShader *vs, FragmentShader *fs)= 0;
|
||||
virtual bool link(string &messages)= 0;
|
||||
virtual void activate()= 0;
|
||||
virtual void deactivate()= 0;
|
||||
|
||||
virtual void setUniform(const string &name, int value)= 0;
|
||||
virtual void setUniform(const string &name, float value)= 0;
|
||||
virtual void setUniform(const string &name, const Vec2f &value)= 0;
|
||||
virtual void setUniform(const string &name, const Vec3f &value)= 0;
|
||||
virtual void setUniform(const string &name, const Vec4f &value)= 0;
|
||||
virtual void setUniform(const string &name, const Matrix3f &value)= 0;
|
||||
virtual void setUniform(const string &name, const Matrix4f &value)= 0;
|
||||
};
|
||||
|
||||
// =====================================================
|
||||
// class Shader
|
||||
// =====================================================
|
||||
|
||||
class Shader{
|
||||
public:
|
||||
virtual ~Shader(){}
|
||||
virtual void init()= 0;
|
||||
virtual void end()= 0;
|
||||
|
||||
virtual void load(const string &path)= 0;
|
||||
virtual bool compile(string &messages)= 0;
|
||||
};
|
||||
|
||||
class VertexShader: virtual public Shader{
|
||||
};
|
||||
|
||||
class FragmentShader: virtual public Shader{
|
||||
};
|
||||
|
||||
// =====================================================
|
||||
// class ShaderSource
|
||||
// =====================================================
|
||||
|
||||
class ShaderSource{
|
||||
private:
|
||||
string pathInfo;
|
||||
string code;
|
||||
|
||||
public:
|
||||
const string &getPathInfo() const {return pathInfo;}
|
||||
const string &getCode() const {return code;}
|
||||
|
||||
void load(const string &path);
|
||||
};
|
||||
|
||||
}}//end namespace
|
||||
|
||||
#endif
|
53
source/shared_lib/include/graphics/shader_manager.h
Normal file
53
source/shared_lib/include/graphics/shader_manager.h
Normal file
@@ -0,0 +1,53 @@
|
||||
// ==============================================================
|
||||
// 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_SHADERMANAGER_H_
|
||||
#define _SHARED_GRAPHICS_SHADERMANAGER_H_
|
||||
|
||||
#include "shader.h"
|
||||
#include <vector>
|
||||
#include "leak_dumper.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace Shared{ namespace Graphics{
|
||||
|
||||
// =====================================================
|
||||
// class ShaderManager
|
||||
// =====================================================
|
||||
|
||||
class ShaderManager{
|
||||
protected:
|
||||
typedef vector<ShaderProgram*> ShaderProgramContainer;
|
||||
typedef vector<Shader*> ShaderContainer;
|
||||
|
||||
protected:
|
||||
ShaderProgramContainer shaderPrograms;
|
||||
ShaderContainer shaders;
|
||||
string logString;
|
||||
|
||||
public:
|
||||
ShaderManager(){}
|
||||
virtual ~ShaderManager();
|
||||
|
||||
ShaderProgram *newShaderProgram();
|
||||
VertexShader *newVertexShader();
|
||||
FragmentShader *newFragmentShader();
|
||||
|
||||
void init();
|
||||
void end();
|
||||
|
||||
const string &getLogString() const {return logString;}
|
||||
};
|
||||
|
||||
}}//end namespace
|
||||
|
||||
#endif
|
@@ -13,9 +13,9 @@
|
||||
#define _SHARED_GRAPHICS_TEXTRENDERER_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "vec.h"
|
||||
#include "font.h"
|
||||
#include "leak_dumper.h"
|
||||
|
||||
using std::string;
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
// ==============================================================
|
||||
// This file is part of Glest Shared Library (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
|
||||
// the terms of the GNU General Public License as published
|
||||
@@ -14,8 +14,8 @@
|
||||
|
||||
#include "types.h"
|
||||
#include "pixmap.h"
|
||||
|
||||
#include <string>
|
||||
#include "leak_dumper.h"
|
||||
|
||||
using std::string;
|
||||
using Shared::Platform::uint8;
|
||||
|
@@ -13,8 +13,8 @@
|
||||
#define _SHARED_GRAPHICS_TEXTUREMANAGER_H_
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "texture.h"
|
||||
#include "leak_dumper.h"
|
||||
|
||||
using std::vector;
|
||||
|
||||
|
@@ -16,6 +16,7 @@
|
||||
#include "math_wrapper.h"
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include "leak_dumper.h"
|
||||
|
||||
namespace Shared{ namespace Graphics{
|
||||
|
||||
|
Reference in New Issue
Block a user