softwareRenderer.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #ifndef SRENDERER_H
  2. #define SRENDERER_H
  3. #include "rasterizer.h"
  4. #include "buffer.h"
  5. #include "mesh.h"
  6. #include "camera.h"
  7. class SoftwareRenderer {
  8. public:
  9. //Dummy Constructor / Destructor
  10. SoftwareRenderer();
  11. ~SoftwareRenderer();
  12. //Creates all buffers and preps everything for for rendering
  13. bool startUp(int w, int h);
  14. void shutDown();
  15. //This could be expanded with more methods
  16. // to draw different types of meshes or models
  17. void drawTriangularMesh(Mesh * triMesh);
  18. void clearBuffers();
  19. Buffer<Uint32>* getRenderTarget();
  20. void setCameraToRenderFrom(Camera * camera);
  21. private:
  22. //Buffer methods
  23. bool createBuffers(int w, int h);
  24. //Primitive building methods
  25. void buildTri(Vector3 &f, Vector3 *trianglePrim, std::vector<Vector3> &verts);
  26. //Culling methods
  27. bool backFaceCulling(Vector3 *trianglePrim);
  28. //Pointer to the scene's target camera
  29. Camera * mCamera;
  30. bool startUpComplete = false;
  31. Buffer<float> * zBuffer;
  32. Buffer<Uint32> * pixelBuffer;
  33. };
  34. #endif