From 95a0d0370d80881ff2ba78390b62c16060abe068 Mon Sep 17 00:00:00 2001 From: Vadim Lopatin Date: Tue, 26 Apr 2016 10:29:14 +0300 Subject: [PATCH] DMiner fixes for android --- examples/dminer/src/dminer/core/blocks.d | 16 ++++++++-------- examples/dminer/src/dminer/core/minetypes.d | 4 ++-- examples/dminer/src/dminer/core/world.d | 6 +++++- examples/dminer/src/minermain.d | 6 +++--- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/examples/dminer/src/dminer/core/blocks.d b/examples/dminer/src/dminer/core/blocks.d index c8bb4cb6..c659e55c 100644 --- a/examples/dminer/src/dminer/core/blocks.d +++ b/examples/dminer/src/dminer/core/blocks.d @@ -94,7 +94,7 @@ X<-----x----- 3 | 2 */ -static const float[VERTEX_COMPONENTS * 4] face_vertices_north = +__gshared static const float[VERTEX_COMPONENTS * 4] face_vertices_north = [ 0.5, 0.5, -0.5, 0.0, 0.0, -1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, -0.5, 0.5, -0.5, 0.0, 0.0, -1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, @@ -109,7 +109,7 @@ static const float[VERTEX_COMPONENTS * 4] face_vertices_north = 3 | 2 */ -static const float[VERTEX_COMPONENTS * 4] face_vertices_south = +__gshared static const float[VERTEX_COMPONENTS * 4] face_vertices_south = [ -0.5, 0.5, 0.5, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.5, 0.5, 0.5, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, @@ -124,7 +124,7 @@ static const float[VERTEX_COMPONENTS * 4] face_vertices_south = 3 | 2 */ -static const float[VERTEX_COMPONENTS * 4] face_vertices_west = +__gshared static const float[VERTEX_COMPONENTS * 4] face_vertices_west = [ -0.5, 0.5, -0.5, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, -0.5, 0.5, 0.5, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, @@ -139,7 +139,7 @@ Z<-----x----- 3 | 2 */ -static const float[VERTEX_COMPONENTS * 4] face_vertices_east = +__gshared static const float[VERTEX_COMPONENTS * 4] face_vertices_east = [ 0.5, 0.5, 0.5, -1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.5, 0.5, -0.5, -1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, @@ -155,7 +155,7 @@ static const float[VERTEX_COMPONENTS * 4] face_vertices_east = Zv */ -static const float[VERTEX_COMPONENTS * 4] face_vertices_up = +__gshared static const float[VERTEX_COMPONENTS * 4] face_vertices_up = [ -0.5, 0.5, -0.5, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.5, 0.5, -0.5, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, @@ -170,7 +170,7 @@ X<-----x----- Zv */ -static const float[VERTEX_COMPONENTS * 4] face_vertices_down = +__gshared static const float[VERTEX_COMPONENTS * 4] face_vertices_down = [ 0.5, -0.5,-0.5, 0.0, -1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, -0.5, -0.5,-0.5, 0.0, -1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, @@ -178,12 +178,12 @@ static const float[VERTEX_COMPONENTS * 4] face_vertices_down = 0.5, -0.5, 0.5, 0.0, -1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 1.0, ]; -static const ushort[6] face_indexes = +__gshared static const ushort[6] face_indexes = [ 2, 1, 0, 0, 3, 2 // CCW ]; -static const ushort[6] face_indexes_back = +__gshared static const ushort[6] face_indexes_back = [ 0, 2, 1, 2, 3, 1 ]; diff --git a/examples/dminer/src/dminer/core/minetypes.d b/examples/dminer/src/dminer/core/minetypes.d index 1317f566..fa90e5a8 100644 --- a/examples/dminer/src/dminer/core/minetypes.d +++ b/examples/dminer/src/dminer/core/minetypes.d @@ -159,7 +159,7 @@ struct Vector3d { } } -const Vector3d ZERO3 = Vector3d(0, 0, 0); +__gshared const Vector3d ZERO3 = Vector3d(0, 0, 0); struct Array(T) { private: @@ -721,7 +721,7 @@ struct Random { } } -const Vector3d[6] DIRECTION_VECTORS = [ +__gshared const Vector3d[6] DIRECTION_VECTORS = [ Vector3d(0, 0, -1), Vector3d(0, 0, 1), Vector3d(-1, 0, 0), diff --git a/examples/dminer/src/dminer/core/world.d b/examples/dminer/src/dminer/core/world.d index 40341d42..f8ef87cb 100644 --- a/examples/dminer/src/dminer/core/world.d +++ b/examples/dminer/src/dminer/core/world.d @@ -3,7 +3,11 @@ module dminer.core.world; import dminer.core.minetypes; import dminer.core.blocks; -const int MAX_VIEW_DISTANCE_BITS = 6; +version (Android) { + const int MAX_VIEW_DISTANCE_BITS = 6; +} else { + const int MAX_VIEW_DISTANCE_BITS = 5; +} const int MAX_VIEW_DISTANCE = (1 << MAX_VIEW_DISTANCE_BITS); // Layer is 16x16 (CHUNK_DX_SHIFT x CHUNK_DX_SHIFT) cells diff --git a/examples/dminer/src/minermain.d b/examples/dminer/src/minermain.d index 64835c8d..a9e98940 100644 --- a/examples/dminer/src/minermain.d +++ b/examples/dminer/src/minermain.d @@ -444,7 +444,7 @@ class UiWidget : VerticalLayout, CellVisitor { /// this is OpenGLDrawableDelegate implementation private void doDraw(Rect windowRect, Rect rc) { - _cam.setPerspective(rc.width, rc.height, 45.0f, 0.1, 100); + _cam.setPerspective(rc.width, rc.height, 45.0f, 0.3, MAX_VIEW_DISTANCE); _cam.setIdentity(); _cam.translate(_animatingPosition); _cam.rotateY(_animatingAngle); @@ -453,8 +453,8 @@ class UiWidget : VerticalLayout, CellVisitor { dirLightNode.translate(_animatingPosition); dirLightNode.rotateY(_animatingAngle); - checkgl!glEnable(GL_CULL_FACE); - //checkgl!glDisable(GL_CULL_FACE); + //checkgl!glEnable(GL_CULL_FACE); + checkgl!glDisable(GL_CULL_FACE); checkgl!glEnable(GL_DEPTH_TEST); checkgl!glCullFace(GL_BACK);