Explorar o código

Merge branch 'win-port'

Conflicts:
	samples/lua/CMakeLists.txt
	samples/terrain/CMakeLists.txt
	samples/terrain/terrain_main.cpp
	src/CMakeLists.txt
	src/Device.cpp
	src/os/win/Mutex.h
	src/renderers/gles/egl/GLContext.h
Daniele Bartolini %!s(int64=12) %!d(string=hai) anos
pai
achega
4f85a7026d
Modificáronse 53 ficheiros con 1283 adicións e 1155 borrados
  1. 11 1
      CMakeLists.txt
  2. 92 36
      android/jni/Android.mk
  3. 32 33
      android/src/crown/android/CrownActivity.java
  4. 37 9
      android/src/crown/android/CrownLib.java
  5. 13 113
      android/src/crown/android/CrownView.java
  6. 0 42
      game/Game.cpp
  7. 0 11
      samples/json/CMakeLists.txt
  8. 0 36
      samples/json/json.cpp
  9. 0 23
      samples/lua/CMakeLists.txt
  10. 0 12
      samples/lua/lua/lua/game.lua
  11. 5 5
      samples/terrain/CMakeLists.txt
  12. 198 195
      samples/terrain/terrain_main.cpp
  13. 19 29
      src/CMakeLists.txt
  14. 14 1
      src/Device.cpp
  15. 1 1
      src/Game.cpp
  16. 1 3
      src/Game.h
  17. 1 6
      src/lua/AccelerometerBinds.cpp
  18. 7 1
      src/lua/CMakeLists.txt
  19. 42 25
      src/lua/CameraBinds.cpp
  20. 34 4
      src/lua/DeviceBinds.cpp
  21. 7 8
      src/lua/KeyboardBinds.cpp
  22. 3 5
      src/lua/LuaEnvironment.cpp
  23. 9 6
      src/lua/LuaEnvironment.h
  24. 19 1
      src/lua/LuaStack.cpp
  25. 7 1
      src/lua/LuaStack.h
  26. 58 34
      src/lua/Mat4Binds.cpp
  27. 34 22
      src/lua/MathBinds.cpp
  28. 6 11
      src/lua/MouseBinds.cpp
  29. 19 14
      src/lua/QuatBinds.cpp
  30. 38 26
      src/lua/Vec2Binds.cpp
  31. 39 45
      src/lua/Vec3Binds.cpp
  32. 7 9
      src/os/OS.h
  33. 22 12
      src/os/android/AndroidDevice.cpp
  34. 0 81
      src/os/android/AndroidInput.cpp
  35. 53 56
      src/os/android/AndroidOS.cpp
  36. 2 1
      src/os/android/AndroidOS.h
  37. 3 4
      src/os/android/OsFile.cpp
  38. 143 0
      src/os/android/OsWindow.cpp
  39. 72 0
      src/os/android/OsWindow.h
  40. 1 1
      src/os/win/Mutex.h
  41. 5 3
      src/os/win/WinOS.cpp
  42. 55 46
      src/renderers/gles/GLESRenderer.cpp
  43. 2 2
      src/renderers/gles/GLESRenderer.h
  44. 6 30
      src/renderers/gles/GLESUtils.h
  45. 97 0
      src/renderers/gles/egl/GLContext.cpp
  46. 57 0
      src/renderers/gles/egl/GLContext.h
  47. 4 12
      tests/CMakeLists.txt
  48. 8 3
      third/win64/CMakeLists.txt
  49. BIN=BIN
      third/win64/luajit/lib/lua51.dll
  50. BIN=BIN
      third/win64/luajit/lib/lua51.lib
  51. 0 136
      third/win64/luajit/lib/luajit-5.1.def
  52. BIN=BIN
      third/win64/luajit/lib/luajit-5.1.exp
  53. BIN=BIN
      third/win64/luajit/lib/luajit-5.1.lib

+ 11 - 1
CMakeLists.txt

@@ -80,6 +80,16 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
 		${CMAKE_SOURCE_DIR}/src/os/win
 		${CMAKE_SOURCE_DIR}/src/renderers/gl/wgl
 	)
+	
+	list (APPEND CROWN_THIRD_INCLUDES
+		${CROWN_THIRD}/zlib/include
+		${CROWN_THIRD}/luajit/include/luajit-2.0
+	)
+
+	list (APPEND CROWN_THIRD_LIBS
+		${CROWN_THIRD}/zlib/lib
+		${CROWN_THIRD}/luajit/lib
+	)
 endif (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
 
 include_directories(${CROWN_INCLUDES} ${CROWN_THIRD_INCLUDES})
@@ -87,7 +97,7 @@ link_directories(${CROWN_THIRD_LIBS})
 
 # add build directories
 add_subdirectory(src)
-add_subdirectory(${CROWN_THIRD})
+add_subdirectory(${CROWN_THIRD}) #necessary?
 
 if (CROWN_BUILD_TOOLS)
 	add_subdirectory(tools)

+ 92 - 36
android/jni/Android.mk

@@ -21,7 +21,16 @@ LOCAL_SRC_FILES :=\
 	core/bv/Circle.cpp\
 	core/bv/Frustum.cpp\
 	core/bv/Rect.cpp\
+	core/compressors/ZipCompressor.cpp\
 	core/containers/Generic.cpp\
+	core/filesystem/BinaryReader.cpp\
+	core/filesystem/BinaryWriter.cpp\
+	core/filesystem/DiskFile.cpp\
+	core/filesystem/File.cpp\
+	core/filesystem/Filesystem.cpp\
+	core/filesystem/MemoryFile.cpp\
+	core/filesystem/TextReader.cpp\
+	core/filesystem/TextWriter.cpp\
 	core/math/Color4.cpp\
 	core/math/Mat3.cpp\
 	core/math/Mat4.cpp\
@@ -32,77 +41,124 @@ LOCAL_SRC_FILES :=\
 	core/math/Vec2.cpp\
 	core/math/Vec3.cpp\
 	core/math/Vec4.cpp\
-	core/mem/MallocAllocator.cpp\
-	core/streams/FileStream.cpp\
-	core/streams/MemoryStream.cpp\
-	core/streams/Stream.cpp\
+	core/mem/Allocator.cpp\
+	core/mem/HeapAllocator.cpp\
+	core/mem/LinearAllocator.cpp\
+	core/mem/ProxyAllocator.cpp\
+	core/mem/StackAllocator.cpp\
+	core/mem/Memory.cpp\
+	core/settings/FloatSetting.cpp\
+	core/settings/IntSetting.cpp\
+	core/settings/StringSetting.cpp\
+	core/Args.cpp\
+	core/Log.cpp\
 \
+	input/Accelerometer.cpp\
+	input/Keyboard.cpp\
+	input/Mouse.cpp\
+	input/Touch.cpp\
 	input/EventDispatcher.cpp\
 	input/InputManager.cpp\
+\
+	lua/LuaStack.cpp\
+	lua/LuaEnvironment.cpp\
+\
+	network/BitMessage.cpp\
 \
 	os/OS.cpp\
 	os/android/AndroidOS.cpp\
-	os/android/AndroidInput.cpp\
 	os/android/AndroidDevice.cpp\
-	os/android/File.cpp\
+	os/android/OsWindow.cpp\
+	os/android/OsFile.cpp\
 	os/posix/Thread.cpp\
 	os/posix/Mutex.cpp\
 	os/posix/Cond.cpp\
 	os/posix/TCPSocket.cpp\
 	os/posix/UDPSocket.cpp\
 \
-	Filesystem.cpp\
-\
-	renderers/gles/GLESIndexBuffer.cpp\
 	renderers/gles/GLESRenderer.cpp\
 	renderers/gles/GLESUtils.cpp\
-	renderers/gles/GLESVertexBuffer.cpp\
+	renderers/gles/egl/GLContext.cpp\
+	renderers/DebugRenderer.cpp\
+	renderers/PixelFormat.cpp\
+	renderers/VertexFormat.cpp\
 \
+	ArchiveBundle.cpp\
 	Camera.cpp\
 	Device.cpp\
-	Font.cpp\
-	Image.cpp\
-	Log.cpp\
+	FileBundle.cpp\
+	FontResource.cpp\
+	FPSSystem.cpp\
+	JSONParser.cpp\
 	MaterialResource.cpp\
-	MovableCamera.cpp\
-	Pixel.cpp\
+	PixelShaderResource.cpp\
 	ResourceManager.cpp\
-	ResourceLoader.cpp\
-	FileResourceArchive.cpp\
-	ArchiveResourceArchive.cpp\
-	TextureResource.cpp\
 	TextResource.cpp\
-	Skybox.cpp\
-	FPSSystem.cpp\
-\
-	samples/android/triangle.cpp\
+	TextureResource.cpp\
+	VertexShaderResource.cpp\
+	Game.cpp\
 \
 
 LOCAL_C_INCLUDES	:=\
+	$(LOCAL_PATH)/\
 	$(LOCAL_PATH)/core\
-	$(LOCAL_PATH)/core/math\
+	$(LOCAL_PATH)/core/bv\
 	$(LOCAL_PATH)/core/compressors\
 	$(LOCAL_PATH)/core/containers\
-	$(LOCAL_PATH)/core/strings\
-	$(LOCAL_PATH)/core/threads\
-	$(LOCAL_PATH)/core/bv\
+	$(LOCAL_PATH)/core/filesystem\
+	$(LOCAL_PATH)/core/math\
 	$(LOCAL_PATH)/core/mem\
-	$(LOCAL_PATH)/core/streams\
-	$(LOCAL_PATH)/core/threads\
+	$(LOCAL_PATH)/core/filesystem\
 	$(LOCAL_PATH)/core/settings\
-	$(LOCAL_PATH)/loaders\
+	$(LOCAL_PATH)/core/strings\
+	$(LOCAL_PATH)/input\
+	$(LOCAL_PATH)/lua\
+	$(LOCAL_PATH)/network\
 	$(LOCAL_PATH)/os\
 	$(LOCAL_PATH)/os/android\
 	$(LOCAL_PATH)/renderers\
-	$(LOCAL_PATH)/things\
-	$(LOCAL_PATH)/filesystem\
 	$(LOCAL_PATH)/renderers/gles\
 	$(LOCAL_PATH)/renderers/gles/egl\
-	$(LOCAL_PATH)/input\
 	$(LOCAL_PATH)/samples\
-
+#	include third/luajit/include
+\
 
 LOCAL_CPPFLAGS	:= -g -fexceptions
-LOCAL_LDLIBS	:= -llog -landroid -lGLESv1_CM
+LOCAL_LDLIBS	:= -llog -landroid -lEGL -lGLESv2 -lz
+LOCAL_LDLIBS 	+= $(LOCAL_PATH)/libluajit-5.1.so -lluajit-5.1
+LOCAL_SHARED_LIBRARIES := crown luajit-5.1
 include $(BUILD_SHARED_LIBRARY)
-#(call import-module, android/native_app_glue)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE    := crownlua
+
+LOCAL_SRC_FILES :=\
+	lua/LuaStack.cpp\
+	lua/LuaEnvironment.cpp\
+	lua/AccelerometerBinds.cpp\
+	lua/CameraBinds.cpp\
+	lua/DeviceBinds.cpp\
+	lua/KeyboardBinds.cpp\
+	lua/Mat4Binds.cpp\
+	lua/MathBinds.cpp\
+	lua/MouseBinds.cpp\
+	lua/QuatBinds.cpp\
+	lua/TouchBinds.cpp\
+	lua/Vec2Binds.cpp\
+	lua/Vec3Binds.cpp\
+	Game.cpp\
+
+\
+
+LOCAL_C_INCLUDES	:=\
+	$(LOCAL_PATH)\
+	$(LOCAL_PATH)/lua\
+#	include third/luajit/include
+\
+
+LOCAL_CPPFLAGS	:= -g -fexceptions -I
+LOCAL_LDLIBS	:= -llog -landroid
+LOCAL_LDLIBS 	+= $(LOCAL_PATH)/libluajit-5.1.so -lluajit-5.1
+LOCAL_SHARED_LIBRARIES := crown luajit-5.1
+include $(BUILD_SHARED_LIBRARY)

+ 32 - 33
android/src/crown/android/CrownActivity.java

@@ -1,3 +1,28 @@
+/*
+Copyright (c) 2013 Daniele Bartolini, Michele Rossi
+Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+*/
 package crown.android;
 
 import android.app.Activity;
@@ -12,7 +37,8 @@ import android.hardware.SensorManager;
 import android.content.Context;
 import android.widget.Toast;
 import android.content.res.AssetManager;
-import android.view.ScaleGestureDetector;
+import android.view.Surface;
+import android.view.SurfaceView;
 
 import crown.android.CrownEnum;
 
@@ -28,20 +54,18 @@ public class CrownActivity extends Activity
 	// Resource attributes
     static AssetManager 		mAssetManager;
 
-	// Graphic attributes
-	private CrownView 			mView;
-
 	// Input attributes
 	private CrownTouch 			mTouch;
 	private CrownSensor			mSensor;
 
-	// Gestures detectors
-	private ScaleGestureDetector mScaleDetector;
+	// Graphic attributes
+	static SurfaceView			mWindow;
 
 //-----------------------------------------------------------------------------------
     public void onCreate(Bundle savedInstanceState)
     {
         super.onCreate(savedInstanceState);
+		setContentView(R.layout.main);
 
 		// init AssetManager
 		mAssetManager = getAssets();
@@ -55,7 +79,8 @@ public class CrownActivity extends Activity
 		mTouch = new CrownTouch(this);
 		mSensor = new CrownSensor(this);
 		
-	    mScaleDetector = new ScaleGestureDetector(this, new ScaleListener());
+        mWindow = (SurfaceView)findViewById(R.id.crown_window);
+        CrownLib.setWindow(mWindow);
     }
 
 //-----------------------------------------------------------------------------------
@@ -74,7 +99,6 @@ public class CrownActivity extends Activity
 	public void onResume()
 	{
 		super.onResume();
-        mView.onResume();
 		
 		// init accelerometer
 		if (!mSensor.startListening(this))
@@ -87,7 +111,6 @@ public class CrownActivity extends Activity
 	public void onPause()
 	{
 		super.onPause();
-        mView.onPause();
 	}
 
 //-----------------------------------------------------------------------------------
@@ -108,8 +131,6 @@ public class CrownActivity extends Activity
 //-----------------------------------------------------------------------------------
 	public boolean onTouchEvent(MotionEvent event)
 	{
-		mScaleDetector.onTouchEvent(event);
-
 		mTouch.onTouch(event);
         return super.onTouchEvent(event);
 	}
@@ -119,26 +140,4 @@ public class CrownActivity extends Activity
 	{
 		return context.getPackageManager().hasSystemFeature("android.hardware.touchscreen.multitouch");
 	}
-
-
-//-----------------------------------------------------------------------------------
-	private class ScaleListener extends ScaleGestureDetector.SimpleOnScaleGestureListener
-	{
-	    public boolean onScale(ScaleGestureDetector detector) 
-	    {
-	    	Log.i(TAG, "onScale.");
-	    	return true;
-	    }
-
-	    public boolean onScaleBegin(ScaleGestureDetector detector) 
-	    {
-	    	Log.i(TAG, "onScaleBegin.");
-	    	return true;
-	    }
-
-	    public void onScaleEnd(ScaleGestureDetector detector) 
-	    {
-	    	Log.i(TAG, "onScaleBegin.");
-	    }
-	};
 }

+ 37 - 9
android/src/crown/android/CrownLib.java

@@ -1,6 +1,32 @@
+/*
+Copyright (c) 2013 Daniele Bartolini, Michele Rossi
+Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+*/
 package crown.android;
 
 import android.content.res.AssetManager;
+import android.view.Surface;
 
 public class CrownLib
 {
@@ -10,18 +36,20 @@ public class CrownLib
 	}
 	
 	// Device functions
-	public static native void init();
-	public static native void frame();
-	public static native void shutdown();
+	public static native void 		init();
+	public static native void 		frame();
+	public static native void 		shutdown();
+	public static native boolean 	isInit();
+	public static native boolean	isRunning();
 
 	// AssetManager functions
-	public static native void initAssetManager(AssetManager assetManager);
+	public static native void 		initAssetManager(AssetManager assetManager);
 
 	// InputManager functions
-	public static native void pushIntEvent(int type, int a, int b, int c, int d);
-	public static native void pushFloatEvent(int type, float a, float b, float c, float d);
-
-	// RenderWindow functions
-	public static native void setRenderWindowMetrics(int width, int height);
+	public static native void 		pushIntEvent(int type, int a, int b, int c, int d);
+	public static native void 		pushFloatEvent(int type, float a, float b, float c, float d);
 
+	// Window functions
+	public static native void		setWindow(Surface window);
+	public static native void 		setDisplaySize(int width, int height);
 }

+ 13 - 113
android/src/crown/android/CrownView.java

@@ -11,7 +11,7 @@ import javax.microedition.khronos.egl.EGL10;
 import javax.microedition.khronos.egl.EGLConfig;
 import javax.microedition.khronos.egl.EGLContext;
 import javax.microedition.khronos.egl.EGLDisplay;
-import javax.microedition.khronos.opengles.GL10;
+import javax.microedition.khronos.opengles.GL20;
 
 
 /**
@@ -135,10 +135,8 @@ class CrownView extends GLSurfaceView
             mStencilSize = stencil;
         }
 
-		// Choose OpenGL|ES 1 bit
-        private static int EGL_OPENGL_ES_BIT = 1;
 		// Choose OpenGl|ES 2 bit
-//        private static int EGL_OPENGL_ES_BIT = 4;
+        private static int EGL_OPENGL_ES_BIT = 4;
         private static int[] s_configAttribs2 =
         {
             EGL10.EGL_RED_SIZE, 4,
@@ -150,7 +148,6 @@ class CrownView extends GLSurfaceView
 
         public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) 
 		{
-			Log.i(TAG, "JAVA CHOOSE CONFIG CALLED.");
             /* Get the number of minimally matching EGL configurations
              */
             int[] num_config = new int[1];
@@ -168,10 +165,7 @@ class CrownView extends GLSurfaceView
             EGLConfig[] configs = new EGLConfig[numConfigs];
             egl.eglChooseConfig(display, s_configAttribs2, configs, numConfigs, num_config);
 
-            if (DEBUG) 
-			{
-                 printConfigs(egl, display, configs);
-            }
+
             /* Now return the "best" one
              */
             return chooseConfig(egl, display, configs);
@@ -217,107 +211,6 @@ class CrownView extends GLSurfaceView
             return defaultValue;
         }
 
-        private void printConfigs(EGL10 egl, EGLDisplay display, EGLConfig[] configs) 
-		{
-//            int numConfigs = configs.length;
-//            Log.w(TAG, String.format("%d configurations", numConfigs));
-//            for (int i = 0; i < numConfigs; i++) 
-//			{
-//                Log.w(TAG, String.format("Configuration %d:\n", i));
-//                printConfig(egl, display, configs[i]);
-//            }
-        }
-
-        private void printConfig(EGL10 egl, EGLDisplay display, EGLConfig config) 
-		{
-//            int[] attributes = {
-//				                    EGL10.EGL_BUFFER_SIZE,
-//            				        EGL10.EGL_ALPHA_SIZE,
-//                    				EGL10.EGL_BLUE_SIZE,
-//                   					EGL10.EGL_GREEN_SIZE,
-//                    				EGL10.EGL_RED_SIZE,
-//                    				EGL10.EGL_DEPTH_SIZE,
-//                   	 				EGL10.EGL_STENCIL_SIZE,
-//                    				EGL10.EGL_CONFIG_CAVEAT,
-//                    				EGL10.EGL_CONFIG_ID,
-//                    				EGL10.EGL_LEVEL,
-//                    				EGL10.EGL_MAX_PBUFFER_HEIGHT,
-//                    				EGL10.EGL_MAX_PBUFFER_PIXELS,
-//                    				EGL10.EGL_MAX_PBUFFER_WIDTH,
-//                    				EGL10.EGL_NATIVE_RENDERABLE,
-//								    EGL10.EGL_NATIVE_VISUAL_ID,
-//								    EGL10.EGL_NATIVE_VISUAL_TYPE,
-//								    0x3030, // EGL10.EGL_PRESERVED_RESOURCES,
-//								    EGL10.EGL_SAMPLES,
-//								    EGL10.EGL_SAMPLE_BUFFERS,
-//								    EGL10.EGL_SURFACE_TYPE,
-//								    EGL10.EGL_TRANSPARENT_TYPE,
-//								    EGL10.EGL_TRANSPARENT_RED_VALUE,
-//								    EGL10.EGL_TRANSPARENT_GREEN_VALUE,
-//								    EGL10.EGL_TRANSPARENT_BLUE_VALUE,
-//								    0x3039, // EGL10.EGL_BIND_TO_TEXTURE_RGB,
-//								    0x303A, // EGL10.EGL_BIND_TO_TEXTURE_RGBA,
-//								    0x303B, // EGL10.EGL_MIN_SWAP_INTERVAL,
-//								    0x303C, // EGL10.EGL_MAX_SWAP_INTERVAL,
-//								    EGL10.EGL_LUMINANCE_SIZE,
-//								    EGL10.EGL_ALPHA_MASK_SIZE,
-//								    EGL10.EGL_COLOR_BUFFER_TYPE,
-//								    EGL10.EGL_RENDERABLE_TYPE,
-//								    0x3042 // EGL10.EGL_CONFORMANT
-//            };
-//            String[] names = {
-//								    "EGL_BUFFER_SIZE",
-//								    "EGL_ALPHA_SIZE",
-//								    "EGL_BLUE_SIZE",
-//								    "EGL_GREEN_SIZE",
-//								    "EGL_RED_SIZE",
-//								    "EGL_DEPTH_SIZE",
-//								    "EGL_STENCIL_SIZE",
-//								    "EGL_CONFIG_CAVEAT",
-//								    "EGL_CONFIG_ID",
-//								    "EGL_LEVEL",
-//								    "EGL_MAX_PBUFFER_HEIGHT",
-//								    "EGL_MAX_PBUFFER_PIXELS",
-//								    "EGL_MAX_PBUFFER_WIDTH",
-//								    "EGL_NATIVE_RENDERABLE",
-//								    "EGL_NATIVE_VISUAL_ID",
-//								    "EGL_NATIVE_VISUAL_TYPE",
-//								    "EGL_PRESERVED_RESOURCES",
-//								    "EGL_SAMPLES",
-//								    "EGL_SAMPLE_BUFFERS",
-//								    "EGL_SURFACE_TYPE",
-//								    "EGL_TRANSPARENT_TYPE",
-//								    "EGL_TRANSPARENT_RED_VALUE",
-//								    "EGL_TRANSPARENT_GREEN_VALUE",
-//								    "EGL_TRANSPARENT_BLUE_VALUE",
-//								    "EGL_BIND_TO_TEXTURE_RGB",
-//								    "EGL_BIND_TO_TEXTURE_RGBA",
-//								    "EGL_MIN_SWAP_INTERVAL",
-//								    "EGL_MAX_SWAP_INTERVAL",
-//								    "EGL_LUMINANCE_SIZE",
-//								    "EGL_ALPHA_MASK_SIZE",
-//								    "EGL_COLOR_BUFFER_TYPE",
-//								    "EGL_RENDERABLE_TYPE",
-//								    "EGL_CONFORMANT"
-//            };
-
-//            int[] value = new int[1];
-//            for (int i = 0; i < attributes.length; i++) 
-//			{
-//                int attribute = attributes[i];
-//                String name = names[i];
-//                if ( egl.eglGetConfigAttrib(display, config, attribute, value))
-//				{
-//                    Log.w(TAG, String.format("  %s: %d\n", name, value[0]));
-//                } 
-//				else 
-//				{
-//                    // Log.w(TAG, String.format("  %s: failed\n", name));
-//                    while (egl.eglGetError() != EGL10.EGL_SUCCESS);
-//                }
-//            }
-        }
-
         // Subclasses can adjust these values:
         protected int mRedSize;
         protected int mGreenSize;
