diff options
Diffstat (limited to 'src/scene.cpp')
-rw-r--r-- | src/scene.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/scene.cpp b/src/scene.cpp index e69de29..b52553a 100644 --- a/src/scene.cpp +++ b/src/scene.cpp @@ -0,0 +1,29 @@ +#include "scene.hpp" +#include <memory> + +Scene::Scene() { + directional_light = {0, 0, -1}; + viewport_dimension = {2, 3}; + scene_dimension = {SCREEN_WIDTH, SCREEN_HEIGHT}; + + z_plane = int2fx(1); +} + +void Scene::render() { + auto this_ptr = std::make_shared<Scene>(this); + for (auto renderable : renderables) { + renderable.render(this_ptr); + } +} + +POINT Scene::project_2d(VECTOR vertex) { + POINT pt = {0, 0}; + + if (vertex.z != 0) { + pt.x = fxdiv(z_plane, vertex.z); + pt.y = fxmul(vertex.y, pt.x); + pt.x = fxmul(vertex.x, pt.x); + } + + return pt; +} |