Browse Source

Fix samples assets loading

This will fix assets loading for samples under Linux so that you can now
launch them from the Build directory or from their installation
directory.
The new default is to consider file paths as relative to the samples
root.
Marco Bortolin 6 years ago
parent
commit
ebe2d425b2
35 changed files with 178 additions and 187 deletions
  1. 2 1
      Samples/basic/animation/src/main.cpp
  2. 5 10
      Samples/basic/bitmapfont/src/main.cpp
  3. 5 10
      Samples/basic/customlog/src/main.cpp
  4. 3 3
      Samples/basic/directx10/src/main.cpp
  5. 1 1
      Samples/basic/drag/src/Inventory.cpp
  6. 3 2
      Samples/basic/drag/src/main.cpp
  7. 4 9
      Samples/basic/loaddocument/src/main.cpp
  8. 9 16
      Samples/basic/sdl2/src/main.cpp
  9. 9 7
      Samples/basic/sfml2/src/main.cpp
  10. 2 1
      Samples/basic/transform/src/main.cpp
  11. 6 10
      Samples/basic/treeview/src/main.cpp
  12. 1 1
      Samples/invaders/src/EventManager.cpp
  13. 3 8
      Samples/invaders/src/main.cpp
  14. 1 1
      Samples/luainvaders/data/game.rml
  15. 2 2
      Samples/luainvaders/data/main_menu.rml
  16. 1 1
      Samples/luainvaders/data/window.rml
  17. 2 2
      Samples/luainvaders/lua/start.lua
  18. 1 1
      Samples/luainvaders/src/Game.cpp
  19. 4 8
      Samples/luainvaders/src/main.cpp
  20. 5 14
      Samples/shell/include/Shell.h
  21. 7 0
      Samples/shell/include/ShellOpenGL.h
  22. 0 9
      Samples/shell/include/ShellRenderInterfaceOpenGL.h
  23. 0 8
      Samples/shell/src/Shell.cpp
  24. 21 12
      Samples/shell/src/macosx/ShellMacOSX.cpp
  25. 22 10
      Samples/shell/src/win32/ShellWin32.cpp
  26. 41 2
      Samples/shell/src/x11/ShellX11.cpp
  27. 0 0
      Samples/tutorial/datagrid/data/high_score.txt
  28. 1 1
      Samples/tutorial/datagrid/src/HighScores.cpp
  29. 4 9
      Samples/tutorial/datagrid/src/main.cpp
  30. 0 0
      Samples/tutorial/datagrid_tree/data/high_score.txt
  31. 1 1
      Samples/tutorial/datagrid_tree/src/HighScores.cpp
  32. 4 9
      Samples/tutorial/datagrid_tree/src/main.cpp
  33. 4 9
      Samples/tutorial/template/src/main.cpp
  34. 1 1
      Samples/tutorial/tutorial_drag/src/Inventory.cpp
  35. 3 8
      Samples/tutorial/tutorial_drag/src/main.cpp

+ 2 - 1
Samples/basic/animation/src/main.cpp

@@ -30,6 +30,7 @@
 #include <Rocket/Debugger.h>
 #include <Rocket/Debugger.h>
 #include <Input.h>
 #include <Input.h>
 #include <Shell.h>
 #include <Shell.h>
+#include <ShellRenderInterfaceOpenGL.h>
 #include <Rocket/Core/TransformPrimitive.h>
 #include <Rocket/Core/TransformPrimitive.h>
 
 
 #include <sstream>
 #include <sstream>
