rasterizer.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #ifndef RASTERIZER_H
  2. #define RASTERIZER_H
  3. #include "SDL.h"
  4. #include "canvas.h"
  5. #include "model.h"
  6. class Rasterizer{
  7. public:
  8. Rasterizer(Canvas *canvas) :mCanvas(canvas){}
  9. void drawTriangles(Vector3 &v1, Vector3 &v2, Vector3 &v3);
  10. void drawWireFrame(Vector3 &v1, Vector3 &v2, Vector3 &v3);
  11. void testPattern();
  12. void makeCoolPattern();
  13. private:
  14. static const Uint32 PIXEL_FORMAT = SDL_PIXELFORMAT_RGBA8888;
  15. static const SDL_PixelFormat* mappingFormat;
  16. Uint32 getPixelColor(int x, int y);
  17. void drawLine(Vector3 &vertex1, Vector3 &vertex2, Uint32 &color);
  18. void setPixelColor(Uint32 color, int x, int y);
  19. int convertCoordinates(int x, int y);
  20. Canvas * mCanvas;
  21. Uint32 white = SDL_MapRGBA(mappingFormat, 0xFF,0xFF,0xFF,0xFF);
  22. Uint32 red = SDL_MapRGBA(mappingFormat, 0xFF,0x00,0x00,0xFF);
  23. Uint32 green = SDL_MapRGBA(mappingFormat, 0x00,0xFF,0x00,0xFF);
  24. Uint32 blue = SDL_MapRGBA(mappingFormat, 0x00,0x00,0xFF,0xFF);
  25. };
  26. #endif