Skip to content

Commit 63a8fa3

Browse files
authored
Merge pull request #17 from KaranAhlawat/dev
Add demo tool, update root CMakeLists.txt, and update compile_and_run.sh script
2 parents eb2e9ac + d1f8d58 commit 63a8fa3

File tree

5 files changed

+63
-1
lines changed

5 files changed

+63
-1
lines changed

Diff for: CMakeLists.txt

+5
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ project(lambda)
1717

1818
option(LAMBDA_TOOLS_BUILD_SANDBOX "Sandbox for testing lambda" OFF)
1919
option(LAMBDA_TOOLS_BUILD_MATHBOX "Sandbox for testing math functions" OFF)
20+
option(LAMBDA_TOOLS_BUILD_DEMO "Basic application demonstrating lambda" OFF)
2021
option(LAMBDA_ENGINE_BUILD_TESTS "Build tests for lambda" OFF)
2122

2223
file(
@@ -121,3 +122,7 @@ endif()
121122
if (${LAMBDA_TOOLS_BUILD_MATHBOX})
122123
add_subdirectory(${CMAKE_SOURCE_DIR}/tools/mathbox)
123124
endif()
125+
126+
if (${LAMBDA_TOOLS_BUILD_DEMO})
127+
add_subdirectory(${CMAKE_SOURCE_DIR}/tools/demo)
128+
endif()

Diff for: scripts/compile_and_run.sh

+2
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ if [ "$LAMBDA_build" = "Release" ] || [ "$LAMBDA_build" = "Debug" ]; then
5757
-DDISTRIBUTION_BUILD=False \
5858
-DLAMBDA_TOOLS_BUILD_SANDBOX=ON \
5959
-DLAMBDA_TOOLS_BUILD_MATHBOX=ON \
60+
-DLAMBDA_TOOLS_BUILD_DEMO=ON \
6061
-G Ninja
6162
elif [ "$LAMBDA_build" = "Dist" ]; then
6263
lambda_log_info "Compiling a distribution build for the engine."
@@ -65,6 +66,7 @@ elif [ "$LAMBDA_build" = "Dist" ]; then
6566
-DDISTRIBUTION_BUILD=True \
6667
-DLAMBDA_TOOLS_BUILD_SANDBOX=ON \
6768
-DLAMBDA_TOOLS_BUILD_MATHBOX=ON \
69+
-DLAMBDA_TOOLS_BUILD_DEMO=ON \
6870
-G Ninja
6971
else
7072
lambda_log_fatal "You need to pass a build type in order to compile a tool."

Diff for: tools/demo/CMakeLists.txt

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
project(demo)
2+
3+
set(APP_SRC src/main.cpp)
4+
5+
add_executable(demo ${APP_SRC})
6+
7+
target_include_directories(demo PRIVATE ${LAMBDA_ENGINE_INCLUDE_DIR})
8+
target_link_libraries(demo PRIVATE lambda)

Diff for: tools/demo/src/main.cpp

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#include "Lambda/Lambda.h"
2+
#include "Lambda/core/Entrypoint.h"
3+
4+
using namespace lambda::core;
5+
using namespace lambda::lib;
6+
7+
// Our Layer to receive events and hook into the update loop within lambda. You
8+
// can make as many layers as you like!
9+
class HelloLayer : public layers::Layer {
10+
public:
11+
HelloLayer(){};
12+
// OnUpdate provides you when the last update occurred as a delta that
13+
// can be computed as whatever precision is needed.
14+
void OnUpdate(TimeStep delta) override {
15+
LAMBDA_CLIENT_INFO("{} seconds since last update.",
16+
delta.InSeconds<double>());
17+
}
18+
19+
// Provided by the Application, Events are generic pointers that are
20+
// used for handling more specific types of events using the
21+
// events::Dispacther
22+
void OnEvent(events::Event *const event) override{};
23+
24+
void OnAttach() override{};
25+
26+
void OnDetach() override{};
27+
28+
void OnImGuiRender() override{};
29+
};
30+
31+
// Our Application instance.
32+
class HelloLambda : public Application {
33+
public:
34+
// The constructor servers as your application's way of initializing the state
35+
// of your application before running.
36+
HelloLambda() : Application() {
37+
PushLayer(memory::CreateUnique<HelloLayer>());
38+
}
39+
};
40+
41+
// This function becomes your new main function. Any logic here is used before
42+
// Creating an instance of your Application (In this case, HelloLambda). Lambda
43+
// needs this function implemented and returning a valid Application instance
44+
// order to instantiate
45+
memory::Unique<Application> lambda::core::CreateApplication() {
46+
return memory::CreateUnique<HelloLambda>();
47+
}

Diff for: tools/mathbox/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ file(
1515
add_executable(mathbox ${APP_SRC})
1616

1717
target_include_directories(mathbox PRIVATE ${LAMBDA_ENGINE_INCLUDE_DIR})
18-
target_link_libraries(mathbox PRIVATE lambda)
18+
target_link_libraries(mathbox PRIVATE lambda)

0 commit comments

Comments
 (0)