diff --git a/Engine/Components/Componet.h b/Engine/Components/Componet.h new file mode 100644 index 0000000..e69de29 diff --git a/Engine/engine.cpp b/Engine/engine.cpp index ee37738..d1ad752 100644 --- a/Engine/engine.cpp +++ b/Engine/engine.cpp @@ -58,8 +58,27 @@ GLFWwindow* Engine::GetWindow() { } void Engine::ResizeFramebuffer(int width, int height) { - fbWidth = width; - fbHeight = height; + // Avoid division by zero. + if (height <= 0) + height = 1; + + // Define the desired target aspect ratio (e.g., 16:9). + const float targetAspect = 16.0f / 9.0f; + float currentAspect = static_cast(width) / static_cast(height); + + // Adjust dimensions to maintain the target aspect ratio. + int newWidth = width; + int newHeight = height; + if (currentAspect > targetAspect) { + // The viewport is too wide: adjust width. + newWidth = static_cast(height * targetAspect); + } else if (currentAspect < targetAspect) { + // The viewport is too tall: adjust height. + newHeight = static_cast(width / targetAspect); + } + + fbWidth = newWidth; + fbHeight = newHeight; glBindFramebuffer(GL_FRAMEBUFFER, framebuffer); @@ -92,6 +111,7 @@ void Engine::ResizeFramebuffer(int width, int height) { glBindFramebuffer(GL_FRAMEBUFFER, 0); } + GLuint Engine::CompileShader(const char* vertexSrc, const char* fragmentSrc) { GLuint vertexShader = glCreateShader(GL_VERTEX_SHADER); glShaderSource(vertexShader, 1, &vertexSrc, nullptr); @@ -229,8 +249,8 @@ bool Engine::SetupScene() { void main() { // Ambient. - float ambientStrength = 0.2; - vec3 ambient = ambientStrength * vec3(1.0, 0.0, 0.0); + float ambientStrength = 0.3; + vec3 ambient = ambientStrength * vec3(1.0, 0.0, 1.0); // Diffuse. vec3 norm = normalize(Normal); @@ -270,7 +290,7 @@ ImTextureID Engine::RenderScene(const glm::mat4 &view, const glm::mat4 &projecti glUniform3f(glGetUniformLocation(shaderProgram, "viewPos"), viewPos.x, viewPos.y, viewPos.z); rotationAngle += 0.01f; - glm::mat4 model = glm::rotate(glm::mat4(1.0f), rotationAngle, glm::vec3(1,1,1)); + glm::mat4 model = glm::rotate(glm::mat4(1.0f), rotationAngle, glm::vec3(1,1,0)); glUniformMatrix4fv(glGetUniformLocation(shaderProgram, "model"), 1, GL_FALSE, glm::value_ptr(model)); glUniform3f(glGetUniformLocation(shaderProgram, "lightPos"), 0.0f, 20.0f, 0.0f); diff --git a/Three-Labs.exe b/Three-Labs.exe index 2ca6e05..6a2f19a 100644 Binary files a/Three-Labs.exe and b/Three-Labs.exe differ diff --git a/build/Engine/engine.o b/build/Engine/engine.o index 5df155b..e905e5d 100644 Binary files a/build/Engine/engine.o and b/build/Engine/engine.o differ diff --git a/imgui.ini b/imgui.ini index 8768b04..f17b88a 100644 --- a/imgui.ini +++ b/imgui.ini @@ -15,9 +15,10 @@ Collapsed=0 DockId=0x00000001,0 [Window][Rendered Output] -Pos=337,0 -Size=943,800 +Pos=336,0 +Size=944,800 Collapsed=0 +DockId=0x00000002,0 [Window][Editor] Pos=176,231 @@ -27,5 +28,5 @@ Collapsed=0 [Docking][Data] DockSpace ID=0x08BD597D Window=0x1BBC0F80 Pos=0,0 Size=1280,800 Split=X Selected=0x5098C5B2 DockNode ID=0x00000001 Parent=0x08BD597D SizeRef=334,800 Selected=0x5098C5B2 - DockNode ID=0x00000002 Parent=0x08BD597D SizeRef=944,800 CentralNode=1 + DockNode ID=0x00000002 Parent=0x08BD597D SizeRef=944,800 CentralNode=1 Selected=0xB6999AB4