Panagiotis Christopoulos Charitos преди 14 години
родител
ревизия
3d8e64b824

Файловите разлики са ограничени, защото са твърде много
+ 0 - 0
build/debug/Makefile


+ 1 - 1
build/debug/gen.cfg.py

@@ -9,6 +9,6 @@ executableName = "anki"
 
 compiler = "g++"
 
-compilerFlags = "-DPLATFORM_LINUX -DMATH_INTEL_SIMD -DREVISION=\\\"`svnversion -c ../..`\\\" -c -pedantic-errors -pedantic -ansi -Wall -Wextra -W -Wno-long-long -pipe -g3 -fsingle-precision-constant -msse4"
+compilerFlags = "-DPLATFORM_LINUX -DMATH_INTEL_SIMD -DREVISION=\\\"`svnversion ../..`\\\" -c -pedantic-errors -pedantic -ansi -Wall -Wextra -W -Wno-long-long -pipe -g3 -fsingle-precision-constant -msse4"
 
 linkerFlags = "-rdynamic -L../../extern/lib-x86-64-linux -Wl,-Bstatic -lBulletSoftBody -lBulletDynamics -lBulletCollision -lLinearMath -lGLEW -lGLU -Wl,-Bdynamic -lGL -ljpeg -lSDL -lpng -lpython2.6 -lboost_system -lboost_python -lboost_filesystem -lboost_thread"

+ 1 - 1
build/release/gen.cfg.py

@@ -9,6 +9,6 @@ executableName = "anki"
 
 compiler = "g++-4.5"
 
-compilerFlags = "-DPLATFORM_LINUX -DMATH_INTEL_SIMD -DNDEBUG -DBOOST_DISABLE_ASSERTS -DREVISION=\\\"`svnversion -c ../..`\\\" -c -pedantic-errors -pedantic -ansi -Wall -Wextra -W -Wno-long-long -pipe -fsingle-precision-constant -msse4 -O3 -mtune=core2 -ffast-math -flto"
+compilerFlags = "-DPLATFORM_LINUX -DMATH_INTEL_SIMD -DNDEBUG -DBOOST_DISABLE_ASSERTS -DREVISION=\\\"`svnversion ../..`\\\" -c -pedantic-errors -pedantic -ansi -Wall -Wextra -W -Wno-long-long -pipe -fsingle-precision-constant -msse4 -O3 -mtune=core2 -ffast-math -flto"
 
 linkerFlags = "-rdynamic -flto -L../../extern/lib-x86-64-linux -Wl,-Bstatic -lBulletSoftBody -lBulletDynamics -lBulletCollision -lLinearMath -lGLEW -lGLU -Wl,-Bdynamic -lGL -ljpeg -lSDL -lpng -lpython2.6 -lboost_system -lboost_python -lboost_filesystem -lboost_thread"

BIN
engine-rsrc/fontmap.png


BIN
engine-rsrc/side-blur.png


+ 2 - 1
shaders/PpsSideBlur.glsl

@@ -13,5 +13,6 @@ layout(location = 0) out vec3 fFragColor;
 
 void main()
 {
-	fFragColor = vec3(0.0, 0.0, texture2D(tex, vTexCoords).r);
+	float factor = texture2D(tex, vTexCoords).r;
+	fFragColor = vec3(0.0, 0.0, factor * 2.0);
 }

+ 5 - 5
shaders/Ui.glsl

@@ -1,18 +1,18 @@
 #pragma anki vertShaderBegins
 
 in vec2 position;
-in vec2 texCoords;
 
-uniform mat2 tranformation; ///< Position transformation
-uniform mat2 textureTranformation; ///< Texture transformation
+uniform mat3 tranformation; ///< Position transformation
+uniform mat3 textureTranformation; ///< Texture transformation
 
 out vec2 vTexCoords;
 
 
 void main(void)
 {
-	vTexCoords = textureTranformation * texCoords;
-	gl_Position = vec4(tranformation * position, 0.0, 1.0);
+	vec3 pos3d = vec3(position, 0.0);
+	vTexCoords = (textureTranformation * pos3d).xy;
+	gl_Position = vec4(tranformation * pos3d, 1.0);
 }
 
 #pragma anki fragShaderBegins

+ 3 - 0
src/Core/Globals.cpp

@@ -0,0 +1,3 @@
+#include "Globals.h"
+
+Ui* gUi;

