Vivid
Loading...
Searching...
No Matches
renderer_2D_example.cpp
1#include "Vivid.h"
2
4{
5public:
6 void Setup() override
7 {
8 OPENGL_2D_CONFS
9
11 }
12
13 void Draw() override
14 {
16
17 // Draw using API
19
21 Vivid::Maths::Vec3(1.0f, 0.5f, 0.0f));
22
23 Vivid::Renderer2D::DrawQuad(-200, -200, 100, 100, Vivid::Maths::Vec3(1.0f, 1.0f, 0.0f));
24
26 }
27
28 void ImGuiRender() override
29 {
30 ImGui::Begin("Debug");
31 // ImGui::SliderFloat3("Translation Model 1", &suzannePosition.x, -500.0f, 500.0f);
32 // // ImGui::SliderFloat3("Translation Model 2", &lightPosition.x, -300.0f, 300.0f);
33 // ImGui::SliderFloat3("Light Position", &lightPos.x, -500.0f, 500.0f);
34 ImGui::Text("Application average %.3f ms/frame (%.1f FPS)",
35 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
36
37 ImGui::End();
38 }
39};
40
41Application* Vivid::CreateApplication()
42{
43 Application* app = Application::GetInstance(1920, 1080, "Rendering2D");
44
45 // Important for 2D rendering, set the camera to OrthoCamera
46 Maths::Vec3 pos = Maths::Vec3(0, 0, 0);
47 float rot = 0.0f;
48 float zoom = 0.10f;
49 Camera* camera = new OrthoCamera(pos, rot, zoom, -1000.0f, 1000.0f);
50 app->SetCamera(camera);
51
52 app->SetRenderingInterface(new ExampleInterface);
53 return app;
54}
55
56int main()
57{
58 return Vivid::main(0, nullptr);
59}
Application class.
Definition: Application.h:19
A class that represents the camera.
Definition: Camera.h:25
void Setup() override
Setup function.
void ImGuiRender() override
ImGuiRender function.
void Draw() override
Draw function.
A class for the OrthoCamera's.
Definition: OrthoCamera.h:12
RenderingInterface class.
static void BeginScene()
Begins the scene.
Definition: Renderer2D.cpp:67
static void Init(int reserveVertices=10000)
Initializes the Renderer2D.
Definition: Renderer2D.cpp:9
static void EndScene()
Ends the scene.
Definition: Renderer2D.cpp:119
static void DrawLine(Maths::Vec2 start, Maths::Vec2 end, float thickness, Maths::Vec3 color)
Draws a line.
Definition: Renderer2D.cpp:98
static void DrawQuad(float x, float y, float width, float height, const Maths::Vec3 &color)
Draws a quad.
Definition: Renderer2D.cpp:87
static void DrawCircle(Maths::Vec2 center, float radius, Maths::Vec3 color)
Draws a circle.
Definition: Renderer2D.cpp:113
Contains a 2D vector.
Definition: Vec.h:108
Contains a 3D vector.
Definition: Vec.h:51