00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __MX_TYPES_H__
00018 #define __MX_TYPES_H__
00019
00020 #include<iostream>
00021 #include<string>
00022 #include<cstdlib>
00023
00024 #include "SDL.h"
00025 #include "mxf.h"
00026 #include "mx_exception.h"
00027 #include "mxsurface.h"
00028 #include "mxtype.h"
00029
00030
00031 namespace mx
00032 {
00033
00034 SDL_Surface *CreateBuffer(size_t w = 640, size_t h = 480);
00035
00039 typedef union __Color
00040 {
00042 unsigned int value;
00044 unsigned char colors[4];
00046 __Color() { value = 0; }
00050 __Color(unsigned int v) { value = v; }
00056 __Color( unsigned char r, unsigned char g, unsigned char b)
00057 {
00058 colors[0] = r, colors[1] = g, colors[2] = b;
00059 }
00060 } _Color;
00061
00063 class Color {
00064
00065 public:
00067 Color();
00073 Color(unsigned char r, unsigned char g, unsigned char b);
00077 Color(const unsigned int value);
00081 Color(const Color &c);
00085 Color(const __Color &c);
00089 Color(const SDL_Color &c);
00090
00091
00092
00097 Color& operator=(const Color &c);
00102 Color& operator=(const unsigned int long_x);
00107 Color& operator=(const SDL_Color &c);
00108
00112 const unsigned int toInteger() const;
00116 const SDL_Color toSDL_Color() const;
00118 __Color color;
00126 static unsigned int mapRGB(mx::mxSurface &surface, unsigned char r, unsigned char g, unsigned char b)
00127 {
00128 return SDL_MapRGB(surface.getSurface()->format, r, g, b);
00129 }
00135 static unsigned int mapRGB(mx::mxSurface &surface, const __Color &c)
00136 {
00137 return SDL_MapRGB(surface.getSurface()->format, c.colors[0], c.colors[1], c.colors[2]);
00138 }
00144 static unsigned int mapRGB(mx::mxSurface &surface, const Color &c)
00145 {
00146 return mapRGB(surface, c.color);
00147 }
00148
00154 static unsigned int mapRGB(SDL_Surface *surface, const Color &c) {
00155 return SDL_MapRGB(surface->format, c.color.colors[0], c.color.colors[1], c.color.colors[2]);
00156 }
00157 };
00158
00160 typedef signed char s8_t;
00162 typedef unsigned char u8_t;
00164 typedef signed short s16_t;
00166 typedef unsigned short u16_t;
00168 typedef signed int s32_t;
00170 typedef unsigned int u32_t;
00171 }
00172
00173
00174 #endif
00175
00176