Skip to content

Commit

Permalink
add ref and scope
Browse files Browse the repository at this point in the history
  • Loading branch information
qiyuewuyi2333 committed Aug 16, 2024
1 parent 0777c68 commit a8fa655
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -360,4 +360,4 @@ MigrationBackup/
.ionide/

# Fody - auto-generated XML schema
FodyWeavers.xsd
FodyWeavers.xsd
5 changes: 2 additions & 3 deletions Huan/include/Huan/Application.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include "Renderer/Renderer.h"
#include "util/TimeStep.h"


namespace Huan
{
std::unordered_map<int, std::string> createKeycodeMap();
Expand All @@ -40,10 +39,10 @@ class HUAN_API Application
static Application* instance;

private:
std::unique_ptr<Window> myWindow;
Scope<Window> myWindow;
LayerStack myLayerStack;
bool isRunning = true;
float myLastFrameTime = 0.0f;
float myLastFrameTime = 0.0f;
};
inline Application* createApplication();

Expand Down
11 changes: 11 additions & 0 deletions Huan/include/Huan/Core.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,14 @@
#endif

#define BIND_EVENT_FUNC(x) std::bind(&x, this, std::placeholders::_1)

namespace Huan
{

template<typename T>
using Scope = std::unique_ptr<T>;

template<typename T>
using Ref = std::shared_ptr<T>;

}
10 changes: 5 additions & 5 deletions Sandbox/include/ExampleLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ class ExampleLayer : public Huan::Layer
void onEvent(Huan::Event& event) override;

private:
std::unique_ptr<Huan::Scene> myScene1;
std::unique_ptr<Huan::Scene> myScene2;
std::unique_ptr<Huan::Scene> myScene3;
std::unique_ptr<Huan::Shader> shader;
std::shared_ptr<Huan::Camera> myCamera;
Huan::Scope<Huan::Scene> myScene1;
Huan::Scope<Huan::Scene> myScene2;
Huan::Scope<Huan::Scene> myScene3;
Huan::Scope<Huan::Shader> shader;
Huan::Ref<Huan::Camera> myCamera;
Huan::Renderer& myRenderer;

};
2 changes: 1 addition & 1 deletion third_party/imgui
Submodule imgui updated 1 files
+1 −12 CMakeLists.txt

0 comments on commit a8fa655

Please sign in to comment.