From 84fe6a34677d75390a25ab7bd523477de4b9cac5 Mon Sep 17 00:00:00 2001 From: Vadim Lopatin Date: Thu, 7 Apr 2016 12:13:06 +0300 Subject: [PATCH] Fix NO_OPENGL configurations, fix imports --- dlangui-msvc.visualdproj | 4 ++-- dub.json | 4 ++-- examples/d3d/d3d-msvc.visualdproj | 4 ++-- examples/d3d/src/d3d.d | 8 ++++++- examples/d3d/src/dminer/core/blocks.d | 3 +++ examples/d3d/src/dminer/core/minetypes.d | 3 +++ examples/d3d/src/dminer/core/world.d | 7 ++++-- src/dlangui/core/config.d | 24 +++++++++++++++++---- src/dlangui/graphics/scene/camera.d | 3 +++ src/dlangui/graphics/scene/drawableobject.d | 9 ++++++-- src/dlangui/graphics/scene/fbximport.d | 3 +++ src/dlangui/graphics/scene/light.d | 6 +++++- src/dlangui/graphics/scene/material.d | 1 + src/dlangui/graphics/scene/mesh.d | 3 +++ src/dlangui/graphics/scene/model.d | 3 +++ src/dlangui/graphics/scene/node.d | 14 +++++++----- src/dlangui/graphics/scene/objimport.d | 3 +++ src/dlangui/graphics/scene/scene3d.d | 14 +++++++----- src/dlangui/graphics/scene/transform.d | 3 +++ src/dlangui/package.d | 1 + 20 files changed, 94 insertions(+), 26 deletions(-) diff --git a/dlangui-msvc.visualdproj b/dlangui-msvc.visualdproj index 6d624519..36161889 100644 --- a/dlangui-msvc.visualdproj +++ b/dlangui-msvc.visualdproj @@ -72,7 +72,7 @@ 0 0 - EmbedStandardResources ForceLogs USE_OPENGL + EmbedStandardResources ForceLogs 0 0 0 @@ -378,7 +378,7 @@ 0 0 - EmbedStandardResources ForceLogs USE_OPENGL + EmbedStandardResources ForceLogs 0 0 0 diff --git a/dub.json b/dub.json index 868539f3..90c0085d 100644 --- a/dub.json +++ b/dub.json @@ -65,8 +65,8 @@ { "name": "minimal", "versions": ["EmbedStandardResources", "ForceLogs"], - "versions-posix": ["USE_SDL", "USE_FREETYPE", "USE_OPENGL"], - "versions-windows": ["Unicode"], + "versions-posix": ["USE_SDL", "USE_FREETYPE", "NO_OPENGL"], + "versions-windows": ["Unicode" ,"NO_OPENGL"], "dependencies-posix": { "derelict-gl3": "~>1.0.18", "derelict-sdl2": "~>1.9.7", diff --git a/examples/d3d/d3d-msvc.visualdproj b/examples/d3d/d3d-msvc.visualdproj index 20d53180..6d39644a 100644 --- a/examples/d3d/d3d-msvc.visualdproj +++ b/examples/d3d/d3d-msvc.visualdproj @@ -72,7 +72,7 @@ 0 0 - EmbedStandardResources USE_OPENGL + 0 0 0 @@ -276,7 +276,7 @@ 0 0 - EmbedStandardResources + 0 0 0 diff --git a/examples/d3d/src/d3d.d b/examples/d3d/src/d3d.d index eb1d5ab9..6f96ec10 100644 --- a/examples/d3d/src/d3d.d +++ b/examples/d3d/src/d3d.d @@ -29,7 +29,11 @@ extern (C) int UIAppMain(string[] args) { // create window Window window = Platform.instance.createWindow("DlangUI example - 3D Application", null, WindowFlag.Resizable, 600, 500); - window.mainWidget = new UiWidget(); + static if (ENABLE_OPENGL) { + window.mainWidget = new UiWidget(); + } else { + window.mainWidget = new TextWidget("error", "Please build with OpenGL enabled"d); + } //MeshPart part = new MeshPart(); @@ -40,6 +44,8 @@ extern (C) int UIAppMain(string[] args) { return Platform.instance.enterMessageLoop(); } +static if (ENABLE_OPENGL): + class UiWidget : VerticalLayout, CellVisitor { this() { super("OpenGLView"); diff --git a/examples/d3d/src/dminer/core/blocks.d b/examples/d3d/src/dminer/core/blocks.d index f1866525..e89ab10c 100644 --- a/examples/d3d/src/dminer/core/blocks.d +++ b/examples/d3d/src/dminer/core/blocks.d @@ -1,5 +1,8 @@ module dminer.core.blocks; +public import dlangui.core.config; +static if (ENABLE_OPENGL): + import dminer.core.minetypes; import dminer.core.world; import dlangui.graphics.scene.mesh; diff --git a/examples/d3d/src/dminer/core/minetypes.d b/examples/d3d/src/dminer/core/minetypes.d index 91091854..88fef484 100644 --- a/examples/d3d/src/dminer/core/minetypes.d +++ b/examples/d3d/src/dminer/core/minetypes.d @@ -1,5 +1,8 @@ module dminer.core.minetypes; +public import dlangui.core.config; +static if (ENABLE_OPENGL): + alias cell_t = ubyte; immutable cell_t NO_CELL = 0; diff --git a/examples/d3d/src/dminer/core/world.d b/examples/d3d/src/dminer/core/world.d index 41d7e6f2..b5da0387 100644 --- a/examples/d3d/src/dminer/core/world.d +++ b/examples/d3d/src/dminer/core/world.d @@ -1,5 +1,8 @@ module dminer.core.world; +public import dlangui.core.config; +static if (ENABLE_OPENGL): + import dminer.core.minetypes; import dminer.core.blocks; @@ -225,8 +228,8 @@ struct DiamondVisitor { //int index = diamondIndex(v, maxDistBits); if (visited_ptr[index] == visitedOccupied)// || cell == visitedEmpty) return; - if (v * position.direction.forward < dist / 3) - return; + //if (v * position.direction.forward < dist / 3) + // return; Vector3d pos = pos0 + v; cell_t cell = world.getCell(pos); diff --git a/src/dlangui/core/config.d b/src/dlangui/core/config.d index 46c05c45..24b0008f 100644 --- a/src/dlangui/core/config.d +++ b/src/dlangui/core/config.d @@ -59,28 +59,44 @@ version (USE_SDL) { // no backend selected: set default based on platform version (Windows) { // For Windows - enum ENABLE_OPENGL = true; + version (NO_OPENGL) { + enum ENABLE_OPENGL = false; + } else { + enum ENABLE_OPENGL = true; + } enum BACKEND_SDL = false; enum BACKEND_X11 = false; enum BACKEND_DSFML = false; enum BACKEND_WIN32 = true; } else version(linux) { // Default for Linux: use SDL and OpenGL - enum ENABLE_OPENGL = true; + version (NO_OPENGL) { + enum ENABLE_OPENGL = false; + } else { + enum ENABLE_OPENGL = true; + } enum BACKEND_SDL = true; enum BACKEND_X11 = false; enum BACKEND_DSFML = false; enum BACKEND_WIN32 = false; } else version(OSX) { // Default: use SDL and OpenGL - enum ENABLE_OPENGL = true; + version (NO_OPENGL) { + enum ENABLE_OPENGL = false; + } else { + enum ENABLE_OPENGL = true; + } enum BACKEND_SDL = true; enum BACKEND_X11 = false; enum BACKEND_DSFML = false; enum BACKEND_WIN32 = false; } else { // Unknown platform: use SDL and OpenGL - enum ENABLE_OPENGL = true; + version (NO_OPENGL) { + enum ENABLE_OPENGL = false; + } else { + enum ENABLE_OPENGL = true; + } enum BACKEND_SDL = true; enum BACKEND_X11 = false; enum BACKEND_DSFML = false; diff --git a/src/dlangui/graphics/scene/camera.d b/src/dlangui/graphics/scene/camera.d index cbf595bc..b64dcd5a 100644 --- a/src/dlangui/graphics/scene/camera.d +++ b/src/dlangui/graphics/scene/camera.d @@ -1,5 +1,8 @@ module dlangui.graphics.scene.camera; +public import dlangui.core.config; +static if (ENABLE_OPENGL): + import dlangui.graphics.scene.node; import dlangui.core.math3d; diff --git a/src/dlangui/graphics/scene/drawableobject.d b/src/dlangui/graphics/scene/drawableobject.d index 92a37d8f..bc73a92f 100644 --- a/src/dlangui/graphics/scene/drawableobject.d +++ b/src/dlangui/graphics/scene/drawableobject.d @@ -1,12 +1,17 @@ module dlangui.graphics.scene.drawableobject; -public import dlangui.core.types; -public import dlangui.graphics.scene.node; +import dlangui.core.config; +static if (ENABLE_OPENGL): + +import dlangui.core.types; /// Reference counted DrawableObject alias DrawableObjectRef = Ref!DrawableObject; class DrawableObject : RefCountedObject { + + import dlangui.graphics.scene.node; + this() { } void draw(Node3d node, bool wireframe) { diff --git a/src/dlangui/graphics/scene/fbximport.d b/src/dlangui/graphics/scene/fbximport.d index 82d6bc24..8667f678 100644 --- a/src/dlangui/graphics/scene/fbximport.d +++ b/src/dlangui/graphics/scene/fbximport.d @@ -1,5 +1,8 @@ module dlangui.graphics.scene.fbximport; +public import dlangui.core.config; +static if (ENABLE_OPENGL): + import dlangui.core.logger; import dlangui.core.math3d; import dlangui.dml.tokenizer; diff --git a/src/dlangui/graphics/scene/light.d b/src/dlangui/graphics/scene/light.d index b22ba6f6..7c8b7e8e 100644 --- a/src/dlangui/graphics/scene/light.d +++ b/src/dlangui/graphics/scene/light.d @@ -1,8 +1,10 @@ module dlangui.graphics.scene.light; +public import dlangui.core.config; +static if (ENABLE_OPENGL): + import dlangui.core.math3d; import dlangui.core.types; -import dlangui.graphics.scene.node; import std.conv : to; @@ -17,6 +19,8 @@ alias LightRef = Ref!Light; class Light : RefCountedObject { + import dlangui.graphics.scene.node; + protected Node3d _node; protected vec3 _color; diff --git a/src/dlangui/graphics/scene/material.d b/src/dlangui/graphics/scene/material.d index c0706e57..ae27b3d7 100644 --- a/src/dlangui/graphics/scene/material.d +++ b/src/dlangui/graphics/scene/material.d @@ -1,6 +1,7 @@ module dlangui.graphics.scene.material; public import dlangui.core.config; +static if (ENABLE_OPENGL): import dlangui.core.types; import dlangui.core.logger; diff --git a/src/dlangui/graphics/scene/mesh.d b/src/dlangui/graphics/scene/mesh.d index 79ac1104..91146ca9 100644 --- a/src/dlangui/graphics/scene/mesh.d +++ b/src/dlangui/graphics/scene/mesh.d @@ -1,5 +1,8 @@ module dlangui.graphics.scene.mesh; +public import dlangui.core.config; +static if (ENABLE_OPENGL): + import dlangui.core.math3d; import dlangui.core.types; //import dlangui.graphics.scene.material; diff --git a/src/dlangui/graphics/scene/model.d b/src/dlangui/graphics/scene/model.d index 5c081c38..8679e434 100644 --- a/src/dlangui/graphics/scene/model.d +++ b/src/dlangui/graphics/scene/model.d @@ -1,5 +1,8 @@ module dlangui.graphics.scene.model; +public import dlangui.core.config; +static if (ENABLE_OPENGL): + import dlangui.graphics.scene.drawableobject; import dlangui.graphics.scene.mesh; import dlangui.graphics.scene.material; diff --git a/src/dlangui/graphics/scene/node.d b/src/dlangui/graphics/scene/node.d index 1fc568a6..23a14176 100644 --- a/src/dlangui/graphics/scene/node.d +++ b/src/dlangui/graphics/scene/node.d @@ -1,16 +1,20 @@ module dlangui.graphics.scene.node; +public import dlangui.core.config; +static if (ENABLE_OPENGL): + import dlangui.core.math3d; import dlangui.graphics.scene.transform; -import dlangui.core.collections; -import dlangui.graphics.scene.scene3d; -import dlangui.graphics.scene.drawableobject; -import dlangui.graphics.scene.light; -import dlangui.graphics.scene.camera; /// 3D scene node class Node3d : Transform { + import dlangui.core.collections; + import dlangui.graphics.scene.scene3d; + import dlangui.graphics.scene.drawableobject; + import dlangui.graphics.scene.light; + import dlangui.graphics.scene.camera; + protected Node3d _parent; protected Scene3d _scene; protected string _id; diff --git a/src/dlangui/graphics/scene/objimport.d b/src/dlangui/graphics/scene/objimport.d index a54d2a3d..7cbdf4d9 100644 --- a/src/dlangui/graphics/scene/objimport.d +++ b/src/dlangui/graphics/scene/objimport.d @@ -1,5 +1,8 @@ module dlangui.graphics.scene.objimport; +public import dlangui.core.config; +static if (ENABLE_OPENGL): + import dlangui.core.logger; import dlangui.core.math3d; import dlangui.dml.tokenizer; diff --git a/src/dlangui/graphics/scene/scene3d.d b/src/dlangui/graphics/scene/scene3d.d index 6a0d0407..b420a6cb 100644 --- a/src/dlangui/graphics/scene/scene3d.d +++ b/src/dlangui/graphics/scene/scene3d.d @@ -1,17 +1,21 @@ module dlangui.graphics.scene.scene3d; -import dlangui.core.types; -import dlangui.graphics.scene.node; -import dlangui.graphics.scene.camera; -import dlangui.graphics.scene.light; +public import dlangui.core.config; +static if (ENABLE_OPENGL): -public import dlangui.core.math3d; +import dlangui.core.types; + +import dlangui.core.math3d; +import dlangui.graphics.scene.node; /// Reference counted Scene3d object alias Scene3dRef = Ref!Scene3d; + /// 3D scene class Scene3d : Node3d { + import dlangui.graphics.scene.camera; + import dlangui.graphics.scene.light; protected vec3 _ambientColor; protected Camera _activeCamera; diff --git a/src/dlangui/graphics/scene/transform.d b/src/dlangui/graphics/scene/transform.d index 9d1aec38..f3705875 100644 --- a/src/dlangui/graphics/scene/transform.d +++ b/src/dlangui/graphics/scene/transform.d @@ -1,5 +1,8 @@ module dlangui.graphics.scene.transform; +public import dlangui.core.config; +static if (ENABLE_OPENGL): + import dlangui.core.math3d; import dlangui.core.types; diff --git a/src/dlangui/package.d b/src/dlangui/package.d index 31ba86be..0c3c11ac 100644 --- a/src/dlangui/package.d +++ b/src/dlangui/package.d @@ -47,6 +47,7 @@ Authors: Vadim Lopatin, coolreader.org@gmail.com module dlangui; public { + import dlangui.core.config; import dlangui.core.logger; import dlangui.core.types; import dlangui.core.i18n;