rasterizer.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #ifndef RASTERIZER_H
  2. #define RASTERIZER_H
  3. #include "SDL.h"
  4. #include "buffer.h"
  5. #include "model.h"
  6. class Rasterizer{
  7. public:
  8. Rasterizer(Buffer<Uint32> *buffer) :mPixelBuffer(buffer){}
  9. void drawTriangles(Vector3 &v1, Vector3 &v2, Vector3 &v3, float intensity);
  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( int x, int y, Uint32 color);
  19. int convertCoordinates(int x, int y);
  20. float getDepthBufferAtLocation(int x, int y);
  21. void setDepthBufferAtLocation(int x, int y, float depth);
  22. Buffer<Uint32> * mPixelBuffer;
  23. Uint32 white = SDL_MapRGBA(mappingFormat, 0xFF,0xFF,0xFF,0xFF);
  24. Uint32 red = SDL_MapRGBA(mappingFormat, 0xFF,0x00,0x00,0xFF);
  25. Uint32 green = SDL_MapRGBA(mappingFormat, 0x00,0xFF,0x00,0xFF);
  26. Uint32 blue = SDL_MapRGBA(mappingFormat, 0x00,0x00,0xFF,0xFF);
  27. };
  28. #endif