started to fix the manuals for EBuf. Implemented a
[neuro.git] / include / neuro / other.h
blob9169b202e0fa7810d632ca03991ae3e205085708
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"
31 #include <stdlib.h>
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
37 extern char **Neuro_SepChr(const unsigned char chr, char *source, int *items);
39 /* the EBUF data uses this struct */
40 typedef struct SepChr_Data
42 char *string;
43 }SepChr_Data;
45 extern EBUF *Neuro_SepChr2(const u8 chr, char *source);
47 /* convert color of default screen depth to 24 bit
48 * and gives each color separately in R G and B
50 extern void Neuro_GiveConvertRGB(u32 color, u8 *R, u8 *G, u8 *B);
52 /* 4 functions to convert R G B values to the depth each of them do */
53 extern u32 Neuro_GiveRGB32(u8 R, u8 G, u8 B);
54 extern u32 Neuro_GiveRGB24(u8 R, u8 G, u8 B);
55 extern u32 Neuro_GiveRGB16(u8 R, u8 G, u8 B);
56 extern u32 Neuro_GiveRGB8(u8 R, u8 G, u8 B);
58 /* instead of using the above(Neuro_GiveRGB*), use this function that automatically
59 * check the current depth in use and use the correct one.
61 extern u32 Neuro_MapRGB(u8 R, u8 G, u8 B);
63 /* uses the SDL special RGBA system, if in doubt, use
64 * Neuro_MapRGB instead. (used internally)
65 * returns a u32 that contains a 24bit color system.
67 extern u32 Neuro_GiveRGB(u8 R, u8 G, u8 B);
69 /* an interface to easily give the size of an image object
70 * width and height require the address of u32 to put the data on.
72 extern void Neuro_GiveImageSize(v_object *image, i32 *width, i32 *height);
74 extern u32 Neuro_RawGetPixel(v_object *srf, int x, int y);
76 extern void Neuro_RawPutPixel(v_object *srf, int x, int y, u32 pixel);
78 extern void Neuro_Sleep(u32 t);
80 extern u32 Neuro_GetTickCount();
82 extern void Neuro_PrintFPS();
84 /* use Neuro_BoundsCheck instead */
85 extern u8 Neuro_DumbBoundsCheck(Rectan *indep, Rectan *depen);
87 /* rectangle or square bounds check function.
88 * return values :
89 * 0 = depen is inside indep.
90 * 1 = depen and indep are not touching each others(they are far away).
91 * 2 = depen is overlaping indep.
92 * 3 = depen and indep links between corners are into the other but the corners
93 * are not touching.
94 * 4 = indep is inside depen (reverse of 0)
96 extern u8 Neuro_BoundsCheck(Rectan *indep, Rectan *depen);
98 extern void Neuro_VerticalBoundCrop(Rectan *indep, Rectan *isrc, Rectan *idst);
100 extern void Neuro_HorizontalBoundCrop(Rectan *indep, Rectan *isrc, Rectan *idst);
102 /* generate characters (source is chgen.c in src/misc TODO might need to have the Neuro_ prefix */
103 extern void Uchar(int amount, unsigned char **buf);
105 /* internal function (source is bitmap.c in src/misc) */
106 extern void readBitmapFileToPixmap(const char *bitmap, EBUF **output_pixmap);
107 extern void readBitmapBufferToPixmap(char *data, EBUF **output_pixmap);
108 extern void setBitmapColorKey(u32 key);
109 extern v_object *readBitmapFile(const char *bitmap);
110 /* internal function (source is bitmap.c in src/misc)
111 * pretty much useless, use Neuro_CleanEBuf() instead
113 extern void cleanPixmapEbuf(EBUF **pixmap);
115 /* -------- Argument System ---------- */
117 enum
119 OPTION_NORMAL = 0x00000000, /* normal option which includes a callback or not */
120 OPTION_ARGUMENT = 0x00000001, /* needs an argument */
121 OPTION_REQUIRED = 0x00000010, /* is required to make the app run */
122 OPTION_NESTED = 0x00000100, /* can be nested with other */
123 OPTION_MULTI = 0x00001000, /* can have more than one option of this type */
124 OPTION_VOID = 0x00010000, /* when the command has no options, this option is executed */
125 OPTION_QUIT = 0x00100000 /* when this option is called, no more options r executed. */
128 extern int Neuro_ArgInit(int argc, char **argv);
130 extern void Neuro_ArgClean();
132 extern void Neuro_ArgOption(char *string, int options, void (*action)(char *data));
134 /* return 2 on error, 1 on normal exit requested and 0 on execution continue */
135 extern int Neuro_ArgProcess();
137 /* ---------- End of the Argument System ---------- */
140 /* blit one surface to another one with this function */
141 extern void Neuro_BlitObject(v_object *source, Rectan *src, v_object *destination, Rectan *dst);
143 /* free a v_object after its use is no longer needed. */
144 extern void Neuro_FreeVObject(v_object *source);
146 /* load a M$ bitmap from a file that you input
147 * pass the address of a pointer v_object :
148 * v_object *image;
150 * and pointer for that is &image
152 extern void Neuro_LoadBMP(const char *path, v_object **img);
154 /* sets the color key that will not be drawn (for transparency) of a surface.
155 * this needs to be done strictly before loading a surface with X11 and
156 * can be done anytime with SDL.
158 extern void Neuro_SetColorKey(v_object *vobj, u32 key);
160 /* sets the alpha (transparency) of a surface */
161 extern void Neuro_SetAlpha(v_object *vobj, u8 alpha);
163 /* syncs the pixels so subsequent input or output on them
164 * are getting correct informations.
166 extern void Neuro_SyncPixels(v_object *src);
168 /* create visual surfaces with this function */
169 extern v_object * Neuro_CreateVObject(u32 flags, i32 width, i32 height, i32 depth, u32 Rmask, u32 Gmask, u32 Bmask, u32 Amask);
172 /* you can load a truetype (or any other that the freetype library
173 * supports) with this function.
174 * returns NULL on error or a pointer to a font_object.
176 extern font_object *Neuro_LoadFontFile(const char *fonts_file_path);
178 /* this function is to clean a font file
179 * loaded using the function Neuro_LoadFontFile()
181 extern void Neuro_CleanFont(font_object *font);
183 /* even though the input arguments seem to be quite complicated, it is not.
184 * the ttf input address can be given with the load fonts function, the size
185 * is the size of the fonts you want in pixels, the character is the character
186 * code you want to render.
188 * The x and y coordinates are a bit special, the value in those are changed so
189 * characters in a string have the correct spacing(instead of overlapping).
191 * color is the color you want your character to be and the 2 Rectan output
192 * the basic informations about the surface so it can be blit easily.
194 * returns the v_object pointer if the character got loaded well or
195 * NULL if either there was an error or the character that was input
196 * requires more than one byte to be complete.
198 * NOTE This function do handle spaces! ie ' '. just input the corresponding
199 * x and y addresses so the function can calculate itself the size they take.
200 * For this purpose, you CAN leave color, src and dst to 0 or NULL!
201 * just remember to put the correct size and character (to ' ') so the size
202 * of the space is correct.
204 extern v_object *Neuro_RenderUnicode(font_object *ttf, u32 size, u32 character,
205 i16 *x, i16 *y, u32 color, Rectan *src, Rectan *dst);
207 /* you can set the size of the screen with this function.
208 * note that this function will not work on the fly, you
209 * can only use this __before__ you init Neuro! or
210 * else it won't work.
212 extern void Lib_SetScreenSize(u32 width, u32 height);
214 /* puts the size of the screen in current use in the input variables */
215 extern void Lib_GetScreenSize(u32 *width, u32 *height);
217 /* for pixel manipulations (input/output) this locks the lock on
218 * the pixels buffer. So nothing can be done in the background on
219 * them.
221 extern void Lib_LockVObject(v_object *vobj);
223 /* for pixel manipulations (input/output) this unlocks the lock on
224 * the pixels buffer.
226 extern void Lib_UnlockVObject(v_object *vobj);
228 #ifdef __cplusplus
230 #endif
232 #endif /* __OTHER_H */