struct SOMPAINT_LIB(server);
#define SOMPAINT SOMPAINT_LIB(server)*
struct SOMPAINT_LIB(buffer); //video mem
#define SOMPAINT_PAL SOMPAINT_LIB(buffer)*
struct SOMPAINT_LIB(raster); //OS handle
#define SOMPAINT_PIX SOMPAINT_LIB(raster)*
struct SOMPAINT_LIB(window); //rectangle
#define SOMPAINT_BOX SOMPAINT_LIB(window)*
struct SOMPAINT_LIB(server)
{
#ifndef __cplusplus
/*probably should not rely on this working
//Use the SOMPAINT_LIB(Status) API instead*/
void *vtable; /*debugger*/
#endif
int status;
float progress; //0~1
const wchar_t *message;
#ifdef __cplusplus
SOMPAINT_LIB(server)()
{
status = 0; message = L""; progress = 0.0;
}
/*0: Normal idling status
//Busy at work if greater
//Fatal error if negative*/
inline operator int(){ return this?status:-1; }
/*the device is lost and cannot reset
//should only occur if expose is used*/
inline bool lost(){ return this?status==-2:false; }
/*compiler: MSVC2005 has trouble calling
//virtual members from an object reference*/
inline SOMPAINT operator->(){ return this; }
/*See struct SOMPAINT_LIB(buffer)*/
virtual SOMPAINT_PAL buffer(void **io)=0;
template<typename T>
inline SOMPAINT_PAL pal(T *t){ return buffer(&t->pal); }
template<typename T>
inline SOMPAINT_PAL pal(T &t){ return buffer(&t.pal); }
/*See C API comments before using*/
virtual bool share(void **io, void **io2)=0;
virtual bool format2(void **io, const char*,va_list)=0;
virtual bool source(void **io, const wchar_t[MAX_PATH])=0;
virtual bool expose2(void **io, const char*,va_list)=0;
virtual void discard(void **io)=0;
inline bool format(void **io, const char *f,...)
{
va_list v; va_start(v,f); bool o = format2(io,f,v); va_end(v); return o;
}
inline bool expose(void **io, const char *f,...)
{
va_list v; va_start(v,f); bool o = expose2(io,f,v); va_end(v); return o;
}
virtual void *lock(void **io, const char *mode, size_t inout[4], int plane=0)=0;
virtual void unlock(void **io)=0;
virtual const wchar_t *assemble(const char *code, size_t codelen=-1)=0;
virtual bool run(const wchar_t*)=0;
virtual int load2(const char*,va_list)=0;
virtual int load3(const char*,void**,size_t)=0;
inline int load(const char *f,...)
{
va_list v; va_start(v,f); int o = load2(f,v); va_end(v); return o;
}
virtual void reclaim(const wchar_t*)=0;
/*C-like preprocessor macros APIs*/
virtual void **define(const char *d, const char *def="", void **io=0)=0;
inline void **define(const char *d, int e, void **io=0)
{
char def[64]=""; if(sprintf(def,"%d",e)) return define(d,def,io);
}
inline void **define(const char *d, double e, void **io=0)
{
char def[64]=""; if(sprintf(def,"%f",e)) return define(d,def,io);
}
inline void **undef(const char *d, void **io=0)
{
return define(d,0,io);
}
virtual const char *ifdef(const char *d, void **io=0)=0;
/*painting abstraction layer APIs*/
virtual bool reset(const char *unused=0)=0;
virtual bool frame(size_t inout[4])=0;
virtual bool clip(size_t inout[4])=0;
/*portable operating systems APIs*/
virtual SOMPAINT_PIX raster(void **io, void *local=0, const char *typeid_local_raw_name=0)=0;
virtual SOMPAINT_BOX window(void **io, void *local=0, const char *typeid_local_raw_name=0)=0;
template<typename T>
inline SOMPAINT_PIX raster(void **io, T *local)
{
return raster(io,local,typeid(T).raw_name());
}
template<typename T>
inline SOMPAINT_BOX window(void **io, T *local)
{
return window(io,local,typeid(T).raw_name());
}
protected: /*See C API comments*/
/*disconnect should return 0 unless an
//alternative unload protocol needs to
//be used within the build environment*/
virtual void *disconnect(bool host)=0;
#endif
};
struct SOMPAINT_LIB(buffer)
{
#ifdef __cplusplus
virtual bool apply(int i=0)=0;
virtual bool setup(int i=0)=0;
virtual bool clear(int mask=~0)=0;
virtual bool sample(int i=0)=0;
virtual bool layout(const wchar_t*)=0;
virtual int stream(int n, const void *up, size_t up_s)=0;
virtual bool draw(int start, int count, int vstart, int vcount)=0;
/*portable operating systems APIs*/
virtual bool present(int zoom, SOMPAINT_BOX src, SOMPAINT_BOX dst, SOMPAINT_PIX)=0;
virtual bool fill(int m, int n, int wrap, int zoom, SOMPAINT_BOX, SOMPAINT_BOX, SOMPAINT_PIX)=0;
virtual bool print(int width, int height, SOMPAINT_PIX)=0;
#endif
};