Skip to content

Commit

Permalink
Merge branch 'sarpnt' ti pull #7
Browse files Browse the repository at this point in the history
This is a merge of changes created by @SArpnt
  • Loading branch information
Tumble committed Feb 19, 2021
2 parents 00ff7ed + b59dc2d commit 02d660b
Show file tree
Hide file tree
Showing 13 changed files with 61 additions and 57 deletions.
20 changes: 9 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion engine/core/module.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* API FOR CREATING MODULES FOR CINNABAR ENGINE
* API FOR CREATING MODULES FOR CINNABAR ENGINE
*/

#pragma once
Expand Down
2 changes: 1 addition & 1 deletion engine/core/tpnt_log.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
57 changes: 34 additions & 23 deletions engine/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -45,32 +45,43 @@ 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
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);
Expand All @@ -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);
Expand Down
11 changes: 6 additions & 5 deletions engine/managers/asset_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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);
}
Expand All @@ -109,4 +110,4 @@ ce::MeshFile ce::AssetManager::getMeshFile(std::string filename) {
}
}
return file;
}
}
9 changes: 4 additions & 5 deletions engine/rendering/mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,17 @@
#include <managers/asset_manager.h>

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() {
Expand Down
2 changes: 1 addition & 1 deletion engine/rendering/render_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion engine/rendering/vertex.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion res/shaders/affine.vert
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ in vec2 aTexCoord;
out vec4 vColor;
out vec2 vTexCoord;


void main() {
vColor = aColor;
vTexCoord = aTexCoord;
Expand Down
1 change: 0 additions & 1 deletion res/shaders/basic.vert
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ in vec2 aTexCoord;
out vec4 vColor;
out vec2 vTexCoord;


void main() {
vColor = aColor;
vTexCoord = aTexCoord;
Expand Down
4 changes: 2 additions & 2 deletions res/shaders/null.frag
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
out vec4 fColor;

void main() {
fColor = vec4(1,1,1,1);
}
fColor = vec4(0, 0, 0, 1);
}
6 changes: 2 additions & 4 deletions res/shaders/null.vert
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

in vec3 aPos;


void main() {

gl_Position = vec4(aPos, 1.);
}
gl_Position = vec4(aPos, 1);
}
1 change: 0 additions & 1 deletion res/shaders/vertColor.vert
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ in vec2 aTexCoord;
out vec4 vColor;
out vec2 vTexCoord;


void main() {
vColor = aColor;
vTexCoord = aTexCoord;
Expand Down

0 comments on commit 02d660b

Please sign in to comment.