Commit d08163d7 by Jamie Madill Committed by Commit Bot

Fix standalone build.

BUG=angleproject:1471 Change-Id: I52aadeb58f75d5b944421bd0cd4a5dddead3f6d1 Reviewed-on: https://chromium-review.googlesource.com/379916 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarYuly Novikov <ynovikov@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 70866b89
......@@ -84,8 +84,14 @@ class MultiTextureSample : public SampleApplication
mLightMapLoc = glGetUniformLocation(mProgram, "s_lightMap");
// Load the textures
mBaseMapTexID = loadTexture(angle::GetExecutableDirectory() + "/basemap.tga");
mLightMapTexID = loadTexture(angle::GetExecutableDirectory() + "/lightmap.tga");
std::stringstream baseStr;
baseStr << angle::GetExecutableDirectory() << "/basemap.tga";
std::stringstream lightStr;
lightStr << angle::GetExecutableDirectory() << "/lightmap.tga";
mBaseMapTexID = loadTexture(baseStr.str());
mLightMapTexID = loadTexture(lightStr.str());
if (mBaseMapTexID == 0 || mLightMapTexID == 0)
{
return false;
......
......@@ -49,15 +49,22 @@ class MultipleDrawBuffersSample : public SampleApplication
return false;
}
mMRTProgram = CompileProgramFromFiles(angle::GetExecutableDirectory() + "/multiple_draw_buffers_vs.glsl",
angle::GetExecutableDirectory() + "/multiple_draw_buffers_fs.glsl");
std::stringstream vsStream;
vsStream << angle::GetExecutableDirectory() << "/multiple_draw_buffers_vs.glsl";
std::stringstream fsStream;
fsStream << angle::GetExecutableDirectory() << "/multiple_draw_buffers_fs.glsl";
std::stringstream copyFsStream;
fsStream << angle::GetExecutableDirectory() << "/multiple_draw_buffers_copy_fs.glsl";
mMRTProgram = CompileProgramFromFiles(vsStream.str(), fsStream.str());
if (!mMRTProgram)
{
return false;
}
mCopyProgram = CompileProgramFromFiles(angle::GetExecutableDirectory() + "/multiple_draw_buffers_vs.glsl",
angle::GetExecutableDirectory() + "/multiple_draw_buffers_copy_fs.glsl");
mCopyProgram = CompileProgramFromFiles(vsStream.str(), copyFsStream.str());
if (!mCopyProgram)
{
return false;
......
......@@ -115,8 +115,11 @@ class ParticleSystemSample : public SampleApplication
mParticleTime = 1.0f;
std::stringstream smokeStr;
smokeStr << angle::GetExecutableDirectory() << "/smoke.tga";
TGAImage img;
if (!LoadTGAImageFromFile(angle::GetExecutableDirectory() + "/smoke.tga", &img))
if (!LoadTGAImageFromFile(smokeStr.str(), &img))
{
return false;
}
......
......@@ -81,20 +81,25 @@ deBool deIsDir(const char *filename)
#error TODO(jmadill): support other platforms
#endif
bool FindDataDir(std::string *dataDir)
bool FindDataDir(std::string *dataDirOut)
{
for (auto searchDir : g_dEQPDataSearchDirs)
{
if (deIsDir((std::string(searchDir) + "/gles2").c_str()))
{
*dataDir = searchDir;
*dataDirOut = searchDir;
return true;
}
std::string directory = angle::GetExecutableDirectory() + "/" + searchDir;
if (deIsDir((directory + "/gles2").c_str()))
std::stringstream dirStream;
dirStream << angle::GetExecutableDirectory() << "/" << searchDir;
std::string dataDir = dirStream.str();
dirStream << "/gles2";
std::string searchPath = dirStream.str();
if (deIsDir(searchPath.c_str()))
{
*dataDir = directory;
*dataDirOut = dataDir;
return true;
}
}
......
......@@ -16,7 +16,10 @@
namespace angle
{
std::string GetExecutablePath()
namespace
{
std::string GetExecutablePathImpl()
{
// We cannot use lstat to get the size of /proc/self/exe as it always returns 0
// so we just use a big buffer and hope the path fits in it.
......@@ -32,14 +35,28 @@ std::string GetExecutablePath()
return path;
}
std::string GetExecutableDirectory()
std::string GetExecutableDirectoryImpl()
{
std::string executablePath = GetExecutablePath();
size_t lastPathSepLoc = executablePath.find_last_of("/");
return (lastPathSepLoc != std::string::npos) ? executablePath.substr(0, lastPathSepLoc) : "";
}
std::string GetSharedLibraryExtension()
} // anonymous namespace
const char *GetExecutablePath()
{
const static std::string &exePath = GetExecutablePathImpl();
return exePath.c_str();
}
const char *GetExecutableDirectory()
{
const static std::string &exeDir = GetExecutableDirectoryImpl();
return exeDir.c_str();
}
const char *GetSharedLibraryExtension()
{
return "so";
}
......
......@@ -15,7 +15,10 @@
namespace angle
{
std::string GetExecutablePath()
namespace
{
std::string GetExecutablePathImpl()
{
std::string result;
......@@ -35,14 +38,28 @@ std::string GetExecutablePath()
return buffer.data();
}
std::string GetExecutableDirectory()
std::string GetExecutableDirectoryImpl()
{
std::string executablePath = GetExecutablePath();
size_t lastPathSepLoc = executablePath.find_last_of("/");
return (lastPathSepLoc != std::string::npos) ? executablePath.substr(0, lastPathSepLoc) : "";
}
std::string GetSharedLibraryExtension()
} // anonymous namespace
const char *GetExecutablePath()
{
const static std::string &exePath = GetExecutablePathImpl();
return exePath.c_str();
}
const char *GetExecutableDirectory()
{
const static std::string &exeDir = GetExecutableDirectoryImpl();
return exeDir.c_str();
}
const char *GetSharedLibraryExtension()
{
return "dylib";
}
......
......@@ -18,9 +18,9 @@
namespace angle
{
ANGLE_EXPORT std::string GetExecutablePath();
ANGLE_EXPORT std::string GetExecutableDirectory();
ANGLE_EXPORT std::string GetSharedLibraryExtension();
ANGLE_EXPORT const char *GetExecutablePath();
ANGLE_EXPORT const char *GetExecutableDirectory();
ANGLE_EXPORT const char *GetSharedLibraryExtension();
// Cross platform equivalent of the Windows Sleep function
ANGLE_EXPORT void Sleep(unsigned int milliseconds);
......
......@@ -16,7 +16,10 @@
namespace angle
{
std::string GetExecutablePath()
namespace
{
std::string GetExecutablePathImpl()
{
std::array<char, MAX_PATH> executableFileBuf;
DWORD executablePathLen = GetModuleFileNameA(NULL, executableFileBuf.data(),
......@@ -24,14 +27,28 @@ std::string GetExecutablePath()
return (executablePathLen > 0 ? std::string(executableFileBuf.data()) : "");
}
std::string GetExecutableDirectory()
std::string GetExecutableDirectoryImpl()
{
std::string executablePath = GetExecutablePath();
size_t lastPathSepLoc = executablePath.find_last_of("\\/");
return (lastPathSepLoc != std::string::npos) ? executablePath.substr(0, lastPathSepLoc) : "";
}
std::string GetSharedLibraryExtension()
} // anonymous namespace
const char *GetExecutablePath()
{
const static std::string &exePath = GetExecutablePathImpl();
return exePath.c_str();
}
const char *GetExecutableDirectory()
{
const static std::string &exeDir = GetExecutableDirectoryImpl();
return exeDir.c_str();
}
const char *GetSharedLibraryExtension()
{
return "dll";
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment