diff options
author | Elizabeth Hunt <elizabeth.hunt@simponic.xyz> | 2023-11-25 17:05:01 -0700 |
---|---|---|
committer | Elizabeth Hunt <elizabeth.hunt@simponic.xyz> | 2023-11-25 17:05:01 -0700 |
commit | f4a7739a40c095e0c837d78d00f13a1ef47d3a11 (patch) | |
tree | 901a02ea8cf1cab8344bf3d6310ae4812f7062f4 /src/scene.cpp | |
parent | ebc517c800a90f6f0ed157e5c3bd7c3bd18165b5 (diff) | |
download | gbarubik-f4a7739a40c095e0c837d78d00f13a1ef47d3a11.tar.gz gbarubik-f4a7739a40c095e0c837d78d00f13a1ef47d3a11.zip |
cube foo init
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; +} |