From 3554d42ce95597a8035cb59fe5838997609a4d20 Mon Sep 17 00:00:00 2001 From: Jerome St-Louis Date: Wed, 26 Nov 2014 22:24:28 -0500 Subject: [PATCH] ecere; samples/guiAndGfx/HelloForm: Emscripten fixes - Emscripten configurations - OpenGLDisplayDriver: Avoiding glRecti() as it's not supported by the Em legacy wrapper - Call to ExternalPosition() to size desktop window --- ecere/ecere.epj | 66 ++++++++++++++++++++++++++-- ecere/ecereCOM.epj | 13 +++++- ecere/src/gfx/drivers/OpenGLDisplayDriver.ec | 59 ++++++++++++++++++++++++- ecere/src/gui/drivers/EmscriptenInterface.ec | 1 + samples/guiAndGfx/HelloForm/helloForm.ec | 2 +- samples/guiAndGfx/HelloForm/helloForm.epj | 22 ++++++++++ 6 files changed, 156 insertions(+), 7 deletions(-) diff --git a/ecere/ecere.epj b/ecere/ecere.epj index 4757285..846d5b2 100644 --- a/ecere/ecere.epj +++ b/ecere/ecere.epj @@ -441,6 +441,19 @@ from wherever you obtained them. "_GLES" ] } + }, + { + "Name" : "Emscripten", + "Options" : { + "Debug" : true, + "PreprocessorDefinitions" : [ + "ECERE_STATIC", + "ECERE_VANILLA", + "NOBLENDING" + ], + "TargetType" : "StaticLibrary", + "TargetFileName" : "ecereStatic" + } } ], "Files" : [ @@ -653,6 +666,12 @@ from wherever you obtained them. } } ] + }, + { + "Name" : "Emscripten", + "Options" : { + "ExcludeFromBuild" : true + } } ] }, @@ -695,6 +714,12 @@ from wherever you obtained them. } } ] + }, + { + "Name" : "Emscripten", + "Options" : { + "ExcludeFromBuild" : true + } } ] }, @@ -717,6 +742,12 @@ from wherever you obtained them. } } ] + }, + { + "Name" : "Emscripten", + "Options" : { + "ExcludeFromBuild" : true + } } ] }, @@ -731,7 +762,17 @@ from wherever you obtained them. } ] }, - "PNGFormat.ec", + { + "FileName" : "PNGFormat.ec", + "Configurations" : [ + { + "Name" : "Emscripten", + "Options" : { + "ExcludeFromBuild" : true + } + } + ] + }, { "FileName" : "RGBFormat.ec", "Configurations" : [ @@ -757,6 +798,12 @@ from wherever you obtained them. } } ] + }, + { + "Name" : "Emscripten", + "Options" : { + "ExcludeFromBuild" : true + } } ] } @@ -1876,9 +1923,14 @@ from wherever you obtained them. }, { "FileName" : "EmscriptenInterface.ec", - "Options" : { - "ExcludeFromBuild" : false - } + "Configurations" : [ + { + "Name" : "Emscripten", + "Options" : { + "ExcludeFromBuild" : false + } + } + ] } ], "Options" : { @@ -2074,6 +2126,12 @@ from wherever you obtained them. } } ] + }, + { + "Name" : "Emscripten", + "Options" : { + "ExcludeFromBuild" : true + } } ] }, diff --git a/ecere/ecereCOM.epj b/ecere/ecereCOM.epj index 1e6bf37..46aea46 100644 --- a/ecere/ecereCOM.epj +++ b/ecere/ecereCOM.epj @@ -70,13 +70,24 @@ ], "TargetType" : "StaticLibrary", "TargetFileName" : "ecereCOMStatic", - "TargetDirectory" : "ecereCOMStatic", "ObjectsDirectory" : "ecereCOMStatic", "Libraries" : [ ], "FastMath" : true } + }, + { + "Name" : "Emscripten", + "Options" : { + "Optimization" : "Size", + "PreprocessorDefinitions" : [ + "ECERE_STATIC", + "ECERE_COM_ONLY" + ], + "TargetType" : "StaticLibrary", + "TargetFileName" : "ecereCOMStatic" + } } ], "Files" : [ diff --git a/ecere/src/gfx/drivers/OpenGLDisplayDriver.ec b/ecere/src/gfx/drivers/OpenGLDisplayDriver.ec index af87f3d..829dc41 100644 --- a/ecere/src/gfx/drivers/OpenGLDisplayDriver.ec +++ b/ecere/src/gfx/drivers/OpenGLDisplayDriver.ec @@ -419,6 +419,52 @@ static double nearPlane = 1; #endif +#if defined(ECERE_NO3D) || defined(ECERE_VANILLA) +public union Matrix +{ + double array[16]; + double m[4][4]; + + void Identity() + { + FillBytesBy4(this, 0, sizeof(Matrix) >> 2); + m[0][0]=m[1][1]=m[2][2]=m[3][3]=1; + } + + void Transpose(Matrix source) + { + int i,j; + for(i=0; i<4; i++) + for(j=0; j<4; j++) + m[j][i] = source.m[i][j]; + } + + void Multiply(Matrix a, Matrix b) + { + // We need a full matrix multiplication for the Projection matrix + m[0][0]=a.m[0][0]*b.m[0][0] + a.m[0][1]*b.m[1][0] + a.m[0][2]*b.m[2][0] + a.m[0][3]*b.m[3][0]; + m[0][1]=a.m[0][0]*b.m[0][1] + a.m[0][1]*b.m[1][1] + a.m[0][2]*b.m[2][1] + a.m[0][3]*b.m[3][1]; + m[0][2]=a.m[0][0]*b.m[0][2] + a.m[0][1]*b.m[1][2] + a.m[0][2]*b.m[2][2] + a.m[0][3]*b.m[3][2]; + m[0][3]=a.m[0][0]*b.m[0][3] + a.m[0][1]*b.m[1][3] + a.m[0][2]*b.m[2][3] + a.m[0][3]*b.m[3][3]; + + m[1][0]=a.m[1][0]*b.m[0][0] + a.m[1][1]*b.m[1][0] + a.m[1][2]*b.m[2][0] + a.m[1][3]*b.m[3][0]; + m[1][1]=a.m[1][0]*b.m[0][1] + a.m[1][1]*b.m[1][1] + a.m[1][2]*b.m[2][1] + a.m[1][3]*b.m[3][1]; + m[1][2]=a.m[1][0]*b.m[0][2] + a.m[1][1]*b.m[1][2] + a.m[1][2]*b.m[2][2] + a.m[1][3]*b.m[3][2]; + m[1][3]=a.m[1][0]*b.m[0][3] + a.m[1][1]*b.m[1][3] + a.m[1][2]*b.m[2][3] + a.m[1][3]*b.m[3][3]; + + m[2][0]=a.m[2][0]*b.m[0][0] + a.m[2][1]*b.m[1][0] + a.m[2][2]*b.m[2][0] + a.m[2][3]*b.m[3][0]; + m[2][1]=a.m[2][0]*b.m[0][1] + a.m[2][1]*b.m[1][1] + a.m[2][2]*b.m[2][1] + a.m[2][3]*b.m[3][1]; + m[2][2]=a.m[2][0]*b.m[0][2] + a.m[2][1]*b.m[1][2] + a.m[2][2]*b.m[2][2] + a.m[2][3]*b.m[3][2]; + m[2][3]=a.m[2][0]*b.m[0][3] + a.m[2][1]*b.m[1][3] + a.m[2][2]*b.m[2][3] + a.m[2][3]*b.m[3][3]; + + m[3][0]=a.m[3][0]*b.m[0][0] + a.m[3][1]*b.m[1][0] + a.m[3][2]*b.m[2][0] + a.m[3][3]*b.m[3][0]; + m[3][1]=a.m[3][0]*b.m[0][1] + a.m[3][1]*b.m[1][1] + a.m[3][2]*b.m[2][1] + a.m[3][3]*b.m[3][1]; + m[3][2]=a.m[3][0]*b.m[0][2] + a.m[3][1]*b.m[1][2] + a.m[3][2]*b.m[2][2] + a.m[3][3]*b.m[3][2]; + m[3][3]=a.m[3][0]*b.m[0][3] + a.m[3][1]*b.m[1][3] + a.m[3][2]*b.m[2][3] + a.m[3][3]*b.m[3][3]; + } +}; +#endif + // Our own matrix stack static Matrix matrixStack[3][32]; static int matrixIndex[3]; @@ -894,6 +940,7 @@ public void glesFrustum( double l, double r, double b, double t, double n, doubl } } +#if !defined(ECERE_NO3D) && !defined(ECERE_VANILLA) public void glesRotated( double a, double b, double c, double d ) { Quaternion q; @@ -934,6 +981,7 @@ public void glesMultMatrixd( double * i ) matrixStack[curStack][matrixIndex[curStack]] = r; LoadCurMatrix(); } +#endif public void glesMatrixMode(int mode) { @@ -2816,9 +2864,18 @@ class OpenGLDisplayDriver : DisplayDriver //Logf("Area\n"); glColor4fv(oglSurface.background); + +#ifdef __EMSCRIPTEN__ + glBegin(GL_QUADS); + glVertex2f(x1+surface.offset.x, y1+surface.offset.y); + glVertex2f(x1+surface.offset.x, y2+surface.offset.y+1); + glVertex2f(x2+surface.offset.x+1, y2+surface.offset.y+1); + glVertex2f(x2+surface.offset.x+1, y1+surface.offset.y); + glEnd(); +#else glRecti(x1+surface.offset.x, y1+surface.offset.y, x2+surface.offset.x + 1, y2+surface.offset.y + 1); - +#endif /* glRectf(x1+surface.offset.x, y1+surface.offset.y, x2+surface.offset.x + 1, y2+surface.offset.y + 1); diff --git a/ecere/src/gui/drivers/EmscriptenInterface.ec b/ecere/src/gui/drivers/EmscriptenInterface.ec index eb3d17e..9df8751 100644 --- a/ecere/src/gui/drivers/EmscriptenInterface.ec +++ b/ecere/src/gui/drivers/EmscriptenInterface.ec @@ -39,6 +39,7 @@ class EmscriptenInterface : Interface bool ::Initialize() { sflnprintf("class(EmscriptenInterface) ::Initialize [STUB!]\n"); + guiApp.desktop.ExternalPosition(0,0, 640, 480); return true; } diff --git a/samples/guiAndGfx/HelloForm/helloForm.ec b/samples/guiAndGfx/HelloForm/helloForm.ec index 3f2dbf2..69793fc 100644 --- a/samples/guiAndGfx/HelloForm/helloForm.ec +++ b/samples/guiAndGfx/HelloForm/helloForm.ec @@ -1,4 +1,4 @@ -import "ecere" +import IMPORT_STATIC "ecere" class HelloForm : Window { diff --git a/samples/guiAndGfx/HelloForm/helloForm.epj b/samples/guiAndGfx/HelloForm/helloForm.epj index 07266b4..8ec2f9e 100644 --- a/samples/guiAndGfx/HelloForm/helloForm.epj +++ b/samples/guiAndGfx/HelloForm/helloForm.epj @@ -15,6 +15,9 @@ "Name" : "Debug", "Options" : { "Debug" : true, + "PreprocessorDefinitions" : [ + "IMPORT_STATIC=" + ], "FastMath" : false } }, @@ -23,9 +26,28 @@ "Options" : { "Debug" : true, "MemoryGuard" : true, + "PreprocessorDefinitions" : [ + "IMPORT_STATIC=" + ], "Console" : true, "FastMath" : false } + }, + { + "Name" : "Emscripten", + "Options" : { + "Debug" : true, + "PreprocessorDefinitions" : [ + "IMPORT_STATIC=static" + ], + "Libraries" : [ + "ecereStatic", + "freetype" + ], + "LibraryDirs" : [ + "../../../ecere/obj/emscripten.linux.emscripten.x32" + ] + } } ], "Files" : [ -- 1.8.3.1