Browse Source

sys: add the base source directory to the list of search directories

on automake platforms, too.
legacy
Sam Hocevar sam 12 years ago
parent
commit
7e8edd7c3e
5 changed files with 40 additions and 11 deletions
  1. +1
    -1
      configure.ac
  2. +2
    -2
      src/debug/fps.cpp
  3. +6
    -1
      src/lol/sys/init.h
  4. +28
    -4
      src/sys/init.cpp
  5. +3
    -3
      tutorial/11_fractal.cpp

+ 1
- 1
configure.ac View File

@@ -378,7 +378,7 @@ LOL_DEPENDENCIES="${LOL_DEPENDENCIES} \$(top_builddir)/src/bullet/liblolbullet.a


dnl How to use the Lol Engine inside this tree dnl How to use the Lol Engine inside this tree
AM_CPPFLAGS="${AM_CPPFLAGS} -I\$(top_srcdir)/src" AM_CPPFLAGS="${AM_CPPFLAGS} -I\$(top_srcdir)/src"
AM_CPPFLAGS="${AM_CPPFLAGS} -DLOL_SOURCE_SUBDIR=\\\"\$(subdir)\\\""
AM_CPPFLAGS="${AM_CPPFLAGS} -DLOL_CONFIG_SOURCESUBDIR=\\\"\$(subdir)\\\""
AM_CPPFLAGS="${AM_CPPFLAGS} ${LOL_CFLAGS}" AM_CPPFLAGS="${AM_CPPFLAGS} ${LOL_CFLAGS}"
AM_LDFLAGS="${AM_LDFLAGS} ${LOL_DEPENDENCIES}" AM_LDFLAGS="${AM_LDFLAGS} ${LOL_DEPENDENCIES}"
AM_LDFLAGS="${AM_LDFLAGS} ${LOL_LIBS}" AM_LDFLAGS="${AM_LDFLAGS} ${LOL_LIBS}"


+ 2
- 2
src/debug/fps.cpp View File

@@ -44,12 +44,12 @@ DebugFps::DebugFps(int x, int y)
#if 0 #if 0
for (int i = 0; i < 5; i ++) for (int i = 0; i < 5; i ++)
{ {
data->lines[i] = new Text(NULL, "src/data/font/ascii.png");
data->lines[i] = new Text(NULL, "data/font/ascii.png");
data->lines[i]->SetPos(ivec3(x, y + (i ? 8 : 0) + 16 * i, 0)); data->lines[i]->SetPos(ivec3(x, y + (i ? 8 : 0) + 16 * i, 0));
Ticker::Ref(data->lines[i]); Ticker::Ref(data->lines[i]);
} }
#else #else
data->lines[0] = new Text(NULL, "src/data/font/ascii.png");
data->lines[0] = new Text(NULL, "data/font/ascii.png");
data->lines[0]->SetPos(ivec3(x, y, 100)); data->lines[0]->SetPos(ivec3(x, y, 100));
Ticker::Ref(data->lines[0]); Ticker::Ref(data->lines[0]);
#endif #endif


+ 6
- 1
src/lol/sys/init.h View File

@@ -34,6 +34,10 @@ namespace lol
# define LOL_CONFIG_SOLUTIONDIR "" # define LOL_CONFIG_SOLUTIONDIR ""
#endif #endif


#if !defined LOL_CONFIG_SOURCESUBDIR
# define LOL_CONFIG_SOURCESUBDIR ""
#endif

