Skip to content

Commit 54f9139

Browse files
committed
Cube example & Fix build scripts
1 parent e5f4810 commit 54f9139

File tree

18 files changed

+77
-59
lines changed

18 files changed

+77
-59
lines changed

.editorconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,11 @@ end_of_line = lf
1212
charset = utf-8
1313
trim_trailing_whitespace = true
1414
insert_final_newline = true
15+
16+
[*.md]
17+
indent_style = space
18+
indent_size = 3
19+
20+
[*.py]
21+
indent_style = space
22+
indent_size = 4

.justfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ default:
1313
@just --list
1414

1515
# Run a package
16-
run *args='hello':
16+
run *args='f22':
1717
./target/release/{{args}}
1818

1919
# Build the project(Release or Debug)
@@ -33,7 +33,7 @@ clean:
3333
# Run code quality tools
3434
test:
3535
echo "Running tests..."
36-
./target/release/kiwicpp_tests
36+
./target/release/test_libray
3737

3838
# Format the project
3939
format:

.vscode/settings.json

Lines changed: 0 additions & 11 deletions
This file was deleted.

Dockerfile

Lines changed: 0 additions & 32 deletions
This file was deleted.

examples/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
add_subdirectory(f22)
21
add_subdirectory(bunny)
2+
add_subdirectory(cube)
3+
add_subdirectory(f22)

examples/bunny/bunny.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@
2424
int main(int argc, char** argv) {
2525
// Initialization of display
2626
#ifndef BENCHMARK_MODE
27-
kiwigl::Display display;
27+
kiwigl::Display display(kiwigl::Vector3D(0, 0, -0.25), kiwigl::Vector3D(M_PI, M_PI, 0));
2828
#else
2929
kiwigl::Display display(10000);
3030
#endif
3131
// Load the Stanford bunny mesh
32-
display.loadMesh("../assets/bunny.obj");
32+
display.loadMesh("./assets/bunny.obj");
3333

3434
// Main graphics loop
3535
// Loop until window close button is pressed

examples/cube/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
set(EXECUTABLE_NAME cube)
2+
3+
add_executable(${EXECUTABLE_NAME} ${EXECUTABLE_NAME}.cpp)
4+
target_link_libraries(${EXECUTABLE_NAME} PRIVATE ${PROJECT_NAME})
5+
6+
# Setting our output directory
7+
set_target_properties(${EXECUTABLE_NAME} PROPERTIES
8+
RUNTIME_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/target/release/"
9+
OUTPUT_NAME ${EXECUTABLE_NAME}
10+
)

examples/cube/cube.cpp

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#include <stddef.h>
2+
#include <stdio.h>
3+
4+
#include <iostream>
5+
#include <kiwigl/kiwigl.hpp>
6+
7+
#ifdef USE_METAL
8+
#include <cassert>
9+
10+
#define NS_PRIVATE_IMPLEMENTATION
11+
#define MTL_PRIVATE_IMPLEMENTATION
12+
#define MTK_PRIVATE_IMPLEMENTATION
13+
#define CA_PRIVATE_IMPLEMENTATION
14+
#include <simd/simd.h>
15+
16+
#include <AppKit/AppKit.hpp>
17+
#include <Metal/Metal.hpp>
18+
#include <MetalKit/MetalKit.hpp>
19+
#endif
20+
21+
//------------------------------------------------------------------------------------
22+
// Program main entry point
23+
//------------------------------------------------------------------------------------
24+
int main(int argc, char** argv) {
25+
// Initialization of display
26+
#ifndef BENCHMARK_MODE
27+
kiwigl::Display display;
28+
#else
29+
kiwigl::Display display(10000);
30+
#endif
31+
// Load the Cube mesh
32+
display.loadMesh("./assets/cube.obj");
33+
34+
// Main graphics loop
35+
// Loop until window close button is pressed
36+
while (!display.shouldClose()) {
37+
#ifdef BENCHMARK_MODE
38+
display.update();
39+
#else
40+
display.processInput();
41+
display.update();
42+
display.render();
43+
#endif
44+
}
45+
return 0;
46+
}

examples/f22/f22.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ int main(int argc, char** argv) {
2929
kiwigl::Display display(10000);
3030
#endif
3131
// Load the F-22 mesh
32-
display.loadMesh("../assets/f22.obj");
32+
display.loadMesh("./assets/f22.obj");
3333

3434
// Main graphics loop
3535
// Loop until window close button is pressed

include/kiwigl/graphics/display.hpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,14 @@ class Display {
6363
public:
6464
#ifndef BENCHMARK_MODE
6565
// Constructor to initialize memory
66-
Display() {
66+
Display(const Vector3D& cameraPosition = Vector3D(0, 0, -5), const Vector3D& cameraRotation = Vector3D(0, 0, 0)) {
6767
#else
68-
Display(uint32_t numOfFrames) {
68+
Display(uint32_t numOfFrames, const Vector3D& cameraPosition = Vector3D(0, 0, -5),
69+
const Vector3D& cameraRotation = Vector3D(0, 0, 0)) {
6970
#endif
7071
// Initialize the camera
71-
camera = Vector3D(0, 0, -5);
72-
rotation = Vector3D(0, 0, 0);
72+
camera = cameraPosition;
73+
rotation = cameraRotation;
7374
rotationSpeed = Vector3D(0, 0, 0);
7475
#ifndef BENCHMARK_MODE
7576
fullScreen = true;

0 commit comments

Comments
 (0)