Skip to content

Commit

Permalink
Vulkan Template completed.
Browse files Browse the repository at this point in the history
  • Loading branch information
Cherrytree56567 committed Apr 1, 2024
1 parent 1379cf0 commit 613141b
Show file tree
Hide file tree
Showing 32 changed files with 133 additions and 29 deletions.
1 change: 1 addition & 0 deletions Drizzle3D/OpenGL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Drizzle3D {
void RenderingLayer::InitGlRendering() {
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glEnable(GL_DEPTH_TEST);
glGenBuffers(1, &lightsBuffer);
glBindBuffer(GL_UNIFORM_BUFFER, lightsBuffer);
Expand Down
54 changes: 35 additions & 19 deletions Drizzle3D/RenderingLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,7 @@ namespace Drizzle3D {
// Vertex Buffer
// Index Buffer
// Shader (not needed)

if (UseOpenGL && UseVulkan) {
UseOpenGL = true;
UseVulkan = false;
}

if (UseOpenGL && !UseOLDOpenGL) {
UseOLDOpenGL = UseOpenGL;
InitGlRendering();
Expand All @@ -87,12 +83,22 @@ namespace Drizzle3D {
InitVulkanRendering();
}
if (UseOpenGL) {
UseOpenGL = true;
UseVulkan = false;
UseOLDOpenGL = UseOpenGL;
InitGlRendering();
} else if (UseVulkan) {
UseOpenGL = false;
UseVulkan = true;
UseOLDVulkan = UseVulkan;
InitVulkanRendering();
}
else {
UseOpenGL = true;
UseVulkan = false;
UseOLDOpenGL = UseOpenGL;
InitGlRendering();
}

Light pointLight;

Expand Down Expand Up @@ -131,10 +137,6 @@ namespace Drizzle3D {
myOBJ.modelMatrix = modelMatrix;
myOBJ.mat = shaderProgram;
// Create Vertex Array Object (VAO), Vertex Buffer Object (VBO), and Element Buffer Object (EBO)
if (UseOpenGL && UseVulkan) {
UseOpenGL = true;
UseVulkan = false;
}
if (UseOpenGL && !UseOLDOpenGL) {
UseOLDOpenGL = UseOpenGL;
InitGlRendering();
Expand All @@ -144,12 +146,23 @@ namespace Drizzle3D {
InitVulkanRendering();
}
if (UseOpenGL) {
UseOpenGL = true;
UseVulkan = false;
UseOLDOpenGL = UseOpenGL;
DrawVertGLRendering(myOBJ);
} else if (UseVulkan) {
}
else if (UseVulkan) {
UseOpenGL = false;
UseVulkan = true;
UseOLDVulkan = UseVulkan;
DrawVertVulkanRendering(myOBJ);
}
else {
UseOpenGL = true;
UseVulkan = false;
UseOLDOpenGL = UseOpenGL;
DrawVertGLRendering(myOBJ);
}

return myOBJ;
}
Expand All @@ -161,14 +174,6 @@ namespace Drizzle3D {
glfwRestoreWindow(pWindow->returnwindow());
}

if (UseOpenGL && UseVulkan) {
UseOpenGL = true;
UseVulkan = false;
}
if (!UseOpenGL && !UseVulkan) {
UseOpenGL = true;
UseVulkan = false;
}
if (UseOpenGL && !UseOLDOpenGL) {
UseOLDOpenGL = UseOpenGL;
InitGlRendering();
Expand All @@ -178,12 +183,23 @@ namespace Drizzle3D {
InitVulkanRendering();
}
if (UseOpenGL) {
UseOpenGL = true;
UseVulkan = false;
UseOLDOpenGL = UseOpenGL;
RenderInitGlRendering();
} else if (UseVulkan) {
}
else if (UseVulkan) {
UseOpenGL = false;
UseVulkan = true;
UseOLDVulkan = UseVulkan;
RenderInitVulkanRendering();
}
else {
UseOpenGL = true;
UseVulkan = false;
UseOLDOpenGL = UseOpenGL;
RenderInitGlRendering();
}
}

Drizzle3D_API GLuint GetTexture(const char* TexturePath) {
Expand Down
1 change: 1 addition & 0 deletions Drizzle3D/RenderingLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ namespace Drizzle3D {
GLuint textureID = NULL;
GLuint mat = 0;
char* name = (char*)"PLZ_SPECIFY_A_NAME";
// Add New Vulkan Shader here as pass it NULL by default.
};

struct Camera {
Expand Down
89 changes: 89 additions & 0 deletions Drizzle3D/Vulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,102 @@
namespace Drizzle3D {
void RenderingLayer::InitVulkanRendering() {
log.Warning("Vulkan Initialization Not Implemented.");
// Set GLFW Flags to NO_CLIENT_API
// Initialize Vulkan
glm::mat4 projectionMatrix = glm::perspective(glm::radians(45.0f), 800.0f / 600.0f, 0.1f, 100.0f);
// Init Vulkan Shaders
// Create shader modules for vertex and fragment shaders
// Create pipeline layout
// Create render pass
// Create graphics pipeline
// Create command buffers
}

void RenderingLayer::RenderInitVulkanRendering() {
log.Warning("Vulkan Rendering Not Implemented.");
// Clear Color and Depth Buffer

glm::mat4 projectionMatrix = glm::perspective(glm::radians(45.0f), 800.0f / 600.0f, 0.1f, 150.0f);
glm::mat4 viewMatrix = glm::lookAt(returnCamera(current_camera)->position, returnCamera(current_camera)->look_at_position, returnCamera(current_camera)->up);
//glm::mat4 viewMatrix = glm::lookAt(glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 1.0f, 0.0f));
glm::vec3 cameraPosition = glm::inverse(viewMatrix)[3];

// Pass ProjectionMatrix, ViewMatrix and CameraPosition to Vulkan Shader

// Pass Lights and Number of Lights to Vulkan Shader

// Set the uniform values for the number of lights

// Loop through each light in the array
for (size_t i = 0; i < Lights.size(); ++i) {
std::string lightPrefix = "lights[" + std::to_string(i) + "]";
// Set its values
}
for (const auto& obje : Objects) {
// Look at Object struct in RenderingLayer.h
if (false) { // If Default Vulkan shader is not equal to Vulkan Shader Inside "obje"

// Set Vulkan Shader inside of "obje" as current usable one

// Pass ProjectionMatrix, ViewMatrix and CameraPosition to Vulkan Shader

// Pass Lights and Number of Lights to Vulkan Shader inside of "obje"

// Set the uniform values for the number of lights to Vulkan Shader inside of "obje"

// Loop through each light in the array
for (size_t i = 0; i < Lights.size(); ++i) {
std::string lightPrefix = "lights[" + std::to_string(i) + "]";
// Set its values to Vulkan Shader inside of "obje"
}

// If Skybox is True
if (obje.name == "Skybox") {
// Pass true to Skybox Value in Vulkan Shader inside of "obje"
}
else {
// Pass false to Skybox Value in Vulkan Shader inside of "obje"
}
if (Lighting == false) {
// Pass true to Skybox Value in Vulkan Shader inside of "obje"
}
// Convert OpenGL Texture to Vulkan Texture

// Pass Vulkan Texture to Vulkan Shader inside of "obje"

// Pass Vulkan Shader the ModelMatrix inside "obje"
}
else {
// If Skybox is True
if (obje.name == "Skybox") {
// Pass true to Skybox Value in Vulkan Shader
}
else {
// Pass false to Skybox Value in Vulkan Shader
}
if (Lighting == false) {
// Pass true to Skybox Value in Vulkan Shader
}
// Convert OpenGL Texture to Vulkan Texture

// Pass Vulkan Texture to Vulkan Shader

// Pass Vulkan Shader the ModelMatrix
}

// Bind Vertex Array inside of "obje"
// Draw Vertexs
}

// Disable Face Culling
}

void RenderingLayer::DrawVertVulkanRendering(Object& myOBJ) {
log.Warning("Vulkan Vertex Drawing Not Implemented.");
// Create vertex buffer
// Allocate memory for vertex buffer
// Bind memory to vertex buffer
// Copy vertex data to vertex buffer
// Create index buffer (similar to vertex buffer)
}
}
1 change: 0 additions & 1 deletion Drizzle3D/Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ namespace Drizzle3D {
glfwInit();
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
window = glfwCreateWindow(width, height, WindowName, NULL, NULL);
if (window == NULL) {
std::cout << "[Drizzle3D::Core::Window] Error: Failed to create GLFW window." << std::endl;
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.
4 changes: 1 addition & 3 deletions Drizzle3D/x64/Debug/Drizzle3D.log
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
C:\Users\ronit\Desktop\Drizzle3D\Drizzle3D\Light.cpp(13,16): warning C4244: '=': conversion from 'float' to 'int', possible loss of data
Object.cpp
OpenGL.cpp
C:\Users\ronit\Desktop\Drizzle3D\Drizzle3D\OpenGL.cpp(178,59): warning C4267: 'argument': conversion from 'size_t' to 'GLsizei', possible loss of data
C:\Users\ronit\Desktop\Drizzle3D\Drizzle3D\OpenGL.cpp(179,59): warning C4267: 'argument': conversion from 'size_t' to 'GLsizei', possible loss of data
RenderingLayer.cpp
Shader.cpp
Skybox.cpp
Expand All @@ -15,6 +15,4 @@ C:\Users\ronit\Desktop\Drizzle3D\Drizzle3D\OpenGL.cpp(178,59): warning C4267: 'a
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
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/link.read.1.tlog
Binary file not shown.
Binary file modified Drizzle3D/x64/Debug/FirstPersonCamera.obj
Binary file not shown.
Binary file modified Drizzle3D/x64/Debug/Light.obj
Binary file not shown.
Binary file modified Drizzle3D/x64/Debug/Object.obj
Binary file not shown.
Binary file modified Drizzle3D/x64/Debug/OpenGL.obj
Binary file not shown.
Binary file modified Drizzle3D/x64/Debug/RenderingLayer.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/Vulkan.obj
Binary file not shown.
Binary file modified Drizzle3D/x64/Debug/Window.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.
9 changes: 5 additions & 4 deletions ExampleProject/ExampleProject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ int main() {
* Key Released and Mouse Released
*/
std::shared_ptr<Drizzle3D::App> app = std::make_shared<Drizzle3D::App>();

app->GetRenderingLayer()->GetFlags()->ChangeFlag("Lighting", false);
app->GetRenderingLayer()->GetFlags()->ChangeFlag("UseOpenGL", false);
app->GetRenderingLayer()->GetFlags()->ChangeFlag("UseVulkan", true);

Drizzle3D::FirstPersonCamera fpc(app);
Drizzle3D::Skybox sky(app, "skybox.png");
Drizzle3D::Material mat1(app->GetResourceManager(), "Scene1_vertex.glsl", "Scene1_fragment.glsl");
Expand All @@ -90,10 +95,6 @@ int main() {

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

app->GetRenderingLayer()->GetFlags()->ChangeFlag("Lighting", false);
app->GetRenderingLayer()->GetFlags()->ChangeFlag("UseOpenGL", false);
app->GetRenderingLayer()->GetFlags()->ChangeFlag("UseVulkan", true);

app->ImguiLayer()->code = ImGUICode;
app->GetRenderingLayer()->AddObject("Cube", app->GetRenderingLayer()->DrawVerts(Drizzle3D::LoadObjFile("Scene1_Cube.obj"), modelMatrix));
app->GetRenderingLayer()->returnObject("Cube")->textureID = Drizzle3D::GetTexture("duck.png");
Expand Down
Binary file modified ExampleProject/x64/Debug/ExampleProject.ilk
Binary file not shown.
3 changes: 1 addition & 2 deletions ExampleProject/x64/Debug/ExampleProject.log
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
 Scanning sources for module dependencies...
ExampleProject.cpp
 ExampleProject.cpp
ExampleProject.vcxproj -> C:\Users\ronit\Desktop\Drizzle3D\x64\Debug\ExampleProject.exe
Binary file modified ExampleProject/x64/Debug/ExampleProject.obj
Binary file not shown.
Binary file modified ExampleProject/x64/Debug/vc143.idb
Binary file not shown.
Binary file modified ExampleProject/x64/Debug/vc143.pdb
Binary file not shown.
Binary file modified x64/Debug/Drizzle3D.dll
Binary file not shown.
Binary file modified x64/Debug/Drizzle3D.pdb
Binary file not shown.
Binary file modified x64/Debug/ExampleProject.exe
Binary file not shown.
Binary file modified x64/Debug/ExampleProject.pdb
Binary file not shown.

0 comments on commit 613141b

Please sign in to comment.