47 #ifndef _quickcg_h_included
48 #define _quickcg_h_included
67 const T template_abs(
const T &a)
69 return (a < 0) ? -a : a;
74 std::string valtostr(
const T& val)
76 std::ostringstream sstream;
83 T strtoval(
const std::string& s)
85 std::istringstream sstream(s);
93 std::string valtostr(
const T& val,
int length,
bool fixed =
true)
95 std::ostringstream sstream;
96 if(fixed) sstream << std::fixed;
97 sstream << std::setprecision(length) << val;
113 ColorRGB(Uint8 r, Uint8 g, Uint8 b);
126 static const ColorRGB RGB_Black ( 0, 0, 0);
127 static const ColorRGB RGB_Red (255, 0, 0);
128 static const ColorRGB RGB_Green ( 0, 255, 0);
129 static const ColorRGB RGB_Blue ( 0, 0, 255);
130 static const ColorRGB RGB_Cyan ( 0, 255, 255);
131 static const ColorRGB RGB_Magenta (255, 0, 255);
132 static const ColorRGB RGB_Yellow (255, 255, 0);
133 static const ColorRGB RGB_White (255, 255, 255);
134 static const ColorRGB RGB_Gray (128, 128, 128);
135 static const ColorRGB RGB_Grey (192, 192, 192);
136 static const ColorRGB RGB_Maroon (128, 0, 0);
137 static const ColorRGB RGB_Darkgreen( 0, 128, 0);
138 static const ColorRGB RGB_Navy ( 0, 0, 128);
139 static const ColorRGB RGB_Teal ( 0, 128, 128);
140 static const ColorRGB RGB_Purple (128, 0, 128);
141 static const ColorRGB RGB_Olive (128, 128, 0);
162 ColorHSL(Uint8 h, Uint8 s, Uint8 l);
173 ColorHSV(Uint8 h, Uint8 s, Uint8 v);
188 bool keyDown(
int key);
189 bool keyPressed(
int key);
195 void screen(
int width = 640,
int height = 400,
bool fullscreen = 0,
const std::string& text =
" ");
199 void cls(
const ColorRGB& color = RGB_Black);
200 void pset(
int x,
int y,
const ColorRGB& color);
202 void drawBuffer(Uint32 *buffer);
203 bool onScreen(
int x,
int y);
204 SDL_Surface* getScreenSurface();
211 void waitFrame(
double oldTime,
double frameDuration);
212 bool done(
bool quit_if_esc =
true,
bool delay =
true);
216 void getMouseState(
int&
mouseX,
int&
mouseY,
bool& LMB,
bool& RMB);
217 unsigned long getTicks();
218 inline double getTime() {
return getTicks() / 1000.0; }
224 bool horLine(
int y,
int x1,
int x2,
const ColorRGB& color);
225 bool verLine(
int x,
int y1,
int y2,
const ColorRGB& color);
226 bool drawLine(
int x1,
int y1,
int x2,
int y2,
const ColorRGB& color);
227 bool drawCircle(
int xc,
int yc,
int radius,
const ColorRGB& color);
228 bool drawDisk(
int xc,
int yc,
int radius,
const ColorRGB& color);
229 bool drawRect(
int x1,
int y1,
int x2,
int y2,
const ColorRGB& color);
230 bool clipLine(
int x1,
int y1,
int x2,
int y2,
int & x3,
int & y3,
int & x4,
int & y4);
235 ColorHSL RGBtoHSL(
const ColorRGB& colorRGB);
236 ColorRGB HSLtoRGB(
const ColorHSL& colorHSL);
237 ColorHSV RGBtoHSV(
const ColorRGB& colorRGB);
238 ColorRGB HSVtoRGB(
const ColorHSV& colorHSV);
239 Uint32 RGBtoINT(
const ColorRGB& colorRGB);
240 ColorRGB INTtoRGB(Uint32 colorINT);
246 void loadFile(std::vector<unsigned char>& buffer,
const std::string& filename);
247 void saveFile(
const std::vector<unsigned char>& buffer,
const std::string& filename);
253 int loadImage(std::vector<ColorRGB>& out,
unsigned long& w,
unsigned long& h,
const std::string& filename);
254 int loadImage(std::vector<Uint32>& out,
unsigned long& w,
unsigned long& h,
const std::string& filename);
255 int decodePNG(std::vector<unsigned char>& out_image_32bit,
unsigned long& image_width,
unsigned long& image_height,
const unsigned char* in_png,
unsigned long in_size);
256 int decodePNG(std::vector<unsigned char>& out_image_32bit,
unsigned long& image_width,
unsigned long& image_height,
const std::vector<unsigned char>& in_png);
261 extern bool font[256][8][8];
262 void drawLetter(
unsigned char n,
int x,
int y,
const ColorRGB& color = RGB_White,
bool bg = 0,
const ColorRGB& color2 = RGB_Black);
263 int printString(
const std::string& text,
int x = 0,
int y = 0,
const ColorRGB& color = RGB_White,
bool bg = 0,
const ColorRGB& color2 = RGB_Black,
int forceLength = 0);
267 int print(
const T& val,
int x = 0,
int y = 0,
const ColorRGB& color = RGB_White,
bool bg = 0,
const ColorRGB& color2 = RGB_Black,
int forceLength = 0)
269 std::string text = valtostr(val);
270 return printString(text, x, y, color, bg, color2, forceLength);
275 int fprint(
const T& val,
int length,
int x = 0,
int y = 0,
const ColorRGB& color = RGB_White,
bool bg = 0,
const ColorRGB& color2 = RGB_Black,
int forceLength = 0)
277 std::string text = valtostr(val, length,
true);
278 return printString(text, x, y, color, bg, color2, forceLength);
284 Uint8 getInputCharacter();
285 void getInputString(std::string& text,
const std::string& message =
"",
bool clear =
false,
int x = 0,
int y = 0,
const ColorRGB& color = RGB_White,
bool bg = 0,
const ColorRGB& color2 = RGB_Black);
288 T getInput(
const std::string& message =
"",
bool clear =
false,
int x = 0,
int y = 0,
const ColorRGB& color = RGB_White,
bool bg = 0,
const ColorRGB& color2 = RGB_Black)
291 getInputString(text, message, clear, x, y, color, bg, color2);
292 return strtoval<T>(text);
299 int audioOpen(
int samplerate,
int framesize);
307 void audioPushSamples(
const std::vector<double>& samples,
size_t pos,
size_t end);
309 size_t audioSamplesShortage();
310 size_t audioSamplesOverflow();
311 void audioSetBufferSamplesRange(
size_t min_samples,
size_t max_samples);
320 void audioPlay(
const std::vector<double>& samples);
322 void audioSetMode(
int mode);
323 void audioSetVolume(
double volume);
Definition: quickcg.h:107
int mouseX
Variabile globale che contiene le coordinate X del mouse.
Definition: vsgl.cpp:26
int mouseY
Variabile globale che contiene le coordinate Y del mouse.
Definition: vsgl.cpp:26
Definition: quickcg.h:156
Definition: quickcg.h:144
Definition: quickcg.h:167