Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // gLib2D by Geecko - A simple, fast, light-weight 2D graphics library.
- //
- // This work is licensed under the Creative Commons BY-SA 3.0 Unported License.
- // See LICENSE for more details.
- #ifndef GLIB2D_H
- #define GLIB2D_H
- //#define USE_VFPU TODO
- #define USE_PNG
- //#define USE_JPG TODO
- #define G_SCR_W (480)
- #define G_SCR_H (272)
- #define G_FALSE 0
- #define G_TRUE !0
- #define G_RGBA(r,g,b,a) \
- ((r)|((g)<<8)|((b)<<16)|((a)<<24))
- #define G_GET_R(color) (((color) ) & 0xFF)
- #define G_GET_G(color) (((color)>>8 ) & 0xFF)
- #define G_GET_B(color) (((color)>>16) & 0xFF)
- #define G_GET_A(color) (((color)>>24) & 0xFF)
- #define G_MODULATE(color,luminance,alpha) \
- G_RGBA(luminance*G_GET_R(color)/255, \
- luminance*G_GET_G(color)/255, \
- luminance*G_GET_B(color)/255, \
- alpha *G_GET_A(color)/255)
- enum gColors
- {
- // Primary colors
- RED = 0xFF0000FF,
- GREEN = 0xFF00FF00,
- BLUE = 0xFFFF0000,
- // Secondary colors
- CYAN = 0xFFFFFF00,
- MAGENTA = 0xFFFF00FF,
- YELLOW = 0xFF00FFFF,
- // Tertiary colors
- AZURE = 0xFFFF7F00,
- VIOLET = 0xFFFF007F,
- ROSE = 0xFF7F00FF,
- ORANGE = 0xFF007FFF,
- CHARTREUSE = 0xFF00FF7F,
- SPRING_GREEN = 0xFF7FFF00,
- // Grayscale
- WHITE = 0xFFFFFFFF,
- LITEGRAY = 0xFFBFBFBF,
- GRAY = 0xFF7F7F7F,
- DARKGRAY = 0xFF3F3F3F,
- BLACK = 0xFF000000
- };
- // First gEnum is the default.
- enum Coord_Modes { G_UP_LEFT, G_UP_RIGHT, G_DOWN_RIGHT, G_DOWN_LEFT, G_CENTER };
- typedef char bool;
- typedef unsigned char gAlpha;
- typedef unsigned int gColor;
- typedef int gEnum;
- typedef struct
- {
- int tw, th;
- int w, h;
- float ratio;
- bool swizzled;
- gColor* data;
- } gImage;
- void gClear(gColor color); // Clears screen & depth buffer (if used in the loop)
- void gClearZ(); // Clears depth buffer
- void gBegin(gImage* tex, bool use_tex_blend); // Begin Object
- void gEnd(); // End & draw Object
- void gReset(); // Call all gReset* functions (for gSetRelative* stuff)
- void gFlip(bool vsync); // Flip the screen
- void gAdd(); // Adds an obj to the render list.
- // Transform stack
- void gPush();
- void gPop();
- // All gSet* functions must be called between gBegin() & gEnd()
- // All gSetRelative* functions are relative to the others gSet* functions parameters
- void gResetCoord(); // Set to G_UP_LEFT and (0.f;0.f;0.f)
- void gSetCoordMode(gEnum mode); // Choose between Coord_Modes
- void gSetCoordXY(float x, float y); // New object (or vertex)
- void gSetCoordXYZ(float x, float y, float z); // New object (or vertex) with zbuffer
- void gSetCoordXYRelative(float x, float y, bool use_rot);
- void gSetCoordXYZRelative(float x, float y, float z, bool use_rot);
- void gResetCrop();
- void gSetCropXY(int x, int y); // Image part to blit, position
- void gSetCropWH(int w, int h); // Image part to blit, size
- void gSetCropXYRelative(int x, int y);
- void gSetCropWHRelative(int w, int h);
- void gResetScale(); // Set scale to 1.f,1.f
- void gSetScale(float w, float h); // Set scale from 0.f to 1.f, value can be negative to invert
- void gSetScaleWH(int w, int h); // Set new width & height, an alternative to gSetScale
- void gSetScaleRelative(float w, float h);
- void gSetScaleWHRelative(int w, int h);
- void gResetColor(); // Set color to WHITE
- void gResetAlpha(); // Set alpha to 255
- void gSetColor(gColor color); // Set color of the object, used to colorize it
- void gSetAlpha(gAlpha alpha); // Set alpha of the object, proportionnal with the color alpha.
- void gSetAlphaRelative(gAlpha alpha);
- void gResetRotation(); // Set rotation to 0°
- void gSetRotationRad(float radians); // Sets the rotation angle, in radians.
- void gSetRotation(float degrees); // Sets the rotation angle, in degrees.
- void gSetRotationRadRelative(float radians);
- void gSetRotationRelative(float degrees);
- gImage* gTexLoad(char path[], bool swizzle); // Load an image file, can be swizzled (fastest)
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement