diff --git a/.hgignore b/.hgignore index bd2662646..de74a9d4d 100644 --- a/.hgignore +++ b/.hgignore @@ -1,28 +1,30 @@ -syntax: glob -./obj -./fonts -./libs -./make -./assets -./data -./projects/android-project/bin -./projects/android-project/obj -./projects/android-project/data -./projects/android-project/gen -*\.user -*\.filters -*\.suo -*\.DS_Store -*.pdb -./eees* -./eeew* -./eetest* -./eesound* -./eesprite* -./eeiv* -./docs +syntax: regexp +^fonts$ +^obj$ +^libs$ +^make$ +^assets$ +^data$ +^docs$ +^projects/android-project/bin$ +^projects/android-project/obj$ +^projects/android-project/data$ +^projects/android-project/gen$ +^projects/android-project/assets$ +^projects/android-project/libs$ +.*.dll +eees* +eeew* +eetest* +eesound* +eesprite* +eefonts* +eeiv* ee.tag log.log -eepp-debug.dll -eepp.dll external_projects.lua +.*\.user$ +.*\.filters$ +.*\.suo$ +.*\.DS_Store$ +.*.pdb$ diff --git a/include/eepp/graphics/cttffont.hpp b/include/eepp/graphics/cttffont.hpp index 4ce7ec4e1..8c68c99dd 100755 --- a/include/eepp/graphics/cttffont.hpp +++ b/include/eepp/graphics/cttffont.hpp @@ -105,7 +105,7 @@ class EE_API cTTFFont : public cFont { bool iLoad( const eeUint& Size, EE_TTF_FONT_STYLE Style, const bool& VerticalDraw, const Uint16& NumCharsToGen, const eeColor& FontColor, Uint8 OutlineSize, const eeColor& OutlineColor, const bool& AddPixelSeparator ); - void MakeOutline( Uint8 *in, Uint8 *out, Int16 w, Int16 h); + void MakeOutline( Uint8 *in, Uint8 *out, Int16 w, Int16 h, Int16 OutlineSize ); void RebuildFromGlyphs(); }; diff --git a/include/eepp/graphics/renderer/cgl.hpp b/include/eepp/graphics/renderer/cgl.hpp index 690d789d5..c7391c36e 100644 --- a/include/eepp/graphics/renderer/cgl.hpp +++ b/include/eepp/graphics/renderer/cgl.hpp @@ -151,11 +151,11 @@ class EE_API cGL { virtual void DisableClientState( GLenum array ) = 0; - virtual void VertexPointer ( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer, GLuint allocate ) = 0; + virtual void VertexPointer ( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer ) = 0; - virtual void ColorPointer ( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer, GLuint allocate ) = 0; + virtual void ColorPointer ( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer ) = 0; - virtual void TexCoordPointer ( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer, GLuint allocate ) = 0; + virtual void TexCoordPointer ( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer ) = 0; virtual void SetShader( cShaderProgram * Shader ); diff --git a/include/eepp/graphics/renderer/crenderergl.hpp b/include/eepp/graphics/renderer/crenderergl.hpp index f36a9c37a..d248932df 100644 --- a/include/eepp/graphics/renderer/crenderergl.hpp +++ b/include/eepp/graphics/renderer/crenderergl.hpp @@ -48,11 +48,11 @@ class EE_API cRendererGL : public cGL { void DisableClientState( GLenum array ); - void VertexPointer ( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer, GLuint allocate ); + void VertexPointer ( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer ); - void ColorPointer ( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer, GLuint allocate ); + void ColorPointer ( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer ); - void TexCoordPointer ( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer, GLuint allocate ); + void TexCoordPointer ( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer ); void ClipPlane( GLenum plane, const GLdouble *equation ); diff --git a/include/eepp/graphics/renderer/crenderergl3.hpp b/include/eepp/graphics/renderer/crenderergl3.hpp index 6f1e2dc8c..be8855f26 100644 --- a/include/eepp/graphics/renderer/crenderergl3.hpp +++ b/include/eepp/graphics/renderer/crenderergl3.hpp @@ -60,11 +60,11 @@ class EE_API cRendererGL3 : public cGL { void DisableClientState( GLenum array ); - void VertexPointer ( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer, GLuint allocate ); + void VertexPointer ( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer ); - void ColorPointer ( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer, GLuint allocate ); + void ColorPointer ( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer ); - void TexCoordPointer ( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer, GLuint allocate ); + void TexCoordPointer ( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer ); void ClientActiveTexture( GLenum texture ); diff --git a/include/eepp/graphics/renderer/crenderergles2.hpp b/include/eepp/graphics/renderer/crenderergles2.hpp index 61e53713b..0c817e6d8 100644 --- a/include/eepp/graphics/renderer/crenderergles2.hpp +++ b/include/eepp/graphics/renderer/crenderergles2.hpp @@ -63,11 +63,11 @@ class EE_API cRendererGLES2 : public cGL { void DisableClientState( GLenum array ); - void VertexPointer ( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer, GLuint allocate ); + void VertexPointer ( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer ); - void ColorPointer ( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer, GLuint allocate ); + void ColorPointer ( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer ); - void TexCoordPointer ( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer, GLuint allocate ); + void TexCoordPointer ( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer ); void ClientActiveTexture( GLenum texture ); diff --git a/include/eepp/physics/cphysicsmanager.hpp b/include/eepp/physics/cphysicsmanager.hpp index c9cf74a9f..6ca5304a0 100644 --- a/include/eepp/physics/cphysicsmanager.hpp +++ b/include/eepp/physics/cphysicsmanager.hpp @@ -41,7 +41,7 @@ class CP_API cPhysicsManager { /** The Memory Manager will keep track of all the allocations from cSpace, cBody, cShape and cConstraint and will release any non-released pointer. *** This is a lazy deallocation for the lazy programmers. It is disabled by default. - *** To work properly set as active before allocating anything, activate it just before the singleton instantiation. + *** To work properly set as active before allocating anything, activate it just after the singleton instantiation. */ void MemoryManager( bool MemoryManager ); diff --git a/premake4.lua b/premake4.lua index bec7c7955..db5e9bd3c 100644 --- a/premake4.lua +++ b/premake4.lua @@ -323,6 +323,10 @@ end function generate_os_links() if os.is_real("linux") then multiple_insert( os_links, { "rt", "pthread", "X11", "openal", "GL", "Xcursor" } ) + + if _OPTIONS["with-static-eepp"] then + table.insert( os_links, "dl" ) + end elseif os.is_real("windows") then multiple_insert( os_links, { "OpenAL32", "opengl32", "glu32", "gdi32" } ) elseif os.is_real("mingw32") then @@ -736,6 +740,12 @@ solution "eepp" files { "src/examples/sprites/*.cpp" } build_link_configuration( "eesprites" ) + project "eepp-fonts" + kind "WindowedApp" + language "C++" + files { "src/examples/fonts/*.cpp" } + build_link_configuration( "eefonts" ) + if os.isfile("external_projects.lua") then dofile("external_projects.lua") end diff --git a/projects/linux/ee.config b/projects/linux/ee.config index a963c8e16..80277fd96 100644 --- a/projects/linux/ee.config +++ b/projects/linux/ee.config @@ -6,3 +6,4 @@ #define EE_BACKEND_SDL2 #define EE_BACKEND_SDL_1_2 #define EE_X11_PLATFORM +#define EE_DEBUG diff --git a/projects/linux/ee.creator.user b/projects/linux/ee.creator.user index e2eb44514..384b4986b 100644 --- a/projects/linux/ee.creator.user +++ b/projects/linux/ee.creator.user @@ -1,6 +1,6 @@ - + ProjectExplorer.Project.ActiveTarget @@ -48,9 +48,9 @@ Desktop Desktop {388e5431-b31b-42b3-b9ad-9002d279d75d} - 0 + 16 0 - 0 + 8 /home/programming/eepp/make/linux @@ -389,6 +389,46 @@ debug-sprites GenericProjectManager.GenericBuildConfiguration + + /home/programming/eepp/make/linux + + + + false + -j4 eepp-fonts + make + true + Make + + GenericProjectManager.GenericMakeStep + + 1 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + clean + make + %{buildDir} + Custom Process Step + + ProjectExplorer.ProcessStep + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + debug-test + debug-fonts + GenericProjectManager.GenericBuildConfiguration + /home/programming/eepp/make/linux @@ -709,7 +749,7 @@ release-es GenericProjectManager.GenericBuildConfiguration - 16 + 17 0 @@ -1100,7 +1140,54 @@ false true - 8 + + true + + false + false + false + false + true + 0.01 + 10 + true + 25 + + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + + 2 + /home/programming/eepp/eefonts-debug + false + + %{buildDir} + Run /home/programming/eepp/eefonts-debug + eefonts-debug + ProjectExplorer.CustomExecutableRunConfiguration + 3768 + true + false + false + true + + 9 diff --git a/projects/linux/ee.files b/projects/linux/ee.files index e8c95a4f2..04f649a4c 100644 --- a/projects/linux/ee.files +++ b/projects/linux/ee.files @@ -455,7 +455,6 @@ ../../src/eepp/window/platform/x11/ccursorx11.cpp ../../src/eepp/window/platform/platformimpl.hpp ../../src/eepp/graphics/pixelperfect.cpp -../../src/eepp/graphics/glhelper.cpp ../../src/eepp/graphics/cvertexbuffervbo.cpp ../../src/eepp/graphics/cvertexbufferogl.cpp ../../src/eepp/graphics/cvertexbuffermanager.cpp @@ -610,3 +609,4 @@ ../../src/eepp/window/backend/SDL2/cbackendsdl2.cpp ../../src/examples/sound/sound.cpp ../../src/examples/sprites/sprites.cpp +../../src/examples/fonts/fonts.cpp diff --git a/projects/linux/ee.includes b/projects/linux/ee.includes new file mode 100644 index 000000000..02a2a3994 --- /dev/null +++ b/projects/linux/ee.includes @@ -0,0 +1 @@ +../../src/ diff --git a/src/eepp/graphics/cbatchrenderer.cpp b/src/eepp/graphics/cbatchrenderer.cpp index 33dd3a4bf..afe4c32a6 100755 --- a/src/eepp/graphics/cbatchrenderer.cpp +++ b/src/eepp/graphics/cbatchrenderer.cpp @@ -122,18 +122,16 @@ void cBatchRenderer::Flush() { GLi->Translatef( -mCenter.x, -mCenter.y, 0.0f); } - Uint32 alloc = sizeof(eeVertex) * NumVertex; - if ( NULL != mTexture ) { mTF->Bind( mTexture ); - GLi->TexCoordPointer( 2, GL_FP , sizeof(eeVertex), reinterpret_cast ( &mVertex[0] ) + sizeof(eeVector2f) , alloc ); + GLi->TexCoordPointer( 2, GL_FP , sizeof(eeVertex), reinterpret_cast ( &mVertex[0] ) + sizeof(eeVector2f) ); } else { GLi->Disable( GL_TEXTURE_2D ); GLi->DisableClientState( GL_TEXTURE_COORD_ARRAY ); } - GLi->VertexPointer ( 2, GL_FP , sizeof(eeVertex), reinterpret_cast ( &mVertex[0] ) , alloc ); - GLi->ColorPointer ( 4, GL_UNSIGNED_BYTE , sizeof(eeVertex), reinterpret_cast ( &mVertex[0] ) + sizeof(eeVector2f) + sizeof(eeTexCoord) , alloc ); + GLi->VertexPointer ( 2, GL_FP , sizeof(eeVertex), reinterpret_cast ( &mVertex[0] ) ); + GLi->ColorPointer ( 4, GL_UNSIGNED_BYTE , sizeof(eeVertex), reinterpret_cast ( &mVertex[0] ) + sizeof(eeVector2f) + sizeof(eeTexCoord) ); #ifdef EE_GLES if ( DM_QUADS == mCurrentMode ) { diff --git a/src/eepp/graphics/cfont.cpp b/src/eepp/graphics/cfont.cpp index c16bc8ddd..a835f702d 100644 --- a/src/eepp/graphics/cfont.cpp +++ b/src/eepp/graphics/cfont.cpp @@ -319,11 +319,9 @@ void cFont::Draw( cTextCache& TextCache, const eeFloat& X, const eeFloat& Y, con numvert = TextCache.CachedVerts(); } - Uint32 alloc = numvert * sizeof(eeVertexCoords); - - GLi->ColorPointer ( 4, GL_UNSIGNED_BYTE , 0 , reinterpret_cast( &Colors[0] ) , alloc ); - GLi->TexCoordPointer( 2, GL_FP , sizeof(eeVertexCoords), reinterpret_cast( &RenderCoords[0] ) , alloc ); - GLi->VertexPointer ( 2, GL_FP , sizeof(eeVertexCoords), reinterpret_cast( &RenderCoords[0] ) + sizeof(eeFloat) * 2 , alloc ); + GLi->ColorPointer ( 4, GL_UNSIGNED_BYTE , 0 , reinterpret_cast( &Colors[0] ) ); + GLi->TexCoordPointer( 2, GL_FP , sizeof(eeVertexCoords), reinterpret_cast( &RenderCoords[0] ) ); + GLi->VertexPointer ( 2, GL_FP , sizeof(eeVertexCoords), reinterpret_cast( &RenderCoords[0] ) + sizeof(eeFloat) * 2 ); #ifndef EE_GLES GLi->DrawArrays( GL_QUADS, 0, numvert ); @@ -500,11 +498,9 @@ void cFont::SubDraw( const String& Text, const eeFloat& X, const eeFloat& Y, con } } - Uint32 alloc = numvert * sizeof(eeVertexCoords); - - GLi->ColorPointer ( 4, GL_UNSIGNED_BYTE , 0 , reinterpret_cast( &mColors[0] ) , alloc ); - GLi->TexCoordPointer ( 2, GL_FP , sizeof(eeVertexCoords), reinterpret_cast( &mRenderCoords[0] ) , alloc ); - GLi->VertexPointer ( 2, GL_FP , sizeof(eeVertexCoords), reinterpret_cast( &mRenderCoords[0] ) + sizeof(eeFloat) * 2 , alloc ); + GLi->ColorPointer ( 4, GL_UNSIGNED_BYTE , 0 , reinterpret_cast( &mColors[0] ) ); + GLi->TexCoordPointer ( 2, GL_FP , sizeof(eeVertexCoords), reinterpret_cast( &mRenderCoords[0] ) ); + GLi->VertexPointer ( 2, GL_FP , sizeof(eeVertexCoords), reinterpret_cast( &mRenderCoords[0] ) + sizeof(eeFloat) * 2 ); #ifndef EE_GLES GLi->DrawArrays( GL_QUADS, 0, numvert ); diff --git a/src/eepp/graphics/cimage.cpp b/src/eepp/graphics/cimage.cpp index 5fa4c4e08..a4ada43ff 100644 --- a/src/eepp/graphics/cimage.cpp +++ b/src/eepp/graphics/cimage.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -319,6 +320,11 @@ eeUint cImage::Channels() const { bool cImage::SaveToFile( const std::string& filepath, const EE_SAVE_TYPE& Format ) { bool Res = false; + std::string fpath( FileSystem::FileRemoveFileName( filepath )); + + if ( !FileSystem::IsDirectory( fpath ) ) + FileSystem::MakeDir( fpath ); + if ( NULL != mPixels && 0 != mWidth && 0 != mHeight && 0 != mChannels ) { if ( SAVE_TYPE_JPG != Format ) { Res = 0 != ( SOIL_save_image ( filepath.c_str(), Format, (Int32)mWidth, (Int32)mHeight, mChannels, GetPixelsPtr() ) ); diff --git a/src/eepp/graphics/cparticlesystem.cpp b/src/eepp/graphics/cparticlesystem.cpp index 86c135617..f35e78665 100755 --- a/src/eepp/graphics/cparticlesystem.cpp +++ b/src/eepp/graphics/cparticlesystem.cpp @@ -327,10 +327,8 @@ void cParticleSystem::Draw() { GLi->Enable( GL_POINT_SPRITE ); GLi->PointSize( mSize ); - Uint32 alloc = mPCount * sizeof(cParticle); - - GLi->ColorPointer ( 4, GL_FP, sizeof(cParticle), reinterpret_cast( &mParticle[0] ) + sizeof(eeFloat) * 2 , alloc ); - GLi->VertexPointer ( 2, GL_FP, sizeof(cParticle), reinterpret_cast( &mParticle[0] ) , alloc ); + GLi->ColorPointer ( 4, GL_FP, sizeof(cParticle), reinterpret_cast( &mParticle[0] ) + sizeof(eeFloat) * 2 ); + GLi->VertexPointer ( 2, GL_FP, sizeof(cParticle), reinterpret_cast( &mParticle[0] ) ); GLi->DrawArrays( GL_POINTS, 0, (GLsizei)mPCount ); diff --git a/src/eepp/graphics/cttffont.cpp b/src/eepp/graphics/cttffont.cpp index 692d83ba3..6487e6266 100755 --- a/src/eepp/graphics/cttffont.cpp +++ b/src/eepp/graphics/cttffont.cpp @@ -224,9 +224,9 @@ bool cTTFFont::iLoad( const eeUint& Size, EE_TTF_FONT_STYLE Style, const bool& V if ( OutlineSize ) { Uint32 Pos = 0; - std::vector TexO( TexSize, 0 ); - std::vector TexN( TexSize, 0 ); - std::vector TexI( TexSize, 0 ); + Uint8 * TexO = eeNewArray( Uint8, TexSize ); + Uint8 * TexN = eeNewArray( Uint8, TexSize ); + Uint8 * TexI = eeNewArray( Uint8, TexSize ); // Fill the TexO ( the default font alpha channels ) and the TexN ( the new outline ) for ( Int32 y = 0; y < mTexHeight; y++ ) { @@ -234,33 +234,32 @@ bool cTTFFont::iLoad( const eeUint& Size, EE_TTF_FONT_STYLE Style, const bool& V Pos = x + y * (Uint32)mTexWidth; TexO[ Pos ] = mPixels[ Pos ].A(); TexN[ Pos ] = TexO[ Pos ]; + TexI[ Pos ] = 0; } } - Uint8* alpha = reinterpret_cast( &TexN[0] ); - Uint8* alpha2 = reinterpret_cast( &TexI[0] ); + Uint8* alpha = reinterpret_cast( &TexN[0] ); + Uint8* alpha2 = reinterpret_cast( &TexI[0] ); // Create the outline - for ( Uint8 passes = 0; passes < OutlineSize; passes++ ) { - MakeOutline( alpha, alpha2, static_cast( mTexWidth ), static_cast( mTexHeight ) ); - - Uint8* temp = alpha; - alpha = alpha2; - alpha2 = temp; - } + MakeOutline( alpha, alpha2, static_cast( mTexWidth ), static_cast( mTexHeight ), OutlineSize ); for ( Int32 y = 0; y < mTexHeight; y++ ) { for( Int32 x = 0; x < mTexWidth; x++) { Pos = x + y * (Uint32)mTexWidth; // Fill the outline color - mPixels[ Pos ] = eeColorA( OutlineColor.R(), OutlineColor.G(), OutlineColor.B(), alpha[ Pos ] ); + mPixels[ Pos ] = eeColorA( OutlineColor.R(), OutlineColor.G(), OutlineColor.B(), alpha2[ Pos ] ); // Fill the font color if ( TexO[ Pos ] > 50 ) mPixels[ Pos ] = eeColorA( FontColor.R(), FontColor.G(), FontColor.B(), TexO[ Pos ] ); } } + + eeSAFE_DELETE_ARRAY( TexO ); + eeSAFE_DELETE_ARRAY( TexN ); + eeSAFE_DELETE_ARRAY( TexI ); } hkFontManager::instance()->CloseFont( mFont ); @@ -374,13 +373,13 @@ bool cTTFFont::Save( const std::string& TexturePath, const std::string& Coordina return SaveTexture(TexturePath, Format) && SaveCoordinates( CoordinatesDatPath ); } -void cTTFFont::MakeOutline( Uint8 *in, Uint8 *out, Int16 w, Int16 h) { +void cTTFFont::MakeOutline( Uint8 *in, Uint8 *out, Int16 w, Int16 h , Int16 OutlineSize ) { for ( eeInt y = 0; y < h; y++ ) { for( eeInt x = 0; x < w; x++ ) { - eeInt c = in[ y * w + x ]; + eeInt c = ( in[ y * w + x ] >> 24 ) & 0xFF; - for ( eeInt s_y = -1; s_y <= 1; s_y++ ) { - for ( eeInt s_x = -1; s_x <= 1; s_x++ ) { + for ( eeInt s_y = -OutlineSize; s_y <= OutlineSize; s_y++ ) { + for ( eeInt s_x = -OutlineSize; s_x <= OutlineSize; s_x++ ) { eeInt get_x = x + s_x; eeInt get_y = y + s_y; diff --git a/src/eepp/graphics/cvertexbufferogl.cpp b/src/eepp/graphics/cvertexbufferogl.cpp index bfde36abb..09e8edf13 100644 --- a/src/eepp/graphics/cvertexbufferogl.cpp +++ b/src/eepp/graphics/cvertexbufferogl.cpp @@ -33,13 +33,10 @@ void cVertexBufferOGL::Draw() { } void cVertexBufferOGL::SetVertexStates() { - Uint32 alloc = GetVertexCount() * sizeof(GLfloat) * 2; - Uint32 allocC = GetVertexCount() * sizeof(GL_UNSIGNED_BYTE) * 4; - /// POSITION if( VERTEX_FLAG_QUERY( mVertexFlags, VERTEX_FLAG_POSITION ) ) { GLi->EnableClientState( GL_VERTEX_ARRAY ); - GLi->VertexPointer( eeVertexElements[ VERTEX_FLAG_POSITION ], GL_FP, sizeof(eeFloat) * eeVertexElements[ VERTEX_FLAG_POSITION ], &mVertexArray[ VERTEX_FLAG_POSITION ][0], alloc ); + GLi->VertexPointer( eeVertexElements[ VERTEX_FLAG_POSITION ], GL_FP, sizeof(eeFloat) * eeVertexElements[ VERTEX_FLAG_POSITION ], &mVertexArray[ VERTEX_FLAG_POSITION ][0] ); } else { GLi->DisableClientState( GL_VERTEX_ARRAY ); } @@ -47,7 +44,7 @@ void cVertexBufferOGL::SetVertexStates() { /// COLOR if( VERTEX_FLAG_QUERY( mVertexFlags, VERTEX_FLAG_COLOR ) ) { GLi->EnableClientState( GL_COLOR_ARRAY ); - GLi->ColorPointer( eeVertexElements[ VERTEX_FLAG_COLOR ], GL_UNSIGNED_BYTE, sizeof(Uint8) * eeVertexElements[ VERTEX_FLAG_COLOR ], &mColorArray[0], allocC ); + GLi->ColorPointer( eeVertexElements[ VERTEX_FLAG_COLOR ], GL_UNSIGNED_BYTE, sizeof(Uint8) * eeVertexElements[ VERTEX_FLAG_COLOR ], &mColorArray[0] ); } else { GLi->DisableClientState( GL_COLOR_ARRAY ); } @@ -59,16 +56,19 @@ void cVertexBufferOGL::SetVertexStates() { GLi->ClientActiveTexture( GL_TEXTURE0 + i ); GLi->EnableClientState( GL_TEXTURE_COORD_ARRAY ); - GLi->TexCoordPointer( eeVertexElements[ VERTEX_FLAG_TEXTURE0 + i ], GL_FP, sizeof(eeFloat) * eeVertexElements[ VERTEX_FLAG_TEXTURE0 + i ], &mVertexArray[ VERTEX_FLAG_TEXTURE0 + i ][0], alloc ); + GLi->TexCoordPointer( eeVertexElements[ VERTEX_FLAG_TEXTURE0 + i ], GL_FP, sizeof(eeFloat) * eeVertexElements[ VERTEX_FLAG_TEXTURE0 + i ], &mVertexArray[ VERTEX_FLAG_TEXTURE0 + i ][0] ); } else { - GLi->Disable( GL_TEXTURE_2D ); - GLi->DisableClientState( GL_TEXTURE_COORD_ARRAY ); + if ( 0 == i ) { + GLi->Disable( GL_TEXTURE_2D ); + GLi->DisableClientState( GL_TEXTURE_COORD_ARRAY ); + break; + } } } } else { if ( VERTEX_FLAG_QUERY( mVertexFlags, VERTEX_FLAG_TEXTURE0 ) ) { GLi->EnableClientState( GL_TEXTURE_COORD_ARRAY ); - GLi->TexCoordPointer( eeVertexElements[ VERTEX_FLAG_TEXTURE0 ], GL_FP, sizeof(eeFloat) * eeVertexElements[ VERTEX_FLAG_TEXTURE0 ], &mVertexArray[ VERTEX_FLAG_TEXTURE0 ][0], alloc ); + GLi->TexCoordPointer( eeVertexElements[ VERTEX_FLAG_TEXTURE0 ], GL_FP, sizeof(eeFloat) * eeVertexElements[ VERTEX_FLAG_TEXTURE0 ], &mVertexArray[ VERTEX_FLAG_TEXTURE0 ][0] ); } else { GLi->Disable( GL_TEXTURE_2D ); GLi->DisableClientState( GL_TEXTURE_COORD_ARRAY ); diff --git a/src/eepp/graphics/cvertexbuffervbo.cpp b/src/eepp/graphics/cvertexbuffervbo.cpp index 793e8d576..25e16b322 100644 --- a/src/eepp/graphics/cvertexbuffervbo.cpp +++ b/src/eepp/graphics/cvertexbuffervbo.cpp @@ -192,14 +192,16 @@ void cVertexBufferVBO::SetVertexStates() { else #endif { - GLi->TexCoordPointer( eeVertexElements[ VERTEX_FLAG_TEXTURE0 + i ], GL_FP, 0, (char*)NULL, 0 ); + GLi->TexCoordPointer( eeVertexElements[ VERTEX_FLAG_TEXTURE0 + i ], GL_FP, 0, (char*)NULL ); } mTextured = true; } else { - GLi->DisableClientState( GL_TEXTURE_COORD_ARRAY ); - GLi->Disable( GL_TEXTURE_2D ); - break; + if ( 0 == i ) { + GLi->DisableClientState( GL_TEXTURE_COORD_ARRAY ); + GLi->Disable( GL_TEXTURE_2D ); + break; + } } } } else { @@ -219,7 +221,7 @@ void cVertexBufferVBO::SetVertexStates() { else #endif { - GLi->TexCoordPointer( eeVertexElements[ VERTEX_FLAG_TEXTURE0 ], GL_FP, 0, (char*)NULL, 0 ); + GLi->TexCoordPointer( eeVertexElements[ VERTEX_FLAG_TEXTURE0 ], GL_FP, 0, (char*)NULL ); } mTextured = true; @@ -248,7 +250,7 @@ void cVertexBufferVBO::SetVertexStates() { else #endif { - GLi->VertexPointer( eeVertexElements[ VERTEX_FLAG_POSITION ], GL_FP, 0, (char*)NULL, 0 ); + GLi->VertexPointer( eeVertexElements[ VERTEX_FLAG_POSITION ], GL_FP, 0, (char*)NULL ); } } else { GLi->DisableClientState( GL_VERTEX_ARRAY ); @@ -271,7 +273,7 @@ void cVertexBufferVBO::SetVertexStates() { else #endif { - GLi->ColorPointer( eeVertexElements[ VERTEX_FLAG_COLOR ], GL_UNSIGNED_BYTE, 0, (char*)NULL, 0 ); + GLi->ColorPointer( eeVertexElements[ VERTEX_FLAG_COLOR ], GL_UNSIGNED_BYTE, 0, (char*)NULL ); } } else { GLi->DisableClientState( GL_COLOR_ARRAY ); diff --git a/src/eepp/graphics/renderer/crenderergl.cpp b/src/eepp/graphics/renderer/crenderergl.cpp index f381cca74..7562b3806 100644 --- a/src/eepp/graphics/renderer/crenderergl.cpp +++ b/src/eepp/graphics/renderer/crenderergl.cpp @@ -201,15 +201,15 @@ void cRendererGL::DisableClientState( GLenum array ) { glDisableClientState( array ); } -void cRendererGL::VertexPointer ( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer, GLuint allocate ) { +void cRendererGL::VertexPointer ( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer ) { glVertexPointer( size, type, stride, pointer ); } -void cRendererGL::ColorPointer ( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer, GLuint allocate ) { +void cRendererGL::ColorPointer ( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer ) { glColorPointer( size, type, stride, pointer ); } -void cRendererGL::TexCoordPointer ( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer, GLuint allocate ) { +void cRendererGL::TexCoordPointer ( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer ) { glTexCoordPointer( size, type, stride, pointer ); } diff --git a/src/eepp/graphics/renderer/crenderergl3.cpp b/src/eepp/graphics/renderer/crenderergl3.cpp index 0a6b4cf1c..b28c1965c 100644 --- a/src/eepp/graphics/renderer/crenderergl3.cpp +++ b/src/eepp/graphics/renderer/crenderergl3.cpp @@ -337,7 +337,7 @@ void cRendererGL3::DisableClientState( GLenum array ) { } } -void cRendererGL3::VertexPointer ( GLint size, GLenum type, GLsizei stride, const GLvoid * pointer, GLuint allocate ) { +void cRendererGL3::VertexPointer ( GLint size, GLenum type, GLsizei stride, const GLvoid * pointer ) { const GLint index = mAttribsLoc[ EEGL_VERTEX_ARRAY ]; if ( -1 != index ) { @@ -351,7 +351,7 @@ void cRendererGL3::VertexPointer ( GLint size, GLenum type, GLsizei stride, cons } } -void cRendererGL3::ColorPointer ( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer, GLuint allocate ) { +void cRendererGL3::ColorPointer ( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer ) { const GLint index = mAttribsLoc[ EEGL_COLOR_ARRAY ]; if ( -1 != index ) { @@ -369,7 +369,7 @@ void cRendererGL3::ColorPointer ( GLint size, GLenum type, GLsizei stride, const } } -void cRendererGL3::TexCoordPointer ( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer, GLuint allocate ) { +void cRendererGL3::TexCoordPointer ( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer ) { const GLint index = mTextureUnits[ mCurActiveTex ]; if ( -1 != index ) { diff --git a/src/eepp/graphics/renderer/crenderergles2.cpp b/src/eepp/graphics/renderer/crenderergles2.cpp index 9174858a3..8b0d26afd 100644 --- a/src/eepp/graphics/renderer/crenderergles2.cpp +++ b/src/eepp/graphics/renderer/crenderergles2.cpp @@ -398,7 +398,7 @@ void cRendererGLES2::DisableClientState( GLenum array ) { } } -void cRendererGLES2::VertexPointer ( GLint size, GLenum type, GLsizei stride, const GLvoid * pointer, GLuint allocate ) { +void cRendererGLES2::VertexPointer ( GLint size, GLenum type, GLsizei stride, const GLvoid * pointer ) { const GLint index = mAttribsLoc[ EEGL_VERTEX_ARRAY ]; if ( -1 != index ) { @@ -412,7 +412,7 @@ void cRendererGLES2::VertexPointer ( GLint size, GLenum type, GLsizei stride, co } } -void cRendererGLES2::ColorPointer ( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer, GLuint allocate ) { +void cRendererGLES2::ColorPointer ( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer ) { const GLint index = mAttribsLoc[ EEGL_COLOR_ARRAY ]; if ( -1 != index ) { @@ -430,7 +430,7 @@ void cRendererGLES2::ColorPointer ( GLint size, GLenum type, GLsizei stride, con } } -void cRendererGLES2::TexCoordPointer ( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer, GLuint allocate ) { +void cRendererGLES2::TexCoordPointer ( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer ) { if ( mCurShaderLocal ) { if ( 1 == mTexActive ) { if ( mCurShader == mShaders[ EEGLES2_SHADER_PRIMITIVE ] ) { diff --git a/src/eepp/physics/constraints/cdampedspring.cpp b/src/eepp/physics/constraints/cdampedspring.cpp index 1594144ff..d89b968be 100644 --- a/src/eepp/physics/constraints/cdampedspring.cpp +++ b/src/eepp/physics/constraints/cdampedspring.cpp @@ -78,8 +78,8 @@ void cDampedSpring::Draw() { GLi->DisableClientState( GL_TEXTURE_COORD_ARRAY ); std::vector tcolors( springVAR_count * 4, eeColorA( 0, 255, 0, 255 ) ); - GLi->ColorPointer( 4, GL_UNSIGNED_BYTE, 0, reinterpret_cast( &tcolors[0] ), pillVAR_count * sizeof(GLfloat) * 4 ); - GLi->VertexPointer( 2, GL_FLOAT, 0, springVAR, springVAR_count * sizeof(GLfloat) * 2 ); + GLi->ColorPointer( 4, GL_UNSIGNED_BYTE, 0, reinterpret_cast( &tcolors[0] ) ); + GLi->VertexPointer( 2, GL_FLOAT, 0, springVAR ); GLi->PushMatrix(); diff --git a/src/eepp/physics/cshapesegment.cpp b/src/eepp/physics/cshapesegment.cpp index 72825ff5d..e4817f5a6 100644 --- a/src/eepp/physics/cshapesegment.cpp +++ b/src/eepp/physics/cshapesegment.cpp @@ -81,21 +81,21 @@ void cShapeSegment::Draw( cSpace * space ) { GLi->MultMatrixf( matrix ); - GLi->VertexPointer( 3, GL_FLOAT, 0, pillVAR, pillVAR_count * sizeof(GLfloat) * 3 ); + GLi->VertexPointer( 3, GL_FLOAT, 0, pillVAR ); if( !seg->CP_PRIVATE(shape).sensor ) { eeColorA C = ColorForShape( mShape, space->Space() ); tcolors.assign( tcolors.size(), C ); - GLi->ColorPointer( 4, GL_UNSIGNED_BYTE, 0, reinterpret_cast( &tcolors[0] ), pillVAR_count * sizeof(GLfloat) * 4 ); + GLi->ColorPointer( 4, GL_UNSIGNED_BYTE, 0, reinterpret_cast( &tcolors[0] ) ); GLi->DrawArrays( GL_TRIANGLE_FAN, 0, pillVAR_count ); } tcolors.assign( tcolors.size(), eeColorA( 102, 102, 102, 255 ) ); - GLi->ColorPointer( 4, GL_UNSIGNED_BYTE, 0, reinterpret_cast( &tcolors[0] ), pillVAR_count * sizeof(GLfloat) * 4 ); + GLi->ColorPointer( 4, GL_UNSIGNED_BYTE, 0, reinterpret_cast( &tcolors[0] ) ); GLi->DrawArrays( GL_LINE_LOOP, 0, pillVAR_count ); diff --git a/src/eepp/window/cinput.cpp b/src/eepp/window/cinput.cpp index e31feea05..9664a7637 100644 --- a/src/eepp/window/cinput.cpp +++ b/src/eepp/window/cinput.cpp @@ -114,7 +114,7 @@ void cInput::ProcessEvent( InputEvent * Event ) { mReleaseTrigger |= EE_BUTTON_MASK( Event->button.button ); mClickTrigger |= EE_BUTTON_MASK( Event->button.button ); - // I know this is ugly, but i'm to lazy to fix it, it works... + // I know this is ugly, but i'm too lazy to fix it, it works... if ( Event->button.button == EE_BUTTON_LEFT ) { mLastButtonLeftClicked = mLastButtonLeftClick; mLastButtonLeftClick = Sys::GetTicks(); diff --git a/src/eepp/window/inputhelper.cpp b/src/eepp/window/inputhelper.cpp index 884033201..c4e3fe5a6 100644 --- a/src/eepp/window/inputhelper.cpp +++ b/src/eepp/window/inputhelper.cpp @@ -64,25 +64,6 @@ Uint32 eeConvertKeyCharacter( const Uint32& KeyCode, const Uint16& Unicode, cons default: break; } -/** @TODO: Report SDL2 bug not reporting Key Modifiers correctly. */ -#ifndef EE_SDL_VERSION_2 - if ( !( Modifiers & KEYMOD_NUM ) ) { - switch ( KeyCode ) { - case KEY_KP0: value = KEY_INSERT; break; - case KEY_KP1: value = KEY_END; break; - case KEY_KP2: value = KEY_DOWN; break; - case KEY_KP3: value = KEY_PAGEDOWN; break; - case KEY_KP4: value = KEY_LEFT; break; - case KEY_KP5: value = 0; break; - case KEY_KP6: value = KEY_RIGHT; break; - case KEY_KP7: value = KEY_HOME; break; - case KEY_KP8: value = KEY_UP; break; - case KEY_KP9: value = KEY_PAGEUP; break; - default: break; - } - } -#endif - return value; } diff --git a/src/examples/empty_window/empty_window.cpp b/src/examples/empty_window/empty_window.cpp index 70d62aec2..d0c02b18d 100644 --- a/src/examples/empty_window/empty_window.cpp +++ b/src/examples/empty_window/empty_window.cpp @@ -10,8 +10,7 @@ EE_MAIN_FUNC int main (int argc, char * argv []) win->BackColor( eeColor( 50, 50, 50 ) ); // Check if created - if ( win->Created() ) - { + if ( win->Created() ) { // Create an instance of the primitive renderer cPrimitives p; @@ -19,14 +18,12 @@ EE_MAIN_FUNC int main (int argc, char * argv []) p.SetColor( eeColorA( 0, 255, 0, 150 ) ); // Application loop - while ( win->Running() ) - { + while ( win->Running() ) { // Update the input win->GetInput()->Update(); // Check if ESCAPE key is pressed - if ( win->GetInput()->IsKeyDown( KEY_ESCAPE ) ) - { + if ( win->GetInput()->IsKeyDown( KEY_ESCAPE ) ) { // Close the window win->Close(); } diff --git a/src/examples/external_shader/external_shader.cpp b/src/examples/external_shader/external_shader.cpp index cc54b940c..5166114bb 100644 --- a/src/examples/external_shader/external_shader.cpp +++ b/src/examples/external_shader/external_shader.cpp @@ -247,10 +247,10 @@ EE_MAIN_FUNC int main (int argc, char * argv []) /// VertexPointer assigns values by default to the attribute "dgl_Vertex" /// TextureCoordPointer to "dgl_MultiTexCoord0" - GLi->VertexPointer( 3, GL_FLOAT, sizeof(eeVector3ff), reinterpret_cast ( &vertices[0] ), 0 ); + GLi->VertexPointer( 3, GL_FLOAT, sizeof(eeVector3ff), reinterpret_cast ( &vertices[0] ) ); /// ColorPointer to "dgl_FrontColor" - GLi->ColorPointer( 4, GL_FP, sizeof(eeColorAf), reinterpret_cast ( &colors[0] ), 0 ); + GLi->ColorPointer( 4, GL_FP, sizeof(eeColorAf), reinterpret_cast ( &colors[0] ) ); /// Draw the lines GLi->DrawArrays( DM_LINES, 0, ParticlesNum ); diff --git a/src/examples/fonts/fonts.cpp b/src/examples/fonts/fonts.cpp new file mode 100644 index 000000000..bdcd828b8 --- /dev/null +++ b/src/examples/fonts/fonts.cpp @@ -0,0 +1,110 @@ +#include + +EE_MAIN_FUNC int main (int argc, char * argv []) +{ + // Create a new window + cWindow * win = cEngine::instance()->CreateWindow( WindowSettings( 960, 640, "eepp - Fonts" ), ContextSettings( true ) ); + + // Set window background color + win->BackColor( eeColor(255,255,255) ); + + // Check if created + if ( win->Created() ) { + // Get the application path + std::string AppPath = Sys::GetProcessPath(); + + // Create a new True Type Font + cTTFFont * TTF = cTTFFont::New( "DejaVuSansMonoOutline" ); + cTTFFont * TTF2 = cTTFFont::New( "DejaVuSansMono" ); + cTextureFont * TexF = cTextureFont::New( "ProggySquareSZ" ); + cTextureFont * TexF2 = cTextureFont::New( "conchars" ); + + // Load the TTF font + TTF->Load( AppPath + "assets/fonts/DejaVuSansMono.ttf", 18, TTF_STYLE_NORMAL, false, 128, eeColor(255,255,255), 3, eeColor(0,0,0), true ); + TTF2->Load( AppPath + "assets/fonts/DejaVuSansMono.ttf", 24, TTF_STYLE_NORMAL, false, 128, eeColor(255,255,255), 0, eeColor(0,0,0), true ); + + // Save the TTF font so then it can be loaded as a cTextureFont + TTF->Save( AppPath + "assets/temp/DejaVuSansMono.png", AppPath + "assets/temp/DejaVuSansMono.fnt" ); + + // Load the texture font, previusly generated from a True Type Font + // First load the texture + Uint32 TexFid = cTextureFactory::instance()->Load( AppPath + "assets/fonts/ProggySquareSZ.png" ); + TexF->Load( TexFid, AppPath + "assets/fonts/ProggySquareSZ.dat" ); + + // Load a monospaced texture font from image ( using the texture loader to set the color key ) + cTextureLoader TexLoader( AppPath + "assets/fonts/conchars.png" ); + TexLoader.SetColorKey( eeColor(0,0,0) ); + TexLoader.Load();; + TexF2->Load( TexLoader.Id(), 32 ); + + // Set a text to render + TTF->SetText( "Lorem ipsum dolor sit amet, consectetur adipisicing elit." ); + TTF2->SetText( TTF->GetText() ); + TexF->SetText( TTF->GetText() ); + TexF2->SetText( TTF->GetText() ); + + // Set the font color + TTF2->Color( eeColor(0,0,0) ); + TexF->Color( eeColor(0,0,0) ); + + // Create a new text string + String Txt( String::FromUtf8( "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." ) ); + + // Make the text fit the screen width ( wrap the text ) + TTF2->ShrinkText( Txt, win->GetWidth() - 96 ); + + // Create a new text cache to draw on screen + // The cached text will + cTextCache TxtCache( TTF2, Txt, eeColorA(0,0,0,255) ); + + // Set the font color to a substring of the text + // To be able to set the color of the font, create the font as white + // Create a gradient + size_t size = TxtCache.Text().size(); + + for ( size_t i = 0; i < size; i++ ) { + TxtCache.Color( eeColorA(255*i/size,0,0,255), i, i+1 ); + } + + // Application loop + while ( win->Running() ) { + // Update the input + win->GetInput()->Update(); + + // Check if ESCAPE key is pressed + if ( win->GetInput()->IsKeyDown( KEY_ESCAPE ) ) { + // Close the window + win->Close(); + } + + eeFloat YPos = 32; + + // Draw the text on screen + TTF->Draw( win->GetWidth() * 0.5f - TTF->GetTextWidth() * 0.5f, YPos ); + + TTF2->Draw( win->GetWidth() * 0.5f - TTF2->GetTextWidth() * 0.5f, ( YPos += TTF->GetTextHeight() + 24 ) ); + + TexF->Draw( win->GetWidth() * 0.5f - TexF->GetTextWidth() * 0.5f, ( YPos += TTF2->GetTextHeight() + 24 ) ); + + TexF2->Draw( win->GetWidth() * 0.5f - TexF2->GetTextWidth() * 0.5f, ( YPos += TexF->GetTextHeight() + 24 ) ); + + // Draw the cached text + TxtCache.Draw( 48, ( YPos += TexF2->GetTextHeight() + 24 ), FONT_DRAW_CENTER ); + + // Text rotated and scaled + TTF->Draw( win->GetWidth() * 0.5f - TTF->GetTextWidth() * 0.5f, 512, FONT_DRAW_LEFT, 0.75f, 12.5f ); + + // Draw frame + win->Display(); + } + } + + // Destroy the engine instance. Destroys all the windows and engine singletons. + // Fonts are autoreleased by the engine + cEngine::DestroySingleton(); + + // If was compiled in debug mode it will print the memory manager report + EE::MemoryManager::ShowResults(); + + return EXIT_SUCCESS; +} diff --git a/src/examples/sprites/sprites.cpp b/src/examples/sprites/sprites.cpp index 942ed55c7..22daab7a9 100644 --- a/src/examples/sprites/sprites.cpp +++ b/src/examples/sprites/sprites.cpp @@ -31,9 +31,6 @@ EE_MAIN_FUNC int main (int argc, char * argv []) // Create a new window cWindow * win = cEngine::instance()->CreateWindow( WindowSettings( 640, 480, "eepp - Sprites" ), ContextSettings( true ) ); - // Set window background color - win->BackColor( eeColor( 0, 0, 0 ) ); - // Check if created if ( win->Created() ) { // Get the application path