You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
1.5 KiB

5 years ago
  1. #pragma once
  2. #include "CELLMath.hpp"
  3. namespace CELL
  4. {
  5. enum DRAWMODE
  6. {
  7. DM_POINTS = 0,
  8. DM_LINES = 1,
  9. DM_LINE_LOOP = 2,
  10. DM_LINE_STRIP = 3,
  11. };
  12. class Raster
  13. {
  14. public:
  15. Rgba* _buffer;
  16. int _width;
  17. int _height;
  18. Rgba _color;
  19. public:
  20. Raster(int w,int h,void* buffer);
  21. ~Raster(void);
  22. void clear();
  23. void drawPoint(int x,int y, Rgba color,int ptSize);
  24. void drawArrays(DRAWMODE mode,const float2* points,int count);
  25. void drawFilleRect(int startX,int startY,int w,int h)
  26. {
  27. for (int x = startX ; x < startX + w ; ++ x)
  28. {
  29. for (int y = startY ; y < startY + h ; ++ y)
  30. {
  31. setPixelEx(x,y,_color);
  32. }
  33. }
  34. }
  35. public:
  36. void drawLine(float2 pt1,float2 pt2,Rgba color1,Rgba color2);
  37. void drawPoints(float2 pt1,Rgba4Byte color)
  38. {
  39. }
  40. inline void setPixelEx(unsigned x,unsigned y,Rgba color)
  41. {
  42. _buffer[y * _width + x] = color;
  43. }
  44. inline void setPixel(unsigned x,unsigned y,Rgba color)
  45. {
  46. if (x >= _width || y >= _height)
  47. {
  48. return;
  49. }
  50. _buffer[y * _width + x] = color;
  51. }
  52. };
  53. }