Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef DRAW_H_INCLUDED
- #define DRAW_H_INCLUDED
- #include <GL/gl.h>
- #include <GL/glext.h>
- #include <stdint.h>
- ///OGL texture structs
- //textures are the format OGL blits, non editable data -(loaded sprites/images)
- struct OGL_Texture{
- protected:
- bool texture_generated;
- public:
- GLuint Texture_ID;
- uint32_t w,h;
- void gen_texture(uint16_t w, uint16_t h, uint8_t *PixData);
- OGL_Texture();
- ~OGL_Texture();
- };
- //surfaces contain editable pixel data, can be cast to textures for blitting -(effects, debug/primitive data draws)
- struct OGL_Surface : OGL_Texture{
- uint32_t w,h;
- uint8_t bpp;
- uint8_t *PixData;
- void Create_Surface(uint16_t w,uint16_t h, char bpp);
- void Clear_Surface(uint8_t r, uint8_t g, uint8_t b, uint8_t a=255);
- void Set_Surface_AlphaKey(uint8_t r, uint8_t g, uint8_t b);
- void gen_texture();
- OGL_Surface();
- ~OGL_Surface();
- };
- OGL_Texture *Texture_Cast(OGL_Surface *Surface);
- ////////
- //BLIT//
- ////////
- enum Image_Options{
- IMG_NORM = 0,
- IMG_HFLIP = 1,
- IMG_VFLIP = 2,
- IMG_ADD_BLEND = 3
- };
- void DrawImage(OGL_Texture *Texture, int dx, int dy, float rot=0.0,float scale_x=1.0,float scale_y=1.0,float alpha=1.0,int options=0);
- void DrawSubImage(OGL_Texture *Texture, int sx, int sy, int sw, int sh, int dx, int dy, float rot=0.0,float scale_x=1.0,float scale_y=1.0,float alpha=1.0,int options=0);
- //////////
- //COLOUR//
- //////////
- uint32_t make_col(uint8_t r, uint8_t g, uint8_t b, uint8_t a);
- uint32_t make_col(uint8_t r, uint8_t g, uint8_t b);
- ///////////////////
- //DRAW PRIMITIVES//
- ///////////////////
- bool putpixel(OGL_Surface *Surface, int x, int y, uint32_t col);
- bool getpixel(OGL_Surface *Surface, int x, int y, uint32_t &col);
- //
- void hline(OGL_Surface *Surface, int x, int y, int w, uint32_t col);
- void vline(OGL_Surface *Surface, int x, int y, int h, uint32_t col);
- void line(OGL_Surface *Surface, int x1, int y1, int x2, int y2, uint32_t col);
- void box(OGL_Surface *Surface, int x, int y, int w, int h, uint32_t col);
- void rect(OGL_Surface *Surface, int x, int y, int w, int h, uint32_t col);
- void polyline(OGL_Surface *Surface, unsigned char n, int points[], uint32_t col);
- void polygon(OGL_Surface *Surface, unsigned char n, int points[], uint32_t col);
- void circle(OGL_Surface *Surface, int x0, int y0, int radius, uint32_t col);
- void circle_fill(OGL_Surface *Surface, int x0, int y0, int radius, uint32_t col);
- //
- #endif // DRAW_H_INCLUDED
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement