Skip to content

Commit

Permalink
Flags and Fullscreen Support
Browse files Browse the repository at this point in the history
  • Loading branch information
Cherrytree56567 committed Mar 26, 2024
1 parent c688fd6 commit 05f28d3
Show file tree
Hide file tree
Showing 44 changed files with 136 additions and 19 deletions.
2 changes: 2 additions & 0 deletions Drizzle3D/Drizzle3D.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<ClCompile Include="Camera.cpp" />
<ClCompile Include="Events.cpp" />
<ClCompile Include="FirstPersonCamera.cpp" />
<ClCompile Include="Flags.cpp" />
<ClCompile Include="ImGuiLayer.cpp" />
<ClCompile Include="Layer.cpp" />
<ClCompile Include="Light.cpp" />
Expand Down Expand Up @@ -51,6 +52,7 @@
<ClInclude Include="base.h" />
<ClInclude Include="Events.h" />
<ClInclude Include="FirstPersonCamera.h" />
<ClInclude Include="Flags.h" />
<ClInclude Include="ImGuiLayer.h" />
<ClInclude Include="KeyCodes.h" />
<ClInclude Include="KeyEvent.h" />
Expand Down
9 changes: 9 additions & 0 deletions Drizzle3D/Drizzle3D.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@
<Filter Include="Source Files\Rendering\Material">
<UniqueIdentifier>{766b5aaf-57a2-477b-82c9-2cc16b3d97a4}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\Flags">
<UniqueIdentifier>{d2494ee0-6d9c-46f2-8671-60f383df2474}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cpp">
Expand Down Expand Up @@ -156,6 +159,9 @@
<ClCompile Include="vendor\glm\glm\glm.cppm">
<Filter>Vendor</Filter>
</ClCompile>
<ClCompile Include="Flags.cpp">
<Filter>Source Files\Flags</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Window.h">
Expand Down Expand Up @@ -239,6 +245,9 @@
<ClInclude Include="main.h">
<Filter>Vendor</Filter>
</ClInclude>
<ClInclude Include="Flags.h">
<Filter>Source Files\Flags</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<FxCompile Include="VertexShader.glsl">
Expand Down
31 changes: 31 additions & 0 deletions Drizzle3D/Flags.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include "Flags.h"

namespace Drizzle3D {
void Flags::AddFlag(const std::string& name, bool& pointer) {
flagMap[name] = &pointer;
}

void Flags::ChangeFlag(const std::string& name, const bool newValue) {
if (flagMap.find(name) != flagMap.end()) {
try {
*flagMap[name] = newValue;
}
catch (const std::bad_any_cast& e) {
log.Error("Failed to cast to the correct type: " + (std::string)e.what() + "\n");
}
}
else {
log.Error("Flag with name " + name + " not found.\n");
}
}

bool Flags::GetFlag(const std::string& name) {
if (flagMap.find(name) != flagMap.end()) {
return *flagMap[name];
}
else {
log.Error("Flag with name " + name + " not found.\n");
return false;
}
}
}
23 changes: 23 additions & 0 deletions Drizzle3D/Flags.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#pragma once
#include <map>
#include <string>
#include <any>
#include "base.h"
#include "Logging.h"

namespace Drizzle3D {
class Flags {
public:
Drizzle3D_API Flags() {}

Drizzle3D_API void AddFlag(const std::string& name, bool& pointer);

Drizzle3D_API void ChangeFlag(const std::string& name, const bool newValue);

Drizzle3D_API bool GetFlag(const std::string& name);

private:
std::map<std::string, bool*> flagMap;
Logging log;
};
}
11 changes: 11 additions & 0 deletions Drizzle3D/RenderingLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@

