Compare commits
No commits in common. "1f1a7766865e4a6e5fc3c5bc828a5f9aa3197005" and "a1ec94e98396de9598b2bcf89cf97f462b050554" have entirely different histories.
1f1a776686
...
a1ec94e983
@ -20,10 +20,7 @@ public:
|
|||||||
ImGui::StyleColorsDark();
|
ImGui::StyleColorsDark();
|
||||||
|
|
||||||
ImGui_ImplGlfw_InitForOpenGL(window.GetGLFWHandle(), true);
|
ImGui_ImplGlfw_InitForOpenGL(window.GetGLFWHandle(), true);
|
||||||
ImGui_ImplOpenGL3_Init("#version 450");
|
ImGui_ImplOpenGL3_Init("#version 440");
|
||||||
|
|
||||||
ImGuizmo::SetOrthographic(true);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Begin ()
|
void Begin ()
|
||||||
@ -32,19 +29,20 @@ public:
|
|||||||
ImGui_ImplOpenGL3_NewFrame();
|
ImGui_ImplOpenGL3_NewFrame();
|
||||||
|
|
||||||
ImGui::NewFrame();
|
ImGui::NewFrame();
|
||||||
|
|
||||||
|
ImGuizmo::SetOrthographic(true);
|
||||||
ImGuizmo::BeginFrame();
|
ImGuizmo::BeginFrame();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void End()
|
void End()
|
||||||
{
|
{
|
||||||
|
|
||||||
ImGui::EndFrame();
|
ImGui::EndFrame();
|
||||||
|
|
||||||
|
|
||||||
ImGui::Render();
|
ImGui::Render();
|
||||||
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
||||||
|
|
||||||
|
|
||||||
if (ImGui::GetIO().ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
if (ImGui::GetIO().ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
|
||||||
{
|
{
|
||||||
GLFWwindow* last_context = glfwGetCurrentContext();
|
GLFWwindow* last_context = glfwGetCurrentContext();
|
||||||
@ -53,18 +51,14 @@ public:
|
|||||||
glfwMakeContextCurrent(last_context);
|
glfwMakeContextCurrent(last_context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
~GUIRenderer(){
|
~GUIRenderer(){
|
||||||
|
|
||||||
|
|
||||||
ImGui_ImplOpenGL3_Shutdown();
|
ImGui_ImplOpenGL3_Shutdown();
|
||||||
ImGui_ImplGlfw_Shutdown();
|
ImGui_ImplGlfw_Shutdown();
|
||||||
ImGui::DestroyContext();
|
ImGui::DestroyContext();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -125,12 +125,26 @@ public:
|
|||||||
|
|
||||||
class Viewport : EditorWindow {
|
class Viewport : EditorWindow {
|
||||||
public:
|
public:
|
||||||
Viewport (Framebuffer& fb) : EditorWindow("SceneView") {
|
Viewport (Scene& scene) : EditorWindow("SceneView") {
|
||||||
|
Framebuffer framebuffer = Framebuffer((int)ImGui::GetWindowWidth(),(int)ImGui::GetWindowHeight());
|
||||||
|
|
||||||
|
|
||||||
|
Renderer renderer = Renderer();
|
||||||
|
renderer.Prepare(scene);
|
||||||
|
renderer.Render(&framebuffer, scene);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ImGui::Image(
|
ImGui::Image(
|
||||||
(void*)(intptr_t)fb.GetColourAttachment(),
|
(void*)(intptr_t)framebuffer.GetColourAttachment(),
|
||||||
ImVec2{ (float)ImGui::GetWindowWidth(),(float)ImGui::GetWindowHeight() }
|
ImVec2{ (float)ImGui::GetWindowWidth(),(float)ImGui::GetWindowHeight() }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//ImGuizmo::SetDrawlist();
|
//ImGuizmo::SetDrawlist();
|
||||||
//ImGuizmo::SetRect(ImGui::GetWindowPos().x, ImGui::GetWindowPos().y, ImGui::GetWindowWidth(), ImGui::GetWindowHeight());
|
//ImGuizmo::SetRect(ImGui::GetWindowPos().x, ImGui::GetWindowPos().y, ImGui::GetWindowWidth(), ImGui::GetWindowHeight());
|
||||||
//ImGuizmo::Enable(true);
|
//ImGuizmo::Enable(true);
|
||||||
@ -172,8 +186,6 @@ private:
|
|||||||
class AssetFinder : EditorWindow {
|
class AssetFinder : EditorWindow {
|
||||||
public:
|
public:
|
||||||
AssetFinder() : EditorWindow("Assets") {
|
AssetFinder() : EditorWindow("Assets") {
|
||||||
|
|
||||||
|
|
||||||
ImGui::DragInt("IconSize", &iconSize, 1, 30, 90);
|
ImGui::DragInt("IconSize", &iconSize, 1, 30, 90);
|
||||||
|
|
||||||
|
|
||||||
@ -197,14 +209,14 @@ public:
|
|||||||
|
|
||||||
if (asset.isFolder) {
|
if (asset.isFolder) {
|
||||||
ImGui::ImageButton(
|
ImGui::ImageButton(
|
||||||
(ImTextureID)(Texture("rsc/folderIcon.png")).GetID(),
|
(ImTextureID)folderIcon.GetID(),
|
||||||
ImVec2{ (float)iconSize,(float)iconSize });
|
ImVec2{ (float)iconSize,(float)iconSize });
|
||||||
ImGui::Text(asset.GetName(), row);
|
ImGui::Text(asset.GetName(), row);
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ImGui::ImageButton(
|
ImGui::ImageButton(
|
||||||
(ImTextureID)(Texture("rsc/assetIcon.png")).GetID(),
|
(ImTextureID)AssetIcon.GetID(),
|
||||||
ImVec2{ (float)iconSize, (float)iconSize });
|
ImVec2{ (float)iconSize, (float)iconSize });
|
||||||
ImGui::Text(asset.GetName(), row);
|
ImGui::Text(asset.GetName(), row);
|
||||||
|
|
||||||
@ -222,7 +234,7 @@ public:
|
|||||||
|
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
static Texture folderIcon;
|
Texture folderIcon = Texture("rsc/folderIcon.png");
|
||||||
static Texture AssetIcon;
|
Texture AssetIcon = Texture("rsc/assetIcon.png");
|
||||||
int iconSize = 60;
|
int iconSize = 60;
|
||||||
};
|
};
|
@ -14,28 +14,17 @@
|
|||||||
#include "AssetManagement/AssetManager.h"
|
#include "AssetManagement/AssetManager.h"
|
||||||
#include "UI/MainMenuBar.h"
|
#include "UI/MainMenuBar.h"
|
||||||
|
|
||||||
|
|
||||||
const unsigned int MS_PER_UPDATE = 2;
|
const unsigned int MS_PER_UPDATE = 2;
|
||||||
void CreateTestProject(std::unique_ptr<Project>& project, Scene& scene);
|
void CreateTestProject(std::unique_ptr<Project>& project, Scene& scene);
|
||||||
|
|
||||||
class Editor : public Application {
|
class Editor : public Application {
|
||||||
public:
|
public:
|
||||||
Editor() : Application("Editor"){
|
Editor() : Application("Editor") {}
|
||||||
}
|
|
||||||
|
|
||||||
void Run() override
|
void Run() override
|
||||||
{
|
{
|
||||||
|
|
||||||
auto NativeEditorWindow = NativeWindow(1200, 700);
|
auto NativeEditorWindow = NativeWindow(1200, 700);
|
||||||
|
//auto renderer = Renderer();
|
||||||
framebuffer = new Framebuffer(800, 600);
|
|
||||||
auto renderer = Renderer(RendererConfig{
|
|
||||||
1200, // Screen Width
|
|
||||||
700, // Screen Height
|
|
||||||
glm::vec3{0,0,0}, // Clear Color
|
|
||||||
true // Depth testing
|
|
||||||
});
|
|
||||||
|
|
||||||
auto GuiRenderer = GUIRenderer(NativeEditorWindow);
|
auto GuiRenderer = GUIRenderer(NativeEditorWindow);
|
||||||
|
|
||||||
Selected = (entt::entity)-1;
|
Selected = (entt::entity)-1;
|
||||||
@ -44,11 +33,10 @@ public:
|
|||||||
|
|
||||||
ActiveScene.Start();
|
ActiveScene.Start();
|
||||||
|
|
||||||
renderer.setCurrentFrameBuffer(*framebuffer);
|
|
||||||
|
|
||||||
|
|
||||||
double previous = glfwGetTime();
|
double previous = glfwGetTime();
|
||||||
double lag = 0.0;
|
double lag = 0.0;
|
||||||
|
|
||||||
|
|
||||||
while (!NativeEditorWindow.WindowShouldClose())
|
while (!NativeEditorWindow.WindowShouldClose())
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -65,16 +53,8 @@ public:
|
|||||||
lag -= MS_PER_UPDATE;
|
lag -= MS_PER_UPDATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// submit DrawCommands for all render3DComponents
|
// renderer.Render(framebuffer, ActiveScene);
|
||||||
|
|
||||||
auto group = ActiveScene.getReg().view<TransformComponent, Render3DComponent>();
|
|
||||||
group.each([&renderer](auto enity, TransformComponent& t, Render3DComponent& renderComponent) {
|
|
||||||
renderer.Submit(renderComponent, t);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
renderer.Render();
|
|
||||||
|
|
||||||
GuiRenderer.Begin();
|
GuiRenderer.Begin();
|
||||||
RenderGUI();
|
RenderGUI();
|
||||||
@ -86,8 +66,6 @@ public:
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
delete framebuffer;
|
|
||||||
ActiveScene.Stop();
|
ActiveScene.Stop();
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -108,7 +86,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
Viewport sceneview = Viewport(*framebuffer);
|
Viewport sceneview = Viewport(ActiveScene);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -149,8 +127,6 @@ private:
|
|||||||
std::unique_ptr<Project> CurrentProject;
|
std::unique_ptr<Project> CurrentProject;
|
||||||
Scene ActiveScene;
|
Scene ActiveScene;
|
||||||
entt::entity Selected;
|
entt::entity Selected;
|
||||||
Framebuffer* framebuffer ;
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -25,7 +25,6 @@ project "YoggieEngine"
|
|||||||
"../libs/assimp/include",
|
"../libs/assimp/include",
|
||||||
"../libs/entt/src",
|
"../libs/entt/src",
|
||||||
|
|
||||||
"../libs/physx/pxshared/include",
|
|
||||||
"../libs/physx/physx/include",
|
"../libs/physx/physx/include",
|
||||||
|
|
||||||
"../libs/lua/include",
|
"../libs/lua/include",
|
||||||
@ -33,6 +32,7 @@ project "YoggieEngine"
|
|||||||
"../libs/GorillaAudio/include",
|
"../libs/GorillaAudio/include",
|
||||||
"../libs/steam-audio/include",
|
"../libs/steam-audio/include",
|
||||||
|
|
||||||
|
|
||||||
"../libs/ImGui",
|
"../libs/ImGui",
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,14 +44,6 @@ project "YoggieEngine"
|
|||||||
"assimp-vc143-mtd",
|
"assimp-vc143-mtd",
|
||||||
"glfw3",
|
"glfw3",
|
||||||
"ImGui",
|
"ImGui",
|
||||||
|
|
||||||
"PhysX_64",
|
|
||||||
"PhysXCooking_64",
|
|
||||||
"PhysXCommon_64",
|
|
||||||
"PhysXFoundation_64",
|
|
||||||
"PhysXPvdSDK_static_64",
|
|
||||||
"PhysXExtensions_static_64"
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -61,8 +53,6 @@ project "YoggieEngine"
|
|||||||
"../libs/spdlog/build/Release",
|
"../libs/spdlog/build/Release",
|
||||||
"../libs/assimp/lib/Debug",
|
"../libs/assimp/lib/Debug",
|
||||||
"../libs/glfw/build/src/Debug",
|
"../libs/glfw/build/src/Debug",
|
||||||
"../libs/physx/physx/bin/win.x86_64.vc142.md/debug"
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
files {
|
files {
|
||||||
|
@ -1,45 +1,11 @@
|
|||||||
#include <YoggieEngine.h>
|
#include <YoggieEngine.h>
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
#include <PxPhysicsAPI.h>
|
|
||||||
#define PVD_HOST "127.0.0.1"
|
|
||||||
|
|
||||||
using namespace physx;
|
|
||||||
|
|
||||||
namespace YoggieEngine {
|
namespace YoggieEngine {
|
||||||
|
|
||||||
static PxDefaultErrorCallback gDefaultErrorCallback;
|
|
||||||
static PxDefaultAllocator gDefaultAllocatorCallback;
|
|
||||||
static PxFoundation* mFoundation;
|
|
||||||
static PxPvd* mPvd;
|
|
||||||
static PxPvdTransport* transport;
|
|
||||||
static PxPhysics* mPhysics;
|
|
||||||
bool recordMemoryAllocations = true;
|
|
||||||
|
|
||||||
|
|
||||||
Application::Application(const std::string& name )
|
Application::Application(const std::string& name )
|
||||||
: m_AppName(name)
|
: m_AppName(name)
|
||||||
{
|
{
|
||||||
EngineInstrumentation::PerfomanceSamplerInit();
|
EngineInstrumentation::PerfomanceSamplerInit();
|
||||||
|
|
||||||
// startup PhysX
|
|
||||||
mFoundation = PxCreateFoundation(PX_PHYSICS_VERSION, gDefaultAllocatorCallback, gDefaultErrorCallback);
|
|
||||||
if (!mFoundation) {
|
|
||||||
spdlog::critical("PxCreateFoundation failed!");
|
|
||||||
}
|
|
||||||
|
|
||||||
mPvd = physx::PxCreatePvd(*mFoundation);
|
|
||||||
if (!mPvd) {
|
|
||||||
spdlog::critical("pxCreatPvd failed!");
|
|
||||||
}
|
|
||||||
transport = PxDefaultPvdSocketTransportCreate(PVD_HOST, 5425, 10);
|
|
||||||
mPvd->connect(*transport, PxPvdInstrumentationFlag::eALL);
|
|
||||||
|
|
||||||
|
|
||||||
mPhysics = PxCreatePhysics(PX_PHYSICS_VERSION, *mFoundation, PxTolerancesScale(), recordMemoryAllocations, mPvd);
|
|
||||||
if (!mPhysics) {
|
|
||||||
spdlog::critical("pxCreatePhysics failed!");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -48,24 +14,4 @@ namespace YoggieEngine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Application::~Application(){
|
|
||||||
|
|
||||||
if (mPhysics)
|
|
||||||
mPhysics->release();
|
|
||||||
|
|
||||||
if (mPvd) {
|
|
||||||
if (mPvd->isConnected()) {
|
|
||||||
mPvd->disconnect();
|
|
||||||
}
|
|
||||||
mPvd->release();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (transport)
|
|
||||||
transport->release();
|
|
||||||
|
|
||||||
|
|
||||||
if (mFoundation)
|
|
||||||
mFoundation->release();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
@ -1,13 +1,10 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "YoggieEngine.h"
|
#include "YoggieEngine.h"
|
||||||
|
|
||||||
|
|
||||||
namespace YoggieEngine {
|
namespace YoggieEngine {
|
||||||
|
|
||||||
class Application {
|
class Application {
|
||||||
public:
|
public:
|
||||||
Application(const std::string& name);
|
Application(const std::string& name);
|
||||||
~Application();
|
|
||||||
virtual void Run();
|
virtual void Run();
|
||||||
|
|
||||||
|
|
||||||
|
@ -47,6 +47,10 @@ namespace YoggieEngine {
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (!glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE)
|
if (!glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE)
|
||||||
{
|
{
|
||||||
std::cout << "Framebuffer is incomplete!" << std::endl;
|
std::cout << "Framebuffer is incomplete!" << std::endl;
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include "Scene/Components.h"
|
|
||||||
namespace YoggieEngine {
|
|
||||||
struct DrawCommand {
|
|
||||||
unsigned int VAO_identifier;
|
|
||||||
unsigned int num_elements;
|
|
||||||
unsigned int IBO_identifier;
|
|
||||||
TransformComponent& transform;
|
|
||||||
Shader& shader;
|
|
||||||
// Material
|
|
||||||
};
|
|
||||||
};
|
|
@ -1,34 +1,24 @@
|
|||||||
#include <YoggieEngine.h>
|
#include <YoggieEngine.h>
|
||||||
|
|
||||||
#include "Renderer.h"
|
#include "Renderer.h"
|
||||||
#include "../Scene/Components.h"
|
#include "../Scene/Components.h"
|
||||||
#include "../Graphics/Memory/Buffer.h"
|
|
||||||
#include "../Graphics/Memory/VertexArray.h"
|
#include "../Graphics/Memory/VertexArray.h"
|
||||||
#include "../Graphics/Primitives/DrawCommand.h"
|
#include "../Graphics/Memory/Buffer.h"
|
||||||
|
|
||||||
namespace YoggieEngine {
|
namespace YoggieEngine {
|
||||||
float Angle = 0.0;
|
float Angle = 0.0;
|
||||||
Camera cam = Camera(glm::vec3(12.0f, 0.0f, 0.0f), glm::vec3(0.0f, 0.0f, 0.0f), 90.0f);
|
Camera cam = Camera(glm::vec3(12.0f, 0.0f, 0.0f), glm::vec3(0.0f, 0.0f, 0.0f), 90.0f);
|
||||||
glm::mat4 projection = glm::perspective(glm::radians(cam.Zoom), (800.0f / 600.0f), 0.001f, 100.0f);
|
glm::mat4 projection = glm::perspective(glm::radians(cam.Zoom), (800.0f / 600.0f), 0.001f, 100.0f);
|
||||||
|
|
||||||
Renderer::Renderer(RendererConfig& config)
|
Renderer::Renderer(){
|
||||||
: m_framebuffer(Framebuffer(config.ScreenWidth, config.ScreenHeight))
|
glEnable(GL_DEPTH_TEST);
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Renderer::~Renderer(){}
|
Renderer::~Renderer(){}
|
||||||
|
|
||||||
|
void Renderer::Prepare(Scene& scene ) {
|
||||||
void Renderer::Submit( Render3DComponent& renderComponent, TransformComponent& transform) {
|
auto group = scene.getReg().view<Render3DComponent>();
|
||||||
|
group.each([](auto enity, Render3DComponent& renderComponent) {
|
||||||
if (renderComponent.VAO == 0 || renderComponent.IBO == 0)
|
|
||||||
{
|
|
||||||
if (renderComponent.VAO != 0)
|
|
||||||
glDeleteVertexArrays(1, &(renderComponent.VAO));
|
|
||||||
if (renderComponent.IBO != 0)
|
|
||||||
glDeleteBuffers(1, &(renderComponent.IBO));
|
|
||||||
|
|
||||||
VertexArray va = VertexArray();
|
VertexArray va = VertexArray();
|
||||||
Buffer vertexBuffer = Buffer();
|
Buffer vertexBuffer = Buffer();
|
||||||
Buffer elementBuffer = Buffer();
|
Buffer elementBuffer = Buffer();
|
||||||
@ -56,77 +46,64 @@ void Renderer::Submit( Render3DComponent& renderComponent, TransformComponent& t
|
|||||||
|
|
||||||
renderComponent.VAO = va.getID();
|
renderComponent.VAO = va.getID();
|
||||||
renderComponent.IBO = elementBuffer.getBufferID();
|
renderComponent.IBO = elementBuffer.getBufferID();
|
||||||
}
|
});
|
||||||
|
|
||||||
DrawCommand dc = { renderComponent.VAO, renderComponent.mesh.elements.size(), renderComponent.IBO, transform, renderComponent.shader };
|
|
||||||
commands.push_back(dc);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::Render()
|
|
||||||
|
|
||||||
|
void Renderer::Render(Scene& scene)
|
||||||
{
|
{
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, m_framebuffer.GetId());
|
auto group = scene.getReg().view<TransformComponent, Render3DComponent>();
|
||||||
|
group.each([&](auto entity , TransformComponent& trans, Render3DComponent& renderComponent)
|
||||||
if (m_depthTest) {
|
|
||||||
glEnable(GL_DEPTH_TEST);
|
|
||||||
}
|
|
||||||
|
|
||||||
glClearColor(m_clearColor.r, m_clearColor.g, m_clearColor.b, 1.0f);
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
|
||||||
|
|
||||||
for (const DrawCommand& command : commands)
|
|
||||||
{
|
{
|
||||||
glBindVertexArray(command.VAO_identifier);
|
glBindVertexArray(renderComponent.VAO);
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, command.IBO_identifier);
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, renderComponent.IBO);
|
||||||
|
|
||||||
command.shader.Use();
|
renderComponent.shader.Use();
|
||||||
|
|
||||||
glm::mat4 rotation = glm::rotate(glm::mat4(1.0f), command.transform.Rotation.x, glm::vec3(1.0f, 0.0f, 0.0f));
|
auto lights = scene.getReg().view<LightComponent>();
|
||||||
rotation *= glm::rotate(glm::mat4(1.0f), command.transform.Rotation.y, glm::vec3(0.0f, 1.0f, 0.0f));
|
|
||||||
rotation *= glm::rotate(glm::mat4(1.0f), command.transform.Rotation.z, glm::vec3(0.0f, 0.0f, 1.0f));
|
|
||||||
|
|
||||||
|
|
||||||
glm::mat4 modelMatrix = glm::translate(glm::mat4(1.0f), command.transform.Position) * glm::scale(glm::mat4(1.0f), command.transform.Scale) * rotation;
|
|
||||||
|
|
||||||
|
|
||||||
command.shader.setUniformVec3("Color", glm::vec3(1.0f, 0.0f, 0.0f));
|
|
||||||
command.shader.setUniformMat4("M", modelMatrix);
|
|
||||||
command.shader.setUniformMat4("V", cam.GetViewMatrix());
|
|
||||||
command.shader.setUniformMat4("P", projection);
|
|
||||||
|
|
||||||
glDrawElements(GL_TRIANGLES, static_cast<unsigned int>(command.num_elements),
|
|
||||||
GL_UNSIGNED_INT, NULL);
|
|
||||||
|
|
||||||
glBindVertexArray(0);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Lighting pass
|
|
||||||
* auto lights = scene.getReg().view<LightComponent>();
|
|
||||||
lights.each([&](auto entity, LightComponent& light) {
|
lights.each([&](auto entity, LightComponent& light) {
|
||||||
renderComponent.shader.setUniformVec3("lighting.color", light.Color);
|
renderComponent.shader.setUniformVec3("lighting.color", light.Color);
|
||||||
renderComponent.shader.setUniformFloat("lighting.strength", light.Strength);
|
renderComponent.shader.setUniformFloat("lighting.strength", light.Strength);
|
||||||
});
|
});
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
commands.clear();
|
|
||||||
|
glm::mat4 rotation = glm::rotate(glm::mat4(1.0f), trans.Rotation.x, glm::vec3(1.0f, 0.0f, 0.0f));
|
||||||
|
rotation *= glm::rotate(glm::mat4(1.0f), trans.Rotation.y, glm::vec3(0.0f, 1.0f, 0.0f));
|
||||||
|
rotation *= glm::rotate(glm::mat4(1.0f), trans.Rotation.z, glm::vec3(0.0f, 0.0f, 1.0f));
|
||||||
|
|
||||||
|
|
||||||
|
glm::mat4 modelMatrix = glm::translate(glm::mat4(1.0f), trans.Position) * glm::scale(glm::mat4(1.0f), trans.Scale) *rotation;
|
||||||
|
|
||||||
|
|
||||||
|
renderComponent.shader.setUniformVec3("Color", renderComponent.color);
|
||||||
|
renderComponent.shader.setUniformMat4("M", modelMatrix);
|
||||||
|
renderComponent.shader.setUniformMat4("V", cam.GetViewMatrix());
|
||||||
|
renderComponent.shader.setUniformMat4("P", projection);
|
||||||
|
|
||||||
|
//std::cout << "Draw " << renderComponent.mesh.elements.size() << " elements" << std::endl;
|
||||||
|
glDrawElements(GL_TRIANGLES, static_cast<unsigned int>(renderComponent.mesh.elements.size()) ,
|
||||||
|
GL_UNSIGNED_INT, NULL);
|
||||||
|
|
||||||
|
glBindVertexArray(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void Renderer::Render(Framebuffer* framebuffer, Scene& scene)
|
||||||
|
{
|
||||||
|
if (framebuffer == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
|
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer->GetId());
|
||||||
|
|
||||||
|
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
|
Render(scene);
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Renderer::setCurrentFrameBuffer(const Framebuffer& fb)
|
|
||||||
{
|
|
||||||
m_framebuffer = fb;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Renderer::setClearColor(const glm::vec3& ClearColor)
|
|
||||||
{
|
|
||||||
m_clearColor = ClearColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -1,38 +1,23 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "GLFW/glfw3.h"
|
#include "GLFW/glfw3.h"
|
||||||
#include <vector>
|
|
||||||
#include "../PerfCounter.h"
|
#include "../PerfCounter.h"
|
||||||
|
|
||||||
#include "Renderable.h"
|
#include "Renderable.h"
|
||||||
#include "Memory/Framebuffer.h"
|
#include "Memory/Framebuffer.h"
|
||||||
#include "../Scene/Components.h"
|
#include "../Scene/Components.h"
|
||||||
#include"../Scene/Scene.h"
|
#include"../Scene/Scene.h"
|
||||||
#include "Graphics/Primitives/DrawCommand.h"
|
|
||||||
|
|
||||||
namespace YoggieEngine {
|
namespace YoggieEngine {
|
||||||
|
|
||||||
struct RendererConfig {
|
|
||||||
int ScreenWidth, ScreenHeight;
|
|
||||||
glm::vec3 ClearColor;
|
|
||||||
bool DepthTest;
|
|
||||||
};
|
|
||||||
|
|
||||||
class Renderer {
|
class Renderer {
|
||||||
public:
|
public:
|
||||||
Renderer(RendererConfig& config);
|
Renderer();
|
||||||
~Renderer();
|
~Renderer();
|
||||||
|
|
||||||
|
void Prepare(Scene& scene);
|
||||||
|
void Render(Scene& scene );
|
||||||
|
|
||||||
void Submit(Render3DComponent& renderComponent, TransformComponent& transform); // Collects DrawCommands
|
void Render(Framebuffer* framebuffer, Scene& scene);
|
||||||
void Render(); // Draw to screen (usingthe drawCalls
|
|
||||||
|
|
||||||
void setCurrentFrameBuffer(const Framebuffer& fb);
|
|
||||||
void setClearColor(const glm::vec3& ClearColor);
|
|
||||||
|
|
||||||
private:
|
|
||||||
Framebuffer m_framebuffer;
|
|
||||||
glm::vec3 m_clearColor;
|
|
||||||
bool m_depthTest;
|
|
||||||
std::vector<DrawCommand> commands;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -19,8 +19,6 @@
|
|||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
#include <entt/entt.hpp>
|
#include <entt/entt.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
#include "lauxlib.h"
|
#include "lauxlib.h"
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 9414174ec0140ac6b13f4834f16eea93f435a4e7
|
Subproject commit c3d5537bdebd6f5cd82fcaf87474b838fe6fd5fa
|
Loading…
x
Reference in New Issue
Block a user