mirror of
https://github.com/aap/librw.git
synced 2026-01-25 20:42:56 +00:00
implemented im3d for gl3 and d3d
This commit is contained in:
61
src/rwbase.h
61
src/rwbase.h
@@ -61,6 +61,66 @@ typedef uint32 uint;
|
||||
|
||||
#define nelem(A) (sizeof(A) / sizeof A[0])
|
||||
|
||||
// Lists
|
||||
|
||||
struct LLLink
|
||||
{
|
||||
LLLink *next;
|
||||
LLLink *prev;
|
||||
void init(void){
|
||||
this->next = nil;
|
||||
this->prev = nil;
|
||||
}
|
||||
void remove(void){
|
||||
this->prev->next = this->next;
|
||||
this->next->prev = this->prev;
|
||||
}
|
||||
};
|
||||
|
||||
#define LLLinkGetData(linkvar,type,entry) \
|
||||
((type*)(((uint8*)(linkvar))-offsetof(type,entry)))
|
||||
|
||||
// Have to be careful since the link might be deleted.
|
||||
#define FORLIST(_link, _list) \
|
||||
for(rw::LLLink *_next = nil, *_link = (_list).link.next; \
|
||||
_next = (_link)->next, (_link) != (_list).end(); \
|
||||
(_link) = _next)
|
||||
|
||||
struct LinkList
|
||||
{
|
||||
LLLink link;
|
||||
void init(void){
|
||||
this->link.next = &this->link;
|
||||
this->link.prev = &this->link;
|
||||
}
|
||||
bool32 isEmpty(void){
|
||||
return this->link.next == &this->link;
|
||||
}
|
||||
void add(LLLink *link){
|
||||
link->next = this->link.next;
|
||||
link->prev = &this->link;
|
||||
this->link.next->prev = link;
|
||||
this->link.next = link;
|
||||
}
|
||||
void append(LLLink *link){
|
||||
link->next = &this->link;
|
||||
link->prev = this->link.prev;
|
||||
this->link.prev->next = link;
|
||||
this->link.prev = link;
|
||||
}
|
||||
LLLink *end(void){
|
||||
return &this->link;
|
||||
}
|
||||
int32 count(void){
|
||||
int32 n = 0;
|
||||
FORLIST(lnk, (*this))
|
||||
n++;
|
||||
return n;
|
||||
}
|
||||
};
|
||||
|
||||
// Mathematical types
|
||||
|
||||
struct RGBA
|
||||
{
|
||||
uint8 red;
|
||||
@@ -68,6 +128,7 @@ struct RGBA
|
||||
uint8 blue;
|
||||
uint8 alpha;
|
||||
};
|
||||
inline RGBA makeRGBA(uint8 r, uint8 g, uint8 b, uint8 a) { RGBA c = { r, g, b, a }; return c; }
|
||||
inline bool32 equal(const RGBA &c1, const RGBA &c2) { return c1.red == c2.red && c1.green == c2.green && c1.blue == c2.blue && c1.alpha == c2.alpha; }
|
||||
|
||||
struct RGBAf
|
||||
|
||||
Reference in New Issue
Block a user