Btk
render.hpp
1 #if !defined(_BTKIMPL_RENDER_HPP_)
2 #define _BTKIMPL_RENDER_HPP_
3 #include <SDL2/SDL_render.h>
4 #include "../rect.hpp"
5 #if 0
6 namespace Btk{
7  class PixBuf;
8  class Texture;
9  struct Renderer{
10  //Software render
11  Renderer(PixBuf &);
12  Renderer(SDL_Renderer *ren = nullptr):render(ren){};
13  ~Renderer();
14  //Draw something
15  int line(int x1,int y1,int x2,int y2,SDL_Color c);
16  int aaline(int x1,int y1,int x2,int y2,SDL_Color c);
17  //fill a rect
18  int fill_rect(const SDL_Rect &,SDL_Color c);
19  //draw a rect
20  int draw_rect(const SDL_Rect &,SDL_Color c);
21  int rounded_box(const SDL_Rect &,int rad,SDL_Color c);
22  int rounded_rect(const SDL_Rect &,int rad,SDL_Color c);
23  //some alias
24  inline int rect(const SDL_Rect &r,SDL_Color c){
25  return draw_rect(r,c);
26  }
27  inline int box(const SDL_Rect &r,SDL_Color c){
28  return fill_rect(r,c);
29  }
30  //some useful draw methods
31  int rounded_box_with_boarder(const SDL_Rect &rect,
32  int rad,
33  SDL_Color bg,
34  SDL_Color boarder){
35  int i = 0;
36  //draw background
37  i |= rounded_box(rect,rad,bg);
38  //draw boarder
39  i |= rounded_rect(rect,rad,boarder);
40  return i;
41  }
42  //operators
43  Renderer &operator =(SDL_Renderer *renderer){
44  render = renderer;
45  return *this;
46  }
47  SDL_Renderer* operator *() const noexcept{
48  return render;
49  }
50  bool operator ==(SDL_Renderer *r) const noexcept{
51  return render == r;
52  }
53  //ViewPort
54  Rect get_viewport();//Get ViewPort
55  int set_viewport();//Reset ViewPort
56  int set_viewport(const SDL_Rect &r);//Set ViewPort
57  //ClipRect
58  Rect get_cliprect();
59  int set_cliprect();
60  int set_cliprect(const SDL_Rect &r);
61  //copy texture
62  int copy(const Texture &t,const SDL_Rect *src,const SDL_Rect *dst);
63  int start(SDL_Color bgcolor);//Start for rendering
64  void done();//Finished rendering
65  //texture methods
66  //create texture
67  Texture create_from(const PixBuf &pixbuf);
68  Texture clone_texture(const Texture &);
69  PixBuf dump_texture(const Texture &);//dump texture to pixels
70 
71  SDL_Renderer *render;
72  };
73 
74 };
75 #endif
76 #include "../render.hpp"
77 
78 #endif // _BTKIMPL_RENDER_HPP_
This header include many useful containers.
Definition: async.hpp:7