/* /*
* System namespace. The platform-specific stuff in there makes the API * System namespace. The platform-specific stuff in there makes the API
* not as clean as the rest of the framework. * not as clean as the rest of the framework.
@@ -44,7 +48,8 @@ namespace System


extern void Init(int argc, char *argv[], extern void Init(int argc, char *argv[],
String const &projectdir = LOL_CONFIG_PROJECTDIR, String const &projectdir = LOL_CONFIG_PROJECTDIR,
String const &solutiondir = LOL_CONFIG_SOLUTIONDIR);
String const &solutiondir = LOL_CONFIG_SOLUTIONDIR,
String const &sourcesubdir = LOL_CONFIG_SOURCESUBDIR);


extern void AddDataDir(String const &dir); extern void AddDataDir(String const &dir);
extern Array<String> GetPathList(String const &file); extern Array<String> GetPathList(String const &file);


+ 28
- 4
src/sys/init.cpp View File

@@ -38,7 +38,9 @@ namespace System
static Array<String> data_dir; static Array<String> data_dir;


void Init(int argc, char *argv[], void Init(int argc, char *argv[],
String const &projectdir, String const &solutiondir)
String const &projectdir,
String const &solutiondir,
String const &sourcesubdir)
{ {
using namespace std; using namespace std;


@@ -76,10 +78,17 @@ void Init(int argc, char *argv[],
* assume it was. */ * assume it was. */
if (i) if (i)
{ {
String rootdir = projectdir;
String rootdir = solutiondir;
if (rootdir.Last() != SEPARATOR) if (rootdir.Last() != SEPARATOR)
rootdir += SEPARATOR; rootdir += SEPARATOR;
rootdir += "../../src/"; /* FIXME: use SEPARATOR? */
AddDataDir(rootdir); AddDataDir(rootdir);

rootdir = projectdir;
if (rootdir.Last() != SEPARATOR)
rootdir += SEPARATOR;
AddDataDir(rootdir);

got_rootdir = true; got_rootdir = true;
} }
break; break;
@@ -89,7 +98,22 @@ void Init(int argc, char *argv[],
/* If no rootdir found, use the executable location */ /* If no rootdir found, use the executable location */
if (!got_rootdir) if (!got_rootdir)
{ {
AddDataDir(binarydir);
String rootdir = binarydir;
if (rootdir.Last() != SEPARATOR)
rootdir += SEPARATOR;
for (int i = 1; i < sourcesubdir.Count(); ++i)
{
if ((sourcesubdir[i] == SEPARATOR
&& sourcesubdir[i - 1] != SEPARATOR)
|| i == sourcesubdir.Count() - 1)
rootdir += "../";
}
rootdir += "src/";
AddDataDir(rootdir);

rootdir = binarydir;
AddDataDir(rootdir);

got_rootdir = true; got_rootdir = true;
} }


@@ -113,7 +137,7 @@ Array<String> GetPathList(String const &file)
Array<String> ret; Array<String> ret;


for (int i = 0; i < data_dir.Count(); ++i) for (int i = 0; i < data_dir.Count(); ++i)
ret << data_dir[0] + file;
ret << data_dir[i] + file;


if (ret.Count() == 0) if (ret.Count() == 0)
ret << file; ret << file;


+ 3
- 3
tutorial/11_fractal.cpp View File

@@ -104,15 +104,15 @@ public:
} }


#if !defined __native_client__ #if !defined __native_client__
m_centertext = new Text(NULL, "src/data/font/ascii.png");
m_centertext = new Text(NULL, "data/font/ascii.png");
m_centertext->SetPos(ivec3(5, m_window_size.y - 15, 1)); m_centertext->SetPos(ivec3(5, m_window_size.y - 15, 1));
Ticker::Ref(m_centertext); Ticker::Ref(m_centertext);


m_mousetext = new Text(NULL, "src/data/font/ascii.png");
m_mousetext = new Text(NULL, "data/font/ascii.png");
m_mousetext->SetPos(ivec3(5, m_window_size.y - 29, 1)); m_mousetext->SetPos(ivec3(5, m_window_size.y - 29, 1));
Ticker::Ref(m_mousetext); Ticker::Ref(m_mousetext);


m_zoomtext = new Text(NULL, "src/data/font/ascii.png");
m_zoomtext = new Text(NULL, "data/font/ascii.png");
m_zoomtext->SetPos(ivec3(5, m_window_size.y - 43, 1)); m_zoomtext->SetPos(ivec3(5, m_window_size.y - 43, 1));
Ticker::Ref(m_zoomtext); Ticker::Ref(m_zoomtext);
#endif #endif


Loading…
Cancel
Save