Render Target for J2D
Some checks failed
Run ReCI Build Test / Explore-Gitea-Actions (push) Failing after 2m10s
Some checks failed
Run ReCI Build Test / Explore-Gitea-Actions (push) Failing after 2m10s
This commit is contained in:
18
main.cpp
18
main.cpp
@@ -4,9 +4,6 @@
|
||||
#include <Colors.hpp>
|
||||
#include <chrono>
|
||||
#include <J3ML/LinearAlgebra/Vector2.hpp>
|
||||
#include <JGL/types/Font.h>
|
||||
#include <JGL/Logger.h>
|
||||
#include <ReTexture/Texture.h>
|
||||
|
||||
using J3ML::LinearAlgebra::Vector2;
|
||||
using namespace JGL;
|
||||
@@ -51,8 +48,6 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
Texture* image;
|
||||
|
||||
class Camera {
|
||||
public:
|
||||
Vector3 position = {0,0,0};
|
||||
@@ -96,6 +91,9 @@ Gizmo b({200, 250});
|
||||
Gizmo c({350, 300});
|
||||
Gizmo d({450, 250});
|
||||
|
||||
Texture* image;
|
||||
RenderTarget* j2d_render_target;
|
||||
|
||||
class JGLDemoWindow : public ReWindow::RWindow
|
||||
{
|
||||
public:
|
||||
@@ -114,6 +112,7 @@ public:
|
||||
glDepthFunc(GL_LESS);
|
||||
glDepthMask(GL_TRUE);
|
||||
image = new Texture("assets/sprites/Re3D.png", TextureFilteringMode::BILINEAR);
|
||||
j2d_render_target = new RenderTarget(1280, {0,0,0,0});
|
||||
}
|
||||
|
||||
Vector3 textAngle = {0,0,0};
|
||||
@@ -156,9 +155,9 @@ public:
|
||||
J3D::DrawString(Colors::Red, "JGL Sample Text", {-0.33, -0.1, 1.0f}, 1.f, 32, FreeSans, textAngle, true);
|
||||
J3D::End();
|
||||
|
||||
J2D::Begin();
|
||||
|
||||
J2D::Begin(j2d_render_target, true);
|
||||
J2D::FillRect(Colors::Blue, {0,52}, {100,100});
|
||||
J2D::DrawSprite(*image, {300, 300}, 0, {0.5, 0.5}, {1, 1}, Colors::White);
|
||||
J2D::DrawMirrorSprite(*image, {400, 300}, Direction::Horizontal | Direction::Vertical, sprite_radians, {0.5,0.5}, {1, 1}, Colors::White);
|
||||
J2D::DrawPartialSprite(*image, {225, 300}, image->GetDimensions() * 0.25, image->GetDimensions() * 0.75, sprite_radians, {0.5, 0.5});
|
||||
J2D::FillRect(Colors::Pinks::HotPink, {68, 120}, {32, 32});
|
||||
@@ -193,6 +192,11 @@ public:
|
||||
d.Draw();
|
||||
J2D::End();
|
||||
|
||||
//Draw the Render Target that we just drew all that stuff onto.
|
||||
J2D::Begin();
|
||||
J2D::DrawRenderTargetAsSprite(*j2d_render_target, {0, 0});
|
||||
J2D::End();
|
||||
|
||||
if (framerate_measurement) {
|
||||
frames++;
|
||||
std::chrono::system_clock::time_point stop = std::chrono::high_resolution_clock::now();
|
||||
|
Reference in New Issue
Block a user