From 8b145f477aebdf86e177b8646d18f5e42cdcd3ec Mon Sep 17 00:00:00 2001 From: Jerome St-Louis Date: Mon, 27 Jul 2015 04:59:17 -0400 Subject: [PATCH] Unstaged changes (WIP) --- compiler/libec/src/ecdefs.ec | 3 ++ compiler/libec/src/freeAst.ec | 6 +++- deps/libungif-4.1.1/lib/dgif_lib.c | 2 ++ ecere/src/com/dataTypes.ec | 2 +- ecere/src/gfx/3D/Quaternion.ec | 42 ++++++++++++++++++++++ ecere/src/gfx/drivers/OpenGLDisplayDriver.ec | 36 +++++++++++++++++-- ecere/src/gui/GuiApplication.ec | 2 +- ecere/src/gui/drivers/EmscriptenInterface.ec | 2 +- ecere/src/sys/Mutex.ec | 3 ++ extras/XMLParser.ec | 2 +- extras/gui/GuiConfigData.ec | 34 +++++++++--------- extras/types/DynamicString.ec | 2 ++ .../Lab6/lab6.ec | 2 +- .../Lab6/lab6.epj | 4 +-- samples/3D/hello3D/hello3D.ec | 2 +- samples/3D/hello3D/hello3D.epj | 23 +++++++++++- samples/android/helloAndroid.epj | 35 ++++++++++++------ samples/eC/HelloWorld/HelloWorld.epj | 11 ++++++ samples/eC/staticLink/staticLink.ec | 2 +- samples/games/othello/othello.ec | 2 +- samples/games/stonePairs/stonePairs.epj | 12 ++++++- 21 files changed, 187 insertions(+), 42 deletions(-) diff --git a/compiler/libec/src/ecdefs.ec b/compiler/libec/src/ecdefs.ec index 7a3ea19..7f2917c 100644 --- a/compiler/libec/src/ecdefs.ec +++ b/compiler/libec/src/ecdefs.ec @@ -1154,6 +1154,9 @@ public: } return; } +#ifdef _DEBUG + if(incoming) // TOFIX: Null pointer crash +#endif CreateEdge(from, soft); } diff --git a/compiler/libec/src/freeAst.ec b/compiler/libec/src/freeAst.ec index a9fc0cc..b2076ce 100644 --- a/compiler/libec/src/freeAst.ec +++ b/compiler/libec/src/freeAst.ec @@ -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) { diff --git a/deps/libungif-4.1.1/lib/dgif_lib.c b/deps/libungif-4.1.1/lib/dgif_lib.c index 9540437..20df31b 100644 --- a/deps/libungif-4.1.1/lib/dgif_lib.c +++ b/deps/libungif-4.1.1/lib/dgif_lib.c @@ -74,8 +74,10 @@ GifFileType *DGifOpenFileName(const char *FileName) } GifFile = DGifOpenFileHandle(FileHandle); +#if !defined(__EMSCRIPTEN__) if (GifFile == (GifFileType *)NULL) close(FileHandle); +#endif return GifFile; } diff --git a/ecere/src/com/dataTypes.ec b/ecere/src/com/dataTypes.ec index 04f42aa..8ae72cb 100644 --- a/ecere/src/com/dataTypes.ec +++ b/ecere/src/com/dataTypes.ec @@ -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 diff --git a/ecere/src/gfx/3D/Quaternion.ec b/ecere/src/gfx/3D/Quaternion.ec index 80a2d57..200d84d 100644 --- a/ecere/src/gfx/3D/Quaternion.ec +++ b/ecere/src/gfx/3D/Quaternion.ec @@ -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 ); diff --git a/ecere/src/gfx/drivers/OpenGLDisplayDriver.ec b/ecere/src/gfx/drivers/OpenGLDisplayDriver.ec index 7c79ca4..e4770c5 100644 --- a/ecere/src/gfx/drivers/OpenGLDisplayDriver.ec +++ b/ecere/src/gfx/drivers/OpenGLDisplayDriver.ec @@ -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; cnIndices; 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); diff --git a/ecere/src/gui/GuiApplication.ec b/ecere/src/gui/GuiApplication.ec index bb7fd95..fb4005b 100644 --- a/ecere/src/gui/GuiApplication.ec +++ b/ecere/src/gui/GuiApplication.ec @@ -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 diff --git a/ecere/src/gui/drivers/EmscriptenInterface.ec b/ecere/src/gui/drivers/EmscriptenInterface.ec index 9df8751..9493ae6 100644 --- a/ecere/src/gui/drivers/EmscriptenInterface.ec +++ b/ecere/src/gui/drivers/EmscriptenInterface.ec @@ -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; } diff --git a/ecere/src/sys/Mutex.ec b/ecere/src/sys/Mutex.ec index 9632796..5fd1a8f 100644 --- a/ecere/src/sys/Mutex.ec +++ b/ecere/src/sys/Mutex.ec @@ -1,3 +1,6 @@ +#ifdef MEMINFO +#undef _DEBUG +#endif #if defined(__ANDROID__) #include diff --git a/extras/XMLParser.ec b/extras/XMLParser.ec index ac93896..056fdd7 100644 --- a/extras/XMLParser.ec +++ b/extras/XMLParser.ec @@ -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 { diff --git a/extras/gui/GuiConfigData.ec b/extras/gui/GuiConfigData.ec index ced0421..c03a7a2 100644 --- a/extras/gui/GuiConfigData.ec +++ b/extras/gui/GuiConfigData.ec @@ -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; diff --git a/extras/types/DynamicString.ec b/extras/types/DynamicString.ec index 4189386..eab96f4 100644 --- a/extras/types/DynamicString.ec +++ b/extras/types/DynamicString.ec @@ -1,5 +1,7 @@ #ifdef ECERE_STATIC public import static "ecere" +#else +import "ecere" #endif #include diff --git a/installer/coursework/Chapter 6 - Classes, Methods and Instances/Lab6/lab6.ec b/installer/coursework/Chapter 6 - Classes, Methods and Instances/Lab6/lab6.ec index 9002aa6..f55ca3b 100644 --- a/installer/coursework/Chapter 6 - Classes, Methods and Instances/Lab6/lab6.ec +++ b/installer/coursework/Chapter 6 - Classes, Methods and Instances/Lab6/lab6.ec @@ -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); diff --git a/installer/coursework/Chapter 6 - Classes, Methods and Instances/Lab6/lab6.epj b/installer/coursework/Chapter 6 - Classes, Methods and Instances/Lab6/lab6.epj index 5e79245..4ee88d1 100644 --- a/installer/coursework/Chapter 6 - Classes, Methods and Instances/Lab6/lab6.epj +++ b/installer/coursework/Chapter 6 - Classes, Methods and Instances/Lab6/lab6.epj @@ -7,7 +7,8 @@ "TargetFileName" : "Lab6", "Libraries" : [ "ecere" - ] + ], + "Console" : true }, "Configurations" : [ { @@ -18,7 +19,6 @@ "PreprocessorDefinitions" : [ "_DEBUG" ], - "Console" : true, "FastMath" : false } }, diff --git a/samples/3D/hello3D/hello3D.ec b/samples/3D/hello3D/hello3D.ec index e50144d..7002d04 100644 --- a/samples/3D/hello3D/hello3D.ec +++ b/samples/3D/hello3D/hello3D.ec @@ -1,4 +1,4 @@ -import "ecere" +import IMPORT_STATIC "ecere" class MyApp : GuiApplication { diff --git a/samples/3D/hello3D/hello3D.epj b/samples/3D/hello3D/hello3D.epj index 8409ce7..7c180b6 100644 --- a/samples/3D/hello3D/hello3D.epj +++ b/samples/3D/hello3D/hello3D.epj @@ -16,7 +16,8 @@ "Debug" : true, "Optimization" : "None", "PreprocessorDefinitions" : [ - "_DEBUG" + "_DEBUG", + "IMPORT_STATIC=" ], "FastMath" : false } @@ -26,8 +27,28 @@ "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" : [ diff --git a/samples/android/helloAndroid.epj b/samples/android/helloAndroid.epj index 41bc4ee..d3577e9 100644 --- a/samples/android/helloAndroid.epj +++ b/samples/android/helloAndroid.epj @@ -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", diff --git a/samples/eC/HelloWorld/HelloWorld.epj b/samples/eC/HelloWorld/HelloWorld.epj index ef09fd2..34199fa 100644 --- a/samples/eC/HelloWorld/HelloWorld.epj +++ b/samples/eC/HelloWorld/HelloWorld.epj @@ -25,6 +25,17 @@ ], "FastMath" : false } + }, + { + "Name" : "Emscripten", + "Options" : { + "Libraries" : [ + "ecereCOMStatic" + ], + "LibraryDirs" : [ + "../../../ecere/obj/ecereCOM.emscripten.linux.emscripten" + ] + } } ], "Files" : [ diff --git a/samples/eC/staticLink/staticLink.ec b/samples/eC/staticLink/staticLink.ec index 8091122..6bcaf65 100644 --- a/samples/eC/staticLink/staticLink.ec +++ b/samples/eC/staticLink/staticLink.ec @@ -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) { diff --git a/samples/games/othello/othello.ec b/samples/games/othello/othello.ec index d952df3..d3d0a45 100644 --- a/samples/games/othello/othello.ec +++ b/samples/games/othello/othello.ec @@ -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 --- diff --git a/samples/games/stonePairs/stonePairs.epj b/samples/games/stonePairs/stonePairs.epj index 6b0b9e7..a35ff7d 100644 --- a/samples/games/stonePairs/stonePairs.epj +++ b/samples/games/stonePairs/stonePairs.epj @@ -19,7 +19,17 @@ "_DEBUG" ], "FastMath" : false - } + }, + "Platforms" : [ + { + "Name" : "linux", + "Options" : { + "Libraries" : [ + "m" + ] + } + } + ] }, { "Name" : "Release", -- 1.8.3.1