@@ -332,7 +333,7 @@ int main(int ROCKET_UNUSED_PARAMETER(argc), char** ROCKET_UNUSED_PARAMETER(argv)
 	shell_renderer = &opengl_renderer;
 	shell_renderer = &opengl_renderer;
 
 
 	// Generic OS initialisation, creates a window and attaches OpenGL.
 	// Generic OS initialisation, creates a window and attaches OpenGL.
-	if (!Shell::Initialise("../../Samples/") ||
+	if (!Shell::Initialise() ||
 		!Shell::OpenWindow("Animation Sample", shell_renderer, width, height, true))
 		!Shell::OpenWindow("Animation Sample", shell_renderer, width, height, true))
 	{
 	{
 		Shell::Shutdown();
 		Shell::Shutdown();

+ 5 - 10
Samples/basic/bitmapfont/src/main.cpp

@@ -29,6 +29,7 @@
 #include <Rocket/Debugger.h>
 #include <Rocket/Debugger.h>
 #include <Input.h>
 #include <Input.h>
 #include <Shell.h>
 #include <Shell.h>
+#include <ShellRenderInterfaceOpenGL.h>
 
 
 Rocket::Core::Context* context = NULL;
 Rocket::Core::Context* context = NULL;
 
 
@@ -60,12 +61,6 @@ int main(int ROCKET_UNUSED_PARAMETER(argc), char** ROCKET_UNUSED_PARAMETER(argv)
 	ROCKET_UNUSED(argv);
 	ROCKET_UNUSED(argv);
 #endif
 #endif
 
 
-#ifdef ROCKET_PLATFORM_LINUX
-#define APP_PATH "../Samples/basic/loaddocument/"
-#else
-#define APP_PATH "../../Samples/basic/loaddocument/"
-#endif
-
 #ifdef ROCKET_PLATFORM_WIN32
 #ifdef ROCKET_PLATFORM_WIN32
         AllocConsole();
         AllocConsole();
 #endif
 #endif
@@ -77,8 +72,8 @@ int main(int ROCKET_UNUSED_PARAMETER(argc), char** ROCKET_UNUSED_PARAMETER(argv)
 	shell_renderer = &opengl_renderer;
 	shell_renderer = &opengl_renderer;
 
 
 	// Generic OS initialisation, creates a window and attaches OpenGL.
 	// Generic OS initialisation, creates a window and attaches OpenGL.
-	if (!Shell::Initialise(APP_PATH) ||
-		!Shell::OpenWindow("Load Document Sample", shell_renderer, window_width, window_height, true))
+	if (!Shell::Initialise() ||
+		!Shell::OpenWindow("Bitmap Font Sample", shell_renderer, window_width, window_height, true))
 	{
 	{
 		Shell::Shutdown();
 		Shell::Shutdown();
 		return -1;
 		return -1;
@@ -107,10 +102,10 @@ int main(int ROCKET_UNUSED_PARAMETER(argc), char** ROCKET_UNUSED_PARAMETER(argv)
 	shell_renderer->SetContext(context);
 	shell_renderer->SetContext(context);
 
 
     // Load bitmap font
     // Load bitmap font
-    Rocket::Core::FontDatabase::LoadFontFace("../../assets/Arial.fnt");
+    Rocket::Core::FontDatabase::LoadFontFace("assets/Arial.fnt");
 	
 	
     // Load and show the demo document.
     // Load and show the demo document.
-	Rocket::Core::ElementDocument* document = context->LoadDocument("../../assets/bitmapfont.rml");
+	Rocket::Core::ElementDocument* document = context->LoadDocument("assets/bitmapfont.rml");
 	if (document != NULL)
 	if (document != NULL)
 	{
 	{
 		document->Show();
 		document->Show();

+ 5 - 10
Samples/basic/customlog/src/main.cpp

@@ -29,6 +29,7 @@
 #include <Rocket/Debugger.h>
 #include <Rocket/Debugger.h>
 #include <Input.h>
 #include <Input.h>
 #include <Shell.h>
 #include <Shell.h>
+#include <ShellRenderInterfaceOpenGL.h>
 #include "SystemInterface.h"
 #include "SystemInterface.h"
 
 
 Rocket::Core::Context* context = NULL;
 Rocket::Core::Context* context = NULL;
@@ -61,12 +62,6 @@ int main(int ROCKET_UNUSED_PARAMETER(argc), char** ROCKET_UNUSED_PARAMETER(argv)
 	ROCKET_UNUSED(argv);
 	ROCKET_UNUSED(argv);
 #endif
 #endif
 
 
-#ifdef ROCKET_PLATFORM_LINUX
-#define APP_PATH "../Samples/basic/customlog/"
-#else
-#define APP_PATH "../../Samples/basic/customlog/"
-#endif
-
 #ifdef ROCKET_PLATFORM_WIN32
 #ifdef ROCKET_PLATFORM_WIN32
         AllocConsole();
         AllocConsole();
 #endif
 #endif
@@ -78,7 +73,7 @@ int main(int ROCKET_UNUSED_PARAMETER(argc), char** ROCKET_UNUSED_PARAMETER(argv)
 	shell_renderer = &opengl_renderer;
 	shell_renderer = &opengl_renderer;
 
 
 	// Generic OS initialisation, creates a window and attaches OpenGL.
 	// Generic OS initialisation, creates a window and attaches OpenGL.
-	if (!Shell::Initialise(APP_PATH) ||
+	if (!Shell::Initialise() ||
 		!Shell::OpenWindow("Custom File Handler Sample", shell_renderer, window_width, window_height, true))
 		!Shell::OpenWindow("Custom File Handler Sample", shell_renderer, window_width, window_height, true))
 	{
 	{
 		Shell::Shutdown();
 		Shell::Shutdown();
@@ -109,10 +104,10 @@ int main(int ROCKET_UNUSED_PARAMETER(argc), char** ROCKET_UNUSED_PARAMETER(argv)
 	Input::SetContext(context);
 	Input::SetContext(context);
 	shell_renderer->SetContext(context);
 	shell_renderer->SetContext(context);
 
 
-	Shell::LoadFonts("../../assets/");
+	Shell::LoadFonts("assets/");
 
 
 	// Load a non-existent document to spawn an error message.
 	// Load a non-existent document to spawn an error message.
-	Rocket::Core::ElementDocument* invalid_document = context->LoadDocument("../../assets/invalid.rml");
+	Rocket::Core::ElementDocument* invalid_document = context->LoadDocument("assets/invalid.rml");
 	ROCKET_ASSERTMSG(invalid_document != NULL, "Testing ASSERT logging.");
 	ROCKET_ASSERTMSG(invalid_document != NULL, "Testing ASSERT logging.");
 	if (invalid_document != NULL)
 	if (invalid_document != NULL)
 	{
 	{
@@ -121,7 +116,7 @@ int main(int ROCKET_UNUSED_PARAMETER(argc), char** ROCKET_UNUSED_PARAMETER(argv)
 	}
 	}
 
 
 	// Load and show the demo document.
 	// Load and show the demo document.
-	Rocket::Core::ElementDocument* document = context->LoadDocument("../../assets/demo.rml");
+	Rocket::Core::ElementDocument* document = context->LoadDocument("assets/demo.rml");
 	if (document != NULL)
 	if (document != NULL)
 	{
 	{
 		document->Show();
 		document->Show();

+ 3 - 3
Samples/basic/directx10/src/main.cpp

@@ -37,7 +37,7 @@ int APIENTRY WinMain(HINSTANCE ROCKET_UNUSED_PARAMETER(instance_handle), HINSTAN
 	shell_renderer = &directx_renderer;
 	shell_renderer = &directx_renderer;
 
 
 	// Generic OS initialisation, creates a window and does not attach OpenGL.
 	// Generic OS initialisation, creates a window and does not attach OpenGL.
-	if (!Shell::Initialise("../Samples/basic/directx/") ||
+	if (!Shell::Initialise() ||
 		!Shell::OpenWindow("DirectX 10 Sample", shell_renderer, window_width, window_height, true))
 		!Shell::OpenWindow("DirectX 10 Sample", shell_renderer, window_width, window_height, true))
 	{
 	{
 		Shell::Shutdown();
 		Shell::Shutdown();
@@ -65,10 +65,10 @@ int APIENTRY WinMain(HINSTANCE ROCKET_UNUSED_PARAMETER(instance_handle), HINSTAN
 	Input::SetContext(context);
 	Input::SetContext(context);
 	shell_renderer->SetContext(context);
 	shell_renderer->SetContext(context);
 
 
-	Shell::LoadFonts("../../assets/");
+	Shell::LoadFonts("assets/");
 
 
 	// Load and show the tutorial document.
 	// Load and show the tutorial document.
-	Rocket::Core::ElementDocument* document = context->LoadDocument("../../assets/demo.rml");
+	Rocket::Core::ElementDocument* document = context->LoadDocument("assets/demo.rml");
 	if (document != NULL)
 	if (document != NULL)
 	{
 	{
 		document->Show();
 		document->Show();

+ 1 - 1
Samples/basic/drag/src/Inventory.cpp

@@ -32,7 +32,7 @@
 // Constructs a new inventory and opens its window.
 // Constructs a new inventory and opens its window.
 Inventory::Inventory(const Rocket::Core::String& title, const Rocket::Core::Vector2f& position, Rocket::Core::Context* context)
 Inventory::Inventory(const Rocket::Core::String& title, const Rocket::Core::Vector2f& position, Rocket::Core::Context* context)
 {
 {
-	document = context->LoadDocument("data/inventory.rml");
+	document = context->LoadDocument("basic/drag/data/inventory.rml");
 	if (document != NULL)
 	if (document != NULL)
 	{
 	{
 		document->GetElementById("title")->SetInnerRML(title);
 		document->GetElementById("title")->SetInnerRML(title);

+ 3 - 2
Samples/basic/drag/src/main.cpp

@@ -29,6 +29,7 @@
 #include <Rocket/Debugger.h>
 #include <Rocket/Debugger.h>
 #include <Input.h>
 #include <Input.h>
 #include <Shell.h>
 #include <Shell.h>
+#include <ShellRenderInterfaceOpenGL.h>
 #include "Inventory.h"
 #include "Inventory.h"
 
 
 Rocket::Core::Context* context = NULL;
 Rocket::Core::Context* context = NULL;
@@ -78,7 +79,7 @@ int main(int ROCKET_UNUSED_PARAMETER(argc), char** ROCKET_UNUSED_PARAMETER(argv)
 	shell_renderer = &opengl_renderer;
 	shell_renderer = &opengl_renderer;
 
 
 	// Generic OS initialisation, creates a window and attaches OpenGL.
 	// Generic OS initialisation, creates a window and attaches OpenGL.
-	if (!Shell::Initialise(APP_PATH) ||
+	if (!Shell::Initialise() ||
 		!Shell::OpenWindow("Drag Sample", shell_renderer, window_width, window_height, true))
 		!Shell::OpenWindow("Drag Sample", shell_renderer, window_width, window_height, true))
 	{
 	{
 		Shell::Shutdown();
 		Shell::Shutdown();
@@ -107,7 +108,7 @@ int main(int ROCKET_UNUSED_PARAMETER(argc), char** ROCKET_UNUSED_PARAMETER(argv)
 	Input::SetContext(context);
 	Input::SetContext(context);
 	shell_renderer->SetContext(context);
 	shell_renderer->SetContext(context);
 
 
-	Shell::LoadFonts("../../assets/");
+	Shell::LoadFonts("assets/");
 
 
 	// Load and show the inventory document.
 	// Load and show the inventory document.
 	Inventory* inventory_1 = new Inventory("Inventory 1", Rocket::Core::Vector2f(50, 200), context);
 	Inventory* inventory_1 = new Inventory("Inventory 1", Rocket::Core::Vector2f(50, 200), context);

+ 4 - 9
Samples/basic/loaddocument/src/main.cpp

@@ -29,6 +29,7 @@
 #include <Rocket/Debugger.h>
 #include <Rocket/Debugger.h>
 #include <Input.h>
 #include <Input.h>
 #include <Shell.h>
 #include <Shell.h>
+#include <ShellRenderInterfaceOpenGL.h>
 
 
 Rocket::Core::Context* context = NULL;
 Rocket::Core::Context* context = NULL;
 
 
@@ -60,12 +61,6 @@ int main(int ROCKET_UNUSED_PARAMETER(argc), char** ROCKET_UNUSED_PARAMETER(argv)
 	ROCKET_UNUSED(argv);
 	ROCKET_UNUSED(argv);
 #endif
 #endif
 
 
-#ifdef ROCKET_PLATFORM_LINUX
-#define APP_PATH "../Samples/basic/loaddocument/"
-#else
-#define APP_PATH "../../Samples/basic/loaddocument/"
-#endif
-
 #ifdef ROCKET_PLATFORM_WIN32
 #ifdef ROCKET_PLATFORM_WIN32
         AllocConsole();
         AllocConsole();
 #endif
 #endif
@@ -77,7 +72,7 @@ int main(int ROCKET_UNUSED_PARAMETER(argc), char** ROCKET_UNUSED_PARAMETER(argv)
 	shell_renderer = &opengl_renderer;
 	shell_renderer = &opengl_renderer;
 
 
 	// Generic OS initialisation, creates a window and attaches OpenGL.
 	// Generic OS initialisation, creates a window and attaches OpenGL.
-	if (!Shell::Initialise(APP_PATH) ||
+	if (!Shell::Initialise() ||
 		!Shell::OpenWindow("Load Document Sample", shell_renderer, window_width, window_height, true))
 		!Shell::OpenWindow("Load Document Sample", shell_renderer, window_width, window_height, true))
 	{
 	{
 		Shell::Shutdown();
 		Shell::Shutdown();
@@ -106,10 +101,10 @@ int main(int ROCKET_UNUSED_PARAMETER(argc), char** ROCKET_UNUSED_PARAMETER(argv)
 	Input::SetContext(context);
 	Input::SetContext(context);
 	shell_renderer->SetContext(context);
 	shell_renderer->SetContext(context);
 
 
-	Shell::LoadFonts("../../assets/");
+	Shell::LoadFonts("assets/");
 
 
 	// Load and show the demo document.
 	// Load and show the demo document.
-	Rocket::Core::ElementDocument* document = context->LoadDocument("../../assets/demo.rml");
+	Rocket::Core::ElementDocument* document = context->LoadDocument("assets/demo.rml");
 	if (document != NULL)
 	if (document != NULL)
 	{
 	{
 		document->Show();
 		document->Show();

+ 9 - 16
Samples/basic/sdl2/src/main.cpp

@@ -28,6 +28,7 @@
 #include <Rocket/Core.h>
 #include <Rocket/Core.h>
 #include <Rocket/Core/Input.h>
 #include <Rocket/Core/Input.h>
 #include <Rocket/Debugger/Debugger.h>
 #include <Rocket/Debugger/Debugger.h>
+#include <Shell.h>
 #include <ShellFileInterface.h>
 #include <ShellFileInterface.h>
 
 
 #include "SystemInterfaceSDL2.h"
 #include "SystemInterfaceSDL2.h"
@@ -39,16 +40,6 @@
 
 
 int main(int argc, char **argv)
 int main(int argc, char **argv)
 {
 {
-#ifdef ROCKET_PLATFORM_LINUX
-#define APP_PATH "../Samples/basic/sdl2/"
-#else
-#ifdef ROCKET_PLATFORM_MACOSX
-#define APP_PATH "../../../../../Samples/basic/sdl2/"
-#else
-#define APP_PATH "../../Samples/basic/sdl2/"
-#endif
-#endif
-
 #ifdef ROCKET_PLATFORM_WIN32
 #ifdef ROCKET_PLATFORM_WIN32
         DoAllocConsole();
         DoAllocConsole();
 #endif
 #endif
@@ -86,7 +77,9 @@ int main(int argc, char **argv)
  
  
 	RocketSDL2Renderer Renderer(renderer, screen);
 	RocketSDL2Renderer Renderer(renderer, screen);
 	RocketSDL2SystemInterface SystemInterface;
 	RocketSDL2SystemInterface SystemInterface;
-	ShellFileInterface FileInterface("../Samples/assets/");
+	
+	Rocket::Core::String root = Shell::FindSamplesRoot();
+	ShellFileInterface FileInterface(root);
 
 
 	Rocket::Core::SetFileInterface(&FileInterface);
 	Rocket::Core::SetFileInterface(&FileInterface);
 	Rocket::Core::SetRenderInterface(&Renderer);
 	Rocket::Core::SetRenderInterface(&Renderer);
@@ -95,17 +88,17 @@ int main(int argc, char **argv)
 	if(!Rocket::Core::Initialise())
 	if(!Rocket::Core::Initialise())
 		return 1;
 		return 1;
 
 
-	Rocket::Core::FontDatabase::LoadFontFace("Delicious-Bold.otf");
-	Rocket::Core::FontDatabase::LoadFontFace("Delicious-BoldItalic.otf");
-	Rocket::Core::FontDatabase::LoadFontFace("Delicious-Italic.otf");
-	Rocket::Core::FontDatabase::LoadFontFace("Delicious-Roman.otf");
+	Rocket::Core::FontDatabase::LoadFontFace("assets/Delicious-Bold.otf");
+	Rocket::Core::FontDatabase::LoadFontFace("assets/Delicious-BoldItalic.otf");
+	Rocket::Core::FontDatabase::LoadFontFace("assets/Delicious-Italic.otf");
+	Rocket::Core::FontDatabase::LoadFontFace("assets/Delicious-Roman.otf");
 
 
 	Rocket::Core::Context *Context = Rocket::Core::CreateContext("default",
 	Rocket::Core::Context *Context = Rocket::Core::CreateContext("default",
 		Rocket::Core::Vector2i(window_width, window_height));
 		Rocket::Core::Vector2i(window_width, window_height));
 
 
 	Rocket::Debugger::Initialise(Context);
 	Rocket::Debugger::Initialise(Context);
 
 
-	Rocket::Core::ElementDocument *Document = Context->LoadDocument("demo.rml");
+	Rocket::Core::ElementDocument *Document = Context->LoadDocument("assets/demo.rml");
 
 
 	if(Document)
 	if(Document)
 	{
 	{

+ 9 - 7
Samples/basic/sfml2/src/main.cpp

@@ -41,7 +41,8 @@
 #include "RenderInterfaceSFML.h"
 #include "RenderInterfaceSFML.h"
 #include <Rocket/Core/Input.h>
 #include <Rocket/Core/Input.h>
 #include <Rocket/Debugger/Debugger.h>
 #include <Rocket/Debugger/Debugger.h>
-#include "ShellFileInterface.h"
+#include <Shell.h>
+#include <ShellFileInterface.h>
 
 
 int main(int argc, char **argv)
 int main(int argc, char **argv)
 {
 {
@@ -71,7 +72,8 @@ int main(int argc, char **argv)
 
 
 	// NOTE: if fonts and rml are not found you'll probably have to adjust
 	// NOTE: if fonts and rml are not found you'll probably have to adjust
 	// the path information in the string
 	// the path information in the string
-	ShellFileInterface FileInterface("../Samples/assets/");
+	Rocket::Core::String root = Shell::FindSamplesRoot();
+	ShellFileInterface FileInterface(root);
 
 
 	if(!MyWindow.isOpen())
 	if(!MyWindow.isOpen())
 		return 1;
 		return 1;
@@ -86,17 +88,17 @@ int main(int argc, char **argv)
 	if(!Rocket::Core::Initialise())
 	if(!Rocket::Core::Initialise())
 		return 1;
 		return 1;
 
 
-	Rocket::Core::FontDatabase::LoadFontFace("Delicious-Bold.otf");
-	Rocket::Core::FontDatabase::LoadFontFace("Delicious-BoldItalic.otf");
-	Rocket::Core::FontDatabase::LoadFontFace("Delicious-Italic.otf");
-	Rocket::Core::FontDatabase::LoadFontFace("Delicious-Roman.otf");
+	Rocket::Core::FontDatabase::LoadFontFace("assets/Delicious-Bold.otf");
+	Rocket::Core::FontDatabase::LoadFontFace("assets/Delicious-BoldItalic.otf");
+	Rocket::Core::FontDatabase::LoadFontFace("assets/Delicious-Italic.otf");
+	Rocket::Core::FontDatabase::LoadFontFace("assets/Delicious-Roman.otf");
 
 
 	Rocket::Core::Context *Context = Rocket::Core::CreateContext("default",
 	Rocket::Core::Context *Context = Rocket::Core::CreateContext("default",
 		Rocket::Core::Vector2i(MyWindow.getSize().x, MyWindow.getSize().y));
 		Rocket::Core::Vector2i(MyWindow.getSize().x, MyWindow.getSize().y));
 
 
 	Rocket::Debugger::Initialise(Context);
 	Rocket::Debugger::Initialise(Context);
 
 
-	Rocket::Core::ElementDocument *Document = Context->LoadDocument("demo.rml");
+	Rocket::Core::ElementDocument *Document = Context->LoadDocument("assets/demo.rml");
 
 
 	if(Document)
 	if(Document)
 	{
 	{

+ 2 - 1
Samples/basic/transform/src/main.cpp

@@ -30,6 +30,7 @@
 #include <Rocket/Debugger.h>
 #include <Rocket/Debugger.h>
 #include <Input.h>
 #include <Input.h>
 #include <Shell.h>
 #include <Shell.h>
+#include <ShellRenderInterfaceOpenGL.h>
 
 
 #include <cmath>
 #include <cmath>
 #include <sstream>
 #include <sstream>
@@ -139,7 +140,7 @@ int main(int ROCKET_UNUSED_PARAMETER(argc), char** ROCKET_UNUSED_PARAMETER(argv)
 	shell_renderer = &opengl_renderer;
 	shell_renderer = &opengl_renderer;
 
 
 	// Generic OS initialisation, creates a window and attaches OpenGL.
 	// Generic OS initialisation, creates a window and attaches OpenGL.
-	if (!Shell::Initialise("../../Samples/") ||
+	if (!Shell::Initialise() ||
 		!Shell::OpenWindow("Transform Sample", shell_renderer, 1024, 768, true))
 		!Shell::OpenWindow("Transform Sample", shell_renderer, 1024, 768, true))
 	{
 	{
 		Shell::Shutdown();
 		Shell::Shutdown();

+ 6 - 10
Samples/basic/treeview/src/main.cpp

@@ -30,6 +30,7 @@
 #include <Rocket/Debugger.h>
 #include <Rocket/Debugger.h>
 #include <Input.h>
 #include <Input.h>
 #include <Shell.h>
 #include <Shell.h>
+#include <ShellRenderInterfaceOpenGL.h>
 #include "FileFormatter.h"
 #include "FileFormatter.h"
 #include "FileSystem.h"
 #include "FileSystem.h"
 
 
@@ -63,12 +64,6 @@ int main(int ROCKET_UNUSED_PARAMETER(argc), char** ROCKET_UNUSED_PARAMETER(argv)
 	ROCKET_UNUSED(argv);
 	ROCKET_UNUSED(argv);
 #endif
 #endif
 
 
-#ifdef ROCKET_PLATFORM_LINUX
-#define APP_PATH "../Samples/basic/treeview/"
-#else
-#define APP_PATH "../../Samples/basic/treeview/"
-#endif
-
 #ifdef ROCKET_PLATFORM_WIN32
 #ifdef ROCKET_PLATFORM_WIN32
         AllocConsole();
         AllocConsole();
 #endif
 #endif
@@ -80,7 +75,7 @@ int main(int ROCKET_UNUSED_PARAMETER(argc), char** ROCKET_UNUSED_PARAMETER(argv)
 	shell_renderer = &opengl_renderer;
 	shell_renderer = &opengl_renderer;
 
 
 	// Generic OS initialisation, creates a window and attaches OpenGL.
 	// Generic OS initialisation, creates a window and attaches OpenGL.
-	if (!Shell::Initialise(APP_PATH) ||
+	if (!Shell::Initialise() ||
 		!Shell::OpenWindow("Tree View Sample", shell_renderer, window_width, window_height, true))
 		!Shell::OpenWindow("Tree View Sample", shell_renderer, window_width, window_height, true))
 	{
 	{
 		Shell::Shutdown();
 		Shell::Shutdown();
@@ -110,14 +105,15 @@ int main(int ROCKET_UNUSED_PARAMETER(argc), char** ROCKET_UNUSED_PARAMETER(argv)
 	Input::SetContext(context);
 	Input::SetContext(context);
 	shell_renderer->SetContext(context);
 	shell_renderer->SetContext(context);
 
 
-	Shell::LoadFonts("../../assets/");
+	Shell::LoadFonts("assets/");
 
 
 	// Create the file data source and formatter.
 	// Create the file data source and formatter.
-	FileSystem file_system("../Samples/basic/treeview/");
+	Rocket::Core::String root = Shell::FindSamplesRoot();
+	FileSystem file_system(root + "basic/");
 	FileFormatter file_formatter;
 	FileFormatter file_formatter;
 
 
 	// Load and show the demo document.
 	// Load and show the demo document.
-	Rocket::Core::ElementDocument* document = context->LoadDocument("data/treeview.rml");
+	Rocket::Core::ElementDocument* document = context->LoadDocument("basic/treeview/data/treeview.rml");
 	if (document != NULL)
 	if (document != NULL)
 	{
 	{
 		document->GetElementById("title")->SetInnerRML(document->GetTitle());
 		document->GetElementById("title")->SetInnerRML(document->GetTitle());

+ 1 - 1
Samples/invaders/src/EventManager.cpp

@@ -144,7 +144,7 @@ Rocket::Core::ElementDocument* EventManager::LoadWindow(const Rocket::Core::Stri
 		event_handler = NULL;
 		event_handler = NULL;
 
 
 	// Attempt to load the referenced RML document.
 	// Attempt to load the referenced RML document.
-	Rocket::Core::String document_path = Rocket::Core::String("data/") + window_name + Rocket::Core::String(".rml");
+	Rocket::Core::String document_path = Rocket::Core::String("invaders/data/") + window_name + Rocket::Core::String(".rml");
 	Rocket::Core::ElementDocument* document = context->LoadDocument(document_path.CString());
 	Rocket::Core::ElementDocument* document = context->LoadDocument(document_path.CString());
 	if (document == NULL)
 	if (document == NULL)
 	{
 	{

+ 3 - 8
Samples/invaders/src/main.cpp

@@ -29,6 +29,7 @@
 #include <Rocket/Controls.h>
 #include <Rocket/Controls.h>
 #include <Rocket/Debugger.h>
 #include <Rocket/Debugger.h>
 #include <Shell.h>
 #include <Shell.h>
+#include <ShellRenderInterfaceOpenGL.h>
 #include <Input.h>
 #include <Input.h>
 #include "DecoratorInstancerDefender.h"
 #include "DecoratorInstancerDefender.h"
 #include "DecoratorInstancerStarfield.h"
 #include "DecoratorInstancerStarfield.h"
@@ -72,12 +73,6 @@ int main(int ROCKET_UNUSED_PARAMETER(argc), char** ROCKET_UNUSED_PARAMETER(argv)
 	ROCKET_UNUSED(argv);
 	ROCKET_UNUSED(argv);
 #endif
 #endif
 
 
-#ifdef ROCKET_PLATFORM_LINUX
-#define APP_PATH "../Samples/invaders/"
-#else
-#define APP_PATH "../../Samples/invaders/"
-#endif
-
 #ifdef ROCKET_PLATFORM_WIN32
 #ifdef ROCKET_PLATFORM_WIN32
 	AllocConsole();
 	AllocConsole();
 #endif
 #endif
@@ -89,7 +84,7 @@ int main(int ROCKET_UNUSED_PARAMETER(argc), char** ROCKET_UNUSED_PARAMETER(argv)
 	shell_renderer = &opengl_renderer;
 	shell_renderer = &opengl_renderer;
 
 
 	// Generic OS initialisation, creates a window and attaches OpenGL.
 	// Generic OS initialisation, creates a window and attaches OpenGL.
-	if (!Shell::Initialise(APP_PATH) ||
+	if (!Shell::Initialise() ||
 		!Shell::OpenWindow("Rocket Invaders from Mars", shell_renderer, window_width, window_height, false))
 		!Shell::OpenWindow("Rocket Invaders from Mars", shell_renderer, window_width, window_height, false))
 	{
 	{
 		Shell::Shutdown();
 		Shell::Shutdown();
@@ -122,7 +117,7 @@ int main(int ROCKET_UNUSED_PARAMETER(argc), char** ROCKET_UNUSED_PARAMETER(argv)
 	shell_renderer->SetContext(context);
 	shell_renderer->SetContext(context);
 
 
 	// Load the font faces required for Invaders.
 	// Load the font faces required for Invaders.
-	Shell::LoadFonts("../assets/");
+	Shell::LoadFonts("assets/");
 
 
 	// Register Invader's custom element and decorator instancers.
 	// Register Invader's custom element and decorator instancers.
 	Rocket::Core::ElementInstancer* element_instancer = new Rocket::Core::ElementInstancerGeneric< ElementGame >();
 	Rocket::Core::ElementInstancer* element_instancer = new Rocket::Core::ElementInstancerGeneric< ElementGame >();

+ 1 - 1
Samples/luainvaders/data/game.rml

@@ -98,7 +98,7 @@ Game = Game or {} --namespace for functions
 
 
 function Game.OnKeyDown(event, document)
 function Game.OnKeyDown(event, document)
 	if event.parameters['key_identifier'] == rocket.key_identifier.ESCAPE then
 	if event.parameters['key_identifier'] == rocket.key_identifier.ESCAPE then
-		document.context:LoadDocument('data/pause.rml'):Show()
+		document.context:LoadDocument('luainvaders/data/pause.rml'):Show()
     end
     end
 end
 end
 		</script>
 		</script>

+ 2 - 2
Samples/luainvaders/data/main_menu.rml

@@ -28,8 +28,8 @@ function MainMenu.CloseLogo(document)
 end
 end
 		</script>
 		</script>
 	</head>
 	</head>
-	<body template="luawindow" onload="Window.OnWindowLoad(document) document.context:LoadDocument('data/logo.rml'):Show()" onunload="MainMenu.CloseLogo(document)">
-		<button onclick="document.context:LoadDocument('data/start_game.rml'):Show() document:Close()">Start Game</button><br />
+	<body template="luawindow" onload="Window.OnWindowLoad(document) document.context:LoadDocument('luainvaders/data/logo.rml'):Show()" onunload="MainMenu.CloseLogo(document)">
+		<button onclick="document.context:LoadDocument('luainvaders/data/start_game.rml'):Show() document:Close()">Start Game</button><br />
 		<button onclick="Window.LoadMenu('high_score',document)">High Scores</button><br />
 		<button onclick="Window.LoadMenu('high_score',document)">High Scores</button><br />
 		<button onclick="Window.LoadMenu('options',document)">Options</button><br />
 		<button onclick="Window.LoadMenu('options',document)">Options</button><br />
 		<button onclick="Window.LoadMenu('help',document)">Help</button><br />
 		<button onclick="Window.LoadMenu('help',document)">Help</button><br />

+ 1 - 1
Samples/luainvaders/data/window.rml

@@ -9,7 +9,7 @@ function Window.OnWindowLoad(document)
 end
 end
 	
 	
 function Window.LoadMenu(name,document)
 function Window.LoadMenu(name,document)
-	local doc = document.context:LoadDocument('data/' .. name .. '.rml')
+	local doc = document.context:LoadDocument('luainvaders/data/' .. name .. '.rml')
 	if doc then
 	if doc then
 		doc:Show()
 		doc:Show()
 		document:Close()
 		document:Close()

+ 2 - 2
Samples/luainvaders/lua/start.lua

@@ -33,8 +33,8 @@ Formatters["ship"] = DataFormatter.new("ship",SecondFormatData)
 
 
 function Startup()
 function Startup()
 	maincontext = rocket.contexts["main"]
 	maincontext = rocket.contexts["main"]
-	maincontext:LoadDocument("data/background.rml"):Show()
-	maincontext:LoadDocument("data/main_menu.rml"):Show()
+	maincontext:LoadDocument("luainvaders/data/background.rml"):Show()
+	maincontext:LoadDocument("luainvaders/data/main_menu.rml"):Show()
 end
 end
 
 
 Startup()
 Startup()

+ 1 - 1
Samples/luainvaders/src/Game.cpp

@@ -80,7 +80,7 @@ Game::Game()
 
 
 	// Use the OpenGL render interface to load our texture.
 	// Use the OpenGL render interface to load our texture.
 	Rocket::Core::Vector2i texture_dimensions;
 	Rocket::Core::Vector2i texture_dimensions;
-	Rocket::Core::GetRenderInterface()->LoadTexture(texture, texture_dimensions, "data/invaders.tga");
+	Rocket::Core::GetRenderInterface()->LoadTexture(texture, texture_dimensions, "luainvaders/data/invaders.tga");
 
 
 	defender = new Defender(this);
 	defender = new Defender(this);
 }
 }

+ 4 - 8
Samples/luainvaders/src/main.cpp

@@ -32,6 +32,7 @@
 
 
 #include <Input.h>
 #include <Input.h>
 #include <Shell.h>
 #include <Shell.h>
+#include <ShellRenderInterfaceOpenGL.h>
 #include "DecoratorInstancerDefender.h"
 #include "DecoratorInstancerDefender.h"
 #include "DecoratorInstancerStarfield.h"
 #include "DecoratorInstancerStarfield.h"
 #include "ElementGame.h"
 #include "ElementGame.h"
@@ -62,11 +63,6 @@ int APIENTRY WinMain(HINSTANCE, HINSTANCE, char*, int)
 int main(int, char**)
 int main(int, char**)
 #endif
 #endif
 {
 {
-#ifdef ROCKET_PLATFORM_LINUX
-#define APP_PATH "../Samples/luainvaders/"
-#else
-#define APP_PATH "../../Samples/luainvaders/"
-#endif
 
 
 #ifdef ROCKET_PLATFORM_WIN32
 #ifdef ROCKET_PLATFORM_WIN32
 	DoAllocConsole();
 	DoAllocConsole();
@@ -79,7 +75,7 @@ int main(int, char**)
 	shell_renderer = &opengl_renderer;
 	shell_renderer = &opengl_renderer;
 
 
 	// Generic OS initialisation, creates a window and attaches OpenGL.
 	// Generic OS initialisation, creates a window and attaches OpenGL.
-	if (!Shell::Initialise(APP_PATH) ||
+	if (!Shell::Initialise() ||
 		!Shell::OpenWindow("Rocket Invaders from Mars (Lua Powered)", shell_renderer, window_width, window_height, false))
 		!Shell::OpenWindow("Rocket Invaders from Mars (Lua Powered)", shell_renderer, window_width, window_height, false))
 	{
 	{
 		Shell::Shutdown();
 		Shell::Shutdown();
@@ -115,7 +111,7 @@ int main(int, char**)
 	shell_renderer->SetContext(context);
 	shell_renderer->SetContext(context);
 
 
 	// Load the font faces required for Invaders.
 	// Load the font faces required for Invaders.
-	Shell::LoadFonts("../assets/");
+	Shell::LoadFonts("assets/");
 
 
 	// Register Invader's custom decorator instancers.
 	// Register Invader's custom decorator instancers.
 	Rocket::Core::DecoratorInstancer* decorator_instancer = new DecoratorInstancerStarfield();
 	Rocket::Core::DecoratorInstancer* decorator_instancer = new DecoratorInstancerStarfield();
@@ -131,7 +127,7 @@ int main(int, char**)
 
 
 	// Fire off the startup script.
 	// Fire off the startup script.
     LuaInterface::Initialise(Rocket::Core::Lua::Interpreter::GetLuaState()); //the tables/functions defined in the samples
     LuaInterface::Initialise(Rocket::Core::Lua::Interpreter::GetLuaState()); //the tables/functions defined in the samples
-    Rocket::Core::Lua::Interpreter::LoadFile(Rocket::Core::String("lua/start.lua"));
+    Rocket::Core::Lua::Interpreter::LoadFile(Rocket::Core::String("luainvaders/lua/start.lua"));
 
 
 	Shell::EventLoop(GameLoop);	
 	Shell::EventLoop(GameLoop);	
 
 

+ 5 - 14
Samples/shell/include/Shell.h

@@ -31,13 +31,7 @@
 #include <Rocket/Core/Types.h>
 #include <Rocket/Core/Types.h>
 #include <Rocket/Core/Context.h>
 #include <Rocket/Core/Context.h>
 #include <Rocket/Core/SystemInterface.h>
 #include <Rocket/Core/SystemInterface.h>
-#include <ShellRenderInterfaceExtensions.h>
-
-#ifdef ROCKET_PLATFORM_WIN32
-#define PATH_SEPARATOR	";"
-#else
-#define PATH_SEPARATOR	":"
-#endif
+#include "ShellRenderInterfaceExtensions.h"
 
 
 /**
 /**
 	Shell functions for creating windows, attaching OpenGL and handling input in a platform independent way.
 	Shell functions for creating windows, attaching OpenGL and handling input in a platform independent way.
@@ -48,17 +42,16 @@ class Shell
 {
 {
 public:
 public:
 	/// Initialise the shell.
 	/// Initialise the shell.
-	/// @param[in] path The path (relative to the current working directory) of the application's working directory.
-	static bool Initialise(const Rocket::Core::String& path);
+	static bool Initialise();
 	/// Shutdown the shell.
 	/// Shutdown the shell.
 	static void Shutdown();
 	static void Shutdown();
 
 
+	/// Finds the Samples root directory.
+	static Rocket::Core::String FindSamplesRoot();
+	
 	/// Loads the default fonts from the given path.
 	/// Loads the default fonts from the given path.
 	static void LoadFonts(const char* directory);
 	static void LoadFonts(const char* directory);
 
 
-	/// Returns the path to the application's executable.
-	static const Rocket::Core::String& GetExecutablePath();
-
 	/// Open a platform specific window, optionally initialising an OpenGL context on it.
 	/// Open a platform specific window, optionally initialising an OpenGL context on it.
 	/// @param[in] title Title of the window.
 	/// @param[in] title Title of the window.
 	/// @param[in] srie Provides the interface for attaching a renderer to the window and performing related bits of interface.
 	/// @param[in] srie Provides the interface for attaching a renderer to the window and performing related bits of interface.
@@ -87,11 +80,9 @@ public:
 	static void SetContext(Rocket::Core::Context* context);
 	static void SetContext(Rocket::Core::Context* context);
 
 
 private:
 private:
-	static Rocket::Core::String executable_path;
 	static Rocket::Core::Context* context;
 	static Rocket::Core::Context* context;
 };
 };
 
 
-#include "ShellRenderInterfaceOpenGL.h"
 #include "ShellSystemInterface.h"
 #include "ShellSystemInterface.h"
 
 
 #endif
 #endif

+ 7 - 0
Samples/shell/include/ShellOpenGL.h

@@ -50,6 +50,13 @@
 #ifdef None
 #ifdef None
   #undef None
   #undef None
 #endif
 #endif
+
+struct __X11NativeWindowData
+{
+	Window window;
+	Display *display;
+	XVisualInfo *visual_info;
+};
 #endif
 #endif
 
 
 #endif
 #endif

+ 0 - 9
Samples/shell/include/ShellRenderInterfaceOpenGL.h

@@ -36,15 +36,6 @@
 	@author Peter Curry
 	@author Peter Curry
  */
  */
 
 
-#if defined(ROCKET_PLATFORM_LINUX)
-struct __X11NativeWindowData
-{
-	Window window;
-	Display *display;
-	XVisualInfo *visual_info;
-};
-#endif
-
 class ShellRenderInterfaceOpenGL : public Rocket::Core::RenderInterface,  public ShellRenderInterfaceExtensions
 class ShellRenderInterfaceOpenGL : public Rocket::Core::RenderInterface,  public ShellRenderInterfaceExtensions
 {
 {
 public:
 public:

+ 0 - 8
Samples/shell/src/Shell.cpp

@@ -28,8 +28,6 @@
 #include "Shell.h"
 #include "Shell.h"
 #include <Rocket/Core/FontDatabase.h>
 #include <Rocket/Core/FontDatabase.h>
 
 
-Rocket::Core::String Shell::executable_path;
-
 /// Loads the default fonts from the given path.
 /// Loads the default fonts from the given path.
 void Shell::LoadFonts(const char* directory)
 void Shell::LoadFonts(const char* directory)
 {
 {
@@ -45,9 +43,3 @@ void Shell::LoadFonts(const char* directory)
 	}
 	}
 }
 }
 
 
-// Returns the path to the application's executable.
-const Rocket::Core::String& Shell::GetExecutablePath()
-{
-	return executable_path;
-}
-

+ 21 - 12
Samples/shell/src/macosx/ShellMacOSX.cpp

@@ -59,12 +59,30 @@ ShellFileInterface* file_interface = NULL;
 static void IdleTimerCallback(EventLoopTimerRef timer, EventLoopIdleTimerMessage inState, void* p);
 static void IdleTimerCallback(EventLoopTimerRef timer, EventLoopIdleTimerMessage inState, void* p);
 static OSStatus EventHandler(EventHandlerCallRef next_handler, EventRef event, void* p);
 static OSStatus EventHandler(EventHandlerCallRef next_handler, EventRef event, void* p);
 
 
-bool Shell::Initialise(const Rocket::Core::String& path)
+bool Shell::Initialise()
 {
 {
 	gettimeofday(&start_time, NULL);
 	gettimeofday(&start_time, NULL);
 
 
 	InputMacOSX::Initialise();
 	InputMacOSX::Initialise();
 
 
+	Rocket::Core::String root = FindSamplesRoot();
+
+	file_interface = new ShellFileInterface(root);
+	Rocket::Core::SetFileInterface(file_interface);
+
+	return true;
+}
+
+void Shell::Shutdown()
+{
+	delete file_interface;
+	file_interface = NULL;
+}
+
+Rocket::Core::String Shell::FindSamplesRoot()
+{
+	Rocket::Core::String path = "../../Samples/";
+	
 	// Find the location of the executable.
 	// Find the location of the executable.
 	CFBundleRef bundle = CFBundleGetMainBundle();
 	CFBundleRef bundle = CFBundleGetMainBundle();
 	CFURLRef executable_url = CFBundleCopyExecutableURL(bundle);
 	CFURLRef executable_url = CFBundleCopyExecutableURL(bundle);
@@ -74,23 +92,14 @@ bool Shell::Initialise(const Rocket::Core::String& path)
 	if (!CFStringGetFileSystemRepresentation(executable_posix_file_name, executable_file_name, max_length))
 	if (!CFStringGetFileSystemRepresentation(executable_posix_file_name, executable_file_name, max_length))
 		executable_file_name[0] = 0;
 		executable_file_name[0] = 0;
 
 
-	executable_path = Rocket::Core::String(executable_file_name);
+	Rocket::Core::String executable_path = Rocket::Core::String(executable_file_name);
 	executable_path = executable_path.Substring(0, executable_path.RFind("/") + 1);
 	executable_path = executable_path.Substring(0, executable_path.RFind("/") + 1);
 
 
 	delete[] executable_file_name;
 	delete[] executable_file_name;
 	CFRelease(executable_posix_file_name);
 	CFRelease(executable_posix_file_name);
 	CFRelease(executable_url);
 	CFRelease(executable_url);
 
 
-	file_interface = new ShellFileInterface(executable_path + "../../../" + path);
-	Rocket::Core::SetFileInterface(file_interface);
-
-	return true;
-}
-
-void Shell::Shutdown()
-{
-	delete file_interface;
-	file_interface = NULL;
+	return (executable_path + "../../../" + path);
 }
 }
 
 
 static ShellRenderInterfaceExtensions *shell_renderer;
 static ShellRenderInterfaceExtensions *shell_renderer;

+ 22 - 10
Samples/shell/src/win32/ShellWin32.cpp

@@ -45,7 +45,7 @@ static LARGE_INTEGER time_startup;
 
 
 static ShellFileInterface* file_interface = NULL;
 static ShellFileInterface* file_interface = NULL;
 
 
-bool Shell::Initialise(const Rocket::Core::String& path)
+bool Shell::Initialise()
 {
 {
 	instance_handle = GetModuleHandle(NULL);
 	instance_handle = GetModuleHandle(NULL);
 	InputWin32::Initialise();
 	InputWin32::Initialise();
@@ -56,15 +56,9 @@ bool Shell::Initialise(const Rocket::Core::String& path)
 
 
 	time_frequency = 1.0 / (double) time_ticks_per_second.QuadPart;
 	time_frequency = 1.0 / (double) time_ticks_per_second.QuadPart;
 
 
-	// Fetch the path of the executable, append the path onto that.
-	char executable_file_name[MAX_PATH];
-	if (GetModuleFileNameA(instance_handle, executable_file_name, MAX_PATH) >= MAX_PATH &&
-		GetLastError() == ERROR_INSUFFICIENT_BUFFER)
-		executable_file_name[0] = 0;
-
-	executable_path = Rocket::Core::String(executable_file_name);
-	executable_path = executable_path.Substring(0, executable_path.RFind("\\") + 1);
-	file_interface = new ShellFileInterface(executable_path + path);
+	Rocket::Core::String root = FindSamplesRoot();
+	
+	file_interface = new ShellFileInterface(root);
 	Rocket::Core::SetFileInterface(file_interface);
 	Rocket::Core::SetFileInterface(file_interface);
 
 
 	return true;
 	return true;
@@ -78,6 +72,24 @@ void Shell::Shutdown()
 	file_interface = NULL;
 	file_interface = NULL;
 }
 }
 
 
+Rocket::Core::String Shell::FindSamplesRoot()
+{
+	Rocket::Core::String path = "../../Samples/";
+	
+	// Fetch the path of the executable, append the path onto that.
+	char executable_file_name[MAX_PATH];
+	if (GetModuleFileNameA(instance_handle, executable_file_name, MAX_PATH) >= MAX_PATH &&
+		GetLastError() == ERROR_INSUFFICIENT_BUFFER)
+	{
+		executable_file_name[0] = 0;
+	}
+
+	Rocket::Core::String executable_path = Rocket::Core::String(executable_file_name);
+	executable_path = executable_path.Substring(0, executable_path.RFind("\\") + 1);
+	
+	return executable_path + path;
+}
+
 static ShellRenderInterfaceExtensions *shell_renderer = NULL;
 static ShellRenderInterfaceExtensions *shell_renderer = NULL;
 bool Shell::OpenWindow(const char* name, ShellRenderInterfaceExtensions *_shell_renderer, unsigned int width, unsigned int height, bool allow_resize)
 bool Shell::OpenWindow(const char* name, ShellRenderInterfaceExtensions *_shell_renderer, unsigned int width, unsigned int height, bool allow_resize)
 {
 {

+ 41 - 2
Samples/shell/src/x11/ShellX11.cpp

@@ -26,6 +26,7 @@
  */
  */
 
 
 #include <Shell.h>
 #include <Shell.h>
+#include <ShellOpenGL.h>
 #include <Rocket/Core.h>
 #include <Rocket/Core.h>
 #include "ShellFileInterface.h"
 #include "ShellFileInterface.h"
 #include <x11/InputX11.h>
 #include <x11/InputX11.h>
@@ -36,6 +37,8 @@
 #include <time.h>
 #include <time.h>
 #include <unistd.h>
 #include <unistd.h>
 #include <stdio.h>
 #include <stdio.h>
+#include <sys/stat.h>
+#include <limits.h>
 
 
 static bool running = false;
 static bool running = false;
 static int screen = -1;
 static int screen = -1;
@@ -43,12 +46,20 @@ static timeval start_time;
 
 
 static ShellFileInterface* file_interface = NULL;
 static ShellFileInterface* file_interface = NULL;
 
 
-bool Shell::Initialise(const Rocket::Core::String& path)
+static bool isDirectory(const Rocket::Core::String &path)
+{
+	struct stat sb;
+	return (stat(path.CString(), &sb)==0 && S_ISDIR(sb.st_mode));
+}
+
+bool Shell::Initialise()
 {
 {
 	gettimeofday(&start_time, NULL);
 	gettimeofday(&start_time, NULL);
 	InputX11::Initialise();
 	InputX11::Initialise();
 
 
-	file_interface = new ShellFileInterface(path);
+	Rocket::Core::String root = FindSamplesRoot();
+
+	file_interface = new ShellFileInterface(root);
 	Rocket::Core::SetFileInterface(file_interface);
 	Rocket::Core::SetFileInterface(file_interface);
 
 
 	return true;
 	return true;
@@ -62,6 +73,34 @@ void Shell::Shutdown()
 	file_interface = NULL;
 	file_interface = NULL;
 }
 }
 
 
+Rocket::Core::String Shell::FindSamplesRoot()
+{
+	char executable_file_name[PATH_MAX];
+	ssize_t len = readlink("/proc/self/exe", executable_file_name, PATH_MAX);
+	if (len == -1) {
+		printf("Unable to determine the executable path!\n");
+		executable_file_name[0] = 0;
+	} else {
+		// readlink() does not append a null byte to buf.
+		executable_file_name[len] = 0;
+	}
+	Rocket::Core::String executable_path = Rocket::Core::String(executable_file_name);
+	executable_path = executable_path.Substring(0, executable_path.RFind("/") + 1);
+	
+	// for "../Samples/" to be valid we must be in the Build directory.
+	// NOTE: we can't use "../../Samples/" because it is valid only if:
+	//  1. we are in the installation directory and
+	//  2. the installation directory is exactly "Samples" (case sensitive).
+	Rocket::Core::String path = "../Samples/";
+	
+	if(!isDirectory(executable_path + path)) {
+		// we probably are in the installation directory, up by 1 should do.
+		path = "../";
+	}
+	
+	return (executable_path + path);
+}
+
 static Display* display = NULL;
 static Display* display = NULL;
 static XVisualInfo* visual_info = NULL;
 static XVisualInfo* visual_info = NULL;
 static Window window = 0;
 static Window window = 0;

+ 0 - 0
Samples/tutorial/datagrid/high_score.txt → Samples/tutorial/datagrid/data/high_score.txt


+ 1 - 1
Samples/tutorial/datagrid/src/HighScores.cpp

@@ -73,7 +73,7 @@ void HighScores::LoadScores()
 {
 {
 	// Open and read the high score file.
 	// Open and read the high score file.
 	Rocket::Core::FileInterface* file_interface = Rocket::Core::GetFileInterface();
 	Rocket::Core::FileInterface* file_interface = Rocket::Core::GetFileInterface();
-	Rocket::Core::FileHandle scores_file = file_interface->Open("high_score.txt");
+	Rocket::Core::FileHandle scores_file = file_interface->Open("tutorial/datagrid/data/high_score.txt");
 	
 	
 	if (scores_file)
 	if (scores_file)
 	{
 	{

+ 4 - 9
Samples/tutorial/datagrid/src/main.cpp

@@ -14,6 +14,7 @@
 #include <Rocket/Debugger.h>
 #include <Rocket/Debugger.h>
 #include <Input.h>
 #include <Input.h>
 #include <Shell.h>
 #include <Shell.h>
+#include <ShellRenderInterfaceOpenGL.h>
 #include "DecoratorInstancerDefender.h"
 #include "DecoratorInstancerDefender.h"
 #include "HighScores.h"
 #include "HighScores.h"
 
 
@@ -47,12 +48,6 @@ int main(int ROCKET_UNUSED_PARAMETER(argc), char** ROCKET_UNUSED_PARAMETER(argv)
 	ROCKET_UNUSED(argv);
 	ROCKET_UNUSED(argv);
 #endif
 #endif
 
 
-#ifdef ROCKET_PLATFORM_LINUX
-#define APP_PATH "../Samples/tutorial/datagrid/"
-#else
-#define APP_PATH "../../Samples/tutorial/datagrid/"
-#endif
-
 #ifdef ROCKET_PLATFORM_WIN32
 #ifdef ROCKET_PLATFORM_WIN32
         AllocConsole();
         AllocConsole();
 #endif
 #endif
@@ -61,7 +56,7 @@ int main(int ROCKET_UNUSED_PARAMETER(argc), char** ROCKET_UNUSED_PARAMETER(argv)
 	shell_renderer = &opengl_renderer;
 	shell_renderer = &opengl_renderer;
 
 
 	// Generic OS initialisation, creates a window and attaches OpenGL.
 	// Generic OS initialisation, creates a window and attaches OpenGL.
-	if (!Shell::Initialise(APP_PATH) ||
+	if (!Shell::Initialise() ||
 		!Shell::OpenWindow("Datagrid Tutorial", shell_renderer, 1024, 768, true))
 		!Shell::OpenWindow("Datagrid Tutorial", shell_renderer, 1024, 768, true))
 	{
 	{
 		Shell::Shutdown();
 		Shell::Shutdown();
@@ -91,7 +86,7 @@ int main(int ROCKET_UNUSED_PARAMETER(argc), char** ROCKET_UNUSED_PARAMETER(argv)
 	Input::SetContext(context);
 	Input::SetContext(context);
 	shell_renderer->SetContext(context);
 	shell_renderer->SetContext(context);
 
 
-	Shell::LoadFonts("../../assets/");
+	Shell::LoadFonts("assets/");
 
 
 	// Load the defender decorator.
 	// Load the defender decorator.
 	Rocket::Core::DecoratorInstancer* decorator_instancer = Rocket::Core::Factory::RegisterDecoratorInstancer("defender", new DecoratorInstancerDefender());
 	Rocket::Core::DecoratorInstancer* decorator_instancer = Rocket::Core::Factory::RegisterDecoratorInstancer("defender", new DecoratorInstancerDefender());
@@ -102,7 +97,7 @@ int main(int ROCKET_UNUSED_PARAMETER(argc), char** ROCKET_UNUSED_PARAMETER(argv)
 	HighScores::Initialise();
 	HighScores::Initialise();
 
 
 	// Load and show the tutorial document.
 	// Load and show the tutorial document.
-	Rocket::Core::ElementDocument* document = context->LoadDocument("data/tutorial.rml");
+	Rocket::Core::ElementDocument* document = context->LoadDocument("tutorial/datagrid/data/tutorial.rml");
 	document->GetElementById("title")->SetInnerRML(document->GetTitle());
 	document->GetElementById("title")->SetInnerRML(document->GetTitle());
 	if (document != NULL)
 	if (document != NULL)
 	{
 	{

+ 0 - 0
Samples/tutorial/datagrid_tree/high_score.txt → Samples/tutorial/datagrid_tree/data/high_score.txt


+ 1 - 1
Samples/tutorial/datagrid_tree/src/HighScores.cpp

@@ -126,7 +126,7 @@ void HighScores::LoadScores()
 {
 {
 	// Open and read the high score file.
 	// Open and read the high score file.
 	Rocket::Core::FileInterface* file_interface = Rocket::Core::GetFileInterface();
 	Rocket::Core::FileInterface* file_interface = Rocket::Core::GetFileInterface();
-	Rocket::Core::FileHandle scores_file = file_interface->Open("high_score.txt");
+	Rocket::Core::FileHandle scores_file = file_interface->Open("tutorial/datagrid_tree/data/high_score.txt");
 	
 	
 	if (scores_file)
 	if (scores_file)
 	{
 	{

+ 4 - 9
Samples/tutorial/datagrid_tree/src/main.cpp

@@ -14,6 +14,7 @@
 #include <Rocket/Debugger.h>
 #include <Rocket/Debugger.h>
 #include <Input.h>
 #include <Input.h>
 #include <Shell.h>
 #include <Shell.h>
+#include <ShellRenderInterfaceOpenGL.h>
 #include "DecoratorInstancerDefender.h"
 #include "DecoratorInstancerDefender.h"
 #include "HighScores.h"
 #include "HighScores.h"
 #include "HighScoresShipFormatter.h"
 #include "HighScoresShipFormatter.h"
@@ -48,12 +49,6 @@ int main(int ROCKET_UNUSED_PARAMETER(argc), char** ROCKET_UNUSED_PARAMETER(argv)
 	ROCKET_UNUSED(argv);
 	ROCKET_UNUSED(argv);
 #endif
 #endif
 
 
-#ifdef ROCKET_PLATFORM_LINUX
-#define APP_PATH "../Samples/tutorial/datagrid_tree/"
-#else
-#define APP_PATH "../../Samples/tutorial/datagrid_tree/"
-#endif
-
 #ifdef ROCKET_PLATFORM_WIN32
 #ifdef ROCKET_PLATFORM_WIN32
         AllocConsole();
         AllocConsole();
 #endif
 #endif
@@ -65,7 +60,7 @@ int main(int ROCKET_UNUSED_PARAMETER(argc), char** ROCKET_UNUSED_PARAMETER(argv)
 	shell_renderer = &opengl_renderer;
 	shell_renderer = &opengl_renderer;
 
 
 	// Generic OS initialisation, creates a window and attaches OpenGL.
 	// Generic OS initialisation, creates a window and attaches OpenGL.
-	if (!Shell::Initialise(APP_PATH) ||
+	if (!Shell::Initialise() ||
 		!Shell::OpenWindow("Datagrid Tree Tutorial", shell_renderer, window_width, window_height, true))
 		!Shell::OpenWindow("Datagrid Tree Tutorial", shell_renderer, window_width, window_height, true))
 	{
 	{
 		Shell::Shutdown();
 		Shell::Shutdown();
@@ -95,7 +90,7 @@ int main(int ROCKET_UNUSED_PARAMETER(argc), char** ROCKET_UNUSED_PARAMETER(argv)
 	Input::SetContext(context);
 	Input::SetContext(context);
 	shell_renderer->SetContext(context);
 	shell_renderer->SetContext(context);
 
 
-	Shell::LoadFonts("../../assets/");
+	Shell::LoadFonts("assets/");
 
 
 	// Load the defender decorator.
 	// Load the defender decorator.
 	Rocket::Core::DecoratorInstancer* decorator_instancer = Rocket::Core::Factory::RegisterDecoratorInstancer("defender", new DecoratorInstancerDefender());
 	Rocket::Core::DecoratorInstancer* decorator_instancer = Rocket::Core::Factory::RegisterDecoratorInstancer("defender", new DecoratorInstancerDefender());
@@ -109,7 +104,7 @@ int main(int ROCKET_UNUSED_PARAMETER(argc), char** ROCKET_UNUSED_PARAMETER(argv)
 	HighScores::Initialise();
 	HighScores::Initialise();
 
 
 	// Load and show the tutorial document.
 	// Load and show the tutorial document.
-	Rocket::Core::ElementDocument* document = context->LoadDocument("data/tutorial.rml");
+	Rocket::Core::ElementDocument* document = context->LoadDocument("tutorial/datagrid_tree/data/tutorial.rml");
 	document->GetElementById("title")->SetInnerRML(document->GetTitle());
 	document->GetElementById("title")->SetInnerRML(document->GetTitle());
 	if (document != NULL)
 	if (document != NULL)
 	{
 	{

+ 4 - 9
Samples/tutorial/template/src/main.cpp

@@ -13,6 +13,7 @@
 #include <Rocket/Debugger.h>
 #include <Rocket/Debugger.h>
 #include <Input.h>
 #include <Input.h>
 #include <Shell.h>
 #include <Shell.h>
+#include <ShellRenderInterfaceOpenGL.h>
 
 
 Rocket::Core::Context* context = NULL;
 Rocket::Core::Context* context = NULL;
 
 
@@ -44,12 +45,6 @@ int main(int ROCKET_UNUSED_PARAMETER(argc), char** ROCKET_UNUSED_PARAMETER(argv)
 	ROCKET_UNUSED(argv);
 	ROCKET_UNUSED(argv);
 #endif
 #endif
 
 
-#ifdef ROCKET_PLATFORM_LINUX
-#define APP_PATH "../Samples/tutorial/template/"
-#else
-#define APP_PATH "../../Samples/tutorial/template/"
-#endif
-
 #ifdef ROCKET_PLATFORM_WIN32
 #ifdef ROCKET_PLATFORM_WIN32
         AllocConsole();
         AllocConsole();
 #endif
 #endif
@@ -61,7 +56,7 @@ int main(int ROCKET_UNUSED_PARAMETER(argc), char** ROCKET_UNUSED_PARAMETER(argv)
 	shell_renderer = &opengl_renderer;
 	shell_renderer = &opengl_renderer;
 
 
 	// Generic OS initialisation, creates a window and attaches OpenGL.
 	// Generic OS initialisation, creates a window and attaches OpenGL.
-	if (!Shell::Initialise(APP_PATH) ||
+	if (!Shell::Initialise() ||
 		!Shell::OpenWindow("Template Tutorial", shell_renderer, window_width, window_height, true))
 		!Shell::OpenWindow("Template Tutorial", shell_renderer, window_width, window_height, true))
 	{
 	{
 		Shell::Shutdown();
 		Shell::Shutdown();
@@ -90,10 +85,10 @@ int main(int ROCKET_UNUSED_PARAMETER(argc), char** ROCKET_UNUSED_PARAMETER(argv)
 	Input::SetContext(context);
 	Input::SetContext(context);
 	shell_renderer->SetContext(context);
 	shell_renderer->SetContext(context);
 
 
-	Shell::LoadFonts("../../assets/");
+	Shell::LoadFonts("assets/");
 
 
 	// Load and show the tutorial document.
 	// Load and show the tutorial document.
-	Rocket::Core::ElementDocument* document = context->LoadDocument("data/tutorial.rml");
+	Rocket::Core::ElementDocument* document = context->LoadDocument("tutorial/template/data/tutorial.rml");
 	if (document != NULL)
 	if (document != NULL)
 	{
 	{
 		document->Show();
 		document->Show();

+ 1 - 1
Samples/tutorial/tutorial_drag/src/Inventory.cpp

@@ -4,7 +4,7 @@
 // Constructs a new inventory and opens its window.
 // Constructs a new inventory and opens its window.
 Inventory::Inventory(const Rocket::Core::String& title, const Rocket::Core::Vector2f& position, Rocket::Core::Context* context)
 Inventory::Inventory(const Rocket::Core::String& title, const Rocket::Core::Vector2f& position, Rocket::Core::Context* context)
 {
 {
-	document = context->LoadDocument("data/inventory.rml");
+	document = context->LoadDocument("tutorial/tutorial_drag/data/inventory.rml");
 	if (document != NULL)
 	if (document != NULL)
 	{
 	{
 		document->GetElementById("title")->SetInnerRML(title);
 		document->GetElementById("title")->SetInnerRML(title);

+ 3 - 8
Samples/tutorial/tutorial_drag/src/main.cpp

@@ -13,6 +13,7 @@
 #include <Rocket/Debugger.h>
 #include <Rocket/Debugger.h>
 #include <Input.h>
 #include <Input.h>
 #include <Shell.h>
 #include <Shell.h>
+#include <ShellRenderInterfaceOpenGL.h>
 #include "Inventory.h"
 #include "Inventory.h"
 
 
 Rocket::Core::Context* context = NULL;
 Rocket::Core::Context* context = NULL;
@@ -45,12 +46,6 @@ int main(int ROCKET_UNUSED_PARAMETER(argc), char** ROCKET_UNUSED_PARAMETER(argv)
 	ROCKET_UNUSED(argv);
 	ROCKET_UNUSED(argv);
 #endif
 #endif
 
 
-#ifdef ROCKET_PLATFORM_LINUX
-#define APP_PATH "../Samples/tutorial/tutorial_drag/"
-#else
-#define APP_PATH "../../Samples/tutorial/tutorial_drag/"
-#endif
-
 #ifdef ROCKET_PLATFORM_WIN32
 #ifdef ROCKET_PLATFORM_WIN32
         AllocConsole();
         AllocConsole();
 #endif
 #endif
@@ -62,7 +57,7 @@ int main(int ROCKET_UNUSED_PARAMETER(argc), char** ROCKET_UNUSED_PARAMETER(argv)
 	shell_renderer = &opengl_renderer;
 	shell_renderer = &opengl_renderer;
 
 
 	// Generic OS initialisation, creates a window and attaches OpenGL.
 	// Generic OS initialisation, creates a window and attaches OpenGL.
-	if (!Shell::Initialise(APP_PATH) ||
+	if (!Shell::Initialise() ||
 		!Shell::OpenWindow("Drag Tutorial", shell_renderer, window_width, window_height, true))
 		!Shell::OpenWindow("Drag Tutorial", shell_renderer, window_width, window_height, true))
 	{
 	{
 		Shell::Shutdown();
 		Shell::Shutdown();
@@ -91,7 +86,7 @@ int main(int ROCKET_UNUSED_PARAMETER(argc), char** ROCKET_UNUSED_PARAMETER(argv)
 	Input::SetContext(context);
 	Input::SetContext(context);
 	shell_renderer->SetContext(context);
 	shell_renderer->SetContext(context);
 
 
-	Shell::LoadFonts("../../assets/");
+	Shell::LoadFonts("assets/");
 
 
 	// Load and show the inventory document.
 	// Load and show the inventory document.
 	Inventory* inventory_1 = new Inventory("Inventory 1", Rocket::Core::Vector2f(50, 200), context);
 	Inventory* inventory_1 = new Inventory("Inventory 1", Rocket::Core::Vector2f(50, 200), context);