namespace Drizzle3D {

RenderingLayer::RenderingLayer(Window* window, std::shared_ptr<ResourceManager> resmgr) : name("3DLayer"), show(true), pWindow(window), resourcemgr(resmgr) {
flags.AddFlag("Lighting", Lighting);
flags.AddFlag("Fullscreen", fullscreen);
flags.AddFlag("Show", show);
}

Drizzle3D_API std::pair<std::vector<float>, std::vector<unsigned int>> LoadObjFile(const std::string& filePath) {
std::vector<float> vertices;
std::vector<unsigned int> indices;
Expand Down Expand Up @@ -152,6 +158,11 @@ namespace Drizzle3D {
}

void RenderingLayer::Render() {
if (fullscreen) {
glfwMaximizeWindow(pWindow->returnwindow());
} else {
glfwRestoreWindow(pWindow->returnwindow());
}
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glUseProgram(shaderProgram);
Expand Down
10 changes: 6 additions & 4 deletions Drizzle3D/RenderingLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "Material.h"
#include "ResourceManager.h"
#include "base.h"
#include "Flags.h"

namespace Drizzle3D {

Expand Down Expand Up @@ -65,7 +66,7 @@ namespace Drizzle3D {

class RenderingLayer : public Layer {
public:
Drizzle3D_API RenderingLayer(Window* window, std::shared_ptr<ResourceManager> resmgr) : name("3DLayer"), show(true), pWindow(window), resourcemgr(resmgr) {}
Drizzle3D_API RenderingLayer(Window* window, std::shared_ptr<ResourceManager> resmgr);

Drizzle3D_API void OnAttach() override;
Drizzle3D_API void OnDetach() override {}
Expand All @@ -90,10 +91,10 @@ namespace Drizzle3D {
Drizzle3D_API char* GetActiveCamera() { return current_camera; }
Drizzle3D_API Camera ReturnActiveCamera();
Drizzle3D_API Camera GetCameraFromID(char* cam);

bool Lighting = true;

Drizzle3D_API Flags* GetFlags() { return &flags; }
private:
bool Lighting = true;
bool fullscreen = false;
bool show;
GLuint shaderProgram = 0;
GLuint OldshaderProgram = 0;
Expand All @@ -102,6 +103,7 @@ namespace Drizzle3D {
std::vector<Object> Objects;
std::vector<Light> Lights;
std::vector<Camera> Cameras;
Flags flags;

GLuint lightsBuffer = 0;
char* current_camera = (char*)"Default";
Expand Down
2 changes: 1 addition & 1 deletion Drizzle3D/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ Drizzle3D_API int TestProgram() {

app->dispatcher()->AddEventListener(EWindowClose, Closed);

app->GetRenderingLayer()->Lighting = false;
app->GetRenderingLayer()->GetFlags()->ChangeFlag("Lighting", false);

app->ImguiLayer()->code = ImGUICode;
app->GetRenderingLayer()->AddObject("Cube", app->GetRenderingLayer()->DrawVerts(Drizzle3D::LoadObjFile("Scene1_Cube.obj"), modelMatrix));
Expand Down
Binary file modified Drizzle3D/x64/Debug/App.obj
Binary file not shown.
Binary file modified Drizzle3D/x64/Debug/Camera.obj
Binary file not shown.
Binary file modified Drizzle3D/x64/Debug/Drizzle3D.ilk
Binary file not shown.
17 changes: 13 additions & 4 deletions Drizzle3D/x64/Debug/Drizzle3D.log
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
 Scanning sources for module dependencies...
App.cpp
Camera.cpp
ResourceManager.cpp
C:\Users\ronit\Desktop\Drizzle3D\Drizzle3D\ResourceManager.cpp(14,34): warning C4302: 'type cast': truncation from 'const char []' to 'char'
C:\Users\ronit\Desktop\Drizzle3D\Drizzle3D\ResourceManager.cpp(41,31): warning C4302: 'type cast': truncation from 'const char []' to 'char'
FirstPersonCamera.cpp
Light.cpp
C:\Users\ronit\Desktop\Drizzle3D\Drizzle3D\Light.cpp(13,16): warning C4244: '=': conversion from 'float' to 'int', possible loss of data
Object.cpp
RenderingLayer.cpp
C:\Users\ronit\Desktop\Drizzle3D\Drizzle3D\RenderingLayer.cpp(289,59): warning C4267: 'argument': conversion from 'size_t' to 'GLsizei', possible loss of data
Shader.cpp
Skybox.cpp
main.cpp
Generating Code...
C:\Users\ronit\Desktop\Drizzle3D\Drizzle3D\Camera.cpp(46,1): warning C4715: 'Drizzle3D::RenderingLayer::ReturnActiveCamera': not all control paths return a value
C:\Users\ronit\Desktop\Drizzle3D\Drizzle3D\Camera.cpp(54,1): warning C4715: 'Drizzle3D::RenderingLayer::GetCameraFromID': not all control paths return a value
C:\Users\ronit\Desktop\Drizzle3D\Drizzle3D\Camera.cpp(46,1): warning C4715: 'Drizzle3D::RenderingLayer::ReturnActiveCamera': not all control paths return a value
Creating library C:\Users\ronit\Desktop\Drizzle3D\x64\Debug\Drizzle3D.lib and object C:\Users\ronit\Desktop\Drizzle3D\x64\Debug\Drizzle3D.exp
LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
Drizzle3D.vcxproj -> C:\Users\ronit\Desktop\Drizzle3D\x64\Debug\Drizzle3D.dll
Binary file modified Drizzle3D/x64/Debug/Drizzle3D.tlog/CL.command.1.tlog
Binary file not shown.
Binary file modified Drizzle3D/x64/Debug/Drizzle3D.tlog/CL.read.1.tlog
Binary file not shown.
Binary file modified Drizzle3D/x64/Debug/Drizzle3D.tlog/CL.write.1.tlog
Binary file not shown.
1 change: 1 addition & 0 deletions Drizzle3D/x64/Debug/Drizzle3D.tlog/Cl.items.tlog
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ C:\Users\ronit\Desktop\Drizzle3D\Drizzle3D\App.cpp;C:\Users\ronit\Desktop\Drizzl
C:\Users\ronit\Desktop\Drizzle3D\Drizzle3D\Camera.cpp;C:\Users\ronit\Desktop\Drizzle3D\Drizzle3D\x64\Debug\Camera.obj
C:\Users\ronit\Desktop\Drizzle3D\Drizzle3D\Events.cpp;C:\Users\ronit\Desktop\Drizzle3D\Drizzle3D\x64\Debug\Events.obj
C:\Users\ronit\Desktop\Drizzle3D\Drizzle3D\FirstPersonCamera.cpp;C:\Users\ronit\Desktop\Drizzle3D\Drizzle3D\x64\Debug\FirstPersonCamera.obj
C:\Users\ronit\Desktop\Drizzle3D\Drizzle3D\Flags.cpp;C:\Users\ronit\Desktop\Drizzle3D\Drizzle3D\x64\Debug\Flags.obj
C:\Users\ronit\Desktop\Drizzle3D\Drizzle3D\ImGuiLayer.cpp;C:\Users\ronit\Desktop\Drizzle3D\Drizzle3D\x64\Debug\ImGuiLayer.obj
C:\Users\ronit\Desktop\Drizzle3D\Drizzle3D\Layer.cpp;C:\Users\ronit\Desktop\Drizzle3D\Drizzle3D\x64\Debug\Layer.obj
C:\Users\ronit\Desktop\Drizzle3D\Drizzle3D\Light.cpp;C:\Users\ronit\Desktop\Drizzle3D\Drizzle3D\x64\Debug\Light.obj
Expand Down
Binary file modified Drizzle3D/x64/Debug/Drizzle3D.tlog/link.command.1.tlog
Binary file not shown.
Binary file modified Drizzle3D/x64/Debug/Drizzle3D.tlog/link.read.1.tlog
Binary file not shown.
2 changes: 1 addition & 1 deletion Drizzle3D/x64/Debug/Drizzle3D.tlog/link.secondary.1.tlog
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
^C:\USERS\RONIT\DESKTOP\DRIZZLE3D\DRIZZLE3D\X64\DEBUG\APP.OBJ|C:\USERS\RONIT\DESKTOP\DRIZZLE3D\DRIZZLE3D\X64\DEBUG\CAMERA.OBJ|C:\USERS\RONIT\DESKTOP\DRIZZLE3D\DRIZZLE3D\X64\DEBUG\EVENTS.OBJ|C:\USERS\RONIT\DESKTOP\DRIZZLE3D\DRIZZLE3D\X64\DEBUG\FIRSTPERSONCAMERA.OBJ|C:\USERS\RONIT\DESKTOP\DRIZZLE3D\DRIZZLE3D\X64\DEBUG\GLAD.OBJ|C:\USERS\RONIT\DESKTOP\DRIZZLE3D\DRIZZLE3D\X64\DEBUG\GLM.CPPM.OBJ|C:\USERS\RONIT\DESKTOP\DRIZZLE3D\DRIZZLE3D\X64\DEBUG\IMGUI.OBJ|C:\USERS\RONIT\DESKTOP\DRIZZLE3D\DRIZZLE3D\X64\DEBUG\IMGUILAYER.OBJ|C:\USERS\RONIT\DESKTOP\DRIZZLE3D\DRIZZLE3D\X64\DEBUG\IMGUI_DEMO.OBJ|C:\USERS\RONIT\DESKTOP\DRIZZLE3D\DRIZZLE3D\X64\DEBUG\IMGUI_DRAW.OBJ|C:\USERS\RONIT\DESKTOP\DRIZZLE3D\DRIZZLE3D\X64\DEBUG\IMGUI_IMPL_GLFW.OBJ|C:\USERS\RONIT\DESKTOP\DRIZZLE3D\DRIZZLE3D\X64\DEBUG\IMGUI_IMPL_OPENGL3.OBJ|C:\USERS\RONIT\DESKTOP\DRIZZLE3D\DRIZZLE3D\X64\DEBUG\IMGUI_TABLES.OBJ|C:\USERS\RONIT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64\DEBUG\RENDERINGLAYER.OBJ|C:\USERS\RONIT\DESKTOP\DRIZZLE3D\DRIZZLE3D\X64\DEBUG\RESOURCEMANAGER.OBJ|C:\USERS\RONIT\DESKTOP\DRIZZLE3D\DRIZZLE3D\X64\DEBUG\SHADER.OBJ|C:\USERS\RONIT\DESKTOP\DRIZZLE3D\DRIZZLE3D\X64\DEBUG\SKYBOX.OBJ|C:\USERS\RONIT\DESKTOP\DRIZZLE3D\DRIZZLE3D\X64\DEBUG\WINDOW.OBJ
C:\Users\ronit\Desktop\Drizzle3D\x64\Debug\Drizzle3D.lib
C:\Users\ronit\Desktop\Drizzle3D\x64\Debug\Drizzle3D.EXP
C:\Users\ronit\Desktop\Drizzle3D\Drizzle3D\x64\Debug\Drizzle3D.ilk
Binary file modified Drizzle3D/x64/Debug/Drizzle3D.tlog/link.write.1.tlog
Binary file not shown.
Binary file modified Drizzle3D/x64/Debug/FirstPersonCamera.obj
Binary file not shown.
Binary file added Drizzle3D/x64/Debug/Flags.obj
Binary file not shown.
Binary file modified Drizzle3D/x64/Debug/Light.obj
Binary file not shown.
Binary file modified Drizzle3D/x64/Debug/Material.obj
Binary file not shown.
Binary file modified Drizzle3D/x64/Debug/Object.obj
Binary file not shown.
Binary file modified Drizzle3D/x64/Debug/RenderingLayer.obj
Binary file not shown.
Binary file modified Drizzle3D/x64/Debug/ResourceManager.obj
Binary file not shown.
Binary file modified Drizzle3D/x64/Debug/Shader.obj
Binary file not shown.
Binary file modified Drizzle3D/x64/Debug/Skybox.obj
Binary file not shown.
Binary file modified Drizzle3D/x64/Debug/main.obj
Binary file not shown.
Binary file modified Drizzle3D/x64/Debug/vc143.idb
Binary file not shown.
Binary file modified Drizzle3D/x64/Debug/vc143.pdb
Binary file not shown.
14 changes: 13 additions & 1 deletion ExampleProject/ExampleProject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ glm::vec3 camera_la_pos;
char* cam;
float streg = 0.0f;
bool use_ios = true;
bool sld = false;
bool sh = true;

void Closed(GLFWwindow* window, std::unique_ptr<Drizzle3D::Event> ev, std::any a) {
std::cout << "Closeda";
Expand Down Expand Up @@ -61,6 +63,14 @@ void ImGUICode(std::shared_ptr<Drizzle3D::ImGuiLayer> rend) {
ImGui::SliderFloat("Camera Look-At X", &camera_la_pos.x, 0.0f, 50.0f);
ImGui::SliderFloat("Camera Look-At Y", &camera_la_pos.y, 0.0f, 50.0f);
ImGui::SliderFloat("Camera Look-At Z", &camera_la_pos.z, 0.0f, 50.0f);

if (ImGui::Button("Fullscreen")) {
sld = !sld;
}

if (ImGui::Button("Show")) {
sh = !sh;
}
}

int main() {
Expand All @@ -80,7 +90,7 @@ int main() {

app->dispatcher()->AddEventListener(EWindowClose, Closed);

app->GetRenderingLayer()->Lighting = false;
app->GetRenderingLayer()->GetFlags()->ChangeFlag("Lighting", false);

app->ImguiLayer()->code = ImGUICode;
app->GetRenderingLayer()->AddObject("Cube", app->GetRenderingLayer()->DrawVerts(Drizzle3D::LoadObjFile("Scene1_Cube.obj"), modelMatrix));
Expand Down Expand Up @@ -116,6 +126,8 @@ int main() {
app->GetRenderingLayer()->returnCamera("Acam")->position = camera_pos;
app->GetRenderingLayer()->returnCamera("Acam")->up = camera_up_pos;
app->GetRenderingLayer()->returnCamera("Acam")->look_at_position = camera_la_pos;
app->GetRenderingLayer()->GetFlags()->ChangeFlag("Fullscreen", sld);
app->GetRenderingLayer()->GetFlags()->ChangeFlag("Show", sh);
}

return 0;
Expand Down
Loading

0 comments on commit 05f28d3

Please sign in to comment.