diff --git a/GUI b/GUI index 1b95b15..92dd659 100644 --- a/GUI +++ b/GUI @@ -6,6 +6,14 @@ GUI Elements shall be scaled and position based upon the same normalized coordin These normalized values are tied strictly to the size of the screen as returned by v_width and v_height as defined in Core. +Furthermore, the special GUI element position flag indicates the point of origin. These points are: + * LEFT, indicating x origin being at 0.0 of the screen and moving positively + * RIGHT, indicating x origin starting at 1.0 of the screen and moving negatively from there + * TOP, indicating y origin starting at 0.0 and moving positively from there + * BOTTOM, indicating y origin starting at 1.0 and moving negatively from there + * HCENTER, indicating an x origin of 0.5 and moving either negatively or positively + * VCENTER, indicating a y origin of 0.5 and moving either negatively or positively + Creation -------- Each GUI element shall be created via the GUI, which then in turn creates a new RenderObject() for the UI RenderScene as defined in Core. diff --git a/TODO b/TODO index 348dacd..533f58a 100644 --- a/TODO +++ b/TODO @@ -11,3 +11,48 @@ Initial steps b. Do some tests for - iOS - Web via Emscripten + +-------------------------------- +What Must Be Done +-------------------------------- + 1. GUI + * SDL2_ttf! + * GUI Elements creating RenderView + * GuiElement.doRender() + * Updates RenderView + * For each child, we call their doRender() and render their FBO to this + * GuiElement sub-classes + - GuiButton, GuiImage, GuiText, GuiInput, GuiContainer + 2. Campaign class + * Use FS as db + * Name, unique + * Map, unique name + * contains CACHE of files used + * contains size of Map (dynamic? or no?) + * contains Terrain Heightmap + * contains sections of map, storing Tokens (QuadTree?) + * Token may be linked with TokenData + 3. Token class + * Is a type, default is 2D, meaning: + * token PNG file + * scale size + * rotation + * TokenData reference(string?) + * Owner (Player? Player Name? Campaign Master?) + * Layer (Terrain? Game? etc.?) + 4. Edit interface + * build a GuiList of GuiImage(s)(GuiToken?) from each AssetCache dir? (maybe buttons on top, tabular-like) + * Selected icon can be dragged out onto Game board, wherein it gets added to the current Token Layer + 5. Net stuff + * Game state + - Server + * on Movement/Update of things, send updates to Clients + - Client + * on attempted movement of a Token (spawns a drag'n'drop semitransparent icon, maybe render of that exact object?), send command to server + * General + * basic communication (message to all, message to person(s?)) + * Init + - Server + * authenticate user if username/password matches? + - Client + * attempt connect and wait for auth ok (if okay, we probably ask for Campaign/Map info) diff --git a/build/android/jni/src/Android.mk b/build/android/jni/src/Android.mk index f28e889..d612674 100755 --- a/build/android/jni/src/Android.mk +++ b/build/android/jni/src/Android.mk @@ -53,6 +53,8 @@ LOCAL_SRC_FILES := $(SDL_PATH)/src/main/android/SDL_android_main.c \ ../../../../src/common.hpp \ ../../../../src/Core.cpp \ ../../../../src/Core.hpp \ + ../../../../src/SysInfo.cpp \ + ../../../../src/SysInfo.hpp \ ../../../../src/Gui.cpp \ ../../../../src/Gui.hpp \ ../../../../src/State.hpp \ @@ -62,6 +64,10 @@ LOCAL_SRC_FILES := $(SDL_PATH)/src/main/android/SDL_android_main.c \ ../../../../src/states/TestState.hpp \ ../../../../src/gui/GuiElement.cpp \ ../../../../src/gui/GuiElement.hpp \ + ../../../../src/gui/GuiButton.cpp \ + ../../../../src/gui/GuiButton.hpp \ + ../../../../src/gui/GuiList.cpp \ + ../../../../src/gui/GuiList.hpp \ ../../../../src/main.cpp LOCAL_SHARED_LIBRARIES := SDL2 SDL2_image diff --git a/build/android/src/com/polymathic/RtB/RtB.java b/build/android/src/com/polymathic/RtB/RtB.java index 0a1bab8..9ca163a 100644 --- a/build/android/src/com/polymathic/RtB/RtB.java +++ b/build/android/src/com/polymathic/RtB/RtB.java @@ -2,6 +2,7 @@ package com.polymathic.RtB; import org.libsdl.app.SDLActivity; import android.content.res.AssetManager; +import android.util.DisplayMetrics; import android.os.*; import java.io.File; @@ -12,6 +13,7 @@ public class RtB extends SDLActivity { private static native void setAssetManager(AssetManager manager); private static native void setAppDirectory(String dir); private static native void setExtDirectory(String dir); + private static native void setDpiInfo(int density_dpi, float xdpi, float ydpi); @Override protected void onCreate(Bundle savedInstanceState) { @@ -23,6 +25,10 @@ public class RtB extends SDLActivity { setAppDirectory(dir.getPath()); File ext_dir = getApplicationContext().getExternalFilesDir(null); setExtDirectory(ext_dir.getPath()); + // send our DPI info + DisplayMetrics metrics = new DisplayMetrics(); + getWindowManager().getDefaultDisplay().getMetrics(metrics); + setDpiInfo(metrics.densityDpi, metrics.xdpi, metrics.ydpi); // Pass on to SDLActivity super.onCreate(savedInstanceState); } diff --git a/build/ios/Roll them Bones.xcodeproj/project.pbxproj b/build/ios/Roll them Bones.xcodeproj/project.pbxproj index 7487b40..494d1cb 100755 --- a/build/ios/Roll them Bones.xcodeproj/project.pbxproj +++ b/build/ios/Roll them Bones.xcodeproj/project.pbxproj @@ -12,32 +12,19 @@ 1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; }; 20517C8F1A9B40A200DE49E9 /* Program.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 20517C8B1A9B40A200DE49E9 /* Program.cpp */; }; 20517C901A9B40A200DE49E9 /* Quat.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 20517C8D1A9B40A200DE49E9 /* Quat.cpp */; }; - 20517CA11A9B40E800DE49E9 /* chest.obj in Copy Models */ = {isa = PBXBuildFile; fileRef = 205723DB1A9B4053001400FA /* chest.obj */; }; - 20517D161A9B449200DE49E9 /* default_fs.100.glsl in Resources */ = {isa = PBXBuildFile; fileRef = 20517D121A9B449200DE49E9 /* default_fs.100.glsl */; }; - 20517D171A9B449200DE49E9 /* default_vs.100.glsl in Resources */ = {isa = PBXBuildFile; fileRef = 20517D131A9B449200DE49E9 /* default_vs.100.glsl */; }; - 20517D181A9B449200DE49E9 /* fb_fs.100.glsl in Resources */ = {isa = PBXBuildFile; fileRef = 20517D141A9B449200DE49E9 /* fb_fs.100.glsl */; }; - 20517D191A9B449200DE49E9 /* fb_vs.100.glsl in Resources */ = {isa = PBXBuildFile; fileRef = 20517D151A9B449200DE49E9 /* fb_vs.100.glsl */; }; - 20517D1A1A9B449700DE49E9 /* default_fs.100.glsl in Copy Shaders */ = {isa = PBXBuildFile; fileRef = 20517D121A9B449200DE49E9 /* default_fs.100.glsl */; }; - 20517D1B1A9B449700DE49E9 /* default_vs.100.glsl in Copy Shaders */ = {isa = PBXBuildFile; fileRef = 20517D131A9B449200DE49E9 /* default_vs.100.glsl */; }; - 20517D1C1A9B449700DE49E9 /* fb_fs.100.glsl in Copy Shaders */ = {isa = PBXBuildFile; fileRef = 20517D141A9B449200DE49E9 /* fb_fs.100.glsl */; }; - 20517D1D1A9B449700DE49E9 /* fb_vs.100.glsl in Copy Shaders */ = {isa = PBXBuildFile; fileRef = 20517D151A9B449200DE49E9 /* fb_vs.100.glsl */; }; 20517DB91A9C237D00DE49E9 /* checksum.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 20517DB51A9C237D00DE49E9 /* checksum.cpp */; }; 20517DBA1A9C237D00DE49E9 /* fio.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 20517DB71A9C237D00DE49E9 /* fio.cpp */; }; 20517E5A1A9D4A0300DE49E9 /* Core.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 20517E581A9D4A0300DE49E9 /* Core.cpp */; }; - 205183891A9DE71F00DE49E9 /* cube.obj in Resources */ = {isa = PBXBuildFile; fileRef = 205183881A9DE71F00DE49E9 /* cube.obj */; }; - 2051838A1A9DE72A00DE49E9 /* cube.obj in Copy Models */ = {isa = PBXBuildFile; fileRef = 205183881A9DE71F00DE49E9 /* cube.obj */; }; 2056AE551A8A423E00833760 /* Mat4.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2056AE4F1A8A423E00833760 /* Mat4.cpp */; }; 2056AE561A8A423E00833760 /* RenderObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2056AE511A8A423E00833760 /* RenderObject.cpp */; }; 2056AE571A8A423E00833760 /* Vec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2056AE531A8A423E00833760 /* Vec.cpp */; }; - 205723E11A9B4053001400FA /* chest.obj in Resources */ = {isa = PBXBuildFile; fileRef = 205723DB1A9B4053001400FA /* chest.obj */; }; 2078E3811AA5CE4700172D34 /* GuiElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2078E37F1AA5CE4700172D34 /* GuiElement.cpp */; }; 2078E3841AA5CE5500172D34 /* Gui.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2078E3821AA5CE5500172D34 /* Gui.cpp */; }; 208B63BF1AA69C28008D37B5 /* libSDL2_image.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 208B63BE1AA69C28008D37B5 /* libSDL2_image.a */; }; - 208B64331AA6B8C4008D37B5 /* cube.png in Resources */ = {isa = PBXBuildFile; fileRef = 208B64321AA6B8C4008D37B5 /* cube.png */; }; - 208B64361AA6B8FD008D37B5 /* cube.png in Copy Textures */ = {isa = PBXBuildFile; fileRef = 208B64321AA6B8C4008D37B5 /* cube.png */; }; 208B64421AA6B93E008D37B5 /* Texture.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 208B64401AA6B93E008D37B5 /* Texture.cpp */; }; 208B64551AA6B9D4008D37B5 /* ImageIO.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 208B64541AA6B9D4008D37B5 /* ImageIO.framework */; }; 208B645E1AA6B9F7008D37B5 /* MobileCoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 208B645D1AA6B9F7008D37B5 /* MobileCoreServices.framework */; }; + 208B66461AA7CC16008D37B5 /* data in Resources */ = {isa = PBXBuildFile; fileRef = 208B66451AA7CC16008D37B5 /* data */; }; 20A7A91D1A89F91300EDC1A0 /* RenderCamera.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 20A7A9151A89F91300EDC1A0 /* RenderCamera.cpp */; }; 20A7A91E1A89F91300EDC1A0 /* RenderScene.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 20A7A9171A89F91300EDC1A0 /* RenderScene.cpp */; }; 20A7A91F1A89F91300EDC1A0 /* RenderSet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 20A7A9191A89F91300EDC1A0 /* RenderSet.cpp */; }; @@ -59,46 +46,6 @@ FDB8BFC60E5A0F6A00980157 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FDB8BFC50E5A0F6A00980157 /* CoreGraphics.framework */; }; /* End PBXBuildFile section */ -/* Begin PBXCopyFilesBuildPhase section */ - 20517CBD1A9B411300DE49E9 /* Copy Models */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = data/models; - dstSubfolderSpec = 7; - files = ( - 2051838A1A9DE72A00DE49E9 /* cube.obj in Copy Models */, - 20517CA11A9B40E800DE49E9 /* chest.obj in Copy Models */, - ); - name = "Copy Models"; - runOnlyForDeploymentPostprocessing = 0; - }; - 20517CBE1A9B411300DE49E9 /* Copy Shaders */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = data/shaders; - dstSubfolderSpec = 7; - files = ( - 20517D1A1A9B449700DE49E9 /* default_fs.100.glsl in Copy Shaders */, - 20517D1B1A9B449700DE49E9 /* default_vs.100.glsl in Copy Shaders */, - 20517D1C1A9B449700DE49E9 /* fb_fs.100.glsl in Copy Shaders */, - 20517D1D1A9B449700DE49E9 /* fb_vs.100.glsl in Copy Shaders */, - ); - name = "Copy Shaders"; - runOnlyForDeploymentPostprocessing = 0; - }; - 208B64351AA6B8EB008D37B5 /* Copy Textures */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = data/textures; - dstSubfolderSpec = 7; - files = ( - 208B64361AA6B8FD008D37B5 /* cube.png in Copy Textures */, - ); - name = "Copy Textures"; - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXCopyFilesBuildPhase section */ - /* Begin PBXFileReference section */ 0097E29A12F70C4D00724AC5 /* begin_code.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = begin_code.h; sourceTree = ""; }; 0097E29B12F70C4D00724AC5 /* close_code.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = close_code.h; sourceTree = ""; }; @@ -166,35 +113,29 @@ 20517C8C1A9B40A200DE49E9 /* Program.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = Program.hpp; path = ../../src/Program.hpp; sourceTree = SOURCE_ROOT; }; 20517C8D1A9B40A200DE49E9 /* Quat.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Quat.cpp; path = ../../src/Quat.cpp; sourceTree = SOURCE_ROOT; }; 20517C8E1A9B40A200DE49E9 /* Quat.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = Quat.hpp; path = ../../src/Quat.hpp; sourceTree = SOURCE_ROOT; }; - 20517D121A9B449200DE49E9 /* default_fs.100.glsl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = default_fs.100.glsl; sourceTree = ""; }; - 20517D131A9B449200DE49E9 /* default_vs.100.glsl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = default_vs.100.glsl; sourceTree = ""; }; - 20517D141A9B449200DE49E9 /* fb_fs.100.glsl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = fb_fs.100.glsl; sourceTree = ""; }; - 20517D151A9B449200DE49E9 /* fb_vs.100.glsl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = fb_vs.100.glsl; sourceTree = ""; }; 20517DB51A9C237D00DE49E9 /* checksum.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = checksum.cpp; path = ../../src/checksum.cpp; sourceTree = SOURCE_ROOT; }; 20517DB61A9C237D00DE49E9 /* checksum.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = checksum.hpp; path = ../../src/checksum.hpp; sourceTree = SOURCE_ROOT; }; 20517DB71A9C237D00DE49E9 /* fio.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = fio.cpp; path = ../../src/fio.cpp; sourceTree = SOURCE_ROOT; }; 20517DB81A9C237D00DE49E9 /* fio.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = fio.hpp; path = ../../src/fio.hpp; sourceTree = SOURCE_ROOT; }; 20517E581A9D4A0300DE49E9 /* Core.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Core.cpp; path = ../../src/Core.cpp; sourceTree = SOURCE_ROOT; }; 20517E591A9D4A0300DE49E9 /* Core.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = Core.hpp; path = ../../src/Core.hpp; sourceTree = SOURCE_ROOT; }; - 205183881A9DE71F00DE49E9 /* cube.obj */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = cube.obj; path = ../../data/models/cube.obj; sourceTree = SOURCE_ROOT; }; 2056AE4F1A8A423E00833760 /* Mat4.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Mat4.cpp; path = ../../src/Mat4.cpp; sourceTree = SOURCE_ROOT; }; 2056AE501A8A423E00833760 /* Mat4.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = Mat4.hpp; path = ../../src/Mat4.hpp; sourceTree = SOURCE_ROOT; }; 2056AE511A8A423E00833760 /* RenderObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RenderObject.cpp; path = ../../src/RenderObject.cpp; sourceTree = SOURCE_ROOT; }; 2056AE521A8A423E00833760 /* RenderObject.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = RenderObject.hpp; path = ../../src/RenderObject.hpp; sourceTree = SOURCE_ROOT; }; 2056AE531A8A423E00833760 /* Vec.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Vec.cpp; path = ../../src/Vec.cpp; sourceTree = SOURCE_ROOT; }; 2056AE541A8A423E00833760 /* Vec.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = Vec.hpp; path = ../../src/Vec.hpp; sourceTree = SOURCE_ROOT; }; - 205723DB1A9B4053001400FA /* chest.obj */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = chest.obj; path = ../../data/models/chest.obj; sourceTree = SOURCE_ROOT; }; 2078E37F1AA5CE4700172D34 /* GuiElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = GuiElement.cpp; path = ../../src/gui/GuiElement.cpp; sourceTree = SOURCE_ROOT; }; 2078E3801AA5CE4700172D34 /* GuiElement.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = GuiElement.hpp; path = ../../src/gui/GuiElement.hpp; sourceTree = SOURCE_ROOT; }; 2078E3821AA5CE5500172D34 /* Gui.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Gui.cpp; path = ../../src/Gui.cpp; sourceTree = SOURCE_ROOT; }; 2078E3831AA5CE5500172D34 /* Gui.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = Gui.hpp; path = ../../src/Gui.hpp; sourceTree = SOURCE_ROOT; }; 208B63B41AA69BEE008D37B5 /* SDL_image.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_image.h; path = ../../../android/SDL2_image/SDL_image.h; sourceTree = SOURCE_ROOT; }; 208B63BE1AA69C28008D37B5 /* libSDL2_image.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libSDL2_image.a; path = ../../../android/SDL2_image/libSDL2_image.a; sourceTree = SOURCE_ROOT; }; - 208B64321AA6B8C4008D37B5 /* cube.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = cube.png; path = textures/cube.png; sourceTree = ""; }; 208B64401AA6B93E008D37B5 /* Texture.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Texture.cpp; path = ../../src/Texture.cpp; sourceTree = SOURCE_ROOT; }; 208B64411AA6B93E008D37B5 /* Texture.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = Texture.hpp; path = ../../src/Texture.hpp; sourceTree = SOURCE_ROOT; }; 208B64541AA6B9D4008D37B5 /* ImageIO.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ImageIO.framework; path = System/Library/Frameworks/ImageIO.framework; sourceTree = SDKROOT; }; 208B645D1AA6B9F7008D37B5 /* MobileCoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MobileCoreServices.framework; path = System/Library/Frameworks/MobileCoreServices.framework; sourceTree = SDKROOT; }; + 208B66451AA7CC16008D37B5 /* data */ = {isa = PBXFileReference; lastKnownFileType = folder; name = data; path = ../../data; sourceTree = SOURCE_ROOT; }; 20A7A9151A89F91300EDC1A0 /* RenderCamera.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RenderCamera.cpp; path = ../../src/RenderCamera.cpp; sourceTree = SOURCE_ROOT; }; 20A7A9161A89F91300EDC1A0 /* RenderCamera.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = RenderCamera.hpp; path = ../../src/RenderCamera.hpp; sourceTree = SOURCE_ROOT; }; 20A7A9171A89F91300EDC1A0 /* RenderScene.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RenderScene.cpp; path = ../../src/RenderScene.cpp; sourceTree = SOURCE_ROOT; }; @@ -343,38 +284,6 @@ name = Products; sourceTree = ""; }; - 205723D91A9B4053001400FA /* data */ = { - isa = PBXGroup; - children = ( - 208B64311AA6B8B7008D37B5 /* textures */, - 205723DC1A9B4053001400FA /* shaders */, - 205723DA1A9B4053001400FA /* models */, - ); - name = data; - path = ../../data; - sourceTree = SOURCE_ROOT; - }; - 205723DA1A9B4053001400FA /* models */ = { - isa = PBXGroup; - children = ( - 205183881A9DE71F00DE49E9 /* cube.obj */, - 205723DB1A9B4053001400FA /* chest.obj */, - ); - name = models; - path = "../../../../../../$(SOURCE_ROOT)"; - sourceTree = SOURCE_ROOT; - }; - 205723DC1A9B4053001400FA /* shaders */ = { - isa = PBXGroup; - children = ( - 20517D121A9B449200DE49E9 /* default_fs.100.glsl */, - 20517D131A9B449200DE49E9 /* default_vs.100.glsl */, - 20517D141A9B449200DE49E9 /* fb_fs.100.glsl */, - 20517D151A9B449200DE49E9 /* fb_vs.100.glsl */, - ); - path = shaders; - sourceTree = ""; - }; 2078E37E1AA5CE3700172D34 /* Gui */ = { isa = PBXGroup; children = ( @@ -409,14 +318,6 @@ name = lib; sourceTree = ""; }; - 208B64311AA6B8B7008D37B5 /* textures */ = { - isa = PBXGroup; - children = ( - 208B64321AA6B8C4008D37B5 /* cube.png */, - ); - name = textures; - sourceTree = ""; - }; 20A7A9131A89F8F600EDC1A0 /* Classes */ = { isa = PBXGroup; children = ( @@ -484,7 +385,6 @@ 29B97314FDCFA39411CA2CEA /* CustomTemplate */ = { isa = PBXGroup; children = ( - 205723D91A9B4053001400FA /* data */, 29B97315FDCFA39411CA2CEA /* Sources */, 20A7A9131A89F8F600EDC1A0 /* Classes */, 20A7A9221A89F91B00EDC1A0 /* Other Sources */, @@ -514,6 +414,7 @@ 29B97317FDCFA39411CA2CEA /* Resources */ = { isa = PBXGroup; children = ( + 208B66451AA7CC16008D37B5 /* data */, FD77A07E0E26BDA900F39101 /* Default.png */, FD77A07C0E26BD8C00F39101 /* Icon.png */, 8D1107310486CEB800E47090 /* Info.plist */, @@ -545,9 +446,6 @@ 1D60588D0D05DD3D006BFB54 /* Resources */, 1D60588E0D05DD3D006BFB54 /* Sources */, 1D60588F0D05DD3D006BFB54 /* Frameworks */, - 20517CBD1A9B411300DE49E9 /* Copy Models */, - 20517CBE1A9B411300DE49E9 /* Copy Shaders */, - 208B64351AA6B8EB008D37B5 /* Copy Textures */, ); buildRules = ( ); @@ -589,13 +487,7 @@ files = ( FD77A07D0E26BD8C00F39101 /* Icon.png in Resources */, FD77A07F0E26BDA900F39101 /* Default.png in Resources */, - 205723E11A9B4053001400FA /* chest.obj in Resources */, - 20517D161A9B449200DE49E9 /* default_fs.100.glsl in Resources */, - 20517D171A9B449200DE49E9 /* default_vs.100.glsl in Resources */, - 20517D181A9B449200DE49E9 /* fb_fs.100.glsl in Resources */, - 20517D191A9B449200DE49E9 /* fb_vs.100.glsl in Resources */, - 205183891A9DE71F00DE49E9 /* cube.obj in Resources */, - 208B64331AA6B8C4008D37B5 /* cube.png in Resources */, + 208B66461AA7CC16008D37B5 /* data in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/build/osx/Roll them Bones.xcodeproj/project.pbxproj b/build/osx/Roll them Bones.xcodeproj/project.pbxproj index 3720d3d..d03c69f 100644 --- a/build/osx/Roll them Bones.xcodeproj/project.pbxproj +++ b/build/osx/Roll them Bones.xcodeproj/project.pbxproj @@ -12,27 +12,19 @@ 20517D531A9BFB1B00DE49E9 /* fio.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 20517D511A9BFB1B00DE49E9 /* fio.cpp */; }; 20517D601A9C083B00DE49E9 /* checksum.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 20517D5E1A9C083B00DE49E9 /* checksum.cpp */; }; 20517DCE1A9D44DB00DE49E9 /* Core.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 20517DCC1A9D44DB00DE49E9 /* Core.cpp */; }; - 205182A81A9DD62C00DE49E9 /* cube.obj in Resources */ = {isa = PBXBuildFile; fileRef = 205182A71A9DD62C00DE49E9 /* cube.obj */; }; - 205182C01A9DD63E00DE49E9 /* cube.obj in Copy Models */ = {isa = PBXBuildFile; fileRef = 205182A71A9DD62C00DE49E9 /* cube.obj */; }; 205183C71A9F324700DE49E9 /* AssetManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 205183C51A9F324600DE49E9 /* AssetManager.cpp */; }; 205183CC1A9F330000DE49E9 /* Asset.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 205183CA1A9F330000DE49E9 /* Asset.cpp */; }; 2056AE3C1A8A421500833760 /* Mat4.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2056AE361A8A421500833760 /* Mat4.cpp */; }; 2056AE3D1A8A421500833760 /* RenderObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2056AE381A8A421500833760 /* RenderObject.cpp */; }; 2056AE3E1A8A421500833760 /* Vec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2056AE3A1A8A421500833760 /* Vec.cpp */; }; - 205723781A9B3EA3001400FA /* chest.obj in Resources */ = {isa = PBXBuildFile; fileRef = 205723771A9B3EA3001400FA /* chest.obj */; }; - 2057237B1A9B3EB2001400FA /* default_fs.glsl in Resources */ = {isa = PBXBuildFile; fileRef = 205723791A9B3EB2001400FA /* default_fs.glsl */; }; - 2057237C1A9B3EB2001400FA /* default_vs.glsl in Resources */ = {isa = PBXBuildFile; fileRef = 2057237A1A9B3EB2001400FA /* default_vs.glsl */; }; - 205723911A9B3ECF001400FA /* default_fs.glsl in Copy Shaders */ = {isa = PBXBuildFile; fileRef = 205723791A9B3EB2001400FA /* default_fs.glsl */; }; - 205723921A9B3ECF001400FA /* default_vs.glsl in Copy Shaders */ = {isa = PBXBuildFile; fileRef = 2057237A1A9B3EB2001400FA /* default_vs.glsl */; }; - 205723931A9B3ED3001400FA /* chest.obj in Copy Models */ = {isa = PBXBuildFile; fileRef = 205723771A9B3EA3001400FA /* chest.obj */; }; 205723A11A9B3F04001400FA /* Quat.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2057239F1A9B3F04001400FA /* Quat.cpp */; }; 205D36CE1A6749FB00C05BD8 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 205D36CD1A6749FB00C05BD8 /* main.cpp */; }; 205D370C1A674B1D00C05BD8 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 205D370B1A674B1D00C05BD8 /* OpenGL.framework */; }; - 206662951A9305FF00631FC0 /* fb_fs.glsl in Copy Shaders */ = {isa = PBXBuildFile; fileRef = 209930A31A92CAB10089E661 /* fb_fs.glsl */; }; - 206662961A9305FF00631FC0 /* fb_vs.glsl in Copy Shaders */ = {isa = PBXBuildFile; fileRef = 209930A41A92CAB10089E661 /* fb_vs.glsl */; }; + 206884021AA8FDAD0020756D /* GuiButton.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 206884001AA8FDAD0020756D /* GuiButton.cpp */; }; + 206884601AA9023A0020756D /* GuiList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2068845E1AA9023A0020756D /* GuiList.cpp */; }; + 206885591AA92C9A0020756D /* SysInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 206885571AA92C9A0020756D /* SysInfo.cpp */; }; 208B63C51AA6A8B2008D37B5 /* Texture.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 208B63C31AA6A8B2008D37B5 /* Texture.cpp */; }; - 208B63F21AA6B2F6008D37B5 /* cube.png in Resources */ = {isa = PBXBuildFile; fileRef = 208B63F11AA6B2F6008D37B5 /* cube.png */; }; - 208B63FB1AA6B32E008D37B5 /* cube.png in Copy Textures */ = {isa = PBXBuildFile; fileRef = 208B63F11AA6B2F6008D37B5 /* cube.png */; }; + 208B66321AA7CBA0008D37B5 /* data in Resources */ = {isa = PBXBuildFile; fileRef = 208B66161AA7CBA0008D37B5 /* data */; }; 209930831A92ADB00089E661 /* Program.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 209930811A92ADB00089E661 /* Program.cpp */; }; 20A7A8D51A89E11200EDC1A0 /* RenderScene.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 20A7A8D11A89E11200EDC1A0 /* RenderScene.cpp */; }; 20A7A8D61A89E11200EDC1A0 /* RenderSet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 20A7A8D31A89E11200EDC1A0 /* RenderSet.cpp */; }; @@ -48,46 +40,6 @@ 8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; }; /* End PBXBuildFile section */ -/* Begin PBXCopyFilesBuildPhase section */ - 204FF23E1A93F28B0006E1F0 /* Copy Models */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = data/models; - dstSubfolderSpec = 7; - files = ( - 205182C01A9DD63E00DE49E9 /* cube.obj in Copy Models */, - 205723931A9B3ED3001400FA /* chest.obj in Copy Models */, - ); - name = "Copy Models"; - runOnlyForDeploymentPostprocessing = 0; - }; - 208B64081AA6B343008D37B5 /* Copy Textures */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = data/textures; - dstSubfolderSpec = 7; - files = ( - 208B63FB1AA6B32E008D37B5 /* cube.png in Copy Textures */, - ); - name = "Copy Textures"; - runOnlyForDeploymentPostprocessing = 0; - }; - 209930BA1A92CB1C0089E661 /* Copy Shaders */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = data/shaders; - dstSubfolderSpec = 7; - files = ( - 205723911A9B3ECF001400FA /* default_fs.glsl in Copy Shaders */, - 205723921A9B3ECF001400FA /* default_vs.glsl in Copy Shaders */, - 206662951A9305FF00631FC0 /* fb_fs.glsl in Copy Shaders */, - 206662961A9305FF00631FC0 /* fb_vs.glsl in Copy Shaders */, - ); - name = "Copy Shaders"; - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXCopyFilesBuildPhase section */ - /* Begin PBXFileReference section */ 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = ""; }; 20020C6F1A8A01EE00F985D8 /* common.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = common.hpp; path = ../../src/common.hpp; sourceTree = SOURCE_ROOT; }; @@ -99,7 +51,6 @@ 20517D5F1A9C083B00DE49E9 /* checksum.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = checksum.hpp; path = ../../src/checksum.hpp; sourceTree = SOURCE_ROOT; }; 20517DCC1A9D44DB00DE49E9 /* Core.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Core.cpp; path = ../../src/Core.cpp; sourceTree = SOURCE_ROOT; }; 20517DCD1A9D44DB00DE49E9 /* Core.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = Core.hpp; path = ../../src/Core.hpp; sourceTree = SOURCE_ROOT; }; - 205182A71A9DD62C00DE49E9 /* cube.obj */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = cube.obj; path = models/cube.obj; sourceTree = ""; }; 205183C51A9F324600DE49E9 /* AssetManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = AssetManager.cpp; path = ../../src/AssetManager.cpp; sourceTree = SOURCE_ROOT; }; 205183C61A9F324600DE49E9 /* AssetManager.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = AssetManager.hpp; path = ../../src/AssetManager.hpp; sourceTree = SOURCE_ROOT; }; 205183CA1A9F330000DE49E9 /* Asset.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Asset.cpp; path = ../../src/Asset.cpp; sourceTree = SOURCE_ROOT; }; @@ -110,20 +61,21 @@ 2056AE391A8A421500833760 /* RenderObject.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = RenderObject.hpp; path = ../../src/RenderObject.hpp; sourceTree = SOURCE_ROOT; }; 2056AE3A1A8A421500833760 /* Vec.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Vec.cpp; path = ../../src/Vec.cpp; sourceTree = SOURCE_ROOT; }; 2056AE3B1A8A421500833760 /* Vec.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = Vec.hpp; path = ../../src/Vec.hpp; sourceTree = SOURCE_ROOT; }; - 205723771A9B3EA3001400FA /* chest.obj */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = chest.obj; path = models/chest.obj; sourceTree = ""; }; - 205723791A9B3EB2001400FA /* default_fs.glsl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = default_fs.glsl; sourceTree = ""; }; - 2057237A1A9B3EB2001400FA /* default_vs.glsl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = default_vs.glsl; sourceTree = ""; }; 2057239F1A9B3F04001400FA /* Quat.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Quat.cpp; path = ../../src/Quat.cpp; sourceTree = SOURCE_ROOT; }; 205723A01A9B3F04001400FA /* Quat.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = Quat.hpp; path = ../../src/Quat.hpp; sourceTree = SOURCE_ROOT; }; 205D36CD1A6749FB00C05BD8 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = main.cpp; path = ../../src/main.cpp; sourceTree = SOURCE_ROOT; }; 205D370B1A674B1D00C05BD8 /* OpenGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGL.framework; path = /System/Library/Frameworks/OpenGL.framework; sourceTree = ""; }; + 206884001AA8FDAD0020756D /* GuiButton.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = GuiButton.cpp; path = ../../src/gui/GuiButton.cpp; sourceTree = SOURCE_ROOT; }; + 206884011AA8FDAD0020756D /* GuiButton.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = GuiButton.hpp; path = ../../src/gui/GuiButton.hpp; sourceTree = SOURCE_ROOT; }; + 2068845E1AA9023A0020756D /* GuiList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = GuiList.cpp; path = ../../src/gui/GuiList.cpp; sourceTree = SOURCE_ROOT; }; + 2068845F1AA9023A0020756D /* GuiList.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = GuiList.hpp; path = ../../src/gui/GuiList.hpp; sourceTree = SOURCE_ROOT; }; + 206885571AA92C9A0020756D /* SysInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SysInfo.cpp; path = ../../src/SysInfo.cpp; sourceTree = SOURCE_ROOT; }; + 206885581AA92C9A0020756D /* SysInfo.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = SysInfo.hpp; path = ../../src/SysInfo.hpp; sourceTree = SOURCE_ROOT; }; 208B63C31AA6A8B2008D37B5 /* Texture.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Texture.cpp; path = ../../src/Texture.cpp; sourceTree = SOURCE_ROOT; }; 208B63C41AA6A8B2008D37B5 /* Texture.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = Texture.hpp; path = ../../src/Texture.hpp; sourceTree = SOURCE_ROOT; }; - 208B63F11AA6B2F6008D37B5 /* cube.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = cube.png; path = textures/cube.png; sourceTree = ""; }; + 208B66161AA7CBA0008D37B5 /* data */ = {isa = PBXFileReference; lastKnownFileType = folder; name = data; path = ../../data; sourceTree = SOURCE_ROOT; }; 209930811A92ADB00089E661 /* Program.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Program.cpp; path = ../../src/Program.cpp; sourceTree = SOURCE_ROOT; }; 209930821A92ADB00089E661 /* Program.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = Program.hpp; path = ../../src/Program.hpp; sourceTree = SOURCE_ROOT; }; - 209930A31A92CAB10089E661 /* fb_fs.glsl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = fb_fs.glsl; sourceTree = ""; }; - 209930A41A92CAB10089E661 /* fb_vs.glsl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = fb_vs.glsl; sourceTree = ""; }; 20A7A8D11A89E11200EDC1A0 /* RenderScene.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RenderScene.cpp; path = ../../src/RenderScene.cpp; sourceTree = SOURCE_ROOT; }; 20A7A8D21A89E11200EDC1A0 /* RenderScene.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = RenderScene.hpp; path = ../../src/RenderScene.hpp; sourceTree = SOURCE_ROOT; }; 20A7A8D31A89E11200EDC1A0 /* RenderSet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RenderSet.cpp; path = ../../src/RenderSet.cpp; sourceTree = SOURCE_ROOT; }; @@ -168,6 +120,8 @@ 080E96DDFE201D6D7F000001 /* Classes */ = { isa = PBXGroup; children = ( + 206885571AA92C9A0020756D /* SysInfo.cpp */, + 206885581AA92C9A0020756D /* SysInfo.hpp */, 208B63C31AA6A8B2008D37B5 /* Texture.cpp */, 208B63C41AA6A8B2008D37B5 /* Texture.hpp */, 20FC42861AA5BFF50083B64C /* Gui */, @@ -239,15 +193,6 @@ name = Products; sourceTree = ""; }; - 205723721A9B3E90001400FA /* models */ = { - isa = PBXGroup; - children = ( - 205182A71A9DD62C00DE49E9 /* cube.obj */, - 205723771A9B3EA3001400FA /* chest.obj */, - ); - name = models; - sourceTree = ""; - }; 205D36C31A6749DF00C05BD8 /* Sources */ = { isa = PBXGroup; children = ( @@ -264,36 +209,6 @@ usesTabs = 0; wrapsLines = 1; }; - 208B63F01AA6B2ED008D37B5 /* textures */ = { - isa = PBXGroup; - children = ( - 208B63F11AA6B2F6008D37B5 /* cube.png */, - ); - name = textures; - sourceTree = ""; - }; - 2099309F1A92CAB10089E661 /* data */ = { - isa = PBXGroup; - children = ( - 208B63F01AA6B2ED008D37B5 /* textures */, - 205723721A9B3E90001400FA /* models */, - 209930A01A92CAB10089E661 /* shaders */, - ); - name = data; - path = ../../data; - sourceTree = SOURCE_ROOT; - }; - 209930A01A92CAB10089E661 /* shaders */ = { - isa = PBXGroup; - children = ( - 205723791A9B3EB2001400FA /* default_fs.glsl */, - 2057237A1A9B3EB2001400FA /* default_vs.glsl */, - 209930A31A92CAB10089E661 /* fb_fs.glsl */, - 209930A41A92CAB10089E661 /* fb_vs.glsl */, - ); - path = shaders; - sourceTree = ""; - }; 20FC41ED1AA45D650083B64C /* States */ = { isa = PBXGroup; children = ( @@ -308,6 +223,10 @@ 20FC42861AA5BFF50083B64C /* Gui */ = { isa = PBXGroup; children = ( + 2068845E1AA9023A0020756D /* GuiList.cpp */, + 2068845F1AA9023A0020756D /* GuiList.hpp */, + 206884001AA8FDAD0020756D /* GuiButton.cpp */, + 206884011AA8FDAD0020756D /* GuiButton.hpp */, 20FC42871AA5C00A0083B64C /* GuiElement.cpp */, 20FC42881AA5C00A0083B64C /* GuiElement.hpp */, ); @@ -317,7 +236,6 @@ 29B97314FDCFA39411CA2CEA /* INDIE */ = { isa = PBXGroup; children = ( - 2099309F1A92CAB10089E661 /* data */, 205D36C31A6749DF00C05BD8 /* Sources */, 080E96DDFE201D6D7F000001 /* Classes */, 29B97315FDCFA39411CA2CEA /* Other Sources */, @@ -342,6 +260,7 @@ 29B97317FDCFA39411CA2CEA /* Resources */ = { isa = PBXGroup; children = ( + 208B66161AA7CBA0008D37B5 /* data */, ); name = Resources; sourceTree = ""; @@ -365,9 +284,6 @@ 8D1107290486CEB800E47090 /* Resources */, 8D11072C0486CEB800E47090 /* Sources */, 8D11072E0486CEB800E47090 /* Frameworks */, - 209930BA1A92CB1C0089E661 /* Copy Shaders */, - 204FF23E1A93F28B0006E1F0 /* Copy Models */, - 208B64081AA6B343008D37B5 /* Copy Textures */, ); buildRules = ( ); @@ -411,11 +327,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - 205723781A9B3EA3001400FA /* chest.obj in Resources */, - 2057237B1A9B3EB2001400FA /* default_fs.glsl in Resources */, - 2057237C1A9B3EB2001400FA /* default_vs.glsl in Resources */, - 205182A81A9DD62C00DE49E9 /* cube.obj in Resources */, - 208B63F21AA6B2F6008D37B5 /* cube.png in Resources */, + 208B66321AA7CBA0008D37B5 /* data in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -449,6 +361,9 @@ 20FC42651AA587F10083B64C /* Gui.cpp in Sources */, 20FC42891AA5C00A0083B64C /* GuiElement.cpp in Sources */, 208B63C51AA6A8B2008D37B5 /* Texture.cpp in Sources */, + 206884021AA8FDAD0020756D /* GuiButton.cpp in Sources */, + 206884601AA9023A0020756D /* GuiList.cpp in Sources */, + 206885591AA92C9A0020756D /* SysInfo.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -509,6 +424,7 @@ ONLY_ACTIVE_ARCH = YES; PREBINDING = NO; SDKROOT = ""; + USER_HEADER_SEARCH_PATHS = "../../src/**"; }; name = Debug; }; diff --git a/data/models/null.obj b/data/models/null.obj new file mode 100644 index 0000000..a14594f --- /dev/null +++ b/data/models/null.obj @@ -0,0 +1,213 @@ +# Blender v2.72 (sub 0) OBJ File: '' +# www.blender.org +o Cube +v -0.248228 0.552063 -1.812306 +v -0.248228 0.552063 -2.312306 +v 0.251772 0.552063 -2.312306 +v 0.251772 0.552063 -1.812306 +v -0.248228 1.052063 -1.812306 +v -0.248228 1.052063 -2.312306 +v 0.251772 1.052063 -2.312306 +v 0.251772 1.052063 -1.812306 +v 0.250000 1.053831 -1.605233 +v 0.250000 0.553831 -1.605233 +v -0.250000 0.553831 -1.605233 +v -0.250000 1.053831 -1.605233 +v 0.250000 1.053831 -0.597948 +v 0.250000 0.553831 -0.597948 +v -0.250000 0.553831 -0.597948 +v -0.250000 1.053831 -0.597948 +v -0.054597 1.053831 -0.110633 +v -0.054597 0.553831 -0.110633 +v -0.554597 0.553831 -0.110633 +v -0.554597 1.053831 -0.110633 +v -0.366389 1.053831 0.162388 +v -0.366390 0.553831 0.162388 +v -0.866390 0.553831 0.294664 +v -0.866389 1.053831 0.294664 +v -0.366389 1.053831 0.945808 +v -0.366390 0.553831 0.945808 +v -0.866390 0.553831 0.945808 +v -0.866389 1.053831 0.945808 +v -0.096027 1.053831 1.274053 +v -0.096027 0.553831 1.274053 +v -0.596027 0.553831 1.274053 +v -0.596027 1.053831 1.274053 +v 0.608858 1.053831 1.082715 +v 0.608857 0.553831 1.082715 +v -0.035833 0.553831 1.601242 +v -0.035833 1.053831 1.601242 +vt 0.802095 0.859859 +vt 0.802095 0.719718 +vt 0.942881 0.719718 +vt 0.922054 0.215919 +vt 0.922054 0.356060 +vt 0.780491 0.356060 +vt 0.517866 0.927775 +vt 0.517866 0.787634 +vt 0.658651 0.787634 +vt 0.979158 0.470702 +vt 0.979158 0.610843 +vt 0.841979 0.610843 +vt 0.142115 0.877665 +vt 0.000000 0.877665 +vt 0.000000 0.737524 +vt 0.142115 0.730638 +vt 0.284230 0.730638 +vt 0.284230 0.870779 +vt 0.375751 0.740260 +vt 0.517314 0.740260 +vt 0.517314 0.880401 +vt 0.659980 0.719718 +vt 0.802095 0.866676 +vt 0.142115 0.562007 +vt 0.000000 0.562007 +vt 0.000000 0.282324 +vt 0.142115 0.000000 +vt 0.284230 0.000000 +vt 0.284230 0.282324 +vt 0.284230 0.562007 +vt 0.142115 0.282324 +vt 0.000000 0.000000 +vt 1.000000 0.000000 +vt 1.000000 0.140141 +vt 0.873788 0.140141 +vt 0.780491 0.235351 +vt 0.780491 0.396423 +vt 0.659980 0.470702 +vt 0.659980 0.161072 +vt 0.659980 0.000000 +vt 0.659980 0.640676 +vt 0.659980 0.787634 +vt 0.517866 0.559464 +vt 0.517866 0.740260 +vt 0.696327 0.470702 +vt 0.748682 0.574756 +vt 0.748682 0.719718 +vt 0.320576 0.590955 +vt 0.284230 0.455475 +vt 0.372931 0.341939 +vt 0.373197 0.731096 +vt 0.284230 0.731096 +vt 0.284230 0.590955 +vt 0.900645 1.000000 +vt 0.802095 1.000000 +vt 0.659980 0.219578 +vt 0.659980 0.439157 +vt 0.517866 0.439157 +vt 0.517866 0.182504 +vt 0.517866 0.000000 +vt 0.375751 0.341939 +vt 0.517866 0.341939 +vt 0.873788 0.000000 +vt 0.780491 0.215919 +vt 0.841979 0.686621 +vt 0.748682 0.610843 +vt 0.748682 0.470702 +vt 0.366168 0.731096 +vt 0.366168 0.871237 +vt 0.284230 0.871237 +vt 0.401048 0.000000 +vt 0.378759 0.138407 +vt 0.401048 0.341939 +vt 0.401048 0.201253 +vt 0.942881 0.859859 +vt 0.658651 0.927775 +vt 0.841979 0.470702 +vt 0.142115 0.737524 +vt 0.142115 0.870779 +vt 0.375751 0.880401 +vt 0.659981 0.866676 +vt 0.659980 0.309630 +vt 0.780491 0.074279 +vt 0.517866 0.640676 +vt 0.375751 0.559464 +vt 0.659980 0.606182 +vt 0.372931 0.486901 +vt 0.373197 0.590955 +vt 0.900645 0.859859 +vt 0.517866 0.256653 +vt 0.780491 0.075778 +vt 0.841978 0.546480 +vt 0.284230 0.140686 +vt 0.495577 0.203532 +vn -1.000000 0.000000 0.000000 +vn 0.000000 0.000000 -1.000000 +vn 1.000000 0.000000 0.000000 +vn 0.000000 0.000000 1.000000 +vn 0.000000 -1.000000 0.000000 +vn 0.000000 1.000000 0.000000 +vn -0.848000 0.000000 -0.530000 +vn -0.792600 0.000000 -0.609700 +vn 0.848000 -0.000000 0.530000 +vn 0.658800 -0.000000 0.752300 +vn -0.771900 0.000000 0.635800 +vn -0.504300 0.000000 0.863500 +vn 0.771900 -0.000000 -0.635800 +vn 0.626700 -0.000000 0.779200 +vn -0.262000 0.000000 -0.965100 +s off +f 6/1/1 2/2/1 1/3/1 +f 7/4/2 3/5/2 2/6/2 +f 8/7/3 4/8/3 3/9/3 +f 5/10/4 1/11/4 4/12/4 +f 2/13/5 3/14/5 4/15/5 +f 7/16/6 6/17/6 5/18/6 +f 10/19/2 11/20/2 12/21/2 +f 16/22/7 15/2/7 19/23/7 +f 13/24/3 14/25/3 10/26/3 +f 14/27/5 15/28/5 11/29/5 +f 15/30/1 16/24/1 12/31/1 +f 9/31/6 12/26/6 16/32/6 +f 20/33/8 19/34/8 23/35/8 +f 14/36/5 18/37/5 19/38/5 +f 13/36/6 16/39/6 20/40/6 +f 13/41/9 17/42/9 18/8/9 +f 23/43/1 27/44/1 28/19/1 +f 18/45/5 22/46/5 23/47/5 +f 17/48/6 20/49/6 24/50/6 +f 17/51/10 21/52/10 22/53/10 +f 27/54/11 31/55/11 32/1/11 +f 22/56/5 26/57/5 27/58/5 +f 21/56/6 24/59/6 28/60/6 +f 22/61/3 21/62/3 25/43/3 +f 31/15/12 35/25/12 36/24/12 +f 27/63/5 26/35/5 30/64/5 +f 28/65/6 32/66/6 29/67/6 +f 26/68/13 25/69/13 29/70/13 +f 36/17/14 35/16/14 34/24/14 +f 31/71/6 30/72/6 34/73/6 +f 32/62/6 36/74/6 33/60/6 +f 30/58/15 29/57/15 33/41/15 +f 5/75/1 6/1/1 1/3/1 +f 6/64/2 7/4/2 2/6/2 +f 7/76/3 8/7/3 3/9/3 +f 8/77/4 5/10/4 4/12/4 +f 1/78/5 2/13/5 4/15/5 +f 8/79/6 7/16/6 5/18/6 +f 9/80/2 10/19/2 12/21/2 +f 20/81/7 16/22/7 19/23/7 +f 9/31/3 13/24/3 10/26/3 +f 10/31/5 14/27/5 11/29/5 +f 11/29/1 15/30/1 12/31/1 +f 13/27/6 9/31/6 16/32/6 +f 24/63/8 20/33/8 23/35/8 +f 15/82/5 14/36/5 19/38/5 +f 17/83/6 13/36/6 20/40/6 +f 14/84/9 13/41/9 18/8/9 +f 24/85/1 23/43/1 28/19/1 +f 19/86/5 18/45/5 23/47/5 +f 21/87/6 17/48/6 24/50/6 +f 18/88/10 17/51/10 22/53/10 +f 28/89/11 27/54/11 32/1/11 +f 23/90/5 22/56/5 27/58/5 +f 25/40/6 21/56/6 28/60/6 +f 26/85/3 22/61/3 25/43/3 +f 32/78/12 31/15/12 36/24/12 +f 31/91/5 27/63/5 30/64/5 +f 25/92/6 28/65/6 29/67/6 +f 30/52/13 26/68/13 29/70/13 +f 33/30/14 36/17/14 34/24/14 +f 35/93/5 31/71/5 34/73/5 +f 29/94/5 32/62/5 33/60/5 +f 34/84/15 30/58/15 33/41/15 diff --git a/data/models/plane.obj b/data/models/plane.obj new file mode 100644 index 0000000..2622cb3 --- /dev/null +++ b/data/models/plane.obj @@ -0,0 +1,15 @@ +# Blender v2.72 (sub 0) OBJ File: '' +# www.blender.org +o Plane +v -1.000000 -0.000000 -1.000000 +v 1.000000 -0.000000 -1.000000 +v -1.000000 0.000000 1.000000 +v 1.000000 0.000000 1.000000 +vt 1.000000 0.000000 +vt 1.000000 1.000000 +vt 0.000000 1.000000 +vt 0.000000 0.000000 +vn 0.000000 -1.000000 0.000000 +s off +f 2/1/1 4/2/1 3/3/1 +f 1/4/1 2/1/1 3/3/1 diff --git a/data/shaders/100/default_fs.glsl b/data/shaders/100/default_fs.glsl index 84293b1..4ac8df5 100644 --- a/data/shaders/100/default_fs.glsl +++ b/data/shaders/100/default_fs.glsl @@ -4,8 +4,13 @@ precision mediump float; uniform sampler2D texture_sampler; // in varying vec2 frag_uv; +varying vec3 frag_normal; void main() { - gl_FragColor = texture2D(texture_sampler, frag_uv); + if (frag_normal.x > 0.0 || frag_normal.z < 0.0 || frag_normal.y < 0.0) { + gl_FragColor = texture2D(texture_sampler, frag_uv) * vec4(0.85, 0.85, 0.85, 1.0); + } else { + gl_FragColor = texture2D(texture_sampler, frag_uv); + } //gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); } diff --git a/data/shaders/100/default_vs.glsl b/data/shaders/100/default_vs.glsl index 2ba9af1..d7ea444 100644 --- a/data/shaders/100/default_vs.glsl +++ b/data/shaders/100/default_vs.glsl @@ -8,10 +8,12 @@ attribute vec2 uv; attribute vec3 normal; // out varying vec2 frag_uv; +varying vec3 frag_normal; void main() { vec4 eye = mv_matrix * vec4(vp, 1.0); gl_Position = proj_matrix * eye; // 1.0 - uv.t = flipped texture frag_uv = vec2(uv.s, 1.0 - uv.t); + frag_normal = normal; } diff --git a/data/shaders/100/gui_fs.glsl b/data/shaders/100/gui_fs.glsl new file mode 100644 index 0000000..28b46e7 --- /dev/null +++ b/data/shaders/100/gui_fs.glsl @@ -0,0 +1,11 @@ +#version 100 +precision mediump float; +// uniform data +uniform sampler2D texture_sampler; +// in +varying vec2 frag_uv; +varying vec3 frag_normal; + +void main() { + gl_FragColor = texture2D(texture_sampler, frag_uv); +} diff --git a/data/shaders/100/gui_vs.glsl b/data/shaders/100/gui_vs.glsl new file mode 100644 index 0000000..d7ea444 --- /dev/null +++ b/data/shaders/100/gui_vs.glsl @@ -0,0 +1,19 @@ +#version 100 +// shared data +// our projection and translation matrices +uniform mat4 proj_matrix, mv_matrix; +// attributes +attribute vec3 vp; +attribute vec2 uv; +attribute vec3 normal; +// out +varying vec2 frag_uv; +varying vec3 frag_normal; + +void main() { + vec4 eye = mv_matrix * vec4(vp, 1.0); + gl_Position = proj_matrix * eye; + // 1.0 - uv.t = flipped texture + frag_uv = vec2(uv.s, 1.0 - uv.t); + frag_normal = normal; +} diff --git a/data/shaders/120/default_fs.glsl b/data/shaders/120/default_fs.glsl index 0836768..e763c59 100644 --- a/data/shaders/120/default_fs.glsl +++ b/data/shaders/120/default_fs.glsl @@ -3,8 +3,13 @@ uniform sampler2D texture_sampler; // in varying vec2 frag_uv; +varying vec3 frag_normal; void main() { - gl_FragColor = texture2D(texture_sampler, frag_uv); + if (frag_normal.x > 0.0 || frag_normal.z < 0.0 || frag_normal.y < 0.0) { + gl_FragColor = texture2D(texture_sampler, frag_uv) * vec4(0.85, 0.85, 0.85, 1.0); + } else { + gl_FragColor = texture2D(texture_sampler, frag_uv); + } //gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); } diff --git a/data/shaders/120/default_vs.glsl b/data/shaders/120/default_vs.glsl index ffb8620..525e93b 100644 --- a/data/shaders/120/default_vs.glsl +++ b/data/shaders/120/default_vs.glsl @@ -8,10 +8,12 @@ attribute vec2 uv; attribute vec3 normal; // out varying vec2 frag_uv; +varying vec3 frag_normal; void main() { vec4 eye = mv_matrix * vec4(vp, 1.0); gl_Position = proj_matrix * eye; // 1.0 - uv.t = flipped texture frag_uv = vec2(uv.s, 1.0 - uv.t); + frag_normal = normal; } diff --git a/data/shaders/120/gui_fs.glsl b/data/shaders/120/gui_fs.glsl new file mode 100644 index 0000000..8364fe2 --- /dev/null +++ b/data/shaders/120/gui_fs.glsl @@ -0,0 +1,10 @@ +#version 120 +// uniform data +uniform sampler2D texture_sampler; +// in +varying vec2 frag_uv; +varying vec3 frag_normal; + +void main() { + gl_FragColor = texture2D(texture_sampler, frag_uv); +} diff --git a/data/shaders/120/gui_vs.glsl b/data/shaders/120/gui_vs.glsl new file mode 100644 index 0000000..525e93b --- /dev/null +++ b/data/shaders/120/gui_vs.glsl @@ -0,0 +1,19 @@ +#version 120 +// shared data +// our projection and translation matrices +uniform mat4 proj_matrix, mv_matrix; +// attributes +attribute vec3 vp; +attribute vec2 uv; +attribute vec3 normal; +// out +varying vec2 frag_uv; +varying vec3 frag_normal; + +void main() { + vec4 eye = mv_matrix * vec4(vp, 1.0); + gl_Position = proj_matrix * eye; + // 1.0 - uv.t = flipped texture + frag_uv = vec2(uv.s, 1.0 - uv.t); + frag_normal = normal; +} diff --git a/data/textures/cube.png b/data/textures/cube.png index f70694c..882088b 100644 Binary files a/data/textures/cube.png and b/data/textures/cube.png differ diff --git a/data/textures/null.png b/data/textures/null.png new file mode 100644 index 0000000..b090b9e Binary files /dev/null and b/data/textures/null.png differ diff --git a/data/ui/icon_isocube.png b/data/ui/icon_isocube.png new file mode 100644 index 0000000..fc90940 Binary files /dev/null and b/data/ui/icon_isocube.png differ diff --git a/data/ui/icon_perscube.png b/data/ui/icon_perscube.png new file mode 100644 index 0000000..eba9f42 Binary files /dev/null and b/data/ui/icon_perscube.png differ diff --git a/data/ui/icon_token.png b/data/ui/icon_token.png new file mode 100644 index 0000000..ed54809 Binary files /dev/null and b/data/ui/icon_token.png differ diff --git a/src/Core.cpp b/src/Core.cpp index c40b812..c41ee32 100644 --- a/src/Core.cpp +++ b/src/Core.cpp @@ -12,7 +12,6 @@ Core is somewhat like a service locator, but with larger engine capabilities - i #include "TestState.hpp" // includes for getting "user" directory #if defined(__APPLE__) && !defined(__IPHONEOS__) -#include #include #include #include @@ -23,6 +22,7 @@ Core is somewhat like a service locator, but with larger engine capabilities - i #include #include #endif +#include "SysInfo.hpp" Core core; @@ -126,9 +126,9 @@ int Core::initSystem() { // Load the built-in RO ApkAssetCache directory first asset_manager->addCache(new ApkAssetCache("data")); // Load in the application's RW location on the install location - asset_manager->addCache(new AssetCache(android_app_dir.c_str())); + asset_manager->addCache(new AssetCache(sysinfo.app_dir.c_str())); // Load in the application's RW external location - asset_manager->addCache(new AssetCache(android_ext_dir.c_str())); + asset_manager->addCache(new AssetCache(sysinfo.ext_dir.c_str())); #elif __IPHONEOS__ // Use the built-in resources directory (read-only) asset_manager->addCache(new AssetCache("data")); @@ -136,13 +136,7 @@ int Core::initSystem() { asset_manager->addCache(new AssetCache("../Documents")); #elif __APPLE__ asset_manager->addCache(new AssetCache("data")); - FSRef ref; - OSType folderType = kApplicationSupportFolderType; - char path[PATH_MAX]; - FSFindFolder(kUserDomain, folderType, kCreateFolder, &ref); - FSRefMakePath(&ref, (UInt8*)&path, PATH_MAX); - char user_dir[PATH_MAX]; - snprintf(user_dir, PATH_MAX, "%s/RtB", path); + char *user_dir = (char*)sysinfo.user_dir.c_str(); struct stat dir_check = {0}; if (stat(user_dir, &dir_check) == -1) { mkdir(user_dir, 0700); diff --git a/src/Gui.cpp b/src/Gui.cpp index e661235..7b000d6 100644 --- a/src/Gui.cpp +++ b/src/Gui.cpp @@ -17,7 +17,7 @@ Gui::Gui() { scene = new RenderScene(); camera = new RenderCamera(); camera->setRenderMode(1); // Use orthographic mode - camera->setPitch(270.0f); // look down + camera->setPitch(90.0f); // look down camera->setPosition(0, 0, 0); camera->setNear(-1.0f); camera->setFar(1.0f); @@ -27,12 +27,25 @@ Gui::Gui() { camera->updateProjection(w, h); // ensure our projection is good camera->doRefresh(); // aaand update scene->addCamera(camera); + // This is a strange thing - we use this camera for the rendering of all children. The children modify it to match their render dimensions (so that 1 unit == 1px) + child_camera = new RenderCamera(); + child_camera->setRenderMode(1); // Use orthographic mode + child_camera->setPitch(90.0f); // look down + child_camera->setPosition(0, 0, 0); + child_camera->setNear(-1.0f); + child_camera->setFar(1.0f); + child_camera->setRenderFlags(RenderCamera::CLEAR_DEPTH); // only clear the depth before rendering + child_camera->setRenderView(core.getWindowView()); // set the child_camera's render view to point to the main render view + child_camera->setSize(h*2); // set our vertical size to the height of the window - this means 1 unit will correspond to 1 pixel + child_camera->updateProjection(w, h); // ensure our projection is good + child_camera->doRefresh(); // aaand update + // asset_manager = core.getAssetManager(); // compile our GUI program std::string shader_file; Asset* shader_asset; - Program* program = new Program(); + program = new Program(); shader_file = "shaders/" + core.shader_version + "/gui_fs.glsl"; shader_asset = asset_manager->loadFile(shader_file.c_str()); @@ -84,20 +97,22 @@ int Gui::onEvent(SDL_Event event) { switch (event.type) { case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONUP: - x = float(event.button.x) / float(core.getWidth()); - y = float(event.button.y) / float(core.getHeight()); + x = float(event.button.x); + y = float(event.button.y); LOG(LOG_INFO) << FUNC_NAME << ": CHECK: " << x << "x" << y; for (element_it = elements.rbegin(), element_end = elements.rend(); element_it != element_end; ++element_it) { + if ((*element_it)->getFlags() & GuiElement::HIDDEN) continue; element = (*element_it)->getHit(x, y); if (element != NULL) break; } break; case SDL_FINGERDOWN: case SDL_FINGERUP: - x = event.tfinger.x; - y = event.tfinger.y; + x = event.tfinger.x * core.getWidth(); + y = event.tfinger.y * core.getHeight();; LOG(LOG_INFO) << FUNC_NAME << ": CHECK: " << x << "x" << y; for (element_it = elements.rbegin(), element_end = elements.rend(); element_it != element_end; ++element_it) { + if ((*element_it)->getFlags() & GuiElement::HIDDEN) continue; element = (*element_it)->getHit(x, y); if (element != NULL) break; } @@ -110,26 +125,30 @@ int Gui::onEvent(SDL_Event event) { } int Gui::addElement(GuiElement *element) { // - element->object = new RenderObject(); - Asset *asset = asset_manager->loadFile("ui/ui_token.png"); - Texture *texture = new Texture("ui/ui_token.png", asset->getData(), asset->getDataLength()); - texture->buildTexture(); - element->object->setMesh(element_mesh); - element->object->setTexture(texture); - set_basic->addObject(element->object); - // FIXME: calling this here for now - element->setGeometry(element->x, element->y, element->w, element->h); - - element->view = new RenderView(element->w, element->h); - - // Get the top-most (parent) element and only add that. + if (element->object == NULL && !(element->type & GuiElement::LIST)) { + element->object = new RenderObject(); + element->object->setMesh(element_mesh); + set_basic->addObject(element->object); + if (element->flags & GuiElement::HIDDEN) element->object->hide(); + // FIXME: calling this here for now + element->setGeometry(element->x, element->y, element->w, element->h); + } + //element->view = new RenderView(element->w, element->h); + // Add the children as well + std::vector::iterator element_it, element_end; + for (element_it = element->children.begin(), element_end = element->children.end(); element_it != element_end; ++element_it) { + addElement(*element_it); + } + /*// Get the top-most (parent) element and only add that. GuiElement *top_element = element->parent; while (top_element != NULL) { element = top_element; top_element = top_element->parent; + }*/ + if (element->parent == NULL) { + elements.push_back(element); + LOG(LOG_INFO) << FUNC_NAME << " added element " << element->text; } - elements.push_back(element); - LOG(LOG_INFO) << FUNC_NAME << " added element " << element->text; return elements.size()-1; } int Gui::setView(int width, int height) { @@ -142,35 +161,29 @@ int Gui::setView(int width, int height) { updateElements(); return 0; } +int Gui::getWidth() { + return w; +} +int Gui::getHeight() { + return h; +} +RenderCamera* Gui::getChildCamera() { + return child_camera; +} void Gui::updateElements() { std::vector::iterator element_it, element_end; GuiElement *p_element = NULL; GuiElement *c_element = NULL; for (element_it = elements.begin(), element_end = elements.end(); element_it != element_end; ++element_it) { p_element = *element_it; - float ex = p_element->x*2; - float ey = p_element->y*2; - float ew = p_element->w; - float eh = p_element->h; - if (p_element->pflags & GuiElement::TOP) { - ey = -h+ey-eh; - } else if (p_element->pflags & GuiElement::BOTTOM) { - ey = h-ey+eh; - } else if (p_element->pflags & GuiElement::VCENTER) { - ey = ey; - } - if (p_element->pflags & GuiElement::LEFT) { - ex = -w+ex-ew; - } else if (p_element->pflags & GuiElement::RIGHT) { - ex = w-ex+ew; - } else if (p_element->pflags & GuiElement::HCENTER) { - ex = ex; - } - p_element->object->setTranslation(ex, 0.0f, ey); - p_element->object->calcMatrix(); + if (p_element->getFlags() & GuiElement::HIDDEN) continue; + p_element->doUpdate(w, h); } } int Gui::doRender() { scene->doRender(); return 0; } +Program* Gui::getProgram() { + return program; +} diff --git a/src/Gui.hpp b/src/Gui.hpp index bd4bf39..21bed5c 100644 --- a/src/Gui.hpp +++ b/src/Gui.hpp @@ -18,6 +18,10 @@ class Gui { ~Gui(); int addElement(GuiElement *element); void updateElements(); + int getWidth(); + int getHeight(); + RenderCamera *getChildCamera(); + Program *getProgram(); protected: int onEvent(SDL_Event event); int doRender(); @@ -26,7 +30,9 @@ class Gui { // Scene/Camera RenderScene *scene; RenderCamera *camera; + RenderCamera *child_camera; // weird camera used by children for their rendering RenderSet *set_basic; + Program *program; private: std::vector elements; AssetManager *asset_manager; diff --git a/src/RenderObject.cpp b/src/RenderObject.cpp index b840632..1c3033a 100644 --- a/src/RenderObject.cpp +++ b/src/RenderObject.cpp @@ -18,6 +18,7 @@ RenderObject::RenderObject() { ); rotation = scale = translation; calcMatrix(); + flags = 0; } RenderObject::~RenderObject() { } @@ -44,3 +45,9 @@ void RenderObject::setScale(float x, float y, float z) { void RenderObject::calcMatrix() { model = translation * rotation * scale; } +void RenderObject::show() { + flags &= ~HIDDEN; +} +void RenderObject::hide() { + flags |= HIDDEN; +} diff --git a/src/RenderObject.hpp b/src/RenderObject.hpp index 3940d21..03914d9 100644 --- a/src/RenderObject.hpp +++ b/src/RenderObject.hpp @@ -17,6 +17,9 @@ class RenderObject { friend class RenderSet; friend class RenderScene; public: + enum Flags { + HIDDEN = (1 << 1) + }; RenderObject(); ~RenderObject(); void calcMatrix(); @@ -25,6 +28,10 @@ class RenderObject { void setScale(float x, float y, float z); void setMesh(Mesh *new_mesh); void setTexture(Texture *new_texture); + void show(); + void hide(); + protected: + int flags; private: Mesh *mesh; Texture *texture; diff --git a/src/RenderScene.cpp b/src/RenderScene.cpp index 08e6aa1..1ab258a 100644 --- a/src/RenderScene.cpp +++ b/src/RenderScene.cpp @@ -94,6 +94,7 @@ int RenderScene::doRender() { std::vector::iterator obj_it, obj_end; for (obj_it = set->objects.begin(), obj_end = set->objects.end(); obj_it != obj_end; ++obj_it) { object = *obj_it; + if (object->flags & RenderObject::HIDDEN) continue; Mat4 mv_matrix; // modelview matrix float mv[16]; // converted modelview to send to OpenGL Mesh *mesh; diff --git a/src/RenderView.cpp b/src/RenderView.cpp index be94e1e..3c9a501 100644 --- a/src/RenderView.cpp +++ b/src/RenderView.cpp @@ -43,6 +43,12 @@ Mesh *RenderView::getMesh() { Program* RenderView::getProgram() { return program; } +int RenderView::getWidth() { + return w; +} +int RenderView::getHeight() { + return h; +} /* ======== Setters ======== */ int RenderView::createView(int width, int height) { // TODO: call destroyView() and create new FBO at width and height diff --git a/src/RenderView.hpp b/src/RenderView.hpp index 2b3039a..1c734f6 100644 --- a/src/RenderView.hpp +++ b/src/RenderView.hpp @@ -27,6 +27,8 @@ class RenderView { int setProgram(Program *program); Program *getProgram(); int setView(int width, int height); + int getWidth(); + int getHeight(); protected: GLuint fbo; // The fbo that RenderScene will draw to private: diff --git a/src/SysInfo.cpp b/src/SysInfo.cpp new file mode 100644 index 0000000..d192ca6 --- /dev/null +++ b/src/SysInfo.cpp @@ -0,0 +1,50 @@ +#include "SysInfo.hpp" + +#if defined(__APPLE__) && !defined(__IPHONEOS__) +#include +#include +#include +#endif + + +SysInfo sysinfo; + +SysInfo::SysInfo() { + density_dpi = 0; + xdpi = 0.0f; + ydpi = 0.0f; + #if defined(__APPLE__) && !defined(__IPHONEOS__) + FSRef ref; + OSType folderType = kApplicationSupportFolderType; + char path[PATH_MAX]; + FSFindFolder(kUserDomain, folderType, kCreateFolder, &ref); + FSRefMakePath(&ref, (UInt8*)&path, PATH_MAX); + char path_dir[PATH_MAX]; + snprintf(path_dir, PATH_MAX, "%s/RtB", path); + user_dir.assign(path_dir); + #endif +} +SysInfo::~SysInfo() { +} + +#ifdef __ANDROID__ +JNIEXPORT void JNICALL Java_com_polymathic_RtB_RtB_setDpiInfo(JNIEnv* env, jobject obj, jint density_dpi, jfloat xdpi, jfloat ydpi) { + sysinfo.density_dpi = density_dpi; + sysinfo.xdpi = xdpi; + sysinfo.ydpi = ydpi; +} +JNIEXPORT void JNICALL Java_com_polymathic_RtB_RtB_setAppDirectory(JNIEnv* env, jobject obj, jstring app_dir) { + jboolean iscopy; + const char *native_string = env->GetStringUTFChars(app_dir, &iscopy); + sysinfo.app_dir.assign(native_string); + env->ReleaseStringUTFChars(app_dir, native_string); +} + +JNIEXPORT void JNICALL Java_com_polymathic_RtB_RtB_setExtDirectory(JNIEnv* env, jobject obj, jstring ext_dir) { + jboolean iscopy; + const char *native_string = env->GetStringUTFChars(ext_dir, &iscopy); + sysinfo.ext_dir.assign(native_string); + env->ReleaseStringUTFChars(ext_dir, native_string); +} + +#endif diff --git a/src/SysInfo.hpp b/src/SysInfo.hpp new file mode 100644 index 0000000..46692a2 --- /dev/null +++ b/src/SysInfo.hpp @@ -0,0 +1,31 @@ +/* ================================================================ +SysInfo +---------------- +================================================================ */ +#ifndef SYSTEM_HPP +#define SYSTEM_HPP +#include +class SysInfo { + public: + SysInfo(); + ~SysInfo(); + std::string app_dir; + std::string user_dir; + std::string ext_dir; + // display + int density_dpi; + float xdpi; + float ydpi; +}; +extern SysInfo sysinfo; +// **Android** +#ifdef __ANDROID__ +#include +extern "C" { + JNIEXPORT void JNICALL Java_com_polymathic_RtB_RtB_setDpiInfo(JNIEnv* env, jobject obj, jint density_dpi, jfloat xdpi, jfloat ydpi); + JNIEXPORT void JNICALL Java_com_polymathic_RtB_RtB_setAppDirectory(JNIEnv* env, jobject obj, jstring app_dir); + JNIEXPORT void JNICALL Java_com_polymathic_RtB_RtB_setExtDirectory(JNIEnv* env, jobject obj, jstring ext_dir); +} +#endif + +#endif diff --git a/src/Texture.cpp b/src/Texture.cpp index 5e64652..86b874a 100644 --- a/src/Texture.cpp +++ b/src/Texture.cpp @@ -11,6 +11,14 @@ Texture::Texture(std::string name_, const char *buffer, size_t buffer_size) { image = NULL; loadImg(buffer, buffer_size); } +// NOTE: this is a special test constructor just so I can use RenderView(s) within the current system nicely +Texture::Texture(std::string name_, RenderView *view) { + name.assign(name_); + texture = view->getTex(); + flags = 0; + w = view->getWidth(); + h = view->getHeight(); +} Texture::~Texture() { destroyTexture(); } @@ -69,7 +77,11 @@ GLuint Texture::buildTexture() { LOG(LOG_WARNING) << FUNC_NAME << ": failed to generate texture!"; return 0; } + #ifdef __APPLE__ + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, image->w, image->h, 0, GL_BGRA, GL_UNSIGNED_BYTE, image->pixels); + #else glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, image->w, image->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, image->pixels); + #endif /*glGenerateMipmap(GL_TEXTURE_2D); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);*/ diff --git a/src/Texture.hpp b/src/Texture.hpp index e7b592e..de06071 100644 --- a/src/Texture.hpp +++ b/src/Texture.hpp @@ -6,10 +6,12 @@ Texture.cpp/Texture.hpp provide the Texture class. This class is most akin to th #ifndef TEXTURE_HPP #define TEXTURE_HPP #include "common.hpp" +#include "RenderView.hpp" #include class Texture { public: Texture(std::string name_, const char *buffer, size_t buffer_size); + Texture(std::string name_, RenderView *view); ~Texture(); enum Flags { LOADED = (1 << 1), diff --git a/src/common.hpp b/src/common.hpp index 52b1621..6378d8e 100644 --- a/src/common.hpp +++ b/src/common.hpp @@ -34,4 +34,4 @@ This header provides common includes to SDL2 and OpenGL/OpenGLES #define glDeleteVertexArrays glDeleteVertexArraysAPPLE #endif #endif -#endif \ No newline at end of file +#endif diff --git a/src/fio.cpp b/src/fio.cpp index 0eede10..97900d5 100644 --- a/src/fio.cpp +++ b/src/fio.cpp @@ -126,21 +126,6 @@ AAssetDir* apk_openDir(const char *dir) { return AAssetManager_openDir(android_asset_manager, dir); } -std::string android_app_dir; -std::string android_ext_dir; -JNIEXPORT void JNICALL Java_com_polymathic_RtB_RtB_setAppDirectory(JNIEnv* env, jobject obj, jstring app_dir) { - jboolean iscopy; - const char *native_string = env->GetStringUTFChars(app_dir, &iscopy); - android_app_dir.assign(native_string); - env->ReleaseStringUTFChars(app_dir, native_string); -} - -JNIEXPORT void JNICALL Java_com_polymathic_RtB_RtB_setExtDirectory(JNIEnv* env, jobject obj, jstring ext_dir) { - jboolean iscopy; - const char *native_string = env->GetStringUTFChars(ext_dir, &iscopy); - android_ext_dir.assign(native_string); - env->ReleaseStringUTFChars(ext_dir, native_string); -} AAssetManager *getAAssetManager() { return android_asset_manager; } diff --git a/src/fio.hpp b/src/fio.hpp index 10ccc59..c7c3700 100644 --- a/src/fio.hpp +++ b/src/fio.hpp @@ -18,16 +18,12 @@ FILE *asset_fopen(const char *filename, const char *mode); #include #include #include -extern std::string android_app_dir; -extern std::string android_ext_dir; extern "C" AAssetManager* android_asset_manager; extern "C" { void apk_set_asset_manager(AAssetManager* manager); FILE *apk_fopen(const char *filename, const char *mode); AAssetDir* apk_openDir(const char *dir); JNIEXPORT void JNICALL Java_com_polymathic_RtB_RtB_setAssetManager(JNIEnv* env, jobject obj, jobject assetManager); - JNIEXPORT void JNICALL Java_com_polymathic_RtB_RtB_setAppDirectory(JNIEnv* env, jobject obj, jstring app_dir); - JNIEXPORT void JNICALL Java_com_polymathic_RtB_RtB_setExtDirectory(JNIEnv* env, jobject obj, jstring ext_dir); AAssetManager *getAAssetManager(); } #endif diff --git a/src/gui/GuiButton.cpp b/src/gui/GuiButton.cpp new file mode 100644 index 0000000..0afa0d3 --- /dev/null +++ b/src/gui/GuiButton.cpp @@ -0,0 +1,34 @@ +#include "GuiButton.hpp" +#include "Log.hpp" + +GuiButton::GuiButton(std::string string, Texture *texture_) { + text.assign(string); + texture = texture_; +} +GuiButton::~GuiButton() { + +} + +int GuiButton::doUpdate(int c_width, int c_height) { + float ex = x * 2; + float ey = y * 2; + if (pflags & TOP) { + ey = c_height - ey + h - offset_y; + } else if (pflags & BOTTOM) { + ey = -c_height + ey - h + offset_y; + } else if (pflags & VCENTER) { + ey = ey; + } + if (pflags & LEFT) { + ex = -c_width + ex - w + offset_x; + } else if (pflags & RIGHT) { + ex = c_width - ex + w - offset_x; + } else if (pflags & HCENTER) { + ex = ex; + } + if (object == NULL) return 1; // return if we haven't been added to Gui yet + object->setTranslation(ex, 0.0f, ey); + object->calcMatrix(); + if (texture != NULL) object->setTexture(texture); + return 0; +} diff --git a/src/gui/GuiButton.hpp b/src/gui/GuiButton.hpp new file mode 100644 index 0000000..83970a7 --- /dev/null +++ b/src/gui/GuiButton.hpp @@ -0,0 +1,15 @@ +#ifndef GUIBUTTON_HPP +#define GUIBUTTON_HPP +#include "GuiElement.hpp" +#include +#include "Texture.hpp" + +class GuiButton : public GuiElement { + public: + GuiButton(std::string text, Texture *texture); + ~GuiButton(); + virtual int doUpdate(int c_width, int c_height); + protected: + Texture *texture; // image texture for button image +}; +#endif diff --git a/src/gui/GuiElement.cpp b/src/gui/GuiElement.cpp index d3106f1..66bcda7 100644 --- a/src/gui/GuiElement.cpp +++ b/src/gui/GuiElement.cpp @@ -11,7 +11,9 @@ GuiElement::GuiElement(const char *string, GuiElement *parent_) { object = NULL; view = NULL; pflags = 0; + flags = 0; x = 0.25; y = 0.25; + offset_x = offset_y = 0; w = 0.25; h = 0.25; } GuiElement::GuiElement(const char *string) { @@ -20,7 +22,9 @@ GuiElement::GuiElement(const char *string) { text.assign(string); object = NULL; pflags = 0; + flags = 0; view = NULL; + offset_x = offset_y = 0; x = 0.25; y = 0.25; w = 0.25; h = 0.25; } @@ -33,17 +37,22 @@ GuiElement::GuiElement(const char *string, int group_id, int this_id) { object = NULL; view = NULL; pflags = 0; + flags = 0; x = 0.25; y = 0.25; + offset_x = offset_y = 0; w = 0.25; h = 0.25; } GuiElement::GuiElement() { parent = NULL; type = DEFAULT; x = 0.25; y = 0.25; + offset_x = offset_y = 0; w = 0.25; h = 0.25; + view = NULL; object = NULL; view = NULL; pflags = 0; + flags = 0; } GuiElement::~GuiElement() { if (view != NULL) delete view; @@ -53,12 +62,18 @@ int GuiElement::addChild(GuiElement *child) { children.push_back(child); return children.size()-1; } +int GuiElement::setParent(GuiElement *parent_) { + parent = parent_; + // TODO: detach from old parent + return 0; +} /* ======== Interactions ======== */ /* getHit This function takes in normalized coordinates and returns either NULL or the element hit if within the element's bounding box. If this element is hit, it will call getHit to all children elements until either a match is found or NULL is returned. If a match is found, that is returned, otherwise this element is returned. */ GuiElement* GuiElement::getHit(float xhit, float yhit) { GuiElement *element = NULL; + LOG(LOG_INFO) << text << " " << xhit << "x" << yhit << " vs " << x << "x" << y << "|" << x+w << "x" << y+h; if ( (xhit >= x && xhit <= x+w) && (yhit >= y && yhit <= y+h) ) { LOG(LOG_INFO) << FUNC_NAME << ": HIT " << text <<": " << xhit << "x" << yhit; // check the children for hits and return them if so @@ -78,25 +93,98 @@ GuiElement* GuiElement::getHit(float xhit, float yhit) { } return element; } +float GuiElement::getWidth() { + return w; +} +float GuiElement::getHeight() { + return h; +} /* ======== Render Modifications ======== */ int GuiElement::setGeometry(float x_, float y_, float w_, float h_) { x = x_; y = y_; w = w_; h = h_; + //view->setView(w, h); if (object == NULL) return 1; object->setScale(w, 1.0, h); //object->setTranslation(x, 0.0, y); object->calcMatrix(); return 0; } +void GuiElement::setSize(float width, float height) { + w = width; + h = height; + if (object == NULL) return; + object->setScale(w, 1.0, h); + //object->setTranslation(x, 0.0, y); + object->calcMatrix(); +} +void GuiElement::setPosition(float newx, float newy) { + x = newx; + y = newy; +} int GuiElement::setPFlags(int pflags_) { pflags = pflags_; return 0; } +void GuiElement::setOffset(float offx, float offy) { + offset_x = offx; + offset_y = offy; +} /* ======== Render, eugh ======== */ +int GuiElement::doUpdate(int c_width, int c_height) { + float ex = x * 2; + float ey = y * 2; + if (pflags & TOP) { + ey = c_height - ey + h; + } else if (pflags & BOTTOM) { + ey = -c_height + ey - h; + } else if (pflags & VCENTER) { + ey = ey; + } + if (pflags & LEFT) { + ex = -c_width + ex - w; + } else if (pflags & RIGHT) { + ex = c_width - ex + w; + } else if (pflags & HCENTER) { + ex = ex; + } + object->setTranslation(ex, 0.0f, ey); + object->calcMatrix(); + return 0; +} int GuiElement::doRender() { // TEMP: this is gross - Gui should just manage us, but this almost makes more sense.. Gui *gui = core.getGui(); if (gui == NULL) return 1; - + GuiElement *element; + float full_width = gui->getWidth(); + float full_height = gui->getHeight(); + float width = w; + float height = h; + std::vector::iterator element_it, element_end; + for (element_it = children.begin(), element_end = children.end(); element_it != element_end; ++element_it) { + element = *element_it; + // TODO: RenderCamera *child_child, is passed to doRender and: has its size set to the appropriate height of the child, also has widthxheight set (so as to maintain 1 to 1 pixel sizes). Additionally, glViewport is set to this renderView size + // TODO: if CHILD_EXPANDS(or some such?) is set, we: + // * setRenderView to new expanded width derived from child's renderview + // TODO: render our stuff, and then render the child's FBO to this + /*element->doRender(); + if (element->w > width) width = element->w; + if (element->h > height) height = element->h;*/ + } return 0; } +RenderView* GuiElement::getView() { + return view; +} +void GuiElement::hide() { + flags |= HIDDEN; + if (object != NULL) object->hide(); +} +void GuiElement::show() { + flags &= ~HIDDEN; + if (object != NULL) object->show(); +} +int GuiElement::getFlags() { + return flags; +} diff --git a/src/gui/GuiElement.hpp b/src/gui/GuiElement.hpp index 153fe94..029da99 100644 --- a/src/gui/GuiElement.hpp +++ b/src/gui/GuiElement.hpp @@ -9,6 +9,7 @@ This file describes the GuiElement class. This is the base class for further GUI #include #include "RenderObject.hpp" #include "RenderView.hpp" +#include "RenderCamera.hpp" class GuiElement { friend class Gui; public: @@ -18,7 +19,8 @@ class GuiElement { TEXT, TEXTINPUT, TEXTAREA, - CHECKBOX + CHECKBOX, + LIST }; enum Position { VCENTER = (1 << 1), @@ -28,18 +30,32 @@ class GuiElement { TOP = (1 << 5), BOTTOM = (1 << 6) }; + enum Flags { + HIDDEN = (1 <<1) + }; GuiElement(); GuiElement(const char *string); GuiElement(const char *string, GuiElement *parent_); GuiElement(const char *string, int group_id, int this_id); - ~GuiElement(); + virtual ~GuiElement(); // int setGeometry(float x, float y, float w, float h); // int setText(const char *string); GuiElement *getHit(float xhit, float yhit); int addChild(GuiElement *child); + int setParent(GuiElement *parent); int setPFlags(int pflags); - virtual int doRender(); + RenderView *getView(); + virtual int doUpdate(int c_width, int c_height); + int doRender(); + float getWidth(); + float getHeight(); + void setSize(float width, float height); + void setPosition(float newx, float newy); + void setOffset(float offx, float offy); + int getFlags(); + void hide(); + void show(); protected: std::vector children; // children of this element RenderView *view; // Ugh, we use FBOs for GUI elements cuz otherwise it's too annoying. @@ -47,10 +63,12 @@ class GuiElement { std::string text; // text of this element int type; // flag for this type int pflags; // positioning flags + int flags; // flags int gid; // group id for this element int id; // id for this element RenderObject *object;// render object, as set by manager class, Gui // float x, y, w, h; // position and dimensions for this element + float offset_x, offset_y; // offset x and y }; #endif diff --git a/src/gui/GuiList.cpp b/src/gui/GuiList.cpp new file mode 100644 index 0000000..f195308 --- /dev/null +++ b/src/gui/GuiList.cpp @@ -0,0 +1,46 @@ +#include "GuiList.hpp" +#include "Log.hpp" + +GuiList::GuiList(std::string string) { + text.assign(string); + type = LIST; +} +GuiList::~GuiList() { + +} + +int GuiList::doUpdate(int c_width, int c_height) { + float ex = x * 2; + float ey = y * 2; + if (pflags & TOP) { + ey = c_height - ey + offset_y; + } else if (pflags & BOTTOM) { + ey = -c_height + ey - offset_y; + } else if (pflags & VCENTER) { + ey = ey + offset_y; + } + if (pflags & LEFT) { + ex = -c_width + ex + offset_x; + } else if (pflags & RIGHT) { + ex = c_width - ex - offset_x; + } else if (pflags & HCENTER) { + ex = ex + offset_x; + } + float off_x = offset_x*2; + float off_y = offset_y*2; + GuiElement *child; + std::vector::iterator element_it, element_end; + for (element_it = children.begin(), element_end = children.end(); element_it != element_end; ++element_it) { + child = *element_it; + if (child->getFlags() & HIDDEN) continue; + off_x += (child->getWidth()*2); + off_y = child->getHeight()*2; + child->setOffset(off_x, off_y); + child->doUpdate(c_width, c_height); + } + setSize(off_x/2, off_y/2); + if (object == NULL) return 1; // return if we haven't been added to Gui yet + object->setTranslation(ex+offset_x, 0.0f, ey+offset_y); + object->calcMatrix(); + return 0; +} diff --git a/src/gui/GuiList.hpp b/src/gui/GuiList.hpp new file mode 100644 index 0000000..0720ced --- /dev/null +++ b/src/gui/GuiList.hpp @@ -0,0 +1,12 @@ +#ifndef GUILIST_HPP +#define GUILIST_HPP +#include "GuiElement.hpp" +#include + +class GuiList : public GuiElement { + public: + GuiList(std::string text); + ~GuiList(); + virtual int doUpdate(int c_width, int c_height); +}; +#endif diff --git a/src/states/TestState.cpp b/src/states/TestState.cpp index 4c7492d..e412766 100644 --- a/src/states/TestState.cpp +++ b/src/states/TestState.cpp @@ -7,6 +7,9 @@ #include "Program.hpp" #include "Mesh.hpp" #include "Texture.hpp" +#include "GuiButton.hpp" +#include "GuiList.hpp" +#include "SysInfo.hpp" // for DPI /* ======== Construction and Destruction ======== */ TestState::TestState() { scene = NULL; @@ -36,8 +39,11 @@ int TestState::onEvent(SDL_Event event) { Vec3 camera_pos = camera->getPosition(); int width = core.getWidth(); int height = core.getHeight(); - float x = event.tfinger.dx * width/16; - float y = event.tfinger.dy * height/16; + /*float x = camera_pos.y * event.tfinger.dx / 0.5; + float y = camera_pos.y * event.tfinger.dy / 0.5;*/ + LOG(LOG_INFO) << "finger traveled: " << event.tfinger.dx*width << "x" << event.tfinger.dy*height << ", " << (event.tfinger.dx*width)/sysinfo.ydpi << "inx" << (event.tfinger.dy*height)/sysinfo.xdpi << "in"; + float x = (camera_pos.y * (event.tfinger.dx * width / sysinfo.density_dpi)); + float y = (camera_pos.y * (event.tfinger.dy * height / sysinfo.density_dpi)); // This is weird. float yaw = camera->getYaw() * M_PI / 180.0f; @@ -55,8 +61,8 @@ int TestState::onEvent(SDL_Event event) { Vec3 camera_pos = camera->getPosition(); int width = core.getWidth(); int height = core.getHeight(); - float x = (float)event.motion.xrel / (width/50); - float y = (float)event.motion.yrel / (height/50); + float x = camera_pos.y * (float)event.motion.xrel / (float)width; + float y = camera_pos.y * (float)event.motion.yrel / (float)height; // This is weird. (again) float yaw = camera->getYaw() * M_PI / 180.0f; float ax = (-x * cosf(yaw)) + (y * sinf(yaw)); @@ -165,17 +171,44 @@ int TestState::onInit() { objerct->setTexture(core.getTexture("textures/cube.png")); sert->addObject(objerct); + objerct = new RenderObject(); + objerct->setMesh(core.getMesh("models/plane.obj")); + objerct->setTexture(core.getTexture("tokens/gentlebones.png")); + objerct->setTranslation(4.0f, 0.0f, 4.0f); + objerct->calcMatrix(); + sert->addObject(objerct); + scene->addSet(sert); // GUI testing - GuiElement *element = new GuiElement("test", 10, 1); - element->setPFlags(GuiElement::VCENTER|GuiElement::HCENTER); + GuiElement *element = new GuiButton("test", core.getTexture("ui/icon_perscube.png")); + element->setPFlags(GuiElement::TOP|GuiElement::RIGHT); element->setGeometry(0.0f, 0.0f, 128.0f, 128.0f); - gui->addElement(element); - element = new GuiElement("test2", 10, 2); + + GuiList *element_list = new GuiList("list1"); + element_list->addChild(element); + element->setParent(element_list); + element_list->setPFlags(GuiElement::TOP|GuiElement::RIGHT); + element_list->setGeometry(0.0f, 0.0f, 128.0f, 128.0f); + + element = new GuiButton("test2", core.getTexture("ui/icon_isocube.png")); + element->setPFlags(GuiElement::TOP|GuiElement::RIGHT); + element->setGeometry(0.0f, 0.0f, 128.0f, 128.0f); + element_list->addChild(element); + element->setParent(element_list); + + element = new GuiButton("test3", core.getTexture("ui/icon_token.png")); + element->setPFlags(GuiElement::TOP|GuiElement::RIGHT); + element->setGeometry(0.0f, 0.0f, 128.0f, 128.0f); + element_list->addChild(element); + element->setParent(element_list); + + gui->addElement(element_list); + + /*element = new GuiElement("test2", 10, 2); element->setPFlags(GuiElement::RIGHT|GuiElement::TOP); element->setGeometry(256.0f, 128.0f, 128.0f, 128.0f); - gui->addElement(element); + gui->addElement(element);*/ // manually update GUI gui->updateElements();