+ 6 - 0
src/Core/Globals.h

@@ -0,0 +1,6 @@
+#ifndef GLOBALS_H
+#define GLOBALS_H
+
+extern class Ui* gUi;
+
+#endif

+ 4 - 1
src/Main.cpp

@@ -39,7 +39,8 @@
 #include "SkinNode.h"
 #include "Skin.h"
 #include "MaterialRuntime.h"
-#include "ScannerException.h"
+#include "Ui.h"
+#include "Globals.h"
 
 
 // map (hard coded)
@@ -120,6 +121,8 @@ void init()
 
 	srand(unsigned(time(NULL)));
 
+	gUi = new Ui;
+
 	//Ui::init();
 
 	// camera

+ 0 - 4
src/Resources/Core/ResourceManager.h

@@ -84,10 +84,6 @@ class ResourceManager
 		template<typename Type>
 		typename Types<Type>::Iterator find(const char* filename, typename Types<Type>::Container& container);
 
-		/// Find a resource using the pointer
-		template<typename Type>
-		typename Types<Type>::Iterator find(const Type* resource, typename Types<Type>::Container& container);
-
 		/// Specialized func
 		template<typename Type>
 		typename Types<Type>::Container& choseContainer();

+ 3 - 22
src/Resources/Core/ResourceManager.inl.h

@@ -31,7 +31,7 @@ void ResourceManager::allocAndLoadRsrc(const char* filename, Type*& newInstance)
 
 
 //======================================================================================================================
-// loadRsrc                                                                                                            =
+// load                                                                                                                =
 //======================================================================================================================
 template<typename Type>
 typename ResourceManager::Types<Type>::Hook& ResourceManager::load(const char* filename)
@@ -89,7 +89,7 @@ void ResourceManager::unload(const typename Types<Type>::Hook& hook)
 	typename Types<Type>::Container& c = choseContainer<Type>();
 
 	// Find
-	typename Types<Type>::Iterator it = find<Type>(hook.resource, c);
+	typename Types<Type>::Iterator it = find<Type>(hook.uuid.c_str(), c);
 
 	// If not found
 	if(it == c.end())
@@ -102,6 +102,7 @@ void ResourceManager::unload(const typename Types<Type>::Hook& hook)
 		INFO(it->uuid << " " << hook.uuid);
 	}
 
+	ERROR(it->uuid << " " << hook.uuid << " " << it->resource << " " << hook.resource << " " << dummyTex.get());
 	ASSERT(it->uuid == hook.uuid);
 	ASSERT(it->referenceCounter == hook.referenceCounter);
 
@@ -134,23 +135,3 @@ ResourceManager::find(const char* filename, typename Types<Type>::Container& con
 
 	return it;
 }
-
-
-//======================================================================================================================
-// find [Type*]                                                                                                        =
-//======================================================================================================================
-template<typename Type>
-typename ResourceManager::Types<Type>::Iterator
-ResourceManager::find(const Type* resource, typename Types<Type>::Container& container)
-{
-	typename Types<Type>::Iterator it = container.begin();
-	for(; it != container.end(); it++)
-	{
-		if(it->resource == resource)
-		{
-			break;
-		}
-	}
-
-	return it;
-}

+ 1 - 0
src/Resources/Texture/Image.cpp

@@ -4,6 +4,7 @@
 #include <fstream>
 #include "Image.h"
 #include "Exception.h"
+#include "Logger.h"
 
 
 uchar Image::tgaHeaderUncompressed[12] = {0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0};

+ 1 - 1
src/Resources/Texture/Texture.cpp

@@ -14,7 +14,7 @@
 //======================================================================================================================
 int Texture::textureUnitsNum = -1;
 bool Texture::mipmappingEnabled = true;
-bool Texture::compressionEnabled = true;
+bool Texture::compressionEnabled = false;
 int Texture::anisotropyLevel = 8;
 
 

+ 16 - 221
src/Ui/Ui.cpp

