ecere; samples/guiAndGfx/HelloForm: Emscripten fixes
authorJerome St-Louis <jerome@ecere.com>
Thu, 27 Nov 2014 03:24:28 +0000 (22:24 -0500)
committerJerome St-Louis <jerome@ecere.com>
Fri, 20 Feb 2015 15:39:18 +0000 (10:39 -0500)
- 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
ecere/ecereCOM.epj
ecere/src/gfx/drivers/OpenGLDisplayDriver.ec
ecere/src/gui/drivers/EmscriptenInterface.ec
samples/guiAndGfx/HelloForm/helloForm.ec
samples/guiAndGfx/HelloForm/helloForm.epj

index 4757285..846d5b2 100644 (file)
@@ -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
+                     }
                   }
                ]
             },
index 1e6bf37..46aea46 100644 (file)
             ],
             "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" : [
index af87f3d..829dc41 100644 (file)
@@ -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);
index eb3d17e..9df8751 100644 (file)
@@ -39,6 +39,7 @@ class EmscriptenInterface : Interface
    bool ::Initialize()
    {
       sflnprintf("class(EmscriptenInterface) ::Initialize [STUB!]\n");
+      guiApp.desktop.ExternalPosition(0,0, 640, 480);
       return true;
    }
 
index 3f2dbf2..69793fc 100644 (file)
@@ -1,4 +1,4 @@
-import "ecere"
+import IMPORT_STATIC "ecere"
 
 class HelloForm : Window
 {
index 07266b4..8ec2f9e 100644 (file)
@@ -15,6 +15,9 @@
          "Name" : "Debug",
          "Options" : {
             "Debug" : true,
+            "PreprocessorDefinitions" : [
+               "IMPORT_STATIC="
+            ],
             "FastMath" : false
          }
       },
          "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" : [