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 ...@@ -84,8 +84,14 @@ class MultiTextureSample : public SampleApplication
mLightMapLoc = glGetUniformLocation(mProgram, "s_lightMap"); mLightMapLoc = glGetUniformLocation(mProgram, "s_lightMap");
// Load the textures // Load the textures
mBaseMapTexID = loadTexture(angle::GetExecutableDirectory() + "/basemap.tga"); std::stringstream baseStr;
mLightMapTexID = loadTexture(angle::GetExecutableDirectory() + "/lightmap.tga"); 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) if (mBaseMapTexID == 0 || mLightMapTexID == 0)
{ {
return false; return false;
......
...@@ -49,15 +49,22 @@ class MultipleDrawBuffersSample : public SampleApplication ...@@ -49,15 +49,22 @@ class MultipleDrawBuffersSample : public SampleApplication
return false; return false;
} }
mMRTProgram = CompileProgramFromFiles(angle::GetExecutableDirectory() + "/multiple_draw_buffers_vs.glsl", std::stringstream vsStream;
angle::GetExecutableDirectory() + "/multiple_draw_buffers_fs.glsl"); 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) if (!mMRTProgram)
{ {
return false; return false;
} }
mCopyProgram = CompileProgramFromFiles(angle::GetExecutableDirectory() + "/multiple_draw_buffers_vs.glsl", mCopyProgram = CompileProgramFromFiles(vsStream.str(), copyFsStream.str());
angle::GetExecutableDirectory() + "/multiple_draw_buffers_copy_fs.glsl");
if (!mCopyProgram) if (!mCopyProgram)
{ {
return false; return false;
......
...@@ -115,8 +115,11 @@ class ParticleSystemSample : public SampleApplication ...@@ -115,8 +115,11 @@ class ParticleSystemSample : public SampleApplication
mParticleTime = 1.0f; mParticleTime = 1.0f;
std::stringstream smokeStr;
smokeStr << angle::GetExecutableDirectory() << "/smoke.tga";
TGAImage img; TGAImage img;
if (!LoadTGAImageFromFile(angle::GetExecutableDirectory() + "/smoke.tga", &img)) if (!LoadTGAImageFromFile(smokeStr.str(), &img))
{ {
return false; return false;
} }
......
...@@ -81,20 +81,25 @@ deBool deIsDir(const char *filename) ...@@ -81,20 +81,25 @@ deBool deIsDir(const char *filename)
#error TODO(jmadill): support other platforms #error TODO(jmadill): support other platforms
#endif #endif
bool FindDataDir(std::string *dataDir) bool FindDataDir(std::string *dataDirOut)
{ {
for (auto searchDir : g_dEQPDataSearchDirs) for (auto searchDir : g_dEQPDataSearchDirs)
{ {
if (deIsDir((std::string(searchDir) + "/gles2").c_str())) if (deIsDir((std::string(searchDir) + "/gles2").c_str()))
{ {
*dataDir = searchDir; *dataDirOut = searchDir;
return true; return true;
} }
std::string directory = angle::GetExecutableDirectory() + "/" + searchDir; std::stringstream dirStream;
if (deIsDir((directory + "/gles2").c_str())) 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; return true;
} }
} }
......
...@@ -16,7 +16,10 @@ ...@@ -16,7 +16,10 @@
namespace angle 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 // 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. // so we just use a big buffer and hope the path fits in it.
...@@ -32,14 +35,28 @@ std::string GetExecutablePath() ...@@ -32,14 +35,28 @@ std::string GetExecutablePath()
return path; return path;
} }
std::string GetExecutableDirectory() std::string GetExecutableDirectoryImpl()
{ {
std::string executablePath = GetExecutablePath(); std::string executablePath = GetExecutablePath();
size_t lastPathSepLoc = executablePath.find_last_of("/"); size_t lastPathSepLoc = executablePath.find_last_of("/");
return (lastPathSepLoc != std::string::npos) ? executablePath.substr(0, lastPathSepLoc) : ""; 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"; return "so";
} }
......
...@@ -15,7 +15,10 @@ ...@@ -15,7 +15,10 @@
namespace angle namespace angle
{ {
std::string GetExecutablePath() namespace
{
std::string GetExecutablePathImpl()
{ {
std::string result; std::string result;
...@@ -35,14 +38,28 @@ std::string GetExecutablePath() ...@@ -35,14 +38,28 @@ std::string GetExecutablePath()
return buffer.data(); return buffer.data();
} }
std::string GetExecutableDirectory() std::string GetExecutableDirectoryImpl()
{ {
std::string executablePath = GetExecutablePath(); std::string executablePath = GetExecutablePath();
size_t lastPathSepLoc = executablePath.find_last_of("/"); size_t lastPathSepLoc = executablePath.find_last_of("/");
return (lastPathSepLoc != std::string::npos) ? executablePath.substr(0, lastPathSepLoc) : ""; 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"; return "dylib";
} }
......
...@@ -18,9 +18,9 @@ ...@@ -18,9 +18,9 @@
namespace angle namespace angle
{ {
ANGLE_EXPORT std::string GetExecutablePath(); ANGLE_EXPORT const char *GetExecutablePath();
ANGLE_EXPORT std::string GetExecutableDirectory(); ANGLE_EXPORT const char *GetExecutableDirectory();
ANGLE_EXPORT std::string GetSharedLibraryExtension(); ANGLE_EXPORT const char *GetSharedLibraryExtension();
// Cross platform equivalent of the Windows Sleep function // Cross platform equivalent of the Windows Sleep function
ANGLE_EXPORT void Sleep(unsigned int milliseconds); ANGLE_EXPORT void Sleep(unsigned int milliseconds);
......
...@@ -16,7 +16,10 @@ ...@@ -16,7 +16,10 @@
namespace angle namespace angle
{ {
std::string GetExecutablePath() namespace
{
std::string GetExecutablePathImpl()
{ {
std::array<char, MAX_PATH> executableFileBuf; std::array<char, MAX_PATH> executableFileBuf;
DWORD executablePathLen = GetModuleFileNameA(NULL, executableFileBuf.data(), DWORD executablePathLen = GetModuleFileNameA(NULL, executableFileBuf.data(),
...@@ -24,14 +27,28 @@ std::string GetExecutablePath() ...@@ -24,14 +27,28 @@ std::string GetExecutablePath()
return (executablePathLen > 0 ? std::string(executableFileBuf.data()) : ""); return (executablePathLen > 0 ? std::string(executableFileBuf.data()) : "");
} }
std::string GetExecutableDirectory() std::string GetExecutableDirectoryImpl()
{ {
std::string executablePath = GetExecutablePath(); std::string executablePath = GetExecutablePath();
size_t lastPathSepLoc = executablePath.find_last_of("\\/"); size_t lastPathSepLoc = executablePath.find_last_of("\\/");
return (lastPathSepLoc != std::string::npos) ? executablePath.substr(0, lastPathSepLoc) : ""; 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"; 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