mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-29 20:23:04 +02:00
conditional chdir for OS X resources, revert windows Head changes
This commit is contained in:
parent
e2a28b48db
commit
95926cb7fc
5 changed files with 30 additions and 3 deletions
|
@ -438,7 +438,9 @@ Audio::Audio(Oscilloscope *s, Head *linkedHead)
|
||||||
{
|
{
|
||||||
// read the walking sound from the raw file and store it
|
// read the walking sound from the raw file and store it
|
||||||
// in the in memory array
|
// in the in memory array
|
||||||
FILE *soundFile = fopen("interface.app/Contents/Resources/audio/walking.raw", "r");
|
|
||||||
|
switchToResourcesIfRequired();
|
||||||
|
FILE *soundFile = fopen("audio/walking.raw", "r");
|
||||||
|
|
||||||
// get length of file:
|
// get length of file:
|
||||||
std::fseek(soundFile, 0, SEEK_END);
|
std::fseek(soundFile, 0, SEEK_END);
|
||||||
|
|
|
@ -8,11 +8,12 @@
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
#include "Head.h"
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <lodepng.h>
|
#include <lodepng.h>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <SharedUtil.h>
|
||||||
|
#include "Head.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
@ -31,7 +32,7 @@ float browThickness = 0.16;
|
||||||
|
|
||||||
const float DECAY = 0.1;
|
const float DECAY = 0.1;
|
||||||
|
|
||||||
char iris_texture_file[] = "interface.app/Contents/Resources/images/green_eye.png";
|
char iris_texture_file[] = "images/green_eye.png";
|
||||||
|
|
||||||
vector<unsigned char> iris_texture;
|
vector<unsigned char> iris_texture;
|
||||||
unsigned int iris_texture_width = 512;
|
unsigned int iris_texture_width = 512;
|
||||||
|
@ -77,6 +78,7 @@ Head::Head()
|
||||||
hand = new Hand(glm::vec3(skinColor[0], skinColor[1], skinColor[2]));
|
hand = new Hand(glm::vec3(skinColor[0], skinColor[1], skinColor[2]));
|
||||||
|
|
||||||
if (iris_texture.size() == 0) {
|
if (iris_texture.size() == 0) {
|
||||||
|
switchToResourcesIfRequired();
|
||||||
unsigned error = lodepng::decode(iris_texture, iris_texture_width, iris_texture_height, iris_texture_file);
|
unsigned error = lodepng::decode(iris_texture, iris_texture_width, iris_texture_height, iris_texture_file);
|
||||||
if (error != 0) {
|
if (error != 0) {
|
||||||
std::cout << "error " << error << ": " << lodepng_error_text(error) << std::endl;
|
std::cout << "error " << error << ": " << lodepng_error_text(error) << std::endl;
|
||||||
|
|
|
@ -921,6 +921,7 @@ int main(int argc, char** argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Lookup the IP address of things we have hostnames
|
// Lookup the IP address of things we have hostnames
|
||||||
if (atoi(DOMAIN_IP) == 0) {
|
if (atoi(DOMAIN_IP) == 0) {
|
||||||
struct hostent* pHostInfo;
|
struct hostent* pHostInfo;
|
||||||
|
|
|
@ -10,6 +10,10 @@
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include "SharedUtil.h"
|
#include "SharedUtil.h"
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
#include <CoreFoundation/CoreFoundation.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
double usecTimestamp(timeval *time) {
|
double usecTimestamp(timeval *time) {
|
||||||
return (time->tv_sec * 1000000.0 + time->tv_usec);
|
return (time->tv_sec * 1000000.0 + time->tv_usec);
|
||||||
}
|
}
|
||||||
|
@ -56,3 +60,19 @@ int numberOfOnes(unsigned char byte) {
|
||||||
bool oneAtBit(unsigned char byte, int bitIndex) {
|
bool oneAtBit(unsigned char byte, int bitIndex) {
|
||||||
return (byte >> (7 - bitIndex) & 1);
|
return (byte >> (7 - bitIndex) & 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void switchToResourcesIfRequired() {
|
||||||
|
#ifdef __APPLE__
|
||||||
|
CFBundleRef mainBundle = CFBundleGetMainBundle();
|
||||||
|
CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(mainBundle);
|
||||||
|
char path[PATH_MAX];
|
||||||
|
if (!CFURLGetFileSystemRepresentation(resourcesURL, TRUE, (UInt8 *)path, PATH_MAX)) // Error: expected unqualified-id before 'if'
|
||||||
|
{
|
||||||
|
// error!
|
||||||
|
}
|
||||||
|
CFRelease(resourcesURL); // error: expected constructor, destructor or type conversion before '(' token
|
||||||
|
|
||||||
|
chdir(path); // error: expected constructor, destructor or type conversion before '(' token
|
||||||
|
std::cout << "Current Path: " << path << std::endl; // error: expected constructor, destructor or type conversion before '<<' token
|
||||||
|
#endif
|
||||||
|
}
|
|
@ -29,4 +29,6 @@ void outputBits(unsigned char byte);
|
||||||
int numberOfOnes(unsigned char byte);
|
int numberOfOnes(unsigned char byte);
|
||||||
bool oneAtBit(unsigned char byte, int bitIndex);
|
bool oneAtBit(unsigned char byte, int bitIndex);
|
||||||
|
|
||||||
|
void switchToResourcesIfRequired();
|
||||||
|
|
||||||
#endif /* defined(__hifi__SharedUtil__) */
|
#endif /* defined(__hifi__SharedUtil__) */
|
||||||
|
|
Loading…
Reference in a new issue