@@ -335,13 +228,20 @@ class CrownView extends GLSurfaceView
 	{
         public void onDrawFrame(GL10 gl)
 		{
-			CrownLib.frame();
+            if (CrownLib.isRunning())
+			{
+                CrownLib.frame();
+            }
         }
 
         public void onSurfaceChanged(GL10 gl, int width, int height)
 		{
-			CrownLib.init();
-            CrownLib.setRenderWindowMetrics(width, height);
+            if (!CrownLib.isInit())
+            {
+		        CrownLib.init();
+            }
+
+            CrownLib.setDisplaySize(width, height);
         }
 
         public void onSurfaceCreated(GL10 gl, EGLConfig config)

+ 0 - 42
game/Game.cpp

@@ -1,42 +0,0 @@
-#include "lua.hpp"
-#include "Device.h"
-/*
-#include "Game.h"
-
-namespace crown
-{
-
-lua_State* state;
-
-void init()
-{
-	state = luaL_newstate();
-	luaL_openlibs(state);
-
-	luaL_loadfile(state, "lua/lua/game.lua.script");
-
-	lua_getglobal(state, "init");
-
-	lua_pcall(state, 0, 0, 0);
-}
-
-void shutdown()
-{
-	lua_getglobal(state, "shutdown");
-
-	lua_pcall(state, 0, 0, 0);
-
-	lua_close(state);
-}
-
-void frame(float dt)
-{
-	lua_getglobal(state, "frame");
-
-	lua_pushnumber(state, dt);
-
-	lua_pcall(state, 1, 0, 0);
-}
-
-}
-*/

+ 0 - 11
samples/json/CMakeLists.txt

@@ -1,11 +0,0 @@
-cmake_minimum_required(VERSION 2.8)
-
-set (SRC
-	json.cpp
-)
-
-set (HEADERS
-)
-
-add_executable (json ${SRC} ${HEADERS})
-target_link_libraries(json crown)

+ 0 - 36
samples/json/json.cpp

@@ -1,36 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-#include "JSONParser.h"
-#include "Filesystem.h"
-#include "DiskFile.h"
-
-using namespace crown;
-
-// REMOVE JSON SAMPLE, ADD UNIT TEST
-int main(int argc, char** argv)
-{
-	// if (argc != 2)
-	// {
-	// 	printf("Configuration root path must be provided. Aborting!");
-	// 	return -1;
-	// }
-
-	// Filesystem conf_root(argv[1]);
-
-	// if (!conf_root.exists("json.json"))
-	// {
-	// 	printf("Configuration file does not exists. Aborting!\n");
-	// 	return -1;
-	// }
-	
-	// char dst[10][256];
-
-	// DiskFile* stream = (DiskFile*)conf_root.open("json.json", FOM_READ);
-
- // 	JSONParser* parser = new JSONParser(stream);
-
-
-	// conf_root.close(stream);
-
-	return 0;
-}

+ 0 - 23
samples/lua/CMakeLists.txt

@@ -1,23 +0,0 @@
-cmake_minimum_required(VERSION 2.8)
-
-set (SRC
-	lua.cpp
-)
-
-<<<<<<< HEAD
-#add_definitions(-Wl,-E)
-#add_library (game SHARED ${SRC})
-#target_link_libraries(game crown)
-
-
-#install (TARGETS game DESTINATION bin/lua_sample)
-=======
-add_definitions(-Wl,-E)
-add_library (game-lua SHARED ${SRC})
-target_link_libraries(game-lua crown crownlua)
-
-set_target_properties (game-lua PROPERTIES OUTPUT_NAME game)
->>>>>>> master
-
-install (DIRECTORY lua DESTINATION samples)
-install (TARGETS game-lua DESTINATION samples/lua)

+ 0 - 12
samples/lua/lua/lua/game.lua

@@ -1,12 +0,0 @@
-function init()
-	print("Hello from lua!!!")
-end
-
-function shutdown()
-end
-
-function frame(dt)
-	if Keyboard.key_pressed(65) then
-		Device.stop()
-	end
-end

+ 5 - 5
samples/terrain/CMakeLists.txt

@@ -1,18 +1,18 @@
 cmake_minimum_required(VERSION 2.8)
 
 set (SRC
-	terrain_main.cpp
 	Terrain.cpp
+	terrain_main.cpp
 )
 
 set (HEADERS
 	Terrain.h
+	../../game/Game.h
 )
 
-add_library (terrain STATIC ${SRC} ${HEADERS})
-add_executable (game-terrain ${CROWN_MAIN_SRC})
-target_link_libraries (terrain crown)
-target_link_libraries (game-terrain terrain)
+add_library (game-terrain SHARED ${SRC} ${HEADERS})
+target_link_libraries(game-terrain crown)
+
 set_target_properties (game-terrain PROPERTIES OUTPUT_NAME game)
 
 install (DIRECTORY terrain DESTINATION samples)

+ 198 - 195
samples/terrain/terrain_main.cpp

@@ -9,18 +9,18 @@ class WndCtrl: public KeyboardListener
 {
 public:
 
-	WndCtrl()
-	{
-		device()->input_manager()->register_keyboard_listener(this);
-	}
-
-	void key_released(const KeyboardEvent& event)
-	{
-		if (event.key == KC_ESCAPE)
-		{
-			device()->stop();
-		}
-	}
+	//WndCtrl()
+	//{
+	//	device()->input_manager()->register_keyboard_listener(this);
+	//}
+
+	//void key_released(const KeyboardEvent& event)
+	//{
+	//	if (event.key == KC_ESCAPE)
+	//	{
+	//		device()->stop();
+	//	}
+	//}
 };
 
 class MainScene
@@ -28,203 +28,206 @@ class MainScene
 
 public:
 
-	MainScene() :
-		optShowSkybox(true),
-		optShowCrate(true),
-		optShowTerrain(true),
-		camera_active(true)
-	{
-		mouseRightPressed = false;
-		mouseLeftPressed = false;
-	}
-
-	~MainScene()
-	{
-	}
-
-	void poll_input()
-	{
-		Keyboard* keyb = device()->keyboard();
-		Mouse* mouse = device()->mouse();
-
-		if (keyb->key_pressed(KC_1))
-		{
-			terrain.PlotCircle(2, 2, 2, 2);
-		}
-
-		if (keyb->key_pressed(KC_2))
-		{
-			terrain.PlotCircle(4, 4, 4, 2);
-		}
-
-		if (keyb->key_pressed(KC_3))
-		{		
-			terrain.PlotCircle(8, 8, 8, 2);
-		}
-
-		if (keyb->key_pressed(KC_F5))
-		{
-			device()->reload(grass);
-		}
-
-		if (keyb->key_pressed(KC_SPACE))
-		{
-			camera_active = !camera_active;
-		}
-
-		mouseLeftPressed = mouse->button_pressed(MB_LEFT);
-		mouseRightPressed = mouse->button_pressed(MB_RIGHT);
-	}
-		
-	void on_load()
-	{
-		crown::Renderer* renderer = crown::device()->renderer();
-		
-		Vec3 start = Vec3(0.0f, 10.0f, 0.0f);
-
-		// Add a movable camera
-		cam = CE_NEW(m_allocator, Camera)(start, 90.0f, 1.6f);
-		system = CE_NEW(m_allocator, FPSSystem)(cam, 10.0f, 2.5f);
-
-		terrain.CreateTerrain(64, 64, 1, 0.0f);
-		terrain.PlotCircle(4, 4, 4, 2);
-		terrain.UpdateVertexBuffer(true);
-
-		// red_north = device()->load("textures/red_north.tga");
-		// red_south = device()->load("textures/red_south.tga");
-		// red_east  = device()->load("textures/red_east.tga");
-		// red_west  = device()->load("textures/red_west.tga");
-		// red_up    = device()->load("textures/red_up.tga");
-		// red_down  = device()->load("textures/red_down.tga");
-		grass     	 = device()->load("textures/grass.tga");
-
-		device()->resource_manager()->flush();
-
-		TextureResource* grass_texture = (TextureResource*)device()->data(grass);
-		grass_id = device()->renderer()->create_texture(grass_texture->width(), grass_texture->height(), grass_texture->format(), grass_texture->data());
-	}
-
-	void on_unload()
-	{
-		device()->unload(grass);
-
-		device()->unload(red_north);
-		device()->unload(red_south);
-		device()->unload(red_east);
-		device()->unload(red_west);
-		device()->unload(red_up);
-		device()->unload(red_down);
-
-		CE_DELETE(m_allocator, system);
-		CE_DELETE(m_allocator, cam);
-	}
-
-	void update(float dt)
+	//MainScene() :
+	//	optShowSkybox(true),
+	//	optShowCrate(true),
+	//	optShowTerrain(true),
+	//	camera_active(true)
+	//{
+	//	mouseRightPressed = false;
+	//	mouseLeftPressed = false;
+	//}
+
+	//~MainScene()
+	//{
+	//}
+
+	//void poll_input()
+	//{
+	//	Keyboard* keyb = device()->keyboard();
+	//	Mouse* mouse = device()->mouse();
+
+	//	if (keyb->key_pressed(KC_1))
+	//	{
+	//		terrain.PlotCircle(2, 2, 2, 2);
+	//	}
+
+	//	if (keyb->key_pressed(KC_2))
+	//	{
+	//		terrain.PlotCircle(4, 4, 4, 2);
+	//	}
+
+	//	if (keyb->key_pressed(KC_3))
+	//	{		
+	//		terrain.PlotCircle(8, 8, 8, 2);
+	//	}
+
+	//	if (keyb->key_pressed(KC_F5))
+	//	{
+	//		device()->reload(grass);
+	//	}
+
+	//	if (keyb->key_pressed(KC_SPACE))
+	//	{
+	//		camera_active = !camera_active;
+	//	}
+
+	//	mouseLeftPressed = mouse->button_pressed(MB_LEFT);
+	//	mouseRightPressed = mouse->button_pressed(MB_RIGHT);
+	//}
+	//	
+	//void on_load()
+	//{
+	//	crown::Renderer* renderer = crown::device()->renderer();
+	//	
+	//	Vec3 start = Vec3(0.0f, 10.0f, 0.0f);
+
+	//	// Add a movable camera
+	//	cam = CE_NEW(m_allocator, Camera)(start, 90.0f, 1.6f);
+	//	system = CE_NEW(m_allocator, FPSSystem)(cam, 10.0f, 2.5f);
+
+	//	terrain.CreateTerrain(64, 64, 1, 0.0f);
+	//	terrain.PlotCircle(4, 4, 4, 2);
+	//	terrain.UpdateVertexBuffer(true);
+
+	//	// red_north = device()->load("textures/red_north.tga");
+	//	// red_south = device()->load("textures/red_south.tga");
+	//	// red_east  = device()->load("textures/red_east.tga");
+	//	// red_west  = device()->load("textures/red_west.tga");
+	//	// red_up    = device()->load("textures/red_up.tga");
+	//	// red_down  = device()->load("textures/red_down.tga");
+	//	grass     	 = device()->load("textures/grass.tga");
+
+	//	device()->resource_manager()->flush();
+
+	//	TextureResource* grass_texture = (TextureResource*)device()->data(grass);
+	//	grass_id = device()->renderer()->create_texture(grass_texture->width(), grass_texture->height(), grass_texture->format(), grass_texture->data());
+	//}
+
+	//void on_unload()
+	//{
+	//	device()->unload(grass);
+
+	//	device()->unload(red_north);
+	//	device()->unload(red_south);
+	//	device()->unload(red_east);
+	//	device()->unload(red_west);
+	//	device()->unload(red_up);
+	//	device()->unload(red_down);
+
+	//	CE_DELETE(m_allocator, system);
+	//	CE_DELETE(m_allocator, cam);
+	//}
+
+	//void update(float dt)
+	//{
+	//	poll_input();
+
+	//	Renderer* renderer = device()->renderer();
+
+	//	renderer->set_clear_color(Color4::LIGHTBLUE);
+	//	
+	//	if (camera_active)
+	//	{
+	//		system->set_view_by_cursor();
+	//	}
+	//	system->update(dt);
+
+	//	renderer->set_texturing(0, false);
+
+	//	ray.set_origin(cam->position());
+	//	ray.set_direction(cam->look_at());
+
+	//	/* Render the terrain */
+	//	renderer->set_ambient_light(Color4(0.5f, 0.5f, 0.5f, 1.0f));
+
+	//	renderer->set_matrix(MT_MODEL, Mat4::IDENTITY);
+
+	//	if (device()->is_loaded(grass))
+	//	{
+	//		renderer->set_texturing(0, true);
+	//		renderer->bind_texture(0, grass_id);
+	//	}
+
+	//	terrain.Render();
+
+	//	/* Test for intersection */
+	//	Triangle tri, tri2;
+	//	float dist;
+	//	if (terrain.TraceRay(ray, tri, tri2, dist))
+	//	{
+	//		renderer->set_depth_test(false);
+	//		Vec3 intersectionPoint = ray.origin() + (ray.direction() * dist);
+	//		if (mouseLeftPressed)
+	//		{
+	//			terrain.ApplyBrush(intersectionPoint, 0.09f);
+	//			terrain.UpdateVertexBuffer(true);
+	//		}
+	//		if (mouseRightPressed)
+	//		{
+	//			terrain.ApplyBrush(intersectionPoint, -0.09f);
+	//			terrain.UpdateVertexBuffer(true);
+	//		}
+	//		renderer->set_depth_test(true);
+	//	}
+	//}
+
+//private:
+
+	//HeapAllocator m_allocator;
+	//FPSSystem* system;
+	//Camera* cam;
+	//Mat4 ortho;
+	//Terrain terrain;
+
+	//// Resources
+	//ResourceId grass;
+	//ResourceId red_north;
+	//ResourceId red_south;
+	//ResourceId red_east;
+	//ResourceId red_west;
+	//ResourceId red_up;
+	//ResourceId red_down;
+	//TextureId grass_id;
+	//RenderBufferId rb_id;
+	//VertexShaderId vs_id;
+	//PixelShaderId ps_id;
+	//GPUProgramId gpu_program_id;
+
+	//ResourceId script;
+
+	//bool optShowSkybox;
+	//bool optShowCrate;
+	//bool optShowTerrain;
+	//bool mouseLeftPressed;
+	//bool mouseRightPressed;
+	//float wheel;
+	//bool camera_active;
+	//Ray ray;
+public:
+	inline void dumb_func()
 	{
-		poll_input();
-
-		Renderer* renderer = device()->renderer();
-
-		renderer->set_clear_color(Color4::LIGHTBLUE);
-		
-		if (camera_active)
-		{
-			system->set_view_by_cursor();
-		}
-		system->update(dt);
-
-		renderer->set_texturing(0, false);
-
-		ray.set_origin(cam->position());
-		ray.set_direction(cam->look_at());
-
-		/* Render the terrain */
-		renderer->set_ambient_light(Color4(0.5f, 0.5f, 0.5f, 1.0f));
-
-		renderer->set_matrix(MT_MODEL, Mat4::IDENTITY);
-
-		if (device()->is_loaded(grass))
-		{
-			renderer->set_texturing(0, true);
-			renderer->bind_texture(0, grass_id);
-		}
-
-		terrain.Render();
-
-		/* Test for intersection */
-		Triangle tri, tri2;
-		float dist;
-		if (terrain.TraceRay(ray, tri, tri2, dist))
+		if (device()->is_init())
 		{
-			renderer->set_depth_test(false);
-			Vec3 intersectionPoint = ray.origin() + (ray.direction() * dist);
-			if (mouseLeftPressed)
-			{
-				terrain.ApplyBrush(intersectionPoint, 0.09f);
-				terrain.UpdateVertexBuffer(true);
-			}
-			if (mouseRightPressed)
-			{
-				terrain.ApplyBrush(intersectionPoint, -0.09f);
-				terrain.UpdateVertexBuffer(true);
-			}
-			renderer->set_depth_test(true);
+			os::printf("SEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE\n");
 		}
 	}
-
-private:
-
-	HeapAllocator m_allocator;
-	FPSSystem* system;
-	Camera* cam;
-	Mat4 ortho;
-	Terrain terrain;
-
-	// Resources
-	ResourceId grass;
-	ResourceId red_north;
-	ResourceId red_south;
-	ResourceId red_east;
-	ResourceId red_west;
-	ResourceId red_up;
-	ResourceId red_down;
-	TextureId grass_id;
-	RenderBufferId rb_id;
-	VertexShaderId vs_id;
-	PixelShaderId ps_id;
-	GPUProgramId gpu_program_id;
-
-	ResourceId script;
-
-	bool optShowSkybox;
-	bool optShowCrate;
-	bool optShowTerrain;
-	bool mouseLeftPressed;
-	bool mouseRightPressed;
-	float wheel;
-	bool camera_active;
-	Ray ray;
 };
 
 MainScene m_scene;
-WndCtrl m_ctrl;
-
-namespace crown
-{
+//WndCtrl m_ctrl;
 
 void init()
 {
-	m_scene.on_load();
+	//m_scene.on_load();
+	m_scene.dumb_func();
 }
-
-void shutdown()
+void shutdown_1()
 {
-	m_scene.on_unload();
+	//m_scene.on_unload();
 }
 
 void frame(float dt)
 {
-	m_scene.update(dt);
+	//m_scene.update(dt);
 }
-
-}

+ 19 - 29
src/CMakeLists.txt

