-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Get something rendering for hellotriangle
- Loading branch information
1 parent
f15ad23
commit 459b9bd
Showing
1 changed file
with
40 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,40 @@ | ||
#include <oscar/oscar.h> | ||
|
||
using namespace osc; | ||
|
||
namespace | ||
{ | ||
class HelloTriangleScreen final : public IScreen { | ||
public: | ||
void impl_on_draw() override | ||
{ | ||
Camera camera; | ||
graphics::draw(mesh_, identity<Transform>(), material_, camera); | ||
camera.render_to_screen(); | ||
} | ||
private: | ||
Mesh mesh_ = TorusKnotGeometry{}; | ||
Material material_ = MeshBasicMaterial{}; | ||
}; | ||
} | ||
|
||
int main(int, char**) | ||
{ | ||
osc::App app; | ||
app.show<HelloTriangleScreen>(); | ||
return 0; | ||
} | ||
#include <oscar/oscar.h> | ||
|
||
using namespace osc; | ||
|
||
namespace | ||
{ | ||
class HelloTriangleScreen final : public IScreen { | ||
public: | ||
HelloTriangleScreen() | ||
{ | ||
const Vec3 viewer_pos = {3.0f, 0.0f, 0.0f}; | ||
camera_.set_position(viewer_pos); | ||
camera_.set_direction({-1.0f, 0.0f, 0.0f}); | ||
const Color color = Color::red(); | ||
material_.set_ambient_color(0.2f * color); | ||
material_.set_diffuse_color(0.5f * color); | ||
material_.set_specular_color(0.5f * color); | ||
material_.set_viewer_position(viewer_pos); | ||
} | ||
private: | ||
void impl_on_draw() override | ||
{ | ||
const auto secs = App::get().frame_delta_since_startup().count(); | ||
const auto transform = identity<Transform>().with_rotation(angle_axis(Radians{secs}, Vec3{0.0f, 1.0f, 0.0f})); | ||
graphics::draw(mesh_, transform, material_, camera_); | ||
camera_.render_to_screen(); | ||
} | ||
|
||
TorusKnotGeometry mesh_; | ||
MeshPhongMaterial material_; | ||
Camera camera_; | ||
}; | ||
} | ||
|
||
int main(int, char**) | ||
{ | ||
osc::App app; | ||
app.show<HelloTriangleScreen>(); | ||
return 0; | ||
} |