From 200c6a6186fb6ef5cfc7f7ebed377e3214af8e73 Mon Sep 17 00:00:00 2001 From: Carlos Ballesteros Velasco Date: Tue, 18 Jun 2024 21:23:49 +0200 Subject: [PATCH] Update to korlibs 6.0.0-alpha4 and split korge into korge and korge-core (#2243) * Update to korlibs 6.0.0-alpha4 * Split korge into korge-core and korge * Add KorgeCore function to start Korge without the views system --- gradle/libs.versions.toml | 2 +- korge-core/build.gradle.kts | 31 ++++ .../datastructure/_Datastructure_event.kt | 0 .../datastructure/closeable/Closeable.kt | 0 .../korlibs/datastructure/lock/LockAlias.kt | 0 .../datastructure/thread/ThreadAlias.kt | 0 .../src/korlibs/event/EventListener.kt | 0 .../src/korlibs/event/Events.kt | 0 .../src/korlibs/event/InputGamepad.kt | 0 .../src/korlibs/event/Key.kt | 0 .../src/korlibs/event/MouseButton.kt | 0 .../src/korlibs/event/SoftKeyboard.kt | 0 .../gamepad/DarwinMacosGameController.kt | 0 .../gamepad/X11JoyGameControllerCommon.kt | 7 +- .../gamepad/XInputGamepadEventAdapter.kt | 0 .../src/korlibs/graphics/AG.kt | 0 .../src/korlibs/graphics/AGObjects.kt | 0 .../korlibs/graphics/AGProgramWithUniform.kt | 0 .../src/korlibs/graphics/AGState.kt | 0 .../src/korlibs/graphics/AGStats.kt | 0 .../src/korlibs/graphics/AGTextureDrawer.kt | 0 .../graphics/AGVertexArrayObjectFlattener.kt | 0 .../src/korlibs/graphics/DefaultShaders.kt | 0 .../graphics/annotation/KoragExperimental.kt | 0 .../src/korlibs/graphics/gl/AGOpengl.kt | 0 .../korlibs/graphics/gl/AGOpenglConvert.kt | 0 .../korlibs/graphics/gl/AGOpenglFactory.kt | 0 .../src/korlibs/graphics/gl/GLObjects.kt | 0 .../korlibs/graphics/gl/GLShaderCompiler.kt | 0 .../src/korlibs/graphics/log/AGDummy.kt | 0 .../src/korlibs/graphics/log/AGLog.kt | 0 .../metal/shader/BaseMetalShaderGenerator.kt | 0 .../metal/shader/MetalShaderBodyGenerator.kt | 0 .../shader/MetalShaderBufferInputLayouts.kt | 7 +- .../metal/shader/MetalShaderGenerator.kt | 5 +- .../shader/MetalShaderStructureGenerator.kt | 0 .../korlibs/graphics/metal/shader/Shader.kt | 8 ++ .../korlibs/graphics/shader/UniformBlock.kt | 0 .../korlibs/graphics/shader/gl/GLVariant.kt | 0 .../src/korlibs/graphics/shader/gl/GlslExt.kt | 0 .../graphics/shader/gl/GlslGenerator.kt | 0 .../src/korlibs/graphics/shader/shaders.kt | 0 .../src/korlibs/io/annotations/Keep.kt | 0 .../src/korlibs/io/annotations/KorInternal.kt | 0 .../src/korlibs/io/async/AsyncAlias.kt | 0 .../src/korlibs/io/lang/Disposable.kt | 0 .../src/korlibs/kgl/KmlBufferExt.kt | 0 .../src/korlibs/kgl/KmlGl.kt | 0 .../src/korlibs/kgl/KmlGlCached.kt | 0 .../src/korlibs/kgl/KmlGlContext.kt | 0 .../src/korlibs/kgl/KmlGlDummy.kt | 0 .../src/korlibs/kgl/KmlGlExt.kt | 0 .../src/korlibs/kgl/KmlGlProxy.kt | 0 .../src/korlibs/kgl/KmlGlState.kt | 0 .../src/korlibs/kgl/KmlGlUtil.kt | 0 .../src/korlibs/kgl/internal/internal.kt | 0 korge-core/src/korlibs/korge/KorgeCore.kt | 39 +++++ .../src/korlibs/korge/KorgeReload.kt | 15 +- .../korge/annotations/KorgeExperimental.kt | 0 .../korlibs/korge/bitmapfont/BitmapFontExt.kt | 2 +- .../korge/bitmapfont/DebugBitmapFont.kt | 0 .../src/korlibs/korge/blend/BlendMode.kt | 131 +++++++++++++++++ .../src/korlibs/korge/input/Gestures.kt | 0 .../src/korlibs/korge/input/Input.kt | 4 +- .../korlibs/korge/internal/DefaultViewport.kt | 2 +- .../korlibs/korge/internal/KorgeInternal.kt | 0 .../korlibs/korge/internal/KorgeUntested.kt | 0 .../src/korlibs/korge/internal/KorgeUnused.kt | 0 .../src/korlibs/korge/logger/LoggerExt.kt | 0 .../korlibs/korge/render/AgAutoFreeManager.kt | 4 +- .../korge/render/AgBitmapTextureManager.kt | 12 +- .../korlibs/korge/render/AgBufferManager.kt | 0 .../korlibs/korge/render/BatchBuilder2D.kt | 5 +- .../src/korlibs/korge/render/BitmapExt.kt | 0 .../korlibs/korge/render/BoundsProvider.kt | 59 ++++++++ .../korlibs/korge/render/LineRenderBatcher.kt | 7 +- .../src/korlibs/korge/render/RenderContext.kt | 15 +- .../korlibs/korge/render/RenderContext2D.kt | 14 +- .../src/korlibs/korge/render/SDFShaders.kt | 0 .../src/korlibs/korge/render/Texture.kt | 0 .../korge/render/TextureWithBitmapSlice.kt | 0 .../korge/render/TexturedVertexArray.kt | 0 .../src/korlibs/korge/render/VertexInfo.kt | 0 .../src/korlibs/korge/resources/Path.kt | 0 .../korlibs/korge/resources/ResourcesExt.kt | 0 .../korlibs/korge/resources/ResourcesRoot.kt | 0 .../korlibs/korge/service/storage/IStorage.kt | 0 .../korge/service/storage/InmemoryStorage.kt | 0 .../service/vibration/NativeVibration.kt | 9 +- .../src/korlibs/korge/stat/Stats.kt | 0 .../korge/tests/TestCoroutineDispatcher.kt | 0 .../src/korlibs/korge/tween/tweenbase.kt | 5 +- .../render/DeviceDimensionsProvider.kt | 0 .../src/korlibs/render/DialogInterface.kt | 0 .../src/korlibs/render/GameWindow.kt | 3 +- .../render/GameWindowCoroutineDispatcher.kt | 0 .../src/korlibs/render/Korgw.kt | 0 .../SyncEventLoopCoroutineDispatcher.kt | 0 .../src/korlibs/render/TouchEventHandler.kt | 0 .../src/korlibs/render/event/UpdateEvent.kt | 21 +++ .../src/korlibs/render/jvmEngine.kt | 0 .../src@android/korlibs/graphics/AGAndroid.kt | 0 .../graphics/gl/AGOpenglFactoryAndroid.kt | 0 .../src@android/korlibs/kgl/KmlGlAndroid.kt | 0 .../korlibs/kgl/KmlGlContextAndroid.kt | 0 .../korge/KorgeReload_getReloadedClass.kt | 0 .../service/vibration/NativeVibration.kt | 9 +- .../korlibs/render/AndroidGameController.kt | 0 .../korlibs/render/AndroidKeyMap.kt | 0 .../render/DefaultGameWindowAndroid.kt | 0 .../korlibs/render/DialogInterfaceImpl.kt | 0 .../korlibs/render/KorgwActivity.kt | 0 .../korlibs/render/KorgwSurfaceView.kt | 0 .../graphics/gl/AGOpenglFactoryNative.kt | 0 .../korlibs/kgl/KmlGlContextAppleMobile.kt | 0 .../src@darwin/korlibs/kgl/KmlGlNative.kt | 0 .../korlibs/korge/KorgeReloadNative.kt | 0 .../korge/native/KorgeSimpleNativeSyncIO.kt | 0 .../service/vibration/NativeVibration.kt | 5 +- .../src@darwin/korlibs/metal/AGMetal.kt | 0 .../korlibs/metal/AGMetalConverter.kt | 0 .../src@darwin/korlibs/metal/MTLBuffer.kt | 0 .../src@darwin/korlibs/metal/MetalProgram.kt | 0 .../metal/shader/MetalShaderCompiler.kt | 0 .../render/DarwinGameControllerNative.kt | 0 .../korlibs/render/DefaultGameWindowIos.kt | 0 .../korlibs/render/DialogInterfaceIos.kt | 0 .../src@darwin/korlibs/render/IosKeyMap.kt | 0 .../render/DefaultGameWindowIosTools.kt | 0 .../datastructure/event/JsEventLoop.kt | 0 .../korlibs/graphics/gl/AGOpenglFactory.kt | 0 .../src@js/korlibs/graphics/gl/GlExt.kt | 0 .../src@js/korlibs/kgl/KmlGlContextJs.kt | 0 .../src@js/korlibs/kgl/KmlGlJsCanvas.kt | 0 .../korge/KorgeReload_getReloadedClass.kt | 0 .../service/vibration/NativeVibration.kt | 4 +- .../korlibs/render/DefaultGameWindowJs.kt | 0 .../korlibs/render/DialogInterfaceJs.kt | 0 .../render/internal/KorgwJsInternal.kt | 0 .../src@jvm/korlibs/event/AwtKeyMap.kt | 0 .../korlibs/graphics/gl/AGOpenglFactory.kt | 0 .../src@jvm/korlibs/graphics/metal/AGMetal.kt | 0 .../korlibs/kgl/KmlGlContextDefault.kt | 0 .../src@jvm/korlibs/korge/EnsureAddOpens.kt | 0 .../korge/KorgeReload_getReloadedClass.kt | 2 +- .../korge/atlas/AtlasResourceProcessor.kt | 0 .../korge/plugin/KorgePluginExtension.kt | 0 .../korge/plugin/KorgePluginExtensions.kt | 0 .../korge/resources/ResourceProcessor.kt | 0 .../resources/ResourceProcessorRunner.kt | 0 .../korge/resources/ResourceVersion.kt | 0 .../service/vibration/NativeVibration.kt | 9 +- .../korlibs/render/DefaultGameWindowJvm.kt | 0 .../korlibs/render/awt/AwtAGOpenglCanvas.kt | 2 +- .../src@jvm/korlibs/render/awt/AwtAg.kt | 0 .../src@jvm/korlibs/render/awt/AwtExt.kt | 0 .../korlibs/render/awt/AwtFrameTools.kt | 0 .../korlibs/render/awt/AwtGameWindow.kt | 0 .../korlibs/render/awt/BaseAwtGameWindow.kt | 0 .../render/awt/DesktopGamepadUpdater.kt | 0 .../korlibs/render/awt/DialogInterfaceAwt.kt | 0 .../src@jvm/korlibs/render/awt/GLCanvas.kt | 2 - .../korlibs/render/awt/GLCanvasGameWindow.kt | 0 .../korlibs/render/awt/NewAwtGameWindow.kt | 0 .../src@jvm/korlibs/render/osx/Cocoa.kt | 0 .../render/osx/DialogInterfaceJvmCocoa.kt | 0 .../korlibs/render/osx/MacosGLContext.kt | 0 .../korlibs/render/osx/MacosGameWindow.kt | 0 .../korlibs/render/osx/OSXDisplayLink.kt | 0 .../src@jvm/korlibs/render/osx/metal/MTL.kt | 0 .../korlibs/render/osx/metal/MTLExt.kt | 0 .../korlibs/render/platform/AwtTools.kt | 0 .../render/platform/BaseOpenglContext.kt | 0 .../korlibs/render/platform/INativeGL.kt | 0 .../korlibs/render/platform/NativeKgl.kt | 0 .../src@jvm/korlibs/render/win32/Win32.kt | 0 .../korlibs/render/win32/Win32GameWindow.kt | 0 .../korlibs/render/win32/Win32Tools.kt | 0 .../korlibs/render/x11/X11Constants.kt | 0 .../korlibs/render/x11/X11GameWindowJvm.kt | 0 .../korlibs/render/x11/X11OpenglContext.kt | 0 .../_Datastructure_event.jvmAndroid.kt | 0 .../src@jvmAndroid/korlibs/kgl/KmlGlTools.kt | 0 .../korlibs/kgl/KmlGlNativeExpect.kt | 0 .../src@native/korlibs/kgl/KmlGlNativeExt.kt | 0 .../_Datastructure_event.native.kt | 0 .../render/DefaultGameWindowIosTools.kt | 0 .../datastructure/event/WasmJsEventLoop.kt | 0 .../graphics/gl/AGOpenglFactoryWasm.kt | 0 .../src@wasmJs/korlibs/graphics/gl/GlExt.kt | 0 .../src@wasmJs/korlibs/kgl/KmlGlContextJs.kt | 0 .../src@wasmJs/korlibs/kgl/KmlGlWasmCanvas.kt | 0 .../korge/KorgeReload_getReloadedClass.kt | 0 .../service/vibration/NativeVibration.kt | 4 +- .../korlibs/render/DefaultGameWindowWasm.kt | 0 .../korlibs/render/DialogInterfaceJs.kt | 0 .../render/internal/KorgwJsInternal.kt | 0 .../render/internal/KorgwWasmInternal.kt | 0 korge-core/test/korlibs/SkipIOTest.kt | 7 + korge-core/test/korlibs/TestExt.kt | 64 +++++++++ .../datastructure/event/SyncEventLoopTest.kt | 0 .../test/korlibs/event/EventListenerTest.kt | 0 .../test/korlibs/event/EventsTest.kt | 0 .../test/korlibs/event/KorevTest.kt | 0 .../test/korlibs/event/ScrollDeltaTest.kt | 0 .../test/korlibs/event/TouchBuilderTest.kt | 0 .../test/korlibs/graphics/AGNewUniformTest.kt | 0 .../test/korlibs/graphics/AGOpenglTest.kt | 0 .../test/korlibs/graphics/AGStateTest.kt | 0 .../test/korlibs/graphics/AGTest.kt | 0 .../korlibs/graphics/AGUniformBlockTest.kt | 0 .../test/korlibs/graphics/AGValueTest.kt | 0 .../AGVertexArrayObjectFlattenerTest.kt | 0 .../MetalShaderBufferInputLayoutsTest.kt | 0 .../metal/shader/MetalShaderGeneratorTest.kt | 0 .../MetalShaderStructureGeneratorTest.kt | 0 .../graphics/shader/VertexLayoutTest.kt | 0 .../korlibs/graphics/shaders/ShadersTest.kt | 0 .../io/file/registry/WindowsRegistryTest.kt | 0 .../test/korlibs/kgl/KglOffscreenTest.kt | 0 .../test/korlibs/kgl/KglTest.kt | 0 .../test/korlibs/render/AGUniformsTest.kt | 0 .../test/korlibs/render/GameWindowTest.kt | 0 .../test/korlibs/render/KorgwSampleMain.kt | 0 .../test/korlibs/render/KorgwTest.kt | 0 .../SyncEventLoopCoroutineDispatcherTest.kt | 0 .../render/x11/LinuxJoyEventAdapterTest.kt | 2 + .../test/korlibs/test/AnySubject.kt | 0 .../test/korlibs/test/BooleanSubject.kt | 0 .../test/korlibs/test/CollectionSubject.kt | 0 .../test/korlibs/test/DoubleSubject.kt | 0 .../test/korlibs/test/MapSubject.kt | 0 .../test/korlibs/test/truth.kt | 0 korge-sandbox/src/Main.kt | 8 ++ korge-sandbox/src/samples/MainShape2d.kt | 14 +- korge/build.gradle.kts | 18 +-- .../services/com.soywiz.korag.AGFactory | 1 - .../korlibs/graphics/metal/shader/Shader.kt | 7 - korge/src/korlibs/korge/Korge.kt | 4 + korge/src/korlibs/korge/KorgeVersion.kt | 3 - .../korge/render/RenderContext2DExt.kt | 12 ++ .../korlibs/korge/render/RenderContextExt.kt | 16 +++ .../korge/service/storage/NativeStorage.kt | 1 + .../service/vibration/NativeVibrationViews.kt | 6 + korge/src/korlibs/korge/view/BlendMode.kt | 134 +----------------- korge/src/korlibs/korge/view/Circle.kt | 3 +- korge/src/korlibs/korge/view/Views.kt | 68 +-------- korge/src/korlibs/korge/view/fast/FSprites.kt | 1 + .../korge/view/filter/DropShadowFilter.kt | 2 +- .../korlibs/korge/view/vector/GpuShapeView.kt | 3 +- .../service/storage/DarwinNativeStorage.kt | 0 .../service/storage/NativeStorageNative.kt | 0 .../korge/tests/enrichTestGameWindow.kt | 0 korge/src@jvm/korlibs/korge/KorgeExtJvm.kt | 2 + .../korlibs/korge/awt/ViewsDebugger.kt | 1 + .../korge/view/FixedSizeContainerTest.kt | 2 +- .../korlibs/korge/view/tiles/TileMapTest.kt | 4 +- settings.gradle.kts | 1 + 258 files changed, 509 insertions(+), 319 deletions(-) create mode 100644 korge-core/build.gradle.kts rename {korge => korge-core}/src/korlibs/datastructure/_Datastructure_event.kt (100%) rename {korge => korge-core}/src/korlibs/datastructure/closeable/Closeable.kt (100%) rename {korge => korge-core}/src/korlibs/datastructure/lock/LockAlias.kt (100%) rename {korge => korge-core}/src/korlibs/datastructure/thread/ThreadAlias.kt (100%) rename {korge => korge-core}/src/korlibs/event/EventListener.kt (100%) rename {korge => korge-core}/src/korlibs/event/Events.kt (100%) rename {korge => korge-core}/src/korlibs/event/InputGamepad.kt (100%) rename {korge => korge-core}/src/korlibs/event/Key.kt (100%) rename {korge => korge-core}/src/korlibs/event/MouseButton.kt (100%) rename {korge => korge-core}/src/korlibs/event/SoftKeyboard.kt (100%) rename {korge => korge-core}/src/korlibs/event/gamepad/DarwinMacosGameController.kt (100%) rename {korge => korge-core}/src/korlibs/event/gamepad/X11JoyGameControllerCommon.kt (96%) rename {korge => korge-core}/src/korlibs/event/gamepad/XInputGamepadEventAdapter.kt (100%) rename {korge => korge-core}/src/korlibs/graphics/AG.kt (100%) rename {korge => korge-core}/src/korlibs/graphics/AGObjects.kt (100%) rename {korge => korge-core}/src/korlibs/graphics/AGProgramWithUniform.kt (100%) rename {korge => korge-core}/src/korlibs/graphics/AGState.kt (100%) rename {korge => korge-core}/src/korlibs/graphics/AGStats.kt (100%) rename {korge => korge-core}/src/korlibs/graphics/AGTextureDrawer.kt (100%) rename {korge => korge-core}/src/korlibs/graphics/AGVertexArrayObjectFlattener.kt (100%) rename {korge => korge-core}/src/korlibs/graphics/DefaultShaders.kt (100%) rename {korge => korge-core}/src/korlibs/graphics/annotation/KoragExperimental.kt (100%) rename {korge => korge-core}/src/korlibs/graphics/gl/AGOpengl.kt (100%) rename {korge => korge-core}/src/korlibs/graphics/gl/AGOpenglConvert.kt (100%) rename {korge => korge-core}/src/korlibs/graphics/gl/AGOpenglFactory.kt (100%) rename {korge => korge-core}/src/korlibs/graphics/gl/GLObjects.kt (100%) rename {korge => korge-core}/src/korlibs/graphics/gl/GLShaderCompiler.kt (100%) rename {korge => korge-core}/src/korlibs/graphics/log/AGDummy.kt (100%) rename {korge => korge-core}/src/korlibs/graphics/log/AGLog.kt (100%) rename {korge => korge-core}/src/korlibs/graphics/metal/shader/BaseMetalShaderGenerator.kt (100%) rename {korge => korge-core}/src/korlibs/graphics/metal/shader/MetalShaderBodyGenerator.kt (100%) rename {korge => korge-core}/src/korlibs/graphics/metal/shader/MetalShaderBufferInputLayouts.kt (96%) rename {korge => korge-core}/src/korlibs/graphics/metal/shader/MetalShaderGenerator.kt (98%) rename {korge => korge-core}/src/korlibs/graphics/metal/shader/MetalShaderStructureGenerator.kt (100%) create mode 100644 korge-core/src/korlibs/graphics/metal/shader/Shader.kt rename {korge => korge-core}/src/korlibs/graphics/shader/UniformBlock.kt (100%) rename {korge => korge-core}/src/korlibs/graphics/shader/gl/GLVariant.kt (100%) rename {korge => korge-core}/src/korlibs/graphics/shader/gl/GlslExt.kt (100%) rename {korge => korge-core}/src/korlibs/graphics/shader/gl/GlslGenerator.kt (100%) rename {korge => korge-core}/src/korlibs/graphics/shader/shaders.kt (100%) rename {korge => korge-core}/src/korlibs/io/annotations/Keep.kt (100%) rename {korge => korge-core}/src/korlibs/io/annotations/KorInternal.kt (100%) rename {korge => korge-core}/src/korlibs/io/async/AsyncAlias.kt (100%) rename {korge => korge-core}/src/korlibs/io/lang/Disposable.kt (100%) rename {korge => korge-core}/src/korlibs/kgl/KmlBufferExt.kt (100%) rename {korge => korge-core}/src/korlibs/kgl/KmlGl.kt (100%) rename {korge => korge-core}/src/korlibs/kgl/KmlGlCached.kt (100%) rename {korge => korge-core}/src/korlibs/kgl/KmlGlContext.kt (100%) rename {korge => korge-core}/src/korlibs/kgl/KmlGlDummy.kt (100%) rename {korge => korge-core}/src/korlibs/kgl/KmlGlExt.kt (100%) rename {korge => korge-core}/src/korlibs/kgl/KmlGlProxy.kt (100%) rename {korge => korge-core}/src/korlibs/kgl/KmlGlState.kt (100%) rename {korge => korge-core}/src/korlibs/kgl/KmlGlUtil.kt (100%) rename {korge => korge-core}/src/korlibs/kgl/internal/internal.kt (100%) create mode 100644 korge-core/src/korlibs/korge/KorgeCore.kt rename {korge => korge-core}/src/korlibs/korge/KorgeReload.kt (90%) rename {korge => korge-core}/src/korlibs/korge/annotations/KorgeExperimental.kt (100%) rename {korge => korge-core}/src/korlibs/korge/bitmapfont/BitmapFontExt.kt (98%) rename {korge => korge-core}/src/korlibs/korge/bitmapfont/DebugBitmapFont.kt (100%) create mode 100644 korge-core/src/korlibs/korge/blend/BlendMode.kt rename {korge => korge-core}/src/korlibs/korge/input/Gestures.kt (100%) rename {korge => korge-core}/src/korlibs/korge/input/Input.kt (98%) rename {korge => korge-core}/src/korlibs/korge/internal/DefaultViewport.kt (75%) rename {korge => korge-core}/src/korlibs/korge/internal/KorgeInternal.kt (100%) rename {korge => korge-core}/src/korlibs/korge/internal/KorgeUntested.kt (100%) rename {korge => korge-core}/src/korlibs/korge/internal/KorgeUnused.kt (100%) rename {korge => korge-core}/src/korlibs/korge/logger/LoggerExt.kt (100%) rename {korge => korge-core}/src/korlibs/korge/render/AgAutoFreeManager.kt (96%) rename {korge => korge-core}/src/korlibs/korge/render/AgBitmapTextureManager.kt (97%) rename {korge => korge-core}/src/korlibs/korge/render/AgBufferManager.kt (100%) rename {korge => korge-core}/src/korlibs/korge/render/BatchBuilder2D.kt (99%) rename {korge => korge-core}/src/korlibs/korge/render/BitmapExt.kt (100%) create mode 100644 korge-core/src/korlibs/korge/render/BoundsProvider.kt rename {korge => korge-core}/src/korlibs/korge/render/LineRenderBatcher.kt (98%) rename {korge => korge-core}/src/korlibs/korge/render/RenderContext.kt (98%) rename {korge => korge-core}/src/korlibs/korge/render/RenderContext2D.kt (96%) rename {korge => korge-core}/src/korlibs/korge/render/SDFShaders.kt (100%) rename {korge => korge-core}/src/korlibs/korge/render/Texture.kt (100%) rename {korge => korge-core}/src/korlibs/korge/render/TextureWithBitmapSlice.kt (100%) rename {korge => korge-core}/src/korlibs/korge/render/TexturedVertexArray.kt (100%) rename {korge => korge-core}/src/korlibs/korge/render/VertexInfo.kt (100%) rename {korge => korge-core}/src/korlibs/korge/resources/Path.kt (100%) rename {korge => korge-core}/src/korlibs/korge/resources/ResourcesExt.kt (100%) rename {korge => korge-core}/src/korlibs/korge/resources/ResourcesRoot.kt (100%) rename {korge => korge-core}/src/korlibs/korge/service/storage/IStorage.kt (100%) rename {korge => korge-core}/src/korlibs/korge/service/storage/InmemoryStorage.kt (100%) rename {korge => korge-core}/src/korlibs/korge/service/vibration/NativeVibration.kt (76%) rename {korge => korge-core}/src/korlibs/korge/stat/Stats.kt (100%) rename {korge => korge-core}/src/korlibs/korge/tests/TestCoroutineDispatcher.kt (100%) rename {korge => korge-core}/src/korlibs/korge/tween/tweenbase.kt (99%) rename {korge => korge-core}/src/korlibs/render/DeviceDimensionsProvider.kt (100%) rename {korge => korge-core}/src/korlibs/render/DialogInterface.kt (100%) rename {korge => korge-core}/src/korlibs/render/GameWindow.kt (99%) rename {korge => korge-core}/src/korlibs/render/GameWindowCoroutineDispatcher.kt (100%) rename {korge => korge-core}/src/korlibs/render/Korgw.kt (100%) rename {korge => korge-core}/src/korlibs/render/SyncEventLoopCoroutineDispatcher.kt (100%) rename {korge => korge-core}/src/korlibs/render/TouchEventHandler.kt (100%) create mode 100644 korge-core/src/korlibs/render/event/UpdateEvent.kt rename {korge => korge-core}/src/korlibs/render/jvmEngine.kt (100%) rename {korge => korge-core}/src@android/korlibs/graphics/AGAndroid.kt (100%) rename {korge => korge-core}/src@android/korlibs/graphics/gl/AGOpenglFactoryAndroid.kt (100%) rename {korge => korge-core}/src@android/korlibs/kgl/KmlGlAndroid.kt (100%) rename {korge => korge-core}/src@android/korlibs/kgl/KmlGlContextAndroid.kt (100%) rename {korge => korge-core}/src@android/korlibs/korge/KorgeReload_getReloadedClass.kt (100%) rename {korge => korge-core}/src@android/korlibs/korge/service/vibration/NativeVibration.kt (89%) rename {korge => korge-core}/src@android/korlibs/render/AndroidGameController.kt (100%) rename {korge => korge-core}/src@android/korlibs/render/AndroidKeyMap.kt (100%) rename {korge => korge-core}/src@android/korlibs/render/DefaultGameWindowAndroid.kt (100%) rename {korge => korge-core}/src@android/korlibs/render/DialogInterfaceImpl.kt (100%) rename {korge => korge-core}/src@android/korlibs/render/KorgwActivity.kt (100%) rename {korge => korge-core}/src@android/korlibs/render/KorgwSurfaceView.kt (100%) rename {korge => korge-core}/src@darwin/korlibs/graphics/gl/AGOpenglFactoryNative.kt (100%) rename {korge => korge-core}/src@darwin/korlibs/kgl/KmlGlContextAppleMobile.kt (100%) rename {korge => korge-core}/src@darwin/korlibs/kgl/KmlGlNative.kt (100%) rename {korge => korge-core}/src@darwin/korlibs/korge/KorgeReloadNative.kt (100%) rename {korge => korge-core}/src@darwin/korlibs/korge/native/KorgeSimpleNativeSyncIO.kt (100%) rename {korge => korge-core}/src@darwin/korlibs/korge/service/vibration/NativeVibration.kt (83%) rename {korge => korge-core}/src@darwin/korlibs/metal/AGMetal.kt (100%) rename {korge => korge-core}/src@darwin/korlibs/metal/AGMetalConverter.kt (100%) rename {korge => korge-core}/src@darwin/korlibs/metal/MTLBuffer.kt (100%) rename {korge => korge-core}/src@darwin/korlibs/metal/MetalProgram.kt (100%) rename {korge => korge-core}/src@darwin/korlibs/metal/shader/MetalShaderCompiler.kt (100%) rename {korge => korge-core}/src@darwin/korlibs/render/DarwinGameControllerNative.kt (100%) rename {korge => korge-core}/src@darwin/korlibs/render/DefaultGameWindowIos.kt (100%) rename {korge => korge-core}/src@darwin/korlibs/render/DialogInterfaceIos.kt (100%) rename {korge => korge-core}/src@darwin/korlibs/render/IosKeyMap.kt (100%) rename {korge => korge-core}/src@ios/korlibs/render/DefaultGameWindowIosTools.kt (100%) rename {korge => korge-core}/src@js/korlibs/datastructure/event/JsEventLoop.kt (100%) rename {korge => korge-core}/src@js/korlibs/graphics/gl/AGOpenglFactory.kt (100%) rename {korge => korge-core}/src@js/korlibs/graphics/gl/GlExt.kt (100%) rename {korge => korge-core}/src@js/korlibs/kgl/KmlGlContextJs.kt (100%) rename {korge => korge-core}/src@js/korlibs/kgl/KmlGlJsCanvas.kt (100%) rename {korge => korge-core}/src@js/korlibs/korge/KorgeReload_getReloadedClass.kt (100%) rename {korge => korge-core}/src@js/korlibs/korge/service/vibration/NativeVibration.kt (86%) rename {korge => korge-core}/src@js/korlibs/render/DefaultGameWindowJs.kt (100%) rename {korge => korge-core}/src@js/korlibs/render/DialogInterfaceJs.kt (100%) rename {korge => korge-core}/src@js/korlibs/render/internal/KorgwJsInternal.kt (100%) rename {korge => korge-core}/src@jvm/korlibs/event/AwtKeyMap.kt (100%) rename {korge => korge-core}/src@jvm/korlibs/graphics/gl/AGOpenglFactory.kt (100%) rename {korge => korge-core}/src@jvm/korlibs/graphics/metal/AGMetal.kt (100%) rename {korge => korge-core}/src@jvm/korlibs/kgl/KmlGlContextDefault.kt (100%) rename {korge => korge-core}/src@jvm/korlibs/korge/EnsureAddOpens.kt (100%) rename {korge => korge-core}/src@jvm/korlibs/korge/KorgeReload_getReloadedClass.kt (98%) rename {korge => korge-core}/src@jvm/korlibs/korge/atlas/AtlasResourceProcessor.kt (100%) rename {korge => korge-core}/src@jvm/korlibs/korge/plugin/KorgePluginExtension.kt (100%) rename {korge => korge-core}/src@jvm/korlibs/korge/plugin/KorgePluginExtensions.kt (100%) rename {korge => korge-core}/src@jvm/korlibs/korge/resources/ResourceProcessor.kt (100%) rename {korge => korge-core}/src@jvm/korlibs/korge/resources/ResourceProcessorRunner.kt (100%) rename {korge => korge-core}/src@jvm/korlibs/korge/resources/ResourceVersion.kt (100%) rename {korge => korge-core}/src@jvm/korlibs/korge/service/vibration/NativeVibration.kt (72%) rename {korge => korge-core}/src@jvm/korlibs/render/DefaultGameWindowJvm.kt (100%) rename {korge => korge-core}/src@jvm/korlibs/render/awt/AwtAGOpenglCanvas.kt (99%) rename {korge => korge-core}/src@jvm/korlibs/render/awt/AwtAg.kt (100%) rename {korge => korge-core}/src@jvm/korlibs/render/awt/AwtExt.kt (100%) rename {korge => korge-core}/src@jvm/korlibs/render/awt/AwtFrameTools.kt (100%) rename {korge => korge-core}/src@jvm/korlibs/render/awt/AwtGameWindow.kt (100%) rename {korge => korge-core}/src@jvm/korlibs/render/awt/BaseAwtGameWindow.kt (100%) rename {korge => korge-core}/src@jvm/korlibs/render/awt/DesktopGamepadUpdater.kt (100%) rename {korge => korge-core}/src@jvm/korlibs/render/awt/DialogInterfaceAwt.kt (100%) rename {korge => korge-core}/src@jvm/korlibs/render/awt/GLCanvas.kt (98%) rename {korge => korge-core}/src@jvm/korlibs/render/awt/GLCanvasGameWindow.kt (100%) rename {korge => korge-core}/src@jvm/korlibs/render/awt/NewAwtGameWindow.kt (100%) rename {korge => korge-core}/src@jvm/korlibs/render/osx/Cocoa.kt (100%) rename {korge => korge-core}/src@jvm/korlibs/render/osx/DialogInterfaceJvmCocoa.kt (100%) rename {korge => korge-core}/src@jvm/korlibs/render/osx/MacosGLContext.kt (100%) rename {korge => korge-core}/src@jvm/korlibs/render/osx/MacosGameWindow.kt (100%) rename {korge => korge-core}/src@jvm/korlibs/render/osx/OSXDisplayLink.kt (100%) rename {korge => korge-core}/src@jvm/korlibs/render/osx/metal/MTL.kt (100%) rename {korge => korge-core}/src@jvm/korlibs/render/osx/metal/MTLExt.kt (100%) rename {korge => korge-core}/src@jvm/korlibs/render/platform/AwtTools.kt (100%) rename {korge => korge-core}/src@jvm/korlibs/render/platform/BaseOpenglContext.kt (100%) rename {korge => korge-core}/src@jvm/korlibs/render/platform/INativeGL.kt (100%) rename {korge => korge-core}/src@jvm/korlibs/render/platform/NativeKgl.kt (100%) rename {korge => korge-core}/src@jvm/korlibs/render/win32/Win32.kt (100%) rename {korge => korge-core}/src@jvm/korlibs/render/win32/Win32GameWindow.kt (100%) rename {korge => korge-core}/src@jvm/korlibs/render/win32/Win32Tools.kt (100%) rename {korge => korge-core}/src@jvm/korlibs/render/x11/X11Constants.kt (100%) rename {korge => korge-core}/src@jvm/korlibs/render/x11/X11GameWindowJvm.kt (100%) rename {korge => korge-core}/src@jvm/korlibs/render/x11/X11OpenglContext.kt (100%) rename {korge => korge-core}/src@jvmAndroid/korlibs/datastructure/_Datastructure_event.jvmAndroid.kt (100%) rename {korge => korge-core}/src@jvmAndroid/korlibs/kgl/KmlGlTools.kt (100%) rename {korge => korge-core}/src@native/korlibs/kgl/KmlGlNativeExpect.kt (100%) rename {korge => korge-core}/src@native/korlibs/kgl/KmlGlNativeExt.kt (100%) rename {korge => korge-core}/src@native/kotlin/korlibs/datastructure/_Datastructure_event.native.kt (100%) rename {korge => korge-core}/src@tvos/korlibs/render/DefaultGameWindowIosTools.kt (100%) rename {korge => korge-core}/src@wasmJs/korlibs/datastructure/event/WasmJsEventLoop.kt (100%) rename {korge => korge-core}/src@wasmJs/korlibs/graphics/gl/AGOpenglFactoryWasm.kt (100%) rename {korge => korge-core}/src@wasmJs/korlibs/graphics/gl/GlExt.kt (100%) rename {korge => korge-core}/src@wasmJs/korlibs/kgl/KmlGlContextJs.kt (100%) rename {korge => korge-core}/src@wasmJs/korlibs/kgl/KmlGlWasmCanvas.kt (100%) rename {korge => korge-core}/src@wasmJs/korlibs/korge/KorgeReload_getReloadedClass.kt (100%) rename {korge => korge-core}/src@wasmJs/korlibs/korge/service/vibration/NativeVibration.kt (87%) rename {korge => korge-core}/src@wasmJs/korlibs/render/DefaultGameWindowWasm.kt (100%) rename {korge => korge-core}/src@wasmJs/korlibs/render/DialogInterfaceJs.kt (100%) rename {korge => korge-core}/src@wasmJs/korlibs/render/internal/KorgwJsInternal.kt (100%) rename {korge => korge-core}/src@wasmJs/korlibs/render/internal/KorgwWasmInternal.kt (100%) create mode 100644 korge-core/test/korlibs/SkipIOTest.kt create mode 100644 korge-core/test/korlibs/TestExt.kt rename {korge => korge-core}/test/korlibs/datastructure/event/SyncEventLoopTest.kt (100%) rename {korge => korge-core}/test/korlibs/event/EventListenerTest.kt (100%) rename {korge => korge-core}/test/korlibs/event/EventsTest.kt (100%) rename {korge => korge-core}/test/korlibs/event/KorevTest.kt (100%) rename {korge => korge-core}/test/korlibs/event/ScrollDeltaTest.kt (100%) rename {korge => korge-core}/test/korlibs/event/TouchBuilderTest.kt (100%) rename {korge => korge-core}/test/korlibs/graphics/AGNewUniformTest.kt (100%) rename {korge => korge-core}/test/korlibs/graphics/AGOpenglTest.kt (100%) rename {korge => korge-core}/test/korlibs/graphics/AGStateTest.kt (100%) rename {korge => korge-core}/test/korlibs/graphics/AGTest.kt (100%) rename {korge => korge-core}/test/korlibs/graphics/AGUniformBlockTest.kt (100%) rename {korge => korge-core}/test/korlibs/graphics/AGValueTest.kt (100%) rename {korge => korge-core}/test/korlibs/graphics/AGVertexArrayObjectFlattenerTest.kt (100%) rename {korge => korge-core}/test/korlibs/graphics/metal/shader/MetalShaderBufferInputLayoutsTest.kt (100%) rename {korge => korge-core}/test/korlibs/graphics/metal/shader/MetalShaderGeneratorTest.kt (100%) rename {korge => korge-core}/test/korlibs/graphics/metal/shader/MetalShaderStructureGeneratorTest.kt (100%) rename {korge => korge-core}/test/korlibs/graphics/shader/VertexLayoutTest.kt (100%) rename {korge => korge-core}/test/korlibs/graphics/shaders/ShadersTest.kt (100%) rename {korge => korge-core}/test/korlibs/io/file/registry/WindowsRegistryTest.kt (100%) rename {korge => korge-core}/test/korlibs/kgl/KglOffscreenTest.kt (100%) rename {korge => korge-core}/test/korlibs/kgl/KglTest.kt (100%) rename {korge => korge-core}/test/korlibs/render/AGUniformsTest.kt (100%) rename {korge => korge-core}/test/korlibs/render/GameWindowTest.kt (100%) rename {korge => korge-core}/test/korlibs/render/KorgwSampleMain.kt (100%) rename {korge => korge-core}/test/korlibs/render/KorgwTest.kt (100%) rename {korge => korge-core}/test/korlibs/render/SyncEventLoopCoroutineDispatcherTest.kt (100%) rename {korge => korge-core}/test/korlibs/render/x11/LinuxJoyEventAdapterTest.kt (97%) rename {korge => korge-core}/test/korlibs/test/AnySubject.kt (100%) rename {korge => korge-core}/test/korlibs/test/BooleanSubject.kt (100%) rename {korge => korge-core}/test/korlibs/test/CollectionSubject.kt (100%) rename {korge => korge-core}/test/korlibs/test/DoubleSubject.kt (100%) rename {korge => korge-core}/test/korlibs/test/MapSubject.kt (100%) rename {korge => korge-core}/test/korlibs/test/truth.kt (100%) delete mode 100644 korge/resources/META-INF/services/com.soywiz.korag.AGFactory delete mode 100644 korge/src/korlibs/graphics/metal/shader/Shader.kt delete mode 100644 korge/src/korlibs/korge/KorgeVersion.kt create mode 100644 korge/src/korlibs/korge/render/RenderContextExt.kt create mode 100644 korge/src/korlibs/korge/service/vibration/NativeVibrationViews.kt rename korge/{src@darwin => src@ios}/korlibs/korge/service/storage/DarwinNativeStorage.kt (100%) rename korge/{src@darwin => src@ios}/korlibs/korge/service/storage/NativeStorageNative.kt (100%) rename korge/{src@darwin => src@ios}/korlibs/korge/tests/enrichTestGameWindow.kt (100%) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 99b33cf9bd..c57c0006a8 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -15,7 +15,7 @@ kotlinx-coroutines = "1.9.0-RC" kotlinx-serialization = "1.7.0" kotlinx-atomicfu = "0.24.0" -korlibs = "6.0.0-alpha3" +korlibs = "6.0.0-alpha4" #korlibs = "999.0.0.999" kotlinx-benchmark = "0.4.7" diff --git a/korge-core/build.gradle.kts b/korge-core/build.gradle.kts new file mode 100644 index 0000000000..ee7adc1729 --- /dev/null +++ b/korge-core/build.gradle.kts @@ -0,0 +1,31 @@ +import korlibs.applyProjectProperties + +description = "Multiplatform Game Engine written in Kotlin" + +project.extensions.extraProperties.properties.apply { + applyProjectProperties( + "https://github.com/korlibs/korge", + "MIT License", + "https://raw.githubusercontent.com/korlibs/korge/master/LICENSE" + ) +} + +dependencies { + commonMainApi(libs.korlibs.audio) + commonMainApi(libs.korlibs.image) + commonMainApi(libs.korlibs.inject) + commonMainApi(libs.korlibs.template) + commonMainApi(libs.korlibs.time) + commonMainApi(libs.kotlinx.atomicfu) + commonMainApi(libs.kotlinx.coroutines.core) + //commonTestApi(project(":korge-test")) + jvmMainApi("org.jetbrains.kotlin:kotlin-reflect") + jvmMainImplementation(libs.jackson.databind) + jvmMainImplementation(libs.jackson.module.kotlin) + + //commonTestApi(testFixtures(project(":korma"))) + + //add("jvmMainApi", project(":korte")) + + //add("commonTestApi", "it.krzeminski.vis-assert:vis-assert:0.4.0-beta") +} diff --git a/korge/src/korlibs/datastructure/_Datastructure_event.kt b/korge-core/src/korlibs/datastructure/_Datastructure_event.kt similarity index 100% rename from korge/src/korlibs/datastructure/_Datastructure_event.kt rename to korge-core/src/korlibs/datastructure/_Datastructure_event.kt diff --git a/korge/src/korlibs/datastructure/closeable/Closeable.kt b/korge-core/src/korlibs/datastructure/closeable/Closeable.kt similarity index 100% rename from korge/src/korlibs/datastructure/closeable/Closeable.kt rename to korge-core/src/korlibs/datastructure/closeable/Closeable.kt diff --git a/korge/src/korlibs/datastructure/lock/LockAlias.kt b/korge-core/src/korlibs/datastructure/lock/LockAlias.kt similarity index 100% rename from korge/src/korlibs/datastructure/lock/LockAlias.kt rename to korge-core/src/korlibs/datastructure/lock/LockAlias.kt diff --git a/korge/src/korlibs/datastructure/thread/ThreadAlias.kt b/korge-core/src/korlibs/datastructure/thread/ThreadAlias.kt similarity index 100% rename from korge/src/korlibs/datastructure/thread/ThreadAlias.kt rename to korge-core/src/korlibs/datastructure/thread/ThreadAlias.kt diff --git a/korge/src/korlibs/event/EventListener.kt b/korge-core/src/korlibs/event/EventListener.kt similarity index 100% rename from korge/src/korlibs/event/EventListener.kt rename to korge-core/src/korlibs/event/EventListener.kt diff --git a/korge/src/korlibs/event/Events.kt b/korge-core/src/korlibs/event/Events.kt similarity index 100% rename from korge/src/korlibs/event/Events.kt rename to korge-core/src/korlibs/event/Events.kt diff --git a/korge/src/korlibs/event/InputGamepad.kt b/korge-core/src/korlibs/event/InputGamepad.kt similarity index 100% rename from korge/src/korlibs/event/InputGamepad.kt rename to korge-core/src/korlibs/event/InputGamepad.kt diff --git a/korge/src/korlibs/event/Key.kt b/korge-core/src/korlibs/event/Key.kt similarity index 100% rename from korge/src/korlibs/event/Key.kt rename to korge-core/src/korlibs/event/Key.kt diff --git a/korge/src/korlibs/event/MouseButton.kt b/korge-core/src/korlibs/event/MouseButton.kt similarity index 100% rename from korge/src/korlibs/event/MouseButton.kt rename to korge-core/src/korlibs/event/MouseButton.kt diff --git a/korge/src/korlibs/event/SoftKeyboard.kt b/korge-core/src/korlibs/event/SoftKeyboard.kt similarity index 100% rename from korge/src/korlibs/event/SoftKeyboard.kt rename to korge-core/src/korlibs/event/SoftKeyboard.kt diff --git a/korge/src/korlibs/event/gamepad/DarwinMacosGameController.kt b/korge-core/src/korlibs/event/gamepad/DarwinMacosGameController.kt similarity index 100% rename from korge/src/korlibs/event/gamepad/DarwinMacosGameController.kt rename to korge-core/src/korlibs/event/gamepad/DarwinMacosGameController.kt diff --git a/korge/src/korlibs/event/gamepad/X11JoyGameControllerCommon.kt b/korge-core/src/korlibs/event/gamepad/X11JoyGameControllerCommon.kt similarity index 96% rename from korge/src/korlibs/event/gamepad/X11JoyGameControllerCommon.kt rename to korge-core/src/korlibs/event/gamepad/X11JoyGameControllerCommon.kt index 964b9e9d3e..5ef690efe0 100644 --- a/korge/src/korlibs/event/gamepad/X11JoyGameControllerCommon.kt +++ b/korge-core/src/korlibs/event/gamepad/X11JoyGameControllerCommon.kt @@ -9,6 +9,7 @@ import korlibs.io.concurrent.atomic.* import korlibs.io.file.* import korlibs.io.file.sync.* import korlibs.io.lang.* +import korlibs.korge.internal.* import korlibs.math.* import korlibs.memory.* import korlibs.platform.* @@ -21,7 +22,8 @@ import kotlin.time.* /** * */ -internal class LinuxJoyEventAdapter @OptIn(SyncIOAPI::class) constructor(val syncIO: SyncIO = SyncIO) : AutoCloseable { +@KorgeInternal +class LinuxJoyEventAdapter @OptIn(SyncIOAPI::class) constructor(val syncIO: SyncIO = SyncIO) : AutoCloseable { companion object { const val JS_EVENT_BUTTON = 0x01 /* button pressed/released */ const val JS_EVENT_AXIS = 0x02 /* joystick moved */ @@ -93,7 +95,8 @@ internal class LinuxJoyEventAdapter @OptIn(SyncIOAPI::class) constructor(val syn readers.clear() } - internal class X11JoystickReader(val info: DeviceInfo, val platformSyncIO: SyncIO) : AutoCloseable { + @KorgeInternal + class X11JoystickReader(val info: DeviceInfo, val platformSyncIO: SyncIO) : AutoCloseable { val index: Int = info.id private val buttonsPressure = FloatArray(GameButton.MAX) diff --git a/korge/src/korlibs/event/gamepad/XInputGamepadEventAdapter.kt b/korge-core/src/korlibs/event/gamepad/XInputGamepadEventAdapter.kt similarity index 100% rename from korge/src/korlibs/event/gamepad/XInputGamepadEventAdapter.kt rename to korge-core/src/korlibs/event/gamepad/XInputGamepadEventAdapter.kt diff --git a/korge/src/korlibs/graphics/AG.kt b/korge-core/src/korlibs/graphics/AG.kt similarity index 100% rename from korge/src/korlibs/graphics/AG.kt rename to korge-core/src/korlibs/graphics/AG.kt diff --git a/korge/src/korlibs/graphics/AGObjects.kt b/korge-core/src/korlibs/graphics/AGObjects.kt similarity index 100% rename from korge/src/korlibs/graphics/AGObjects.kt rename to korge-core/src/korlibs/graphics/AGObjects.kt diff --git a/korge/src/korlibs/graphics/AGProgramWithUniform.kt b/korge-core/src/korlibs/graphics/AGProgramWithUniform.kt similarity index 100% rename from korge/src/korlibs/graphics/AGProgramWithUniform.kt rename to korge-core/src/korlibs/graphics/AGProgramWithUniform.kt diff --git a/korge/src/korlibs/graphics/AGState.kt b/korge-core/src/korlibs/graphics/AGState.kt similarity index 100% rename from korge/src/korlibs/graphics/AGState.kt rename to korge-core/src/korlibs/graphics/AGState.kt diff --git a/korge/src/korlibs/graphics/AGStats.kt b/korge-core/src/korlibs/graphics/AGStats.kt similarity index 100% rename from korge/src/korlibs/graphics/AGStats.kt rename to korge-core/src/korlibs/graphics/AGStats.kt diff --git a/korge/src/korlibs/graphics/AGTextureDrawer.kt b/korge-core/src/korlibs/graphics/AGTextureDrawer.kt similarity index 100% rename from korge/src/korlibs/graphics/AGTextureDrawer.kt rename to korge-core/src/korlibs/graphics/AGTextureDrawer.kt diff --git a/korge/src/korlibs/graphics/AGVertexArrayObjectFlattener.kt b/korge-core/src/korlibs/graphics/AGVertexArrayObjectFlattener.kt similarity index 100% rename from korge/src/korlibs/graphics/AGVertexArrayObjectFlattener.kt rename to korge-core/src/korlibs/graphics/AGVertexArrayObjectFlattener.kt diff --git a/korge/src/korlibs/graphics/DefaultShaders.kt b/korge-core/src/korlibs/graphics/DefaultShaders.kt similarity index 100% rename from korge/src/korlibs/graphics/DefaultShaders.kt rename to korge-core/src/korlibs/graphics/DefaultShaders.kt diff --git a/korge/src/korlibs/graphics/annotation/KoragExperimental.kt b/korge-core/src/korlibs/graphics/annotation/KoragExperimental.kt similarity index 100% rename from korge/src/korlibs/graphics/annotation/KoragExperimental.kt rename to korge-core/src/korlibs/graphics/annotation/KoragExperimental.kt diff --git a/korge/src/korlibs/graphics/gl/AGOpengl.kt b/korge-core/src/korlibs/graphics/gl/AGOpengl.kt similarity index 100% rename from korge/src/korlibs/graphics/gl/AGOpengl.kt rename to korge-core/src/korlibs/graphics/gl/AGOpengl.kt diff --git a/korge/src/korlibs/graphics/gl/AGOpenglConvert.kt b/korge-core/src/korlibs/graphics/gl/AGOpenglConvert.kt similarity index 100% rename from korge/src/korlibs/graphics/gl/AGOpenglConvert.kt rename to korge-core/src/korlibs/graphics/gl/AGOpenglConvert.kt diff --git a/korge/src/korlibs/graphics/gl/AGOpenglFactory.kt b/korge-core/src/korlibs/graphics/gl/AGOpenglFactory.kt similarity index 100% rename from korge/src/korlibs/graphics/gl/AGOpenglFactory.kt rename to korge-core/src/korlibs/graphics/gl/AGOpenglFactory.kt diff --git a/korge/src/korlibs/graphics/gl/GLObjects.kt b/korge-core/src/korlibs/graphics/gl/GLObjects.kt similarity index 100% rename from korge/src/korlibs/graphics/gl/GLObjects.kt rename to korge-core/src/korlibs/graphics/gl/GLObjects.kt diff --git a/korge/src/korlibs/graphics/gl/GLShaderCompiler.kt b/korge-core/src/korlibs/graphics/gl/GLShaderCompiler.kt similarity index 100% rename from korge/src/korlibs/graphics/gl/GLShaderCompiler.kt rename to korge-core/src/korlibs/graphics/gl/GLShaderCompiler.kt diff --git a/korge/src/korlibs/graphics/log/AGDummy.kt b/korge-core/src/korlibs/graphics/log/AGDummy.kt similarity index 100% rename from korge/src/korlibs/graphics/log/AGDummy.kt rename to korge-core/src/korlibs/graphics/log/AGDummy.kt diff --git a/korge/src/korlibs/graphics/log/AGLog.kt b/korge-core/src/korlibs/graphics/log/AGLog.kt similarity index 100% rename from korge/src/korlibs/graphics/log/AGLog.kt rename to korge-core/src/korlibs/graphics/log/AGLog.kt diff --git a/korge/src/korlibs/graphics/metal/shader/BaseMetalShaderGenerator.kt b/korge-core/src/korlibs/graphics/metal/shader/BaseMetalShaderGenerator.kt similarity index 100% rename from korge/src/korlibs/graphics/metal/shader/BaseMetalShaderGenerator.kt rename to korge-core/src/korlibs/graphics/metal/shader/BaseMetalShaderGenerator.kt diff --git a/korge/src/korlibs/graphics/metal/shader/MetalShaderBodyGenerator.kt b/korge-core/src/korlibs/graphics/metal/shader/MetalShaderBodyGenerator.kt similarity index 100% rename from korge/src/korlibs/graphics/metal/shader/MetalShaderBodyGenerator.kt rename to korge-core/src/korlibs/graphics/metal/shader/MetalShaderBodyGenerator.kt diff --git a/korge/src/korlibs/graphics/metal/shader/MetalShaderBufferInputLayouts.kt b/korge-core/src/korlibs/graphics/metal/shader/MetalShaderBufferInputLayouts.kt similarity index 96% rename from korge/src/korlibs/graphics/metal/shader/MetalShaderBufferInputLayouts.kt rename to korge-core/src/korlibs/graphics/metal/shader/MetalShaderBufferInputLayouts.kt index dceb7ebfe2..7b53a99291 100644 --- a/korge/src/korlibs/graphics/metal/shader/MetalShaderBufferInputLayouts.kt +++ b/korge-core/src/korlibs/graphics/metal/shader/MetalShaderBufferInputLayouts.kt @@ -4,9 +4,11 @@ import korlibs.graphics.shader.Attribute import korlibs.graphics.shader.Uniform import korlibs.graphics.shader.VariableWithOffset import korlibs.graphics.shader.VertexLayout +import korlibs.korge.internal.* import korlibs.logger.Logger -internal fun lazyMetalShaderBufferInputLayouts( +@KorgeInternal +fun lazyMetalShaderBufferInputLayouts( vertexLayouts: List, uniforms: List ) = lazy { @@ -17,7 +19,8 @@ internal fun lazyMetalShaderBufferInputLayouts( ) } -internal class MetalShaderBufferInputLayouts( +@KorgeInternal +class MetalShaderBufferInputLayouts( vertexLayouts: List, private val inputBuffers: List> ) : List> by inputBuffers { diff --git a/korge/src/korlibs/graphics/metal/shader/MetalShaderGenerator.kt b/korge-core/src/korlibs/graphics/metal/shader/MetalShaderGenerator.kt similarity index 98% rename from korge/src/korlibs/graphics/metal/shader/MetalShaderGenerator.kt rename to korge-core/src/korlibs/graphics/metal/shader/MetalShaderGenerator.kt index efb82849d5..c8295227ce 100644 --- a/korge/src/korlibs/graphics/metal/shader/MetalShaderGenerator.kt +++ b/korge-core/src/korlibs/graphics/metal/shader/MetalShaderGenerator.kt @@ -3,13 +3,15 @@ package korlibs.graphics.metal.shader import korlibs.graphics.shader.* import korlibs.graphics.shader.gl.GlobalsProgramVisitor import korlibs.io.util.Indenter +import korlibs.korge.internal.* internal const val vertexMainFunctionName = "vertexMain" internal const val fragmentMainFunctionName = "fragmentMain" private const val vertexInputStructureName = "VertexInput" internal const val vertexInputStructureDeclarationName = "vertexInput" -internal class MetalShaderGenerator( +@KorgeInternal +class MetalShaderGenerator( private val vertexShader: VertexShader, private val fragmentShader: FragmentShader, private val bufferLayouts: MetalShaderBufferInputLayouts @@ -43,6 +45,7 @@ internal class MetalShaderGenerator( fragmentBodyGenerator ) + @KorgeInternal data class Result( val result: String, val inputBuffers: MetalShaderBufferInputLayouts diff --git a/korge/src/korlibs/graphics/metal/shader/MetalShaderStructureGenerator.kt b/korge-core/src/korlibs/graphics/metal/shader/MetalShaderStructureGenerator.kt similarity index 100% rename from korge/src/korlibs/graphics/metal/shader/MetalShaderStructureGenerator.kt rename to korge-core/src/korlibs/graphics/metal/shader/MetalShaderStructureGenerator.kt diff --git a/korge-core/src/korlibs/graphics/metal/shader/Shader.kt b/korge-core/src/korlibs/graphics/metal/shader/Shader.kt new file mode 100644 index 0000000000..2a022c771c --- /dev/null +++ b/korge-core/src/korlibs/graphics/metal/shader/Shader.kt @@ -0,0 +1,8 @@ +package korlibs.graphics.metal.shader + +import korlibs.graphics.shader.* +import korlibs.korge.internal.* + +@KorgeInternal +fun Pair.toNewMetalShaderStringResult(bufferInputsLayout: MetalShaderBufferInputLayouts): MetalShaderGenerator.Result = let { (vertexShader, fragmentShader) -> MetalShaderGenerator(vertexShader, fragmentShader, bufferInputsLayout) } + .generateResult() diff --git a/korge/src/korlibs/graphics/shader/UniformBlock.kt b/korge-core/src/korlibs/graphics/shader/UniformBlock.kt similarity index 100% rename from korge/src/korlibs/graphics/shader/UniformBlock.kt rename to korge-core/src/korlibs/graphics/shader/UniformBlock.kt diff --git a/korge/src/korlibs/graphics/shader/gl/GLVariant.kt b/korge-core/src/korlibs/graphics/shader/gl/GLVariant.kt similarity index 100% rename from korge/src/korlibs/graphics/shader/gl/GLVariant.kt rename to korge-core/src/korlibs/graphics/shader/gl/GLVariant.kt diff --git a/korge/src/korlibs/graphics/shader/gl/GlslExt.kt b/korge-core/src/korlibs/graphics/shader/gl/GlslExt.kt similarity index 100% rename from korge/src/korlibs/graphics/shader/gl/GlslExt.kt rename to korge-core/src/korlibs/graphics/shader/gl/GlslExt.kt diff --git a/korge/src/korlibs/graphics/shader/gl/GlslGenerator.kt b/korge-core/src/korlibs/graphics/shader/gl/GlslGenerator.kt similarity index 100% rename from korge/src/korlibs/graphics/shader/gl/GlslGenerator.kt rename to korge-core/src/korlibs/graphics/shader/gl/GlslGenerator.kt diff --git a/korge/src/korlibs/graphics/shader/shaders.kt b/korge-core/src/korlibs/graphics/shader/shaders.kt similarity index 100% rename from korge/src/korlibs/graphics/shader/shaders.kt rename to korge-core/src/korlibs/graphics/shader/shaders.kt diff --git a/korge/src/korlibs/io/annotations/Keep.kt b/korge-core/src/korlibs/io/annotations/Keep.kt similarity index 100% rename from korge/src/korlibs/io/annotations/Keep.kt rename to korge-core/src/korlibs/io/annotations/Keep.kt diff --git a/korge/src/korlibs/io/annotations/KorInternal.kt b/korge-core/src/korlibs/io/annotations/KorInternal.kt similarity index 100% rename from korge/src/korlibs/io/annotations/KorInternal.kt rename to korge-core/src/korlibs/io/annotations/KorInternal.kt diff --git a/korge/src/korlibs/io/async/AsyncAlias.kt b/korge-core/src/korlibs/io/async/AsyncAlias.kt similarity index 100% rename from korge/src/korlibs/io/async/AsyncAlias.kt rename to korge-core/src/korlibs/io/async/AsyncAlias.kt diff --git a/korge/src/korlibs/io/lang/Disposable.kt b/korge-core/src/korlibs/io/lang/Disposable.kt similarity index 100% rename from korge/src/korlibs/io/lang/Disposable.kt rename to korge-core/src/korlibs/io/lang/Disposable.kt diff --git a/korge/src/korlibs/kgl/KmlBufferExt.kt b/korge-core/src/korlibs/kgl/KmlBufferExt.kt similarity index 100% rename from korge/src/korlibs/kgl/KmlBufferExt.kt rename to korge-core/src/korlibs/kgl/KmlBufferExt.kt diff --git a/korge/src/korlibs/kgl/KmlGl.kt b/korge-core/src/korlibs/kgl/KmlGl.kt similarity index 100% rename from korge/src/korlibs/kgl/KmlGl.kt rename to korge-core/src/korlibs/kgl/KmlGl.kt diff --git a/korge/src/korlibs/kgl/KmlGlCached.kt b/korge-core/src/korlibs/kgl/KmlGlCached.kt similarity index 100% rename from korge/src/korlibs/kgl/KmlGlCached.kt rename to korge-core/src/korlibs/kgl/KmlGlCached.kt diff --git a/korge/src/korlibs/kgl/KmlGlContext.kt b/korge-core/src/korlibs/kgl/KmlGlContext.kt similarity index 100% rename from korge/src/korlibs/kgl/KmlGlContext.kt rename to korge-core/src/korlibs/kgl/KmlGlContext.kt diff --git a/korge/src/korlibs/kgl/KmlGlDummy.kt b/korge-core/src/korlibs/kgl/KmlGlDummy.kt similarity index 100% rename from korge/src/korlibs/kgl/KmlGlDummy.kt rename to korge-core/src/korlibs/kgl/KmlGlDummy.kt diff --git a/korge/src/korlibs/kgl/KmlGlExt.kt b/korge-core/src/korlibs/kgl/KmlGlExt.kt similarity index 100% rename from korge/src/korlibs/kgl/KmlGlExt.kt rename to korge-core/src/korlibs/kgl/KmlGlExt.kt diff --git a/korge/src/korlibs/kgl/KmlGlProxy.kt b/korge-core/src/korlibs/kgl/KmlGlProxy.kt similarity index 100% rename from korge/src/korlibs/kgl/KmlGlProxy.kt rename to korge-core/src/korlibs/kgl/KmlGlProxy.kt diff --git a/korge/src/korlibs/kgl/KmlGlState.kt b/korge-core/src/korlibs/kgl/KmlGlState.kt similarity index 100% rename from korge/src/korlibs/kgl/KmlGlState.kt rename to korge-core/src/korlibs/kgl/KmlGlState.kt diff --git a/korge/src/korlibs/kgl/KmlGlUtil.kt b/korge-core/src/korlibs/kgl/KmlGlUtil.kt similarity index 100% rename from korge/src/korlibs/kgl/KmlGlUtil.kt rename to korge-core/src/korlibs/kgl/KmlGlUtil.kt diff --git a/korge/src/korlibs/kgl/internal/internal.kt b/korge-core/src/korlibs/kgl/internal/internal.kt similarity index 100% rename from korge/src/korlibs/kgl/internal/internal.kt rename to korge-core/src/korlibs/kgl/internal/internal.kt diff --git a/korge-core/src/korlibs/korge/KorgeCore.kt b/korge-core/src/korlibs/korge/KorgeCore.kt new file mode 100644 index 0000000000..8b0d34eab0 --- /dev/null +++ b/korge-core/src/korlibs/korge/KorgeCore.kt @@ -0,0 +1,39 @@ +package korlibs.korge + +import korlibs.io.async.* +import korlibs.render.* +import kotlinx.coroutines.* + +/** + * ```kotlin + * suspend fun main() = KorgeCore { + * val stopWatch = Stopwatch().start() + * onRenderEvent { + * ag.clear(ag.mainFrameBuffer, color = Colors.RED.interpolateWith((stopWatch.elapsed.seconds % 1.0).toRatio(), Colors.WHITE)) + * } + * } + * ``` + */ +suspend fun KorgeCore( + config: GameWindowCreationConfig = GameWindowCreationConfig.DEFAULT, + gameWindow: GameWindow = CreateDefaultGameWindow(config), + block: suspend GameWindow.() -> Unit +) { + //withContext(PreferSyncIo(preferSyncIo = true)) { + withContext(PreferSyncIo(preferSyncIo = null)) { + gameWindow.loop { + block() + } + } +} + +/* +suspefun test() { + KorgeCore { + val gameWindow = this + onRenderEvent { + gameWindow.ag.clear(gameWindow.ag.mainFrameBuffer, color = Colors.RED) + } + } +} +*/ diff --git a/korge/src/korlibs/korge/KorgeReload.kt b/korge-core/src/korlibs/korge/KorgeReload.kt similarity index 90% rename from korge/src/korlibs/korge/KorgeReload.kt rename to korge-core/src/korlibs/korge/KorgeReload.kt index 8394e969e0..9eb6308ca8 100644 --- a/korge/src/korlibs/korge/KorgeReload.kt +++ b/korge-core/src/korlibs/korge/KorgeReload.kt @@ -1,17 +1,18 @@ package korlibs.korge -import korlibs.platform.Platform import korlibs.event.* -import korlibs.inject.Injector -import korlibs.io.lang.Environment +import korlibs.inject.* +import korlibs.io.lang.* +import korlibs.korge.internal.* import korlibs.logger.* -import kotlin.jvm.JvmStatic -import kotlin.native.concurrent.ThreadLocal -import kotlin.reflect.KClass +import korlibs.platform.* +import kotlin.jvm.* +import kotlin.reflect.* class ReloadClassContext(val injector: Injector, val refreshedClasses: Set, val rootFolders: List) -internal open class KorgeReloadInternalImpl { +@KorgeInternal +open class KorgeReloadInternalImpl { open fun getReloadedClass(clazz: KClass, context: ReloadClassContext): KClass = clazz open fun transferKeepProperties(old: Any, new: Any) = Unit } diff --git a/korge/src/korlibs/korge/annotations/KorgeExperimental.kt b/korge-core/src/korlibs/korge/annotations/KorgeExperimental.kt similarity index 100% rename from korge/src/korlibs/korge/annotations/KorgeExperimental.kt rename to korge-core/src/korlibs/korge/annotations/KorgeExperimental.kt diff --git a/korge/src/korlibs/korge/bitmapfont/BitmapFontExt.kt b/korge-core/src/korlibs/korge/bitmapfont/BitmapFontExt.kt similarity index 98% rename from korge/src/korlibs/korge/bitmapfont/BitmapFontExt.kt rename to korge-core/src/korlibs/korge/bitmapfont/BitmapFontExt.kt index e0926a2673..e8c24d46e7 100644 --- a/korge/src/korlibs/korge/bitmapfont/BitmapFontExt.kt +++ b/korge-core/src/korlibs/korge/bitmapfont/BitmapFontExt.kt @@ -1,9 +1,9 @@ package korlibs.korge.bitmapfont import korlibs.korge.render.* -import korlibs.korge.view.* import korlibs.image.color.* import korlibs.image.font.* +import korlibs.korge.blend.* import korlibs.math.geom.* fun BitmapFont.drawText( diff --git a/korge/src/korlibs/korge/bitmapfont/DebugBitmapFont.kt b/korge-core/src/korlibs/korge/bitmapfont/DebugBitmapFont.kt similarity index 100% rename from korge/src/korlibs/korge/bitmapfont/DebugBitmapFont.kt rename to korge-core/src/korlibs/korge/bitmapfont/DebugBitmapFont.kt diff --git a/korge-core/src/korlibs/korge/blend/BlendMode.kt b/korge-core/src/korlibs/korge/blend/BlendMode.kt new file mode 100644 index 0000000000..c3142701ad --- /dev/null +++ b/korge-core/src/korlibs/korge/blend/BlendMode.kt @@ -0,0 +1,131 @@ +package korlibs.korge.blend + +import korlibs.graphics.* +import korlibs.image.color.* + +/** + * Determines how pixels should be blended. The most common blend modes are: [NORMAL] (normal mix) and [ADD] (additive blending) along with [MULTIPLY] and others. + * + * [https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/blendFuncSeparate](https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/blendFuncSeparate) + * + * ```kotlin + * // color(RGB) = (sourceColor * srcRGB) + (destinationColor * dstRGB) + * // color(A) = (sourceAlpha * srcAlpha) + (destinationAlpha * dstAlpha) + * ``` + */ +data class BlendMode( + val factors: AGBlending, + val name: String? = null, +) { + val __hashCode: Int = factors.hashCode() + name.hashCode() * 7 + override fun hashCode(): Int = __hashCode + override fun equals(other: Any?): Boolean = (this === other) || (other is BlendMode && this.factors == other.factors && name == other.name) + override fun toString(): String = name ?: super.toString() + + fun apply(src: RGBAf, dst: RGBAf, out: RGBAf = RGBAf()): RGBAf { + return factors.apply(src, dst, out) + } + + fun apply(src: RGBA, dst: RGBA): RGBA { + return factors.apply(src, dst) + } + + companion object { + /** Mixes the source and destination colors using the source alpha value */ + val NORMAL = BlendMode(name = "NORMAL", factors = AGBlending.NORMAL_PRE) + /** Not an actual blending. It is used to indicate that the next non-inherit BlendMode from its ancestors will be used. */ + val INHERIT = NORMAL.copy(name = "INHERIT") + /** Doesn't blend at all. Just replaces the colors. */ + val NONE = BlendMode(name = "NONE", factors = AGBlending(AGBlendFactor.ONE, AGBlendFactor.ZERO)) // REPLACE + /** Additive mixing for lighting effects */ + val ADD = BlendMode(name = "ADD", factors = AGBlending.ADD_PRE) + + // Unchecked + val MULTIPLY = BlendMode(name = "MULTIPLY", factors = AGBlending(AGBlendFactor.DESTINATION_COLOR, AGBlendFactor.ONE_MINUS_SOURCE_ALPHA)) + val SCREEN = BlendMode(name = "SCREEN", factors = AGBlending(AGBlendFactor.ONE, AGBlendFactor.ONE_MINUS_SOURCE_COLOR)) + + val ERASE = BlendMode(name = "ERASE", factors = AGBlending(AGBlendFactor.ZERO, AGBlendFactor.ONE_MINUS_SOURCE_ALPHA)) + val MASK = BlendMode(name = "MASK", factors = AGBlending(AGBlendFactor.ZERO, AGBlendFactor.SOURCE_ALPHA)) + val BELOW = BlendMode(name = "BELOW", factors = AGBlending(AGBlendFactor.ONE_MINUS_DESTINATION_ALPHA, AGBlendFactor.DESTINATION_ALPHA)) + val SUBTRACT = BlendMode( + name = "SUBTRACT", factors = AGBlending( + AGBlendFactor.SOURCE_ALPHA, AGBlendFactor.DESTINATION_ALPHA, + AGBlendFactor.ONE, AGBlendFactor.ONE, + AGBlendEquation.REVERSE_SUBTRACT + ) + ) + val INVERT = BlendMode( + name = "INVERT", + factors = AGBlending( + AGBlendFactor.ONE_MINUS_DESTINATION_COLOR, AGBlendFactor.ZERO, + AGBlendFactor.ONE, AGBlendFactor.ONE, + ) + ) + + // Unimplemented + val LIGHTEN = BlendMode( + name = "LIGHTEN", + factors = AGBlending( + AGBlendFactor.SOURCE_ALPHA, AGBlendFactor.DESTINATION_ALPHA, + AGBlendFactor.ONE, AGBlendFactor.ONE + ) + ) + val DARKEN = BlendMode( + name = "DARKEN", + factors = AGBlending( + AGBlendFactor.SOURCE_ALPHA, AGBlendFactor.DESTINATION_ALPHA, + AGBlendFactor.ONE, AGBlendFactor.ONE + ) + ) + val DIFFERENCE = BlendMode( + name = "DIFFERENCE", + factors = AGBlending( + AGBlendFactor.SOURCE_ALPHA, AGBlendFactor.DESTINATION_ALPHA, + AGBlendFactor.ONE, AGBlendFactor.ONE + ) + ) + val ALPHA = BlendMode( + name = "ALPHA", + factors = AGBlending( + AGBlendFactor.SOURCE_ALPHA, AGBlendFactor.DESTINATION_ALPHA, + AGBlendFactor.ONE, AGBlendFactor.ONE + ) + ) + val HARDLIGHT = BlendMode( + name = "HARDLIGHT", + factors = AGBlending( + AGBlendFactor.SOURCE_ALPHA, AGBlendFactor.DESTINATION_ALPHA, + AGBlendFactor.ONE, AGBlendFactor.ONE + ) + ) + + val OVERLAY: BlendMode get() = NORMAL + val REPLACE: BlendMode get() = NONE + + val BY_ORDINAL: Array = arrayOf(INHERIT, NONE, NORMAL, ADD, MULTIPLY, SCREEN, ERASE, MASK, BELOW, SUBTRACT, INVERT, LIGHTEN, DARKEN, DIFFERENCE, ALPHA, HARDLIGHT) + val BY_NAME: Map = BY_ORDINAL.associateBy { it.name!! } + val STANDARD_LIST: List = BY_ORDINAL.toList() + + val TO_ORDINAL: Map = BY_ORDINAL.indices.associateBy { BY_ORDINAL[it] } + + operator fun get(ordinal: Int): BlendMode = BY_ORDINAL.getOrElse(ordinal) { INHERIT } + operator fun get(name: String): BlendMode = BY_NAME[name.uppercase()] ?: INHERIT + + + // https://community.khronos.org/t/blending-mode/34770/4 + //multiply a * b + //screen 1 - (1 - a) * (1 - b) + //darken min(a, b) + //lighten max(a, b) + //difference abs(a - b) + //negation 1 - abs(1 - a - b) + //exclusion a + b - 2 * a * b + //overlay a < .5 ? (2 * a * b) : (1 - 2 * (1 - a) * (1 - b)) + //hard light b < .5 ? (2 * a * b) : (1 - 2 * (1 - a) * (1 - b)) + //soft light b < .5 ? (2 * a * b + a * a * (1 - 2 * b)) : (sqrt(a) * (2 * b - 1) + (2 * a) * (1 - b)) + //dodge a / (1 - b) + //burn 1 - (1 - a) / b + } +} + +val BlendMode.ordinal: Int get() = BlendMode.TO_ORDINAL.getOrElse(this) { -1 } diff --git a/korge/src/korlibs/korge/input/Gestures.kt b/korge-core/src/korlibs/korge/input/Gestures.kt similarity index 100% rename from korge/src/korlibs/korge/input/Gestures.kt rename to korge-core/src/korlibs/korge/input/Gestures.kt diff --git a/korge/src/korlibs/korge/input/Input.kt b/korge-core/src/korlibs/korge/input/Input.kt similarity index 98% rename from korge/src/korlibs/korge/input/Input.kt rename to korge-core/src/korlibs/korge/input/Input.kt index cfa3e79be9..474d496c18 100644 --- a/korge/src/korlibs/korge/input/Input.kt +++ b/korge-core/src/korlibs/korge/input/Input.kt @@ -45,7 +45,7 @@ class Input : Extra by Extra.Mixin() { fun getTouch(id: Int) = touches.firstOrNull { it.id == id } ?: dummyTouch @KorgeInternal - internal fun updateTouches(touchEvent: TouchEvent) { + fun updateTouches(touchEvent: TouchEvent) { touch.copyFrom(touchEvent) } @@ -172,7 +172,7 @@ class Input : Extra by Extra.Mixin() { } @KorgeInternal - internal fun triggerOldKeyEvent(e: KeyEvent) { + fun triggerOldKeyEvent(e: KeyEvent) { when (e.type) { KeyEvent.Type.DOWN -> { setKey(e.keyCode, true) diff --git a/korge/src/korlibs/korge/internal/DefaultViewport.kt b/korge-core/src/korlibs/korge/internal/DefaultViewport.kt similarity index 75% rename from korge/src/korlibs/korge/internal/DefaultViewport.kt rename to korge-core/src/korlibs/korge/internal/DefaultViewport.kt index 870bbd26bc..c9fd7709b7 100644 --- a/korge/src/korlibs/korge/internal/DefaultViewport.kt +++ b/korge-core/src/korlibs/korge/internal/DefaultViewport.kt @@ -2,7 +2,7 @@ package korlibs.korge.internal import korlibs.math.geom.* -@PublishedApi internal object DefaultViewport { +object DefaultViewport { const val WIDTH = 1280 const val HEIGHT = 720 val SIZE = Size(WIDTH, HEIGHT) diff --git a/korge/src/korlibs/korge/internal/KorgeInternal.kt b/korge-core/src/korlibs/korge/internal/KorgeInternal.kt similarity index 100% rename from korge/src/korlibs/korge/internal/KorgeInternal.kt rename to korge-core/src/korlibs/korge/internal/KorgeInternal.kt diff --git a/korge/src/korlibs/korge/internal/KorgeUntested.kt b/korge-core/src/korlibs/korge/internal/KorgeUntested.kt similarity index 100% rename from korge/src/korlibs/korge/internal/KorgeUntested.kt rename to korge-core/src/korlibs/korge/internal/KorgeUntested.kt diff --git a/korge/src/korlibs/korge/internal/KorgeUnused.kt b/korge-core/src/korlibs/korge/internal/KorgeUnused.kt similarity index 100% rename from korge/src/korlibs/korge/internal/KorgeUnused.kt rename to korge-core/src/korlibs/korge/internal/KorgeUnused.kt diff --git a/korge/src/korlibs/korge/logger/LoggerExt.kt b/korge-core/src/korlibs/korge/logger/LoggerExt.kt similarity index 100% rename from korge/src/korlibs/korge/logger/LoggerExt.kt rename to korge-core/src/korlibs/korge/logger/LoggerExt.kt diff --git a/korge/src/korlibs/korge/render/AgAutoFreeManager.kt b/korge-core/src/korlibs/korge/render/AgAutoFreeManager.kt similarity index 96% rename from korge/src/korlibs/korge/render/AgAutoFreeManager.kt rename to korge-core/src/korlibs/korge/render/AgAutoFreeManager.kt index aab145c79b..9a1dbd3848 100644 --- a/korge/src/korlibs/korge/render/AgAutoFreeManager.kt +++ b/korge-core/src/korlibs/korge/render/AgAutoFreeManager.kt @@ -3,6 +3,7 @@ package korlibs.korge.render import korlibs.datastructure.* import korlibs.graphics.* import korlibs.io.lang.* +import korlibs.korge.internal.* // @TODO: This is pretty generic, we could expose it elsewhere class AgAutoFreeManager( @@ -40,7 +41,8 @@ class AgAutoFreeManager( } } - internal fun gc() { + @KorgeInternal + fun gc() { // Delete elements that didn't survive the last GC for (entry in availableInLastGC) { if (!cachedCloseables.contains(entry.closeable)) { diff --git a/korge/src/korlibs/korge/render/AgBitmapTextureManager.kt b/korge-core/src/korlibs/korge/render/AgBitmapTextureManager.kt similarity index 97% rename from korge/src/korlibs/korge/render/AgBitmapTextureManager.kt rename to korge-core/src/korlibs/korge/render/AgBitmapTextureManager.kt index ece88350c8..f332cb4909 100644 --- a/korge/src/korlibs/korge/render/AgBitmapTextureManager.kt +++ b/korge-core/src/korlibs/korge/render/AgBitmapTextureManager.kt @@ -64,7 +64,8 @@ class AgBitmapTextureManager( //var BmpCoordsWithBitmap._texture: Texture? by Extra.Property { null } /** Wrapper of [TextureBase] that contains all the [TextureCoords] slices referenced as [BitmapCoords] in our current cache */ - internal class BitmapTextureInfo { + @KorgeInternal + class BitmapTextureInfo { var usedMemory: Int = 0 var textureBase: TextureBase = TextureBase(null, 0, 0) val slices = FastIdentityMap() @@ -83,7 +84,8 @@ class AgBitmapTextureManager( private val textureInfoPool = Pool(reset = { it.reset() }) { BitmapTextureInfo() } private val bitmapsToTextureBase = FastIdentityMap() - internal fun getBitmapsWithTextureInfoCopy(): Map = bitmapsToTextureBase.toMap() + @KorgeInternal + fun getBitmapsWithTextureInfoCopy(): Map = bitmapsToTextureBase.toMap() private var cachedBitmap: Bitmap? = null private var cachedBitmapTextureInfo: BitmapTextureInfo? = null @@ -184,7 +186,8 @@ class AgBitmapTextureManager( /** * Called automatically by the engine after the render has been executed (each frame). It executes a texture GC every [framesBetweenGC] frames. */ - internal fun afterRender() { + @KorgeInternal + fun afterRender() { // Prevent leaks when not referenced anymore clearFastCacheAccess() @@ -199,7 +202,8 @@ class AgBitmapTextureManager( * Performs a kind of Garbage Collection of textures references since the last GC. * This method is automatically executed every [framesBetweenGC] frames. **/ - internal fun gc() { + @KorgeInternal + fun gc() { //println("AgBitmapTextureManager.gc[${referencedBitmaps.size}] - [${referencedBitmapsSinceGC.size}]") referencedBitmaps.fastForEach { bmp -> when { diff --git a/korge/src/korlibs/korge/render/AgBufferManager.kt b/korge-core/src/korlibs/korge/render/AgBufferManager.kt similarity index 100% rename from korge/src/korlibs/korge/render/AgBufferManager.kt rename to korge-core/src/korlibs/korge/render/AgBufferManager.kt diff --git a/korge/src/korlibs/korge/render/BatchBuilder2D.kt b/korge-core/src/korlibs/korge/render/BatchBuilder2D.kt similarity index 99% rename from korge/src/korlibs/korge/render/BatchBuilder2D.kt rename to korge-core/src/korlibs/korge/render/BatchBuilder2D.kt index 887a539a04..989df19783 100644 --- a/korge/src/korlibs/korge/render/BatchBuilder2D.kt +++ b/korge-core/src/korlibs/korge/render/BatchBuilder2D.kt @@ -9,8 +9,8 @@ import korlibs.graphics.shader.* import korlibs.image.bitmap.* import korlibs.image.color.* import korlibs.io.async.* +import korlibs.korge.blend.* import korlibs.korge.internal.* -import korlibs.korge.view.* import korlibs.logger.* import korlibs.math.geom.* import korlibs.memory.* @@ -777,7 +777,8 @@ class BatchBuilder2D( } } -internal val BB_MAX_TEXTURES = when { +@KorgeInternal +val BB_MAX_TEXTURES = when { Platform.isLinux && Platform.arch.isArm && Platform.arch.is32Bits -> 1 //"iosArm32" -> 1 else -> 4 diff --git a/korge/src/korlibs/korge/render/BitmapExt.kt b/korge-core/src/korlibs/korge/render/BitmapExt.kt similarity index 100% rename from korge/src/korlibs/korge/render/BitmapExt.kt rename to korge-core/src/korlibs/korge/render/BitmapExt.kt diff --git a/korge-core/src/korlibs/korge/render/BoundsProvider.kt b/korge-core/src/korlibs/korge/render/BoundsProvider.kt new file mode 100644 index 0000000000..49fd785df9 --- /dev/null +++ b/korge-core/src/korlibs/korge/render/BoundsProvider.kt @@ -0,0 +1,59 @@ +package korlibs.korge.render + +import korlibs.korge.annotations.* +import korlibs.korge.internal.* +import korlibs.math.* +import korlibs.math.geom.* +import kotlin.js.* + +@JsName("NewBoundsProvider") +fun BoundsProvider(): BoundsProvider.Base = BoundsProvider.Base() + +interface BoundsProvider { + var windowToGlobalMatrix: Matrix + var windowToGlobalTransform: MatrixTransform + var globalToWindowMatrix: Matrix + var globalToWindowTransform: MatrixTransform + var actualVirtualBounds: Rectangle + + @KorgeExperimental val actualVirtualLeft: Int get() = actualVirtualBounds.left.toIntRound() + @KorgeExperimental val actualVirtualTop: Int get() = actualVirtualBounds.top.toIntRound() + @KorgeExperimental val actualVirtualWidth: Int get() = actualVirtualBounds.width.toIntRound() + @KorgeExperimental val actualVirtualHeight: Int get() = actualVirtualBounds.height.toIntRound() + //@KorgeExperimental var actualVirtualWidth = DefaultViewport.WIDTH; private set + //@KorgeExperimental var actualVirtualHeight = DefaultViewport.HEIGHT; private set + + val virtualLeft: Double get() = actualVirtualBounds.left.toDouble() + val virtualTop: Double get() = actualVirtualBounds.top.toDouble() + val virtualRight: Double get() = actualVirtualBounds.right.toDouble() + val virtualBottom: Double get() = actualVirtualBounds.bottom.toDouble() + + @KorgeExperimental + val actualVirtualRight: Double get() = actualVirtualBounds.right.toDouble() + @KorgeExperimental + val actualVirtualBottom: Double get() = actualVirtualBounds.bottom.toDouble() + + fun globalToWindowBounds(bounds: Rectangle): Rectangle = + bounds.transformed(globalToWindowMatrix) + + val windowToGlobalScale: Scale get() = windowToGlobalTransform.scale + val windowToGlobalScaleX: Double get() = windowToGlobalTransform.scale.scaleX + val windowToGlobalScaleY: Double get() = windowToGlobalTransform.scale.scaleY + val windowToGlobalScaleAvg: Double get() = windowToGlobalTransform.scale.scaleAvg + + val globalToWindowScale: Scale get() = globalToWindowTransform.scale + val globalToWindowScaleX: Double get() = globalToWindowTransform.scaleX + val globalToWindowScaleY: Double get() = globalToWindowTransform.scaleY + val globalToWindowScaleAvg: Double get() = globalToWindowTransform.scaleAvg + + fun windowToGlobalCoords(pos: Point): Point = windowToGlobalMatrix.transform(pos) + fun globalToWindowCoords(pos: Point): Point = globalToWindowMatrix.transform(pos) + + open class Base : BoundsProvider { + override var windowToGlobalMatrix: Matrix = Matrix() + override var windowToGlobalTransform: MatrixTransform = MatrixTransform() + override var globalToWindowMatrix: Matrix = Matrix() + override var globalToWindowTransform: MatrixTransform = MatrixTransform() + override var actualVirtualBounds: Rectangle = Rectangle(0, 0, DefaultViewport.WIDTH, DefaultViewport.HEIGHT) + } +} diff --git a/korge/src/korlibs/korge/render/LineRenderBatcher.kt b/korge-core/src/korlibs/korge/render/LineRenderBatcher.kt similarity index 98% rename from korge/src/korlibs/korge/render/LineRenderBatcher.kt rename to korge-core/src/korlibs/korge/render/LineRenderBatcher.kt index ebd1c5eebd..0ec0096026 100644 --- a/korge/src/korlibs/korge/render/LineRenderBatcher.kt +++ b/korge-core/src/korlibs/korge/render/LineRenderBatcher.kt @@ -7,8 +7,8 @@ import korlibs.graphics.* import korlibs.graphics.shader.* import korlibs.image.color.* import korlibs.io.async.* +import korlibs.korge.blend.* import korlibs.korge.internal.* -import korlibs.korge.view.* import korlibs.math.geom.* import korlibs.math.geom.shape.* import korlibs.math.geom.vector.* @@ -80,8 +80,9 @@ class LineRenderBatcher( private val vertices = Buffer.allocDirect(6 * 4 * maxVertexCount) @PublishedApi internal var viewMat = Matrix4() - @PublishedApi - internal var vertexCount = 0 + //@set:PublishedApi + var vertexCount = 0 + internal set @PublishedApi internal var vertexPos = 0 diff --git a/korge/src/korlibs/korge/render/RenderContext.kt b/korge-core/src/korlibs/korge/render/RenderContext.kt similarity index 98% rename from korge/src/korlibs/korge/render/RenderContext.kt rename to korge-core/src/korlibs/korge/render/RenderContext.kt index b8b162706f..b8b79459db 100644 --- a/korge/src/korlibs/korge/render/RenderContext.kt +++ b/korge-core/src/korlibs/korge/render/RenderContext.kt @@ -12,7 +12,6 @@ import korlibs.io.async.* import korlibs.io.lang.* import korlibs.korge.internal.* import korlibs.korge.stat.* -import korlibs.korge.view.* import korlibs.math.geom.* import korlibs.memory.unit.* import korlibs.render.* @@ -165,14 +164,6 @@ class RenderContext( enum class FlushKind { STATE, FULL } - val views: Views? = bp as? Views? - - var debugAnnotateView: View? = null - set(value) { - views?.invalidatedView(field) - field = value - views?.invalidatedView(field) - } var debugExtraFontScale : Double = 1.0 var debugExtraFontColor : RGBA = Colors.WHITE @@ -320,11 +311,13 @@ class RenderContext( */ fun refGcCloseable(closeable: AutoCloseable) = agAutoFreeManager.reference(closeable) - @PublishedApi internal fun beforeRender() { + @KorgeInternal + fun beforeRender() { batch.beforeRender() } - @PublishedApi internal fun afterRender() { + @KorgeInternal + fun afterRender() { flush() finish() batch.afterRender() diff --git a/korge/src/korlibs/korge/render/RenderContext2D.kt b/korge-core/src/korlibs/korge/render/RenderContext2D.kt similarity index 96% rename from korge/src/korlibs/korge/render/RenderContext2D.kt rename to korge-core/src/korlibs/korge/render/RenderContext2D.kt index 80e80d3e1d..902367a1e3 100644 --- a/korge/src/korlibs/korge/render/RenderContext2D.kt +++ b/korge-core/src/korlibs/korge/render/RenderContext2D.kt @@ -5,8 +5,8 @@ import korlibs.graphics.* import korlibs.graphics.shader.* import korlibs.image.bitmap.* import korlibs.image.color.* +import korlibs.korge.blend.* import korlibs.korge.internal.* -import korlibs.korge.view.* import korlibs.logger.* import korlibs.math.geom.* import korlibs.math.geom.shape.* @@ -297,15 +297,3 @@ class RenderContext2D( return AGScissor.fromBounds(tl.x.toFloat(), tl.y.toFloat(), br.x.toFloat(), br.y.toFloat()) } } - -inline fun View.renderCtx2d(ctx: RenderContext, crossinline block: (RenderContext2D) -> Unit) { - ctx.useCtx2d { context -> - context.keep { - context.size = Size(this@renderCtx2d.width, this@renderCtx2d.height) - context.blendMode = renderBlendMode - context.multiplyColor = renderColorMul - context.setMatrix(globalMatrix) - block(context) - } - } -} diff --git a/korge/src/korlibs/korge/render/SDFShaders.kt b/korge-core/src/korlibs/korge/render/SDFShaders.kt similarity index 100% rename from korge/src/korlibs/korge/render/SDFShaders.kt rename to korge-core/src/korlibs/korge/render/SDFShaders.kt diff --git a/korge/src/korlibs/korge/render/Texture.kt b/korge-core/src/korlibs/korge/render/Texture.kt similarity index 100% rename from korge/src/korlibs/korge/render/Texture.kt rename to korge-core/src/korlibs/korge/render/Texture.kt diff --git a/korge/src/korlibs/korge/render/TextureWithBitmapSlice.kt b/korge-core/src/korlibs/korge/render/TextureWithBitmapSlice.kt similarity index 100% rename from korge/src/korlibs/korge/render/TextureWithBitmapSlice.kt rename to korge-core/src/korlibs/korge/render/TextureWithBitmapSlice.kt diff --git a/korge/src/korlibs/korge/render/TexturedVertexArray.kt b/korge-core/src/korlibs/korge/render/TexturedVertexArray.kt similarity index 100% rename from korge/src/korlibs/korge/render/TexturedVertexArray.kt rename to korge-core/src/korlibs/korge/render/TexturedVertexArray.kt diff --git a/korge/src/korlibs/korge/render/VertexInfo.kt b/korge-core/src/korlibs/korge/render/VertexInfo.kt similarity index 100% rename from korge/src/korlibs/korge/render/VertexInfo.kt rename to korge-core/src/korlibs/korge/render/VertexInfo.kt diff --git a/korge/src/korlibs/korge/resources/Path.kt b/korge-core/src/korlibs/korge/resources/Path.kt similarity index 100% rename from korge/src/korlibs/korge/resources/Path.kt rename to korge-core/src/korlibs/korge/resources/Path.kt diff --git a/korge/src/korlibs/korge/resources/ResourcesExt.kt b/korge-core/src/korlibs/korge/resources/ResourcesExt.kt similarity index 100% rename from korge/src/korlibs/korge/resources/ResourcesExt.kt rename to korge-core/src/korlibs/korge/resources/ResourcesExt.kt diff --git a/korge/src/korlibs/korge/resources/ResourcesRoot.kt b/korge-core/src/korlibs/korge/resources/ResourcesRoot.kt similarity index 100% rename from korge/src/korlibs/korge/resources/ResourcesRoot.kt rename to korge-core/src/korlibs/korge/resources/ResourcesRoot.kt diff --git a/korge/src/korlibs/korge/service/storage/IStorage.kt b/korge-core/src/korlibs/korge/service/storage/IStorage.kt similarity index 100% rename from korge/src/korlibs/korge/service/storage/IStorage.kt rename to korge-core/src/korlibs/korge/service/storage/IStorage.kt diff --git a/korge/src/korlibs/korge/service/storage/InmemoryStorage.kt b/korge-core/src/korlibs/korge/service/storage/InmemoryStorage.kt similarity index 100% rename from korge/src/korlibs/korge/service/storage/InmemoryStorage.kt rename to korge-core/src/korlibs/korge/service/storage/InmemoryStorage.kt diff --git a/korge/src/korlibs/korge/service/vibration/NativeVibration.kt b/korge-core/src/korlibs/korge/service/vibration/NativeVibration.kt similarity index 76% rename from korge/src/korlibs/korge/service/vibration/NativeVibration.kt rename to korge-core/src/korlibs/korge/service/vibration/NativeVibration.kt index 6b43be13fd..039a6d93a8 100644 --- a/korge/src/korlibs/korge/service/vibration/NativeVibration.kt +++ b/korge-core/src/korlibs/korge/service/vibration/NativeVibration.kt @@ -1,18 +1,13 @@ package korlibs.korge.service.vibration -import korlibs.datastructure.extraPropertyThis -import korlibs.time.TimeSpan -import korlibs.korge.view.Views -import kotlin.native.concurrent.ThreadLocal +import kotlin.coroutines.* import kotlin.time.* -val Views.vibration by extraPropertyThis { NativeVibration(this) } - /** * Support for device vibrations. Currently only works in Browser and Android target. * The `amplitude` is only available on android. */ -expect class NativeVibration constructor(views: Views) { +expect class NativeVibration constructor(coroutineContext: CoroutineContext) { /** * @param timings list of alternating ON-OFF durations in milliseconds. Staring with ON. diff --git a/korge/src/korlibs/korge/stat/Stats.kt b/korge-core/src/korlibs/korge/stat/Stats.kt similarity index 100% rename from korge/src/korlibs/korge/stat/Stats.kt rename to korge-core/src/korlibs/korge/stat/Stats.kt diff --git a/korge/src/korlibs/korge/tests/TestCoroutineDispatcher.kt b/korge-core/src/korlibs/korge/tests/TestCoroutineDispatcher.kt similarity index 100% rename from korge/src/korlibs/korge/tests/TestCoroutineDispatcher.kt rename to korge-core/src/korlibs/korge/tests/TestCoroutineDispatcher.kt diff --git a/korge/src/korlibs/korge/tween/tweenbase.kt b/korge-core/src/korlibs/korge/tween/tweenbase.kt similarity index 99% rename from korge/src/korlibs/korge/tween/tweenbase.kt rename to korge-core/src/korlibs/korge/tween/tweenbase.kt index a414c393de..2047eff55e 100644 --- a/korge/src/korlibs/korge/tween/tweenbase.kt +++ b/korge-core/src/korlibs/korge/tween/tweenbase.kt @@ -1,6 +1,7 @@ package korlibs.korge.tween import korlibs.image.color.* +import korlibs.korge.internal.* import korlibs.math.* import korlibs.math.geom.* import korlibs.math.geom.bezier.* @@ -182,8 +183,8 @@ internal fun _interpolateScale(ratio: Ratio, l: Scale, r: Scale): Scale = ratio. internal fun _interpolateFloat(ratio: Ratio, l: Float, r: Float): Float = ratio.interpolate(l, r) @PublishedApi internal fun _interpolateColor(ratio: Ratio, l: RGBA, r: RGBA): RGBA = RGBA.mixRgba(l, r, ratio) -@PublishedApi -internal fun _interpolateAngle(ratio: Ratio, l: Angle, r: Angle): Angle = ratio.interpolateAngleNormalized(l, r) +@KorgeInternal +fun _interpolateAngle(ratio: Ratio, l: Angle, r: Angle): Angle = ratio.interpolateAngleNormalized(l, r) @PublishedApi internal fun _interpolateAngleDenormalized(ratio: Ratio, l: Angle, r: Angle): Angle = ratio.interpolateAngleDenormalized(l, r) @PublishedApi diff --git a/korge/src/korlibs/render/DeviceDimensionsProvider.kt b/korge-core/src/korlibs/render/DeviceDimensionsProvider.kt similarity index 100% rename from korge/src/korlibs/render/DeviceDimensionsProvider.kt rename to korge-core/src/korlibs/render/DeviceDimensionsProvider.kt diff --git a/korge/src/korlibs/render/DialogInterface.kt b/korge-core/src/korlibs/render/DialogInterface.kt similarity index 100% rename from korge/src/korlibs/render/DialogInterface.kt rename to korge-core/src/korlibs/render/DialogInterface.kt diff --git a/korge/src/korlibs/render/GameWindow.kt b/korge-core/src/korlibs/render/GameWindow.kt similarity index 99% rename from korge/src/korlibs/render/GameWindow.kt rename to korge-core/src/korlibs/render/GameWindow.kt index 71005a3bbf..d331029401 100644 --- a/korge/src/korlibs/render/GameWindow.kt +++ b/korge-core/src/korlibs/render/GameWindow.kt @@ -11,11 +11,11 @@ import korlibs.image.vector.* import korlibs.io.* import korlibs.io.async.* import korlibs.io.file.* -import korlibs.korge.view.* import korlibs.logger.* import korlibs.math.geom.* import korlibs.memory.* import korlibs.render.GameWindow.Quality.* +import korlibs.render.event.* import korlibs.time.* import korlibs.time.measureTime import kotlinx.coroutines.* @@ -850,3 +850,4 @@ fun GameWindow.onDragAndDropFileEvent(block: suspend (DropFileEvent) -> Unit) { } } } + diff --git a/korge/src/korlibs/render/GameWindowCoroutineDispatcher.kt b/korge-core/src/korlibs/render/GameWindowCoroutineDispatcher.kt similarity index 100% rename from korge/src/korlibs/render/GameWindowCoroutineDispatcher.kt rename to korge-core/src/korlibs/render/GameWindowCoroutineDispatcher.kt diff --git a/korge/src/korlibs/render/Korgw.kt b/korge-core/src/korlibs/render/Korgw.kt similarity index 100% rename from korge/src/korlibs/render/Korgw.kt rename to korge-core/src/korlibs/render/Korgw.kt diff --git a/korge/src/korlibs/render/SyncEventLoopCoroutineDispatcher.kt b/korge-core/src/korlibs/render/SyncEventLoopCoroutineDispatcher.kt similarity index 100% rename from korge/src/korlibs/render/SyncEventLoopCoroutineDispatcher.kt rename to korge-core/src/korlibs/render/SyncEventLoopCoroutineDispatcher.kt diff --git a/korge/src/korlibs/render/TouchEventHandler.kt b/korge-core/src/korlibs/render/TouchEventHandler.kt similarity index 100% rename from korge/src/korlibs/render/TouchEventHandler.kt rename to korge-core/src/korlibs/render/TouchEventHandler.kt diff --git a/korge-core/src/korlibs/render/event/UpdateEvent.kt b/korge-core/src/korlibs/render/event/UpdateEvent.kt new file mode 100644 index 0000000000..0db5b7b09e --- /dev/null +++ b/korge-core/src/korlibs/render/event/UpdateEvent.kt @@ -0,0 +1,21 @@ +package korlibs.render.event + +import korlibs.event.* +import korlibs.time.* +import kotlin.time.* + +class UpdateEvent(var fastDeltaTime: FastDuration = FastDuration.ZERO) : Event(), TEvent { + constructor(deltaTime: Duration) : this(deltaTime.fast) + var deltaTime: Duration + set(value) { fastDeltaTime = value.fast } + get() = fastDeltaTime.toDuration() + + companion object : EventType + override val type: EventType get() = UpdateEvent + + fun copyFrom(other: UpdateEvent) { + this.fastDeltaTime = other.fastDeltaTime + } + + override fun toString(): String = "UpdateEvent(time=$fastDeltaTime)" +} diff --git a/korge/src/korlibs/render/jvmEngine.kt b/korge-core/src/korlibs/render/jvmEngine.kt similarity index 100% rename from korge/src/korlibs/render/jvmEngine.kt rename to korge-core/src/korlibs/render/jvmEngine.kt diff --git a/korge/src@android/korlibs/graphics/AGAndroid.kt b/korge-core/src@android/korlibs/graphics/AGAndroid.kt similarity index 100% rename from korge/src@android/korlibs/graphics/AGAndroid.kt rename to korge-core/src@android/korlibs/graphics/AGAndroid.kt diff --git a/korge/src@android/korlibs/graphics/gl/AGOpenglFactoryAndroid.kt b/korge-core/src@android/korlibs/graphics/gl/AGOpenglFactoryAndroid.kt similarity index 100% rename from korge/src@android/korlibs/graphics/gl/AGOpenglFactoryAndroid.kt rename to korge-core/src@android/korlibs/graphics/gl/AGOpenglFactoryAndroid.kt diff --git a/korge/src@android/korlibs/kgl/KmlGlAndroid.kt b/korge-core/src@android/korlibs/kgl/KmlGlAndroid.kt similarity index 100% rename from korge/src@android/korlibs/kgl/KmlGlAndroid.kt rename to korge-core/src@android/korlibs/kgl/KmlGlAndroid.kt diff --git a/korge/src@android/korlibs/kgl/KmlGlContextAndroid.kt b/korge-core/src@android/korlibs/kgl/KmlGlContextAndroid.kt similarity index 100% rename from korge/src@android/korlibs/kgl/KmlGlContextAndroid.kt rename to korge-core/src@android/korlibs/kgl/KmlGlContextAndroid.kt diff --git a/korge/src@android/korlibs/korge/KorgeReload_getReloadedClass.kt b/korge-core/src@android/korlibs/korge/KorgeReload_getReloadedClass.kt similarity index 100% rename from korge/src@android/korlibs/korge/KorgeReload_getReloadedClass.kt rename to korge-core/src@android/korlibs/korge/KorgeReload_getReloadedClass.kt diff --git a/korge/src@android/korlibs/korge/service/vibration/NativeVibration.kt b/korge-core/src@android/korlibs/korge/service/vibration/NativeVibration.kt similarity index 89% rename from korge/src@android/korlibs/korge/service/vibration/NativeVibration.kt rename to korge-core/src@android/korlibs/korge/service/vibration/NativeVibration.kt index 58b2ce05d8..a4b6af03a4 100644 --- a/korge/src@android/korlibs/korge/service/vibration/NativeVibration.kt +++ b/korge-core/src@android/korlibs/korge/service/vibration/NativeVibration.kt @@ -2,20 +2,19 @@ package korlibs.korge.service.vibration import android.annotation.* import android.os.* +import korlibs.io.android.* import korlibs.time.* -import korlibs.korge.android.* -import korlibs.korge.view.* -import korlibs.render.* +import kotlin.coroutines.* import kotlin.math.* -actual class NativeVibration actual constructor(views: Views) { +actual class NativeVibration actual constructor(val coroutineContext: CoroutineContext) { companion object { private const val NO_REPEAT = -1 } private val vibrator: Vibrator? = when { - Build.VERSION.SDK_INT >= 23 -> views.androidContext.getSystemService(Vibrator::class.java) + Build.VERSION.SDK_INT >= 23 -> coroutineContext.androidContext().getSystemService(Vibrator::class.java) else -> null } diff --git a/korge/src@android/korlibs/render/AndroidGameController.kt b/korge-core/src@android/korlibs/render/AndroidGameController.kt similarity index 100% rename from korge/src@android/korlibs/render/AndroidGameController.kt rename to korge-core/src@android/korlibs/render/AndroidGameController.kt diff --git a/korge/src@android/korlibs/render/AndroidKeyMap.kt b/korge-core/src@android/korlibs/render/AndroidKeyMap.kt similarity index 100% rename from korge/src@android/korlibs/render/AndroidKeyMap.kt rename to korge-core/src@android/korlibs/render/AndroidKeyMap.kt diff --git a/korge/src@android/korlibs/render/DefaultGameWindowAndroid.kt b/korge-core/src@android/korlibs/render/DefaultGameWindowAndroid.kt similarity index 100% rename from korge/src@android/korlibs/render/DefaultGameWindowAndroid.kt rename to korge-core/src@android/korlibs/render/DefaultGameWindowAndroid.kt diff --git a/korge/src@android/korlibs/render/DialogInterfaceImpl.kt b/korge-core/src@android/korlibs/render/DialogInterfaceImpl.kt similarity index 100% rename from korge/src@android/korlibs/render/DialogInterfaceImpl.kt rename to korge-core/src@android/korlibs/render/DialogInterfaceImpl.kt diff --git a/korge/src@android/korlibs/render/KorgwActivity.kt b/korge-core/src@android/korlibs/render/KorgwActivity.kt similarity index 100% rename from korge/src@android/korlibs/render/KorgwActivity.kt rename to korge-core/src@android/korlibs/render/KorgwActivity.kt diff --git a/korge/src@android/korlibs/render/KorgwSurfaceView.kt b/korge-core/src@android/korlibs/render/KorgwSurfaceView.kt similarity index 100% rename from korge/src@android/korlibs/render/KorgwSurfaceView.kt rename to korge-core/src@android/korlibs/render/KorgwSurfaceView.kt diff --git a/korge/src@darwin/korlibs/graphics/gl/AGOpenglFactoryNative.kt b/korge-core/src@darwin/korlibs/graphics/gl/AGOpenglFactoryNative.kt similarity index 100% rename from korge/src@darwin/korlibs/graphics/gl/AGOpenglFactoryNative.kt rename to korge-core/src@darwin/korlibs/graphics/gl/AGOpenglFactoryNative.kt diff --git a/korge/src@darwin/korlibs/kgl/KmlGlContextAppleMobile.kt b/korge-core/src@darwin/korlibs/kgl/KmlGlContextAppleMobile.kt similarity index 100% rename from korge/src@darwin/korlibs/kgl/KmlGlContextAppleMobile.kt rename to korge-core/src@darwin/korlibs/kgl/KmlGlContextAppleMobile.kt diff --git a/korge/src@darwin/korlibs/kgl/KmlGlNative.kt b/korge-core/src@darwin/korlibs/kgl/KmlGlNative.kt similarity index 100% rename from korge/src@darwin/korlibs/kgl/KmlGlNative.kt rename to korge-core/src@darwin/korlibs/kgl/KmlGlNative.kt diff --git a/korge/src@darwin/korlibs/korge/KorgeReloadNative.kt b/korge-core/src@darwin/korlibs/korge/KorgeReloadNative.kt similarity index 100% rename from korge/src@darwin/korlibs/korge/KorgeReloadNative.kt rename to korge-core/src@darwin/korlibs/korge/KorgeReloadNative.kt diff --git a/korge/src@darwin/korlibs/korge/native/KorgeSimpleNativeSyncIO.kt b/korge-core/src@darwin/korlibs/korge/native/KorgeSimpleNativeSyncIO.kt similarity index 100% rename from korge/src@darwin/korlibs/korge/native/KorgeSimpleNativeSyncIO.kt rename to korge-core/src@darwin/korlibs/korge/native/KorgeSimpleNativeSyncIO.kt diff --git a/korge/src@darwin/korlibs/korge/service/vibration/NativeVibration.kt b/korge-core/src@darwin/korlibs/korge/service/vibration/NativeVibration.kt similarity index 83% rename from korge/src@darwin/korlibs/korge/service/vibration/NativeVibration.kt rename to korge-core/src@darwin/korlibs/korge/service/vibration/NativeVibration.kt index dac20b9f24..4f6dca848a 100644 --- a/korge/src@darwin/korlibs/korge/service/vibration/NativeVibration.kt +++ b/korge-core/src@darwin/korlibs/korge/service/vibration/NativeVibration.kt @@ -1,10 +1,9 @@ package korlibs.korge.service.vibration -import korlibs.time.TimeSpan -import korlibs.korge.view.Views +import kotlin.coroutines.* import kotlin.time.* -actual class NativeVibration actual constructor(val views: Views) { +actual class NativeVibration actual constructor(val coroutineContext: CoroutineContext) { /** * @param timings list of alternating ON-OFF durations in milliseconds. Staring with ON. * @param amplitudes list of intensities of the vibration. A `0.2` results in 20% vibration power. diff --git a/korge/src@darwin/korlibs/metal/AGMetal.kt b/korge-core/src@darwin/korlibs/metal/AGMetal.kt similarity index 100% rename from korge/src@darwin/korlibs/metal/AGMetal.kt rename to korge-core/src@darwin/korlibs/metal/AGMetal.kt diff --git a/korge/src@darwin/korlibs/metal/AGMetalConverter.kt b/korge-core/src@darwin/korlibs/metal/AGMetalConverter.kt similarity index 100% rename from korge/src@darwin/korlibs/metal/AGMetalConverter.kt rename to korge-core/src@darwin/korlibs/metal/AGMetalConverter.kt diff --git a/korge/src@darwin/korlibs/metal/MTLBuffer.kt b/korge-core/src@darwin/korlibs/metal/MTLBuffer.kt similarity index 100% rename from korge/src@darwin/korlibs/metal/MTLBuffer.kt rename to korge-core/src@darwin/korlibs/metal/MTLBuffer.kt diff --git a/korge/src@darwin/korlibs/metal/MetalProgram.kt b/korge-core/src@darwin/korlibs/metal/MetalProgram.kt similarity index 100% rename from korge/src@darwin/korlibs/metal/MetalProgram.kt rename to korge-core/src@darwin/korlibs/metal/MetalProgram.kt diff --git a/korge/src@darwin/korlibs/metal/shader/MetalShaderCompiler.kt b/korge-core/src@darwin/korlibs/metal/shader/MetalShaderCompiler.kt similarity index 100% rename from korge/src@darwin/korlibs/metal/shader/MetalShaderCompiler.kt rename to korge-core/src@darwin/korlibs/metal/shader/MetalShaderCompiler.kt diff --git a/korge/src@darwin/korlibs/render/DarwinGameControllerNative.kt b/korge-core/src@darwin/korlibs/render/DarwinGameControllerNative.kt similarity index 100% rename from korge/src@darwin/korlibs/render/DarwinGameControllerNative.kt rename to korge-core/src@darwin/korlibs/render/DarwinGameControllerNative.kt diff --git a/korge/src@darwin/korlibs/render/DefaultGameWindowIos.kt b/korge-core/src@darwin/korlibs/render/DefaultGameWindowIos.kt similarity index 100% rename from korge/src@darwin/korlibs/render/DefaultGameWindowIos.kt rename to korge-core/src@darwin/korlibs/render/DefaultGameWindowIos.kt diff --git a/korge/src@darwin/korlibs/render/DialogInterfaceIos.kt b/korge-core/src@darwin/korlibs/render/DialogInterfaceIos.kt similarity index 100% rename from korge/src@darwin/korlibs/render/DialogInterfaceIos.kt rename to korge-core/src@darwin/korlibs/render/DialogInterfaceIos.kt diff --git a/korge/src@darwin/korlibs/render/IosKeyMap.kt b/korge-core/src@darwin/korlibs/render/IosKeyMap.kt similarity index 100% rename from korge/src@darwin/korlibs/render/IosKeyMap.kt rename to korge-core/src@darwin/korlibs/render/IosKeyMap.kt diff --git a/korge/src@ios/korlibs/render/DefaultGameWindowIosTools.kt b/korge-core/src@ios/korlibs/render/DefaultGameWindowIosTools.kt similarity index 100% rename from korge/src@ios/korlibs/render/DefaultGameWindowIosTools.kt rename to korge-core/src@ios/korlibs/render/DefaultGameWindowIosTools.kt diff --git a/korge/src@js/korlibs/datastructure/event/JsEventLoop.kt b/korge-core/src@js/korlibs/datastructure/event/JsEventLoop.kt similarity index 100% rename from korge/src@js/korlibs/datastructure/event/JsEventLoop.kt rename to korge-core/src@js/korlibs/datastructure/event/JsEventLoop.kt diff --git a/korge/src@js/korlibs/graphics/gl/AGOpenglFactory.kt b/korge-core/src@js/korlibs/graphics/gl/AGOpenglFactory.kt similarity index 100% rename from korge/src@js/korlibs/graphics/gl/AGOpenglFactory.kt rename to korge-core/src@js/korlibs/graphics/gl/AGOpenglFactory.kt diff --git a/korge/src@js/korlibs/graphics/gl/GlExt.kt b/korge-core/src@js/korlibs/graphics/gl/GlExt.kt similarity index 100% rename from korge/src@js/korlibs/graphics/gl/GlExt.kt rename to korge-core/src@js/korlibs/graphics/gl/GlExt.kt diff --git a/korge/src@js/korlibs/kgl/KmlGlContextJs.kt b/korge-core/src@js/korlibs/kgl/KmlGlContextJs.kt similarity index 100% rename from korge/src@js/korlibs/kgl/KmlGlContextJs.kt rename to korge-core/src@js/korlibs/kgl/KmlGlContextJs.kt diff --git a/korge/src@js/korlibs/kgl/KmlGlJsCanvas.kt b/korge-core/src@js/korlibs/kgl/KmlGlJsCanvas.kt similarity index 100% rename from korge/src@js/korlibs/kgl/KmlGlJsCanvas.kt rename to korge-core/src@js/korlibs/kgl/KmlGlJsCanvas.kt diff --git a/korge/src@js/korlibs/korge/KorgeReload_getReloadedClass.kt b/korge-core/src@js/korlibs/korge/KorgeReload_getReloadedClass.kt similarity index 100% rename from korge/src@js/korlibs/korge/KorgeReload_getReloadedClass.kt rename to korge-core/src@js/korlibs/korge/KorgeReload_getReloadedClass.kt diff --git a/korge/src@js/korlibs/korge/service/vibration/NativeVibration.kt b/korge-core/src@js/korlibs/korge/service/vibration/NativeVibration.kt similarity index 86% rename from korge/src@js/korlibs/korge/service/vibration/NativeVibration.kt rename to korge-core/src@js/korlibs/korge/service/vibration/NativeVibration.kt index 041aa32f06..d9529d4bdb 100644 --- a/korge/src@js/korlibs/korge/service/vibration/NativeVibration.kt +++ b/korge-core/src@js/korlibs/korge/service/vibration/NativeVibration.kt @@ -1,10 +1,10 @@ package korlibs.korge.service.vibration -import korlibs.korge.view.* import korlibs.time.* import kotlinx.browser.* +import kotlin.coroutines.* -actual class NativeVibration actual constructor(val views: Views) { +actual class NativeVibration actual constructor(val coroutineContext: CoroutineContext) { /** * @param timings list of alternating ON-OFF durations in milliseconds. Staring with ON. diff --git a/korge/src@js/korlibs/render/DefaultGameWindowJs.kt b/korge-core/src@js/korlibs/render/DefaultGameWindowJs.kt similarity index 100% rename from korge/src@js/korlibs/render/DefaultGameWindowJs.kt rename to korge-core/src@js/korlibs/render/DefaultGameWindowJs.kt diff --git a/korge/src@js/korlibs/render/DialogInterfaceJs.kt b/korge-core/src@js/korlibs/render/DialogInterfaceJs.kt similarity index 100% rename from korge/src@js/korlibs/render/DialogInterfaceJs.kt rename to korge-core/src@js/korlibs/render/DialogInterfaceJs.kt diff --git a/korge/src@js/korlibs/render/internal/KorgwJsInternal.kt b/korge-core/src@js/korlibs/render/internal/KorgwJsInternal.kt similarity index 100% rename from korge/src@js/korlibs/render/internal/KorgwJsInternal.kt rename to korge-core/src@js/korlibs/render/internal/KorgwJsInternal.kt diff --git a/korge/src@jvm/korlibs/event/AwtKeyMap.kt b/korge-core/src@jvm/korlibs/event/AwtKeyMap.kt similarity index 100% rename from korge/src@jvm/korlibs/event/AwtKeyMap.kt rename to korge-core/src@jvm/korlibs/event/AwtKeyMap.kt diff --git a/korge/src@jvm/korlibs/graphics/gl/AGOpenglFactory.kt b/korge-core/src@jvm/korlibs/graphics/gl/AGOpenglFactory.kt similarity index 100% rename from korge/src@jvm/korlibs/graphics/gl/AGOpenglFactory.kt rename to korge-core/src@jvm/korlibs/graphics/gl/AGOpenglFactory.kt diff --git a/korge/src@jvm/korlibs/graphics/metal/AGMetal.kt b/korge-core/src@jvm/korlibs/graphics/metal/AGMetal.kt similarity index 100% rename from korge/src@jvm/korlibs/graphics/metal/AGMetal.kt rename to korge-core/src@jvm/korlibs/graphics/metal/AGMetal.kt diff --git a/korge/src@jvm/korlibs/kgl/KmlGlContextDefault.kt b/korge-core/src@jvm/korlibs/kgl/KmlGlContextDefault.kt similarity index 100% rename from korge/src@jvm/korlibs/kgl/KmlGlContextDefault.kt rename to korge-core/src@jvm/korlibs/kgl/KmlGlContextDefault.kt diff --git a/korge/src@jvm/korlibs/korge/EnsureAddOpens.kt b/korge-core/src@jvm/korlibs/korge/EnsureAddOpens.kt similarity index 100% rename from korge/src@jvm/korlibs/korge/EnsureAddOpens.kt rename to korge-core/src@jvm/korlibs/korge/EnsureAddOpens.kt diff --git a/korge/src@jvm/korlibs/korge/KorgeReload_getReloadedClass.kt b/korge-core/src@jvm/korlibs/korge/KorgeReload_getReloadedClass.kt similarity index 98% rename from korge/src@jvm/korlibs/korge/KorgeReload_getReloadedClass.kt rename to korge-core/src@jvm/korlibs/korge/KorgeReload_getReloadedClass.kt index cfda3cb85b..b49f0c2ff0 100644 --- a/korge/src@jvm/korlibs/korge/KorgeReload_getReloadedClass.kt +++ b/korge-core/src@jvm/korlibs/korge/KorgeReload_getReloadedClass.kt @@ -13,7 +13,7 @@ import kotlin.system.* internal actual val KorgeReloadInternal: KorgeReloadInternalImpl = KorgeReloadInternalJvm -internal object KorgeReloadInternalJvm : KorgeReloadInternalImpl() { +object KorgeReloadInternalJvm : KorgeReloadInternalImpl() { val logger = Logger("KorgeReloadInternalJvm") override fun getReloadedClass(clazz: KClass, context: ReloadClassContext): KClass { diff --git a/korge/src@jvm/korlibs/korge/atlas/AtlasResourceProcessor.kt b/korge-core/src@jvm/korlibs/korge/atlas/AtlasResourceProcessor.kt similarity index 100% rename from korge/src@jvm/korlibs/korge/atlas/AtlasResourceProcessor.kt rename to korge-core/src@jvm/korlibs/korge/atlas/AtlasResourceProcessor.kt diff --git a/korge/src@jvm/korlibs/korge/plugin/KorgePluginExtension.kt b/korge-core/src@jvm/korlibs/korge/plugin/KorgePluginExtension.kt similarity index 100% rename from korge/src@jvm/korlibs/korge/plugin/KorgePluginExtension.kt rename to korge-core/src@jvm/korlibs/korge/plugin/KorgePluginExtension.kt diff --git a/korge/src@jvm/korlibs/korge/plugin/KorgePluginExtensions.kt b/korge-core/src@jvm/korlibs/korge/plugin/KorgePluginExtensions.kt similarity index 100% rename from korge/src@jvm/korlibs/korge/plugin/KorgePluginExtensions.kt rename to korge-core/src@jvm/korlibs/korge/plugin/KorgePluginExtensions.kt diff --git a/korge/src@jvm/korlibs/korge/resources/ResourceProcessor.kt b/korge-core/src@jvm/korlibs/korge/resources/ResourceProcessor.kt similarity index 100% rename from korge/src@jvm/korlibs/korge/resources/ResourceProcessor.kt rename to korge-core/src@jvm/korlibs/korge/resources/ResourceProcessor.kt diff --git a/korge/src@jvm/korlibs/korge/resources/ResourceProcessorRunner.kt b/korge-core/src@jvm/korlibs/korge/resources/ResourceProcessorRunner.kt similarity index 100% rename from korge/src@jvm/korlibs/korge/resources/ResourceProcessorRunner.kt rename to korge-core/src@jvm/korlibs/korge/resources/ResourceProcessorRunner.kt diff --git a/korge/src@jvm/korlibs/korge/resources/ResourceVersion.kt b/korge-core/src@jvm/korlibs/korge/resources/ResourceVersion.kt similarity index 100% rename from korge/src@jvm/korlibs/korge/resources/ResourceVersion.kt rename to korge-core/src@jvm/korlibs/korge/resources/ResourceVersion.kt diff --git a/korge/src@jvm/korlibs/korge/service/vibration/NativeVibration.kt b/korge-core/src@jvm/korlibs/korge/service/vibration/NativeVibration.kt similarity index 72% rename from korge/src@jvm/korlibs/korge/service/vibration/NativeVibration.kt rename to korge-core/src@jvm/korlibs/korge/service/vibration/NativeVibration.kt index 53db251193..fdae018171 100644 --- a/korge/src@jvm/korlibs/korge/service/vibration/NativeVibration.kt +++ b/korge-core/src@jvm/korlibs/korge/service/vibration/NativeVibration.kt @@ -1,9 +1,10 @@ package korlibs.korge.service.vibration -import korlibs.time.TimeSpan -import korlibs.korge.view.Views +import korlibs.time.* +import kotlin.coroutines.* +import kotlin.time.* -actual class NativeVibration actual constructor(val views: Views) { +actual class NativeVibration actual constructor(val coroutineContext: CoroutineContext) { /** * @param timings list of alternating ON-OFF durations in milliseconds. Staring with ON. * @param amplitudes list of intensities of the vibration. A `0.2` results in 20% vibration power. @@ -17,6 +18,6 @@ actual class NativeVibration actual constructor(val views: Views) { * @param amplitude percentage intensity of the vibration. A `0.2` results in 20% vibration power. */ @ExperimentalUnsignedTypes - actual fun vibrate(time: TimeSpan, amplitude: Double) { + actual fun vibrate(time: Duration, amplitude: Double) { } } diff --git a/korge/src@jvm/korlibs/render/DefaultGameWindowJvm.kt b/korge-core/src@jvm/korlibs/render/DefaultGameWindowJvm.kt similarity index 100% rename from korge/src@jvm/korlibs/render/DefaultGameWindowJvm.kt rename to korge-core/src@jvm/korlibs/render/DefaultGameWindowJvm.kt diff --git a/korge/src@jvm/korlibs/render/awt/AwtAGOpenglCanvas.kt b/korge-core/src@jvm/korlibs/render/awt/AwtAGOpenglCanvas.kt similarity index 99% rename from korge/src@jvm/korlibs/render/awt/AwtAGOpenglCanvas.kt rename to korge-core/src@jvm/korlibs/render/awt/AwtAGOpenglCanvas.kt index f84155262c..33f98f72d2 100644 --- a/korge/src@jvm/korlibs/render/awt/AwtAGOpenglCanvas.kt +++ b/korge-core/src@jvm/korlibs/render/awt/AwtAGOpenglCanvas.kt @@ -3,7 +3,7 @@ package korlibs.render.awt import korlibs.graphics.* import korlibs.graphics.gl.* import korlibs.kgl.* -import korlibs.korge.view.* +import korlibs.korge.render.* import korlibs.math.geom.Rectangle import korlibs.platform.* import korlibs.render.* diff --git a/korge/src@jvm/korlibs/render/awt/AwtAg.kt b/korge-core/src@jvm/korlibs/render/awt/AwtAg.kt similarity index 100% rename from korge/src@jvm/korlibs/render/awt/AwtAg.kt rename to korge-core/src@jvm/korlibs/render/awt/AwtAg.kt diff --git a/korge/src@jvm/korlibs/render/awt/AwtExt.kt b/korge-core/src@jvm/korlibs/render/awt/AwtExt.kt similarity index 100% rename from korge/src@jvm/korlibs/render/awt/AwtExt.kt rename to korge-core/src@jvm/korlibs/render/awt/AwtExt.kt diff --git a/korge/src@jvm/korlibs/render/awt/AwtFrameTools.kt b/korge-core/src@jvm/korlibs/render/awt/AwtFrameTools.kt similarity index 100% rename from korge/src@jvm/korlibs/render/awt/AwtFrameTools.kt rename to korge-core/src@jvm/korlibs/render/awt/AwtFrameTools.kt diff --git a/korge/src@jvm/korlibs/render/awt/AwtGameWindow.kt b/korge-core/src@jvm/korlibs/render/awt/AwtGameWindow.kt similarity index 100% rename from korge/src@jvm/korlibs/render/awt/AwtGameWindow.kt rename to korge-core/src@jvm/korlibs/render/awt/AwtGameWindow.kt diff --git a/korge/src@jvm/korlibs/render/awt/BaseAwtGameWindow.kt b/korge-core/src@jvm/korlibs/render/awt/BaseAwtGameWindow.kt similarity index 100% rename from korge/src@jvm/korlibs/render/awt/BaseAwtGameWindow.kt rename to korge-core/src@jvm/korlibs/render/awt/BaseAwtGameWindow.kt diff --git a/korge/src@jvm/korlibs/render/awt/DesktopGamepadUpdater.kt b/korge-core/src@jvm/korlibs/render/awt/DesktopGamepadUpdater.kt similarity index 100% rename from korge/src@jvm/korlibs/render/awt/DesktopGamepadUpdater.kt rename to korge-core/src@jvm/korlibs/render/awt/DesktopGamepadUpdater.kt diff --git a/korge/src@jvm/korlibs/render/awt/DialogInterfaceAwt.kt b/korge-core/src@jvm/korlibs/render/awt/DialogInterfaceAwt.kt similarity index 100% rename from korge/src@jvm/korlibs/render/awt/DialogInterfaceAwt.kt rename to korge-core/src@jvm/korlibs/render/awt/DialogInterfaceAwt.kt diff --git a/korge/src@jvm/korlibs/render/awt/GLCanvas.kt b/korge-core/src@jvm/korlibs/render/awt/GLCanvas.kt similarity index 98% rename from korge/src@jvm/korlibs/render/awt/GLCanvas.kt rename to korge-core/src@jvm/korlibs/render/awt/GLCanvas.kt index 46d0917994..af3b41ffa7 100644 --- a/korge/src@jvm/korlibs/render/awt/GLCanvas.kt +++ b/korge-core/src@jvm/korlibs/render/awt/GLCanvas.kt @@ -3,8 +3,6 @@ package korlibs.render.awt import korlibs.graphics.* import korlibs.kgl.* import korlibs.graphics.gl.* -import korlibs.kgl.* -import korlibs.korge.view.* import korlibs.render.* import korlibs.render.platform.* import java.awt.* diff --git a/korge/src@jvm/korlibs/render/awt/GLCanvasGameWindow.kt b/korge-core/src@jvm/korlibs/render/awt/GLCanvasGameWindow.kt similarity index 100% rename from korge/src@jvm/korlibs/render/awt/GLCanvasGameWindow.kt rename to korge-core/src@jvm/korlibs/render/awt/GLCanvasGameWindow.kt diff --git a/korge/src@jvm/korlibs/render/awt/NewAwtGameWindow.kt b/korge-core/src@jvm/korlibs/render/awt/NewAwtGameWindow.kt similarity index 100% rename from korge/src@jvm/korlibs/render/awt/NewAwtGameWindow.kt rename to korge-core/src@jvm/korlibs/render/awt/NewAwtGameWindow.kt diff --git a/korge/src@jvm/korlibs/render/osx/Cocoa.kt b/korge-core/src@jvm/korlibs/render/osx/Cocoa.kt similarity index 100% rename from korge/src@jvm/korlibs/render/osx/Cocoa.kt rename to korge-core/src@jvm/korlibs/render/osx/Cocoa.kt diff --git a/korge/src@jvm/korlibs/render/osx/DialogInterfaceJvmCocoa.kt b/korge-core/src@jvm/korlibs/render/osx/DialogInterfaceJvmCocoa.kt similarity index 100% rename from korge/src@jvm/korlibs/render/osx/DialogInterfaceJvmCocoa.kt rename to korge-core/src@jvm/korlibs/render/osx/DialogInterfaceJvmCocoa.kt diff --git a/korge/src@jvm/korlibs/render/osx/MacosGLContext.kt b/korge-core/src@jvm/korlibs/render/osx/MacosGLContext.kt similarity index 100% rename from korge/src@jvm/korlibs/render/osx/MacosGLContext.kt rename to korge-core/src@jvm/korlibs/render/osx/MacosGLContext.kt diff --git a/korge/src@jvm/korlibs/render/osx/MacosGameWindow.kt b/korge-core/src@jvm/korlibs/render/osx/MacosGameWindow.kt similarity index 100% rename from korge/src@jvm/korlibs/render/osx/MacosGameWindow.kt rename to korge-core/src@jvm/korlibs/render/osx/MacosGameWindow.kt diff --git a/korge/src@jvm/korlibs/render/osx/OSXDisplayLink.kt b/korge-core/src@jvm/korlibs/render/osx/OSXDisplayLink.kt similarity index 100% rename from korge/src@jvm/korlibs/render/osx/OSXDisplayLink.kt rename to korge-core/src@jvm/korlibs/render/osx/OSXDisplayLink.kt diff --git a/korge/src@jvm/korlibs/render/osx/metal/MTL.kt b/korge-core/src@jvm/korlibs/render/osx/metal/MTL.kt similarity index 100% rename from korge/src@jvm/korlibs/render/osx/metal/MTL.kt rename to korge-core/src@jvm/korlibs/render/osx/metal/MTL.kt diff --git a/korge/src@jvm/korlibs/render/osx/metal/MTLExt.kt b/korge-core/src@jvm/korlibs/render/osx/metal/MTLExt.kt similarity index 100% rename from korge/src@jvm/korlibs/render/osx/metal/MTLExt.kt rename to korge-core/src@jvm/korlibs/render/osx/metal/MTLExt.kt diff --git a/korge/src@jvm/korlibs/render/platform/AwtTools.kt b/korge-core/src@jvm/korlibs/render/platform/AwtTools.kt similarity index 100% rename from korge/src@jvm/korlibs/render/platform/AwtTools.kt rename to korge-core/src@jvm/korlibs/render/platform/AwtTools.kt diff --git a/korge/src@jvm/korlibs/render/platform/BaseOpenglContext.kt b/korge-core/src@jvm/korlibs/render/platform/BaseOpenglContext.kt similarity index 100% rename from korge/src@jvm/korlibs/render/platform/BaseOpenglContext.kt rename to korge-core/src@jvm/korlibs/render/platform/BaseOpenglContext.kt diff --git a/korge/src@jvm/korlibs/render/platform/INativeGL.kt b/korge-core/src@jvm/korlibs/render/platform/INativeGL.kt similarity index 100% rename from korge/src@jvm/korlibs/render/platform/INativeGL.kt rename to korge-core/src@jvm/korlibs/render/platform/INativeGL.kt diff --git a/korge/src@jvm/korlibs/render/platform/NativeKgl.kt b/korge-core/src@jvm/korlibs/render/platform/NativeKgl.kt similarity index 100% rename from korge/src@jvm/korlibs/render/platform/NativeKgl.kt rename to korge-core/src@jvm/korlibs/render/platform/NativeKgl.kt diff --git a/korge/src@jvm/korlibs/render/win32/Win32.kt b/korge-core/src@jvm/korlibs/render/win32/Win32.kt similarity index 100% rename from korge/src@jvm/korlibs/render/win32/Win32.kt rename to korge-core/src@jvm/korlibs/render/win32/Win32.kt diff --git a/korge/src@jvm/korlibs/render/win32/Win32GameWindow.kt b/korge-core/src@jvm/korlibs/render/win32/Win32GameWindow.kt similarity index 100% rename from korge/src@jvm/korlibs/render/win32/Win32GameWindow.kt rename to korge-core/src@jvm/korlibs/render/win32/Win32GameWindow.kt diff --git a/korge/src@jvm/korlibs/render/win32/Win32Tools.kt b/korge-core/src@jvm/korlibs/render/win32/Win32Tools.kt similarity index 100% rename from korge/src@jvm/korlibs/render/win32/Win32Tools.kt rename to korge-core/src@jvm/korlibs/render/win32/Win32Tools.kt diff --git a/korge/src@jvm/korlibs/render/x11/X11Constants.kt b/korge-core/src@jvm/korlibs/render/x11/X11Constants.kt similarity index 100% rename from korge/src@jvm/korlibs/render/x11/X11Constants.kt rename to korge-core/src@jvm/korlibs/render/x11/X11Constants.kt diff --git a/korge/src@jvm/korlibs/render/x11/X11GameWindowJvm.kt b/korge-core/src@jvm/korlibs/render/x11/X11GameWindowJvm.kt similarity index 100% rename from korge/src@jvm/korlibs/render/x11/X11GameWindowJvm.kt rename to korge-core/src@jvm/korlibs/render/x11/X11GameWindowJvm.kt diff --git a/korge/src@jvm/korlibs/render/x11/X11OpenglContext.kt b/korge-core/src@jvm/korlibs/render/x11/X11OpenglContext.kt similarity index 100% rename from korge/src@jvm/korlibs/render/x11/X11OpenglContext.kt rename to korge-core/src@jvm/korlibs/render/x11/X11OpenglContext.kt diff --git a/korge/src@jvmAndroid/korlibs/datastructure/_Datastructure_event.jvmAndroid.kt b/korge-core/src@jvmAndroid/korlibs/datastructure/_Datastructure_event.jvmAndroid.kt similarity index 100% rename from korge/src@jvmAndroid/korlibs/datastructure/_Datastructure_event.jvmAndroid.kt rename to korge-core/src@jvmAndroid/korlibs/datastructure/_Datastructure_event.jvmAndroid.kt diff --git a/korge/src@jvmAndroid/korlibs/kgl/KmlGlTools.kt b/korge-core/src@jvmAndroid/korlibs/kgl/KmlGlTools.kt similarity index 100% rename from korge/src@jvmAndroid/korlibs/kgl/KmlGlTools.kt rename to korge-core/src@jvmAndroid/korlibs/kgl/KmlGlTools.kt diff --git a/korge/src@native/korlibs/kgl/KmlGlNativeExpect.kt b/korge-core/src@native/korlibs/kgl/KmlGlNativeExpect.kt similarity index 100% rename from korge/src@native/korlibs/kgl/KmlGlNativeExpect.kt rename to korge-core/src@native/korlibs/kgl/KmlGlNativeExpect.kt diff --git a/korge/src@native/korlibs/kgl/KmlGlNativeExt.kt b/korge-core/src@native/korlibs/kgl/KmlGlNativeExt.kt similarity index 100% rename from korge/src@native/korlibs/kgl/KmlGlNativeExt.kt rename to korge-core/src@native/korlibs/kgl/KmlGlNativeExt.kt diff --git a/korge/src@native/kotlin/korlibs/datastructure/_Datastructure_event.native.kt b/korge-core/src@native/kotlin/korlibs/datastructure/_Datastructure_event.native.kt similarity index 100% rename from korge/src@native/kotlin/korlibs/datastructure/_Datastructure_event.native.kt rename to korge-core/src@native/kotlin/korlibs/datastructure/_Datastructure_event.native.kt diff --git a/korge/src@tvos/korlibs/render/DefaultGameWindowIosTools.kt b/korge-core/src@tvos/korlibs/render/DefaultGameWindowIosTools.kt similarity index 100% rename from korge/src@tvos/korlibs/render/DefaultGameWindowIosTools.kt rename to korge-core/src@tvos/korlibs/render/DefaultGameWindowIosTools.kt diff --git a/korge/src@wasmJs/korlibs/datastructure/event/WasmJsEventLoop.kt b/korge-core/src@wasmJs/korlibs/datastructure/event/WasmJsEventLoop.kt similarity index 100% rename from korge/src@wasmJs/korlibs/datastructure/event/WasmJsEventLoop.kt rename to korge-core/src@wasmJs/korlibs/datastructure/event/WasmJsEventLoop.kt diff --git a/korge/src@wasmJs/korlibs/graphics/gl/AGOpenglFactoryWasm.kt b/korge-core/src@wasmJs/korlibs/graphics/gl/AGOpenglFactoryWasm.kt similarity index 100% rename from korge/src@wasmJs/korlibs/graphics/gl/AGOpenglFactoryWasm.kt rename to korge-core/src@wasmJs/korlibs/graphics/gl/AGOpenglFactoryWasm.kt diff --git a/korge/src@wasmJs/korlibs/graphics/gl/GlExt.kt b/korge-core/src@wasmJs/korlibs/graphics/gl/GlExt.kt similarity index 100% rename from korge/src@wasmJs/korlibs/graphics/gl/GlExt.kt rename to korge-core/src@wasmJs/korlibs/graphics/gl/GlExt.kt diff --git a/korge/src@wasmJs/korlibs/kgl/KmlGlContextJs.kt b/korge-core/src@wasmJs/korlibs/kgl/KmlGlContextJs.kt similarity index 100% rename from korge/src@wasmJs/korlibs/kgl/KmlGlContextJs.kt rename to korge-core/src@wasmJs/korlibs/kgl/KmlGlContextJs.kt diff --git a/korge/src@wasmJs/korlibs/kgl/KmlGlWasmCanvas.kt b/korge-core/src@wasmJs/korlibs/kgl/KmlGlWasmCanvas.kt similarity index 100% rename from korge/src@wasmJs/korlibs/kgl/KmlGlWasmCanvas.kt rename to korge-core/src@wasmJs/korlibs/kgl/KmlGlWasmCanvas.kt diff --git a/korge/src@wasmJs/korlibs/korge/KorgeReload_getReloadedClass.kt b/korge-core/src@wasmJs/korlibs/korge/KorgeReload_getReloadedClass.kt similarity index 100% rename from korge/src@wasmJs/korlibs/korge/KorgeReload_getReloadedClass.kt rename to korge-core/src@wasmJs/korlibs/korge/KorgeReload_getReloadedClass.kt diff --git a/korge/src@wasmJs/korlibs/korge/service/vibration/NativeVibration.kt b/korge-core/src@wasmJs/korlibs/korge/service/vibration/NativeVibration.kt similarity index 87% rename from korge/src@wasmJs/korlibs/korge/service/vibration/NativeVibration.kt rename to korge-core/src@wasmJs/korlibs/korge/service/vibration/NativeVibration.kt index a5ed852781..009015fb7f 100644 --- a/korge/src@wasmJs/korlibs/korge/service/vibration/NativeVibration.kt +++ b/korge-core/src@wasmJs/korlibs/korge/service/vibration/NativeVibration.kt @@ -1,11 +1,11 @@ package korlibs.korge.service.vibration -import korlibs.korge.view.* import korlibs.time.* import korlibs.wasm.* import kotlinx.browser.* +import kotlin.coroutines.* -actual class NativeVibration actual constructor(val views: Views) { +actual class NativeVibration actual constructor(val coroutineContext: CoroutineContext) { /** * @param timings list of alternating ON-OFF durations in milliseconds. Staring with ON. diff --git a/korge/src@wasmJs/korlibs/render/DefaultGameWindowWasm.kt b/korge-core/src@wasmJs/korlibs/render/DefaultGameWindowWasm.kt similarity index 100% rename from korge/src@wasmJs/korlibs/render/DefaultGameWindowWasm.kt rename to korge-core/src@wasmJs/korlibs/render/DefaultGameWindowWasm.kt diff --git a/korge/src@wasmJs/korlibs/render/DialogInterfaceJs.kt b/korge-core/src@wasmJs/korlibs/render/DialogInterfaceJs.kt similarity index 100% rename from korge/src@wasmJs/korlibs/render/DialogInterfaceJs.kt rename to korge-core/src@wasmJs/korlibs/render/DialogInterfaceJs.kt diff --git a/korge/src@wasmJs/korlibs/render/internal/KorgwJsInternal.kt b/korge-core/src@wasmJs/korlibs/render/internal/KorgwJsInternal.kt similarity index 100% rename from korge/src@wasmJs/korlibs/render/internal/KorgwJsInternal.kt rename to korge-core/src@wasmJs/korlibs/render/internal/KorgwJsInternal.kt diff --git a/korge/src@wasmJs/korlibs/render/internal/KorgwWasmInternal.kt b/korge-core/src@wasmJs/korlibs/render/internal/KorgwWasmInternal.kt similarity index 100% rename from korge/src@wasmJs/korlibs/render/internal/KorgwWasmInternal.kt rename to korge-core/src@wasmJs/korlibs/render/internal/KorgwWasmInternal.kt diff --git a/korge-core/test/korlibs/SkipIOTest.kt b/korge-core/test/korlibs/SkipIOTest.kt new file mode 100644 index 0000000000..b9a87405cf --- /dev/null +++ b/korge-core/test/korlibs/SkipIOTest.kt @@ -0,0 +1,7 @@ +package korlibs + +import korlibs.platform.* + +//val skipIOTest get() = OS.isJsBrowser +val skipIOTest get() = Platform.isJsBrowserOrWorker || Platform.isJsNodeJs +val doIOTest get() = !skipIOTest diff --git a/korge-core/test/korlibs/TestExt.kt b/korge-core/test/korlibs/TestExt.kt new file mode 100644 index 0000000000..e4ef83b4da --- /dev/null +++ b/korge-core/test/korlibs/TestExt.kt @@ -0,0 +1,64 @@ +package korlibs +import korlibs.math.* +import korlibs.math.geom.* +import korlibs.math.geom.bezier.* +import kotlin.test.* + +fun < + //@OnlyInputTypes + T> assertEqualsFloat( + expected: T?, + actual: T?, + absoluteTolerance: Double = 0.001, + message: String = "" +) { + if (expected is List<*> && actual is List<*> && expected.size != actual.size) { + throw AssertionError("${expected.size} != ${actual.size} : ${expected}, ${actual}") + } + if (!expected.isAlmostEqualsGeneric(actual, absoluteTolerance)) { + //org.junit.ComparisonFailure: expected:<[a]> but was:<[b]> + + //throw AssertionError("Actual: $actual\nExpected: $expected\nabsoluteTolerance=$absoluteTolerance\n$message") + assertEquals("$expected", "$actual", message) + throw AssertionError("expected:<[$expected]> but was:<[$actual]>\nabsoluteTolerance=$absoluteTolerance\n$message") + } +} + +private fun T?.isAlmostEqualsGeneric( + a: T?, + absoluteTolerance: Double = 0.00001, +): Boolean { + val e = this + if (e == null || a == null) return (e == null) && (a == null) + return when (e) { + is Point -> e.isAlmostEquals((a as? Point?) ?: return false, absoluteTolerance) + is MPoint -> e.isAlmostEquals((a as? MPoint?) ?: return false, absoluteTolerance) + is Vector3F -> e.isAlmostEquals((a as? Vector3F?) ?: return false, absoluteTolerance.toFloat()) + is Vector4F -> e.isAlmostEquals((a as? Vector4F?) ?: return false, absoluteTolerance.toFloat()) + is Float -> { + if (a !is Float?) return false + if (e.isNaN() && a.isNaN()) return true + e.isAlmostEquals(a, absoluteTolerance.toFloat()) + } + is Double -> { + if (a !is Double?) return false + if (e.isNaN() && a.isNaN()) return true + e.isAlmostEquals(a, absoluteTolerance) + } + is Matrix -> e.isAlmostEquals((a as Matrix), absoluteTolerance) + is MatrixTransform -> e.isAlmostEquals((a as MatrixTransform), absoluteTolerance) + is Rectangle -> e.isAlmostEquals((a as Rectangle), absoluteTolerance) + is MRectangle -> e.isAlmostEquals((a as MRectangle), absoluteTolerance) + is Bezier -> e.points.isAlmostEqualsGeneric((a as? Bezier)?.points, absoluteTolerance) + is PointList -> e.toList().isAlmostEqualsGeneric((a as? PointList)?.toList(), absoluteTolerance) + is List<*> -> { + if (a !is List<*>?) return false + if (e.size != a.size) return false + for (n in 0 until e.size) { + if (!e[n].isAlmostEqualsGeneric(a[n], absoluteTolerance)) return false + } + true + } + else -> e == a + } +} diff --git a/korge/test/korlibs/datastructure/event/SyncEventLoopTest.kt b/korge-core/test/korlibs/datastructure/event/SyncEventLoopTest.kt similarity index 100% rename from korge/test/korlibs/datastructure/event/SyncEventLoopTest.kt rename to korge-core/test/korlibs/datastructure/event/SyncEventLoopTest.kt diff --git a/korge/test/korlibs/event/EventListenerTest.kt b/korge-core/test/korlibs/event/EventListenerTest.kt similarity index 100% rename from korge/test/korlibs/event/EventListenerTest.kt rename to korge-core/test/korlibs/event/EventListenerTest.kt diff --git a/korge/test/korlibs/event/EventsTest.kt b/korge-core/test/korlibs/event/EventsTest.kt similarity index 100% rename from korge/test/korlibs/event/EventsTest.kt rename to korge-core/test/korlibs/event/EventsTest.kt diff --git a/korge/test/korlibs/event/KorevTest.kt b/korge-core/test/korlibs/event/KorevTest.kt similarity index 100% rename from korge/test/korlibs/event/KorevTest.kt rename to korge-core/test/korlibs/event/KorevTest.kt diff --git a/korge/test/korlibs/event/ScrollDeltaTest.kt b/korge-core/test/korlibs/event/ScrollDeltaTest.kt similarity index 100% rename from korge/test/korlibs/event/ScrollDeltaTest.kt rename to korge-core/test/korlibs/event/ScrollDeltaTest.kt diff --git a/korge/test/korlibs/event/TouchBuilderTest.kt b/korge-core/test/korlibs/event/TouchBuilderTest.kt similarity index 100% rename from korge/test/korlibs/event/TouchBuilderTest.kt rename to korge-core/test/korlibs/event/TouchBuilderTest.kt diff --git a/korge/test/korlibs/graphics/AGNewUniformTest.kt b/korge-core/test/korlibs/graphics/AGNewUniformTest.kt similarity index 100% rename from korge/test/korlibs/graphics/AGNewUniformTest.kt rename to korge-core/test/korlibs/graphics/AGNewUniformTest.kt diff --git a/korge/test/korlibs/graphics/AGOpenglTest.kt b/korge-core/test/korlibs/graphics/AGOpenglTest.kt similarity index 100% rename from korge/test/korlibs/graphics/AGOpenglTest.kt rename to korge-core/test/korlibs/graphics/AGOpenglTest.kt diff --git a/korge/test/korlibs/graphics/AGStateTest.kt b/korge-core/test/korlibs/graphics/AGStateTest.kt similarity index 100% rename from korge/test/korlibs/graphics/AGStateTest.kt rename to korge-core/test/korlibs/graphics/AGStateTest.kt diff --git a/korge/test/korlibs/graphics/AGTest.kt b/korge-core/test/korlibs/graphics/AGTest.kt similarity index 100% rename from korge/test/korlibs/graphics/AGTest.kt rename to korge-core/test/korlibs/graphics/AGTest.kt diff --git a/korge/test/korlibs/graphics/AGUniformBlockTest.kt b/korge-core/test/korlibs/graphics/AGUniformBlockTest.kt similarity index 100% rename from korge/test/korlibs/graphics/AGUniformBlockTest.kt rename to korge-core/test/korlibs/graphics/AGUniformBlockTest.kt diff --git a/korge/test/korlibs/graphics/AGValueTest.kt b/korge-core/test/korlibs/graphics/AGValueTest.kt similarity index 100% rename from korge/test/korlibs/graphics/AGValueTest.kt rename to korge-core/test/korlibs/graphics/AGValueTest.kt diff --git a/korge/test/korlibs/graphics/AGVertexArrayObjectFlattenerTest.kt b/korge-core/test/korlibs/graphics/AGVertexArrayObjectFlattenerTest.kt similarity index 100% rename from korge/test/korlibs/graphics/AGVertexArrayObjectFlattenerTest.kt rename to korge-core/test/korlibs/graphics/AGVertexArrayObjectFlattenerTest.kt diff --git a/korge/test/korlibs/graphics/metal/shader/MetalShaderBufferInputLayoutsTest.kt b/korge-core/test/korlibs/graphics/metal/shader/MetalShaderBufferInputLayoutsTest.kt similarity index 100% rename from korge/test/korlibs/graphics/metal/shader/MetalShaderBufferInputLayoutsTest.kt rename to korge-core/test/korlibs/graphics/metal/shader/MetalShaderBufferInputLayoutsTest.kt diff --git a/korge/test/korlibs/graphics/metal/shader/MetalShaderGeneratorTest.kt b/korge-core/test/korlibs/graphics/metal/shader/MetalShaderGeneratorTest.kt similarity index 100% rename from korge/test/korlibs/graphics/metal/shader/MetalShaderGeneratorTest.kt rename to korge-core/test/korlibs/graphics/metal/shader/MetalShaderGeneratorTest.kt diff --git a/korge/test/korlibs/graphics/metal/shader/MetalShaderStructureGeneratorTest.kt b/korge-core/test/korlibs/graphics/metal/shader/MetalShaderStructureGeneratorTest.kt similarity index 100% rename from korge/test/korlibs/graphics/metal/shader/MetalShaderStructureGeneratorTest.kt rename to korge-core/test/korlibs/graphics/metal/shader/MetalShaderStructureGeneratorTest.kt diff --git a/korge/test/korlibs/graphics/shader/VertexLayoutTest.kt b/korge-core/test/korlibs/graphics/shader/VertexLayoutTest.kt similarity index 100% rename from korge/test/korlibs/graphics/shader/VertexLayoutTest.kt rename to korge-core/test/korlibs/graphics/shader/VertexLayoutTest.kt diff --git a/korge/test/korlibs/graphics/shaders/ShadersTest.kt b/korge-core/test/korlibs/graphics/shaders/ShadersTest.kt similarity index 100% rename from korge/test/korlibs/graphics/shaders/ShadersTest.kt rename to korge-core/test/korlibs/graphics/shaders/ShadersTest.kt diff --git a/korge/test/korlibs/io/file/registry/WindowsRegistryTest.kt b/korge-core/test/korlibs/io/file/registry/WindowsRegistryTest.kt similarity index 100% rename from korge/test/korlibs/io/file/registry/WindowsRegistryTest.kt rename to korge-core/test/korlibs/io/file/registry/WindowsRegistryTest.kt diff --git a/korge/test/korlibs/kgl/KglOffscreenTest.kt b/korge-core/test/korlibs/kgl/KglOffscreenTest.kt similarity index 100% rename from korge/test/korlibs/kgl/KglOffscreenTest.kt rename to korge-core/test/korlibs/kgl/KglOffscreenTest.kt diff --git a/korge/test/korlibs/kgl/KglTest.kt b/korge-core/test/korlibs/kgl/KglTest.kt similarity index 100% rename from korge/test/korlibs/kgl/KglTest.kt rename to korge-core/test/korlibs/kgl/KglTest.kt diff --git a/korge/test/korlibs/render/AGUniformsTest.kt b/korge-core/test/korlibs/render/AGUniformsTest.kt similarity index 100% rename from korge/test/korlibs/render/AGUniformsTest.kt rename to korge-core/test/korlibs/render/AGUniformsTest.kt diff --git a/korge/test/korlibs/render/GameWindowTest.kt b/korge-core/test/korlibs/render/GameWindowTest.kt similarity index 100% rename from korge/test/korlibs/render/GameWindowTest.kt rename to korge-core/test/korlibs/render/GameWindowTest.kt diff --git a/korge/test/korlibs/render/KorgwSampleMain.kt b/korge-core/test/korlibs/render/KorgwSampleMain.kt similarity index 100% rename from korge/test/korlibs/render/KorgwSampleMain.kt rename to korge-core/test/korlibs/render/KorgwSampleMain.kt diff --git a/korge/test/korlibs/render/KorgwTest.kt b/korge-core/test/korlibs/render/KorgwTest.kt similarity index 100% rename from korge/test/korlibs/render/KorgwTest.kt rename to korge-core/test/korlibs/render/KorgwTest.kt diff --git a/korge/test/korlibs/render/SyncEventLoopCoroutineDispatcherTest.kt b/korge-core/test/korlibs/render/SyncEventLoopCoroutineDispatcherTest.kt similarity index 100% rename from korge/test/korlibs/render/SyncEventLoopCoroutineDispatcherTest.kt rename to korge-core/test/korlibs/render/SyncEventLoopCoroutineDispatcherTest.kt diff --git a/korge/test/korlibs/render/x11/LinuxJoyEventAdapterTest.kt b/korge-core/test/korlibs/render/x11/LinuxJoyEventAdapterTest.kt similarity index 97% rename from korge/test/korlibs/render/x11/LinuxJoyEventAdapterTest.kt rename to korge-core/test/korlibs/render/x11/LinuxJoyEventAdapterTest.kt index a490f55c6e..4863459e2f 100644 --- a/korge/test/korlibs/render/x11/LinuxJoyEventAdapterTest.kt +++ b/korge-core/test/korlibs/render/x11/LinuxJoyEventAdapterTest.kt @@ -5,10 +5,12 @@ import korlibs.event.gamepad.* import korlibs.io.async.* import korlibs.io.file.sync.* import korlibs.io.lang.* +import korlibs.korge.internal.* import korlibs.memory.* import korlibs.platform.* import kotlin.test.* +@OptIn(KorgeInternal::class) class LinuxJoyEventAdapterTest { @Test fun test() = suspendTest({ !Platform.isJs && !Platform.isWasm }) { diff --git a/korge/test/korlibs/test/AnySubject.kt b/korge-core/test/korlibs/test/AnySubject.kt similarity index 100% rename from korge/test/korlibs/test/AnySubject.kt rename to korge-core/test/korlibs/test/AnySubject.kt diff --git a/korge/test/korlibs/test/BooleanSubject.kt b/korge-core/test/korlibs/test/BooleanSubject.kt similarity index 100% rename from korge/test/korlibs/test/BooleanSubject.kt rename to korge-core/test/korlibs/test/BooleanSubject.kt diff --git a/korge/test/korlibs/test/CollectionSubject.kt b/korge-core/test/korlibs/test/CollectionSubject.kt similarity index 100% rename from korge/test/korlibs/test/CollectionSubject.kt rename to korge-core/test/korlibs/test/CollectionSubject.kt diff --git a/korge/test/korlibs/test/DoubleSubject.kt b/korge-core/test/korlibs/test/DoubleSubject.kt similarity index 100% rename from korge/test/korlibs/test/DoubleSubject.kt rename to korge-core/test/korlibs/test/DoubleSubject.kt diff --git a/korge/test/korlibs/test/MapSubject.kt b/korge-core/test/korlibs/test/MapSubject.kt similarity index 100% rename from korge/test/korlibs/test/MapSubject.kt rename to korge-core/test/korlibs/test/MapSubject.kt diff --git a/korge/test/korlibs/test/truth.kt b/korge-core/test/korlibs/test/truth.kt similarity index 100% rename from korge/test/korlibs/test/truth.kt rename to korge-core/test/korlibs/test/truth.kt diff --git a/korge-sandbox/src/Main.kt b/korge-sandbox/src/Main.kt index 76f4d9f5aa..6de18edd51 100644 --- a/korge-sandbox/src/Main.kt +++ b/korge-sandbox/src/Main.kt @@ -1,5 +1,6 @@ import korlibs.event.* +import korlibs.graphics.* import korlibs.image.color.* import korlibs.image.text.* import korlibs.io.async.* @@ -55,6 +56,13 @@ fun Stage.notification(message: String) { } } +suspend fun main2() = KorgeCore { + val stopWatch = Stopwatch().start() + onRenderEvent { + ag.clear(ag.mainFrameBuffer, color = Colors.RED.interpolateWith((stopWatch.elapsed.seconds % 1.0).toRatio(), Colors.WHITE)) + } +} + suspend fun main() = Korge( windowSize = Korge.DEFAULT_WINDOW_SIZE, backgroundColor = DEFAULT_KORGE_BG_COLOR, diff --git a/korge-sandbox/src/samples/MainShape2d.kt b/korge-sandbox/src/samples/MainShape2d.kt index ace7f4e1b5..d169d6d840 100644 --- a/korge-sandbox/src/samples/MainShape2d.kt +++ b/korge-sandbox/src/samples/MainShape2d.kt @@ -26,13 +26,13 @@ class MainShape2dScene : Scene() { val cursorShape = buildVectorPath { star(7, 10.0, 16.0) } val shapes = listOf( - Circle(Point(100, 100), radius = 50), - Ellipse(Point(100, 100), radius = Size(50f, 30f)), - Rectangle(50, 50, 250, 100), - RoundRectangle(Rectangle(50, 50, 250, 100), RectCorners(10f, 15f, 20f, 30f)), - buildVectorPath { star(7, 30.0, 50.0, x = 100.0, y = 100.0) }, - buildVectorPath { star(7, 30.0, 50.0, x = 100.0, y = 100.0); rectHole(Rectangle(80, 80, 40, 40)) }, - Line(Point(50, 50), Point(150, 120)), + Circle(Point(100, 100), radius = 50).toShape2D(), + Ellipse(Point(100, 100), radius = Size(50f, 30f)).toShape2D(), + Rectangle(50, 50, 250, 100).toShape2D(), + RoundRectangle(Rectangle(50, 50, 250, 100), RectCorners(10f, 15f, 20f, 30f)).toShape2D(), + buildVectorPath { star(7, 30.0, 50.0, x = 100.0, y = 100.0) }.toShape2D(), + buildVectorPath { star(7, 30.0, 50.0, x = 100.0, y = 100.0); rectHole(Rectangle(80, 80, 40, 40)) }.toShape2D(), + Line(Point(50, 50), Point(150, 120)).toShape2D(), ) var shape: Shape2D = shapes.first() diff --git a/korge/build.gradle.kts b/korge/build.gradle.kts index ee7adc1729..38bb83835a 100644 --- a/korge/build.gradle.kts +++ b/korge/build.gradle.kts @@ -11,21 +11,5 @@ project.extensions.extraProperties.properties.apply { } dependencies { - commonMainApi(libs.korlibs.audio) - commonMainApi(libs.korlibs.image) - commonMainApi(libs.korlibs.inject) - commonMainApi(libs.korlibs.template) - commonMainApi(libs.korlibs.time) - commonMainApi(libs.kotlinx.atomicfu) - commonMainApi(libs.kotlinx.coroutines.core) - //commonTestApi(project(":korge-test")) - jvmMainApi("org.jetbrains.kotlin:kotlin-reflect") - jvmMainImplementation(libs.jackson.databind) - jvmMainImplementation(libs.jackson.module.kotlin) - - //commonTestApi(testFixtures(project(":korma"))) - - //add("jvmMainApi", project(":korte")) - - //add("commonTestApi", "it.krzeminski.vis-assert:vis-assert:0.4.0-beta") + commonMainApi(project(":korge-core")) } diff --git a/korge/resources/META-INF/services/com.soywiz.korag.AGFactory b/korge/resources/META-INF/services/com.soywiz.korag.AGFactory deleted file mode 100644 index 2a4223a9ef..0000000000 --- a/korge/resources/META-INF/services/com.soywiz.korag.AGFactory +++ /dev/null @@ -1 +0,0 @@ -#korlibs.graphics.software.AGFactorySoftware diff --git a/korge/src/korlibs/graphics/metal/shader/Shader.kt b/korge/src/korlibs/graphics/metal/shader/Shader.kt deleted file mode 100644 index fd7827c1d6..0000000000 --- a/korge/src/korlibs/graphics/metal/shader/Shader.kt +++ /dev/null @@ -1,7 +0,0 @@ -package korlibs.graphics.metal.shader - -import korlibs.graphics.shader.* - -internal fun Pair.toNewMetalShaderStringResult(bufferInputsLayout: MetalShaderBufferInputLayouts) - = let { (vertexShader, fragmentShader) -> MetalShaderGenerator(vertexShader, fragmentShader, bufferInputsLayout) } - .generateResult() diff --git a/korge/src/korlibs/korge/Korge.kt b/korge/src/korlibs/korge/Korge.kt index f22b410a3f..598a810bee 100644 --- a/korge/src/korlibs/korge/Korge.kt +++ b/korge/src/korlibs/korge/Korge.kt @@ -35,6 +35,10 @@ import kotlin.time.* typealias KorgeConfig = Korge +suspend fun test() = Korge { + +} + data class KorgeDisplayMode(val scaleMode: ScaleMode, val scaleAnchor: Anchor, val clipBorders: Boolean) { companion object { val DEFAULT get() = CENTER diff --git a/korge/src/korlibs/korge/KorgeVersion.kt b/korge/src/korlibs/korge/KorgeVersion.kt deleted file mode 100644 index 9b0f18210c..0000000000 --- a/korge/src/korlibs/korge/KorgeVersion.kt +++ /dev/null @@ -1,3 +0,0 @@ -package korlibs.korge - -val Korge.VERSION get() = "1.0.0-beta-3" diff --git a/korge/src/korlibs/korge/render/RenderContext2DExt.kt b/korge/src/korlibs/korge/render/RenderContext2DExt.kt index a2d5f0eb92..aa87258075 100644 --- a/korge/src/korlibs/korge/render/RenderContext2DExt.kt +++ b/korge/src/korlibs/korge/render/RenderContext2DExt.kt @@ -238,3 +238,15 @@ fun RenderContext2D.drawText( n++ } } + +inline fun View.renderCtx2d(ctx: RenderContext, crossinline block: (RenderContext2D) -> Unit) { + ctx.useCtx2d { context -> + context.keep { + context.size = Size(this@renderCtx2d.width, this@renderCtx2d.height) + context.blendMode = renderBlendMode + context.multiplyColor = renderColorMul + context.setMatrix(globalMatrix) + block(context) + } + } +} diff --git a/korge/src/korlibs/korge/render/RenderContextExt.kt b/korge/src/korlibs/korge/render/RenderContextExt.kt new file mode 100644 index 0000000000..2d0e2dec68 --- /dev/null +++ b/korge/src/korlibs/korge/render/RenderContextExt.kt @@ -0,0 +1,16 @@ +package korlibs.korge.render + +import korlibs.datastructure.* +import korlibs.korge.view.* + +val RenderContext.views: Views? get() = bp as? Views? + +private var RenderContext._debugAnnotateView: View? by extraProperty { null } + +var RenderContext.debugAnnotateView: View? + get() = _debugAnnotateView + set(value) { + views?.invalidatedView(_debugAnnotateView) + _debugAnnotateView = value + views?.invalidatedView(_debugAnnotateView) + } diff --git a/korge/src/korlibs/korge/service/storage/NativeStorage.kt b/korge/src/korlibs/korge/service/storage/NativeStorage.kt index 04585277c2..67af2e0ec2 100644 --- a/korge/src/korlibs/korge/service/storage/NativeStorage.kt +++ b/korge/src/korlibs/korge/service/storage/NativeStorage.kt @@ -9,6 +9,7 @@ import kotlin.collections.* /** Cross-platform way of synchronously storing small data */ //expect fun NativeStorage(views: Views): IStorageWithKeys + expect class NativeStorage(views: Views) : IStorageWithKeys { override fun keys(): List override fun set(key: String, value: String) diff --git a/korge/src/korlibs/korge/service/vibration/NativeVibrationViews.kt b/korge/src/korlibs/korge/service/vibration/NativeVibrationViews.kt new file mode 100644 index 0000000000..f5a00c2098 --- /dev/null +++ b/korge/src/korlibs/korge/service/vibration/NativeVibrationViews.kt @@ -0,0 +1,6 @@ +package korlibs.korge.service.vibration + +import korlibs.datastructure.* +import korlibs.korge.view.* + +val Views.vibration by extraPropertyThis { NativeVibration(this.coroutineContext) } diff --git a/korge/src/korlibs/korge/view/BlendMode.kt b/korge/src/korlibs/korge/view/BlendMode.kt index 5fcddd5218..c856b92cd8 100644 --- a/korge/src/korlibs/korge/view/BlendMode.kt +++ b/korge/src/korlibs/korge/view/BlendMode.kt @@ -1,135 +1,3 @@ package korlibs.korge.view -import korlibs.graphics.* -import korlibs.korge.view.BlendMode.Companion.ADD -import korlibs.korge.view.BlendMode.Companion.MULTIPLY -import korlibs.korge.view.BlendMode.Companion.NORMAL -import korlibs.korge.view.property.* -import korlibs.image.color.* - -/** - * Determines how pixels should be blended. The most common blend modes are: [NORMAL] (normal mix) and [ADD] (additive blending) along with [MULTIPLY] and others. - * - * [https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/blendFuncSeparate](https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/blendFuncSeparate) - * - * ```kotlin - * // color(RGB) = (sourceColor * srcRGB) + (destinationColor * dstRGB) - * // color(A) = (sourceAlpha * srcAlpha) + (destinationAlpha * dstAlpha) - * ``` - */ -data class BlendMode( - val factors: AGBlending, - val name: String? = null, -) { - val __hashCode: Int = factors.hashCode() + name.hashCode() * 7 - override fun hashCode(): Int = __hashCode - override fun equals(other: Any?): Boolean = (this === other) || (other is BlendMode && this.factors == other.factors && name == other.name) - override fun toString(): String = name ?: super.toString() - - fun apply(src: RGBAf, dst: RGBAf, out: RGBAf = RGBAf()): RGBAf { - return factors.apply(src, dst, out) - } - - fun apply(src: RGBA, dst: RGBA): RGBA { - return factors.apply(src, dst) - } - - companion object { - /** Mixes the source and destination colors using the source alpha value */ - val NORMAL = BlendMode(name = "NORMAL", factors = AGBlending.NORMAL_PRE) - /** Not an actual blending. It is used to indicate that the next non-inherit BlendMode from its ancestors will be used. */ - val INHERIT = NORMAL.copy(name = "INHERIT") - /** Doesn't blend at all. Just replaces the colors. */ - val NONE = BlendMode(name = "NONE", factors = AGBlending(AGBlendFactor.ONE, AGBlendFactor.ZERO)) // REPLACE - /** Additive mixing for lighting effects */ - val ADD = BlendMode(name = "ADD", factors = AGBlending.ADD_PRE) - - // Unchecked - val MULTIPLY = BlendMode(name = "MULTIPLY", factors = AGBlending(AGBlendFactor.DESTINATION_COLOR, AGBlendFactor.ONE_MINUS_SOURCE_ALPHA)) - val SCREEN = BlendMode(name = "SCREEN", factors = AGBlending(AGBlendFactor.ONE, AGBlendFactor.ONE_MINUS_SOURCE_COLOR)) - - val ERASE = BlendMode(name = "ERASE", factors = AGBlending(AGBlendFactor.ZERO, AGBlendFactor.ONE_MINUS_SOURCE_ALPHA)) - val MASK = BlendMode(name = "MASK", factors = AGBlending(AGBlendFactor.ZERO, AGBlendFactor.SOURCE_ALPHA)) - val BELOW = BlendMode(name = "BELOW", factors = AGBlending(AGBlendFactor.ONE_MINUS_DESTINATION_ALPHA, AGBlendFactor.DESTINATION_ALPHA)) - val SUBTRACT = BlendMode( - name = "SUBTRACT", factors = AGBlending( - AGBlendFactor.SOURCE_ALPHA, AGBlendFactor.DESTINATION_ALPHA, - AGBlendFactor.ONE, AGBlendFactor.ONE, - AGBlendEquation.REVERSE_SUBTRACT - ) - ) - val INVERT = BlendMode( - name = "INVERT", - factors = AGBlending( - AGBlendFactor.ONE_MINUS_DESTINATION_COLOR, AGBlendFactor.ZERO, - AGBlendFactor.ONE, AGBlendFactor.ONE, - ) - ) - - // Unimplemented - val LIGHTEN = BlendMode( - name = "LIGHTEN", - factors = AGBlending( - AGBlendFactor.SOURCE_ALPHA, AGBlendFactor.DESTINATION_ALPHA, - AGBlendFactor.ONE, AGBlendFactor.ONE - ) - ) - val DARKEN = BlendMode( - name = "DARKEN", - factors = AGBlending( - AGBlendFactor.SOURCE_ALPHA, AGBlendFactor.DESTINATION_ALPHA, - AGBlendFactor.ONE, AGBlendFactor.ONE - ) - ) - val DIFFERENCE = BlendMode( - name = "DIFFERENCE", - factors = AGBlending( - AGBlendFactor.SOURCE_ALPHA, AGBlendFactor.DESTINATION_ALPHA, - AGBlendFactor.ONE, AGBlendFactor.ONE - ) - ) - val ALPHA = BlendMode( - name = "ALPHA", - factors = AGBlending( - AGBlendFactor.SOURCE_ALPHA, AGBlendFactor.DESTINATION_ALPHA, - AGBlendFactor.ONE, AGBlendFactor.ONE - ) - ) - val HARDLIGHT = BlendMode( - name = "HARDLIGHT", - factors = AGBlending( - AGBlendFactor.SOURCE_ALPHA, AGBlendFactor.DESTINATION_ALPHA, - AGBlendFactor.ONE, AGBlendFactor.ONE - ) - ) - - val OVERLAY: BlendMode get() = NORMAL - val REPLACE: BlendMode get() = NONE - - val BY_ORDINAL: Array = arrayOf(INHERIT, NONE, NORMAL, ADD, MULTIPLY, SCREEN, ERASE, MASK, BELOW, SUBTRACT, INVERT, LIGHTEN, DARKEN, DIFFERENCE, ALPHA, HARDLIGHT) - val BY_NAME: Map = BY_ORDINAL.associateBy { it.name!! } - val STANDARD_LIST: List = BY_ORDINAL.toList() - - val TO_ORDINAL: Map = BY_ORDINAL.indices.associateBy { BY_ORDINAL[it] } - - operator fun get(ordinal: Int): BlendMode = BY_ORDINAL.getOrElse(ordinal) { INHERIT } - operator fun get(name: String): BlendMode = BY_NAME[name.uppercase()] ?: INHERIT - - - // https://community.khronos.org/t/blending-mode/34770/4 - //multiply a * b - //screen 1 - (1 - a) * (1 - b) - //darken min(a, b) - //lighten max(a, b) - //difference abs(a - b) - //negation 1 - abs(1 - a - b) - //exclusion a + b - 2 * a * b - //overlay a < .5 ? (2 * a * b) : (1 - 2 * (1 - a) * (1 - b)) - //hard light b < .5 ? (2 * a * b) : (1 - 2 * (1 - a) * (1 - b)) - //soft light b < .5 ? (2 * a * b + a * a * (1 - 2 * b)) : (sqrt(a) * (2 * b - 1) + (2 * a) * (1 - b)) - //dodge a / (1 - b) - //burn 1 - (1 - a) / b - } -} - -val BlendMode.ordinal: Int get() = BlendMode.TO_ORDINAL.getOrElse(this) { -1 } +typealias BlendMode = korlibs.korge.blend.BlendMode diff --git a/korge/src/korlibs/korge/view/Circle.kt b/korge/src/korlibs/korge/view/Circle.kt index b26e55c2da..c13ad45f31 100644 --- a/korge/src/korlibs/korge/view/Circle.kt +++ b/korge/src/korlibs/korge/view/Circle.kt @@ -5,6 +5,7 @@ import korlibs.image.paint.* import korlibs.korge.ui.* import korlibs.math.geom.* import korlibs.math.geom.Circle +import korlibs.math.geom.shape.* import korlibs.math.geom.vector.* /** @@ -46,7 +47,7 @@ open class Circle( private fun updateGraphics() { val halfStroke = this@Circle.strokeThickness / 2 val radius = this.radius - hitShape2d = Circle(Point(radius, radius), radius.toDouble()) + hitShape2d = Circle(Point(radius, radius), radius.toDouble()).toShape2D() //println("radius=$radius, halfStroke=$halfStroke") updatePath { clear() diff --git a/korge/src/korlibs/korge/view/Views.kt b/korge/src/korlibs/korge/view/Views.kt index b8a9abeba0..9bc25f3b09 100644 --- a/korge/src/korlibs/korge/view/Views.kt +++ b/korge/src/korlibs/korge/view/Views.kt @@ -50,7 +50,7 @@ class Views( val gameId: String = "korgegame", val settingsFolder: String? = null, val batchMaxQuads: Int = BatchBuilder2D.DEFAULT_BATCH_QUADS, - val bp: BoundsProvider = BoundsProvider.Base(), + val bp: BoundsProvider = korlibs.korge.render.BoundsProvider.Base(), val stageBuilder: (Views) -> Stage = { Stage(it) } ) : BaseEventListener(), Extra by Extra.Mixin(), @@ -592,54 +592,8 @@ fun View.updateSingleViewWithViewsAll( dispatch(views.viewsUpdateEvent.also { it.fastDelta = delta }) } -interface BoundsProvider { - var windowToGlobalMatrix: Matrix - var windowToGlobalTransform: MatrixTransform - var globalToWindowMatrix: Matrix - var globalToWindowTransform: MatrixTransform - var actualVirtualBounds: Rectangle - - @KorgeExperimental val actualVirtualLeft: Int get() = actualVirtualBounds.left.toIntRound() - @KorgeExperimental val actualVirtualTop: Int get() = actualVirtualBounds.top.toIntRound() - @KorgeExperimental val actualVirtualWidth: Int get() = actualVirtualBounds.width.toIntRound() - @KorgeExperimental val actualVirtualHeight: Int get() = actualVirtualBounds.height.toIntRound() - //@KorgeExperimental var actualVirtualWidth = DefaultViewport.WIDTH; private set - //@KorgeExperimental var actualVirtualHeight = DefaultViewport.HEIGHT; private set - - val virtualLeft: Double get() = actualVirtualBounds.left.toDouble() - val virtualTop: Double get() = actualVirtualBounds.top.toDouble() - val virtualRight: Double get() = actualVirtualBounds.right.toDouble() - val virtualBottom: Double get() = actualVirtualBounds.bottom.toDouble() - - @KorgeExperimental - val actualVirtualRight: Double get() = actualVirtualBounds.right.toDouble() - @KorgeExperimental - val actualVirtualBottom: Double get() = actualVirtualBounds.bottom.toDouble() - - fun globalToWindowBounds(bounds: Rectangle): Rectangle = - bounds.transformed(globalToWindowMatrix) - - val windowToGlobalScale: Scale get() = windowToGlobalTransform.scale - val windowToGlobalScaleX: Double get() = windowToGlobalTransform.scale.scaleX - val windowToGlobalScaleY: Double get() = windowToGlobalTransform.scale.scaleY - val windowToGlobalScaleAvg: Double get() = windowToGlobalTransform.scale.scaleAvg - - val globalToWindowScale: Scale get() = globalToWindowTransform.scale - val globalToWindowScaleX: Double get() = globalToWindowTransform.scaleX - val globalToWindowScaleY: Double get() = globalToWindowTransform.scaleY - val globalToWindowScaleAvg: Double get() = globalToWindowTransform.scaleAvg - - fun windowToGlobalCoords(pos: Point): Point = windowToGlobalMatrix.transform(pos) - fun globalToWindowCoords(pos: Point): Point = globalToWindowMatrix.transform(pos) - - open class Base : BoundsProvider { - override var windowToGlobalMatrix: Matrix = Matrix() - override var windowToGlobalTransform: MatrixTransform = MatrixTransform() - override var globalToWindowMatrix: Matrix = Matrix() - override var globalToWindowTransform: MatrixTransform = MatrixTransform() - override var actualVirtualBounds: Rectangle = Rectangle(0, 0, DefaultViewport.WIDTH, DefaultViewport.HEIGHT) - } -} +fun BoundsProvider(): korlibs.korge.render.BoundsProvider.Base = korlibs.korge.render.BoundsProvider.Base() +typealias BoundsProvider = korlibs.korge.render.BoundsProvider fun BoundsProvider.setBoundsInfo( reqVirtualSize: Size, @@ -676,21 +630,7 @@ fun BoundsProvider.setBoundsInfo( suspend fun views(): Views = injector().get() -class UpdateEvent(var fastDeltaTime: FastDuration = FastDuration.ZERO) : Event(), TEvent { - constructor(deltaTime: Duration) : this(deltaTime.fast) - var deltaTime: Duration - set(value) { fastDeltaTime = value.fast } - get() = fastDeltaTime.toDuration() - - companion object : EventType - override val type: EventType get() = UpdateEvent - - fun copyFrom(other: UpdateEvent) { - this.fastDeltaTime = other.fastDeltaTime - } - - override fun toString(): String = "UpdateEvent(time=$fastDeltaTime)" -} +typealias UpdateEvent = korlibs.render.event.UpdateEvent class ViewsUpdateEvent(val views: Views, var fastDelta: FastDuration = FastDuration.ZERO) : Event(), TEvent { constructor(views: Views, delta: Duration) : this(views, delta.fast) diff --git a/korge/src/korlibs/korge/view/fast/FSprites.kt b/korge/src/korlibs/korge/view/fast/FSprites.kt index dbb5284263..ea2d2bc481 100644 --- a/korge/src/korlibs/korge/view/fast/FSprites.kt +++ b/korge/src/korlibs/korge/view/fast/FSprites.kt @@ -6,6 +6,7 @@ import korlibs.image.bitmap.* import korlibs.image.color.* import korlibs.korge.render.* import korlibs.korge.view.* +import korlibs.korge.view.BlendMode import korlibs.math.* import korlibs.math.geom.* import korlibs.memory.* diff --git a/korge/src/korlibs/korge/view/filter/DropShadowFilter.kt b/korge/src/korlibs/korge/view/filter/DropShadowFilter.kt index e0bcb9c69b..53b780c795 100644 --- a/korge/src/korlibs/korge/view/filter/DropShadowFilter.kt +++ b/korge/src/korlibs/korge/view/filter/DropShadowFilter.kt @@ -3,7 +3,7 @@ package korlibs.korge.view.filter import korlibs.graphics.shader.* import korlibs.image.color.* import korlibs.korge.render.* -import korlibs.korge.view.* +import korlibs.korge.view.BlendMode import korlibs.korge.view.property.* import korlibs.math.* import korlibs.math.geom.* diff --git a/korge/src/korlibs/korge/view/vector/GpuShapeView.kt b/korge/src/korlibs/korge/view/vector/GpuShapeView.kt index 70734bbe7f..6dc4eabb7c 100644 --- a/korge/src/korlibs/korge/view/vector/GpuShapeView.kt +++ b/korge/src/korlibs/korge/view/vector/GpuShapeView.kt @@ -12,7 +12,8 @@ import korlibs.korge.view.property.* import korlibs.math.geom.* import korlibs.math.geom.Line import korlibs.math.geom.bezier.* -import korlibs.math.geom.shape.* +import korlibs.math.geom.shape.getPoints2List +import korlibs.math.geom.shape.cachedPoints import korlibs.math.geom.vector.* import korlibs.math.interpolation.* import korlibs.time.measureTime diff --git a/korge/src@darwin/korlibs/korge/service/storage/DarwinNativeStorage.kt b/korge/src@ios/korlibs/korge/service/storage/DarwinNativeStorage.kt similarity index 100% rename from korge/src@darwin/korlibs/korge/service/storage/DarwinNativeStorage.kt rename to korge/src@ios/korlibs/korge/service/storage/DarwinNativeStorage.kt diff --git a/korge/src@darwin/korlibs/korge/service/storage/NativeStorageNative.kt b/korge/src@ios/korlibs/korge/service/storage/NativeStorageNative.kt similarity index 100% rename from korge/src@darwin/korlibs/korge/service/storage/NativeStorageNative.kt rename to korge/src@ios/korlibs/korge/service/storage/NativeStorageNative.kt diff --git a/korge/src@darwin/korlibs/korge/tests/enrichTestGameWindow.kt b/korge/src@ios/korlibs/korge/tests/enrichTestGameWindow.kt similarity index 100% rename from korge/src@darwin/korlibs/korge/tests/enrichTestGameWindow.kt rename to korge/src@ios/korlibs/korge/tests/enrichTestGameWindow.kt diff --git a/korge/src@jvm/korlibs/korge/KorgeExtJvm.kt b/korge/src@jvm/korlibs/korge/KorgeExtJvm.kt index 19422965ed..72abce5e40 100644 --- a/korge/src@jvm/korlibs/korge/KorgeExtJvm.kt +++ b/korge/src@jvm/korlibs/korge/KorgeExtJvm.kt @@ -4,6 +4,8 @@ import korlibs.image.bitmap.* import korlibs.image.color.* import korlibs.time.* import korlibs.korge.awt.* +import korlibs.korge.awt.views +import korlibs.korge.render.* import korlibs.korge.time.* import korlibs.korge.view.* import korlibs.korge.view.Ellipse diff --git a/korge/src@jvm/korlibs/korge/awt/ViewsDebugger.kt b/korge/src@jvm/korlibs/korge/awt/ViewsDebugger.kt index c5dc5dd3f1..41d9ed9c7a 100644 --- a/korge/src@jvm/korlibs/korge/awt/ViewsDebugger.kt +++ b/korge/src@jvm/korlibs/korge/awt/ViewsDebugger.kt @@ -4,6 +4,7 @@ import korlibs.datastructure.* import korlibs.event.Event import korlibs.io.async.* import korlibs.korge.internal.* +import korlibs.korge.render.* import korlibs.korge.view.* import korlibs.korge.view.Container import korlibs.math.geom.Point diff --git a/korge/test/korlibs/korge/view/FixedSizeContainerTest.kt b/korge/test/korlibs/korge/view/FixedSizeContainerTest.kt index 0d8bd4f5a0..d94b09b907 100644 --- a/korge/test/korlibs/korge/view/FixedSizeContainerTest.kt +++ b/korge/test/korlibs/korge/view/FixedSizeContainerTest.kt @@ -13,7 +13,7 @@ class FixedSizeContainerTest { val windowSize = Size(640, 480) val virtualSize = Size(512, 512) val ag: AGLog = AGLog(windowSize) - val bp: BoundsProvider = BoundsProvider.Base() + val bp: BoundsProvider = BoundsProvider() bp.setBoundsInfo(virtualSize, windowSize) val container = ClipContainer(Size(30f, 40f)).xy(110, 120) val log = arrayListOf() diff --git a/korge/test/korlibs/korge/view/tiles/TileMapTest.kt b/korge/test/korlibs/korge/view/tiles/TileMapTest.kt index 4c34962dba..33d2e4831a 100644 --- a/korge/test/korlibs/korge/view/tiles/TileMapTest.kt +++ b/korge/test/korlibs/korge/view/tiles/TileMapTest.kt @@ -26,10 +26,10 @@ class TileMapTest { @Test fun testHitTest() { val tileSet = TileSet(intMapOf( - 0 to TileSetTileInfo(0, Bitmap32(16, 16, premultiplied = true).slice(), collision = TileShapeInfoImpl(HitTestDirectionFlags.NONE, Rectangle(0, 0, 16, 16), Matrix())), + 0 to TileSetTileInfo(0, Bitmap32(16, 16, premultiplied = true).slice(), collision = TileShapeInfoImpl(HitTestDirectionFlags.NONE, Rectangle(0, 0, 16, 16).toShape2D(), Matrix())), 1 to TileSetTileInfo(0, Bitmap32(16, 16, premultiplied = true).slice(), collision = TileShapeInfoImpl(HitTestDirectionFlags.NONE, EmptyShape2D, Matrix())), 2 to TileSetTileInfo(0, Bitmap32(16, 16, premultiplied = true).slice(), collision = TileShapeInfoImpl(HitTestDirectionFlags.ALL, EmptyShape2D, Matrix())), - 3 to TileSetTileInfo(0, Bitmap32(16, 16, premultiplied = true).slice(), collision = TileShapeInfoImpl(HitTestDirectionFlags.ALL, Rectangle(0, 0, 16, 16), Matrix())), + 3 to TileSetTileInfo(0, Bitmap32(16, 16, premultiplied = true).slice(), collision = TileShapeInfoImpl(HitTestDirectionFlags.ALL, Rectangle(0, 0, 16, 16).toShape2D(), Matrix())), )) val map = TileMap(SparseChunkedStackedIntArray2(StackedIntArray2(IntArray2(2, 2, intArrayOf(0, 1, 2, 3)))), tileSet) assertEquals(false, map.pixelHitTest(5, 5, HitTestDirection.DOWN)) diff --git a/settings.gradle.kts b/settings.gradle.kts index 767ae24b18..3c0526560f 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -26,6 +26,7 @@ val inCI = isPropertyTrue("CI") val disabledExtraKorgeLibs = isPropertyTrue("DISABLED_EXTRA_KORGE_LIBS") include(":korge") +include(":korge-core") include(":korge-gradle-plugin") include(":korge-gradle-plugin-common") include(":korge-gradle-plugin-settings")