metaforce/hecl/blender/BlenderConnection.hpp

49 lines
1.1 KiB
C++
Raw Normal View History

#ifndef CBLENDERCONNECTION_HPP
#define CBLENDERCONNECTION_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-05-24 22:19:28 +00:00
#include <string>
#include <functional>
class CBlenderConnection
{
2015-05-24 04:51:16 +00:00
#if _WIN32
HANDLE m_blenderProc;
HANDLE m_readpipe;
HANDLE m_writepipe;
#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-05-24 04:51:16 +00:00
CBlenderConnection(bool silenceBlender=false);
~CBlenderConnection();
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();
};
#endif // CBLENDERCONNECTION_HPP