diff --git a/dlanguilib.visualdproj b/dlanguilib.visualdproj index 93c8f1fe..5332421c 100644 --- a/dlanguilib.visualdproj +++ b/dlanguilib.visualdproj @@ -53,8 +53,8 @@ $(CC) -c 1 $(DMDInstallDir)windows\bin\dmd.exe - 3rdparty ../DerelictGL3/source ../DerelictUtil/source ../DerelictFT/source ../de_image/source/interfaces ../de_image/source/png $(SolutionDir)/../dlib - $(SolutionDir)/views $(SolutionDir)/views/res $(SolutionDir)/views/res/i18n $(SolutionDir)/views/res/mdpi + 3rdparty ../DerelictGL3/source ../DerelictUtil/source ../DerelictFT/source ../de_image/source/interfaces ../de_image/source/png $(SolutionDir)/../dlib $(SolutionDir)/../gl3n + $(SolutionDir)/views $(SolutionDir)/views/res $(SolutionDir)/views/res/i18n $(SolutionDir)/views/res/mdpi $(SolutionDir)/views/res/hdpi $(ConfigurationName) $(OutDir) @@ -72,7 +72,7 @@ 0 DebugFocus 0 - EmbedStandardResources Unicode USE_FREETYPE + EmbedStandardResources Unicode USE_FREETYPE USE_OPENGL USE_SDL 0 0 1 @@ -290,6 +290,15 @@ + + + + + + + + + @@ -368,6 +377,11 @@ + + + + + diff --git a/dub.json b/dub.json index 285e3911..cd6dc1cc 100644 --- a/dub.json +++ b/dub.json @@ -30,6 +30,7 @@ "views", "views/res", "views/res/mdpi", + "views/res/hdpi", "views/res/i18n" ], @@ -37,7 +38,8 @@ "derelict-gl3": ">=1.0.12", "dlib": "~master", "derelict-ft": ">=1.0.0", - "derelict-sdl2": ">=1.9.1" + "derelict-sdl2": ">=1.9.1", + "gl3n": "==1.0.0" }, "-ddoxFilterArgs": ["--unittest-examples", "--min-protection=Protected", "--ex", "win32.", "--ex", "src.dlangui"], diff --git a/examples/example1/example1.visualdproj b/examples/example1/example1.visualdproj index f88ab696..9d810003 100644 --- a/examples/example1/example1.visualdproj +++ b/examples/example1/example1.visualdproj @@ -8,10 +8,12 @@ 0 0 0 + 0 0 0 0 0 + 0 1 0 0 @@ -44,8 +46,12 @@ 0 2 0 + 0 + 0 0 0 + $(CC) -c + 1 $(DMDInstallDir)windows\bin\dmd.exe $(SolutionDir)/src $(SolutionDir)/3rdparty $(SolutionDir)/3rdparty/libpng/source $(SolutionDir)/../DerelictGL3/source $(SolutionDir)/../DerelictUtil/source $(SolutionDir)/../DerelictFT/source $(SolutionDir)/../DerelictSDL2/source $(SolutionDir)/../de_image/source/interfaces $(SolutionDir)/../de_image/source/png $(SolutionDir)/../dlib views views/res views/res/i18n views/res/mdpi @@ -66,7 +72,7 @@ 0 0 - Unicode USE_FREETYPE + Unicode USE_FREETYPE USE_SDL USE_OPENGL 0 3 0 @@ -89,6 +95,7 @@ $(OutDir)\$(ProjectName).exe 1 + 2 -profile @@ -102,10 +109,12 @@ 0 0 0 + 0 0 0 0 0 + 0 0 1 0 @@ -138,8 +147,12 @@ 0 2 0 + 0 + 0 0 0 + $(CC) -c + 1 $(DMDInstallDir)windows\bin\dmd.exe $(SolutionDir)/src $(SolutionDir)/3rdparty $(SolutionDir)/3rdparty/libpng/source $(SolutionDir)/../DerelictGL3/source $(SolutionDir)/../DerelictUtil/source $(SolutionDir)/../DerelictFT/source $(SolutionDir)/../DerelictSDL2/source $(SolutionDir)/../de_image/source/interfaces $(SolutionDir)/../de_image/source/png $(SolutionDir)/../dlib views views/res views/res/i18n views/res/mdpi @@ -183,6 +196,7 @@ $(OutDir)\$(ProjectName).exe 1 + 1 diff --git a/examples/tetris/tetris.visualdproj b/examples/tetris/tetris.visualdproj index 5f803e3d..3e96b75b 100644 --- a/examples/tetris/tetris.visualdproj +++ b/examples/tetris/tetris.visualdproj @@ -8,10 +8,12 @@ 0 0 0 + 0 0 0 0 0 + 0 1 0 0 @@ -44,8 +46,12 @@ 0 2 0 + 0 + 0 0 0 + $(CC) -c + 1 $(DMDInstallDir)windows\bin\dmd.exe $(SolutionDir)/src $(SolutionDir)/3rdparty $(SolutionDir)/3rdparty/libpng/source $(SolutionDir)/../DerelictGL3/source $(SolutionDir)/../DerelictUtil/source $(SolutionDir)/../DerelictFT/source $(SolutionDir)/../DerelictSDL2/source $(SolutionDir)/../de_image/source/interfaces $(SolutionDir)/../de_image/source/png $(SolutionDir)/../dlib views views/res views/mdpi views/i18n @@ -66,7 +72,7 @@ 0 0 - Unicode + Unicode USE_FREETYPE USE_OPENGL USE_SDL 0 3 0 @@ -89,6 +95,7 @@ $(OutDir)\$(ProjectName).exe 1 + 2 -profile @@ -102,10 +109,12 @@ 0 0 0 + 0 0 0 0 0 + 0 0 1 0 @@ -138,8 +147,12 @@ 0 2 0 + 0 + 0 0 0 + $(CC) -c + 1 $(DMDInstallDir)windows\bin\dmd.exe $(SolutionDir)/src $(SolutionDir)/3rdparty $(SolutionDir)/3rdparty/libpng/source $(SolutionDir)/../DerelictGL3/source $(SolutionDir)/../DerelictUtil/source $(SolutionDir)/../DerelictFT/source $(SolutionDir)/../DerelictSDL2/source $(SolutionDir)/../de_image/source/interfaces $(SolutionDir)/../de_image/source/png $(SolutionDir)/../dlib views views/res views/mdpi views/i18n @@ -183,6 +196,7 @@ $(OutDir)\$(ProjectName).exe 1 + 1 diff --git a/src/dlangui/graphics/scene/node.d b/src/dlangui/graphics/scene/node.d new file mode 100644 index 00000000..4bc85319 --- /dev/null +++ b/src/dlangui/graphics/scene/node.d @@ -0,0 +1,10 @@ +module dlangui.graphics.scene.node; + +import gl3n.linalg; +import gl3n.math; + +import dlangui.graphics.scene.transform; + +/// 3D scene node +class Node3d : Transform { +} diff --git a/src/dlangui/graphics/scene/scene3d.d b/src/dlangui/graphics/scene/scene3d.d new file mode 100644 index 00000000..272d8f23 --- /dev/null +++ b/src/dlangui/graphics/scene/scene3d.d @@ -0,0 +1,4 @@ +module dlangui.graphics.scene.scene3d; + +class Scene3d { +} diff --git a/src/dlangui/graphics/scene/transform.d b/src/dlangui/graphics/scene/transform.d new file mode 100644 index 00000000..f8ba471f --- /dev/null +++ b/src/dlangui/graphics/scene/transform.d @@ -0,0 +1,103 @@ +module dlangui.graphics.scene.transform; + +import gl3n.linalg; +import gl3n.math; + +/// 3d transform: scale + translation + rotation +class Transform { + private bool _dirtyTransform = true; + private vec3 _scale = vec3(1.0f, 1.0f, 1.0f); + private vec3 _translation = vec3(0.0f, 0.0f, 0.0f); + private mat4 _rotation = mat4.identity; + + private mat4 _matrix; + + /// get scale vector + public @property ref const(vec3) scaling() const { return _scale; } + /// get scale X + public @property float scalingX() const { return _scale.x; } + /// get scale Y + public @property float scalingY() const { return _scale.y; } + /// get scale Z + public @property float scalingZ() const { return _scale.z; } + + /// set scale vector + public @property void scaling(const ref vec3 value) { _scale = value; _dirtyTransform = true; } + /// set scale vector x, y, z to the same value + public @property void scaling(float value) { _scale.x = _scale.y = _scale.z = value; _dirtyTransform = true; } + /// set scale X + public @property void scalingX(float value) { _scale.x = value; _dirtyTransform = true; } + /// set scale Y + public @property void scalingY(float value) { _scale.y = value; _dirtyTransform = true; } + /// set scale Z + public @property void scalingZ(float value) { _scale.z = value; _dirtyTransform = true; } + + /// get translation vector + public @property ref const(vec3) translation() const { return _translation; } + /// get translation X + public @property float translationX() const { return _translation.x; } + /// get translation Y + public @property float translationY() const { return _translation.y; } + /// get translation Z + public @property float translationZ() const { return _translation.z; } + + /// set translation vector + public @property void translation(const ref vec3 value) { _translation = value; _dirtyTransform = true; } + /// set translation vector x, y, z to the same value + public @property void translation(float value) { _translation.x = _translation.y = _translation.z = value; _dirtyTransform = true; } + /// set translation x + public @property void translationX(float value) { _translation.x = value; _dirtyTransform = true; } + /// set translation y + public @property void translationY(float value) { _translation.y = value; _dirtyTransform = true; } + /// set translation z + public @property void translationZ(float value) { _translation.z = value; _dirtyTransform = true; } + + /// translate by vector + public void translate(vec3 value) { _translation += value; _dirtyTransform = true; } + /// translate X + public void translateX(float value) { _translation.x += value; _dirtyTransform = true; } + /// translate Y + public void translateY(float value) { _translation.y += value; _dirtyTransform = true; } + /// translate Z + public void translateZ(float value) { _translation.z += value; _dirtyTransform = true; } + + /// scale by vector + public void scale(vec3 value) { _scale.x *= value.x; _scale.y *= value.y; _scale.z *= value.z; _dirtyTransform = true; } + /// scale all axis by the same values + public void scale(float value) { _scale *= value; _dirtyTransform = true; } + /// scale X + public void scaleX(float value) { _scale.x *= value; _dirtyTransform = true; } + /// scale Y + public void scaleY(float value) { _scale.y *= value; _dirtyTransform = true; } + /// scale Z + public void scaleZ(float value) { _scale.z *= value; _dirtyTransform = true; } + + /// rotate around X axis + public void rotateX(float angle) { _rotation.rotatex(angle); _dirtyTransform = true; } + /// rotate around Y axis + public void rotateY(float angle) { _rotation.rotatey(angle); _dirtyTransform = true; } + /// rotate around Z axis + public void rotateZ(float angle) { _rotation.rotatez(angle); _dirtyTransform = true; } + /// rotate around custom axis + public void rotate(float angle, const ref vec3 axis) { _rotation.rotate(angle, axis); _dirtyTransform = true; } + + /// set transform to identity transform + public void setIdentity() { + _dirtyTransform = true; + _scale = vec3(1.0f, 1.0f, 1.0f); + _translation = vec3(0.0f, 0.0f, 0.0f); + _rotation = mat4.identity; + } + + /// get transform matrix, recalculates if needed + public @property ref const(mat4) matrix() { + if (_dirtyTransform) { + _matrix = mat4.translation(_translation.x, _translation.y, _translation.z); + _matrix = _matrix * _rotation; + _matrix.scale(_scale.x, _scale.y, _scale.z); + _dirtyTransform = false; + } + return _matrix; + } + +} diff --git a/src/dlangui/platforms/sdl/sdlapp.d b/src/dlangui/platforms/sdl/sdlapp.d index 32b201c4..f5341c3b 100644 --- a/src/dlangui/platforms/sdl/sdlapp.d +++ b/src/dlangui/platforms/sdl/sdlapp.d @@ -1192,7 +1192,7 @@ version (Windows) { SCREEN_DPI = GetDeviceCaps(dc, LOGPIXELSY); DeleteObject(dc); - //SCREEN_DPI = 96 * 3 / 2; + SCREEN_DPI = 96 * 3 / 2; result = myWinMain(hInstance, hPrevInstance, lpCmdLine, nCmdShow); Log.i("calling Runtime.terminate()");