Support lighting using a graphics buffer that is kep open!
This commit is contained in:
@@ -1,5 +1,12 @@
|
||||
#include "main.h"
|
||||
|
||||
#ifdef global
|
||||
#undef global
|
||||
#endif
|
||||
#include <ios>
|
||||
#include <iosfwd>
|
||||
#define global static
|
||||
|
||||
#include <Core/Application/ApplicationManager.h>
|
||||
#include <Core/Common/EnumUtils.h>
|
||||
#include <Core/Common/String.h>
|
||||
@@ -44,13 +51,6 @@ static bool ShowMemoryDebugger = false;
|
||||
|
||||
using namespace Juliet;
|
||||
|
||||
extern "C" {
|
||||
__declspec(dllexport) extern const unsigned int D3D12SDKVersion = 615;
|
||||
}
|
||||
extern "C" {
|
||||
__declspec(dllexport) extern const char* D3D12SDKPath = ".\\";
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
using GameInit_t = void (*)(GameInitParams*);
|
||||
@@ -64,6 +64,9 @@ namespace
|
||||
} Game;
|
||||
|
||||
const char* GameFunctionTable[] = { "GameInit", "GameShutdown", "GameUpdate" };
|
||||
|
||||
LightID RedLightID = 0;
|
||||
LightID BlueLightID = 0;
|
||||
} // namespace
|
||||
|
||||
void JulietApplication::Init(NonNullPtr<Arena>)
|
||||
@@ -75,6 +78,7 @@ void JulietApplication::Init(NonNullPtr<Arena>)
|
||||
#if JULIET_DEBUG
|
||||
config.EnableDebug = true;
|
||||
#endif
|
||||
|
||||
GraphicsDevice = CreateGraphicsDevice(config);
|
||||
|
||||
MainWindow = CreatePlatformWindow("Juliet Editor", 1280, 720);
|
||||
@@ -119,6 +123,21 @@ void JulietApplication::Init(NonNullPtr<Arena>)
|
||||
SetMeshTransform(cube, MatrixTranslation(x, y, 0.0f) * rotation);
|
||||
}
|
||||
}
|
||||
|
||||
// Start with some default test lights
|
||||
PointLight redLight = {};
|
||||
redLight.Position = { 5.0f, 5.0f, 2.0f };
|
||||
redLight.Radius = 10.0f;
|
||||
redLight.Color = { 1.0f, 0.2f, 0.2f };
|
||||
redLight.Intensity = 5.0f;
|
||||
RedLightID = AddPointLight(redLight);
|
||||
|
||||
PointLight blueLight = {};
|
||||
blueLight.Position = { -5.0f, 0.0f, 2.0f };
|
||||
blueLight.Radius = 15.0f;
|
||||
blueLight.Color = { 0.2f, 0.2f, 1.0f };
|
||||
blueLight.Intensity = 8.0f;
|
||||
BlueLightID = AddPointLight(blueLight);
|
||||
}
|
||||
|
||||
GameCode.Functions = reinterpret_cast<void**>(&Game);
|
||||
@@ -232,14 +251,23 @@ void JulietApplication::Update()
|
||||
}
|
||||
}
|
||||
|
||||
ArenaClear(GameScratchArena);
|
||||
|
||||
Vector3 redLightPos{ cosf(CameraTime * 2.0f) * 5.0f, sinf(CameraTime * 2.0f) * 5.0f, 2.0f };
|
||||
SetPointLightPosition(RedLightID, redLightPos);
|
||||
Vector3 blueLightPos{ -5.0f, cosf(CameraTime) * 3.0f, 2.0f };
|
||||
SetPointLightPosition(BlueLightID, blueLightPos);
|
||||
|
||||
#ifdef JULIET_ENABLE_IMGUI
|
||||
// ImGui::ShowDemoWindow();
|
||||
ImGui::ShowDemoWindow();
|
||||
#endif
|
||||
|
||||
DebugDisplay_DrawLine({ 0.0f, 0.0f, 0.0f }, { 1.0f, 0.0f, 0.0f }, { 1.0f, 0.0f, 0.0f, 1.0f }, false);
|
||||
DebugDisplay_DrawLine({ 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, { 0.0f, 1.0f, 0.0f, 1.0f }, true);
|
||||
DebugDisplay_DrawLine({ 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 1.0f }, { 0.0f, 0.0f, 1.0f, 1.0f }, true);
|
||||
DebugDisplay_DrawSphere({ 0.0f, 0.0f, 0.0f }, 0.5f, { 1.0f, 1.0f, 0.0f, 1.0f }, true);
|
||||
DebugDisplay_DrawSphere(blueLightPos, 0.5f, { 0.0f, 0.0f, 1.0f, 1.0f }, true);
|
||||
DebugDisplay_DrawSphere(redLightPos, 0.5f, { 1.0f, 0.0f, 0.0f, 1.0f }, true);
|
||||
|
||||
Game.Update(0.0f);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user