diff --git a/README.md b/README.md index 517ef70..ba19cbb 100644 --- a/README.md +++ b/README.md @@ -28,11 +28,19 @@ Antkeeper uses the CMake build system for configuration. cmake --build . -4. Testing +## Workflow - cmake --build . --target run +### Making Changes + +If any changes have been made to the submodules, commit those first. Each submodule can then be updated to their latest commits with the following command: + + git submodule update --recursive --remote -5. Cleaning +### Testing + + cmake --build . --target run + +### Cleaning First perform a dry run to check what will be deleted: @@ -42,6 +50,10 @@ If there are no issues, clean: git clean -d -f -x +### Shipping + + + ## License The source code for Antkeeper is licensed under the GNU General Public License, version 3. See [COPYING](./COPYING) for details. diff --git a/data b/data index 9e05118..6ddb419 160000 --- a/data +++ b/data @@ -1 +1 @@ -Subproject commit 9e0511889e2d3b1c0c60c0878db02c5c8b7e6b8e +Subproject commit 6ddb419437560e06e12ff6c6d1e42ba88ed5098a diff --git a/src/application.cpp b/src/application.cpp index dbb8b64..aaf4614 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -19,6 +19,8 @@ #include "application.hpp" #include "application-state.hpp" +#include "model-loader.hpp" +#include "material-loader.hpp" #include "states/splash-state.hpp" #include "states/title-state.hpp" #include "states/experiment-state.hpp" @@ -29,9 +31,6 @@ #define OPENGL_VERSION_MAJOR 3 #define OPENGL_VERSION_MINOR 3 -#include "model-loader.hpp" -#include "material-loader.hpp" - Application::Application(int argc, char* argv[]): state(nullptr), nextState(nullptr), diff --git a/src/model-loader.cpp b/src/model-loader.cpp index 1cc56a7..6667854 100644 --- a/src/model-loader.cpp +++ b/src/model-loader.cpp @@ -252,6 +252,10 @@ Model* ModelLoader::load(const std::string& filename) // Allocate model Model* model = new Model(); + model->setVAO(vao); + model->setVBO(vbo); + model->setIBO(ibo); + model->setVertexFormat(modelData->vertexFormat); model->setBounds(modelData->bounds); // Create model groups diff --git a/src/render-passes.cpp b/src/render-passes.cpp index d6bd4ae..6f29e9e 100644 --- a/src/render-passes.cpp +++ b/src/render-passes.cpp @@ -277,6 +277,7 @@ LightingRenderPass::LightingRenderPass(): bool LightingRenderPass::load(const RenderContext* renderContext) { // For each render operation + /* if (renderContext != nullptr) { const std::list* operations = renderContext->queue->getOperations(); @@ -285,6 +286,7 @@ bool LightingRenderPass::load(const RenderContext* renderContext) loadShader(operation); } } + */ // Load tree shadow if (!treeShadow.load("data/textures/tree-shadow-0.png")) @@ -320,6 +322,18 @@ bool LightingRenderPass::load(const RenderContext* renderContext) return false; } + // Load lighting shader + shaderLoader.undefine(); + shaderLoader.define("TEXTURE_COUNT", 0); + shaderLoader.define("VERTEX_POSITION", EMERGENT_VERTEX_POSITION); + shaderLoader.define("VERTEX_NORMAL", EMERGENT_VERTEX_NORMAL); + + lightingShader = shaderLoader.load("data/shaders/lit-object.glsl"); + if (!lightingShader) + { + return false; + } + time = 0.0f; return true; @@ -330,6 +344,8 @@ void LightingRenderPass::unload() cappingRenderQueue.clear(); clippingRenderPass.unload(); cappingRenderPass.unload(); + delete lightingShader; + lightingShader = nullptr; for (auto it = shaderCache.begin(); it != shaderCache.end(); ++it) { @@ -723,6 +739,36 @@ void LightingRenderPass::render(const RenderContext* renderContext) // Disable clipping glDisable(GL_CLIP_DISTANCE0); */ + + // Enable depth testing + glEnable(GL_DEPTH_TEST); + glDepthMask(GL_TRUE); + glDepthFunc(GL_LEQUAL); + + // Enable backface culling + glEnable(GL_CULL_FACE); + glCullFace(GL_BACK); + + // Enable alpha blending + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + // Bind shader + lightingShader->bind(); + ShaderParameterSet* parameters = lightingShader->getParameters(); + + const Camera& camera = *(renderContext->camera); + const std::list* operations = renderContext->queue->getOperations(); + + // Render operations + for (const RenderOperation& operation: *operations) + { + const Matrix4& modelMatrix = operation.transform; + Matrix4 modelViewProjectionMatrix = camera.getViewProjection() * modelMatrix; + parameters->setValue(ShaderParameter::MODEL_VIEW_PROJECTION_MATRIX, modelViewProjectionMatrix); + glBindVertexArray(operation.vao); + glDrawElementsBaseVertex(GL_TRIANGLES, operation.triangleCount * 3, GL_UNSIGNED_INT, (void*)0, operation.indexOffset); + } } bool LightingRenderPass::loadShader(const RenderOperation& operation) diff --git a/src/render-passes.hpp b/src/render-passes.hpp index d12b75b..7918551 100644 --- a/src/render-passes.hpp +++ b/src/render-passes.hpp @@ -111,6 +111,7 @@ private: bool loadShader(const RenderOperation& operation); ShaderLoader shaderLoader; std::map shaderCache; + Shader* lightingShader; Matrix4 biasMatrix; GLuint shadowMap;