diff --git a/README.md b/README.md index 4858ea63..19c84914 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,6 @@ Pull requests are welcome. For major changes, please open an issue first to disc - [ ] Simple object classes (combine assets and automatically manage render commands) - [ ] Depth manipulation - [ ] Skybox - - [x] Render triangle strips - [ ] GL lines - [ ] Sprites (i think you can do GL_POINTS and draw the images in a frag shader) - [ ] Supersampling and subsampling @@ -111,7 +110,7 @@ Pull requests are welcome. For major changes, please open an issue first to disc - [ ] GUI - [ ] Portals - [ ] VR Support - - [ ] Test on Windowsbetter + - [ ] Test on Windows - [ ] Port to Emscripten ### Physics engine (make a seperate project) @@ -141,19 +140,18 @@ Pull requests are welcome. For major changes, please open an issue first to disc - [ ] Test on Windows - [ ] Port to Emscripten - - [ ] VR Support - - [ ] Input System +### Networking (make a seperate project) + + - TODO: Make todo list + +### SceneGraph (make a seperate project) -SceneGraph (make a seperate project) - [ ] States - [ ] Scene Graph - [ ] Map management - [ ] XML based scene graph import + ### Misc + - [ ] Events System - - [ ] Make an Actual Game - # Networking (make a seperate project) - - [ ] Networking - # Platforms - - [ ] Test on Windows - - [ ] Port to Emscripten + - [ ] Make an Actual Game \ No newline at end of file diff --git a/engine/core/module.h b/engine/core/module.h index 5c0fcbd7..ba4522dc 100644 --- a/engine/core/module.h +++ b/engine/core/module.h @@ -1,5 +1,5 @@ /** - * API FOR CREATING MODULES FOR CINNABAR ENGINE + * API FOR CREATING MODULES FOR CINNABAR ENGINE */ #pragma once diff --git a/engine/core/tpnt_log.h b/engine/core/tpnt_log.h index e847a7ff..0aabbeb2 100644 --- a/engine/core/tpnt_log.h +++ b/engine/core/tpnt_log.h @@ -34,4 +34,4 @@ #define LOG_INFO(X) TPNT_LOG("INFO", X) #define LOG_WARN(X) TPNT_LOG(TPNT_LOG_WARN + "WARN" + TPNT_LOG_RESET, X) #define LOG_ERROR(X) TPNT_LOG(TPNT_LOG_ERROR + "ERROR" + TPNT_LOG_RESET, X) -#define LOG_SUCCESS(X) TPNT_LOG(TPNT_LOG_SUCCESS + "SUCCESS" + TPNT_LOG_RESET, X) +#define LOG_SUCCESS(X) TPNT_LOG(TPNT_LOG_SUCCESS + "SUCCESS" + TPNT_LOG_RESET, X) \ No newline at end of file diff --git a/engine/main.cpp b/engine/main.cpp index e27708f5..3fbce344 100644 --- a/engine/main.cpp +++ b/engine/main.cpp @@ -27,15 +27,15 @@ // clang-format off ce::Vertex cubeVerts[] = { // Position Color Texture coord - glm::vec3(-0.5f, -0.5f, -0.5f), glm::vec4(1.0f, 1.0f, 1.0f, 1.0f), glm::vec2(1.0f, 1.0f),// 0 - glm::vec3(-0.5f, 0.5f, -0.5f), glm::vec4(1.0f, 1.0f, 1.0f, 1.0f), glm::vec2(1.0f, 0.0f),// 1 - glm::vec3( 0.5f, -0.5f, -0.5f), glm::vec4(1.0f, 1.0f, 1.0f, 1.0f), glm::vec2(0.0f, 1.0f),// 2 - glm::vec3( 0.5f, 0.5f, -0.5f), glm::vec4(1.0f, 1.0f, 1.0f, 1.0f), glm::vec2(0.0f, 0.0f),// 3 + glm::vec3(-0.5f, -0.5f, -0.5f), glm::vec4(1.0f, 1.0f, 1.0f, 1.0f), glm::vec2(0.0f, 0.0f),// 0 + glm::vec3(-0.5f, -0.5f, 0.5f), glm::vec4(1.0f, 1.0f, 1.0f, 1.0f), glm::vec2(0.0f, 1.0f),// 1 + glm::vec3(-0.5f, 0.5f, -0.5f), glm::vec4(1.0f, 1.0f, 1.0f, 1.0f), glm::vec2(1.0f, 0.0f),// 4 + glm::vec3(-0.5f, 0.5f, 0.5f), glm::vec4(1.0f, 1.0f, 1.0f, 1.0f), glm::vec2(1.0f, 1.0f),// 5 - glm::vec3(-0.5f, -0.5f, 0.5f), glm::vec4(1.0f, 1.0f, 1.0f, 1.0f), glm::vec2(0.0f, 1.0f),// 4 - glm::vec3(-0.5f, 0.5f, 0.5f), glm::vec4(1.0f, 1.0f, 1.0f, 1.0f), glm::vec2(0.0f, 0.0f),// 5 - glm::vec3( 0.5f, -0.5f, 0.5f), glm::vec4(1.0f, 1.0f, 1.0f, 1.0f), glm::vec2(1.0f, 1.0f),// 6 - glm::vec3( 0.5f, 0.5f, 0.5f), glm::vec4(1.0f, 1.0f, 1.0f, 1.0f), glm::vec2(1.0f, 0.0f),// 7 + glm::vec3( 0.5f, -0.5f, -0.5f), glm::vec4(1.0f, 1.0f, 1.0f, 1.0f), glm::vec2(0.0f, 0.0f),// 6 + glm::vec3( 0.5f, -0.5f, 0.5f), glm::vec4(1.0f, 1.0f, 1.0f, 1.0f), glm::vec2(0.0f, 1.0f),// 7 + glm::vec3( 0.5f, 0.5f, -0.5f), glm::vec4(1.0f, 1.0f, 1.0f, 1.0f), glm::vec2(1.0f, 0.0f),// 2 + glm::vec3( 0.5f, 0.5f, 0.5f), glm::vec4(1.0f, 1.0f, 1.0f, 1.0f), glm::vec2(1.0f, 1.0f),// 3 }; ce::Vertex planeVerts[] = { // Position Color Texture coord @@ -45,13 +45,12 @@ ce::Vertex planeVerts[] = { glm::vec3( 1.0f, 0.0f, 1.0f), glm::vec4(0.0f, 1.0f, 0.0f, 1.0f), glm::vec2(1.0f, 1.0f),// 3 }; - /* * this is a cube - /1-3 - / 0-2 - 5-7 / - 4-6/ + /2-6 + / 0-4 + 3-7 / + 1-5/ viewed from the front, bottom face here is front */ // clang-format on @@ -59,18 +58,30 @@ unsigned cubeVertCount = sizeof(cubeVerts) / sizeof(ce::Vertex); unsigned planeVertCount = sizeof(planeVerts) / sizeof(ce::Vertex); // 7<=>5 // clang-format off -GLuint cubeIndices[] = { - 0, 1, 2, 3, // back, right, front - 6, 7, - 4, 5, - 5, 7, // reset - 7, 3, 5, 1, // top, left, bottom - 4, 0, - 6, 2, +GLuint cubeIndices [] = { + // F + 5, 7, 3, + 5, 3, 1, + // L + 1, 3, 2, + 1, 2, 0, + // B + 0, 2, 6, + 0, 6, 4, + // R + 4, 6, 7, + 4, 7, 5, + // D + 4, 5, 1, + 4, 1, 0, + // U + 7, 6, 2, + 7, 2, 3, }; GLuint planeIndices[] = { - 0, 1, 2, 3, + 0, 1, 3, + 0, 3, 2, }; // clang-format on unsigned cubeIndexCount = sizeof(cubeIndices) / sizeof(GLuint); @@ -97,7 +108,7 @@ int main(int argc, char* argv[]) { cubeMaterial->setTexture("uv-map.png"); // Plane - ce::Mesh* planeMesh = new ce::Mesh(planeVerts, planeIndexCount, planeIndices, planeVertCount); + ce::Mesh* planeMesh = new ce::Mesh(planeVerts, planeVertCount, planeIndices, planeIndexCount); ce::Transform* planePos = new ce::Transform(); ce::Material* planeMaterial = new ce::Material("vertColor"); planePos->setPosition(0.0f, -1.0f, 0.0f); diff --git a/engine/managers/asset_manager.cpp b/engine/managers/asset_manager.cpp index 5d034521..53c501d9 100644 --- a/engine/managers/asset_manager.cpp +++ b/engine/managers/asset_manager.cpp @@ -72,7 +72,8 @@ ce::TextureFile ce::AssetManager::getTextureFile(std::string filename) { textureFile.name = filename; textureFile.data = stbi_load(path.c_str(), &textureFile.width, &textureFile.height, &textureFile.channelCount, 0); - if(textureFile.data == NULL)return getTextureFile("missing.png"); + if (textureFile.data == NULL) + return getTextureFile("missing.png"); return textureFile; } @@ -91,11 +92,11 @@ ce::MeshFile ce::AssetManager::getMeshFile(std::string filename) { file.name = filename; for (int i = 0; i < 1 /*scene->mNumMeshes*/; i++) { auto mesh = *(scene->mMeshes + i); - LOG_INFO("Loading Mesh " + path + " (V:I):"+std::to_string(mesh->mNumVertices) + ":" + std::to_string(mesh->mNumFaces)); + LOG_INFO("Loading Mesh " + path + " (V:I):" + std::to_string(mesh->mNumVertices) + ":" + std::to_string(mesh->mNumFaces)); for (int i = 0; i < mesh->mNumVertices; i++) { auto position = *(mesh->mVertices + i); - auto texCoord = glm::vec2(0.f,0.f);//**(mesh->mTextureCoords + i); - auto color = glm::vec4(1.f,1.f,1.f,1.f);//**(mesh->mColors + i); + auto texCoord = glm::vec2(0.f, 0.f); //**(mesh->mTextureCoords + i); + auto color = glm::vec4(1.f, 1.f, 1.f, 1.f); //**(mesh->mColors + i); Vertex vertex = {glm::vec3(position.x, position.y, position.z), glm::vec4(color.r, color.g, color.b, color.a), glm::vec2(texCoord.x, texCoord.y)}; file.vertices.push_back(vertex); } @@ -109,4 +110,4 @@ ce::MeshFile ce::AssetManager::getMeshFile(std::string filename) { } } return file; -} +} \ No newline at end of file diff --git a/engine/rendering/mesh.cpp b/engine/rendering/mesh.cpp index 4caf2a75..4bdc62ff 100644 --- a/engine/rendering/mesh.cpp +++ b/engine/rendering/mesh.cpp @@ -5,18 +5,17 @@ #include ce::Mesh::Mesh(Vertex* vertexArray, const unsigned vertexCount, - GLuint* indexArray, const unsigned cubeIndexCount) - : m_vertexCount(vertexCount), m_indexCount(cubeIndexCount), m_VAO(0), m_VBO(0), m_EBO(0) { + GLuint* indexArray, const unsigned indexCount) + : m_vertexCount(vertexCount), m_indexCount(indexCount), m_VAO(0), m_VBO(0), m_EBO(0) { glGenVertexArrays(1, &m_VAO); glBindVertexArray(m_VAO); initVAO(vertexArray, indexArray); glBindVertexArray(0); } -ce::Mesh::Mesh(const char* name) -{ +ce::Mesh::Mesh(const char* name) { MeshFile file = ce::AssetManager::getMeshFile(name); - Mesh(&file.vertices[0],file.vertices.size(),&file.indices[0],file.indices.size()); + Mesh(&file.vertices[0], file.vertices.size(), &file.indices[0], file.indices.size()); } ce::Mesh::~Mesh() { diff --git a/engine/rendering/render_engine.cpp b/engine/rendering/render_engine.cpp index 924aa59b..9e427ae7 100644 --- a/engine/rendering/render_engine.cpp +++ b/engine/rendering/render_engine.cpp @@ -6,7 +6,7 @@ void ce::RenderEngine::clear() { } void ce::RenderEngine::render(unsigned count) { - glDrawElements(GL_TRIANGLE_STRIP, count, GL_UNSIGNED_INT, 0); + glDrawElements(GL_TRIANGLES, count, GL_UNSIGNED_INT, 0); } void ce::RenderEngine::bind(RenderCommand command) { diff --git a/engine/rendering/vertex.h b/engine/rendering/vertex.h index 1f2c6acb..4635855c 100644 --- a/engine/rendering/vertex.h +++ b/engine/rendering/vertex.h @@ -5,7 +5,7 @@ using namespace glm; namespace ce { - struct Vertex { + struct Vertex { // TODO: just remove this class entirely, vertexes don't and shouldn't work like this vec3 position; vec4 color; vec2 texCoord; diff --git a/res/shaders/affine.vert b/res/shaders/affine.vert index 82c77dab..252502ef 100644 --- a/res/shaders/affine.vert +++ b/res/shaders/affine.vert @@ -15,7 +15,6 @@ in vec2 aTexCoord; out vec4 vColor; out vec2 vTexCoord; - void main() { vColor = aColor; vTexCoord = aTexCoord; diff --git a/res/shaders/basic.vert b/res/shaders/basic.vert index f1947418..2cbeac98 100644 --- a/res/shaders/basic.vert +++ b/res/shaders/basic.vert @@ -15,7 +15,6 @@ in vec2 aTexCoord; out vec4 vColor; out vec2 vTexCoord; - void main() { vColor = aColor; vTexCoord = aTexCoord; diff --git a/res/shaders/null.frag b/res/shaders/null.frag index e2be797b..39199c80 100644 --- a/res/shaders/null.frag +++ b/res/shaders/null.frag @@ -3,5 +3,5 @@ out vec4 fColor; void main() { - fColor = vec4(1,1,1,1); -} + fColor = vec4(0, 0, 0, 1); +} \ No newline at end of file diff --git a/res/shaders/null.vert b/res/shaders/null.vert index 497f4a4c..5aa0acf1 100644 --- a/res/shaders/null.vert +++ b/res/shaders/null.vert @@ -2,8 +2,6 @@ in vec3 aPos; - void main() { - - gl_Position = vec4(aPos, 1.); -} + gl_Position = vec4(aPos, 1); +} \ No newline at end of file diff --git a/res/shaders/vertColor.vert b/res/shaders/vertColor.vert index f1947418..2cbeac98 100644 --- a/res/shaders/vertColor.vert +++ b/res/shaders/vertColor.vert @@ -15,7 +15,6 @@ in vec2 aTexCoord; out vec4 vColor; out vec2 vTexCoord; - void main() { vColor = aColor; vTexCoord = aTexCoord;