diff --git a/grafika_projekt/grafika_projekt.vcxproj b/grafika_projekt/grafika_projekt.vcxproj
index 68ed12b..caf784f 100644
--- a/grafika_projekt/grafika_projekt.vcxproj
+++ b/grafika_projekt/grafika_projekt.vcxproj
@@ -142,6 +142,7 @@
+
@@ -155,6 +156,7 @@
+
diff --git a/grafika_projekt/grafika_projekt.vcxproj.filters b/grafika_projekt/grafika_projekt.vcxproj.filters
index 9fa44ef..4abfd2a 100644
--- a/grafika_projekt/grafika_projekt.vcxproj.filters
+++ b/grafika_projekt/grafika_projekt.vcxproj.filters
@@ -48,6 +48,9 @@
Source Files
+
+ Source Files
+
@@ -95,6 +98,9 @@
Header Files
+
+ Header Files
+
diff --git a/grafika_projekt/src/Engine.cpp b/grafika_projekt/src/Engine.cpp
new file mode 100644
index 0000000..461c890
--- /dev/null
+++ b/grafika_projekt/src/Engine.cpp
@@ -0,0 +1,180 @@
+#include "Engine.h"
+
+
+void Core::Engine::initShaderPrograms() {
+ this->textureShader = shaderLoader.CreateProgram((char*)"shaders/shader_tex.vert", (char*)"shaders/shader_tex.frag");
+ this->skyboxShader = shaderLoader.CreateProgram((char*)"shaders/skybox.vert", (char*)"shaders/skybox.frag");
+ this->bubbleShader = shaderLoader.CreateProgram((char*)"shaders/bubble.vert", (char*)"shaders/bubble.frag");
+}
+
+void Core::Engine::shutdownShaderPrograms() {
+ shaderLoader.DeleteProgram(this->textureShader);
+ shaderLoader.DeleteProgram(this->skyboxShader);
+ shaderLoader.DeleteProgram(this->bubbleShader);
+}
+
+void Core::Engine::initRenderContexts() {
+ loadModelToContext("models/fish.obj", this->fishContext);
+ loadModelToContext("models/submarine.obj", this->submarineContext);
+ loadModelToContext("models/sphere.obj", this->bubbleContext);
+
+ this->terrain = Terrain(this->heightGenerator);
+ obj::Model model = this->terrain.generateTerrain();
+ this->terrainContext.initFromOBJ(model);
+}
+
+void Core::Engine::loadTextures() {
+ this->fishTexture = LoadTexture("textures/fish.png");
+ this->submarineTexture = LoadTexture("textures/submarine.png");
+ this->bubbleTexture = LoadTexture("textures/bubble.png");
+ this->terrainTexture = LoadTexture("textures/terrain.jpg");
+ this->skyboxTexture = loadCubemap();
+}
+
+void Core::Engine::initCube() {
+ GLuint cubeVAO, cubeVBO;
+ glGenVertexArrays(1, &cubeVAO);
+ glGenBuffers(1, &cubeVBO);
+ glBindVertexArray(cubeVAO);
+ glBindBuffer(GL_ARRAY_BUFFER, cubeVBO);
+ glBufferData(GL_ARRAY_BUFFER, sizeof(this->cubeVertices), &this->cubeVertices, GL_STATIC_DRAW);
+ glEnableVertexAttribArray(0);
+ glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 6 * sizeof(float), (void*)0);
+ glEnableVertexAttribArray(1);
+ glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 6 * sizeof(float), (void*)(3 * sizeof(float)));
+}
+
+void Core::Engine::initSkybox() {
+ this->initCube();
+ glGenVertexArrays(1, &this->skyboxVAO);
+ glBindVertexArray(this->skyboxVAO);
+
+ glGenBuffers(1, &this->skyboxVBO);
+ glBindBuffer(GL_ARRAY_BUFFER, this->skyboxVBO);
+ glBufferData(GL_ARRAY_BUFFER, sizeof(this->skyboxVertices), &this->skyboxVertices, GL_STATIC_DRAW);
+
+ GLuint vPosition = glGetAttribLocation(this->skyboxShader, "aPos");
+ glEnableVertexAttribArray(vPosition);
+
+ glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(this->skyboxVertices), this->skyboxVertices);
+ glEnableVertexAttribArray(0);
+ glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), (void*)0);
+}
+
+void Core::Engine::initRandomGenerator(std::default_random_engine gen, std::uniform_int_distribution<> distr) {
+ this->gen = gen;
+ this->distr = distr;
+}
+
+
+std::vector Core::Engine::genBubbleKeyPoints() {
+ float random1 = this->distr(this->gen);
+ float random2 = this->distr(this->gen);
+ std::vector bubbleKeyPoints({
+ glm::vec3(random1 , -this->skyboxVerticeParameter, random2),
+ glm::vec3(random1 , this->skyboxVerticeParameter, random2)
+ }
+ );
+ return bubbleKeyPoints;
+};
+
+void Core::Engine::generateBubbleArray() {
+ for (int i = 0; i < 300; i++) {
+ this->bubbleArray[i] = this->genBubbleKeyPoints();
+ }
+}
+
+void Core::Engine::initBubbles() {
+ this->generateBubbleArray();
+}
+
+const float Core::Engine::cubeVertices[216] = {
+ // positions // normals
+ -0.5f, -0.5f, -0.5f, 0.0f, 0.0f, -1.0f,
+ 0.5f, -0.5f, -0.5f, 0.0f, 0.0f, -1.0f,
+ 0.5f, 0.5f, -0.5f, 0.0f, 0.0f, -1.0f,
+ 0.5f, 0.5f, -0.5f, 0.0f, 0.0f, -1.0f,
+ -0.5f, 0.5f, -0.5f, 0.0f, 0.0f, -1.0f,
+ -0.5f, -0.5f, -0.5f, 0.0f, 0.0f, -1.0f,
+
+ -0.5f, -0.5f, 0.5f, 0.0f, 0.0f, 1.0f,
+ 0.5f, -0.5f, 0.5f, 0.0f, 0.0f, 1.0f,
+ 0.5f, 0.5f, 0.5f, 0.0f, 0.0f, 1.0f,
+ 0.5f, 0.5f, 0.5f, 0.0f, 0.0f, 1.0f,
+ -0.5f, 0.5f, 0.5f, 0.0f, 0.0f, 1.0f,
+ -0.5f, -0.5f, 0.5f, 0.0f, 0.0f, 1.0f,
+
+ -0.5f, 0.5f, 0.5f, -1.0f, 0.0f, 0.0f,
+ -0.5f, 0.5f, -0.5f, -1.0f, 0.0f, 0.0f,
+ -0.5f, -0.5f, -0.5f, -1.0f, 0.0f, 0.0f,
+ -0.5f, -0.5f, -0.5f, -1.0f, 0.0f, 0.0f,
+ -0.5f, -0.5f, 0.5f, -1.0f, 0.0f, 0.0f,
+ -0.5f, 0.5f, 0.5f, -1.0f, 0.0f, 0.0f,
+
+ 0.5f, 0.5f, 0.5f, 1.0f, 0.0f, 0.0f,
+ 0.5f, 0.5f, -0.5f, 1.0f, 0.0f, 0.0f,
+ 0.5f, -0.5f, -0.5f, 1.0f, 0.0f, 0.0f,
+ 0.5f, -0.5f, -0.5f, 1.0f, 0.0f, 0.0f,
+ 0.5f, -0.5f, 0.5f, 1.0f, 0.0f, 0.0f,
+ 0.5f, 0.5f, 0.5f, 1.0f, 0.0f, 0.0f,
+
+ -0.5f, -0.5f, -0.5f, 0.0f, -1.0f, 0.0f,
+ 0.5f, -0.5f, -0.5f, 0.0f, -1.0f, 0.0f,
+ 0.5f, -0.5f, 0.5f, 0.0f, -1.0f, 0.0f,
+ 0.5f, -0.5f, 0.5f, 0.0f, -1.0f, 0.0f,
+ -0.5f, -0.5f, 0.5f, 0.0f, -1.0f, 0.0f,
+ -0.5f, -0.5f, -0.5f, 0.0f, -1.0f, 0.0f,
+
+ -0.5f, 0.5f, -0.5f, 0.0f, 1.0f, 0.0f,
+ 0.5f, 0.5f, -0.5f, 0.0f, 1.0f, 0.0f,
+ 0.5f, 0.5f, 0.5f, 0.0f, 1.0f, 0.0f,
+ 0.5f, 0.5f, 0.5f, 0.0f, 1.0f, 0.0f,
+ -0.5f, 0.5f, 0.5f, 0.0f, 1.0f, 0.0f,
+ -0.5f, 0.5f, -0.5f, 0.0f, 1.0f, 0.0f
+};
+
+const float Core::Engine::skyboxVerticeParameter = 50.0f;
+
+const float Core::Engine::skyboxVertices[108] = {
+ -skyboxVerticeParameter, skyboxVerticeParameter, -skyboxVerticeParameter,
+ -skyboxVerticeParameter, -skyboxVerticeParameter, -skyboxVerticeParameter,
+ skyboxVerticeParameter, -skyboxVerticeParameter, -skyboxVerticeParameter,
+ skyboxVerticeParameter, -skyboxVerticeParameter, -skyboxVerticeParameter,
+ skyboxVerticeParameter, skyboxVerticeParameter, -skyboxVerticeParameter,
+ -skyboxVerticeParameter, skyboxVerticeParameter, -skyboxVerticeParameter,
+
+ -skyboxVerticeParameter, -skyboxVerticeParameter, skyboxVerticeParameter,
+ -skyboxVerticeParameter, -skyboxVerticeParameter, -skyboxVerticeParameter,
+ -skyboxVerticeParameter, skyboxVerticeParameter, -skyboxVerticeParameter,
+ -skyboxVerticeParameter, skyboxVerticeParameter, -skyboxVerticeParameter,
+ -skyboxVerticeParameter, skyboxVerticeParameter, skyboxVerticeParameter,
+ -skyboxVerticeParameter, -skyboxVerticeParameter, skyboxVerticeParameter,
+
+ skyboxVerticeParameter, -skyboxVerticeParameter, -skyboxVerticeParameter,
+ skyboxVerticeParameter, -skyboxVerticeParameter, skyboxVerticeParameter,
+ skyboxVerticeParameter, skyboxVerticeParameter, skyboxVerticeParameter,
+ skyboxVerticeParameter, skyboxVerticeParameter, skyboxVerticeParameter,
+ skyboxVerticeParameter, skyboxVerticeParameter, -skyboxVerticeParameter,
+ skyboxVerticeParameter, -skyboxVerticeParameter, -skyboxVerticeParameter,
+
+ -skyboxVerticeParameter, -skyboxVerticeParameter, skyboxVerticeParameter,
+ -skyboxVerticeParameter, skyboxVerticeParameter, skyboxVerticeParameter,
+ skyboxVerticeParameter, skyboxVerticeParameter, skyboxVerticeParameter,
+ skyboxVerticeParameter, skyboxVerticeParameter, skyboxVerticeParameter,
+ skyboxVerticeParameter, -skyboxVerticeParameter, skyboxVerticeParameter,
+ -skyboxVerticeParameter, -skyboxVerticeParameter, skyboxVerticeParameter,
+
+ -skyboxVerticeParameter, skyboxVerticeParameter, -skyboxVerticeParameter,
+ skyboxVerticeParameter, skyboxVerticeParameter, -skyboxVerticeParameter,
+ skyboxVerticeParameter, skyboxVerticeParameter, skyboxVerticeParameter,
+ skyboxVerticeParameter, skyboxVerticeParameter, skyboxVerticeParameter,
+ -skyboxVerticeParameter, skyboxVerticeParameter, skyboxVerticeParameter,
+ -skyboxVerticeParameter, skyboxVerticeParameter, -skyboxVerticeParameter,
+
+ -skyboxVerticeParameter, -skyboxVerticeParameter, -skyboxVerticeParameter,
+ -skyboxVerticeParameter, -skyboxVerticeParameter, skyboxVerticeParameter,
+ skyboxVerticeParameter, -skyboxVerticeParameter, -skyboxVerticeParameter,
+ skyboxVerticeParameter, -skyboxVerticeParameter, -skyboxVerticeParameter,
+ -skyboxVerticeParameter, -skyboxVerticeParameter, skyboxVerticeParameter,
+ skyboxVerticeParameter, -skyboxVerticeParameter, skyboxVerticeParameter
+};
\ No newline at end of file
diff --git a/grafika_projekt/src/Engine.h b/grafika_projekt/src/Engine.h
new file mode 100644
index 0000000..b555dcf
--- /dev/null
+++ b/grafika_projekt/src/Engine.h
@@ -0,0 +1,43 @@
+#pragma once
+#include "glm.hpp"
+#include "glew.h"
+#include