Unstaged changes (WIP) glabWIPWIP
authorJerome St-Louis <jerome@ecere.com>
Mon, 27 Jul 2015 08:59:17 +0000 (04:59 -0400)
committerJerome St-Louis <jerome@ecere.com>
Mon, 27 Jul 2015 08:59:17 +0000 (04:59 -0400)
21 files changed:
compiler/libec/src/ecdefs.ec
compiler/libec/src/freeAst.ec
deps/libungif-4.1.1/lib/dgif_lib.c
ecere/src/com/dataTypes.ec
ecere/src/gfx/3D/Quaternion.ec
ecere/src/gfx/drivers/OpenGLDisplayDriver.ec
ecere/src/gui/GuiApplication.ec
ecere/src/gui/drivers/EmscriptenInterface.ec
ecere/src/sys/Mutex.ec
extras/XMLParser.ec
extras/gui/GuiConfigData.ec
extras/types/DynamicString.ec
installer/coursework/Chapter 6 - Classes, Methods and Instances/Lab6/lab6.ec
installer/coursework/Chapter 6 - Classes, Methods and Instances/Lab6/lab6.epj
samples/3D/hello3D/hello3D.ec
samples/3D/hello3D/hello3D.epj
samples/android/helloAndroid.epj
samples/eC/HelloWorld/HelloWorld.epj
samples/eC/staticLink/staticLink.ec
samples/games/othello/othello.ec
samples/games/stonePairs/stonePairs.epj

index 7a3ea19..7f2917c 100644 (file)
@@ -1154,6 +1154,9 @@ public:
          }
          return;
       }
+#ifdef _DEBUG
+      if(incoming)    // TOFIX: Null pointer crash
+#endif
       CreateEdge(from, soft);
    }
 
index a9fc0cc..b2076ce 100644 (file)
@@ -943,7 +943,11 @@ public void FreeInstance(Instantiation inst)
          if(_class.type == normalClass)
          {
             Instance instance = (Instance)inst.data;
-            delete instance;
+            if(instance._class == (void *)1)
+               // TOFIX: What causes this?
+               Print("");
+            else
+               delete instance;
          }
          else if(_class.type == noHeadClass)
          {
index 9540437..20df31b 100644 (file)
@@ -74,8 +74,10 @@ GifFileType *DGifOpenFileName(const char *FileName)
     }
 
     GifFile = DGifOpenFileHandle(FileHandle);
+#if !defined(__EMSCRIPTEN__)
     if (GifFile == (GifFileType *)NULL)
         close(FileHandle);
+#endif
     return GifFile;
 }
 
