rasterizer.h 1002 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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 drawModels(Vector3 &v1, Vector3 &v2, Vector3 &v3);
  10. void testPattern();
  11. void makeCoolPattern();
  12. private:
  13. static const Uint32 PIXEL_FORMAT = SDL_PIXELFORMAT_RGBA8888;
  14. static const SDL_PixelFormat* mappingFormat;
  15. Uint32 getPixelColor(int x, int y);
  16. void drawLine(Vector3 vertex1, Vector3 vertex2, Uint32 color);
  17. void setPixelColor(Uint32 color, int x, int y);
  18. int convertCoordinates(int x, int y);
  19. Canvas * mCanvas;
  20. Uint32 white = SDL_MapRGBA(mappingFormat, 0xFF,0xFF,0xFF,0xFF);
  21. Uint32 red = SDL_MapRGBA(mappingFormat, 0xFF,0x00,0x00,0xFF);
  22. Uint32 green = SDL_MapRGBA(mappingFormat, 0x00,0xFF,0x00,0xFF);
  23. Uint32 blue = SDL_MapRGBA(mappingFormat, 0x00,0x00,0xFF,0xFF);
  24. };
  25. #endif