@@ -12,8 +12,10 @@ set (SRC
 	ArchiveBundle.cpp
 	FileBundle.cpp
 
-	FPSSystem.cpp
+	Game.cpp
 	JSONParser.cpp
+
+	FPSSystem.cpp
 )
 
 set (HEADERS
@@ -35,9 +37,9 @@ set (HEADERS
 	ArchiveBundle.h
 	FileBundle.h
 
-	FPSSystem.h
+	Game.h
 	JSONParser.h
-	../game/Game.h
+	FPSSystem.h
 )
 
 set (CORE_SRC
@@ -149,7 +151,6 @@ set (STRINGS_HEADERS
 )
 
 set (MEM_SRC
-	#core/mem/malloc.c
 	core/mem/Memory.cpp
 	core/mem/Allocator.cpp
 	core/mem/HeapAllocator.cpp
@@ -159,7 +160,6 @@ set (MEM_SRC
 )
 
 set (MEM_HEADERS
-	#core/mem/malloc.h
 	core/mem/Memory.h
 	core/mem/Allocator.h
 	core/mem/HeapAllocator.h
@@ -242,9 +242,7 @@ set (OS_HEADERS
 )
 
 # Platform independent libraries
-set (CROWN_LIBRARIES
-	luajit-5.1
-)
+set (CROWN_LIBRARIES)
 
 set (COMPILER_FLAGS
 	-pipe
@@ -304,6 +302,7 @@ if (LINUX)
 		dl
 		GLEW
 		GL
+		luajit-5.1
 	)
 endif (LINUX)
 
@@ -341,17 +340,13 @@ if (WINDOWS)
 		zlib
 		OpenGL32
 		glew32
+		lua51
 	)
 
-	list (APPEND CROWN_THIRD_INCLUDES
-		${CROWN_THIRD}/zlib/include
-	)
-
-	list (APPEND CROWN_THIRD_LIBS
-		${CROWN_THIRD}/zlib/lib
-	)
-
-	set(COMPILER_FLAGS)
+	set (COMPILER_FLAGS /link /OPT:NOREF)
+	
+	set (CROWN_EXECUTABLE_NAME crown-win)
+	set (CROWN_MAIN_SRC os/win/main.cpp)
 endif(WINDOWS)
 
 set (CROWN_SOURCES
@@ -397,28 +392,23 @@ set (CROWN_HEADERS
 
 configure_file (${CMAKE_CURRENT_SOURCE_DIR}/Config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/Config.h)
 
-# Lua bindings and systems
-add_subdirectory(lua)
-
 include_directories(${CROWN_INCLUDES} ${CROWN_THIRD_INCLUDES})
 link_directories(${CROWN_THIRD_LIBS})
-
 link_libraries(${CROWN_LIBRARIES})
 
-add_definitions(${CROWN_COMPILER_FLAGS})
+# Lua bindings and systems
+add_subdirectory(lua)
 
-if (WINDOWS)
-add_definitions(/link /OPT:NOREF)
-add_definitions(/LIBPATH:${CROWN_THIRD}/luajit/lib)
-endif (WINDOWS)
+add_definitions(${CROWN_COMPILER_FLAGS})
 
 add_library(crown STATIC ${CROWN_SOURCES} ${CROWN_HEADERS})
 
+add_executable(${CROWN_EXECUTABLE_NAME} ${CROWN_MAIN_SRC})
+target_link_libraries(${CROWN_EXECUTABLE_NAME} crown crownlua)
+
 install (TARGETS crown DESTINATION lib/${CMAKE_PROJECT_NAME})
+install (TARGETS ${CROWN_EXECUTABLE_NAME} DESTINATION bin)
 
-#------------------------------------------------------------------------------
-#Installing headers
-#------------------------------------------------------------------------------
 install (FILES ${HEADERS} DESTINATION include/${CMAKE_PROJECT_NAME})
 
 install (FILES ${CORE_HEADERS} DESTINATION include/${CMAKE_PROJECT_NAME}/core)

+ 14 - 1
src/Device.cpp

@@ -37,7 +37,6 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include "Types.h"
 #include "StringUtils.h"
 #include "Args.h"
-#include "Game.h"
 #include "ArchiveBundle.h"
 #include "FileBundle.h"
 #include "ResourceManager.h"
@@ -50,6 +49,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include "JSONParser.h"
 #include "DiskFile.h"
 #include "Memory.h"
+#include "Game.h"
 
 namespace crown
 {
@@ -126,6 +126,13 @@ bool Device::init(int argc, char** argv)
 
 	Log::i("Initializing Game...");
 
+	// Initialize the game through init game function
+	crown::init();
+
+	m_is_init = true;
+
+	start();
+
 	if (m_quit_after_init == 1)
 	{
 		shutdown();
@@ -143,6 +150,9 @@ void Device::shutdown()
 		return;
 	}
 
+	// Shutdowns the game
+	crown::shutdown();
+	
 	if (m_input_manager)
 	{
 		CE_DELETE(m_allocator, m_input_manager);
@@ -313,6 +323,8 @@ void Device::frame()
 	m_window->frame();
 	m_input_manager->frame();
 
+	crown::frame(last_delta_time());
+
 	m_debug_renderer->draw_all();
 	m_renderer->frame();
 
@@ -429,6 +441,7 @@ void Device::parse_command_line(int argc, char** argv)
 		"width",            AOA_REQUIRED_ARGUMENT, NULL,        'w',
 		"height",           AOA_REQUIRED_ARGUMENT, NULL,        'h',
 		"fullscreen",       AOA_NO_ARGUMENT,       &m_preferred_window_fullscreen, 1,
+		"dev",              AOA_NO_ARGUMENT,       &m_preferred_mode, MODE_DEVELOPMENT,
 		"quit-after-init",  AOA_NO_ARGUMENT,       &m_quit_after_init, 1,
 		NULL, 0, NULL, 0
 	};

+ 1 - 1
samples/lua/lua.cpp → src/Game.cpp

@@ -1,6 +1,6 @@
 #include "Crown.h"
 #include "Game.h"
-
+#include "lua.hpp"
 
 namespace crown
 {

+ 1 - 3
game/Game.h → src/Game.h

@@ -45,6 +45,4 @@ void shutdown();
 /// in seconds. 
 void frame(float dt);
 
-
-} // namespace crown
-
+}

+ 1 - 6
src/lua/AccelerometerBinds.cpp

@@ -6,11 +6,8 @@
 namespace crown
 {
 
-extern "C"
-{
-
 //-----------------------------------------------------------------------------
-int32_t accelerometer_orientation(lua_State* L)
+CE_EXPORT int32_t accelerometer_orientation(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -22,8 +19,6 @@ int32_t accelerometer_orientation(lua_State* L)
 	return 1;
 }
 
-} // extern "C"
-
 //-----------------------------------------------------------------------------
 void load_accelerometer(LuaEnvironment& env)
 {

+ 7 - 1
src/lua/CMakeLists.txt

@@ -31,10 +31,16 @@ if (WINDOWS)
 add_definitions(/link /OPT:NOREF)
 endif (WINDOWS)
 
-add_library(crownlua SHARED ${LUA_SRC})
+add_library(crownlua SHARED ${LUA_SRC} ${LUA_HEADERS})
 target_link_libraries(crownlua crown)
 
+set_target_properties (crownlua PROPERTIES OUTPUT_NAME libcrownlua)
+
 install (TARGETS crownlua DESTINATION lib/${CMAKE_PROJECT_NAME})
 
+if (WINDOWS)
+install (TARGETS crownlua DESTINATION bin)
+endif (WINDOWS)
+
 install (FILES ${LUA_HEADERS} DESTINATION include/${CMAKE_PROJECT_NAME}/lua)
 

+ 42 - 25
src/lua/CameraBinds.cpp

@@ -6,114 +6,131 @@
 namespace crown
 {
 
-extern "C"
-{
-
-int32_t camera(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t camera(lua_State* L)
 {
 	LuaStack stack(L);	
 
 }
 
-int32_t camera_position(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t camera_position(lua_State* L)
 {
 	LuaStack stack(L);	
 }
 
-int32_t camera_set_position(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t camera_set_position(lua_State* L)
 {
 	LuaStack stack(L);	
 }
 
-int32_t camera_look_at(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t camera_look_at(lua_State* L)
 {
 	LuaStack stack(L);	
 }
 
-int32_t camera_set_look_at(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t camera_set_look_at(lua_State* L)
 {
 	LuaStack stack(L);	
 }
 
-int32_t camera_set_rotation(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t camera_set_rotation(lua_State* L)
 {
 	LuaStack stack(L);	
 }
 
-int32_t camera_up(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t camera_up(lua_State* L)
 {
 	LuaStack stack(L);	
 }
 
-int32_t camera_fov(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t camera_fov(lua_State* L)
 {
 	LuaStack stack(L);	
 }
 
-int32_t camera_set_fov(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t camera_set_fov(lua_State* L)
 {
 	LuaStack stack(L);	
 }
 
-int32_t camera_aspect(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t camera_aspect(lua_State* L)
 {
 	LuaStack stack(L);	
 }
 
-int32_t camera_set_aspect(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t camera_set_aspect(lua_State* L)
 {
 	LuaStack stack(L);	
 }
 
-int32_t camera_near_clip_distance(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t camera_near_clip_distance(lua_State* L)
 {
 	LuaStack stack(L);	
 }
 
-int32_t camera_set_near_clip_distance(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t camera_set_near_clip_distance(lua_State* L)
 {
 	LuaStack stack(L);	
 }
 
-int32_t camera_far_clip_distance(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t camera_far_clip_distance(lua_State* L)
 {
 	LuaStack stack(L);	
 }
 
-int32_t camera_set_far_clip_distance(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t camera_set_far_clip_distance(lua_State* L)
 {
 	LuaStack stack(L);	
 }
 
-int32_t camera_projection_matrix(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t camera_projection_matrix(lua_State* L)
 {
 	LuaStack stack(L);	
 }
 
-int32_t camera_view_matrix(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t camera_view_matrix(lua_State* L)
 {
 	LuaStack stack(L);	
 }
 
-int32_t camera_move_forward(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t camera_move_forward(lua_State* L)
 {
 	LuaStack stack(L);	
 }
 
-int32_t camera_move_backward(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t camera_move_backward(lua_State* L)
 {
 	LuaStack stack(L);	
 }
 
-int32_t camera_strafe_left(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t camera_strafe_left(lua_State* L)
 {
 	LuaStack stack(L);	
 }
 
-int32_t camera_strafe_right(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t camera_strafe_right(lua_State* L)
 {
 	LuaStack stack(L);	
 }
 
-} // enxtern "C"
 } // namespace crown

+ 34 - 4
src/lua/DeviceBinds.cpp

@@ -5,22 +5,52 @@
 namespace crown
 {
 
-extern "C"
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t device_frame_count(lua_State* L)
 {
+	LuaStack stack(L);
+
+	uint64_t frame = device()->frame_count();
+
+	stack.push_uint64(frame);
+
+	return 1;
+}
 
 //-----------------------------------------------------------------------------
-int32_t device_stop(lua_State* L)
+CE_EXPORT int32_t device_last_delta_time(lua_State* L)
 {
-	device()->stop();
+	LuaStack stack(L);
+
+	float delta = device()->last_delta_time();
+
+	stack.push_float(delta);
+
+	return 1;
+}
+
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t device_start(lua_State* L)
+{
+	device()->start();
 
 	return 0;
 }
 
-} // extern "C"
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t device_stop(lua_State* L)
+{
+	device()->stop();
+
+	return 0;
+}
 
 //-----------------------------------------------------------------------------
 void load_device(LuaEnvironment& env)
 {
+	env.load_module_function("Device", "frame_count", device_frame_count);
+	env.load_module_function("Device", "last_delta_time", device_last_delta_time);
+	env.load_module_function("Device", "start", device_start);
 	env.load_module_function("Device", "stop", device_stop);
 }
 

+ 7 - 8
src/lua/KeyboardBinds.cpp

@@ -6,10 +6,8 @@
 namespace crown
 {
 
-extern "C"
-{
-
-int32_t keyboard_modifier_pressed(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t keyboard_modifier_pressed(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -20,7 +18,8 @@ int32_t keyboard_modifier_pressed(lua_State* L)
 	return 1;
 }
 
-int32_t keyboard_key_pressed(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t keyboard_key_pressed(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -31,7 +30,8 @@ int32_t keyboard_key_pressed(lua_State* L)
 	return 1;
 }
 
-int32_t keyboard_key_released(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t keyboard_key_released(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -42,8 +42,7 @@ int32_t keyboard_key_released(lua_State* L)
 	return 1;
 }
 
-} // extern "C"
-
+//-----------------------------------------------------------------------------
 void load_keyboard(LuaEnvironment& env)
 {
 	env.load_module_function("Keyboard", "modifier_pressed",	keyboard_modifier_pressed);

+ 3 - 5
src/lua/LuaEnvironment.cpp

@@ -23,10 +23,8 @@ void LuaEnvironment::load_module_function(const char* module, const char* name,
 	luaL_register(m_state, module, entry);
 }
 
-extern "C"
-{
-
-int32_t luaopen_libcrownlua(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t luaopen_libcrownlua(lua_State* L)
 {
 	LuaEnvironment env(L);
 
@@ -45,7 +43,7 @@ int32_t luaopen_libcrownlua(lua_State* L)
 	return 1;
 }
 
-} // extern "C"
+
 
 
 } // namespace crown

+ 9 - 6
src/lua/LuaEnvironment.h

@@ -2,6 +2,14 @@
 
 #include "lua.hpp"
 #include "Types.h"
+#include "Config.h"
+
+#ifdef WINDOWS
+	#define CE_EXPORT extern "C" __declspec(dllexport)
+#else
+	#define CE_EXPORT
+#endif
+
 
 namespace crown
 {
@@ -37,11 +45,6 @@ void load_camera(LuaEnvironment& env);
 
 void load_device(LuaEnvironment& env);
 
-extern "C"
-{
-	int32_t luaopen_libcrownlua(lua_State* L);
-}
-
-
+CE_EXPORT int32_t luaopen_libcrownlua(lua_State* L);
 
 } // namespace crown

+ 19 - 1
src/lua/LuaStack.cpp

@@ -65,7 +65,25 @@ void LuaStack::push_bool(bool value)
 }
 
 //-----------------------------------------------------------------------------
-void LuaStack::push_int(int32_t value)
+void LuaStack::push_int32(int32_t value)
+{
+	lua_pushinteger(m_state, value);
+}
+
+//-----------------------------------------------------------------------------
+void LuaStack::push_uint32(uint32_t value)
+{
+	lua_pushinteger(m_state, value);
+}
+
+//-----------------------------------------------------------------------------
+void LuaStack::push_int64(int64_t value)
+{
+	lua_pushinteger(m_state, value);
+}
+
+//-----------------------------------------------------------------------------
+void LuaStack::push_uint64(uint64_t value)
 {
 	lua_pushinteger(m_state, value);
 }

+ 7 - 1
src/lua/LuaStack.h

@@ -24,7 +24,13 @@ public:
 
 	void					push_bool(bool value);
 
-	void					push_int(int32_t value);
+	void					push_int32(int32_t value);
+
+	void					push_uint32(uint32_t value);
+
+	void					push_int64(int64_t value);
+
+	void					push_uint64(uint64_t value);
 
 	void 					push_float(float value);
 

+ 58 - 34
src/lua/Mat4Binds.cpp

@@ -7,10 +7,8 @@
 namespace crown
 {
 
-extern "C"
-{
-
-int32_t mat4(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t mat4(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -40,8 +38,9 @@ int32_t mat4(lua_State* L)
 
 	return 1;
 }
-					
-int32_t mat4_add(lua_State* L)
+
+//-----------------------------------------------------------------------------					
+CE_EXPORT int32_t mat4_add(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -55,7 +54,8 @@ int32_t mat4_add(lua_State* L)
 	return 1;
 }
 
-int32_t mat4_subtract(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t mat4_subtract(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -69,7 +69,8 @@ int32_t mat4_subtract(lua_State* L)
 	return 1;
 }
 
-int32_t mat4_multiply(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t mat4_multiply(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -83,7 +84,8 @@ int32_t mat4_multiply(lua_State* L)
 	return 1;
 }	
 
-int32_t mat4_multiply_by_scalar(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t mat4_multiply_by_scalar(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -97,7 +99,8 @@ int32_t mat4_multiply_by_scalar(lua_State* L)
 	return 1;
 }
 
-int32_t mat4_divide_by_scalar(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t mat4_divide_by_scalar(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -111,7 +114,8 @@ int32_t mat4_divide_by_scalar(lua_State* L)
 	return 1;
 }
 
-int32_t mat4_build_rotation_x(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t mat4_build_rotation_x(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -123,7 +127,8 @@ int32_t mat4_build_rotation_x(lua_State* L)
 	return 0;
 }
 
-int32_t mat4_build_rotation_y(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t mat4_build_rotation_y(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -135,7 +140,8 @@ int32_t mat4_build_rotation_y(lua_State* L)
 	return 0;
 }
 
-int32_t mat4_build_rotation_z(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t mat4_build_rotation_z(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -147,7 +153,8 @@ int32_t mat4_build_rotation_z(lua_State* L)
 	return 0;
 }
 
-int32_t mat4_build_rotation(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t mat4_build_rotation(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -160,7 +167,8 @@ int32_t mat4_build_rotation(lua_State* L)
 	return 0;
 }
 
-int32_t mat4_build_projection_perspective_rh(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t mat4_build_projection_perspective_rh(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -175,7 +183,8 @@ int32_t mat4_build_projection_perspective_rh(lua_State* L)
 	return 0;
 }
 
-int32_t mat4_build_projection_perspective_lh(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t mat4_build_projection_perspective_lh(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -190,7 +199,8 @@ int32_t mat4_build_projection_perspective_lh(lua_State* L)
 	return 0;
 }
 
-int32_t mat4_build_projection_ortho_rh(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t mat4_build_projection_ortho_rh(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -205,7 +215,8 @@ int32_t mat4_build_projection_ortho_rh(lua_State* L)
 	return 0;
 }
 
-int32_t mat4_build_projection_ortho_lh(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t mat4_build_projection_ortho_lh(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -220,7 +231,8 @@ int32_t mat4_build_projection_ortho_lh(lua_State* L)
 	return 0;
 }
 
-int32_t mat4_build_projection_ortho_2d_rh(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t mat4_build_projection_ortho_2d_rh(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -235,7 +247,8 @@ int32_t mat4_build_projection_ortho_2d_rh(lua_State* L)
 	return 0;
 }
 
-int32_t mat4_build_look_at_rh(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t mat4_build_look_at_rh(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -249,7 +262,8 @@ int32_t mat4_build_look_at_rh(lua_State* L)
 	return 0;
 }
 
-int32_t mat4_build_look_at_lh(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t mat4_build_look_at_lh(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -263,7 +277,8 @@ int32_t mat4_build_look_at_lh(lua_State* L)
 	return 0;
 }
 
-int32_t mat4_build_viewpoint_billboard(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t mat4_build_viewpoint_billboard(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -277,7 +292,8 @@ int32_t mat4_build_viewpoint_billboard(lua_State* L)
 	return 0;
 }
 
-int32_t mat4_build_axis_billboard(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t mat4_build_axis_billboard(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -291,7 +307,8 @@ int32_t mat4_build_axis_billboard(lua_State* L)
 	return 0;
 }
 
-int32_t mat4_transpose(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t mat4_transpose(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -304,7 +321,8 @@ int32_t mat4_transpose(lua_State* L)
 	return 1;
 }
 
-int32_t mat4_determinant(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t mat4_determinant(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -315,7 +333,8 @@ int32_t mat4_determinant(lua_State* L)
 	return 1;
 }
 
-int32_t mat4_invert(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t mat4_invert(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -328,7 +347,8 @@ int32_t mat4_invert(lua_State* L)
 	return 1;
 }
 
-int32_t mat4_load_identity(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t mat4_load_identity(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -339,7 +359,8 @@ int32_t mat4_load_identity(lua_State* L)
 	return 0;
 }
 
-int32_t mat4_get_translation(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t mat4_get_translation(lua_State* L)
 {	
 	LuaStack stack(L);
 
@@ -353,7 +374,8 @@ int32_t mat4_get_translation(lua_State* L)
 	return 1;
 }
 
-int32_t mat4_set_translation(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t mat4_set_translation(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -365,7 +387,8 @@ int32_t mat4_set_translation(lua_State* L)
 	return 0;
 }
 
-int32_t mat4_get_scale(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t mat4_get_scale(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -379,7 +402,8 @@ int32_t mat4_get_scale(lua_State* L)
 	return 1;
 }
 
-int32_t mat4_set_scale(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t mat4_set_scale(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -391,7 +415,8 @@ int32_t mat4_set_scale(lua_State* L)
 	return 0;
 }
 
-int32_t mat4_print(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t mat4_print(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -405,8 +430,7 @@ int32_t mat4_print(lua_State* L)
 	return 0;
 }
 
-} //extern "C"
-
+//-----------------------------------------------------------------------------
 void load_mat4(LuaEnvironment& env)
 {
 	env.load_module_function("Mat4", "new", 							mat4);

+ 34 - 22
src/lua/MathBinds.cpp

@@ -5,10 +5,8 @@
 namespace crown
 {
 
-extern "C"
-{
-
-int32_t math_deg_to_rad(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t math_deg_to_rad(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -19,7 +17,8 @@ int32_t math_deg_to_rad(lua_State* L)
 	return 1;
 }
 
-int32_t math_rad_to_deg(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t math_rad_to_deg(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -30,18 +29,20 @@ int32_t math_rad_to_deg(lua_State* L)
 	return 1;
 }
 
-int32_t math_next_pow_2(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t math_next_pow_2(lua_State* L)
 {
 	LuaStack stack(L);
 
 	uint32_t x = stack.get_int(1);
 
-	stack.push_int(math::next_pow_2(x));
+	stack.push_uint32(math::next_pow_2(x));
 
 	return 1;
 }
 
-int32_t math_is_pow_2(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t math_is_pow_2(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -52,7 +53,8 @@ int32_t math_is_pow_2(lua_State* L)
 	return 1;
 }
 
-int32_t math_ceil(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t math_ceil(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -63,7 +65,8 @@ int32_t math_ceil(lua_State* L)
 	return 1;
 }
 
-int32_t math_floor(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t math_floor(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -74,7 +77,8 @@ int32_t math_floor(lua_State* L)
 	return 1;
 }
 
-int32_t math_sqrt(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t math_sqrt(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -85,7 +89,8 @@ int32_t math_sqrt(lua_State* L)
 	return 1;
 }
 
-int32_t math_inv_sqrt(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t math_inv_sqrt(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -96,7 +101,8 @@ int32_t math_inv_sqrt(lua_State* L)
 	return 1;
 }
 
-int32_t math_sin(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t math_sin(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -107,7 +113,8 @@ int32_t math_sin(lua_State* L)
 	return 1;
 }
 
-int32_t math_cos(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t math_cos(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -118,7 +125,8 @@ int32_t math_cos(lua_State* L)
 	return 1;
 }
 
-int32_t math_asin(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t math_asin(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -129,7 +137,8 @@ int32_t math_asin(lua_State* L)
 	return 1;
 }
 
-int32_t math_acos(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t math_acos(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -140,7 +149,8 @@ int32_t math_acos(lua_State* L)
 	return 1;
 }
 
-int32_t math_tan(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t math_tan(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -151,7 +161,8 @@ int32_t math_tan(lua_State* L)
 	return 1;
 }
 
-int32_t math_atan2(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t math_atan2(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -163,7 +174,8 @@ int32_t math_atan2(lua_State* L)
 	return 1;
 }
 
-int32_t math_abs(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t math_abs(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -174,7 +186,8 @@ int32_t math_abs(lua_State* L)
 	return 1;
 }
 
-int32_t math_fmod(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t math_fmod(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -186,8 +199,7 @@ int32_t math_fmod(lua_State* L)
 	return 1;
 }
 
-} // extern "C"
-
+//-----------------------------------------------------------------------------
 void load_math(LuaEnvironment& env)
 {
 	env.load_module_function("Math", "deg_to_rad", 	math_deg_to_rad);

+ 6 - 11
src/lua/MouseBinds.cpp

@@ -7,11 +7,8 @@
 namespace crown
 {
 
-extern "C"
-{
-
 //-----------------------------------------------------------------------------
-int32_t mouse_button_pressed(lua_State* L)
+CE_EXPORT int32_t mouse_button_pressed(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -23,7 +20,7 @@ int32_t mouse_button_pressed(lua_State* L)
 }
 
 //-----------------------------------------------------------------------------
-int32_t mouse_button_released(lua_State* L)
+CE_EXPORT int32_t mouse_button_released(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -35,7 +32,7 @@ int32_t mouse_button_released(lua_State* L)
 }
 
 //-----------------------------------------------------------------------------
-int32_t mouse_cursor_xy(lua_State* L)
+CE_EXPORT int32_t mouse_cursor_xy(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -49,7 +46,7 @@ int32_t mouse_cursor_xy(lua_State* L)
 }
 
 //-----------------------------------------------------------------------------
-int32_t mouse_set_cursor_xy(lua_State* L)
+CE_EXPORT int32_t mouse_set_cursor_xy(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -61,7 +58,7 @@ int32_t mouse_set_cursor_xy(lua_State* L)
 }
 
 //-----------------------------------------------------------------------------
-int32_t mouse_cursor_relative_xy(lua_State* L)
+CE_EXPORT int32_t mouse_cursor_relative_xy(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -74,7 +71,7 @@ int32_t mouse_cursor_relative_xy(lua_State* L)
 }
 
 //-----------------------------------------------------------------------------
-int32_t mouse_set_cursor_relative_xy(lua_State* L)
+CE_EXPORT int32_t mouse_set_cursor_relative_xy(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -85,8 +82,6 @@ int32_t mouse_set_cursor_relative_xy(lua_State* L)
 	return 0;
 }
 
-} // extern "C"
-
 //-----------------------------------------------------------------------------
 void load_mouse(LuaEnvironment& env)
 {

+ 19 - 14
src/lua/QuatBinds.cpp

@@ -7,10 +7,8 @@
 namespace crown
 {
 
-extern "C"
-{
-
-int32_t quat(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t quat(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -27,7 +25,8 @@ int32_t quat(lua_State* L)
 	return 1;
 }
 
-int32_t quat_negate(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t quat_negate(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -38,7 +37,8 @@ int32_t quat_negate(lua_State* L)
 	return 0;
 }
 
-int32_t quat_load_identity(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t quat_load_identity(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -49,7 +49,8 @@ int32_t quat_load_identity(lua_State* L)
 	return 0;
 }
 
-int32_t quat_length(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t quat_length(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -60,7 +61,8 @@ int32_t quat_length(lua_State* L)
 	return 1;
 }
 
-int32_t quat_conjugate(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t quat_conjugate(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -74,7 +76,8 @@ int32_t quat_conjugate(lua_State* L)
 	return 1;
 }
 
-int32_t quat_inverse(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t quat_inverse(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -88,7 +91,8 @@ int32_t quat_inverse(lua_State* L)
 	return 1;
 }
 
-int32_t quat_cross(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t quat_cross(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -102,7 +106,8 @@ int32_t quat_cross(lua_State* L)
 	return 1;
 }
 
-int32_t quat_multiply(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t quat_multiply(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -116,7 +121,8 @@ int32_t quat_multiply(lua_State* L)
 	return 1;
 }
 
-int32_t quat_power(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t quat_power(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -130,8 +136,7 @@ int32_t quat_power(lua_State* L)
 	return 1;
 }
 
-} // extern "C"
-
+//-----------------------------------------------------------------------------
 void load_quat(LuaEnvironment& env)
 {
 	env.load_module_function("Quat", "new", quat);

+ 38 - 26
src/lua/Vec2Binds.cpp

@@ -2,14 +2,11 @@
 #include "LuaStack.h"
 #include "LuaEnvironment.h"
 
-
 namespace crown
 {
 
-extern "C"
-{
-
-int32_t	vec2(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t vec2(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -26,7 +23,8 @@ int32_t	vec2(lua_State* L)
 	return 1;
 }
 
-int32_t vec2_values(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t vec2_values(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -41,8 +39,8 @@ int32_t vec2_values(lua_State* L)
 	return 2;
 }
 
-
-int32_t vec2_add(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t vec2_add(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -56,7 +54,8 @@ int32_t vec2_add(lua_State* L)
 	return 1;
 }
 
-int32_t vec2_subtract(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t vec2_subtract(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -70,7 +69,8 @@ int32_t vec2_subtract(lua_State* L)
 	return 1;
 }
 
-int32_t vec2_multiply(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t vec2_multiply(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -83,8 +83,9 @@ int32_t vec2_multiply(lua_State* L)
 
 	return 1;
 }			
-	
-int32_t vec2_divide(lua_State* L)
+
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t vec2_divide(lua_State* L)
 {
 	LuaStack stack(L);
 	
@@ -98,7 +99,8 @@ int32_t vec2_divide(lua_State* L)
 	return 1;
 }
 
-int32_t vec2_dot(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t vec2_dot(lua_State* L)
 {
 	LuaStack stack(L);
 	
@@ -110,7 +112,8 @@ int32_t vec2_dot(lua_State* L)
 	return 1;
 }
 
-int32_t vec2_equals(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t vec2_equals(lua_State* L)
 {
 	LuaStack stack(L);
 	
@@ -122,7 +125,8 @@ int32_t vec2_equals(lua_State* L)
 	return 1;
 }
 
-int32_t vec2_lower(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t vec2_lower(lua_State* L)
 {
 	LuaStack stack(L);
 	
@@ -134,7 +138,8 @@ int32_t vec2_lower(lua_State* L)
 	return 1;
 }
 
-int32_t vec2_greater(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t vec2_greater(lua_State* L)
 {
 	LuaStack stack(L);
 	
@@ -146,7 +151,8 @@ int32_t vec2_greater(lua_State* L)
 	return 1;
 }
 
-int32_t vec2_length(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t vec2_length(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -157,7 +163,8 @@ int32_t vec2_length(lua_State* L)
 	return 1;
 }
 
-int32_t vec2_squared_length(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t vec2_squared_length(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -168,7 +175,8 @@ int32_t vec2_squared_length(lua_State* L)
 	return 1;
 }
 
-int32_t vec2_set_length(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t vec2_set_length(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -180,7 +188,8 @@ int32_t vec2_set_length(lua_State* L)
 	return 0;
 }
 
-int32_t	vec2_normalize(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t vec2_normalize(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -193,7 +202,8 @@ int32_t	vec2_normalize(lua_State* L)
 	return 1;
 }
 
-int32_t	vec2_negate(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t vec2_negate(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -206,7 +216,8 @@ int32_t	vec2_negate(lua_State* L)
 	return 1;
 }
 
-int32_t	vec2_get_distance_to(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t vec2_get_distance_to(lua_State* L)
 {
 	LuaStack stack(L);
 	
@@ -218,7 +229,8 @@ int32_t	vec2_get_distance_to(lua_State* L)
 	return 1;
 }
 
-int32_t	vec2_get_angle_between(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t vec2_get_angle_between(lua_State* L)
 {
 	LuaStack stack(L);
 	
@@ -230,7 +242,8 @@ int32_t	vec2_get_angle_between(lua_State* L)
 	return 1;
 }
 
-int32_t	vec2_zero(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t vec2_zero(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -241,8 +254,7 @@ int32_t	vec2_zero(lua_State* L)
 	return 0;
 }
 
-} // extern "C"
-
+//-----------------------------------------------------------------------------
 void load_vec2(LuaEnvironment& env)
 {
 	env.load_module_function("Vec2", "new", vec2);

+ 39 - 45
src/lua/Vec3Binds.cpp

@@ -5,13 +5,8 @@
 namespace crown
 {
 
-/// Lightweight bind for Vec3 
-
-extern "C"
-{
-
-//------------------------------------------------------------
-int32_t vec3(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t vec3(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -30,8 +25,8 @@ int32_t vec3(lua_State* L)
 	return 1;
 }
 
-//------------------------------------------------------------
-int32_t vec3_values(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t vec3_values(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -48,8 +43,8 @@ int32_t vec3_values(lua_State* L)
 	return 3;
 }
 
-//------------------------------------------------------------
-int32_t vec3_add(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t vec3_add(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -63,8 +58,8 @@ int32_t vec3_add(lua_State* L)
 	return 1;
 }
 
-//------------------------------------------------------------
-int32_t vec3_subtract(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t vec3_subtract(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -78,8 +73,8 @@ int32_t vec3_subtract(lua_State* L)
 	return 1;
 }
 
-//------------------------------------------------------------
-int32_t vec3_multiply(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t vec3_multiply(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -93,8 +88,8 @@ int32_t vec3_multiply(lua_State* L)
 	return 1;
 }
 
-//------------------------------------------------------------
-int32_t vec3_divide(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t vec3_divide(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -108,8 +103,8 @@ int32_t vec3_divide(lua_State* L)
 	return 1;
 }
 
-//------------------------------------------------------------
-int32_t vec3_dot(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t vec3_dot(lua_State* L)
 {
 	LuaStack stack(L);
 	
@@ -121,8 +116,8 @@ int32_t vec3_dot(lua_State* L)
 	return 1;
 }
 
-//------------------------------------------------------------
-int32_t vec3_cross(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t vec3_cross(lua_State* L)
 {
 	LuaStack stack(L);
 	
@@ -137,8 +132,8 @@ int32_t vec3_cross(lua_State* L)
 	return 1;
 }
 
-//------------------------------------------------------------
-int32_t vec3_equals(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t vec3_equals(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -150,8 +145,8 @@ int32_t vec3_equals(lua_State* L)
 	return 1;
 }
 
-//------------------------------------------------------------
-int32_t vec3_lower(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t vec3_lower(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -163,8 +158,8 @@ int32_t vec3_lower(lua_State* L)
 	return 1;
 }
 
-//------------------------------------------------------------
-int32_t vec3_greater(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t vec3_greater(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -176,8 +171,8 @@ int32_t vec3_greater(lua_State* L)
 	return 1;
 }
 
-//------------------------------------------------------------
-int32_t vec3_length(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t vec3_length(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -188,8 +183,8 @@ int32_t vec3_length(lua_State* L)
 	return 1;
 }
 
-//------------------------------------------------------------
-int32_t vec3_squared_length(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t vec3_squared_length(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -200,8 +195,8 @@ int32_t vec3_squared_length(lua_State* L)
 	return 1;
 }
 
-//------------------------------------------------------------
-int32_t vec3_set_length(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t vec3_set_length(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -213,8 +208,8 @@ int32_t vec3_set_length(lua_State* L)
 	return 0;
 }
 
-//------------------------------------------------------------
-int32_t vec3_normalize(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t vec3_normalize(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -225,8 +220,8 @@ int32_t vec3_normalize(lua_State* L)
 	return 0;
 }
 
-//------------------------------------------------------------
-int32_t vec3_negate(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t vec3_negate(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -237,8 +232,8 @@ int32_t vec3_negate(lua_State* L)
 	return 0;
 }
 
-//------------------------------------------------------------
-int32_t vec3_get_distance_to(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t vec3_get_distance_to(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -250,8 +245,8 @@ int32_t vec3_get_distance_to(lua_State* L)
 	return 1;
 }
 
-//------------------------------------------------------------
-int32_t vec3_get_angle_between(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t vec3_get_angle_between(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -263,8 +258,8 @@ int32_t vec3_get_angle_between(lua_State* L)
 	return 1;
 }
 
-//------------------------------------------------------------
-int32_t vec3_zero(lua_State* L)
+//-----------------------------------------------------------------------------
+CE_EXPORT int32_t vec3_zero(lua_State* L)
 {
 	LuaStack stack(L);
 
@@ -275,8 +270,7 @@ int32_t vec3_zero(lua_State* L)
 	return 0;
 }	
 
-} // extern "C"
-
+//-----------------------------------------------------------------------------
 void load_vec3(LuaEnvironment& env)
 {
 	env.load_module_function("Vec3", "new", 				vec3);

+ 7 - 9
src/os/OS.h

@@ -36,20 +36,18 @@ namespace crown
 
 //-----------------------------------------------------------------------------
 #ifdef LINUX
-const size_t	MAX_PATH_LENGTH = 1024;
-const char		PATH_SEPARATOR = '/';
+	const size_t	MAX_PATH_LENGTH = 1024;
+	const char		PATH_SEPARATOR = '/';
 #endif
 
 #ifdef WINDOWS
+	const size_t	MAX_PATH_LENGTH = 1024;
+	const char		PATH_SEPARATOR = '\\';
 
-const size_t	MAX_PATH_LENGTH = 1024;
-const char		PATH_SEPARATOR = '\\';
-
-#define snprintf _snprintf
-
-#undef MK_SHIFT
-#undef MK_ALT
+	#define snprintf _snprintf
 
+	#undef MK_SHIFT
+	#undef MK_ALT
 #endif
 
 namespace os

+ 22 - 12
src/os/android/AndroidDevice.cpp

@@ -4,24 +4,34 @@
 namespace crown
 {
 
-extern "C" 
-{
-	//!< Device init() jni bind
-	JNIEXPORT void JNICALL Java_crown_android_CrownLib_init(JNIEnv* env, jobject obj);
-	//!< Device shutdown() jni bind
-	JNIEXPORT void JNICALL Java_crown_android_CrownLib_shutdown(JNIEnv* env, jobject obj);
-};
-
-//------------------------------------------------------------------------------------
-JNIEXPORT void JNICALL Java_crown_android_CrownLib_init(JNIEnv* env, jobject obj)
+//-----------------------------------------------------------------------------
+extern "C" JNIEXPORT void JNICALL Java_crown_android_CrownLib_init(JNIEnv* env, jobject obj)
 {
 	device()->init(0, NULL);
 }
 
-//------------------------------------------------------------------------------------
-JNIEXPORT void JNICALL Java_crown_android_CrownLib_shutdown(JNIEnv* env, jobject obj)
+//-----------------------------------------------------------------------------
+extern "C" JNIEXPORT void JNICALL Java_crown_android_CrownLib_shutdown(JNIEnv* env, jobject obj)
 {
 	device()->shutdown();
 }
 
+//-----------------------------------------------------------------------------
+extern "C" JNIEXPORT void JNICALL Java_crown_android_CrownLib_frame(JNIEnv* env, jobject obj)
+{
+	device()->frame();
+}
+
+//-----------------------------------------------------------------------------
+extern "C" JNIEXPORT bool JNICALL Java_crown_android_CrownLib_isInit(JNIEnv* env, jobject obj)
+{
+	return device()->is_init();
+}
+
+//-----------------------------------------------------------------------------
+extern "C" JNIEXPORT bool JNICALL Java_crown_android_CrownLib_isRunning(JNIEnv* env, jobject obj)
+{
+	return device()->is_running();
+}
+
 } // namespace crown

+ 0 - 81
src/os/android/AndroidInput.cpp

@@ -1,81 +0,0 @@
-#include "OS.h"
-#include "Log.h"
-#include <jni.h>
-
-namespace crown
-{
-namespace os
-{
-
-extern "C" 
-{
-	/// OS push_event() jni bind
-    JNIEXPORT void JNICALL Java_crown_android_CrownLib_pushIntEvent(JNIEnv * env, jobject obj, jint type, jint a, jint b, jint c, jint d);
-    JNIEXPORT void JNICALL Java_crown_android_CrownLib_pushFloatEvent(JNIEnv * env, jobject obj, jint type, jfloat a, jfloat b, jfloat c, jfloat d);    
-};
-
-//-----------------------------------------------------------------------------
-void init_input()
-{
-	// FIXME
-}
-
-//-----------------------------------------------------------------------------
-void event_loop()
-{
-	// not necessary, implemented in Android
-}
-
-//-----------------------------------------------------------------------------
-void get_cursor_xy(int32_t& x, int32_t& y)
-{
-	// not necessary
-}
-
-//-----------------------------------------------------------------------------
-void set_cursor_xy(int32_t x, int32_t y)
-{
-	// not necessary
-}
-
-//-----------------------------------------------------------------------------
-void hide_cursor()
-{
-	// not necessary
-}
-
-//-----------------------------------------------------------------------------
-void show_cursor()
-{
-	// not necessary
-}
-
-//-----------------------------------------------------------------------------
-JNIEXPORT void JNICALL Java_crown_android_CrownLib_pushIntEvent(JNIEnv * env, jobject obj, jint type, jint a, jint b, jint c, jint d)
-{	
-	OSEventParameter values[4];
-
-	values[0].int_value = a;
-	values[1].int_value = b;
-	values[2].int_value = c;
-	values[3].int_value = d;
-
-	push_event((OSEventType)type, values[0], values[1], values[2], values[3]);
-}
-
-//-----------------------------------------------------------------------------
-JNIEXPORT void JNICALL Java_crown_android_CrownLib_pushFloatEvent(JNIEnv * env, jobject obj, jint type, jfloat a, jfloat b, jfloat c, jfloat d)
-{
-	OSEventParameter values[4];
-
-	values[0].float_value = a;
-	values[1].float_value = b;
-	values[2].float_value = c;
-	values[3].float_value = d;
-
-
-	push_event((OSEventType)type, values[0], values[1], values[2], values[3]);
-}
-
-} // namespace os
-} // namespace crown

+ 53 - 56
src/os/android/AndroidOS.cpp

@@ -34,10 +34,10 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include <sys/time.h>
 #include <time.h>
 #include <android/asset_manager_jni.h>
-#include <pthread.h>
 
 #include "OS.h"
 #include "AndroidOS.h"
+#include "OsWindow.h"
 #include "Log.h"
 
 namespace crown
@@ -45,13 +45,6 @@ namespace crown
 namespace os
 {
 
-extern "C" 
-{
-	// This is sadly necessary in order to get the asset manager from java...
-    JNIEXPORT void JNICALL Java_crown_android_CrownLib_initAssetManager(JNIEnv* env, jobject obj, jobject assetManager);
-	JNIEXPORT void JNICALL Java_crown_android_CrownLib_setRenderWindowMetrics(JNIEnv* env, jobject obj, jint width, jint height);
-};
-
 static timespec			base_time;
 static AAssetManager*	asset_manager = NULL;
 static uint32_t			window_width;
@@ -97,6 +90,38 @@ void log_info(const char* string, va_list arg)
 	__android_log_vprint(ANDROID_LOG_INFO, "crown", string, arg);
 }
 
+//-----------------------------------------------------------------------------
+bool is_root_path(const char* path)
+{
+	CE_ASSERT(path != NULL, "Path must be != NULL");
+
+	if (string::strlen(path) == 1)
+	{
+		if (path[0] == PATH_SEPARATOR)
+		{
+			return true;
+		}
+	}
+
+	return false;
+}
+
+//-----------------------------------------------------------------------------
+bool is_absolute_path(const char* path)
+{
+	CE_ASSERT(path != NULL, "Path must be != NULL");
+
+	if (string::strlen(path) > 0)
+	{
+		if (path[0] == PATH_SEPARATOR)
+		{
+			return true;
+		}
+	}
+
+	return false;
+}
+
 //-----------------------------------------------------------------------------
 bool exists(const char* path)
 {
@@ -188,29 +213,6 @@ const char* get_env(const char* env)
 	return envDevel;
 }
 
-//-----------------------------------------------------------------------------
-// bool ls(const char* path, List<Str>& fileList)
-// {
-// 	DIR *dir;
-// 	struct dirent *ent;
-
-// 	dir = opendir(path);
-
-// 	if (dir == NULL)
-// 	{
-// 		return false;
-// 	}
-
-// 	while ((ent = readdir (dir)) != NULL)
-// 	{
-// 		fileList.push_back(Str(ent->d_name));
-// 	}
-
-// 	closedir (dir);
-
-// 	return true;
-// }
-
 //-----------------------------------------------------------------------------
 void init_os()
 {
@@ -243,43 +245,38 @@ AAssetManager* get_android_asset_manager()
 }
 
 //-----------------------------------------------------------------------------
-bool create_render_window(uint32_t x, uint32_t y, uint32_t width, uint32_t height, bool fullscreen)
+extern "C" JNIEXPORT void JNICALL Java_crown_android_CrownLib_initAssetManager(JNIEnv* env, jobject obj, jobject assetManager)
 {
-	return true;
+	asset_manager = AAssetManager_fromJava(env, assetManager);
 }
 
-//-----------------------------------------------------------------------------
-bool destroy_render_window()
-{
-	return true;
-}
+} // namespace os
 
 //-----------------------------------------------------------------------------
-void get_render_window_metrics(uint32_t& width, uint32_t& height)
-{
-	width = window_width;
-	height = window_height;
-}
+extern "C" JNIEXPORT void JNICALL Java_crown_android_CrownLib_pushIntEvent(JNIEnv * env, jobject obj, jint type, jint a, jint b, jint c, jint d)
+{	
+	OsEventParameter values[4];
 
-//-----------------------------------------------------------------------------
-void swap_buffers()
-{
-	// not necessary
-}
+	values[0].int_value = a;
+	values[1].int_value = b;
+	values[2].int_value = c;
+	values[3].int_value = d;
 
-//-----------------------------------------------------------------------------
-JNIEXPORT void JNICALL Java_crown_android_CrownLib_initAssetManager(JNIEnv* env, jobject obj, jobject assetManager)
-{
-	asset_manager = AAssetManager_fromJava(env, assetManager);
+	push_event((OsEventType)type, values[0], values[1], values[2], values[3]);
 }
 
 //-----------------------------------------------------------------------------
-JNIEXPORT void JNICALL Java_crown_android_CrownLib_setRenderWindowMetrics(JNIEnv* env, jobject obj, jint width, jint height)
+extern "C" JNIEXPORT void JNICALL Java_crown_android_CrownLib_pushFloatEvent(JNIEnv * env, jobject obj, jint type, jfloat a, jfloat b, jfloat c, jfloat d)
 {
-	window_width = width;
-	window_height = height;
+	OsEventParameter values[4];
+
+	values[0].float_value = a;
+	values[1].float_value = b;
+	values[2].float_value = c;
+	values[3].float_value = d;
+
+	push_event((OsEventType)type, values[0], values[1], values[2], values[3]);
 }
 
-} // namespace os
 } // namespace crown
 

+ 2 - 1
src/os/android/AndroidOS.h

@@ -23,6 +23,7 @@ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 OTHER DEALINGS IN THE SOFTWARE.
 */
+#pragma once
 
 #include <jni.h>
 #include <sys/types.h>
@@ -34,7 +35,7 @@ namespace os
 {
 
 // Accessor to the android asset manager
-AAssetManager* get_android_asset_manager();
+AAssetManager* 	get_android_asset_manager();
 
 } // namespace crown
 } // namespace os

+ 3 - 4
src/os/android/OsFile.cpp

@@ -33,15 +33,14 @@ namespace crown
 {
 
 //-----------------------------------------------------------------------------
-OsFile::OsFile(const char* path, FileOpenMode mode) :
-	m_asset(NULL),
+OsFile::OsFile(const char* path, FileOpenMode mode)
 {
 	// Android assets are always read-only
 	(void) mode;
-	m_mode = SOM_READ;
+	m_mode = FOM_READ;
 	m_asset = AAssetManager_open(os::get_android_asset_manager(), path, AASSET_MODE_RANDOM);
 
-	CE_ASSERT(m_asset != NULL, "Unable to open file: %s", path)
+	CE_ASSERT(m_asset != NULL, "Unable to open file: %s", path);
 }
 
 //-----------------------------------------------------------------------------

+ 143 - 0
src/os/android/OsWindow.cpp

@@ -0,0 +1,143 @@
+/*
+Copyright (c) 2013 Daniele Bartolini, Michele Rossi
+Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#include <android/native_window_jni.h>
+
+#include "OsWindow.h"
+#include "GLContext.h"
+#include "Assert.h"
+
+namespace crown
+{
+
+static ANativeWindow* window = NULL;
+
+//-----------------------------------------------------------------------------
+OsWindow::OsWindow(uint32_t width, uint32_t height) :
+	m_window(NULL),
+	m_width(0),
+	m_height(0),
+	m_x(0),
+	m_y(0)
+{
+	m_window = window;
+
+	m_width = ANativeWindow_getWidth(m_window);
+	m_height = ANativeWindow_getHeight(m_window);
+
+    set_android_window(m_window);
+}
+
+//-----------------------------------------------------------------------------
+OsWindow::~OsWindow()
+{
+	if (m_window)
+	{
+		ANativeWindow_release(m_window);
+	}
+
+}
+
+//-----------------------------------------------------------------------------
+void OsWindow::show()
+{
+}
+
+//-----------------------------------------------------------------------------
+void OsWindow::hide()
+{
+}
+
+//-----------------------------------------------------------------------------
+void OsWindow::get_size(uint32_t& width, uint32_t& height)
+{
+	width = m_width;
+	height = m_height;
+}
+
+//-----------------------------------------------------------------------------
+void OsWindow::get_position(uint32_t& x, uint32_t& y)
+{
+	x = m_x;
+	y = m_y;
+}
+
+//-----------------------------------------------------------------------------
+void OsWindow::resize(uint32_t width, uint32_t height)
+{
+}
+
+//-----------------------------------------------------------------------------
+void OsWindow::move(uint32_t x, uint32_t y)
+{
+}
+
+//-----------------------------------------------------------------------------
+void OsWindow::show_cursor()
+{
+}
+
+//-----------------------------------------------------------------------------
+void OsWindow::hide_cursor()
+{
+}
+
+//-----------------------------------------------------------------------------
+void OsWindow::get_cursor_xy(int32_t& x, int32_t& y)
+{
+}
+
+//-----------------------------------------------------------------------------
+void OsWindow::set_cursor_xy(int32_t x, int32_t y)
+{
+}
+
+//-----------------------------------------------------------------------------
+char* OsWindow::title()
+{
+	return NULL;
+}
+
+//-----------------------------------------------------------------------------
+void OsWindow::set_title(const char* title)
+{
+}
+
+//-----------------------------------------------------------------------------
+void OsWindow::frame()
+{
+	// implemented on Java-side
+}
+
+//-----------------------------------------------------------------------------
+extern "C" void Java_crown_android_CrownLib_setWindow(JNIEnv *env, jclass clazz, jobject surface)
+{
+    // obtain a native window from a Java surface
+	CE_ASSERT(surface != 0, "Unable to get Android window");
+    window = ANativeWindow_fromSurface(env, surface);
+}
+
+} // namespace crown

+ 72 - 0
src/os/android/OsWindow.h

@@ -0,0 +1,72 @@
+/*
+Copyright (c) 2013 Daniele Bartolini, Michele Rossi
+Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#pragma once
+
+#include <sys/types.h>
+#include <android/native_window.h>
+
+namespace crown
+{
+
+class OsWindow
+{
+public:
+
+					OsWindow(uint32_t width, uint32_t height);
+					~OsWindow();
+
+	void			show();
+	void			hide();
+
+	void			get_size(uint32_t& width, uint32_t& height);
+	void			get_position(uint32_t& x, uint32_t& y);
+
+	void			resize(uint32_t width, uint32_t height);
+	void			move(uint32_t x, uint32_t y);
+
+	void			show_cursor();
+	void			hide_cursor();
+
+	void			get_cursor_xy(int32_t& x, int32_t& y);
+	void			set_cursor_xy(int32_t x, int32_t y);
+
+	char*			title();
+	void			set_title(const char* title);
+
+	void			frame();
+
+private:
+
+	ANativeWindow*	m_window;
+
+	uint32_t		m_x;
+	uint32_t		m_y;
+	uint32_t		m_width;
+	uint32_t		m_height;
+};
+
+} // namespace crown

+ 1 - 1
src/os/win/Mutex.h

@@ -38,7 +38,7 @@ namespace os
 class Mutex
 {
 public:
-	
+
 						Mutex();
 						~Mutex();
 

+ 5 - 3
src/os/win/WinOS.cpp

@@ -95,7 +95,7 @@ bool is_root_path(const char* path)
 
 	if (string::strlen(path) == 1)
 	{
-		if (path[0] == 'C')
+		if ((path[0] >= 65 && path[0] <= 90) || (path[0] >= 97 && path[0] <= 122))
 		{
 			return true;
 		}
@@ -111,7 +111,7 @@ bool is_absolute_path(const char* path)
 
 	if (string::strlen(path) > 0)
 	{
-		if (path[0] == 'C')
+		if ((path[0] >= 65 && path[0] <= 90) || (path[0] >= 97 && path[0] <= 122))
 		{
 			return true;
 		}
@@ -246,6 +246,7 @@ uint64_t microseconds()
 //-----------------------------------------------------------------------------
 void* open_library(const char* path)
 {
+
 	HMODULE library = LoadLibrary(path);
 
 	CE_ASSERT(library  != NULL, "Unable to load library '%s' with error: %d\n", path, GetLastError());
@@ -258,7 +259,7 @@ void close_library(void* library)
 {
 	BOOL freed = FreeLibrary((HMODULE)library);
 
-	CE_ASSERT(freed,  "Failed to close library\n");
+	CE_ASSERT(freed,  "Failed to close library\n with error: %d\n", GetLastError());
 }
 
 //-----------------------------------------------------------------------------
@@ -266,6 +267,7 @@ void* lookup_symbol(void* library, const char* name)
 {
 	FARPROC symbol = GetProcAddress((HMODULE)library, name);
 
+	CE_ASSERT(symbol  != NULL, "Unable to export symbol '%s' with error: %d\n", name, GetLastError());
 	return symbol;
 }
 

+ 55 - 46
src/renderers/gles/GLESRenderer.cpp

@@ -47,7 +47,30 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 namespace crown
 {
+//-----------------------------------------------------------------------------
+static const char* gl_error_to_string(GLenum error)
+{
+	switch (error)
+	{
+		case GL_INVALID_ENUM: return "GL_INVALID_ENUM";
+		case GL_INVALID_VALUE: return "GL_INVALID_VALUE";
+		case GL_INVALID_OPERATION: return "GL_INVALID_OPERATION";
+		case GL_OUT_OF_MEMORY: return "GL_OUT_OF_MEMORY";
+		default: return "UNKNOWN_GL_ERROR";
+	}
+}
 
+//-----------------------------------------------------------------------------
+#ifdef CROWN_DEBUG
+	#define GL_CHECK(function)\
+		function;\
+		do { GLenum error; CE_ASSERT((error = glGetError()) == GL_NO_ERROR,\
+				"OpenGL error: %s", gl_error_to_string(error)); } while (0)
+#else
+	#define GL_CHECK(function)\
+		function;
+#endif
+		
 //-----------------------------------------------------------------------------
 GLESRenderer::GLESRenderer() :
 	m_max_texture_size(0),
@@ -205,7 +228,7 @@ VertexBufferId GLESRenderer::create_dynamic_vertex_buffer(size_t count, VertexFo
 //-----------------------------------------------------------------------------
 void GLESRenderer::update_vertex_buffer(VertexBufferId id, size_t offset, size_t count, const void* vertices)
 {
-	assert(m_vertex_buffers_id_table.has(id));
+	CE_ASSERT(m_vertex_buffers_id_table.has(id), "VertexBuffers table does not have vertex buffer %d", id);
 
 	VertexBuffer& buffer = m_vertex_buffers[id.index];
 
@@ -217,7 +240,7 @@ void GLESRenderer::update_vertex_buffer(VertexBufferId id, size_t offset, size_t
 //-----------------------------------------------------------------------------
 void GLESRenderer::destroy_vertex_buffer(VertexBufferId id)
 {
-	assert(m_vertex_buffers_id_table.has(id));
+	CE_ASSERT(m_vertex_buffers_id_table.has(id), "VertexBuffers table does not have vertex buffer %d", id);
 
 	VertexBuffer& buffer = m_vertex_buffers[id.index];
 
@@ -246,7 +269,7 @@ IndexBufferId GLESRenderer::create_index_buffer(size_t count, const void* indice
 //-----------------------------------------------------------------------------
 void GLESRenderer::destroy_index_buffer(IndexBufferId id)
 {
-	assert(m_index_buffers_id_table.has(id));
+	CE_ASSERT(m_index_buffers_id_table.has(id), "IndexBuffers table does not have index buffer %d", id);
 
 	IndexBuffer& buffer = m_index_buffers[id.index];
 
@@ -280,7 +303,7 @@ TextureId GLESRenderer::create_texture(uint32_t width, uint32_t height, PixelFor
 //-----------------------------------------------------------------------------
 void GLESRenderer::update_texture(TextureId id, uint32_t x, uint32_t y, uint32_t width, uint32_t height, const void* data)
 {
-	assert(m_textures_id_table.has(id));
+	CE_ASSERT(m_textures_id_table.has(id), "Textures table does not have texture %d", id);
 
 	Texture& gl_texture = m_textures[id.index];
 
@@ -293,7 +316,7 @@ void GLESRenderer::update_texture(TextureId id, uint32_t x, uint32_t y, uint32_t
 //-----------------------------------------------------------------------------
 void GLESRenderer::destroy_texture(TextureId id)
 {
-	assert(m_textures_id_table.has(id));
+	CE_ASSERT(m_textures_id_table.has(id), "Textures table does not have texture %d", id);
 
 	Texture& gl_texture = m_textures[id.index];
 
@@ -303,7 +326,7 @@ void GLESRenderer::destroy_texture(TextureId id)
 //-----------------------------------------------------------------------------
 VertexShaderId GLESRenderer::create_vertex_shader(const char* program)
 {
-	assert(program != NULL);
+	CE_ASSERT(program != NULL, "Vertex shader can not be null");
 
 	const VertexShaderId& id = m_vertex_shaders_id_table.create();
 
@@ -326,7 +349,7 @@ VertexShaderId GLESRenderer::create_vertex_shader(const char* program)
 
 		Log::e("Vertex shader compilation failed.");
 		Log::e("Log: %s", info_log);
-		assert(0);
+		CE_ASSERT(0, "");
 	}
 
 	return id;
@@ -335,7 +358,7 @@ VertexShaderId GLESRenderer::create_vertex_shader(const char* program)
 //-----------------------------------------------------------------------------
 void GLESRenderer::destroy_vertex_shader(VertexShaderId id)
 {
-	assert(m_vertex_shaders_id_table.has(id));
+	CE_ASSERT(m_vertex_shaders_id_table.has(id), "Vertex shaders table does not have vertex shader %d", id);
 
 	VertexShader& gl_shader = m_vertex_shaders[id.index];
 
@@ -345,7 +368,7 @@ void GLESRenderer::destroy_vertex_shader(VertexShaderId id)
 //-----------------------------------------------------------------------------
 PixelShaderId GLESRenderer::create_pixel_shader(const char* program)
 {
-	assert(program != NULL);
+	CE_ASSERT(program != NULL, "Pixel Shader can not be null");
 
 	const PixelShaderId& id = m_pixel_shaders_id_table.create();
 
@@ -368,7 +391,7 @@ PixelShaderId GLESRenderer::create_pixel_shader(const char* program)
 
 		Log::e("Pixel shader compilation failed.");
 		Log::e("Log: %s", info_log);
-		assert(0);
+		CE_ASSERT(0, "");
 	}
 
 	return id;	
@@ -377,7 +400,7 @@ PixelShaderId GLESRenderer::create_pixel_shader(const char* program)
 //-----------------------------------------------------------------------------
 void GLESRenderer::destroy_pixel_shader(PixelShaderId id)
 {
-	assert(m_pixel_shaders_id_table.has(id));
+	CE_ASSERT(m_pixel_shaders_id_table.has(id),  "Pixel shaders table does not have pixel shader %d", id);
 
 	PixelShader& gl_shader = m_pixel_shaders[id.index];
 
@@ -387,8 +410,8 @@ void GLESRenderer::destroy_pixel_shader(PixelShaderId id)
 //-----------------------------------------------------------------------------
 GPUProgramId GLESRenderer::create_gpu_program(VertexShaderId vs, PixelShaderId ps)
 {
-	assert(m_vertex_shaders_id_table.has(vs));
-	assert(m_pixel_shaders_id_table.has(ps));
+	CE_ASSERT(m_vertex_shaders_id_table.has(vs), "Vertex shaders table does not have vertex shader %d", vs);
+	CE_ASSERT(m_pixel_shaders_id_table.has(ps), "Pixel shaders table does not have pixel shader %d", ps);
 
 	const GPUProgramId id = m_gpu_programs_id_table.create();
 
@@ -414,6 +437,7 @@ GPUProgramId GLESRenderer::create_gpu_program(VertexShaderId vs, PixelShaderId p
 		glGetProgramInfoLog(gl_program.gl_object, 256, NULL, info_log);
 		Log::e("GPU program compilation failed.\n");
 		Log::e("Log: %s", info_log);
+		CE_ASSERT(0, "");
 	}
 
 	return id;
@@ -422,7 +446,7 @@ GPUProgramId GLESRenderer::create_gpu_program(VertexShaderId vs, PixelShaderId p
 //-----------------------------------------------------------------------------
 void GLESRenderer::destroy_gpu_program(GPUProgramId id)
 {
-	assert(m_gpu_programs_id_table.has(id));
+	CE_ASSERT(m_gpu_programs_id_table.has(id), "GPU programs table does not have gpu program %d", id);
 
 	GPUProgram& gl_program = m_gpu_programs[id.index];
 
@@ -432,7 +456,7 @@ void GLESRenderer::destroy_gpu_program(GPUProgramId id)
 //-----------------------------------------------------------------------------
 void GLESRenderer::set_gpu_program_bool_uniform(GPUProgramId id, const char* name, bool value)
 {
-	assert(m_gpu_programs_id_table.has(id));
+	CE_ASSERT(m_gpu_programs_id_table.has(id), "GPU programs table does not have gpu program %d", id);
 
 	const GLint uniform = find_gpu_program_uniform(m_gpu_programs[id.index].gl_object, name);
 
@@ -442,7 +466,7 @@ void GLESRenderer::set_gpu_program_bool_uniform(GPUProgramId id, const char* nam
 //-----------------------------------------------------------------------------
 void GLESRenderer::set_gpu_program_int_uniform(GPUProgramId id, const char* name, int value)
 {
-	assert(m_gpu_programs_id_table.has(id));
+	CE_ASSERT(m_gpu_programs_id_table.has(id), "GPU programs table does not have gpu program %d", id);
 
 	const GLint uniform = find_gpu_program_uniform(m_gpu_programs[id.index].gl_object, name);
 
@@ -452,7 +476,7 @@ void GLESRenderer::set_gpu_program_int_uniform(GPUProgramId id, const char* name
 //-----------------------------------------------------------------------------
 void GLESRenderer::set_gpu_program_vec2_uniform(GPUProgramId id, const char* name, const Vec2& value)
 {
-	assert(m_gpu_programs_id_table.has(id));
+	CE_ASSERT(m_gpu_programs_id_table.has(id), "GPU programs table does not have gpu program %d", id);
 
 	const GLint uniform = find_gpu_program_uniform(m_gpu_programs[id.index].gl_object, name);
 
@@ -462,7 +486,7 @@ void GLESRenderer::set_gpu_program_vec2_uniform(GPUProgramId id, const char* nam
 //-----------------------------------------------------------------------------
 void GLESRenderer::set_gpu_program_vec3_uniform(GPUProgramId id, const char* name, const Vec3& value)
 {
-	assert(m_gpu_programs_id_table.has(id));
+	CE_ASSERT(m_gpu_programs_id_table.has(id), "GPU programs table does not have gpu program %d", id);
 
 	const GLint uniform = find_gpu_program_uniform(m_gpu_programs[id.index].gl_object, name);
 
@@ -472,7 +496,7 @@ void GLESRenderer::set_gpu_program_vec3_uniform(GPUProgramId id, const char* nam
 //-----------------------------------------------------------------------------
 void GLESRenderer::set_gpu_program_vec4_uniform(GPUProgramId id, const char* name, const Vec4& value)
 {
-	assert(m_gpu_programs_id_table.has(id));
+	CE_ASSERT(m_gpu_programs_id_table.has(id), "GPU programs table does not have gpu program %d", id);
 
 	const GLint uniform = find_gpu_program_uniform(m_gpu_programs[id.index].gl_object, name);
 
@@ -482,7 +506,7 @@ void GLESRenderer::set_gpu_program_vec4_uniform(GPUProgramId id, const char* nam
 //-----------------------------------------------------------------------------
 void GLESRenderer::set_gpu_porgram_mat3_uniform(GPUProgramId id, const char* name, const Mat3& value)
 {
-	assert(m_gpu_programs_id_table.has(id));
+	CE_ASSERT(m_gpu_programs_id_table.has(id), "GPU programs table does not have gpu program %d", id);
 
 	const GLint uniform = find_gpu_program_uniform(m_gpu_programs[id.index].gl_object, name);
 
@@ -492,7 +516,7 @@ void GLESRenderer::set_gpu_porgram_mat3_uniform(GPUProgramId id, const char* nam
 //-----------------------------------------------------------------------------
 void GLESRenderer::set_gpu_program_mat4_uniform(GPUProgramId id, const char* name, const Mat4& value)
 {
-	assert(m_gpu_programs_id_table.has(id));
+	CE_ASSERT(m_gpu_programs_id_table.has(id), "GPU programs table does not have gpu program %d", id);
 
 	const GLint uniform = find_gpu_program_uniform(m_gpu_programs[id.index].gl_object, name);
 
@@ -502,7 +526,7 @@ void GLESRenderer::set_gpu_program_mat4_uniform(GPUProgramId id, const char* nam
 //-----------------------------------------------------------------------------
 void GLESRenderer::set_gpu_program_sampler_uniform(GPUProgramId id, const char* name, uint32_t value)
 {
-	assert(m_gpu_programs_id_table.has(id));
+	CE_ASSERT(m_gpu_programs_id_table.has(id), "GPU programs table does not have gpu program %d", id);
 
 	const GLint uniform = find_gpu_program_uniform(m_gpu_programs[id.index].gl_object, name);
 
@@ -512,7 +536,7 @@ void GLESRenderer::set_gpu_program_sampler_uniform(GPUProgramId id, const char*
 //-----------------------------------------------------------------------------
 void GLESRenderer::bind_gpu_program(GPUProgramId id) const
 {
-	assert(m_gpu_programs_id_table.has(id));
+	CE_ASSERT(m_gpu_programs_id_table.has(id), "GPU programs table does not have gpu program %d", id);
 
 	const GPUProgram& gl_program = m_gpu_programs[id.index];
 
@@ -573,7 +597,7 @@ void GLESRenderer::set_ambient_light(const Color4& color)
 //-----------------------------------------------------------------------------
 void GLESRenderer::bind_texture(uint32_t unit, TextureId texture)
 {
-	assert(m_textures_id_table.has(texture));
+	CE_ASSERT(m_textures_id_table.has(texture), "Textures table does not have texture %d", texture);
 
 	if (!activate_texture_unit(unit))
 	{
@@ -817,7 +841,7 @@ void GLESRenderer::set_matrix(MatrixType type, const Mat4& matrix)
 		default:
 		{
 			break;
-			assert(0);
+			CE_ASSERT(0, "");
 		}
 	}
 }
@@ -825,26 +849,11 @@ void GLESRenderer::set_matrix(MatrixType type, const Mat4& matrix)
 //-----------------------------------------------------------------------------
 void GLESRenderer::bind_vertex_buffer(VertexBufferId vb) const
 {
-<<<<<<< HEAD
-<<<<<<< HEAD
-	assert(m_vertex_buffers_id_table.has(vb));
-=======
-	ce_assert(vertices != NULL);
-	ce_assert(indices != NULL);
-=======
-	CE_ASSERT(vertices != NULL);
-	CE_ASSERT(indices != NULL);
->>>>>>> master
-
-	glEnableClientState(GL_VERTEX_ARRAY);
-	glEnableClientState(GL_NORMAL_ARRAY);
-	glEnableClientState(GL_TEXTURE_COORD_ARRAY);
-	glEnableClientState(GL_COLOR_ARRAY);
->>>>>>> master
+	CE_ASSERT(m_vertex_buffers_id_table.has(vb), "Vertex buffers table does not have vertex buffer %d", vb);
 
 	const VertexBuffer& vertex_buffer = m_vertex_buffers[vb.index];
 
-	glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer.gl_object);
+	GL_CHECK(glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer.gl_object));
 
 	switch (vertex_buffer.format)
 	{
@@ -884,7 +893,7 @@ void GLESRenderer::bind_vertex_buffer(VertexBufferId vb) const
 		}
 		default:
 		{
-			assert(0);
+			CE_ASSERT(0, "");
 			break;
 		}
 	}
@@ -893,7 +902,7 @@ void GLESRenderer::bind_vertex_buffer(VertexBufferId vb) const
 //-----------------------------------------------------------------------------
 void GLESRenderer::draw_triangles(IndexBufferId id) const
 {
-	assert(m_index_buffers_id_table.has(id));
+	CE_ASSERT(m_index_buffers_id_table.has(id), "Index buffers table does not have index buffer %d", id);
 
 	const IndexBuffer& index_buffer = m_index_buffers[id.index];
 
@@ -905,7 +914,7 @@ void GLESRenderer::draw_triangles(IndexBufferId id) const
 //-----------------------------------------------------------------------------
 // void GLESRenderer::bind_render_buffer(RenderBufferId id) const
 // {
-// 	assert(m_render_buffers_id_table.has(id));
+// 	CE_ASSERT(m_render_buffers_id_table.has(id));
 
 // 	const GLRenderBuffer& render_buffer = m_render_buffers[id.index];
 // }
@@ -997,7 +1006,7 @@ GLint GLESRenderer::find_gpu_program_uniform(GLuint program, const char* name) c
 {
 	GLint uniform = glGetUniformLocation(program, name);
 
-	assert(uniform != -1);
+	CE_ASSERT(uniform != -1, "Uniform not found in GPU program %d", program);
 
 	return uniform;
 }

+ 2 - 2
src/renderers/gles/GLESRenderer.h

@@ -36,7 +36,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include "VertexShader.h"
 #include "PixelShader.h"
 #include "IdTable.h"
-#include "MallocAllocator.h"
+#include "HeapAllocator.h"
 #include "Resource.h"
 
 namespace crown
@@ -208,7 +208,7 @@ private:
 
 private:
 
-	MallocAllocator		m_allocator;
+	HeapAllocator		m_allocator;
 
 	// Matrices
 	Mat4				m_matrix[MT_COUNT];

+ 6 - 30
src/renderers/gles/GLESUtils.h

@@ -26,14 +26,8 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #pragma once
 
-<<<<<<< HEAD
 #include <GLES2/gl2.h>
-#include <cassert>
-
-=======
-#include <GLES/gl.h>
 #include "Assert.h"
->>>>>>> master
 #include "Texture.h"
 #include "Material.h"
 #include "PixelFormat.h"
@@ -70,7 +64,7 @@ private:
 //-----------------------------------------------------------------------------
 inline GLenum GLES::compare_function(CompareFunction function)
 {
-	CE_ASSERT(function < CF_COUNT);
+	CE_ASSERT(function < CF_COUNT, "Compare function not supported");
 
 	return COMPARE_FUNCTION_TABLE[function];
 }
@@ -78,7 +72,7 @@ inline GLenum GLES::compare_function(CompareFunction function)
 //-----------------------------------------------------------------------------
 inline GLenum GLES::blend_function(BlendFunction function)
 {
-	CE_ASSERT(function < BF_COUNT);
+	CE_ASSERT(function < BF_COUNT, "Blend function not supported");
 
 	return BLEND_FUNCTION_TABLE[function];
 }
@@ -86,15 +80,8 @@ inline GLenum GLES::blend_function(BlendFunction function)
 //-----------------------------------------------------------------------------
 inline GLenum GLES::blend_equation(BlendEquation equation)
 {
-<<<<<<< HEAD
-<<<<<<< HEAD
-	assert(equation < BE_COUNT);
-=======
-	ce_assert(mode < TM_COUNT);
->>>>>>> master
-=======
-	CE_ASSERT(mode < TM_COUNT);
->>>>>>> master
+
+	CE_ASSERT(equation < BE_COUNT, "Blend equation not supported");
 
 	return BLEND_EQUATION_TABLE[equation];
 }
@@ -102,7 +89,7 @@ inline GLenum GLES::blend_equation(BlendEquation equation)
 //-----------------------------------------------------------------------------
 inline GLenum GLES::texture_wrap(TextureWrap wrap)
 {
-	CE_ASSERT(wrap < TW_COUNT);
+	CE_ASSERT(wrap < TW_COUNT, "Texture wrapper not supported");
 
 	return TEXTURE_WRAP_TABLE[wrap];
 }
@@ -110,24 +97,13 @@ inline GLenum GLES::texture_wrap(TextureWrap wrap)
 //-----------------------------------------------------------------------------
 inline void GLES::texture_filter(TextureFilter filter, GLint& minFilter, GLint& magFilter)
 {
-	CE_ASSERT(filter < TF_COUNT);
+	CE_ASSERT(filter < TF_COUNT, "Texture filter not supported");
 
 	minFilter = TEXTURE_MIN_FILTER_TABLE[filter];
 	magFilter = TEXTURE_MAG_FILTER_TABLE[filter];
 }
 
 //-----------------------------------------------------------------------------
-<<<<<<< HEAD
-=======
-inline GLenum GLES::fog_mode(FogMode mode)
-{
-	CE_ASSERT(mode < FM_COUNT);
-
-	return FOG_MODE_TABLE[mode];
-}
-
-//-----------------------------------------------------------------------------
->>>>>>> master
 inline GLenum GLES::pixel_format(PixelFormat format)
 {
 	switch (format)

+ 97 - 0
src/renderers/gles/egl/GLContext.cpp

@@ -0,0 +1,97 @@
+/*
+Copyright (c) 2013 Daniele Bartolini, Michele Rossi
+Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#include <GLES2/gl2.h>
+
+#include "GLContext.h"
+
+namespace crown
+{
+
+static ANativeWindow* awindow = NULL;
+
+//-----------------------------------------------------------------------------
+void set_android_window(ANativeWindow* window)
+{
+	awindow = window;
+}
+
+//-----------------------------------------------------------------------------
+GLContext::GLContext() :
+	num_configs(0)
+{
+}
+
+//-----------------------------------------------------------------------------
+void GLContext::create_context()
+{
+	EGLint format;
+
+	// Screen format rgbx8888 with no alpha channel,
+	// maybe it is wrong but is for testing
+	EGLint attrib_list[]= { EGL_RED_SIZE,        8,
+                            EGL_GREEN_SIZE,      8,
+                            EGL_BLUE_SIZE,       8,
+                            EGL_SURFACE_TYPE,    EGL_WINDOW_BIT,
+                            EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
+                            EGL_NONE};
+
+    EGLint attributes[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };
+
+    display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
+
+    eglInitialize(display, NULL, NULL);
+
+    eglBindAPI(EGL_OPENGL_ES_API);
+
+    eglChooseConfig(display, attrib_list, &config, 1, &num_configs);
+
+	eglGetConfigAttrib(display, config, EGL_NATIVE_VISUAL_ID, &format);
+
+	ANativeWindow_setBuffersGeometry(awindow, 0, 0, format);
+
+    context = eglCreateContext(display, config, EGL_NO_CONTEXT, attributes);
+
+	surface = eglCreateWindowSurface(display, config, (EGLNativeWindowType)awindow, NULL);
+
+    eglMakeCurrent(display, surface, surface, context);
+}
+
+//-----------------------------------------------------------------------------
+void GLContext::destroy_context()
+{
+ 	eglDestroyContext(display, context);
+ 	eglDestroySurface(display, surface);
+ 	eglTerminate(display);
+}
+
+//-----------------------------------------------------------------------------
+void GLContext::swap_buffers()
+{
+   	eglSwapBuffers(display, surface);
+}
+
+}

+ 57 - 0
src/renderers/gles/egl/GLContext.h

@@ -0,0 +1,57 @@
+/*
+Copyright (c) 2013 Daniele Bartolini, Michele Rossi
+Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#pragma once
+
+#include <EGL/egl.h>
+#include <android/native_window.h>
+
+namespace crown
+{
+
+void set_android_window(ANativeWindow* window);
+
+class GLContext
+{
+public:
+					GLContext();
+
+	void			create_context();
+	void			destroy_context();
+
+	void			swap_buffers();
+
+private:
+
+	EGLDisplay 		display;
+    EGLSurface 		surface;
+    EGLConfig 		config;
+    EGLContext 		context;
+
+    int32_t			num_configs;
+};
+
+} // namespace crown

+ 4 - 12
tests/CMakeLists.txt

@@ -8,27 +8,19 @@ enable_testing()
 
 add_executable(allocators allocators.cpp)
 add_executable(containers containers.cpp)
-#add_executable(messages messages.cpp)
 add_executable(compressors compressors.cpp)
 add_executable(strings strings.cpp)
 add_executable(paths paths.cpp)
-add_executable(script script.cpp)
 
 target_link_libraries(allocators crown)
 target_link_libraries(containers crown)
-#target_link_libraries(messages crown)
 target_link_libraries(compressors crown)
 target_link_libraries(strings crown)
 target_link_libraries(paths crown)
 
-link_directories(${CROWN_THIRD}/luajit/lib)
-include_directories(${CROWN_THIRD}/luajit/include/luajit-2.0)
-target_link_libraries(script crown luajit-5.1)
-
 add_test(allocators-test ${EXECUTABLE_OUTPUT_PATH}/allocators)
-add_test(containers-test containers)
-#add_test(messages-test messages)
-add_test(compressors-test compressors)
-add_test(strings-test strings)
-add_test(paths-test paths)
+add_test(containers-test ${EXECUTABLE_OUTPUT_PATH}/containers)
+add_test(compressors-test ${EXECUTABLE_OUTPUT_PATH}/compressors)
+add_test(strings-test ${EXECUTABLE_OUTPUT_PATH}/strings)
+add_test(paths-test ${EXECUTABLE_OUTPUT_PATH}/paths)
 

+ 8 - 3
third/win64/CMakeLists.txt

@@ -7,8 +7,13 @@ install (FILES 	luajit/include/luajit-2.0/lua.hpp
 				luajit/include/luajit-2.0/luajit.h
 				luajit/include/luajit-2.0/lualib.h DESTINATION include/crown/luajit)
 				
-#install (DIRECTORY luajit/lib/pkgconfig DESTINATION lib/crown)
-install (FILES luajit/lib/luajit-5.1.dll DESTINATION lib/crown)
+install (FILES luajit/lib/lua51.dll DESTINATION lib/crown)
+if (WINDOWS)
+install (FILES luajit/lib/lua51.dll DESTINATION bin)
+# HACK !!!
+# Don't know why, but crown-win.exe need this...
+install (FILES luajit/lib/luajit-5.1.dll DESTINATION bin)	
+endif (WINDOWS)
 
 install (PROGRAMS luajit/bin/luajit.exe DESTINATION bin)
-install (DIRECTORY luajit/share/luajit-2.0.1/jit DESTINATION bin)
+install (DIRECTORY luajit/share/luajit-2.0.1/jit DESTINATION bin)

BIN=BIN
third/win64/luajit/lib/lua51.dll


BIN=BIN
third/win64/luajit/lib/lua51.lib


+ 0 - 136
third/win64/luajit/lib/luajit-5.1.def

@@ -1,136 +0,0 @@
-EXPORTS
-luaJIT_setmode
-luaJIT_version_2_0_1
-luaL_addlstring
-luaL_addstring
-luaL_addvalue
-luaL_argerror
-luaL_buffinit
-luaL_callmeta
-luaL_checkany
-luaL_checkinteger
-luaL_checklstring
-luaL_checknumber
-luaL_checkoption
-luaL_checkstack
-luaL_checktype
-luaL_checkudata
-luaL_error
-luaL_execresult
-luaL_fileresult
-luaL_findtable
-luaL_getmetafield
-luaL_gsub
-luaL_loadbuffer
-luaL_loadbufferx
-luaL_loadfile
-luaL_loadfilex
-luaL_loadstring
-luaL_newmetatable
-luaL_newstate
-luaL_openlib
-luaL_openlibs
-luaL_optinteger
-luaL_optlstring
-luaL_optnumber
-luaL_prepbuffer
-luaL_pushresult
-luaL_ref
-luaL_register
-luaL_traceback
-luaL_typerror
-luaL_unref
-luaL_where
-lua_atpanic
-lua_call
-lua_checkstack
-lua_close
-lua_concat
-lua_cpcall
-lua_createtable
-lua_dump
-lua_equal
-lua_error
-lua_gc
-lua_getallocf
-lua_getfenv
-lua_getfield
-lua_gethook
-lua_gethookcount
-lua_gethookmask
-lua_getinfo
-lua_getlocal
-lua_getmetatable
-lua_getstack
-lua_gettable
-lua_gettop
-lua_getupvalue
-lua_insert
-lua_iscfunction
-lua_isnumber
-lua_isstring
-lua_isuserdata
-lua_lessthan
-lua_load
-lua_loadx
-lua_newstate
-lua_newthread
-lua_newuserdata
-lua_next
-lua_objlen
-lua_pcall
-lua_pushboolean
-lua_pushcclosure
-lua_pushfstring
-lua_pushinteger
-lua_pushlightuserdata
-lua_pushlstring
-lua_pushnil
-lua_pushnumber
-lua_pushstring
-lua_pushthread
-lua_pushvalue
-lua_pushvfstring
-lua_rawequal
-lua_rawget
-lua_rawgeti
-lua_rawset
-lua_rawseti
-lua_remove
-lua_replace
-lua_resume
-lua_setallocf
-lua_setfenv
-lua_setfield
-lua_sethook
-lua_setlocal
-lua_setmetatable
-lua_settable
-lua_settop
-lua_setupvalue
-lua_status
-lua_toboolean
-lua_tocfunction
-lua_tointeger
-lua_tolstring
-lua_tonumber
-lua_topointer
-lua_tothread
-lua_touserdata
-lua_type
-lua_typename
-lua_upvalueid
-lua_upvaluejoin
-lua_xmove
-lua_yield
-luaopen_base
-luaopen_bit
-luaopen_debug
-luaopen_ffi
-luaopen_io
-luaopen_jit
-luaopen_math
-luaopen_os
-luaopen_package
-luaopen_string
-luaopen_table

BIN=BIN
third/win64/luajit/lib/luajit-5.1.exp


BIN=BIN
third/win64/luajit/lib/luajit-5.1.lib