index 04f42aa..8ae72cb 100644 (file)
@@ -694,7 +694,7 @@ static const char * OnGetString(Class _class, void * data, char * tempString, vo
                   else // if(_class /*memberType*/.type != bitClass)
                   {
                      DataValue value { };
-                     if(_class.type == bitClass)
+                     if(_class.type == bitClass && !memberType.noExpansion)
                      {
                         BitMember bitMember = (BitMember) member;
                         // TODO: Check if base type is 32 or 64 bit
index 80a2d57..200d84d 100644 (file)
@@ -221,6 +221,48 @@ public struct Quaternion
       w = (double)(scale0 * from.w + scale1 * to1[3]);
    }
 
+   void SlerpD(Quaternion from, Quaternion to, double t)
+   {
+      double to1[4];
+      double omega, cosom, sinom, scale0, scale1;
+
+      cosom = from.x * to.x + from.y * to.y + from.z * to.z + from.w * to.w;
+
+      if ( cosom < 0.0 )
+      {
+         cosom = -cosom;
+         to1[0] = -to.x;
+         to1[1] = -to.y;
+         to1[2] = -to.z;
+         to1[3] = -to.w;
+      }
+      else
+      {
+         to1[0] = to.x;
+         to1[1] = to.y;
+         to1[2] = to.z;
+         to1[3] = to.w;
+      }
+
+      if ( (1.0 - cosom) > DELTA )
+      {
+         omega = acos(cosom);
+         sinom = sin(omega);
+         scale0 = sin((1.0 - t) * omega) / sinom;
+         scale1 = sin(t * omega) / sinom;
+
+      }
+      else
+      {
+         scale0 = 1.0 - t;
+         scale1 = t;
+      }
+      x = (double)(scale0 * from.x + scale1 * to1[0]);
+      y = (double)(scale0 * from.y + scale1 * to1[1]);
+      z = (double)(scale0 * from.z + scale1 * to1[2]);
+      w = (double)(scale0 * from.w + scale1 * to1[3]);
+   }
+
    void Yaw(Degrees angle)
    {
       double sa = sin( angle / 2 );
index 7c79ca4..e4770c5 100644 (file)
@@ -2545,8 +2545,11 @@ class OpenGLDisplayDriver : DisplayDriver
 #endif
       //Logf("DisplayScreen\n");
 
-      glFlush();
-      glFinish();
+#if !defined(__ANDROID__)
+      /*glFlush();
+      glFinish();*/
+#endif
+
 #if defined(__WIN32__) || defined(USEPBUFFER)
       if(display.alphaBlend)
       {
@@ -2769,7 +2772,9 @@ class OpenGLDisplayDriver : DisplayDriver
 
          glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
          glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+#ifndef __ANDROID__
          glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 16.0 );
+#endif
 
          glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
 
@@ -4303,6 +4308,33 @@ class OpenGLDisplayDriver : DisplayDriver
          else*/
 #endif
 
+#ifdef EM_MODE
+         /*
+         if(true)
+         {
+            int c;
+            glBegin(primitiveTypes[primitive->type.primitiveType]);
+            if(primitive->data)
+            {
+               OGLIndices oglIndices = primitive->data;
+               MeshFeatures flags = mesh.flags;
+               for(c = 0; c<primitive->nIndices; c++)
+               {
+                  uint16 index = ((uint16 *) oglIndices.indices)[c];
+
+                  //if(flags.normals) glNormal3fv((float *)&mesh.normals[index]);
+                  if(flags.normals) glNormal3f(mesh.normals[index].x, mesh.normals[index].y, mesh.normals[index].z);
+                  //if(flags.texCoords1) glTexCoord2fv((float *)&mesh.texCoords[index]);
+                  if(flags.colors) glColor4fv((float *)&mesh.colors[index]);
+                  glVertex3fv((float *)&mesh.vertices[index]);
+               }
+            }
+            glEnd();
+         }
+         else
+         */
+#endif
+
          {
             OGLIndices oglIndices = primitive->data;
             GLEAB eab = ((!display.display3D.collectingHits && oglIndices) ? oglIndices.buffer : noEAB);
index bb7fd95..fb4005b 100644 (file)
@@ -747,7 +747,7 @@ public:
 #endif
                wait = !ProcessInput(true);
 #if !defined(__EMSCRIPTEN__)
-#ifdef _DEBUG
+#if defined(_DEBUG) && !defined(MEMINFO)
                if(lockMutex.owningThread != GetCurrentThreadID())
                   PrintLn("WARNING: ProcessInput returned unlocked GUI!");
 #endif
index 9df8751..9493ae6 100644 (file)
@@ -50,7 +50,7 @@ class EmscriptenInterface : Interface
 
    bool ::ProcessInput(bool processAll)
    {
-      sflnprintf("class(EmscriptenInterface) ::ProcessInput [STUB!]\n");
+      // sflnprintf("class(EmscriptenInterface) ::ProcessInput [STUB!]\n");
       return false;
    }
 
index 9632796..5fd1a8f 100644 (file)
@@ -1,3 +1,6 @@
+#ifdef MEMINFO
+#undef _DEBUG
+#endif
 
 #if defined(__ANDROID__)
 #include <android/log.h>
index ac93896..056fdd7 100644 (file)
@@ -54,7 +54,7 @@ static WordStatus GetKeyWord(char ** input, char * keyWord, int maxSize)
    return GetKeyWordEx(input, keyWord, maxSize, true);
 }
 
-#define CHARBUFSIZE  65536
+#define CHARBUFSIZE  (65536 * 10)
 
 class XMLParser
 {
index ced0421..c03a7a2 100644 (file)
@@ -32,7 +32,7 @@ public:
 
    void saveWindowInit(const char * configId, Window window)
    {
-      sflnprintf("GuiConfigData::saveWindowInit\n");
+      //sflnprintf("GuiConfigData::saveWindowInit\n");
       applyWindowConfig(configId, window);
       {
          bool isNew = false;
@@ -55,7 +55,7 @@ public:
 
    void saveWindowState(const char * configId, Window window, WindowState state)
    {
-      sflnprintf("GuiConfigData::saveWindowState\n");
+      //sflnprintf("GuiConfigData::saveWindowState\n");
       GuiDataWindow guiData = insertWindowConfig(configId, false, null);
       if(guiData)
       {
@@ -69,7 +69,7 @@ public:
 
    void saveWindowPosition(const char * configId, Window window, Point position, Size size)
    {
-      sflnprintf("GuiConfigData::saveWindowPosition\n");
+      //sflnprintf("GuiConfigData::saveWindowPosition\n");
       GuiDataWindow guiData = insertWindowConfig(configId, false, null);
       if(guiData && window.state == normal)
       {
@@ -85,7 +85,7 @@ public:
 
    void saveWindowSize(const char * configId, Window window, Size size)
    {
-      sflnprintf("GuiConfigData::saveWindowSize\n");
+      //sflnprintf("GuiConfigData::saveWindowSize\n");
       GuiDataWindow guiData = insertWindowConfig(configId, false, null);
       if(guiData && window.state == normal)
       {
@@ -96,7 +96,7 @@ public:
 
    void saveWindowClose(const char * configId)
    {
-      sflnprintf("GuiConfigData::saveWindowClose\n");
+      //sflnprintf("GuiConfigData::saveWindowClose\n");
       GuiDataWindow guiData = getWindowConfig(configId);
       if(guiData)
          guiData.saving = false;
@@ -106,7 +106,7 @@ public:
 
    void savePaneSplitterSize(const char * configId, double scaleSplit)
    {
-      sflnprintf("GuiConfigData::savePaneSplitterSize\n");
+      //sflnprintf("GuiConfigData::savePaneSplitterSize\n");
       GuiDataPaneSplitter guiData = null;
       if(!paneSplitters)
          paneSplitters = { };
@@ -186,14 +186,14 @@ private:
 
    void recordWindowPosition(GuiDataWindow guiData, Window window)
    {
-      sflnprintf("GuiConfigData::recordWindowPosition\n");
+      //sflnprintf("GuiConfigData::recordWindowPosition\n");
       guiData.position = { window.normalAnchor.left.distance, window.normalAnchor.top.distance };
       sflnPrintLn("recordWindowPosition(guiData.position == ", guiData.position, ", created == ", window.created, ")");
    }
 
    void recordWindowSize(GuiDataWindow guiData, Window window)
    {
-      sflnprintf("GuiConfigData::recordWindowSize\n");
+      //sflnprintf("GuiConfigData::recordWindowSize\n");
       //Size s;
       //sflnPrintLn(guiData.size);
       //s = window.normalSizeAnchor.size;
@@ -206,7 +206,7 @@ private:
 
    void applyWindowConfig(const char * configId, Window window)
    {
-      sflnprintf("GuiConfigData::applyWindowConfig\n");
+      //sflnprintf("GuiConfigData::applyWindowConfig\n");
       GuiDataWindow guiData = getWindowConfig(configId);
       if(guiData)
       {
@@ -223,14 +223,14 @@ private:
 
    void applyWindowPosition(Window window, GuiDataWindow guiData)
    {
-      sflnprintf("GuiConfigData::applyWindowPosition\n");
+      //sflnprintf("GuiConfigData::applyWindowPosition\n");
       window.position = guiData.position;
       sflnPrintLn("applyWindowPosition(window.position == ", window.position, ", created == ", window.created, ")");
    }
 
    void applyWindowSize(Window window, GuiDataWindow guiData)
    {
-      sflnprintf("GuiConfigData::applyWindowSize\n");
+      //sflnprintf("GuiConfigData::applyWindowSize\n");
       if(guiData.size.w && guiData.size.h)
       {
          window.size = guiData.size;
@@ -258,7 +258,7 @@ class SavedConfigWindow : Window
 
    bool OnCreate()
    {
-      sflnprintf("SavedConfigWindow::OnCreate\n");
+      //sflnprintf("SavedConfigWindow::OnCreate\n");
       bool result = Window::OnCreate();
       if(result)
       {
@@ -270,7 +270,7 @@ class SavedConfigWindow : Window
 
    bool OnPostCreate()
    {
-      sflnprintf("SavedConfigWindow::OnPostCreate\n");
+      //sflnprintf("SavedConfigWindow::OnPostCreate\n");
       bool result = Window::OnPostCreate();
       if(result)
       {
@@ -291,7 +291,7 @@ class SavedConfigWindow : Window
 
    bool OnStateChange(WindowState state, Modifiers mods)
    {
-      sflnprintf("SavedConfigWindow::OnStateChange\n");
+      //sflnprintf("SavedConfigWindow::OnStateChange\n");
       GuiConfigData data = getGuiConfigData();
       if(data) data.saveWindowState(getGuiConfigInstanceId(), this, state);
       return true;
@@ -299,21 +299,21 @@ class SavedConfigWindow : Window
 
    void OnPosition(int x, int y, int width, int height)
    {
-      sflnprintf("SavedConfigWindow::OnPosition(%i, %i, %i, %i)\n", x, y, width, height);
+      //sflnprintf("SavedConfigWindow::OnPosition(%i, %i, %i, %i)\n", x, y, width, height);
       GuiConfigData data = getGuiConfigData();
       if(data) data.saveWindowPosition(getGuiConfigInstanceId(), this, { x, y }, clientSize);
    }
 
    void OnResize(int width, int height)
    {
-      sflnprintf("SavedConfigWindow::OnResize(%i, %i) -- (%i, %i)\n", width, height, this.normalSizeAnchor.size.w, this.normalSizeAnchor.size.h);
+      //sflnprintf("SavedConfigWindow::OnResize(%i, %i) -- (%i, %i)\n", width, height, this.normalSizeAnchor.size.w, this.normalSizeAnchor.size.h);
       GuiConfigData data = getGuiConfigData();
       if(data) data.saveWindowSize(getGuiConfigInstanceId(), this, clientSize);
    }
 
    bool OnClose(bool parentClosing)
    {
-      sflnprintf("SavedConfigWindow::OnClose\n");
+      //sflnprintf("SavedConfigWindow::OnClose\n");
       GuiConfigData data = getGuiConfigData();
       if(data) data.saveWindowClose(getGuiConfigInstanceId());
       return true;
index 4189386..eab96f4 100644 (file)
@@ -1,5 +1,7 @@
 #ifdef ECERE_STATIC
 public import static "ecere"
+#else
+import "ecere"
 #endif
 
 #include <stdarg.h>
index 9002aa6..f55ca3b 100644 (file)
@@ -76,7 +76,7 @@ public:
    void Attack(Creature opponent)
    {
       Weapon weapon = (Weapon)(equipment ? equipment[EquipmentSlot::rightHand] : null);
-      int d, r, o;
+      int d, o;
       if(!weapon) weapon = bareHand;
       o = GetRandom(0, opponent.dexterity);
       d = GetRandom(0, dexterity - weapon.difficulty);
index 5e79245..4ee88d1 100644 (file)
@@ -7,7 +7,8 @@
       "TargetFileName" : "Lab6",
       "Libraries" : [
          "ecere"
-      ]
+      ],
+      "Console" : true
    },
    "Configurations" : [
       {
@@ -18,7 +19,6 @@
             "PreprocessorDefinitions" : [
                "_DEBUG"
             ],
-            "Console" : true,
             "FastMath" : false
          }
       },
index e50144d..7002d04 100644 (file)
@@ -1,4 +1,4 @@
-import "ecere"
+import IMPORT_STATIC "ecere"
 
 class MyApp : GuiApplication
 {
index 8409ce7..7c180b6 100644 (file)
@@ -16,7 +16,8 @@
             "Debug" : true,
             "Optimization" : "None",
             "PreprocessorDefinitions" : [
-               "_DEBUG"
+               "_DEBUG",
+               "IMPORT_STATIC="
             ],
             "FastMath" : false
          }
          "Options" : {
             "Debug" : false,
             "Optimization" : "Speed",
+            "PreprocessorDefinitions" : [
+               "IMPORT_STATIC="
+            ],
             "FastMath" : true
          }
+      },
+      {
+         "Name" : "Emscripten",
+         "Options" : {
+            "Debug" : true,
+            "PreprocessorDefinitions" : [
+               "IMPORT_STATIC=static"
+            ],
+            "Libraries" : [
+               "ecereStatic",
+               "freetype",
+               "z"
+            ],
+            "LibraryDirs" : [
+               "../../../ecere/obj/emscripten.linux.emscripten.x32"
+            ]
+         }
       }
    ],
    "Files" : [
index 41bc4ee..d3577e9 100644 (file)
@@ -3,27 +3,42 @@
    "ModuleName" : "Hello",
    "Options" : {
       "Warnings" : "All",
-      "TargetType" : "SharedLibrary",
+      "TargetType" : "Executable",
       "TargetFileName" : "Hello",
       "Libraries" : [
-         "ecere",
-         "log",
-         "android",
-         "EGL",
-         "GLESv1_CM"
+         "ecere"
       ],
       "PostbuildCommands" : [
-         "$(call mkdirq,$(OBJ)apk/lib/armeabi)",
+         "$(call mkdirq,$(OBJ)apk/lib/armeabi-v7a)",
          "$(call mkdirq,$(OBJ)apk/lib/x86)",
-         "$(call cpv,../../ecere/obj/android.linux.$(COMPILER)/libecere.so,$(OBJ)apk/lib/armeabi)",
-         "$(call cpv,$(TARGET),$(OBJ)apk/lib/armeabi)",
-         "aapt package -v -f -m -M android/AndroidManifest.xml -F $(OBJ)$(MODULE)-unsigned.apk -I C:/android-sdk/platforms/android-20/android.jar -S android/res $(OBJ)apk",
+         "$(call cpv,../../ecere/obj/android.linux.$(COMPILER)/libecere.so,$(OBJ)apk/lib/armeabi-v7a)",
+         "$(call cpv,$(TARGET),$(OBJ)apk/lib/armeabi-v7a)",
+         "aapt package -v -f -m -M android/AndroidManifest.xml -F $(OBJ)$(MODULE)-unsigned.apk -I C:/android-sdk/platforms/android-21/android.jar -S android/res $(OBJ)apk",
          "jarsigner -storepass android -sigalg MD5withRSA -digestalg SHA1 $(OBJ)$(MODULE)-unsigned.apk -keystore C:/Users/Jerome/debug.keystore androiddebugkey -signedjar $(OBJ)$(MODULE).apk",
          "adb uninstall com.ecere.Hello",
          "adb install $(OBJ)$(MODULE).apk",
          "adb shell am start -a android.intent.action.MAIN -n com.ecere.Hello/android.app.NativeActivity"
       ]
    },
+   "Platforms" : [
+      {
+         "Name" : "linux",
+         "Options" : {
+            "Libraries" : [
+               "log",
+               "android",
+               "EGL",
+               "GLESv1_CM"
+            ]
+         }
+      },
+      {
+         "Name" : "win32",
+         "Options" : {
+            "TargetType" : "Executable"
+         }
+      }
+   ],
    "Configurations" : [
       {
          "Name" : "Debug",
index ef09fd2..34199fa 100644 (file)
             ],
             "FastMath" : false
          }
+      },
+      {
+         "Name" : "Emscripten",
+         "Options" : {
+            "Libraries" : [
+               "ecereCOMStatic"
+            ],
+            "LibraryDirs" : [
+               "../../../ecere/obj/ecereCOM.emscripten.linux.emscripten"
+            ]
+         }
       }
    ],
    "Files" : [
index 8091122..6bcaf65 100644 (file)
@@ -17,7 +17,7 @@ class Form1 : Window
 
    Button button1
    {
-      this, text = "button1", position = { 192, 72 };
+      this, text = $"button1", position = { 192, 72 };
 
       bool NotifyClicked(Button button, int x, int y, Modifiers mods)
       {
index d952df3..d3d0a45 100644 (file)
@@ -44,7 +44,7 @@ class Othello : Window
    OthelloService service { port = OTHELLO_PORT, othello = this };
 
    // Default properties
-   background = black, tabCycle = true, text = "ECERE Othello", borderStyle = sizable, hasClose = true,
+   background = black, tabCycle = true, text = "Ecere Reversi", borderStyle = sizable, hasClose = true,
    size.h = 480, clientSize.w = NUM_COLUMNS*WIDTH;
 
    // --- Othello Utilities ---
index 6b0b9e7..a35ff7d 100644 (file)
                "_DEBUG"
             ],
             "FastMath" : false
-         }
+         },
+         "Platforms" : [
+            {
+               "Name" : "linux",
+               "Options" : {
+                  "Libraries" : [
+                     "m"
+                  ]
+               }
+            }
+         ]
       },
       {
          "Name" : "Release",