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