@@ -1,232 +1,27 @@
-/*
-#include <stdio.h>
-#include <stdarg.h>
+#include <cstdarg>
 #include "Ui.h"
-#include "MainRenderer.h"
-#include "App.h"
+#include "GlStateMachine.h"
 #include "Texture.h"
-#include "Resource.h"
-#include "RsrcPtr.h"
+#include "Logger.h"
 
 
-namespace Ui {
-
-
-
-=======================================================================================================================================
-data members                                                                                                           =
-=======================================================================================================================================
-
-static RsrcPtr<Texture> fontMap;
-
-static RsrcPtr<ShaderProg> shader;
-
-static float  initialX;
-static float  fontW;
-static float  fontH;
-static float  color[4];
-static bool   italic;
-static float  crntX;
-static float  crntY;
-
-
-
-
-=======================================================================================================================================
-static funcs                                                                                                           =
-=======================================================================================================================================
-
-
-
-// SetGL
-static void SetGL()
-{
-	shader->bind();
-	shader->findUniVar("fontMap")->setTexture(*fontMap, 0);
-
-	GlStateMachineSingleton::getInstance().enable(GL_BLEND, true);
-	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-	GlStateMachineSingleton::getInstance().enable(GL_DEPTH_TEST, false);
-	glColor4fv(color);
-
-	// matrix stuff
-	glMatrixMode(GL_TEXTURE);
-	glPushMatrix();
-	glLoadIdentity();
-
-	glMatrixMode(GL_PROJECTION);
-	glPushMatrix();
-	app->getMainRenderer().loadMatrix(Renderer::ortho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0));
-
-	glMatrixMode(GL_MODELVIEW);
-	glPushMatrix();
-	glLoadIdentity();
-
-}
-
-
-// RestoreGL
-static void RestoreGL()
-{
-	glPopMatrix();
-	glMatrixMode(GL_PROJECTION);
-	glPopMatrix();
-	glMatrixMode(GL_TEXTURE);
-	glPopMatrix();
-}
-
-
-// DrawChar
-static void drawChar(char c)
-{
-	// first check for special chars
-	if(c=='\n') // new line
-	{
-		//glTranslatef(initial_x, -font_h, 0.0);
-		crntX = initialX;
-		crntY -= fontH;
-		return;
-	}
-	if(c=='\t') // tab
-	{
-		drawChar(' ');
-		drawChar(' ');
-		return;
-	}
-	if(c<' ' || c>'~') // out of range
-	{
-		c = '~'+1;
-	}
-
-	const int CHARS_PER_LINE = 16; // the chars that font_map.tga has per line
-	const int LINES_NUM      = 8; // the lines of chars in font_map.tga
-
-	// the uvs
-	float charWidth = 1.0/float(CHARS_PER_LINE);
-	float charHeight = 1.0/float(LINES_NUM);
-	float uvTop = float(LINES_NUM - (c-' ')/CHARS_PER_LINE) / float(LINES_NUM);
-	float uvLeft = float((c-' ')%CHARS_PER_LINE) / float(CHARS_PER_LINE);
-	float uvRight = uvLeft + charWidth;
-	float uvBottom = uvTop - charHeight;
-	float uvs[4][2] = {{uvLeft, uvTop}, {uvLeft, uvBottom}, {uvRight, uvBottom}, {uvRight, uvTop}};
-
-	// the coords
-	float fwh = fontW/2.0 - crntX;
-	float fhh = fontH/2.0 - crntY;
-	float coords[4][2] = {{-fwh, fhh}, {-fwh, -fhh}, {fwh, -fhh}, {fwh, fhh}}; // from top left counterclockwise
-
-
-	if(italic)
-	{
-		coords[0][0] += fontW/5.0;
-		coords[3][0] += fontW/5.0;
-	}
-
-	glBegin(GL_QUADS);
-		glTexCoord2fv(uvs[0]);  // top left
-		glVertex2fv(coords[0]);
-		glTexCoord2fv(uvs[1]);  // bottom left
-		glVertex2fv(coords[1]);
-		glTexCoord2fv(uvs[2]);  // botton right
-		glVertex2fv(coords[2]);
-		glTexCoord2fv(uvs[3]);  // top right
-		glVertex2fv(coords[3]);
-	glEnd();
-
-	// draw outline
-	if(1)
-	glDisable(GL_TEXTURE_2D);
-	glColor3f(0.0, 0.0, 1.0);
-	glBegin(GL_LINES);
-		glVertex2fv(coords[0]);
-		glVertex2fv(coords[1]);
-		glVertex2fv(coords[2]);
-		glVertex2fv(coords[3]);
-	glEnd();
-	glEnable(GL_TEXTURE_2D);
-	// end draw outline
-
-	crntX += fontW*0.8;
-	//glTranslatef(font_w*0.8f, 0.0, 0.0); // font_w*(float) to remove the space
-}
-
-
-
-=======================================================================================================================================
-non static funcs                                                                                                       =
-=======================================================================================================================================
-
-
-
-// init
-// exec after init SDL
-void init()
-{
-	fontMap.loadRsrc("gfx/fontmapa.tga");
-	fontMap->setFiltering(Texture::TFT_LINEAR);
-	//font_map->setTexParameter(GL_TEXTURE_MAG_FILTER, GL_NEAREST);
-	shader.loadRsrc("shaders/txt.glsl");
-	setPos(0.0, 0.0);
-	setFontWidth(0.05);
-	setColor(Vec4(1.0, 1.0, 1.0, 1.0));
-	italic = false;
-}
-
-
-// setFontWidth
-// sets font width from the given param and the height fron the aspect ratio
-void setFontWidth(float w_)
-{
-	// width
-	fontW = w_;
-	// height
-	fontH = fontW * app->getMainRenderer().getAspectRatio();
-}
-
-
-// setColor
-void setColor(const Vec4& color_)
+//======================================================================================================================
+// Constructor                                                                                                         =
+//======================================================================================================================
+Ui::Ui()
 {
-	for(int i=0; i<4; i++)
-		color[i] = color_[i];
-}
+	fontMap.loadRsrc("engine-rsrc/fontmap.png");
+	columns = 16;
+	rows = 8;
 
-// setPos
-void setPos(float x_, float y_)
-{
-	initialX = crntX = x_;
-	crntY = y_;
+	sProg.loadRsrc("shaders/Ui.glsl");
 }
 
 
-// printf
-void printf(const char* format, ...)
+//======================================================================================================================
+// Destructor                                                                                                          =
+//======================================================================================================================
+Ui::~Ui()
 {
-	va_list ap;
-	char text[512];
-
-	va_start(ap, format);		// Parses The String For Variables
-		vsprintf(text, format, ap);  // And Converts Symbols To Actual Numbers
-	va_end(ap);
-
-	print(text);
+	INFO("Deleting Ui");
 }
-
-
-//print
-void print(const char* text)
-{
-	SetGL();
-	//glTranslatef(crntX, crntY, 0.0);
-	for(char* pc=const_cast<char*>(text); *pc!='\0'; pc++)
-	{
-		glLoadIdentity();
-		//glTranslatef(crntX, crntY, 0.0);
-		drawChar(*pc);
-	}
-	RestoreGL();
-}
-
-
-} // end namespace
-*/

+ 23 - 24
src/Ui/Ui.h

@@ -1,44 +1,43 @@
 #ifndef UI_H
 #define UI_H
 
-
-/*
-namespace M {
-	class Vec4;
-}
-
-namespace Ui { // begin namespace
-
-
-extern void init(); // exec after init SDL
-extern void setColor(const M::Vec4& color);
-extern void setPos(float x_, float y_);
-extern void setFontWidth(float w_);
-extern void printf(const char* format, ...);
-extern void print(const char* str);
-
-
-} // end namespace */
-
 #include "RsrcPtr.h"
 #include "Math.h"
+#include "Accessors.h"
+#include "Vbo.h"
+#include "Vao.h"
 
 
 class Ui
 {
 	public:
 		Ui();
+		~Ui();
+
+		/// @name Accessors
+		/// @{
+		GETTER_SETTER(Vec2, pos, getPosition, setPosition)
+		GETTER_SETTER(Vec2, size, getSize, setSize)
+		GETTER_SETTER(Vec4, col, getColor, setColor)
+		/// @}
+
+		void print(const char* text);
 
-		void setSize(float width, float height = -1.0);
-		void setPos(const Vec2& pos);
-		void setColor(const Vec4& col);
 		void printf(const char* format, ...);
 
 	private:
 		RsrcPtr<Texture> fontMap;
-		uint charsVertical;
-		uint charsHorizontal;
+		uint columns;
+		uint rows;
 		RsrcPtr<ShaderProg> sProg;
+
+		Vec2 pos;
+		Vec2 size;
+		Vec4 col;
+
+		Vbo qPositions;
+		Vbo qIndeces;
+		Vao qVao;
 };
 
 

Някои файлове не бяха показани, защото твърде много файлове са промени