From 772bae476889be8525d81a100b91915d29519215 Mon Sep 17 00:00:00 2001 From: spartanj Date: Fri, 27 May 2011 03:11:15 -0300 Subject: [PATCH] Added access to the loaded textures on the texture group loader. Added live write option to the log, to force non-delayed writing to the file. Added a try catch to the cWindowAl window creation. Fixed a mayor bug on the SOIL texture loading, that caused to segfault when tried to resize a non-power of two texture. Fixed a minor bug on the VBO. Fixed a minor bug on cUIWinMenu. Fixed how the SDL version is consulted on SDL 1.2 backend. Updated chipmunk. Updated Windows eetest cbp project. --- Makefile | 3 +- ee.win.cbp | 47 ++++++++ src/gaming/maphelper.hpp | 10 +- src/graphics/ctexturegrouploader.cpp | 12 ++ src/graphics/ctexturegrouploader.hpp | 21 ++-- src/graphics/cvertexbuffervbo.cpp | 2 +- src/graphics/renderer/cgl.cpp | 20 +-- src/graphics/renderer/cgl.hpp | 3 +- src/helper/SOIL/SOIL.c | 15 +-- src/helper/chipmunk/chipmunk.h | 1 - src/helper/chipmunk/chipmunk_private.h | 5 + .../constraints/cpDampedRotarySpring.c | 12 +- .../chipmunk/constraints/cpDampedSpring.c | 8 +- src/helper/chipmunk/constraints/cpGearJoint.c | 2 +- .../chipmunk/constraints/cpGrooveJoint.c | 2 +- src/helper/chipmunk/constraints/cpPinJoint.c | 2 +- .../chipmunk/constraints/cpPivotJoint.c | 2 +- .../chipmunk/constraints/cpRatchetJoint.c | 2 +- .../chipmunk/constraints/cpRotaryLimitJoint.c | 2 +- .../chipmunk/constraints/cpSimpleMotor.c | 2 +- .../chipmunk/constraints/cpSlideJoint.c | 2 +- src/helper/chipmunk/cpBBTree.c | 6 +- src/helper/chipmunk/cpBody.c | 40 ++++-- src/helper/chipmunk/cpHashSet.c | 2 +- src/helper/chipmunk/cpPolyShape.c | 6 +- src/helper/chipmunk/cpShape.c | 15 ++- src/helper/chipmunk/cpShape.h | 5 +- src/helper/chipmunk/cpSpace.c | 80 +++++------- src/helper/chipmunk/cpSpaceComponent.c | 2 +- src/helper/chipmunk/cpSpaceHash.c | 9 +- src/helper/chipmunk/cpSpaceStep.c | 22 ++-- src/helper/chipmunk/cpSpatialIndex.h | 2 +- src/system/clog.cpp | 55 ++++++--- src/system/clog.hpp | 12 +- src/test/eetest.cpp | 65 +++++----- src/ui/cuitheme.cpp | 97 +++++++++++++++ src/ui/cuitheme.hpp | 26 ++++ src/ui/cuiwinmenu.hpp | 2 +- src/window/backend/SDL/cwindowsdl.cpp | 4 +- src/window/backend/allegro5/cwindowal.cpp | 114 +++++++++--------- src/window/cwindow.cpp | 4 +- 41 files changed, 504 insertions(+), 239 deletions(-) diff --git a/Makefile b/Makefile index b4222d70a..c71a38d96 100644 --- a/Makefile +++ b/Makefile @@ -168,7 +168,7 @@ SRCCHIPMUNK = $(wildcard ./src/helper/chipmunk/*.c) $(wildcard ./src/helper/ch SRCHAIKUTTF = $(wildcard ./src/helper/haikuttf/*.cpp) SRCBASE = $(wildcard ./src/base/*.cpp) SRCAUDIO = $(wildcard ./src/audio/*.cpp) -SRCGAMING = $(wildcard ./src/gaming/*.cpp) +SRCGAMING = $(wildcard ./src/gaming/*.cpp) $(wildcard ./src/gaming/mapeditor/*.cpp) SRCGRAPHICS = $(wildcard ./src/graphics/*.cpp) $(wildcard ./src/graphics/renderer/*.cpp) SRCMATH = $(wildcard ./src/math/*.cpp) SRCSYSTEM = $(wildcard ./src/system/*.cpp) @@ -243,6 +243,7 @@ dirs: @mkdir -p $(OBJDIR)/src/base @mkdir -p $(OBJDIR)/src/audio @mkdir -p $(OBJDIR)/src/gaming + @mkdir -p $(OBJDIR)/src/gaming/mapeditor @mkdir -p $(OBJDIR)/src/graphics @mkdir -p $(OBJDIR)/src/graphics/renderer @mkdir -p $(OBJDIR)/src/math diff --git a/ee.win.cbp b/ee.win.cbp index 2c1e9905f..3a0c467df 100644 --- a/ee.win.cbp +++ b/ee.win.cbp @@ -36,6 +36,7 @@ + @@ -84,12 +85,33 @@ + + + + + + + + + + + + + + + + + + + + + @@ -310,6 +332,9 @@ + + @@ -691,6 +716,8 @@ + + @@ -739,6 +766,8 @@ + + @@ -771,6 +800,8 @@ + + @@ -797,6 +828,22 @@ + + + + + + + + + + + + + + + + diff --git a/src/gaming/maphelper.hpp b/src/gaming/maphelper.hpp index 7be57a995..b196a5f81 100644 --- a/src/gaming/maphelper.hpp +++ b/src/gaming/maphelper.hpp @@ -6,11 +6,11 @@ namespace EE { namespace Gaming { class GObjFlags { public: enum EE_GAMEOBJECT_FLAGS { - GAMEOBJECT_STATIC = 0, - GAMEOBJECT_ANIMATED, - GAMEOBJECT_MIRRORED, - GAMEOBJECT_FLIPED, - GAMEOBJECT_BLOCKED + GAMEOBJECT_STATIC = ( 1 << 0 ), + GAMEOBJECT_ANIMATED = ( 1 << 1 ), + GAMEOBJECT_MIRRORED = ( 1 << 2 ), + GAMEOBJECT_FLIPED = ( 1 << 3 ), + GAMEOBJECT_BLOCKED = ( 1 << 4 ) }; }; diff --git a/src/graphics/ctexturegrouploader.cpp b/src/graphics/ctexturegrouploader.cpp index 8b352fb76..a128ef18e 100644 --- a/src/graphics/ctexturegrouploader.cpp +++ b/src/graphics/ctexturegrouploader.cpp @@ -176,11 +176,14 @@ void cTextureGroupLoader::CreateShapes() { Int32 pos = StrStartsWith( mAppPath, path ); + // Removes the app path part if ( -1 != pos && (Uint32)(pos + 1) < path.size() ) path = path.substr( pos + 1 ); cTexture * tTex = cTextureFactory::instance()->GetByName( path ); + mTexuresLoaded.push_back( tTex ); + // Create the Shape Group with the name of the real texture, not the Childs ( example load 1.png and not 1_ch1.png ) if ( 0 == z ) { if ( mTexGrHdr.Flags & HDR_TEXTURE_GROUP_REMOVE_EXTENSION ) @@ -236,6 +239,15 @@ const bool& cTextureGroupLoader::IsLoading() const { return mIsLoading; } +cTexture * cTextureGroupLoader::GetTexture( const Uint32& texnum ) const { + eeASSERT( texnum < mTexuresLoaded.size() ); + return mTexuresLoaded[ texnum ]; +} + +Uint32 cTextureGroupLoader::GetTexturesLoadedCount() { + return mTexuresLoaded.size(); +} + bool cTextureGroupLoader::UpdateTextureAtlas( std::string TextureAtlasPath, std::string ImagesPath ) { if ( !TextureAtlasPath.size() || !ImagesPath.size() || !FileExists( TextureAtlasPath ) || !IsDirectory( ImagesPath ) ) return false; diff --git a/src/graphics/ctexturegrouploader.hpp b/src/graphics/ctexturegrouploader.hpp index dd7d521d8..1421a7c7e 100644 --- a/src/graphics/ctexturegrouploader.hpp +++ b/src/graphics/ctexturegrouploader.hpp @@ -41,15 +41,20 @@ class EE_API cTextureGroupLoader { /** Will check if the texture atlas is updated ( all the image of the path are inside the texture atlas, and are the same version, otherwise it will recreate or update the texture atlas. */ bool UpdateTextureAtlas( std::string TextureAtlasPath, std::string ImagesPath ); + + cTexture * GetTexture( const Uint32& texnum = 0 ) const; + + Uint32 GetTexturesLoadedCount(); protected: - cResourceLoader mRL; - std::string mTextureGroupPath; - bool mThreaded; - bool mLoaded; - std::string mAppPath; - cPack * mPack; - bool mSkipResourceLoad; - bool mIsLoading; + cResourceLoader mRL; + std::string mTextureGroupPath; + bool mThreaded; + bool mLoaded; + std::string mAppPath; + cPack * mPack; + bool mSkipResourceLoad; + bool mIsLoading; + std::vector mTexuresLoaded; typedef struct sTempTexGroupS { sTextureHdr Texture; diff --git a/src/graphics/cvertexbuffervbo.cpp b/src/graphics/cvertexbuffervbo.cpp index 894c5ce93..e1fab7d9e 100644 --- a/src/graphics/cvertexbuffervbo.cpp +++ b/src/graphics/cvertexbuffervbo.cpp @@ -76,7 +76,7 @@ bool cVertexBufferVBO::Compile() { } } - glBindBuffer( GL_ARRAY_BUFFER, 0 ); + glBindBufferARB( GL_ARRAY_BUFFER, 0 ); //Create the VBO index array if( VERTEX_FLAG_QUERY( mVertexFlags, VERTEX_FLAG_USE_INDICES ) ) { diff --git a/src/graphics/renderer/cgl.cpp b/src/graphics/renderer/cgl.cpp index 2ed839de7..50a22b55a 100644 --- a/src/graphics/renderer/cgl.cpp +++ b/src/graphics/renderer/cgl.cpp @@ -115,7 +115,8 @@ void cGL::Init() { WriteExtension( EEGL_EXT_framebuffer_object , GLEW_EXT_framebuffer_object ); WriteExtension( EEGL_ARB_multitexture , GLEW_ARB_multitexture ); WriteExtension( EEGL_EXT_texture_compression_s3tc , GLEW_EXT_texture_compression_s3tc ); - WriteExtension( EEGL_ARB_vertex_buffer_object , GLEW_ARB_vertex_buffer_object ); + WriteExtension( EEGL_ARB_vertex_buffer_object , GLEW_ARB_vertex_buffer_object ); + WriteExtension( EEGL_ARB_vertex_array_object , GLEW_ARB_vertex_array_object ); } else #endif @@ -130,7 +131,8 @@ void cGL::Init() { WriteExtension( EEGL_EXT_framebuffer_object , IsExtension( "GL_EXT_framebuffer_object" ) ); WriteExtension( EEGL_ARB_multitexture , IsExtension( "GL_ARB_multitexture" ) ); WriteExtension( EEGL_EXT_texture_compression_s3tc , IsExtension( "GL_EXT_texture_compression_s3tc" ) ); - WriteExtension( EEGL_ARB_vertex_buffer_object , IsExtension( "GL_ARB_vertex_buffer_object" ) ); + WriteExtension( EEGL_ARB_vertex_buffer_object , IsExtension( "GL_ARB_vertex_buffer_object" ) ); + WriteExtension( EEGL_ARB_vertex_array_object , IsExtension( "GL_ARB_vertex_array_object" ) ); glewOn = false; /// avoid compiler warning } @@ -343,12 +345,14 @@ std::string cGL::GetVersion() { return std::string( reinterpret_cast ( cGL::instance()->GetString( GL_VERSION ) ) ); } -std::string cGL::GetShadingLanguageVersion() { - #ifdef GL_SHADING_LANGUAGE_VERSION - return std::string( reinterpret_cast ( cGL::instance()->GetString( GL_SHADING_LANGUAGE_VERSION ) ) ); - #else - return std::string( "0" ); - #endif +std::string cGL::GetShadingLanguageVersion() { + if ( ShadersSupported() ) { + #ifdef GL_SHADING_LANGUAGE_VERSION + return std::string( reinterpret_cast ( cGL::instance()->GetString( GL_SHADING_LANGUAGE_VERSION ) ) ); + #endif + } + + return std::string( "Shaders not supported" ); } }} diff --git a/src/graphics/renderer/cgl.hpp b/src/graphics/renderer/cgl.hpp index 5dbdc2713..e213cac99 100644 --- a/src/graphics/renderer/cgl.hpp +++ b/src/graphics/renderer/cgl.hpp @@ -17,7 +17,8 @@ enum EEGL_extensions { EEGL_EXT_framebuffer_object, EEGL_ARB_multitexture, EEGL_EXT_texture_compression_s3tc, - EEGL_ARB_vertex_buffer_object + EEGL_ARB_vertex_buffer_object, + EEGL_ARB_vertex_array_object }; enum EEGL_version { diff --git a/src/helper/SOIL/SOIL.c b/src/helper/SOIL/SOIL.c index e7f89dc4c..731c72dea 100755 --- a/src/helper/SOIL/SOIL.c +++ b/src/helper/SOIL/SOIL.c @@ -1043,6 +1043,14 @@ unsigned int } } + /* if the user can't support NPOT textures, make sure we force the POT option */ + if( (query_NPOT_capability() == SOIL_CAPABILITY_NONE) && + !(flags & SOIL_FLAG_TEXTURE_RECTANGLE) ) + { + /* add in the POT flag */ + flags |= SOIL_FLAG_POWER_OF_TWO; + } + needCopy = ( ( flags & SOIL_FLAG_INVERT_Y ) || ( flags & SOIL_FLAG_NTSC_SAFE_RGB ) || ( flags & SOIL_FLAG_MULTIPLY_ALPHA ) || ( ( flags & SOIL_FLAG_POWER_OF_TWO ) || ( flags & SOIL_FLAG_MIPMAPS ) || ( iwidth > max_supported_size ) || ( iheight > max_supported_size ) ) || ( flags & SOIL_FLAG_CoCg_Y ) || ( flags & SOIL_FLAG_COMPRESS_TO_DXT ) ); /* create a copy the image data @@ -1102,13 +1110,6 @@ unsigned int break; } } - /* if the user can't support NPOT textures, make sure we force the POT option */ - if( (query_NPOT_capability() == SOIL_CAPABILITY_NONE) && - !(flags & SOIL_FLAG_TEXTURE_RECTANGLE) ) - { - /* add in the POT flag */ - flags |= SOIL_FLAG_POWER_OF_TWO; - } /* do I need to make it a power of 2? */ if( diff --git a/src/helper/chipmunk/chipmunk.h b/src/helper/chipmunk/chipmunk.h index 680c89675..895597bad 100644 --- a/src/helper/chipmunk/chipmunk.h +++ b/src/helper/chipmunk/chipmunk.h @@ -58,7 +58,6 @@ void cpMessage(const char *message, const char *condition, const char *file, int #define CP_BUFFER_BYTES (32*1024) //TODO allow redifinition -#define cpmalloc malloc #define cpcalloc calloc #define cprealloc realloc #define cpfree free diff --git a/src/helper/chipmunk/chipmunk_private.h b/src/helper/chipmunk/chipmunk_private.h index a39695159..b2d9bc4f9 100644 --- a/src/helper/chipmunk/chipmunk_private.h +++ b/src/helper/chipmunk/chipmunk_private.h @@ -103,6 +103,11 @@ void cpArbiterPreStep(cpArbiter *arb, cpFloat dt, cpFloat bias, cpFloat slop); void cpArbiterApplyCachedImpulse(cpArbiter *arb, cpFloat dt_coef); void cpArbiterApplyImpulse(cpArbiter *arb); +#pragma mark Body Functions + +void cpBodyAddShape(cpBody *body, cpShape *shape); +void cpBodyRemoveShape(cpBody *body, cpShape *shape); + #pragma mark Shape/Collision Functions cpShape* cpShapeInit(cpShape *shape, const cpShapeClass *klass, cpBody *body); diff --git a/src/helper/chipmunk/constraints/cpDampedRotarySpring.c b/src/helper/chipmunk/constraints/cpDampedRotarySpring.c index 81cb6bc29..cb2f34b0c 100644 --- a/src/helper/chipmunk/constraints/cpDampedRotarySpring.c +++ b/src/helper/chipmunk/constraints/cpDampedRotarySpring.c @@ -40,7 +40,7 @@ preStep(cpDampedRotarySpring *spring, cpFloat dt) cpAssert(moment != 0.0, "Unsolvable spring."); spring->iSum = 1.0f/moment; - spring->w_coef = 1.0f - cpfexp(-spring->damping*dt*moment*0.25f/(cpFloat)M_E); + spring->w_coef = 1.0f - cpfexp(-spring->damping*dt*moment); spring->target_wrn = 0.0f; // apply spring torque @@ -62,13 +62,13 @@ applyImpulse(cpDampedRotarySpring *spring) // compute velocity loss from drag // not 100% certain this is derived correctly, though it makes sense - cpFloat w_damp = wrn*spring->w_coef; - spring->target_wrn = wrn - w_damp; + cpFloat w_damp = (spring->target_wrn - wrn)*spring->w_coef; + spring->target_wrn = wrn + w_damp; //apply_impulses(a, b, spring->r1, spring->r2, cpvmult(spring->n, v_damp*spring->nMass)); cpFloat j_damp = w_damp*spring->iSum; - a->w -= j_damp*a->i_inv; - b->w += j_damp*b->i_inv; + a->w += j_damp*a->i_inv; + b->w -= j_damp*b->i_inv; } static cpFloat @@ -88,7 +88,7 @@ CP_DefineClassGetter(cpDampedRotarySpring) cpDampedRotarySpring * cpDampedRotarySpringAlloc(void) { - return (cpDampedRotarySpring *)cpmalloc(sizeof(cpDampedRotarySpring)); + return (cpDampedRotarySpring *)cpcalloc(1, sizeof(cpDampedRotarySpring)); } cpDampedRotarySpring * diff --git a/src/helper/chipmunk/constraints/cpDampedSpring.c b/src/helper/chipmunk/constraints/cpDampedSpring.c index ef3819251..80a9188f7 100644 --- a/src/helper/chipmunk/constraints/cpDampedSpring.c +++ b/src/helper/chipmunk/constraints/cpDampedSpring.c @@ -48,7 +48,7 @@ preStep(cpDampedSpring *spring, cpFloat dt) spring->nMass = 1.0f/k; spring->target_vrn = 0.0f; - spring->v_coef = 1.0f - cpfexp(-spring->damping*dt*k*0.5f/(cpFloat)M_E); + spring->v_coef = 1.0f - cpfexp(-spring->damping*dt*k); // apply spring force cpFloat f_spring = spring->springForceFunc((cpConstraint *)spring, dist); @@ -68,10 +68,10 @@ applyImpulse(cpDampedSpring *spring) cpVect r2 = spring->r2; // compute relative velocity - cpFloat vrn = normal_relative_velocity(a, b, r1, r2, n) - spring->target_vrn; + cpFloat vrn = normal_relative_velocity(a, b, r1, r2, n); // compute velocity loss from drag - cpFloat v_damp = -vrn*spring->v_coef; + cpFloat v_damp = (spring->target_vrn - vrn)*spring->v_coef; spring->target_vrn = vrn + v_damp; apply_impulses(a, b, spring->r1, spring->r2, cpvmult(spring->n, v_damp*spring->nMass)); @@ -94,7 +94,7 @@ CP_DefineClassGetter(cpDampedSpring) cpDampedSpring * cpDampedSpringAlloc(void) { - return (cpDampedSpring *)cpmalloc(sizeof(cpDampedSpring)); + return (cpDampedSpring *)cpcalloc(1, sizeof(cpDampedSpring)); } cpDampedSpring * diff --git a/src/helper/chipmunk/constraints/cpGearJoint.c b/src/helper/chipmunk/constraints/cpGearJoint.c index 5426c4ec0..37cb45f32 100644 --- a/src/helper/chipmunk/constraints/cpGearJoint.c +++ b/src/helper/chipmunk/constraints/cpGearJoint.c @@ -90,7 +90,7 @@ CP_DefineClassGetter(cpGearJoint) cpGearJoint * cpGearJointAlloc(void) { - return (cpGearJoint *)cpmalloc(sizeof(cpGearJoint)); + return (cpGearJoint *)cpcalloc(1, sizeof(cpGearJoint)); } cpGearJoint * diff --git a/src/helper/chipmunk/constraints/cpGrooveJoint.c b/src/helper/chipmunk/constraints/cpGrooveJoint.c index 5d46dded1..99abe7f6f 100644 --- a/src/helper/chipmunk/constraints/cpGrooveJoint.c +++ b/src/helper/chipmunk/constraints/cpGrooveJoint.c @@ -121,7 +121,7 @@ CP_DefineClassGetter(cpGrooveJoint) cpGrooveJoint * cpGrooveJointAlloc(void) { - return (cpGrooveJoint *)cpmalloc(sizeof(cpGrooveJoint)); + return (cpGrooveJoint *)cpcalloc(1, sizeof(cpGrooveJoint)); } cpGrooveJoint * diff --git a/src/helper/chipmunk/constraints/cpPinJoint.c b/src/helper/chipmunk/constraints/cpPinJoint.c index 8bd53dfa5..4210964b6 100644 --- a/src/helper/chipmunk/constraints/cpPinJoint.c +++ b/src/helper/chipmunk/constraints/cpPinJoint.c @@ -97,7 +97,7 @@ CP_DefineClassGetter(cpPinJoint); cpPinJoint * cpPinJointAlloc(void) { - return (cpPinJoint *)cpmalloc(sizeof(cpPinJoint)); + return (cpPinJoint *)cpcalloc(1, sizeof(cpPinJoint)); } cpPinJoint * diff --git a/src/helper/chipmunk/constraints/cpPivotJoint.c b/src/helper/chipmunk/constraints/cpPivotJoint.c index b2c7b5795..5f51144e4 100644 --- a/src/helper/chipmunk/constraints/cpPivotJoint.c +++ b/src/helper/chipmunk/constraints/cpPivotJoint.c @@ -93,7 +93,7 @@ CP_DefineClassGetter(cpPivotJoint) cpPivotJoint * cpPivotJointAlloc(void) { - return (cpPivotJoint *)cpmalloc(sizeof(cpPivotJoint)); + return (cpPivotJoint *)cpcalloc(1, sizeof(cpPivotJoint)); } cpPivotJoint * diff --git a/src/helper/chipmunk/constraints/cpRatchetJoint.c b/src/helper/chipmunk/constraints/cpRatchetJoint.c index 4a1a4dd7f..69defb0a0 100644 --- a/src/helper/chipmunk/constraints/cpRatchetJoint.c +++ b/src/helper/chipmunk/constraints/cpRatchetJoint.c @@ -110,7 +110,7 @@ CP_DefineClassGetter(cpRatchetJoint) cpRatchetJoint * cpRatchetJointAlloc(void) { - return (cpRatchetJoint *)cpmalloc(sizeof(cpRatchetJoint)); + return (cpRatchetJoint *)cpcalloc(1, sizeof(cpRatchetJoint)); } cpRatchetJoint * diff --git a/src/helper/chipmunk/constraints/cpRotaryLimitJoint.c b/src/helper/chipmunk/constraints/cpRotaryLimitJoint.c index f4d9f51a5..a314112c2 100644 --- a/src/helper/chipmunk/constraints/cpRotaryLimitJoint.c +++ b/src/helper/chipmunk/constraints/cpRotaryLimitJoint.c @@ -107,7 +107,7 @@ CP_DefineClassGetter(cpRotaryLimitJoint) cpRotaryLimitJoint * cpRotaryLimitJointAlloc(void) { - return (cpRotaryLimitJoint *)cpmalloc(sizeof(cpRotaryLimitJoint)); + return (cpRotaryLimitJoint *)cpcalloc(1, sizeof(cpRotaryLimitJoint)); } cpRotaryLimitJoint * diff --git a/src/helper/chipmunk/constraints/cpSimpleMotor.c b/src/helper/chipmunk/constraints/cpSimpleMotor.c index 333c845d7..45082bcc3 100644 --- a/src/helper/chipmunk/constraints/cpSimpleMotor.c +++ b/src/helper/chipmunk/constraints/cpSimpleMotor.c @@ -86,7 +86,7 @@ CP_DefineClassGetter(cpSimpleMotor) cpSimpleMotor * cpSimpleMotorAlloc(void) { - return (cpSimpleMotor *)cpmalloc(sizeof(cpSimpleMotor)); + return (cpSimpleMotor *)cpcalloc(1, sizeof(cpSimpleMotor)); } cpSimpleMotor * diff --git a/src/helper/chipmunk/constraints/cpSlideJoint.c b/src/helper/chipmunk/constraints/cpSlideJoint.c index 698b936d6..6d19a5846 100644 --- a/src/helper/chipmunk/constraints/cpSlideJoint.c +++ b/src/helper/chipmunk/constraints/cpSlideJoint.c @@ -112,7 +112,7 @@ CP_DefineClassGetter(cpSlideJoint) cpSlideJoint * cpSlideJointAlloc(void) { - return (cpSlideJoint *)cpmalloc(sizeof(cpSlideJoint)); + return (cpSlideJoint *)cpcalloc(1, sizeof(cpSlideJoint)); } cpSlideJoint * diff --git a/src/helper/chipmunk/cpBBTree.c b/src/helper/chipmunk/cpBBTree.c index 6ba93c656..39ed8d4e4 100644 --- a/src/helper/chipmunk/cpBBTree.c +++ b/src/helper/chipmunk/cpBBTree.c @@ -153,7 +153,7 @@ PairFromPool(cpBBTree *tree) int count = CP_BUFFER_BYTES/sizeof(Pair); cpAssert(count, "Buffer size is too small."); - Pair *buffer = (Pair *)cpmalloc(CP_BUFFER_BYTES); + Pair *buffer = (Pair *)cpcalloc(1, CP_BUFFER_BYTES); cpArrayPush(tree->allocatedBuffers, buffer); // push all but the first one, return the first instead @@ -242,7 +242,7 @@ NodeFromPool(cpBBTree *tree) int count = CP_BUFFER_BYTES/sizeof(Node); cpAssert(count, "Buffer size is too small."); - Node *buffer = (Node *)cpmalloc(CP_BUFFER_BYTES); + Node *buffer = (Node *)cpcalloc(1, CP_BUFFER_BYTES); cpArrayPush(tree->allocatedBuffers, buffer); // push all but the first one, return the first instead @@ -578,7 +578,7 @@ cpBBTreeDestroy(cpBBTree *tree) { cpHashSetFree(tree->leaves); - cpArrayFreeEach(tree->allocatedBuffers, cpfree); + if(tree->allocatedBuffers) cpArrayFreeEach(tree->allocatedBuffers, cpfree); cpArrayFree(tree->allocatedBuffers); } diff --git a/src/helper/chipmunk/cpBody.c b/src/helper/chipmunk/cpBody.c index 4c9be6427..788a0e976 100644 --- a/src/helper/chipmunk/cpBody.c +++ b/src/helper/chipmunk/cpBody.c @@ -32,14 +32,12 @@ cpBody cpStaticBodySingleton; cpBody* cpBodyAlloc(void) { - return (cpBody *)cpmalloc(sizeof(cpBody)); + return (cpBody *)cpcalloc(1, sizeof(cpBody)); } cpBody * cpBodyInit(cpBody *body, cpFloat m, cpFloat i) { - bzero(body, sizeof(cpBody)); - body->space = NULL; body->shapeList = NULL; body->arbiterList = NULL; @@ -48,14 +46,13 @@ cpBodyInit(cpBody *body, cpFloat m, cpFloat i) body->velocity_func = cpBodyUpdateVelocity; body->position_func = cpBodyUpdatePosition; - cpBodySetMass(body, m); - cpBodySetMoment(body, i); - + cpComponentNode node = {NULL, NULL, 0.0f}; + body->node = node; + body->p = cpvzero; body->v = cpvzero; body->f = cpvzero; - cpBodySetAngle(body, 0.0f); body->w = 0.0f; body->t = 0.0f; @@ -65,11 +62,13 @@ cpBodyInit(cpBody *body, cpFloat m, cpFloat i) body->v_limit = (cpFloat)INFINITY; body->w_limit = (cpFloat)INFINITY; - cpComponentNode node = {NULL, NULL, 0.0f}; - body->node = node; - body->data = NULL; + // Setters must be called after full initialization so the sanity checks don't assert on garbage data. + cpBodySetMass(body, m); + cpBodySetMoment(body, i); + cpBodySetAngle(body, 0.0f); + return body; } @@ -145,6 +144,27 @@ cpBodySetMoment(cpBody *body, cpFloat moment) body->i_inv = 1.0f/moment; } +void +cpBodyAddShape(cpBody *body, cpShape *shape) +{ + shape->next = body->shapeList; body->shapeList = shape; +} + +void +cpBodyRemoveShape(cpBody *body, cpShape *shape) +{ + cpShape **prev_ptr = &body->shapeList; + cpShape *node = body->shapeList; + + while(node && node != shape){ + prev_ptr = &node->next; + node = node->next; + } + + cpAssert(node, "Attempted to remove a shape from a body it was never attached to."); + (*prev_ptr) = node->next; +} + static inline void updateShapes(cpBody *body){ cpSpace *space = body->space; diff --git a/src/helper/chipmunk/cpHashSet.c b/src/helper/chipmunk/cpHashSet.c index 1fb2d10bd..1da80a5b2 100644 --- a/src/helper/chipmunk/cpHashSet.c +++ b/src/helper/chipmunk/cpHashSet.c @@ -137,7 +137,7 @@ getUnusedBin(cpHashSet *set) int count = CP_BUFFER_BYTES/sizeof(cpHashSetBin); cpAssert(count, "Buffer size is too small."); - cpHashSetBin *buffer = (cpHashSetBin *)cpmalloc(CP_BUFFER_BYTES); + cpHashSetBin *buffer = (cpHashSetBin *)cpcalloc(1, CP_BUFFER_BYTES); cpArrayPush(set->allocatedBuffers, buffer); // push all but the first one, return it instead diff --git a/src/helper/chipmunk/cpPolyShape.c b/src/helper/chipmunk/cpPolyShape.c index 6b627e0de..4d46183fa 100644 --- a/src/helper/chipmunk/cpPolyShape.c +++ b/src/helper/chipmunk/cpPolyShape.c @@ -75,10 +75,8 @@ cpPolyShapeCacheData(cpPolyShape *poly, cpVect p, cpVect rot) } static void -cpPolyShapeDestroy(cpShape *shape) +cpPolyShapeDestroy(cpPolyShape *poly) { - cpPolyShape *poly = (cpPolyShape *)shape; - cpfree(poly->verts); cpfree(poly->tVerts); @@ -227,6 +225,6 @@ void cpPolyShapeSetVerts(cpShape *shape, int numVerts, cpVect *verts, cpVect offset) { cpAssert(shape->klass == &polyClass, "Shape is not a poly shape."); - cpPolyShapeDestroy(shape); + cpPolyShapeDestroy((cpPolyShape *)shape); setUpVerts((cpPolyShape *)shape, numVerts, verts, offset); } diff --git a/src/helper/chipmunk/cpShape.c b/src/helper/chipmunk/cpShape.c index bb5bcb1d3..1ed92ea8b 100644 --- a/src/helper/chipmunk/cpShape.c +++ b/src/helper/chipmunk/cpShape.c @@ -69,7 +69,7 @@ cpShapeInit(cpShape *shape, const cpShapeClass *klass, cpBody *body) void cpShapeDestroy(cpShape *shape) { - if(shape->klass->destroy) shape->klass->destroy(shape); + if(shape->klass && shape->klass->destroy) shape->klass->destroy(shape); } void @@ -81,6 +81,19 @@ cpShapeFree(cpShape *shape) } } +void +cpShapeSetBody(cpShape *shape, cpBody *body) +{ + // This is a little tricky, but was requested by a user. + // Changing the body on an active shape swapping out the shape lists on the bodies + if(shape->next){ + cpBodyRemoveShape(shape->body, shape); + cpBodyAddShape(body, shape); + } + + shape->body = body; +} + cpBB cpShapeCacheBB(cpShape *shape) { diff --git a/src/helper/chipmunk/cpShape.h b/src/helper/chipmunk/cpShape.h index 691281d59..1a64507a2 100644 --- a/src/helper/chipmunk/cpShape.h +++ b/src/helper/chipmunk/cpShape.h @@ -121,8 +121,9 @@ static inline void cpShapeSet##name(cpShape *shape, type value){ \ CP_DefineShapeStructGetter(type, member, name) \ CP_DefineShapeStructSetter(type, member, name, activates) -// TODO the properties -CP_DefineShapeStructProperty(cpBody *, body, Body, cpTrue); +CP_DefineShapeStructGetter(cpBody *, body, Body); +void cpShapeSetBody(cpShape *shape, cpBody *body); + CP_DefineShapeStructGetter(cpBB, bb, BB); CP_DefineShapeStructProperty(cpBool, sensor, IsSensor, cpTrue); CP_DefineShapeStructProperty(cpFloat, e, Elasticity, cpFalse); diff --git a/src/helper/chipmunk/cpSpace.c b/src/helper/chipmunk/cpSpace.c index bf8024907..4a63e0629 100644 --- a/src/helper/chipmunk/cpSpace.c +++ b/src/helper/chipmunk/cpSpace.c @@ -51,7 +51,7 @@ handlerSetEql(cpCollisionHandler *check, cpCollisionHandler *pair) static void * handlerSetTrans(cpCollisionHandler *handler, void *unused) { - cpCollisionHandler *copy = (cpCollisionHandler *)cpmalloc(sizeof(cpCollisionHandler)); + cpCollisionHandler *copy = (cpCollisionHandler *)cpcalloc(1, sizeof(cpCollisionHandler)); (*copy) = (*handler); return copy; @@ -155,15 +155,11 @@ cpSpaceDestroy(cpSpace *space) cpArrayFree(space->allocatedBuffers); } - if(space->postStepCallbacks){ - cpHashSetEach(space->postStepCallbacks, freeWrap, NULL); - cpHashSetFree(space->postStepCallbacks); - } + if(space->postStepCallbacks) cpHashSetEach(space->postStepCallbacks, freeWrap, NULL); + cpHashSetFree(space->postStepCallbacks); - if(space->collisionHandlers){ - cpHashSetEach(space->collisionHandlers, freeWrap, NULL); - cpHashSetFree(space->collisionHandlers); - } + if(space->collisionHandlers) cpHashSetEach(space->collisionHandlers, freeWrap, NULL); + cpHashSetFree(space->collisionHandlers); } void @@ -175,6 +171,12 @@ cpSpaceFree(cpSpace *space) } } +#define cpAssertSpaceUnlocked(space) \ + cpAssert(!space->locked, \ + "This addition/removal cannot be done safely during a call to cpSpaceStep() or during a query. " \ + "Put these calls into a post-step callback." \ + ); + #pragma mark Collision Handler Function Management void @@ -187,6 +189,8 @@ cpSpaceAddCollisionHandler( cpCollisionSeparateFunc separate, void *data ){ + cpAssertSpaceUnlocked(space); + // Remove any old function so the new one will get added. cpSpaceRemoveCollisionHandler(space, a, b); @@ -205,6 +209,8 @@ cpSpaceAddCollisionHandler( void cpSpaceRemoveCollisionHandler(cpSpace *space, cpCollisionType a, cpCollisionType b) { + cpAssertSpaceUnlocked(space); + struct { cpCollisionType a, b; } ids = {a, b}; cpCollisionHandler *old_handler = (cpCollisionHandler *) cpHashSetRemove(space->collisionHandlers, CP_HASH_PAIR(a, b), &ids); cpfree(old_handler); @@ -219,6 +225,8 @@ cpSpaceSetDefaultCollisionHandler( cpCollisionSeparateFunc separate, void *data ){ + cpAssertSpaceUnlocked(space); + cpCollisionHandler handler = { 0, 0, begin ? begin : alwaysCollide, @@ -233,28 +241,6 @@ cpSpaceSetDefaultCollisionHandler( } #pragma mark Body, Shape, and Joint Management - -#define cpAssertSpaceUnlocked(space) \ - cpAssert(!space->locked, \ - "This addition/removal cannot be done safely during a call to cpSpaceStep() or during a query. " \ - "Put these calls into a post-step callback." \ - ); - -static void -cpBodyRemoveShape(cpBody *body, cpShape *shape) -{ - cpShape **prev_ptr = &body->shapeList; - cpShape *node = body->shapeList; - - while(node && node != shape){ - prev_ptr = &node->next; - node = node->next; - } - - cpAssert(node, "Attempted to remove a shape from a body it was never attached to."); - (*prev_ptr) = node->next; -} - cpShape * cpSpaceAddShape(cpSpace *space, cpShape *shape) { @@ -266,9 +252,7 @@ cpSpaceAddShape(cpSpace *space, cpShape *shape) cpAssertSpaceUnlocked(space); cpBodyActivate(body); - - // Push onto the head of the body's shape list - shape->next = body->shapeList; body->shapeList = shape; + cpBodyAddShape(body, shape); cpShapeUpdate(shape, body->p, body->rot); cpSpatialIndexInsert(space->activeShapes, shape, shape->hashid); @@ -284,6 +268,7 @@ cpSpaceAddStaticShape(cpSpace *space, cpShape *shape) cpAssertSpaceUnlocked(space); cpBody *body = shape->body; + cpBodyAddShape(body, shape); cpShapeUpdate(shape, body->p, body->rot); cpSpaceActivateShapesTouchingShape(space, shape); cpSpatialIndexInsert(space->staticShapes, shape, shape->hashid); @@ -392,20 +377,19 @@ cpSpaceRemoveShape(cpSpace *space, cpShape *shape) cpBody *body = shape->body; if(cpBodyIsStatic(body)){ cpSpaceRemoveStaticShape(space, shape); - return; + } else { + cpBodyActivate(body); + + cpAssert(cpSpaceContainsShape(space, shape), + "Cannot remove a shape that was not added to the space. (Removed twice maybe?)"); + cpAssertSpaceUnlocked(space); + + cpBodyRemoveShape(body, shape); + + arbiterRemovalContext context = {space, shape}; + cpHashSetFilter(space->cachedArbiters, (cpHashSetFilterFunc)arbiterSetFilterRemovedShape, &context); + cpSpatialIndexRemove(space->activeShapes, shape, shape->hashid); } - - cpBodyActivate(body); - - cpAssert(cpSpaceContainsShape(space, shape), - "Cannot remove a shape that was not added to the space. (Removed twice maybe?)"); - cpAssertSpaceUnlocked(space); - - cpBodyRemoveShape(body, shape); - - arbiterRemovalContext context = {space, shape}; - cpHashSetFilter(space->cachedArbiters, (cpHashSetFilterFunc)arbiterSetFilterRemovedShape, &context); - cpSpatialIndexRemove(space->activeShapes, shape, shape->hashid); } void @@ -415,6 +399,8 @@ cpSpaceRemoveStaticShape(cpSpace *space, cpShape *shape) "Cannot remove a static or sleeping shape that was not added to the space. (Removed twice maybe?)"); cpAssertSpaceUnlocked(space); + cpBodyRemoveShape(shape->body, shape); + arbiterRemovalContext context = {space, shape}; cpHashSetFilter(space->cachedArbiters, (cpHashSetFilterFunc)arbiterSetFilterRemovedShape, &context); cpSpatialIndexRemove(space->staticShapes, shape, shape->hashid); diff --git a/src/helper/chipmunk/cpSpaceComponent.c b/src/helper/chipmunk/cpSpaceComponent.c index 49ab7411d..10c26ac07 100644 --- a/src/helper/chipmunk/cpSpaceComponent.c +++ b/src/helper/chipmunk/cpSpaceComponent.c @@ -91,7 +91,7 @@ cpSpaceDeactivateBody(cpSpace *space, cpBody *body) // Save contact values to a new block of memory so they won't time out size_t bytes = arb->numContacts*sizeof(cpContact); - cpContact *contacts = (cpContact *)cpmalloc(bytes); + cpContact *contacts = (cpContact *)cpcalloc(1, bytes); memcpy(contacts, arb->contacts, bytes); arb->contacts = contacts; } diff --git a/src/helper/chipmunk/cpSpaceHash.c b/src/helper/chipmunk/cpSpaceHash.c index 74e7b0109..013ad38f8 100644 --- a/src/helper/chipmunk/cpSpaceHash.c +++ b/src/helper/chipmunk/cpSpaceHash.c @@ -82,7 +82,7 @@ handleSetTrans(void *obj, cpSpaceHash *hash) int count = CP_BUFFER_BYTES/sizeof(cpHandle); cpAssert(count, "Buffer size is too small."); - cpHandle *buffer = (cpHandle *)cpmalloc(CP_BUFFER_BYTES); + cpHandle *buffer = (cpHandle *)cpcalloc(1, CP_BUFFER_BYTES); cpArrayPush(hash->allocatedBuffers, buffer); for(int i=0; ipooledHandles, buffer + i); @@ -144,7 +144,7 @@ getEmptyBin(cpSpaceHash *hash) int count = CP_BUFFER_BYTES/sizeof(cpSpaceHashBin); cpAssert(count, "Buffer size is too small."); - cpSpaceHashBin *buffer = (cpSpaceHashBin *)cpmalloc(CP_BUFFER_BYTES); + cpSpaceHashBin *buffer = (cpSpaceHashBin *)cpcalloc(1, CP_BUFFER_BYTES); cpArrayPush(hash->allocatedBuffers, buffer); // push all but the first one, return the first instead @@ -210,15 +210,14 @@ cpSpaceHashNew(cpFloat celldim, int cells, cpSpatialIndexBBFunc bbfunc, cpSpatia static void cpSpaceHashDestroy(cpSpaceHash *hash) { - clearTable(hash); + if(hash->table) clearTable(hash); + cpfree(hash->table); cpHashSetFree(hash->handleSet); cpArrayFreeEach(hash->allocatedBuffers, cpfree); cpArrayFree(hash->allocatedBuffers); cpArrayFree(hash->pooledHandles); - - cpfree(hash->table); } #pragma mark Helper Functions diff --git a/src/helper/chipmunk/cpSpaceStep.c b/src/helper/chipmunk/cpSpaceStep.c index 6a9afff37..34a7e115b 100644 --- a/src/helper/chipmunk/cpSpaceStep.c +++ b/src/helper/chipmunk/cpSpaceStep.c @@ -41,7 +41,7 @@ postStepFuncSetEql(cpPostStepCallback *a, cpPostStepCallback *b){ static void * postStepFuncSetTrans(cpPostStepCallback *callback, void *ignored) { - cpPostStepCallback *value = (cpPostStepCallback *)cpmalloc(sizeof(cpPostStepCallback)); + cpPostStepCallback *value = (cpPostStepCallback *)cpcalloc(1, sizeof(cpPostStepCallback)); (*value) = (*callback); return value; @@ -137,7 +137,7 @@ typedef struct cpContactBuffer { static cpContactBufferHeader * cpSpaceAllocContactBuffer(cpSpace *space) { - cpContactBuffer *buffer = (cpContactBuffer *)cpmalloc(sizeof(cpContactBuffer)); + cpContactBuffer *buffer = (cpContactBuffer *)cpcalloc(1, sizeof(cpContactBuffer)); cpArrayPush(space->allocatedBuffers, buffer); return (cpContactBufferHeader *)buffer; } @@ -208,7 +208,7 @@ cpSpaceArbiterSetTrans(cpShape **shapes, cpSpace *space) int count = CP_BUFFER_BYTES/sizeof(cpArbiter); cpAssert(count, "Buffer size too small."); - cpArbiter *buffer = (cpArbiter *)cpmalloc(CP_BUFFER_BYTES); + cpArbiter *buffer = (cpArbiter *)cpcalloc(1, CP_BUFFER_BYTES); cpArrayPush(space->allocatedBuffers, buffer); for(int i=0; ipooledArbiters, buffer + i); @@ -217,6 +217,13 @@ cpSpaceArbiterSetTrans(cpShape **shapes, cpSpace *space) return cpArbiterInit((cpArbiter *)cpArrayPop(space->pooledArbiters), shapes[0], shapes[1]); } +static inline cpCollisionHandler * +lookupCollisionHandler(cpSpace *space, cpCollisionType a, cpCollisionType b) +{ + cpCollisionType types[] = {a, b}; + return (cpCollisionHandler *)cpHashSetFind(space->collisionHandlers, CP_HASH_PAIR(a, b), types); +} + static inline cpBool queryReject(cpShape *a, cpShape *b) { @@ -239,10 +246,7 @@ collideShapes(cpShape *a, cpShape *b, cpSpace *space) // Reject any of the simple cases if(queryReject(a,b)) return; - // Find the collision pair function for the shapes. - cpCollisionType types[] = {a->collision_type, b->collision_type}; - cpHashValue collHashID = CP_HASH_PAIR(a->collision_type, b->collision_type); - cpCollisionHandler *handler = (cpCollisionHandler *)cpHashSetFind(space->collisionHandlers, collHashID, types); + cpCollisionHandler *handler = lookupCollisionHandler(space, a->collision_type, b->collision_type); cpBool sensor = a->sensor || b->sensor; if(sensor && handler == &cpDefaultCollisionHandler) return; @@ -314,7 +318,9 @@ cpSpaceArbiterSetFilter(cpArbiter *arb, cpSpace *space) // Arbiter was used last frame, but not this one if(ticks >= 1 && arb->state != cpArbiterStateCached){ - arb->handler->separate(arb, space, arb->handler->data); + // The handler needs to be looked up again as the handler cached on the arbiter may have been deleted since the last step. + cpCollisionHandler *handler = lookupCollisionHandler(space, arb->a->collision_type, arb->b->collision_type); + handler->separate(arb, space, handler->data); arb->state = cpArbiterStateCached; } diff --git a/src/helper/chipmunk/cpSpatialIndex.h b/src/helper/chipmunk/cpSpatialIndex.h index 996c890d3..401aa0219 100644 --- a/src/helper/chipmunk/cpSpatialIndex.h +++ b/src/helper/chipmunk/cpSpatialIndex.h @@ -159,7 +159,7 @@ void cpSpatialIndexCollideStatic(cpSpatialIndex *dynamicIndex, cpSpatialIndex *s static inline void cpSpatialIndexDestroy(cpSpatialIndex *index) { - index->klass->destroy(index); + if(index->klass) index->klass->destroy(index); } /// Get the number of objects in the spatial index. diff --git a/src/system/clog.cpp b/src/system/clog.cpp index cd0437ea0..4feabccc0 100755 --- a/src/system/clog.cpp +++ b/src/system/clog.cpp @@ -4,7 +4,8 @@ namespace EE { namespace System { cLog::cLog() : mSave( false ), - mConsoleOutput( false ) + mConsoleOutput( false ), + mLiveWrite( false ) { Write("...::: Entropia Engine++ Loaded :::..."); Write( "Loaded on " + GetDateTimeStr() ); @@ -14,26 +15,22 @@ cLog::~cLog() { Write( "\nUnloaded on " + GetDateTimeStr(), false ); Write( "...::: Entropia Engine++ Unloaded :::..." ); - if ( !mFilePath.empty() ) - mFilePath = GetProcessPath(); - - if ( mSave ) { - std::string str = mFilePath; - str += "log.log"; - - std::ofstream fs( str.c_str(), std::ios::app ); - - fs << mData << std::endl; - fs.close(); + if ( mSave && !mLiveWrite ) { + openfs(); + mFS << mData << std::endl; + } + + if ( mFS.is_open() ) { + mFS.close(); } } -void cLog::Save(const std::string& filepath) { +void cLog::Save( const std::string& filepath ) { mFilePath = filepath; mSave = true; } -void cLog::Write(const std::string& Text, const bool& newLine) { +void cLog::Write( const std::string& Text, const bool& newLine ) { mData += Text; if ( newLine ) { @@ -46,7 +43,22 @@ void cLog::Write(const std::string& Text, const bool& newLine) { } else { std::cout << Text; } + } + + if ( mLiveWrite ) { + openfs(); + mFS << Text << std::endl; } +} + +void cLog::openfs() { + if ( !mFilePath.empty() ) + mFilePath = GetProcessPath(); + + if ( !mFS.is_open() ) { + std::string str = mFilePath + "log.log"; + mFS.open( str.c_str(), std::ios::app ); + } } void cLog::Writef( const char* format, ... ) { @@ -73,7 +85,12 @@ void cLog::Writef( const char* format, ... ) { if ( mConsoleOutput ) { std::cout << tstr << std::endl; - } + } + + if ( mLiveWrite ) { + openfs(); + mFS << tstr << std::endl; + } return; } @@ -97,6 +114,14 @@ const bool& cLog::ConsoleOutput() const { void cLog::ConsoleOutput( const bool& output ) { mConsoleOutput = output; +} + +const bool& cLog::LiveWrite() const { + return mLiveWrite; +} + +void cLog::LiveWrite( const bool& lw ) { + mLiveWrite = lw; } }} diff --git a/src/system/clog.hpp b/src/system/clog.hpp index 3d63fa335..b3cea3174 100755 --- a/src/system/clog.hpp +++ b/src/system/clog.hpp @@ -19,7 +19,11 @@ class EE_API cLog : public tSingleton { const bool& ConsoleOutput() const; - void ConsoleOutput( const bool& output ); + void ConsoleOutput( const bool& output ); + + const bool& LiveWrite() const; + + void LiveWrite( const bool& lw ); ~cLog(); protected: @@ -27,7 +31,11 @@ class EE_API cLog : public tSingleton { private: std::string mData, mFilePath; bool mSave; - bool mConsoleOutput; + bool mConsoleOutput; + bool mLiveWrite; + std::ofstream mFS; + + void openfs(); }; }} diff --git a/src/test/eetest.cpp b/src/test/eetest.cpp index c0b79a90d..da6bf1c87 100644 --- a/src/test/eetest.cpp +++ b/src/test/eetest.cpp @@ -4,7 +4,8 @@ void cEETest::Init() { EE = cEngine::instance(); #ifdef EE_DEBUG - cLog::instance()->ConsoleOutput( true ); + cLog::instance()->ConsoleOutput( true ); + cLog::instance()->LiveWrite( true ); #endif run = false; @@ -62,7 +63,9 @@ void cEETest::Init() { run = ( mWindow->Created() && PAK.IsOpen() ); - if ( run ) { + if ( run ) { + cLog::instance()->Write( "Running eepp" ); + #ifdef EE_DEBUG std::cout << "Size of Callback0: " << sizeof( cb::Callback0 ) << std::endl; std::cout << "Size of cWaypoints: " << sizeof( cWaypoints ) << std::endl; @@ -136,24 +139,31 @@ void cEETest::Init() { if ( NULL != mFBO ) mFBO->ClearColor( eeColorAf( 0, 0, 0, 0.5f ) ); - eePolygon2f Poly = CreateRoundedPolygon( 0.f, 0.f, 256.f, 50.f ); - mVBO = cVertexBuffer::Create( VERTEX_FLAG_GET( VERTEX_FLAG_POSITION ) | VERTEX_FLAG_GET( VERTEX_FLAG_COLOR ), DM_POLYGON ); + mVBO = cVertexBuffer::Create( VERTEX_FLAG_GET( VERTEX_FLAG_POSITION ) | VERTEX_FLAG_GET( VERTEX_FLAG_COLOR ), DM_POLYGON ); + + if ( NULL != mVBO ) { + for ( Uint32 i = 0; i < Poly.Size(); i++ ) { + mVBO->AddVertex( Poly[i] ); + mVBO->AddColor( eeColorA( 100 + i, 255 - i, 150 + i, 200 ) ); + } - for ( Uint32 i = 0; i < Poly.Size(); i++ ) { - mVBO->AddVertex( Poly[i] ); - mVBO->AddColor( eeColorA( 100 + i, 255 - i, 150 + i, 200 ) ); - } - - mVBO->Compile(); + mVBO->Compile(); + } PhysicsCreate(); Launch(); - } else { - std::cout << "Failed to start EE++" << std::endl; - cEngine::DestroySingleton(); + } else { + std::string err; + + std::cout << err.c_str() << std::endl; + + cLog::instance()->Write( err ); + + cEngine::DestroySingleton(); + exit(0); } } @@ -207,9 +217,9 @@ void cEETest::OnFontLoaded( cResourceLoader * ObjLoaded ) { Map.Font( FF ); Con.Create( FF, true ); - Con.IgnoreCharOnPrompt( 186 ); // 'º' + Con.IgnoreCharOnPrompt( 186 ); // 'º' - mBuda = String::FromUtf8( "El mono ve el pez en el agua y sufre. Piensa que su mundo es el único que existe, el mejor, el real. Sufre porque es bueno y tiene compasión, lo ve y piensa: \"Pobre se está ahogando no puede respirar\". Y lo saca, lo saca y se queda tranquilo, por fin lo salvé. Pero el pez se retuerce de dolor y muere. Por eso te mostré el sueño, es imposible meter el mar en tu cabeza, que es un balde." ); + mBuda = String::FromUtf8( "El mono ve el pez en el agua y sufre. Piensa que su mundo es el único que existe, el mejor, el real. Sufre porque es bueno y tiene compasión, lo ve y piensa: \"Pobre se está ahogando no puede respirar\". Y lo saca, lo saca y se queda tranquilo, por fin lo salvé. Pero el pez se retuerce de dolor y muere. Por eso te mostré el sueño, es imposible meter el mar en tu cabeza, que es un balde." ); CreateUI(); @@ -239,9 +249,12 @@ void cEETest::CreateUI() { Log->Writef( "Texture Atlas Loading Time: %f", TE.ElapsedSinceStart() ); cTextureGroupLoader tgl( MyPath + "data/aquatg/aqua.etg" ); - TF->GetByName( "data/aquatg/aqua.png" )->TextureFilter( TEX_FILTER_NEAREST ); - cUIThemeManager::instance()->Add( cUITheme::LoadFromShapeGroup( cShapeGroupManager::instance()->GetByName( "aqua" ), "aqua", "aqua" ) ); + tgl.GetTexture()->TextureFilter( TEX_FILTER_NEAREST ); + cUITheme * Aqua = cUITheme::LoadFromShapeGroup( cShapeGroupManager::instance()->GetByName( "aqua" ), "aqua", "aqua" ); + Aqua->FontSelectedColor( eeColorA( 255, 255, 255, 255 ) ); + + cUIThemeManager::instance()->Add( Aqua ); cUIThemeManager::instance()->DefaultEffectsEnabled( true ); cUIThemeManager::instance()->DefaultFont( TTF ); cUIThemeManager::instance()->DefaultTheme( "aqua" ); @@ -399,7 +412,6 @@ void cEETest::CreateUI() { LBParams.PosSet( 325, 8 ); LBParams.Size = eeSize( 200, 240-16 ); LBParams.Flags = UI_CLIP_ENABLE | UI_AUTO_PADDING; // | UI_MULTI_SELECT - LBParams.FontSelectedColor = eeColorA( 255, 255, 255, 255 ); mListBox = eeNew( cUIListBox, ( LBParams ) ); mListBox->Visible( true ); mListBox->Enabled( true ); @@ -452,7 +464,6 @@ void cEETest::CreateUI() { MenuParams.MinWidth = 100; MenuParams.MinSpaceForIcons = 16; MenuParams.PosSet( 0, 0 ); - MenuParams.FontSelectedColor = eeColorA( 255, 255, 255, 255 ); MenuParams.MinRightMargin = 8; Menu = eeNew( cUIPopUpMenu, ( MenuParams ) ); Menu->Add( "New", cGlobalShapeGroup::instance()->GetByName( "aqua_button_ok" ) ); @@ -559,7 +570,7 @@ void cEETest::CreateUI() { cUICommonDialog::CreateParams CDParams; CDParams.Flags = UI_HALIGN_CENTER; CDParams.WinFlags |= cUIWindow::UI_WIN_MAXIMIZE_BUTTON; // | cUIWindow::UI_WIN_MODAL - CDParams.Size = eeSize( 420, 267 ); + CDParams.ButtonsPositionFixer.x = -2; cUICommonDialog * CDialog = eeNew( cUICommonDialog, ( CDParams ) ); CDialog->AddFilePattern( "*.hpp;*.cpp", true ); CDialog->Center(); @@ -573,8 +584,6 @@ void cEETest::CreateWinMenu() { WinMenuParams.Parent( mUIWindow->Container() ); WinMenuParams.ButtonMargin = 12; - WinMenuParams.FontSelectedColor = eeColorA( 255, 255, 255, 255 ); - WinMenuParams.Flags |= cUIWindow::UI_WIN_NO_BORDER; cUIWinMenu * WinMenu = eeNew( cUIWinMenu, ( WinMenuParams ) ); @@ -585,7 +594,6 @@ void cEETest::CreateWinMenu() { MenuParams.MinWidth = 100; MenuParams.MinSpaceForIcons = 16; MenuParams.PosSet( 0, 0 ); - MenuParams.FontSelectedColor = eeColorA( 255, 255, 255, 255 ); MenuParams.MinRightMargin = 8; cUIPopUpMenu * PopMenu = eeNew( cUIPopUpMenu, ( MenuParams ) ); @@ -613,6 +621,7 @@ void cEETest::CreateDecoratedWindow() { WinParams.PosSet( 200, 50 ); WinParams.Size = eeSize( 530, 400 ); WinParams.MinWindowSize = eeSize( 100, 200 ); + WinParams.ButtonsPositionFixer.x = -2; mUIWindow = eeNew( cUIWindow, ( WinParams ) ); mUIWindow->AddEventListener( cUIEvent::EventOnWindowCloseClick, cb::Make1( this, &cEETest::CloseClick ) ); @@ -1150,10 +1159,12 @@ void cEETest::Screen4() { mBlindy.Position( 128-16, 128-16 ); mBlindy.Draw(); - - mVBO->Bind(); - mVBO->Draw(); - mVBO->Unbind(); + + if ( NULL != mVBO ) { + mVBO->Bind(); + mVBO->Draw(); + mVBO->Unbind(); + } mFBOText.Draw( 128.f - (eeFloat)(Int32)( mFBOText.GetTextWidth() * 0.5f ), 25.f - (eeFloat)(Int32)( mFBOText.GetTextHeight() * 0.5f ), FONT_DRAW_CENTER ); diff --git a/src/ui/cuitheme.cpp b/src/ui/cuitheme.cpp index a3ddac8f1..9d66f893b 100644 --- a/src/ui/cuitheme.cpp +++ b/src/ui/cuitheme.cpp @@ -4,6 +4,14 @@ #include "../graphics/ctexturefactory.hpp" #include "../graphics/cshapegroupmanager.hpp" +#include "cuicheckbox.hpp" +#include "cuicombobox.hpp" +#include "cuidropdownlist.hpp" +#include "cuilistbox.hpp" +#include "cuipopupmenu.hpp" +#include "cuiprogressbar.hpp" +#include "cuipushbutton.hpp" + namespace EE { namespace UI { static std::vector UI_THEME_ELEMENTS; @@ -261,6 +269,7 @@ cUITheme::cUITheme( const std::string& Name, const std::string& Abbr, cFont * De mFontOverColor( 0, 0, 0, 255 ), mFontSelectedColor( 0, 0, 0, 255 ) { + PostInit(); } cUITheme::~cUITheme() { @@ -330,4 +339,92 @@ void cUITheme::FontSelectedColor( const eeColorA& Color ) { mFontSelectedColor = Color; } +void cUITheme::PostInit() { +} + +cUICheckBox * cUITheme::CreateCheckBox( cUIControl * Parent, const eeSize& Size, const eeVector2i& Pos, const Uint32& Flags ) { + cUITextBox::CreateParams CheckBoxParams; + CheckBoxParams.Parent( Parent ); + CheckBoxParams.PosSet( Pos ); + CheckBoxParams.SizeSet( Size ); + CheckBoxParams.Flags = Flags; + return eeNew( cUICheckBox, ( CheckBoxParams ) ); +} + +cUIComboBox * cUITheme::CreateComboBox( cUIControl * Parent, const eeSize& Size, const eeVector2i& Pos, const Uint32& Flags, Uint32 MinNumVisibleItems, bool PopUpToMainControl, cUIListBox * ListBox ) { + cUIComboBox::CreateParams ComboParams; + ComboParams.Parent( Parent ); + ComboParams.PosSet( Pos ); + ComboParams.SizeSet( Size ); + ComboParams.Flags = Flags; + ComboParams.MinNumVisibleItems = MinNumVisibleItems; + ComboParams.PopUpToMainControl = PopUpToMainControl; + ComboParams.ListBox = ListBox; + return eeNew( cUIComboBox, ( ComboParams ) ); +} + +cUIDropDownList * cUITheme::CreateDropDownList( cUIControl * Parent, const eeSize& Size, const eeVector2i& Pos, const Uint32& Flags, Uint32 MinNumVisibleItems, bool PopUpToMainControl, cUIListBox * ListBox ) { + cUIDropDownList::CreateParams DDLParams; + DDLParams.Parent( Parent ); + DDLParams.PosSet( Pos ); + DDLParams.SizeSet( Size ); + DDLParams.Flags = Flags; + DDLParams.MinNumVisibleItems = MinNumVisibleItems; + DDLParams.PopUpToMainControl = PopUpToMainControl; + DDLParams.ListBox = ListBox; + return eeNew( cUIDropDownList, ( DDLParams ) ); +} + +cUIListBox * cUITheme::CreateListBox( cUIControl * Parent, const eeSize& Size, const eeVector2i& Pos, const Uint32& Flags, bool SmoothScroll, Uint32 RowHeight, UI_SCROLLBAR_MODE VScrollMode, UI_SCROLLBAR_MODE HScrollMode, eeRecti PaddingContainer ) { + cUIListBox::CreateParams LBParams; + LBParams.Parent( Parent ); + LBParams.PosSet( Pos ); + LBParams.SizeSet( Size ); + LBParams.Flags = Flags; + LBParams.SmoothScroll = SmoothScroll; + LBParams.RowHeight = RowHeight; + LBParams.VScrollMode = VScrollMode; + LBParams.HScrollMode = HScrollMode; + LBParams.PaddingContainer = PaddingContainer; + return eeNew( cUIListBox, ( LBParams ) ); +} + +cUIPopUpMenu * cUITheme::CreatePopUpMenu( cUIControl * Parent, const eeSize& Size, const eeVector2i& Pos, const Uint32& Flags ) { + cUIPopUpMenu::CreateParams MenuParams; + MenuParams.Parent( Parent ); + MenuParams.PosSet( Pos ); + MenuParams.SizeSet( Size ); + MenuParams.Flags = Flags; + + /** Aqua Theme Stuff *//** + MenuParams.MinWidth = 100; + MenuParams.MinSpaceForIcons = 16; + MenuParams.MinRightMargin = 8; + */ + return eeNew( cUIPopUpMenu, ( MenuParams ) ); +} + +cUIProgressBar * cUITheme::CreateProgressBar( cUIControl * Parent, const eeSize& Size, const eeVector2i& Pos, const Uint32& Flags, bool DisplayPercent ) { + cUIProgressBar::CreateParams PBParams; + PBParams.Parent( Parent ); + PBParams.PosSet( Pos ); + PBParams.SizeSet( Size ); + PBParams.Flags = Flags; + PBParams.DisplayPercent = DisplayPercent; + return eeNew( cUIProgressBar, ( PBParams ) ); +} + +cUIPushButton * cUITheme::CreatePushButton( cUIControl * Parent, const eeSize& Size, const eeVector2i& Pos, const Uint32& Flags, cShape * Icon ) { + cUIPushButton::CreateParams ButtonParams; + ButtonParams.Parent( Parent ); + ButtonParams.PosSet( Pos ); + ButtonParams.SizeSet( Size ); + ButtonParams.Flags = Flags; + + if ( NULL != Icon ) + ButtonParams.SetIcon( Icon ); + + return eeNew( cUIPushButton, ( ButtonParams ) ); +} + }} diff --git a/src/ui/cuitheme.hpp b/src/ui/cuitheme.hpp index 17de0e0ec..259292bed 100644 --- a/src/ui/cuitheme.hpp +++ b/src/ui/cuitheme.hpp @@ -2,12 +2,22 @@ #define EE_UICUITHEME_HPP #include "base.hpp" +#include "uihelper.hpp" #include "../graphics/cshapegroup.hpp" #include "../graphics/cfont.hpp" #include "cuiskin.hpp" namespace EE { namespace UI { +class cUIControl; +class cUICheckBox; +class cUIComboBox; +class cUIDropDownList; +class cUIListBox; +class cUIPopUpMenu; +class cUIProgressBar; +class cUIPushButton; + class EE_API cUITheme : public tResourceManager { public: static cUITheme * LoadFromPath( const std::string& Path, const std::string& Name, const std::string& NameAbbr, const std::string ImgExt = "png" ); @@ -49,6 +59,20 @@ class EE_API cUITheme : public tResourceManager { void FontOverColor( const eeColorA& Color ); void FontSelectedColor( const eeColorA& Color ); + + virtual cUICheckBox * CreateCheckBox( cUIControl * Parent, const eeSize& Size = eeSize(), const eeVector2i& Pos = eeVector2i(), const Uint32& Flags = UI_VALIGN_CENTER | UI_HALIGN_LEFT ); + + virtual cUIComboBox * CreateComboBox( cUIControl * Parent, const eeSize& Size = eeSize(), const eeVector2i& Pos = eeVector2i(), const Uint32& Flags = UI_CLIP_ENABLE | UI_AUTO_PADDING | UI_VALIGN_CENTER | UI_HALIGN_LEFT, Uint32 MinNumVisibleItems = 6, bool PopUpToMainControl = false, cUIListBox * ListBox = NULL ); + + virtual cUIDropDownList * CreateDropDownList( cUIControl * Parent, const eeSize& Size = eeSize(), const eeVector2i& Pos = eeVector2i(), const Uint32& Flags = UI_CLIP_ENABLE | UI_AUTO_PADDING | UI_VALIGN_CENTER | UI_HALIGN_LEFT, Uint32 MinNumVisibleItems = 6, bool PopUpToMainControl = false, cUIListBox * ListBox = NULL ); + + virtual cUIListBox * CreateListBox( cUIControl * Parent, const eeSize& Size = eeSize(), const eeVector2i& Pos = eeVector2i(), const Uint32& Flags = UI_CLIP_ENABLE | UI_AUTO_PADDING, bool SmoothScroll = true, Uint32 RowHeight = 0, UI_SCROLLBAR_MODE VScrollMode = UI_SCROLLBAR_AUTO, UI_SCROLLBAR_MODE HScrollMode = UI_SCROLLBAR_AUTO, eeRecti PaddingContainer = eeRecti() ); + + virtual cUIPopUpMenu * CreatePopUpMenu( cUIControl * Parent, const eeSize& Size = eeSize(), const eeVector2i& Pos = eeVector2i(), const Uint32& Flags = UI_AUTO_SIZE | UI_AUTO_PADDING ); + + virtual cUIProgressBar * CreateProgressBar( cUIControl * Parent, const eeSize& Size = eeSize(), const eeVector2i& Pos = eeVector2i(), const Uint32& Flags = UI_HALIGN_LEFT | UI_VALIGN_CENTER, bool DisplayPercent = true ); + + virtual cUIPushButton * CreatePushButton( cUIControl * Parent, const eeSize& Size = eeSize(), const eeVector2i& Pos = eeVector2i(), const Uint32& Flags = UI_VALIGN_CENTER | UI_HALIGN_CENTER, cShape * Icon = NULL ); protected: std::string mName; Uint32 mNameHash; @@ -62,6 +86,8 @@ class EE_API cUITheme : public tResourceManager { static bool SearchFilesOfElement( cShapeGroup * SG, const std::string& Path, std::string Element, Uint32& IsComplex, const std::string ImgExt ); static bool SearchFilesInGroup( cShapeGroup * SG, std::string Element, Uint32& IsComplex ); + + virtual void PostInit(); }; }} diff --git a/src/ui/cuiwinmenu.hpp b/src/ui/cuiwinmenu.hpp index 35e5d59d8..2c9f2b219 100644 --- a/src/ui/cuiwinmenu.hpp +++ b/src/ui/cuiwinmenu.hpp @@ -31,7 +31,7 @@ class EE_API cUIWinMenu : public cUIComplexControl { FontColor = Theme->FontColor(); FontShadowColor = Theme->FontShadowColor(); FontOverColor = Theme->FontOverColor(); - FontSelectedColor = FontOverColor; + FontSelectedColor = Theme->FontSelectedColor(); } if ( NULL == Font ) diff --git a/src/window/backend/SDL/cwindowsdl.cpp b/src/window/backend/SDL/cwindowsdl.cpp index 74f183fc6..bc0dc503a 100644 --- a/src/window/backend/SDL/cwindowsdl.cpp +++ b/src/window/backend/SDL/cwindowsdl.cpp @@ -131,9 +131,7 @@ bool cWindowSDL::Create( WindowSettings Settings, ContextSettings Context ) { } std::string cWindowSDL::GetVersion() { - SDL_version ver; - - SDL_GetVersion( &ver ); + SDL_version ver = mWMinfo.version; return StrFormated( "SDL %d.%d.%d", ver.major, ver.minor, ver.patch ); } diff --git a/src/window/backend/allegro5/cwindowal.cpp b/src/window/backend/allegro5/cwindowal.cpp index ef1fb7b0b..bf331dd84 100644 --- a/src/window/backend/allegro5/cwindowal.cpp +++ b/src/window/backend/allegro5/cwindowal.cpp @@ -150,71 +150,73 @@ Uint32 cWindowAl::CreateFlags( const WindowSettings& Settings, const ContextSett } bool cWindowAl::Create( WindowSettings Settings, ContextSettings Context ) { - DestroyDisplay(); + try { + DestroyDisplay(); - mWindow.WindowConfig = Settings; - mWindow.ContextConfig = Context; + mWindow.WindowConfig = Settings; + mWindow.ContextConfig = Context; - al_set_new_display_flags( CreateFlags( Settings, Context ) ); - al_set_new_display_option( ALLEGRO_STENCIL_SIZE , Context.StencilBufferSize , ALLEGRO_SUGGEST ); - al_set_new_display_option( ALLEGRO_DEPTH_SIZE , Context.DepthBufferSize , ALLEGRO_SUGGEST ); + al_set_new_display_flags( CreateFlags( Settings, Context ) ); + al_set_new_display_option( ALLEGRO_STENCIL_SIZE , Context.StencilBufferSize , ALLEGRO_SUGGEST ); + al_set_new_display_option( ALLEGRO_DEPTH_SIZE , Context.DepthBufferSize , ALLEGRO_SUGGEST ); - if ( Context.VSync ) - al_set_new_display_option( ALLEGRO_VSYNC, 1, ALLEGRO_SUGGEST ); + if ( Context.VSync ) + al_set_new_display_option( ALLEGRO_VSYNC, 1, ALLEGRO_SUGGEST ); - ALLEGRO_MONITOR_INFO minfo; + ALLEGRO_MONITOR_INFO minfo; - if ( al_get_monitor_info( 0, &minfo ) ) { - mWindow.DesktopResolution = eeSize( minfo.x2, minfo.y2 ); + if ( al_get_monitor_info( 0, &minfo ) ) { + mWindow.DesktopResolution = eeSize( minfo.x2, minfo.y2 ); - if ( mWindow.WindowConfig.Style & WindowStyle::UseDesktopResolution ) { - mWindow.WindowConfig.Width = mWindow.DesktopResolution.Width(); - mWindow.WindowConfig.Height = mWindow.DesktopResolution.Height(); + if ( mWindow.WindowConfig.Style & WindowStyle::UseDesktopResolution ) { + mWindow.WindowConfig.Width = mWindow.DesktopResolution.Width(); + mWindow.WindowConfig.Height = mWindow.DesktopResolution.Height(); + } + } else { + mWindow.DesktopResolution = eeSize( Settings.Width, Settings.Height ); } - } else { - mWindow.DesktopResolution = eeSize( Settings.Width, Settings.Height ); + + mDisplay = al_create_display( Settings.Width, Settings.Height ); + + if ( NULL != mDisplay ) { + al_inhibit_screensaver( true ); + + Caption( mWindow.WindowConfig.Caption ); + + if ( NULL == cGL::ExistsSingleton() ) { + cGL::CreateSingleton( mWindow.ContextConfig.Version ); + } + + cGL::instance()->Init(); + + CreatePlatform(); + + GetMainContext(); + + CreateView(); + + Setup2D(); + + mWindow.Created = true; + + if ( "" != mWindow.WindowConfig.Icon ) { + Icon( mWindow.WindowConfig.Icon ); + } + + LogSuccessfulInit( "Allegro 5" ); + + /// Init the clipboard after the window creation + reinterpret_cast ( mClipboard )->Init(); + + /// Init the input after the window creation + reinterpret_cast ( mInput )->Init(); + + return true; + } + } catch (...) { + LogFailureInit( "cWindowAl", "Allegro 5" ); } - mDisplay = al_create_display( Settings.Width, Settings.Height ); - - if ( NULL != mDisplay ) { - al_inhibit_screensaver( true ); - - Caption( mWindow.WindowConfig.Caption ); - - if ( NULL == cGL::ExistsSingleton() ) { - cGL::CreateSingleton( mWindow.ContextConfig.Version ); - } - - cGL::instance()->Init(); - - CreatePlatform(); - - GetMainContext(); - - CreateView(); - - Setup2D(); - - mWindow.Created = true; - - if ( "" != mWindow.WindowConfig.Icon ) { - Icon( mWindow.WindowConfig.Icon ); - } - - LogSuccessfulInit( "Allegro 5" ); - - /// Init the clipboard after the window creation - reinterpret_cast ( mClipboard )->Init(); - - /// Init the input after the window creation - reinterpret_cast ( mInput )->Init(); - - return true; - } - - LogFailureInit( "cWindowAl", "Allegro 5" ); - return false; } diff --git a/src/window/cwindow.cpp b/src/window/cwindow.cpp index 8dd8d7a80..3a6880503 100644 --- a/src/window/cwindow.cpp +++ b/src/window/cwindow.cpp @@ -55,7 +55,7 @@ bool cWindow::Resizeable() const { void cWindow::SetViewport( const Int32& x, const Int32& y, const Uint32& Width, const Uint32& Height, const bool& UpdateProjectionMatrix ) { GLi->Viewport( x, GetHeight() - Height - y, Width, Height ); - + if ( UpdateProjectionMatrix ) { GLi->MatrixMode( GL_PROJECTION ); GLi->LoadIdentity(); @@ -101,7 +101,7 @@ void cWindow::Setup2D( const bool& KeepView ) { if ( !KeepView ) SetView( mDefaultView ); - + cTextureFactory::instance()->SetPreBlendFunc( ALPHA_NORMAL, true ); if ( GLv_3 != GLi->Version() ) {