Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fork pull #3

Merged
merged 3 commits into from
Feb 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .clang-format
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
BasedOnStyle: LLVM

ColumnLimit: 0
IndentWidth: '3'
TabWidth: '3'
AccessModifierOffset: '-2'
Expand All @@ -10,11 +11,14 @@ UseTab: ForContinuationAndIndentation
IndentCaseLabels: 'true'
#IndentPPDirectives: BeforeHash
NamespaceIndentation: All
#SpacesInLineCommentPrefix: 1 # clang 13 only
#SortIncludes # clang 13 only, setting needs to be figured out

DerivePointerAlignment: 'false'
PointerAlignment: Left

BreakBeforeBraces: Attach
# https://reviews.llvm.org/D33029 add this when it gets implemented
BreakAfterJavaFieldAnnotations: 'true'
BreakBeforeBinaryOperators: None

Expand All @@ -27,4 +31,4 @@ AllowShortFunctionsOnASingleLine: Inline
AllowShortLoopsOnASingleLine: 'false'

AlignAfterOpenBracket: DontAlign
FixNamespaceComments: false
FixNamespaceComments: false
33 changes: 16 additions & 17 deletions engine/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,27 +73,26 @@ int main(int argc, char* argv[]) {
LOG_INFO("Hello World");

ce::Time* time = new ce::Time();

ce::Window* window = new ce::Window("Cinnabar");
ce::RenderingEngine* renderingEngine = new ce::RenderingEngine();
renderingEngine->setFOV(45.0f);
renderingEngine->setFOV(75.0f);
renderingEngine->setSize(window->getWindowSize());


ce::Transform* transform = new ce::Transform();
ce::Mesh* mesh = new ce::Mesh(vertices, vertexCount, indices, indexCount);
ce::Material* material = new ce::Material(new ce::Shader("basic"));
material->setTexture(new ce::Texture("uv-map.png"));
mesh->sendToShader(material->getShader());

glm::mat4 proj = glm::perspective(
glm::radians(45.0f), window->getAspectRatio(), 0.1f, 100.0f);
glm::radians(75.0f), window->getAspectRatio(), 0.1f, 100.0f);

float mouseSensitivity = 0.1f;
ce::Camera* camera = new ce::Camera();
// Seperate so i can put in a player class later
glm::vec3 cameraVelocity(0.0f);
camera->getTransform()->setPosition(0.0f, 0.0f, 3.0f);
camera->getTransform()->setPosition(0.0f, 0.0f, 1.5f);
camera->getTransform()->setYaw(-90.0f);
/*
* Game Loop
Expand Down Expand Up @@ -159,7 +158,7 @@ int main(int argc, char* argv[]) {
glm::vec2 size = window->getWindowSize();
glViewport(0, 0, size.x, size.y);
proj = glm::perspective(
glm::radians(45.0f), window->getAspectRatio(), 0.1f, 100.0f);
glm::radians(75.0f), window->getAspectRatio(), 0.1f, 100.0f);
break;
}
}
Expand All @@ -168,29 +167,29 @@ int main(int argc, char* argv[]) {
transform->roll(25.0f * time->getDeltaTime());
transform->yaw(50.0f * time->getDeltaTime());
transform->pitch(100.0f * time->getDeltaTime());

// TODO: <PUT THIS IN THE RENDER ENGINE>
material->update();


// Camera
glm::vec3
cameraFront = camera->getTransform()->getForward(),
cameraRight = camera->getRight(),
cameraUp = ce::Transform::GetGlobalUp();
camera->getTransform()->translate((cameraFront * cameraVelocity.z)+(cameraRight * cameraVelocity.x)+(cameraUp * cameraVelocity.y));


camera->getTransform()->translate(
(cameraFront * cameraVelocity.z) +
(cameraRight * cameraVelocity.x) +
(cameraUp * cameraVelocity.y));

transform->sendToShader(material->getShader());
material->getShader()->setMat4("transform.proj",proj);
material->getShader()->setMat4("transform.proj", proj);
camera->sendToShader(material->getShader());



// TODO: </PUT THIS IN THE RENDER ENGINE>

/* Render */
renderingEngine->registerCommand({transform,material,mesh,mesh->GetIndexCount()});
renderingEngine->registerCommand({transform, material, mesh, mesh->GetIndexCount()});

renderingEngine->render();

window->swapBuffers();
Expand Down