Advertisement
Guest User

draw.h

a guest
Jul 5th, 2012
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #ifndef DRAW_H_INCLUDED
  2. #define DRAW_H_INCLUDED
  3.  
  4. #include <GL/gl.h>
  5. #include <GL/glext.h>
  6. #include <stdint.h>
  7.  
  8.  
  9. ///OGL texture structs
  10. //textures are the format OGL blits, non editable data -(loaded sprites/images)
  11. struct OGL_Texture{
  12.     protected:
  13.     bool texture_generated;
  14.  
  15.     public:
  16.     GLuint Texture_ID;
  17.     uint32_t w,h;
  18.  
  19.     void gen_texture(uint16_t w, uint16_t h, uint8_t *PixData);
  20.  
  21.     OGL_Texture();
  22.     ~OGL_Texture();
  23. };
  24. //surfaces contain editable pixel data, can be cast to textures for blitting -(effects, debug/primitive data draws)
  25. struct OGL_Surface : OGL_Texture{
  26.     uint32_t w,h;
  27.     uint8_t bpp;
  28.     uint8_t *PixData;
  29.  
  30.     void Create_Surface(uint16_t w,uint16_t h, char bpp);
  31.     void Clear_Surface(uint8_t r, uint8_t g, uint8_t b, uint8_t a=255);
  32.     void Set_Surface_AlphaKey(uint8_t r, uint8_t g, uint8_t b);
  33.     void gen_texture();
  34.  
  35.     OGL_Surface();
  36.     ~OGL_Surface();
  37. };
  38.  
  39. OGL_Texture *Texture_Cast(OGL_Surface *Surface);
  40.  
  41. ////////
  42. //BLIT//
  43. ////////
  44. enum Image_Options{
  45.     IMG_NORM  = 0,
  46.     IMG_HFLIP = 1,
  47.     IMG_VFLIP = 2,
  48.     IMG_ADD_BLEND = 3
  49. };
  50. 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);
  51. 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);
  52.  
  53. //////////
  54. //COLOUR//
  55. //////////
  56. uint32_t make_col(uint8_t r, uint8_t g, uint8_t b, uint8_t a);
  57. uint32_t make_col(uint8_t r, uint8_t g, uint8_t b);
  58.  
  59. ///////////////////
  60. //DRAW PRIMITIVES//
  61. ///////////////////
  62. bool putpixel(OGL_Surface *Surface, int x, int y, uint32_t col);
  63. bool getpixel(OGL_Surface *Surface, int x, int y, uint32_t &col);
  64. //
  65. void hline(OGL_Surface *Surface, int x, int y, int w, uint32_t col);
  66. void vline(OGL_Surface *Surface, int x, int y, int h, uint32_t col);
  67. void line(OGL_Surface *Surface, int x1, int y1, int x2, int y2, uint32_t col);
  68. void box(OGL_Surface *Surface, int x, int y, int w, int h, uint32_t col);
  69. void rect(OGL_Surface *Surface, int x, int y, int w, int h, uint32_t col);
  70. void polyline(OGL_Surface *Surface, unsigned char n, int points[], uint32_t col);
  71. void polygon(OGL_Surface *Surface, unsigned char n, int points[], uint32_t col);
  72. void circle(OGL_Surface *Surface, int x0, int y0, int radius, uint32_t col);
  73. void circle_fill(OGL_Surface *Surface, int x0, int y0, int radius, uint32_t col);
  74. //
  75.  
  76. #endif // DRAW_H_INCLUDED
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement