Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /******************************************************************************/
- /******************************************************************************/
- //"kit_w32\include\kit\misc.hpp":
- #ifndef _KIT_INC_MISC_HPP
- #define _KIT_INC_MISC_HPP
- #include "commondef.hpp"
- #include "_misc_Mutex.hpp"
- #include "_misc_time.hpp"
- #include "_misc_fileio.hpp"
- #include "_misc_func.hpp"
- #include "_misc_memory.hpp"
- #include "_misc_FStr.hpp"
- #include "_misc_Thread.hpp"
- #include "_misc_Timer.hpp"
- #endif /* _KIT_INC_VIDEO_MISC_HPP */
- /******************************************************************************/
- /******************************************************************************/
- //"kit_w32\include\kit\video.hpp":
- #ifndef _KIT_INC_VIDEO_HPP
- #define _KIT_INC_VIDEO_HPP
- #include "commondef.hpp"
- #include "misc.hpp"
- #include "_video_common.hpp"
- #include "_video_Window.hpp"
- #include "_video_Bitmap.hpp"
- #include "_video_BitmapFont.hpp"
- #endif /* _KIT_INC_VIDEO_HPP */
- /******************************************************************************/
- /******************************************************************************/
- //"kit_w32\include\kit\_audio_AudioStream.hpp":
- #ifndef _KIT_INC__AUDIO_AUDIOSTREAM_HPP
- #define _KIT_INC__AUDIO_AUDIOSTREAM_HPP
- #include "commondef.hpp"
- namespace kit {
- //this is *mostly* lifted from SDL's AudioFormat enumeration
- #define KIT_ASTREAM_FMT_BITSIZE(_fmt) ( (((_fmt)+1)&0xFF) )
- #define KIT_ASTREAM_FMT_BYTESIZE(_fmt) ( KIT_ASTREAM_FMT_BITSIZE(_fmt)/8 )
- enum AudioStreamFormats {
- ASTREAM_FMT_U8 = 0x0007,
- ASTREAM_FMT_S8 = 0x8007,
- ASTREAM_FMT_S16 = 0x800F,
- ASTREAM_FMT_S24 = 0x8018, //(packed signed 24-bit)
- ASTREAM_FMT_S32 = 0x801F,
- ASTREAM_FMT_F32 = 0x811F,
- };
- enum AudioStreamCallbackReturns {
- ASTREAM_RTN_CONTINUE = 0, //keep invoking the callback, and keep playing
- ASTREAM_RTN_COMPLETE = 1, //stop invoking the callback, and stop once all output samples have played
- ASTREAM_RTN_ABORT = 2, //stop invoking the callback, and stop the stream asap
- };
- struct AudioStreamInfo; //forward declaration
- //the callback responsible for reading from input buffers,
- //and/or writing to output buffers.
- typedef s32 (*AudioStreamCallback)(const void* inBuffer, void* outBuffer,
- const AudioStreamInfo* info, void* userdata);
- //if registered with AudioStream::setEndCallback(),
- //this function is called when a stream stops
- //(unlike the regular callback, this is optional!)
- typedef void (*AudioStreamEndCallback)(void* userdata);
- struct AudioStreamInfo {
- //time of first sample of each callback...
- f64 timeInput; //...at the point of ADC input capture
- f64 timeCurrent; //...at the actual callback's start
- f64 timeOutput; //...at the point of DAC output render
- u32 inputBufferSize; //in bytes, not sample frames
- u32 outputBufferSize; //
- s32 inputDeviceID;
- s32 outputDeviceID;
- s32 inputChannels;
- s32 outputChannels;
- u16 inputFormat;
- u16 outputFormat;
- u32 sampleFrames;
- f64 sampleRate;
- f64 inputLatency;
- f64 outputLatency;
- };
- // in/output<parameter> fields are ignored if in/outputDeviceID is -1
- struct AudioStreamParams {
- AudioStreamCallback callback;
- void* userdata;
- s32 inputDeviceID = -1; //-1 for no input
- s32 outputDeviceID = -1; //-1 for no output
- s32 inputChannels = -1; //-1 for whatever is default
- s32 outputChannels = -1; //^^
- u16 inputFormat = ASTREAM_FMT_F32; //float samples by default
- u16 outputFormat = ASTREAM_FMT_F32; //^^
- u32 sampleFrames = 0; // 0 for undefined (may change between callbacks!)
- f64 sampleRate = -1; //-1 for whatever is default
- f64 inputSuggestedLatency = -1.0; //-1.0 for whatever is default
- f64 outputSuggestedLatency = -1.0; //^^
- };
- struct _AudioStreamOpaque;
- class AudioStream {
- u32 _type;
- bool _valid = false;
- bool _constructing = true;
- u16 _padding16;
- _AudioStreamOpaque* _opq = nullptr;
- void _construct(const AudioStreamParams* params);
- public:
- //normal constructor
- AudioStream(AudioStreamParams* params){ _construct(params); }
- //attempts to create a default f32 output stream
- AudioStream(AudioStreamCallback callback, void* userdata = nullptr,
- u32 sampleFrames = 0, s32 channels = 2);
- ~AudioStream();
- bool isValid(){ return _valid; }
- bool isConstructing(){ return _constructing; }
- bool isActive();
- f64 getTime();
- f64 getCPULoad(); //usually 0.0 to 1.0, but may exceed 1.0 if usage is too high
- AudioStreamInfo getInfo();
- void setCallback(AudioStreamCallback newCallback);
- void setEndCallback(AudioStreamEndCallback newEndCallback);
- void lock(bool locked = true);
- void unlock(){ lock(false); }
- void start();
- void stop();
- void abort();
- };
- }; /* namespace kit */
- #endif /* _KIT_INC__AUDIO_AUDIOSTREAM_HPP */
- /******************************************************************************/
- /******************************************************************************/
- //"kit_w32\include\kit\_audio_func.hpp":
- #ifndef _KIT_INC__AUDIO_FUNC_HPP
- #define _KIT_INC__AUDIO_FUNC_HPP
- #include "commondef.hpp"
- namespace kit {
- struct AudioDeviceInfo {
- const char* name;
- struct {
- s32 input;
- s32 output;
- } maxChannels;
- //default latency values (in seconds)
- //for programs with low-interactivity
- //(like an audio player, for example)
- struct {
- f64 input;
- f64 output;
- } defLoLatency;
- //default latency values (in seconds)
- //for programs with high-interactivity
- //(like a video game, for example)
- struct {
- f64 input;
- f64 output;
- } defHiLatency;
- //default sample rate
- f64 defSampleRate;
- };
- //used by audio::areParamsSupported()
- struct AudioStreamParams;
- namespace audio {
- s32 getDeviceCount();
- s32 getDefInputDevice();
- s32 getDefOutputDevice();
- AudioDeviceInfo getDeviceInfo(s32 deviceID);
- //*reason_p (assuming reason_p != nullptr) will be filled with the
- //the constant location of the text version of why the paramters
- //aren't supported (assuming false was returned)
- bool areParamsSupported(const AudioStreamParams* params,
- const char** reason_p = nullptr);
- }; /* namespace audio */
- }; /* namespace kit */
- #endif /* _KIT_INC__AUDIO_FUNC_HPP */
- /******************************************************************************/
- /******************************************************************************/
- //"kit_w32\include\kit\_misc_fileio.hpp":
- #ifndef _KIT_INC__MISC_FILEIO_HPP
- #define _KIT_INC__MISC_FILEIO_HPP
- #include "commondef.hpp"
- namespace kit {
- class BinaryData {
- u32 _type;
- bool _valid = false;
- bool _constructing = true;
- u16 _padding16;
- char* _data = nullptr;
- size_t _data_len = 0;
- union {
- u8 n8;
- u16 n16;
- u32 n32;
- u64 n64;
- char str[8];
- }* _magic; //will be set to _data
- public:
- BinaryData(const char* filePath);
- //this will allocate dataSize bytes for _data, before copying data to _data
- //(it is safe to pass nullptr to data, though that would make this equivalent to malloc)
- BinaryData(const void* data, size_t dataSize);
- ~BinaryData();
- bool isValid(){ return _valid; }
- bool isConstructing(){ return _constructing; }
- char* getData(){ return _data; }
- size_t getSize(){ return _data_len; }
- u8 getMagic8(){ return _magic->n8; } //never seen an 8-bit magic num, but just in case lol
- u16 getMagic16(){ return _magic->n16; }
- u32 getMagic32(){ return _magic->n32; }
- u64 getMagic64(){ return _magic->n64; }
- const char* getMagicStr(){ return _magic->str; } //(not necessarily null-terminated!)
- };
- namespace fileio {
- bool isFileReadOnly(const char* filePath);
- bool fileExists(const char* filePath);
- size_t getSize(const char* filePath);
- void deleteFile(const char* filePath);
- void writeToFile(const char* filePath, const void* data,
- size_t dataSize, bool append = false);
- }; /* namespace fileio */
- }; /* namespace kit */
- #endif /* _KIT_INC__MISC_FILEIO_HPP */
- /******************************************************************************/
- /******************************************************************************/
- //"kit_w32\include\kit\_misc_FStr.hpp":
- #ifndef _KIT_INC__MISC_FSTR_HPP
- #define _KIT_INC__MISC_FSTR_HPP
- #include "commondef.hpp"
- namespace kit {
- class FStr {
- u32 _type;
- bool _valid = false;
- bool _constructing = true;
- u16 _str_size;
- char* _str = nullptr;
- public:
- FStr(u16 maxSize = 2048);
- ~FStr();
- bool isValid(){ return _valid; }
- bool isConstructing(){ return _constructing; }
- u16 getSize(){ return _str_size; }
- char* ptr(){ return _str; }
- char* fmt(const char* fmt_str, ...);
- };
- };
- #endif /* _KIT_INC__MISC_FSTR_HPP */
- /******************************************************************************/
- /******************************************************************************/
- //"kit_w32\include\kit\_misc_func.hpp":
- #ifndef _KIT_INC__MISC_FUNC_HPP
- #define _KIT_INC__MISC_FUNC_HPP
- #include "commondef.hpp"
- namespace kit {
- enum MessageBoxEnum {
- //return values
- MSGBOX_RTN_NULL = 0x00000000, //showMessageBox failed
- MSGBOX_RTN_OK = 0x00000001, //'ok' button was clicked
- MSGBOX_RTN_CANCEL = 0x00000002, //'cancel' button was clicked
- MSGBOX_RTN_ABORT = 0x00000003, //'abort' button was clicked
- MSGBOX_RTN_RETRY = 0x00000004, //'retry' button was clicked
- MSGBOX_RTN_IGNORE = 0x00000005, //'ignore' button was clicked
- MSGBOX_RTN_YES = 0x00000006, //'yes' button was clicked
- MSGBOX_RTN_NO = 0x00000007, //'no' button was clicked
- MSGBOX_RTN_TRYAGAIN = 0x0000000A, //'try again' button was clicked
- MSGBOX_RTN_CONTINUE = 0x0000000B, //'continue' button was clicked
- //button types
- MSGBOX_BTN_OK = 0x00000000,
- MSGBOX_BTN_OKCANCEL = 0x00000001,
- MSGBOX_BTN_ABORTRETRYIGNORE = 0x00000002,
- MSGBOX_BTN_YESNOCANCEL = 0x00000003,
- MSGBOX_BTN_YESNO = 0x00000004,
- MSGBOX_BTN_RETRYCANCEL = 0x00000005,
- MSGBOX_BTN_CANCELTRYCONTINUE = 0x00000006,
- //icon types
- MSGBOX_ICN_ERROR = 0x000000010,
- MSGBOX_ICN_QUESTION = 0x000000020, //apparently deprecated, but still supported
- MSGBOX_ICN_WARNING = 0x000000030,
- MSGBOX_ICN_INFO = 0x000000040,
- };
- class Window;
- u32 showMessageBox(const char* text = nullptr, const char* title = nullptr,
- u32 type = 0, Window* win = nullptr, u32 defaultButton = 0);
- u32 getLastSystemError();
- u32 getNumLogicalCPUCores();
- union WindowEvent;
- //calling this function exclusively in the main thread is recommended
- bool pollWindowEvent(WindowEvent* event_p = nullptr);
- }; /* namespace kit */
- #endif /* _KIT_INC__MISC_FUNC_HPP */
- /******************************************************************************/
- /******************************************************************************/
- //"kit_w32\include\kit\_misc_memory.hpp":
- #ifndef _KIT_INC__MISC_MEMORY_HPP
- #define _KIT_INC__MISC_MEMORY_HPP
- #include "commondef.hpp"
- namespace kit {
- namespace memory {
- void* alloc(size_t size);
- //this version of free is especially useful, because it's safe to pass nullptr to!
- //this rule goes for both ptr_p and *ptr_p
- void free(void* ptr_p);
- void* realloc(void* ptr_p, size_t newSize);
- //^^(for both free and realloc, a void** declared in function as void*,
- // so you don't need to explicitly cast it to void**)
- //same as alloc and free, now with exception throwing!
- void* alloc2(size_t size);
- void free2(void* ptr_p); //(unlike free, this will throw if nullptr is given)
- void* realloc2(void* ptr_p, size_t newSize);
- size_t getNumAllocations();
- void* set(void* ptr, s32 value, size_t size);
- //throws exceptions, unlike set
- void* set2(void* ptr, s32 value, size_t size);
- void* copy(void* destination, const void* source, size_t size);
- //throws exceptions, unlike copy
- void* copy2(void* destination, const void* source, size_t size);
- }; /* namespace memory */
- }; /* namespace kit */
- #endif /* _KIT_INC__MISC_MEMORY_HPP */
- /******************************************************************************/
- /******************************************************************************/
- //"kit_w32\include\kit\_misc_Mutex.hpp":
- #ifndef _KIT_INC__MISC_MUTEX_HPP
- #define _KIT_INC__MISC_MUTEX_HPP
- #include "commondef.hpp"
- namespace kit {
- //this mutex is non-blocking within the same thread!
- //(that means you can lock multiple times in one thread
- // as long as you unlock it the same number of times)
- class MutexSimple {
- u32 _type;
- bool _valid = false;
- bool _constructing = true;
- u16 _padding16;
- _GenericOpaquePtr _mutex_p = nullptr;
- u32 _spinCount;
- public:
- MutexSimple(u32 spinCount = -1);
- ~MutexSimple();
- bool isValid(){ return _valid; }
- bool isConstructing(){ return _constructing; }
- u32 getSpinCount(){ return _spinCount; }
- void setSpinCount(u32 spinCount);
- void lock(bool locked = true);
- void unlock(){ lock(false); }
- bool tryLock(); //returns true if locked successfully
- };
- }; /* namespace kit */
- #endif /* _KIT_INC__MISC_MUTEX_HPP */
- /******************************************************************************/
- /******************************************************************************/
- //"kit_w32\include\kit\_misc_Thread.hpp":
- #ifndef _KIT_INC__MISC_THREAD_HPP
- #define _KIT_INC__MISC_THREAD_HPP
- #include "commondef.hpp"
- namespace kit {
- enum ThreadPriorityEnum {
- THREAD_NO_CHANGE = -3,
- THREAD_LOWEST = -2,
- THREAD_BELOW_NORMAL = -1,
- THREAD_NORMAL = 0,
- THREAD_ABOVE_NORMAL = 1,
- THREAD_HIGHEST = 2,
- };
- typedef s32 (*ThreadFunction)(void* userdata);
- struct _ThreadOpaque;
- class Thread {
- u32 _type;
- bool _valid = false;
- bool _constructing = true;
- s8 _priority = THREAD_NORMAL;
- bool _backgroundMode = false;
- _ThreadOpaque* _opq = nullptr;
- public:
- //if detached is true, the Thread object will not wait for func
- //to return inside the Thread's destructor
- Thread(ThreadFunction func, void* userdata = nullptr,
- bool detached = false, size_t stackSize = 0);
- ~Thread();
- bool isValid(){ return _valid; }
- bool isConstructing(){ return _constructing; }
- bool isDone();
- u32 getID();
- //priority can be one of the values in ThreadPriorityEnum
- void setPriority(s32 priority, bool backgroundMode = false);
- //returns result of func (only for non-detached threads!)
- //(timeout is infinite by default)
- s32 waitUntilDone(u32 timeoutMilliseconds = 0xFFFFFFFF);
- };
- }; /* namespace kit */
- #endif /* _KIT_INC__MISC_THREAD_HPP */
- /******************************************************************************/
- /******************************************************************************/
- //"kit_w32\include\kit\_misc_time.hpp":
- #ifndef _KIT_INC__MISC_TIME_HPP
- #define _KIT_INC__MISC_TIME_HPP
- #include "commondef.hpp"
- namespace kit {
- namespace time {
- u64 getTicks();
- u64 getTicksPerSecond();
- f64 getUptime();
- void ticksleep(u64 ticks);
- void sleep(u32 milliseconds);
- }; /* namespace time */
- }; /* namespace kit */
- #endif /* _KIT_INC__MISC_TIME_HPP */
- /******************************************************************************/
- /******************************************************************************/
- //"kit_w32\include\kit\_misc_Timer.hpp":
- #ifndef _KIT_INC__MISC_TIMER_HPP
- #define _KIT_INC__MISC_TIMER_HPP
- #include "commondef.hpp"
- namespace kit {
- class TimerSimple {
- u32 _type;
- bool _valid = false;
- bool _constructing = true;
- u16 _padding16;
- _GenericOpaquePtr _timer_ptr = nullptr;
- public:
- //only manual reset timers are *for sure* supported currently
- TimerSimple(bool manualReset = true);
- ~TimerSimple();
- void setTimer(f64 durationSeconds);
- void wait(u32 timeoutMilliseconds = 0); //0 for waiting indefinitely
- };
- }; /* namespace kit */
- #endif /* _KIT_INC__MISC_TIMER_HPP */
- /******************************************************************************/
- /******************************************************************************/
- //"kit_w32\include\kit\_video_Bitmap.hpp":
- #ifndef _KIT_INC__VIDEO_BITMAP_HPP
- #define _KIT_INC__VIDEO_BITMAP_HPP
- #include "commondef.hpp"
- #include "_video_common.hpp"
- namespace kit {
- class Window;
- struct _BitmapOpaque;
- class Bitmap {
- u32 _type;
- bool _valid = false;
- bool _constructing = true;
- u16 _padding16;
- _BitmapOpaque* _opq = nullptr;
- //(_parse<format> functions must free what is returned to prevent leaks)
- color::ARGB* _parseQOI(BinaryData& fileData, shape::point& size);
- //separated from first constructor so it can be used by the 2nd constructor too
- void _constructFromMemory(const color::ARGB* pixelData, u32 width, u32 height,
- Window* blit_dst, bool directAccess);
- public:
- //loads from memory (pixel data is copied to bitmap; it isn't just referenced)
- Bitmap(const color::ARGB* pixelData, u32 width, u32 height,
- Window* blit_dst, bool directAccess = false)
- { _constructFromMemory(pixelData, width, height, blit_dst, directAccess); }
- //loads from a file
- Bitmap(const char* filePath, Window* blit_dst, bool directAccess = false);
- ~Bitmap();
- bool isValid(){ return _valid; }
- bool isConstructing(){ return _constructing; }
- bool isDirectAccess();
- color::ARGB* getPixels(); //get pointer to internal pixel data (must be direct access)
- shape::point getSize();
- //(size of pixelDataOut array must be at least sizeof(color::ARGB)*width*height)
- void getPixelData(color::ARGB* pixelDataOut);
- void setPixelData(const color::ARGB* pixelData, u32 width, u32 height);
- void setBlitDestination(Window* blit_dst); //relatively expensive; don't call this too often
- void lock(bool enable = true);
- void unlock(){ lock(false); }
- void blitRect(shape::rect* dst = nullptr, shape::rect* src = nullptr,
- color::ARGB transparency = 0x80000000);
- void blit(s32 x, s32 y, f32 scale = 1.0f,
- color::ARGB transparency = 0x80000000);
- void blitCentered(s32 xCenter, s32 yCenter, f32 scale = 1.0f,
- color::ARGB transparency = 0x80000000);
- };
- }; /* namespace kit */
- #endif /* _KIT_INC__VIDEO_BITMAP_HPP */
- /******************************************************************************/
- /******************************************************************************/
- //"kit_w32\include\kit\_video_BitmapFont.hpp":
- #ifndef _KIT_INC__VIDEO_BITMAPFONT_HPP
- #define _KIT_INC__VIDEO_BITMAPFONT_HPP
- #include "commondef.hpp"
- #include "_video_common.hpp"
- namespace kit {
- class BitmapFont {
- u32 _type;
- bool _valid = false;
- bool _constructing = true;
- u8 _anchorPoint = 0; //tbd
- bool _verticalNewline = true;
- Bitmap* _fontAtlas = nullptr;
- s16 _stepLengths[256]; //how many pixels to step forward for a given char (including glyph size!)
- shape::spoint _offsets[256]; //pixel offsets for a given char
- shape::rect _glyphSrc;
- shape::rect _glyphDst;
- shape::fpoint _glyphScale;
- color::ARGB _transparency = 0xFF00FF; //magenta by default (0x80000000 for no transparency)
- s16 _newlineLen; //how many pixels of spacing every newline (including glyph size!)
- bool _fromMemory = false; //determines whether _fontAtlas should be freed
- //by default, a font will construct monospaced, behaving like stdout text does
- void _constructFromMemory(Bitmap* fontAtlas,
- const s16* stepLengths = nullptr, s16 newlineLen = -32768,
- const shape::spoint* offsets = nullptr, bool verticalNewline = true);
- public:
- //(in this version of the constructor, the memory for fontAtlas
- //is managed by the user, and is therefore not freed)
- BitmapFont(Bitmap* fontAtlas,
- const s16* stepLengths = nullptr, s16 newlineLen = -32768,
- const shape::spoint* offsets = nullptr, bool verticalNewline = true)
- {
- _fromMemory = true;
- _constructFromMemory(fontAtlas, stepLengths, newlineLen,
- offsets, verticalNewline);
- }
- //loads a bitmap from an image file
- BitmapFont(const char* filePath, Window* blit_dst, bool directAccess = false,
- const s16* stepLengths = nullptr, s16 newlineLen = -32768,
- const shape::spoint* offsets = nullptr, bool verticalNewline = true);
- ~BitmapFont();
- bool isValid(){ return _valid; }
- bool isConstructing(){ return _constructing; }
- shape::point getStringSize(const char* str, size_t maxLen = 0);
- shape::point setScale(float x = 1.0f, float y = 1.0f); //returns new char size
- void putChar(s32 x, s32 y, char chr);
- void print(s32 x, s32 y, const char* str, size_t maxLen = 0);
- };
- };
- #endif /* _KIT_INC__VIDEO_BITMAPFONT_HPP */
- /******************************************************************************/
- /******************************************************************************/
- //"kit_w32\include\kit\_video_common.hpp":
- #ifndef _KIT_INC__VIDEO_COMMON_HPP
- #define _KIT_INC__VIDEO_COMMON_HPP
- #include "commondef.hpp"
- #define KIT_VIDEO_COMMON_REMOVE_PADDING
- #ifdef KIT_VIDEO_COMMON_REMOVE_PADDING
- #pragma pack(push,1)
- #endif /* KIT_VIDEO_COMMON_REMOVE_PADDING */
- namespace kit {
- namespace color {
- //what GDI uses (save for the alpha channel)
- union ARGB { //4B; 0xAARRGGBB
- u32 v; //entire color [v]alue
- struct {
- u8 b;
- u8 g;
- u8 r;
- u8 a;
- };
- ARGB() : v(0) {}
- ARGB(u32 _v) : v(_v) {}
- ARGB(u8 _r, u8 _g,
- u8 _b, u8 _a) : r(_r), g(_g), b(_b), a(_a) {}
- inline bool operator==(const ARGB& c){ return (v == c.v); };
- inline bool operator!=(const ARGB& c){ return (v != c.v); };
- inline bool operator==(const u32& cv){ return (v == cv); };
- inline bool operator!=(const u32& cv){ return (v != cv); };
- inline void operator=(const u32 cv){ v = cv; }
- };
- union ABGR { //4B; 0xAABBGGRR
- u32 v; //entire color [v]alue
- struct {
- u8 r;
- u8 g;
- u8 b;
- u8 a;
- };
- ABGR() : v(0) {}
- ABGR(u32 _v) : v(_v) {}
- ABGR(u8 _r, u8 _g,
- u8 _b, u8 _a) : r(_r), g(_g), b(_b), a(_a) {}
- inline bool operator==(const ABGR& c){ return (v == c.v); };
- inline bool operator!=(const ABGR& c){ return (v != c.v); };
- inline bool operator==(const u32& cv){ return (v == cv); };
- inline bool operator!=(const u32& cv){ return (v != cv); };
- inline void operator=(const u32 cv){ v = cv; }
- };
- }; /* namespace color */
- namespace shape {
- struct spoint {
- s16 x, y;
- spoint() : x(0), y(0) {}
- spoint(s16 _x, s16 _y) : x(_x), y(_y) {}
- inline bool operator==(const spoint& p){ return (x==p.x && y==p.y); };
- inline bool operator!=(const spoint& p){ return (x!=p.x && y!=p.y); };
- inline void operator-=(const spoint& p){ x -= p.x; y -= p.y; }
- inline void operator+=(const spoint& p){ x += p.x; y += p.y; }
- };
- struct srect {
- s16 x, y; //x & y position of the rectangle's top-left corner
- s16 w, h; //the rectangle's width & height
- srect() : x(0), y(0), w(0), h(0) {}
- srect(s16 _x, s16 _y) : x(_x), y(_y) {}
- srect(s16 _x, s16 _y,
- s16 _w, s16 _h) : x(_x), y(_y), w(_w), h(_h) {}
- inline bool operator==(const srect& r){ return (x==r.x && y==r.y && w==r.w && h==r.h); };
- inline bool operator!=(const srect& r){ return (x!=r.x && y!=r.y && w!=r.w && h!=r.h); };
- inline void operator-=(const spoint& p){ x -= p.x; y -= p.y; }
- inline void operator+=(const spoint& p){ x += p.x; y += p.y; }
- };
- struct sline {
- s16 x0, y0;
- s16 x1, y1;
- sline() : x0(0), y0(0), x1(0), y1(0) {}
- sline(s16 _x0, s16 _y0,
- s16 _x1, s16 _y1) : x0(_x0), y0(_y0), x1(_x1), y1(_y1) {}
- inline bool operator==(const sline& l){ return (x0==l.x0 && y0==l.y0 && x1==l.x1 && y1==l.y1); };
- inline bool operator!=(const sline& l){ return (x0!=l.x0 && y0!=l.y0 && x1!=l.x1 && y1!=l.y1); };
- };
- struct scircle {
- s16 x, y, r;
- scircle() : x(0), y(0), r(0) {}
- scircle(s16 _x, s16 _y, s16 _r) : x(_x), y(_y), r(_r) {}
- inline bool operator==(const scircle& c){ return (x==c.x && y==c.y && r==c.r); };
- inline bool operator!=(const scircle& c){ return (x!=c.x && y!=c.y && r!=c.r); };
- inline void operator-=(const spoint& p){ x -= p.x; y -= p.y; }
- inline void operator+=(const spoint& p){ x += p.x; y += p.y; }
- };
- struct spoint3d {
- s16 x, y, z;
- spoint3d() : x(0), y(0), z(0) {}
- spoint3d(s16 _x, s16 _y, s16 _z) : x(_x), y(_y), z(_z) {}
- inline bool operator==(const spoint3d& p){ return (x==p.x && y==p.y && z==p.z); }
- inline bool operator!=(const spoint3d& p){ return (x!=p.x && y!=p.y && z!=p.z); }
- };
- struct point {
- s32 x, y;
- point() : x(0), y(0) {}
- point(s32 _x, s32 _y) : x(_x), y(_y) {}
- inline bool operator==(const point& p){ return (x==p.x && y==p.y); };
- inline bool operator!=(const point& p){ return (x!=p.x && y!=p.y); };
- inline void operator-=(const point& p){ x -= p.x; y -= p.y; }
- inline void operator+=(const point& p){ x += p.x; y += p.y; }
- };
- struct rect {
- s32 x, y; //x & y position of the rectangle's top-left corner
- s32 w, h; //the rectangle's width & height
- rect() : x(0), y(0), w(0), h(0) {}
- rect(s32 _x, s32 _y) : x(_x), y(_y) {}
- rect(s32 _x, s32 _y,
- s32 _w, s32 _h) : x(_x), y(_y), w(_w), h(_h) {}
- inline bool operator==(const rect& r){ return (x==r.x && y==r.y && w==r.w && h==r.h); };
- inline bool operator!=(const rect& r){ return (x!=r.x && y!=r.y && w!=r.w && h!=r.h); };
- inline void operator-=(const point& p){ x -= p.x; y -= p.y; }
- inline void operator+=(const point& p){ x += p.x; y += p.y; }
- };
- struct line {
- s32 x0, y0;
- s32 x1, y1;
- line() : x0(0), y0(0), x1(0), y1(0) {}
- line(s32 _x0, s32 _y0,
- s32 _x1, s32 _y1) : x0(_x0), y0(_y0), x1(_x1), y1(_y1) {}
- inline bool operator==(const line& l){ return (x0==l.x0 && y0==l.y0 && x1==l.x1 && y1==l.y1); };
- inline bool operator!=(const line& l){ return (x0!=l.x0 && y0!=l.y0 && x1!=l.x1 && y1!=l.y1); };
- };
- struct circle {
- s32 x, y, r;
- circle() : x(0), y(0), r(0) {}
- circle(s32 _x, s32 _y, s32 _r) : x(_x), y(_y), r(_r) {}
- inline bool operator==(const circle& c){ return (x==c.x && y==c.y && r==c.r); };
- inline bool operator!=(const circle& c){ return (x!=c.x && y!=c.y && r!=c.r); };
- inline void operator-=(const point& p){ x -= p.x; y -= p.y; }
- inline void operator+=(const point& p){ x += p.x; y += p.y; }
- };
- struct point3d {
- s32 x, y, z;
- point3d() : x(0), y(0), z(0) {}
- point3d(s32 _x, s32 _y, s32 _z) : x(_x), y(_y), z(_z) {}
- inline bool operator==(const point3d& p){ return (x==p.x && y==p.y && z==p.z); }
- inline bool operator!=(const point3d& p){ return (x!=p.x && y!=p.y && z!=p.z); }
- };
- struct fpoint {
- f32 x, y;
- fpoint() : x(0.0f), y(0.0f) {}
- fpoint(f32 _x, f32 _y) : x(_x), y(_y) {}
- inline bool operator==(const fpoint& p){ return (x==p.x && y==p.y); };
- inline bool operator!=(const fpoint& p){ return (x!=p.x && y!=p.y); };
- inline void operator-=(const fpoint& p){ x -= p.x; y -= p.y; }
- inline void operator+=(const fpoint& p){ x += p.x; y += p.y; }
- };
- struct frect {
- f32 x, y; //x & y position of rectangle's top-left corner
- f32 w, h; //the rectangle's width & height
- frect() : x(0.0f), y(0.0f), w(0.0f), h(0.0f) {}
- frect(f32 _x, f32 _y) : x(_x), y(_y) {}
- frect(f32 _x, f32 _y,
- f32 _w, f32 _h) : x(_x), y(_y), w(_w), h(_h) {}
- inline bool operator==(const frect& r){ return (x==r.x && y==r.y && w==r.w && h==r.h); };
- inline bool operator!=(const frect& r){ return (x!=r.x && y!=r.y && w!=r.w && h!=r.h); };
- inline void operator-=(const fpoint& p){ x -= p.x; y -= p.y; }
- inline void operator+=(const fpoint& p){ x += p.x; y += p.y; }
- };
- struct fline {
- f32 x0, y0;
- f32 x1, y1;
- fline() : x0(0.0f), y0(0.0f), x1(0.0f), y1(0.0f) {}
- fline(f32 _x0, f32 _y0,
- f32 _x1, f32 _y1) : x0(_x0), y0(_y0), x1(_x1), y1(_y1) {}
- inline bool operator==(const fline& l){ return (x0==l.x0 && y0==l.y0 && x1==l.x1 && y1==l.y1); };
- inline bool operator!=(const fline& l){ return (x0!=l.x0 && y0!=l.y0 && x1!=l.x1 && y1!=l.y1); };
- };
- struct fcircle {
- f32 x, y, r;
- fcircle() : x(0.0f), y(0.0f), r(0.0f) {}
- fcircle(f32 _x, f32 _y, f32 _r) : x(_x), y(_y), r(_r) {}
- inline bool operator==(const fcircle& c){ return (x==c.x && y==c.y && r==c.r); };
- inline bool operator!=(const fcircle& c){ return (x!=c.x && y!=c.y && r!=c.r); };
- inline void operator-=(const fpoint& p){ x -= p.x; y -= p.y; }
- inline void operator+=(const fpoint& p){ x += p.x; y += p.y; }
- };
- struct fpoint3d {
- f32 x, y, z;
- fpoint3d() : x(0.0f), y(0.0f), z(0.0f) {}
- fpoint3d(f32 _x, f32 _y, f32 _z) : x(_x), y(_y), z(_z) {}
- inline bool operator==(const fpoint3d& p){ return (x==p.x && y==p.y && z==p.z); }
- inline bool operator!=(const fpoint3d& p){ return (x!=p.x && y!=p.y && z!=p.z); }
- };
- struct dpoint {
- f64 x, y;
- dpoint() : x(0.0), y(0.0) {}
- dpoint(f64 _x, f64 _y) : x(_x), y(_y) {}
- inline bool operator==(const dpoint& p){ return (x==p.x && y==p.y); };
- inline bool operator!=(const dpoint& p){ return (x!=p.x && y!=p.y); };
- inline void operator-=(const dpoint& p){ x -= p.x; y -= p.y; }
- inline void operator+=(const dpoint& p){ x += p.x; y += p.y; }
- };
- struct drect {
- f64 x, y; //x & y position of rectangle's top-left corner
- f64 w, h; //the rectangle's width & height
- drect() : x(0.0), y(0.0), w(0.0), h(0.0) {}
- drect(f64 _x, f64 _y) : x(_x), y(_y) {}
- drect(f64 _x, f64 _y,
- f64 _w, f64 _h) : x(_x), y(_y), w(_w), h(_h) {}
- inline bool operator==(const drect& r){ return (x==r.x && y==r.y && w==r.w && h==r.h); };
- inline bool operator!=(const drect& r){ return (x!=r.x && y!=r.y && w!=r.w && h!=r.h); };
- inline void operator-=(const dpoint& p){ x -= p.x; y -= p.y; }
- inline void operator+=(const dpoint& p){ x += p.x; y += p.y; }
- };
- struct dline {
- f64 x0, y0;
- f64 x1, y1;
- dline() : x0(0.0), y0(0.0), x1(0.0), y1(0.0) {}
- dline(f64 _x0, f64 _y0,
- f64 _x1, f64 _y1) : x0(_x0), y0(_y0), x1(_x1), y1(_y1) {}
- inline bool operator==(const dline& l){ return (x0==l.x0 && y0==l.y0 && x1==l.x1 && y1==l.y1); };
- inline bool operator!=(const dline& l){ return (x0!=l.x0 && y0!=l.y0 && x1!=l.x1 && y1!=l.y1); };
- };
- struct dcircle {
- f64 x, y;
- f64 r;
- dcircle() : x(0.0), y(0.0), r(0.0) {}
- dcircle(f64 _x, f64 _y, f64 _r) : x(_x), y(_y), r(_r) {}
- inline bool operator==(const dcircle& c){ return (x==c.x && y==c.y && r==c.r); };
- inline bool operator!=(const dcircle& c){ return (x!=c.x && y!=c.y && r!=c.r); };
- inline void operator-=(const dpoint& p){ x -= p.x; y -= p.y; }
- inline void operator+=(const dpoint& p){ x += p.x; y += p.y; }
- };
- struct dpoint3d {
- f64 x, y, z;
- dpoint3d() : x(0.0), y(0.0), z(0.0) {}
- dpoint3d(f64 _x, f64 _y, f64 _z) : x(_x), y(_y), z(_z) {}
- inline bool operator==(const dpoint3d& p){ return (x==p.x && y==p.y && z==p.z); }
- inline bool operator!=(const dpoint3d& p){ return (x!=p.x && y!=p.y && z!=p.z); }
- };
- }; /* namespace shape */
- }; /* namespace kit */
- #ifdef KIT_VIDEO_COMMON_REMOVE_PADDING
- #pragma pack(pop)
- #endif /* KIT_VIDEO_COMMON_REMOVE_PADDING */
- #endif /* _KIT_INC__VIDEO_COMMON_HPP */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement