| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- #ifndef RASTERIZER_H
- #define RASTERIZER_H
- #include "SDL.h"
- #include "buffer.h"
- #include "model.h"
- class Rasterizer{
- public:
- Rasterizer(Buffer<Uint32> *buffer) :mPixelBuffer(buffer){}
- void drawTriangles(Vector3 &v1, Vector3 &v2, Vector3 &v3, float intensity);
- void drawWireFrame(Vector3 &v1, Vector3 &v2, Vector3 &v3);
- void testPattern();
- void makeCoolPattern();
- private:
- static const Uint32 PIXEL_FORMAT = SDL_PIXELFORMAT_RGBA8888;
-
- static const SDL_PixelFormat* mappingFormat;
- Uint32 getPixelColor(int x, int y);
- void drawLine(Vector3 &vertex1, Vector3 &vertex2, Uint32 &color);
- void setPixelColor( int x, int y, Uint32 color);
- int convertCoordinates(int x, int y);
- float getDepthBufferAtLocation(int x, int y);
- void setDepthBufferAtLocation(int x, int y, float depth);
- Buffer<Uint32> * mPixelBuffer;
- Uint32 white = SDL_MapRGBA(mappingFormat, 0xFF,0xFF,0xFF,0xFF);
- Uint32 red = SDL_MapRGBA(mappingFormat, 0xFF,0x00,0x00,0xFF);
- Uint32 green = SDL_MapRGBA(mappingFormat, 0x00,0xFF,0x00,0xFF);
- Uint32 blue = SDL_MapRGBA(mappingFormat, 0x00,0x00,0xFF,0xFF);
- };
- #endif
|