Disabled the debugging functions temporarily.
[neuro.git] / include / neuro / other.h
blobf21639300472ab680e1113b847349c00b4d37037
2 /*
3 * libneuro, a light weight abstraction of high or lower libraries
4 * and toolkit for applications.
5 * Copyright (C) 2005-2006 Nicholas Niro, Robert Lemay
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 /* other.h
25 #ifndef __OTHER_H
26 #define __OTHER_H
28 #include "neuro_engine.h"
29 #include "ebuf.h"
30 #include "bitmap.h"
32 #include <stdlib.h>
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
38 /*--- string manipulation ---*/
40 extern char **Neuro_SepChr(const unsigned char chr, char *source, int *items);
42 /* the EBUF data uses this struct */
43 typedef struct SepChr_Data
45 char *string;
46 }SepChr_Data;
48 extern EBUF *Neuro_SepChr2(const u8 chr, char *source);
50 /*--- end string manipulation ---*/
52 /*--- RGB ---*/
54 /* convert color of default screen depth to 24 bit
55 * and gives each color separately in R G and B
57 extern void Neuro_GiveConvertRGB(u32 color, u8 *R, u8 *G, u8 *B);
59 /* 4 functions to convert R G B values to the depth each of them do */
60 extern u32 Neuro_GiveRGB32(u8 R, u8 G, u8 B);
61 extern u32 Neuro_GiveRGB24(u8 R, u8 G, u8 B);
62 extern u32 Neuro_GiveRGB16(u8 R, u8 G, u8 B);
63 extern u32 Neuro_GiveRGB8(u8 R, u8 G, u8 B);
65 /* instead of using the above(Neuro_GiveRGB*), use this function that automatically
66 * check the current depth in use and use the correct one.
68 extern u32 Neuro_MapRGB(u8 R, u8 G, u8 B);
70 /* uses the SDL special RGBA system, if in doubt, use
71 * Neuro_MapRGB instead. (used internally)
72 * returns a u32 that contains a 24bit color system.
74 extern u32 Neuro_GiveRGB(u8 R, u8 G, u8 B);
75 /*--- end RGB ---*/
77 /*--- util ---*/
79 /* an interface to easily give the size of an image object
80 * width and height require the address of u32 to put the data on.
82 extern void Neuro_GiveImageSize(v_object *image, i32 *width, i32 *height);
84 extern void Neuro_Sleep(u32 t);
86 extern u32 Neuro_GetTickCount();
88 extern void Neuro_PrintFPS();
90 /*--- end util ---*/
92 /*--- crop ---*/
94 /* use Neuro_BoundsCheck instead */
95 extern u8 Neuro_DumbBoundsCheck(Rectan *indep, Rectan *depen);
97 /* rectangle or square bounds check function.
98 * return values :
99 * 0 = depen is inside indep.
100 * 1 = depen and indep are not touching each others(they are far away).
101 * 2 = depen is overlaping indep.
102 * 3 = depen and indep links between corners are into the other but the corners
103 * are not touching.
104 * 4 = indep is inside depen (reverse of 0)
106 extern u8 Neuro_BoundsCheck(Rectan *indep, Rectan *depen);
108 extern void Neuro_VerticalBoundCrop(Rectan *indep, Rectan *isrc, Rectan *idst);
110 extern void Neuro_HorizontalBoundCrop(Rectan *indep, Rectan *isrc, Rectan *idst);
112 /*--- end crop ---*/
114 /*--- obsolete ---*/
116 /* generate characters (source is chgen.c in src/misc TODO might need to have the Neuro_ prefix */
117 extern void Uchar(int amount, unsigned char **buf);
119 /* internal function (source is bitmap.c in src/misc) */
120 extern void readBitmapFileToPixmap(const char *bitmap, EBUF **output_pixmap);
121 extern void readBitmapBufferToPixmap(char *data, EBUF **output_pixmap);
122 extern void setBitmapColorKey(u32 key);
123 extern v_object *readBitmapFile(const char *bitmap);
124 /* internal function (source is bitmap.c in src/misc)
125 * pretty much useless, use Neuro_CleanEBuf() instead
127 extern void cleanPixmapEbuf(EBUF **pixmap);
129 /*--- end Obsolete ---*/
131 /* -------- Argument System ---------- */
133 enum
135 OPTION_NORMAL = 0x00000000, /* normal option which includes a callback or not */
136 OPTION_ARGUMENT = 0x00000001, /* needs an argument */
137 OPTION_REQUIRED = 0x00000002, /* is required to make the app run */
138 OPTION_NESTED = 0x00000004, /* can be nested with other */
139 OPTION_MULTI = 0x00000008, /* can have more than one option of this type */
140 OPTION_VOID = 0x00000010, /* when the command has no options, this option is executed */
141 OPTION_QUIT = 0x00000020 /* when this option is called, no more options are executed. */
144 extern int Neuro_ArgInit(int argc, char **argv);
146 extern void Neuro_ArgClean();
148 /* string contains normally two strings separated by a comma.
149 * an example : "h,help" this will handle the -h and --help
150 * arguments.
152 extern void Neuro_ArgOption(char *string, int options, void (*action)(char *data));
154 /* return 2 on error, 1 on normal exit requested and 0 on execution continue */
155 extern int Neuro_ArgProcess();
157 /* ---------- End of the Argument System ---------- */
160 /*--- extlib Neuro_ interface ---*/
162 extern u32 Neuro_RawGetPixel(v_object *srf, int x, int y);
164 extern void Neuro_RawPutPixel(v_object *srf, int x, int y, u32 pixel);
166 /* blit one surface to another one with this function */
167 extern void Neuro_BlitObject(v_object *source, Rectan *src, v_object *destination, Rectan *dst);
169 /* free a v_object after its use is no longer needed. */
170 extern void Neuro_FreeVObject(v_object *source);
172 /* load a M$ bitmap from a file that you input
173 * pass the address of a pointer v_object :
174 * v_object *image;
176 * and pointer for that is &image
178 extern void Neuro_LoadBMP(const char *path, v_object **img);
180 /* sets the color key that will not be drawn (for transparency) of a surface.
181 * this needs to be done strictly before loading a surface with X11 and
182 * can be done anytime with SDL.
184 extern void Neuro_SetColorKey(v_object *vobj, u32 key);
186 /* sets the alpha (transparency) of a surface */
187 extern void Neuro_SetAlpha(v_object *vobj, u8 alpha);
189 /* syncs the pixels so subsequent input or output on them
190 * are getting correct informations.
192 extern void Neuro_SyncPixels(v_object *src);
194 /* create visual surfaces with this function
196 * depth, Rmask, Gmask, Bmask, Amask
197 * leave those arguments to 0 and it will
198 * use the default values for them.
200 extern v_object * Neuro_CreateVObject(u32 flags, i32 width, i32 height, i32 depth, u32 Rmask, u32 Gmask, u32 Bmask, u32 Amask);
203 /* you can load a truetype (or any other that the freetype library
204 * supports) with this function.
205 * returns NULL on error or a pointer to a font_object.
207 extern font_object *Neuro_LoadFontFile(const char *fonts_file_path);
209 /* this function is to clean a font file
210 * loaded using the function Neuro_LoadFontFile()
212 extern void Neuro_CleanFont(font_object *font);
214 /* even though the input arguments seem to be quite complicated, it is not.
215 * the ttf input address can be given with the load fonts function, the size
216 * is the size of the fonts you want in pixels, the character is the character
217 * code you want to render.
219 * The x and y coordinates are a bit special, the value in those are changed so
220 * characters in a string have the correct spacing(instead of overlapping).
222 * color is the color you want your character to be and the 2 Rectan output
223 * the basic informations about the surface so it can be blit easily.
225 * returns the v_object pointer if the character got loaded well or
226 * NULL if either there was an error or the character that was input
227 * requires more than one byte to be complete.
229 * NOTE This function do handle spaces! ie ' '. just input the corresponding
230 * x and y addresses so the function can calculate itself the size they take.
231 * For this purpose, you CAN leave color, src and dst to 0 or NULL!
232 * just remember to put the correct size and character (to ' ') so the size
233 * of the space is correct.
235 extern v_object *Neuro_RenderUnicode(font_object *ttf, u32 size, u32 character,
236 i16 *x, i16 *y, u32 color, Rectan *src, Rectan *dst);
238 /* you can set the size of the screen with this function.
239 * note that this function will not work on the fly, you
240 * can only use this __before__ you init Neuro! or
241 * else it won't work.
243 extern void Neuro_SetScreenSize(i32 width, i32 height);
245 /* puts the size of the screen in current use in the input variables */
246 extern void Neuro_GetScreenSize(i32 *width, i32 *height);
247 #define Neuro_GiveScreenSize Neuro_GetScreenSize
249 /* for pixel manipulations (input/output) this locks the lock on
250 * the pixels buffer. So nothing can be done in the background on
251 * them.
253 extern void Neuro_LockVObject(v_object *vobj);
255 /* for pixel manipulations (input/output) this unlocks the lock on
256 * the pixels buffer.
258 extern void Neuro_UnlockVObject(v_object *vobj);
260 /*--- end extlib Neuro_ interface ---*/
262 /* don't touch this :) */
264 /* temporary macros to call the functions from bitmap.h */
265 #define Neuro_CreateBMPCTX Bitmap_CreateCTX
266 #define Neuro_DestroyBMPCTX Bitmap_DestroyCTX
267 #define Neuro_GradualLoadBMP Bitmap_Poll
269 #ifdef __cplusplus
271 #endif
273 #endif /* __OTHER_H */