metaforce/hecl/blender/BlenderConnection.hpp

50 lines
1.1 KiB
C++
Raw Normal View History

2015-07-22 19:14:50 +00:00
#ifndef BLENDERCONNECTION_HPP
#define BLENDERCONNECTION_HPP
2015-05-24 04:51:16 +00:00
#if _WIN32
#define _WIN32_LEAN_AND_MEAN 1
#include <windows.h>
#else
#include <unistd.h>
2015-05-24 04:51:16 +00:00
#endif
2015-07-22 19:14:50 +00:00
#include <stdint.h>
2015-05-24 22:19:28 +00:00
#include <string>
#include <functional>
2015-07-22 19:14:50 +00:00
class BlenderConnection
{
2015-05-24 04:51:16 +00:00
#if _WIN32
HANDLE m_blenderProc;
2015-07-22 19:14:50 +00:00
HANDLE m_readpipe[2];
HANDLE m_writepipe[2];
2015-05-24 04:51:16 +00:00
#else
pid_t m_blenderProc;
2015-05-24 04:51:16 +00:00
int m_readpipe[2];
int m_writepipe[2];
#endif
2015-05-24 22:19:28 +00:00
std::string m_loadedBlend;
size_t _readLine(char* buf, size_t bufSz);
size_t _writeLine(const char* buf);
size_t _readBuf(char* buf, size_t len);
size_t _writeBuf(const char* buf, size_t len);
void _closePipe();
public:
2015-07-22 19:14:50 +00:00
BlenderConnection(bool silenceBlender=false);
~BlenderConnection();
2015-05-24 04:51:16 +00:00
2015-05-24 22:19:28 +00:00
bool openBlend(const std::string& path);
enum CookPlatform
{
CP_MODERN = 0,
CP_GX = 1,
};
2015-05-26 04:42:20 +00:00
bool cookBlend(std::function<char*(uint32_t)> bufGetter,
2015-05-24 22:19:28 +00:00
const std::string& expectedType,
const std::string& platform,
bool bigEndian=false);
2015-05-24 04:51:16 +00:00
void quitBlender();
};
2015-07-22 19:14:50 +00:00
#endif // BLENDERCONNECTION_HPP