Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
1ab2377f8e
|
|||
|
45c9e5180f
|
|||
|
19ebe7b64f
|
3
.gitattributes
vendored
3
.gitattributes
vendored
@@ -1,3 +0,0 @@
|
|||||||
*.obj filter=lfs diff=lfs merge=lfs -text
|
|
||||||
*.png filter=lfs diff=lfs merge=lfs -text
|
|
||||||
*.glb filter=lfs diff=lfs merge=lfs -text
|
|
||||||
BIN
assets/turret.obj
LFS
BIN
assets/turret.obj
LFS
Binary file not shown.
BIN
assets/turret_diffuse.png
LFS
BIN
assets/turret_diffuse.png
LFS
Binary file not shown.
1721
assets/zombie.fbx
Normal file
1721
assets/zombie.fbx
Normal file
File diff suppressed because it is too large
Load Diff
BIN
assets/zombie.glb
LFS
BIN
assets/zombie.glb
LFS
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 128 B After Width: | Height: | Size: 994 B |
@@ -16,7 +16,7 @@ class GameState : public ClientState {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
GameState(Client& a_Client, const game::WorldPtr& a_World, std::uint64_t a_StepTime, const std::vector<protocol::LockStep> a_FirstSteps);
|
GameState(Client& a_Client, const game::WorldPtr& a_World, std::uint64_t a_StepTime, const std::vector<protocol::LockStep> a_FirstSteps);
|
||||||
~GameState();
|
~GameState() {}
|
||||||
|
|
||||||
virtual void Update(float a_Delta) override;
|
virtual void Update(float a_Delta) override;
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
namespace td {
|
namespace td {
|
||||||
|
|
||||||
// static constexpr float PI = 3.141592653f;
|
static constexpr float PI = 3.141592653f;
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct Vec2 {
|
struct Vec2 {
|
||||||
|
|||||||
@@ -1,37 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
namespace td {
|
|
||||||
|
|
||||||
class EventDispatcher;
|
|
||||||
|
|
||||||
class Event {
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
struct WindowResizeEvent {
|
|
||||||
int m_Width;
|
|
||||||
int m_Height;
|
|
||||||
};
|
|
||||||
|
|
||||||
class EventDispatcher {
|
|
||||||
public:
|
|
||||||
EventDispatcher(const Event& event);
|
|
||||||
|
|
||||||
template<typename E>
|
|
||||||
void Dispatch();
|
|
||||||
};
|
|
||||||
|
|
||||||
// template<typename Event>
|
|
||||||
// class ConcreteEvent : public Event {
|
|
||||||
// public:
|
|
||||||
// void Accept(EventDispatcher& a_Dispatcher) {
|
|
||||||
// a_Dispatcher.Handle(*this);
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
|
|
||||||
void OnEvent(const Event& event) {
|
|
||||||
EventDispatcher dispatcher(event);
|
|
||||||
dispatcher.Dispatch<WindowResizeEvent>();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include <SDL3/SDL_keycode.h>
|
||||||
|
#include <SDL3/SDL_video.h>
|
||||||
#include <td/common/StateMachine.h>
|
#include <td/common/StateMachine.h>
|
||||||
#include <td/misc/Signal.h>
|
#include <td/misc/Signal.h>
|
||||||
|
|
||||||
@@ -9,15 +11,17 @@ namespace td {
|
|||||||
|
|
||||||
class Display : public StateMachine<Display, void, float> {
|
class Display : public StateMachine<Display, void, float> {
|
||||||
private:
|
private:
|
||||||
int m_LastWidth;
|
SDL_Window* m_Window;
|
||||||
int m_LastHeight;
|
SDL_GLContext m_GLContext;
|
||||||
|
|
||||||
|
int m_LastWidth, m_LastHeight;
|
||||||
float m_AspectRatio;
|
float m_AspectRatio;
|
||||||
|
|
||||||
bool m_ShouldClose;
|
bool m_ShouldClose;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
utils::Signal<float> OnAspectRatioChange;
|
utils::Signal<float> OnAspectRatioChange;
|
||||||
utils::Signal<int> OnKeyDown;
|
utils::Signal<SDL_Keycode> OnKeyDown;
|
||||||
|
|
||||||
Display(int a_Width, int a_Height, const std::string& a_Title);
|
Display(int a_Width, int a_Height, const std::string& a_Title);
|
||||||
~Display();
|
~Display();
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ class DisplayState : public Display::State, private utils::SlotGuard {
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void OnAspectRatioChange(float a_Ratio) {}
|
virtual void OnAspectRatioChange(float a_Ratio) {}
|
||||||
virtual void OnKeyDown(int a_Key) {}
|
virtual void OnKeyDown(SDL_Keycode a_Key) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace td
|
} // namespace td
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ namespace td {
|
|||||||
class DebugWorldState : public DisplayState {
|
class DebugWorldState : public DisplayState {
|
||||||
private:
|
private:
|
||||||
render::RenderPipeline m_Renderer;
|
render::RenderPipeline m_Renderer;
|
||||||
Camera m_Camera;
|
render::Camera m_Camera;
|
||||||
std::unique_ptr<server::Server> m_Server;
|
std::unique_ptr<server::Server> m_Server;
|
||||||
std::unique_ptr<client::Client> m_Client;
|
std::unique_ptr<client::Client> m_Client;
|
||||||
client::GameState* m_ClientState;
|
client::GameState* m_ClientState;
|
||||||
@@ -31,7 +31,7 @@ class DebugWorldState : public DisplayState {
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void OnAspectRatioChange(float a_Ratio) override;
|
virtual void OnAspectRatioChange(float a_Ratio) override;
|
||||||
virtual void OnKeyDown(int a_Key) override;
|
virtual void OnKeyDown(SDL_Keycode a_Key) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace td
|
} // namespace td
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ class MainMenuState : public DisplayState, public MainMenuStateStack {
|
|||||||
void RenderBackButton();
|
void RenderBackButton();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void OnKeyDown(int a_Key) override;
|
virtual void OnKeyDown(SDL_Keycode a_Key) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace td
|
} // namespace td
|
||||||
|
|||||||
@@ -79,10 +79,9 @@ class Mob : public sp::MessageBase<MobType, MobHandler> {
|
|||||||
Vec2fp m_Position;
|
Vec2fp m_Position;
|
||||||
Direction m_Direction;
|
Direction m_Direction;
|
||||||
std::vector<EffectDuration> m_Effects;
|
std::vector<EffectDuration> m_Effects;
|
||||||
std::shared_ptr<Tower> m_LastDamage; // the last tower that damaged the mob
|
const Tower* m_LastDamage; // the last tower that damaged the mob
|
||||||
float m_HitCooldown;
|
float m_HitCooldown;
|
||||||
std::shared_ptr<TeamCastle> m_CastleTarget;
|
TeamCastle* m_CastleTarget;
|
||||||
bool m_HasReachedCastle = false;
|
|
||||||
// utils::CooldownTimer m_AttackTimer;
|
// utils::CooldownTimer m_AttackTimer;
|
||||||
|
|
||||||
MobPtr m_Next;
|
MobPtr m_Next;
|
||||||
|
|||||||
@@ -25,12 +25,12 @@ enum class TileType : std::uint8_t {
|
|||||||
Ice,*/
|
Ice,*/
|
||||||
};
|
};
|
||||||
|
|
||||||
// static constexpr Color BLACK(0, 0, 0);
|
static constexpr Color BLACK{0, 0, 0};
|
||||||
// static constexpr Color WHITE(255, 255, 255);
|
static constexpr Color WHITE{255, 255, 255};
|
||||||
|
|
||||||
// static constexpr Color RED(255, 0, 0);
|
static constexpr Color RED{255, 0, 0};
|
||||||
// static constexpr Color GREEN(0, 255, 0);
|
static constexpr Color GREEN{0, 255, 0};
|
||||||
// static constexpr Color BLUE(0, 0, 255);
|
static constexpr Color BLUE{0, 0, 255};
|
||||||
|
|
||||||
class TileHandler;
|
class TileHandler;
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ class SignalRaw : private NonCopyable {
|
|||||||
|
|
||||||
void operator()(Args... args) const {
|
void operator()(Args... args) const {
|
||||||
for (const CallBack& callback : m_Callbacks) {
|
for (const CallBack& callback : m_Callbacks) {
|
||||||
callback->operator()(std::forward<Args>(args)...);
|
callback->operator()(args...);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -64,9 +64,9 @@ class Signal {
|
|||||||
m_Signal->Connect(std::make_shared<CallBackRaw>(a_Callback));
|
m_Signal->Connect(std::make_shared<CallBackRaw>(a_Callback));
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] std::shared_ptr<ConnectionGuard> ConnectSafe(const CallBack& a_Callback) {
|
[[nodiscard]] std::unique_ptr<ConnectionGuard> ConnectSafe(const CallBack& a_Callback) {
|
||||||
m_Signal->Connect(a_Callback);
|
m_Signal->Connect(a_Callback);
|
||||||
return std::make_shared<ConnectionGuard>(*this, a_Callback);
|
return std::make_unique<ConnectionGuard>(*this, a_Callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Disconnect(const CallBack& a_Callback) {
|
void Disconnect(const CallBack& a_Callback) {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ namespace utils {
|
|||||||
*/
|
*/
|
||||||
class SlotGuard {
|
class SlotGuard {
|
||||||
private:
|
private:
|
||||||
std::vector<std::shared_ptr<Connection>> m_Connections;
|
std::vector<std::unique_ptr<Connection>> m_Connections;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
@@ -21,7 +21,7 @@ class SlotGuard {
|
|||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
void Connect(Signal<Args...> a_Signal, const typename Signal<Args...>::CallBack::element_type& a_Callback) {
|
void Connect(Signal<Args...> a_Signal, const typename Signal<Args...>::CallBack::element_type& a_Callback) {
|
||||||
auto ptr = std::make_shared<typename Signal<Args...>::CallBack::element_type>(a_Callback);
|
auto ptr = std::make_shared<typename Signal<Args...>::CallBack::element_type>(a_Callback);
|
||||||
m_Connections.emplace_back(a_Signal.ConnectSafe(ptr));
|
m_Connections.push_back(a_Signal.ConnectSafe(ptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Disconnect() {
|
void Disconnect() {
|
||||||
|
|||||||
42
include/td/render/Camera.h
Normal file
42
include/td/render/Camera.h
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <td/Maths.h>
|
||||||
|
#include <td/misc/Signal.h>
|
||||||
|
|
||||||
|
namespace td {
|
||||||
|
namespace render {
|
||||||
|
|
||||||
|
class Camera {
|
||||||
|
private:
|
||||||
|
Mat4f m_ViewMatrix;
|
||||||
|
Mat4f m_ProjectionMatrix;
|
||||||
|
Mat4f m_InvViewMatrix;
|
||||||
|
Mat4f m_InvProjectionMatrix;
|
||||||
|
|
||||||
|
float m_CamDistance = 25.0f;
|
||||||
|
Vec3f m_CamPos{0, m_CamDistance, 0};
|
||||||
|
Vec2f m_CamLook{};
|
||||||
|
|
||||||
|
float m_Yaw = -PI / 2.0f;
|
||||||
|
float m_Pitch = -PI / 2.0f + 0.0000001f;
|
||||||
|
|
||||||
|
public:
|
||||||
|
utils::Signal<> OnPerspectiveChange;
|
||||||
|
utils::Signal<> OnViewChange;
|
||||||
|
|
||||||
|
const Mat4f& GetViewMatrix() const {
|
||||||
|
return m_ViewMatrix;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Mat4f& GetProjectionMatrix() const {
|
||||||
|
return m_ProjectionMatrix;
|
||||||
|
}
|
||||||
|
|
||||||
|
void UpdatePerspective(float a_AspectRatio);
|
||||||
|
|
||||||
|
void SetCamPos(const Vec3f& a_NewPos);
|
||||||
|
const Vec3f& GetCamPos() const;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace render
|
||||||
|
} // namespace td
|
||||||
8
include/td/render/OpenGL.h
Normal file
8
include/td/render/OpenGL.h
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef TD_GL_LOADER_GLEW
|
||||||
|
#include <GL/glew.h>
|
||||||
|
#else
|
||||||
|
#include <glbinding/gl/gl.h>
|
||||||
|
using namespace gl;
|
||||||
|
#endif
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
// extern "C" {
|
|
||||||
// #include <raygui.h>
|
|
||||||
// }
|
|
||||||
|
|
||||||
extern "C" {
|
|
||||||
#include <rlImGui.h>
|
|
||||||
}
|
|
||||||
|
|
||||||
#include <imgui.h>
|
|
||||||
@@ -1,10 +1,11 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <raylib-cpp/Camera3D.hpp>
|
#include <td/misc/SlotGuard.h>
|
||||||
|
#include <td/render/Camera.h>
|
||||||
|
#include <td/render/loader/FbxLoader.h>
|
||||||
#include <td/render/loader/GLLoader.h>
|
#include <td/render/loader/GLLoader.h>
|
||||||
#include <td/render/shader/CameraShaderProgram.h>
|
#include <td/render/shader/CameraShaderProgram.h>
|
||||||
#include <td/misc/SlotGuard.h>
|
|
||||||
|
|
||||||
namespace td {
|
namespace td {
|
||||||
namespace render {
|
namespace render {
|
||||||
@@ -15,16 +16,17 @@ class BasicRenderer {
|
|||||||
virtual ~BasicRenderer() {}
|
virtual ~BasicRenderer() {}
|
||||||
|
|
||||||
void Render(const GL::VertexArray& a_Vao);
|
void Render(const GL::VertexArray& a_Vao);
|
||||||
|
void Render(const Model& a_Model);
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename TShader>
|
template <typename TShader>
|
||||||
class Renderer : public BasicRenderer, private utils::SlotGuard {
|
class Renderer : public BasicRenderer, private utils::SlotGuard {
|
||||||
protected:
|
protected:
|
||||||
std::unique_ptr<TShader> m_Shader;
|
std::unique_ptr<TShader> m_Shader;
|
||||||
raylib::Camera& m_Camera;
|
Camera& m_Camera;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Renderer(raylib::Camera& a_Camera);
|
Renderer(Camera& a_Camera);
|
||||||
virtual ~Renderer() {}
|
virtual ~Renderer() {}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
@@ -42,7 +44,7 @@ class RenderPipeline {
|
|||||||
virtual ~RenderPipeline() {}
|
virtual ~RenderPipeline() {}
|
||||||
|
|
||||||
template <typename T, typename... Args>
|
template <typename T, typename... Args>
|
||||||
T& AddRenderer(Args... args) {
|
T& AddRenderer(Args&&... args) {
|
||||||
auto ptr = std::make_unique<T>(args...);
|
auto ptr = std::make_unique<T>(args...);
|
||||||
auto rawPtr = ptr.get();
|
auto rawPtr = ptr.get();
|
||||||
m_Renderers.push_back(std::move(ptr));
|
m_Renderers.push_back(std::move(ptr));
|
||||||
@@ -65,16 +67,16 @@ class RenderPipeline {
|
|||||||
|
|
||||||
|
|
||||||
template <typename TShader>
|
template <typename TShader>
|
||||||
Renderer<TShader>::Renderer(raylib::Camera& a_Camera) : m_Shader(std::make_unique<TShader>()), m_Camera(a_Camera) {
|
Renderer<TShader>::Renderer(Camera& a_Camera) : m_Shader(std::make_unique<TShader>()), m_Camera(a_Camera) {
|
||||||
// Connect(a_Camera.OnPerspectiveChange, [this](){
|
Connect(a_Camera.OnPerspectiveChange, [this]() {
|
||||||
// // m_Shader->Start();
|
m_Shader->Start();
|
||||||
// m_Shader->SetProjectionMatrix(m_Camera.GetProjectionMatrix());
|
m_Shader->SetProjectionMatrix(m_Camera.GetProjectionMatrix());
|
||||||
// });
|
});
|
||||||
|
|
||||||
// Connect(a_Camera.OnViewChange, [this]() {
|
Connect(a_Camera.OnViewChange, [this]() {
|
||||||
// // m_Shader->Start();
|
m_Shader->Start();
|
||||||
// m_Shader->SetViewMatrix(m_Camera.GetViewMatrix());
|
m_Shader->SetViewMatrix(m_Camera.GetViewMatrix());
|
||||||
// });
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace render
|
} // namespace render
|
||||||
|
|||||||
19
include/td/render/loader/FbxLoader.h
Normal file
19
include/td/render/loader/FbxLoader.h
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <td/render/loader/GLLoader.h>
|
||||||
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
namespace td {
|
||||||
|
|
||||||
|
struct Model {
|
||||||
|
std::vector<std::unique_ptr<GL::VertexArray>> m_Vaos;
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace ModelLoader {
|
||||||
|
|
||||||
|
Model LoadModel(const std::string& fileName);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
31
include/td/render/loader/TextureLoader.h
Normal file
31
include/td/render/loader/TextureLoader.h
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <sp/common/NonCopyable.h>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace td {
|
||||||
|
namespace GL {
|
||||||
|
|
||||||
|
class Texture : private sp::NonCopyable {
|
||||||
|
public:
|
||||||
|
Texture(const char* a_Data, int a_Width, int a_Height, int a_Comp);
|
||||||
|
Texture(Texture&& a_Other);
|
||||||
|
|
||||||
|
~Texture();
|
||||||
|
|
||||||
|
void Bind() const;
|
||||||
|
void Unbind() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
unsigned int m_ID;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace GL
|
||||||
|
|
||||||
|
namespace TextureLoader {
|
||||||
|
|
||||||
|
GL::Texture LoadTexture(const std::string& fileName);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace td
|
||||||
@@ -1,14 +1,22 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <td/game/World.h>
|
#include <td/game/World.h>
|
||||||
#include <raylib-cpp/Mesh.hpp>
|
#include <td/render/loader/GLLoader.h>
|
||||||
|
|
||||||
namespace td {
|
namespace td {
|
||||||
namespace render {
|
namespace render {
|
||||||
|
|
||||||
namespace WorldLoader {
|
namespace WorldLoader {
|
||||||
|
|
||||||
Mesh LoadWorldModel(const td::game::World* world);
|
struct RenderData {
|
||||||
|
std::vector<float> positions;
|
||||||
|
std::vector<float> colors;
|
||||||
|
};
|
||||||
|
|
||||||
|
GL::VertexArray LoadMobModel();
|
||||||
|
GL::VertexArray LoadWorldModel(const td::game::World* world);
|
||||||
|
GL::VertexArray LoadTileSelectModel();
|
||||||
|
RenderData LoadTowerModel(const game::TowerPtr& tower);
|
||||||
|
|
||||||
} // namespace WorldLoader
|
} // namespace WorldLoader
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <td/render/loader/TextureLoader.h>
|
||||||
|
#include <td/render/loader/FbxLoader.h>
|
||||||
#include <td/render/Renderer.h>
|
#include <td/render/Renderer.h>
|
||||||
#include <td/render/shader/EntityShader.h>
|
#include <td/render/shader/EntityShader.h>
|
||||||
#include <td/game/World.h>
|
#include <td/game/World.h>
|
||||||
#include <raylib-cpp/Model.hpp>
|
|
||||||
|
|
||||||
namespace td {
|
namespace td {
|
||||||
namespace render {
|
namespace render {
|
||||||
@@ -11,11 +12,11 @@ namespace render {
|
|||||||
class EntityRenderer : public Renderer<shader::EntityShader> {
|
class EntityRenderer : public Renderer<shader::EntityShader> {
|
||||||
private:
|
private:
|
||||||
game::WorldPtr m_World;
|
game::WorldPtr m_World;
|
||||||
raylib::Model m_ZombieModel;
|
Model m_EntityModel;
|
||||||
Texture2D m_ZombieTexture;
|
std::unique_ptr<GL::Texture> m_EntityTexture;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
EntityRenderer(raylib::Camera& a_Camera, const game::WorldPtr& a_World);
|
EntityRenderer(Camera& a_Camera, const game::WorldPtr& a_World);
|
||||||
virtual ~EntityRenderer();
|
virtual ~EntityRenderer();
|
||||||
|
|
||||||
virtual void Render(float a_Lerp) override;
|
virtual void Render(float a_Lerp) override;
|
||||||
|
|||||||
@@ -3,8 +3,6 @@
|
|||||||
#include <td/render/Renderer.h>
|
#include <td/render/Renderer.h>
|
||||||
#include <td/render/shader/EntityShader.h>
|
#include <td/render/shader/EntityShader.h>
|
||||||
#include <td/game/World.h>
|
#include <td/game/World.h>
|
||||||
#include <raylib-cpp/Model.hpp>
|
|
||||||
#include <raylib-cpp/Texture.hpp>
|
|
||||||
|
|
||||||
namespace td {
|
namespace td {
|
||||||
namespace render {
|
namespace render {
|
||||||
@@ -12,11 +10,10 @@ namespace render {
|
|||||||
class TowerRenderer : public Renderer<shader::EntityShader> {
|
class TowerRenderer : public Renderer<shader::EntityShader> {
|
||||||
private:
|
private:
|
||||||
game::WorldPtr m_World;
|
game::WorldPtr m_World;
|
||||||
raylib::Model m_TowerModel;
|
std::unique_ptr<GL::VertexArray> m_EntityVao;
|
||||||
raylib::Texture2D m_TowerTexture;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TowerRenderer(raylib::Camera& a_Camera, const game::WorldPtr& a_World);
|
TowerRenderer(Camera& a_Camera, const game::WorldPtr& a_World);
|
||||||
virtual ~TowerRenderer();
|
virtual ~TowerRenderer();
|
||||||
|
|
||||||
virtual void Render(float a_Lerp) override;
|
virtual void Render(float a_Lerp) override;
|
||||||
|
|||||||
@@ -4,17 +4,16 @@
|
|||||||
#include <td/render/Renderer.h>
|
#include <td/render/Renderer.h>
|
||||||
#include <td/render/loader/GLLoader.h>
|
#include <td/render/loader/GLLoader.h>
|
||||||
#include <td/render/shader/WorldShader.h>
|
#include <td/render/shader/WorldShader.h>
|
||||||
#include <raylib-cpp/Model.hpp>
|
|
||||||
|
|
||||||
namespace td {
|
namespace td {
|
||||||
namespace render {
|
namespace render {
|
||||||
|
|
||||||
class WorldRenderer : public Renderer<shader::WorldShader> {
|
class WorldRenderer : public Renderer<shader::WorldShader> {
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<raylib::Model> m_WorldModel;
|
std::unique_ptr<GL::VertexArray> m_WorldVao;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
WorldRenderer(raylib::Camera& a_Camera, const game::WorldPtr& a_World);
|
WorldRenderer(Camera& a_Camera, const game::WorldPtr& a_World);
|
||||||
virtual ~WorldRenderer();
|
virtual ~WorldRenderer();
|
||||||
|
|
||||||
virtual void Render(float a_Lerp) override;
|
virtual void Render(float a_Lerp) override;
|
||||||
|
|||||||
@@ -1,17 +1,16 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <td/Maths.h>
|
#include <td/render/shader/ShaderProgram.h>
|
||||||
|
|
||||||
namespace td {
|
namespace td {
|
||||||
namespace shader {
|
namespace shader {
|
||||||
|
|
||||||
class CameraShaderProgram {
|
class CameraShaderProgram : public ShaderProgram {
|
||||||
private:
|
private:
|
||||||
unsigned int m_LocationProjection = 0, m_LocationView = 0;
|
unsigned int m_LocationProjection = 0, m_LocationView = 0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CameraShaderProgram() {
|
CameraShaderProgram() {}
|
||||||
}
|
|
||||||
|
|
||||||
void SetProjectionMatrix(const Mat4f& proj) const;
|
void SetProjectionMatrix(const Mat4f& proj) const;
|
||||||
void SetViewMatrix(const Mat4f& view) const;
|
void SetViewMatrix(const Mat4f& view) const;
|
||||||
|
|||||||
43
include/td/render/shader/ShaderProgram.h
Executable file
43
include/td/render/shader/ShaderProgram.h
Executable file
@@ -0,0 +1,43 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <td/Maths.h>
|
||||||
|
#include <td/render/OpenGL.h>
|
||||||
|
|
||||||
|
namespace td {
|
||||||
|
namespace shader {
|
||||||
|
|
||||||
|
class ShaderProgram {
|
||||||
|
public:
|
||||||
|
ShaderProgram();
|
||||||
|
virtual ~ShaderProgram();
|
||||||
|
|
||||||
|
void Start() const;
|
||||||
|
void Stop() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void LoadProgramFile(const std::string& vertexFile, const std::string& fragmentFile);
|
||||||
|
void LoadProgram(const std::string& vertexSource, const std::string& fragmentSource);
|
||||||
|
|
||||||
|
virtual void GetAllUniformLocation() = 0;
|
||||||
|
int GetUniformLocation(const std::string& uniformName) const;
|
||||||
|
|
||||||
|
void LoadFloat(unsigned int location, float value) const;
|
||||||
|
void LoadInt(unsigned int location, int value) const;
|
||||||
|
void LoadVector(unsigned int location, const Vec2f& vector) const;
|
||||||
|
void LoadVector(unsigned int location, const Vec3f& vector) const;
|
||||||
|
void LoadBoolean(unsigned int location, bool value) const;
|
||||||
|
void LoadMat4(unsigned int location, const Mat4f& mat) const;
|
||||||
|
void CleanUp() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
unsigned int m_ProgramID;
|
||||||
|
unsigned int m_VertexShaderID;
|
||||||
|
unsigned int m_FragmentShaderID;
|
||||||
|
|
||||||
|
unsigned int LoadShaderFromFile(const std::string& file, GLenum type);
|
||||||
|
unsigned int LoadShader(const std::string& source, GLenum type);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace shader
|
||||||
|
} // namespace td
|
||||||
@@ -1,19 +1,15 @@
|
|||||||
#include <client/state/GameState.h>
|
#include <client/state/GameState.h>
|
||||||
|
|
||||||
|
|
||||||
namespace td {
|
namespace td {
|
||||||
namespace client {
|
namespace client {
|
||||||
|
|
||||||
GameState::GameState(Client& a_Client, const std::shared_ptr<game::World>& a_World, std::uint64_t a_StepTime,
|
GameState::GameState(Client& a_Client, const std::shared_ptr<game::World>& a_World, std::uint64_t a_StepTime, const std::vector<protocol::LockStep> a_FirstSteps) :
|
||||||
const std::vector<protocol::LockStep> a_FirstSteps) :
|
|
||||||
ClientState(a_Client), m_World(a_World), m_Simulation(a_World, a_StepTime, a_FirstSteps) {
|
ClientState(a_Client), m_World(a_World), m_Simulation(a_World, a_StepTime, a_FirstSteps) {
|
||||||
m_Simulation.OnMissingLockSteps.Connect([this](const std::vector<td::StepTime>& a_MissingSteps) {
|
m_Simulation.OnMissingLockSteps.Connect([this](const std::vector<td::StepTime>& a_MissingSteps) {
|
||||||
SendPacket(protocol::packets::LockStepRequestPacket(a_MissingSteps));
|
SendPacket(protocol::packets::LockStepRequestPacket(a_MissingSteps));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
GameState::~GameState() {}
|
|
||||||
|
|
||||||
void GameState::Handle(const protocol::packets::LockStepsPacket& a_LockStep) {
|
void GameState::Handle(const protocol::packets::LockStepsPacket& a_LockStep) {
|
||||||
m_Simulation.Handle(a_LockStep);
|
m_Simulation.Handle(a_LockStep);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#include <chrono>
|
||||||
#include <td/display/state/MainMenuState.h>
|
#include <td/display/state/MainMenuState.h>
|
||||||
#include <td/misc/Time.h>
|
#include <td/misc/Time.h>
|
||||||
|
|
||||||
|
|||||||
@@ -1,34 +1,133 @@
|
|||||||
#include <td/display/Display.h>
|
#include <td/display/Display.h>
|
||||||
|
|
||||||
#include <td/display/ImGuiTheme.h>
|
#include <GL/glew.h>
|
||||||
|
#include <SDL3/SDL.h>
|
||||||
|
#include <imgui.h>
|
||||||
|
#include <imgui_impl_opengl3.h>
|
||||||
|
#include <imgui_impl_sdl3.h>
|
||||||
|
|
||||||
#include <td/misc/Format.h>
|
#include <td/misc/Format.h>
|
||||||
#include <td/misc/Log.h>
|
#include <td/misc/Log.h>
|
||||||
|
#include <td/display/ImGuiTheme.h>
|
||||||
#include <raylib-cpp/raylib.hpp>
|
|
||||||
#include <td/render/RayGui.h>
|
|
||||||
|
|
||||||
namespace td {
|
namespace td {
|
||||||
|
|
||||||
Display::Display(int a_Width, int a_Height, const std::string& a_Title) :
|
Display::Display(int a_Width, int a_Height, const std::string& a_Title) :
|
||||||
m_LastWidth(0), m_LastHeight(0), m_AspectRatio(1), m_ShouldClose(false) {
|
m_LastWidth(0), m_LastHeight(0), m_AspectRatio(1), m_ShouldClose(false) {
|
||||||
|
if (!SDL_Init(SDL_INIT_VIDEO)) {
|
||||||
|
utils::LOGE(utils::Format("Could not initialize SDL! SDL error: %s", SDL_GetError()));
|
||||||
|
}
|
||||||
|
|
||||||
InitWindow(a_Width, a_Height, a_Title.c_str());
|
m_Window = SDL_CreateWindow(a_Title.c_str(), a_Width, a_Height, SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE);
|
||||||
|
|
||||||
m_LastWidth = a_Width;
|
m_LastWidth = a_Width;
|
||||||
m_LastHeight = a_Height;
|
m_LastHeight = a_Height;
|
||||||
m_AspectRatio = (float)m_LastWidth / m_LastHeight;
|
m_AspectRatio = (float)m_LastWidth / m_LastHeight;
|
||||||
|
|
||||||
|
// Prepare and create context
|
||||||
|
#ifdef __ANDROID__
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
|
||||||
|
#else
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
|
||||||
|
#endif
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 6);
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 0);
|
||||||
|
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);
|
||||||
|
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 8);
|
||||||
|
|
||||||
|
m_GLContext = SDL_GL_CreateContext(m_Window);
|
||||||
|
|
||||||
|
if (!m_GLContext) {
|
||||||
|
utils::LOGE(utils::Format("Could not create context! SDL error: %s", SDL_GetError()));
|
||||||
|
}
|
||||||
|
|
||||||
|
int major, minor, mask;
|
||||||
|
int r, g, b, a, depth;
|
||||||
|
int mBuffers, mSamples;
|
||||||
|
|
||||||
|
SDL_GL_GetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, &mask);
|
||||||
|
SDL_GL_GetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, &major);
|
||||||
|
SDL_GL_GetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, &minor);
|
||||||
|
|
||||||
|
SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &r);
|
||||||
|
SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &g);
|
||||||
|
SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &b);
|
||||||
|
SDL_GL_GetAttribute(SDL_GL_ALPHA_SIZE, &a);
|
||||||
|
|
||||||
|
SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &depth);
|
||||||
|
|
||||||
|
SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &mBuffers);
|
||||||
|
SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &mSamples);
|
||||||
|
|
||||||
|
const char* mask_desc;
|
||||||
|
|
||||||
|
if (mask & SDL_GL_CONTEXT_PROFILE_CORE) {
|
||||||
|
mask_desc = "core";
|
||||||
|
} else if (mask & SDL_GL_CONTEXT_PROFILE_COMPATIBILITY) {
|
||||||
|
mask_desc = "compatibility";
|
||||||
|
} else if (mask & SDL_GL_CONTEXT_PROFILE_ES) {
|
||||||
|
mask_desc = "es";
|
||||||
|
} else {
|
||||||
|
mask_desc = "?";
|
||||||
|
}
|
||||||
|
|
||||||
|
utils::LOG(utils::Format(
|
||||||
|
"GL Context : %i.%i %s, Color : R:%i G:%i B:%i A:%i, Depth bits : %i", major, minor, mask_desc, r, g, b, a, depth));
|
||||||
|
|
||||||
|
utils::LOG(utils::Format("MultiSamples : Buffers : %i, Samples : %i", mBuffers, mSamples));
|
||||||
|
|
||||||
|
SDL_GL_MakeCurrent(m_Window, m_GLContext);
|
||||||
|
|
||||||
|
GLenum error = glewInit();
|
||||||
|
if (error) {
|
||||||
|
utils::LOGE(utils::Format("Error initializing glew : %s", glewGetErrorString(error)));
|
||||||
|
}
|
||||||
|
|
||||||
// WindowResizeEvent(WindowWidth, WindowHeight);
|
// WindowResizeEvent(WindowWidth, WindowHeight);
|
||||||
|
|
||||||
// vsync
|
// vsync
|
||||||
SetTargetFPS(60);
|
SDL_GL_SetSwapInterval(1);
|
||||||
|
|
||||||
rlImGuiSetup(true);
|
// Setup Dear ImGui context
|
||||||
|
IMGUI_CHECKVERSION();
|
||||||
|
ImGui::CreateContext();
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
(void)io;
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
||||||
|
|
||||||
float main_scale = 1.5f;
|
// Setup Dear ImGui style
|
||||||
|
ImGui::StyleColorsDark();
|
||||||
|
// ImGui::StyleColorsLight();
|
||||||
|
|
||||||
ImGui::GetStyle().FontScaleMain = main_scale;
|
// Setup scaling
|
||||||
|
float main_scale = SDL_GetDisplayContentScale(SDL_GetPrimaryDisplay());
|
||||||
|
// ImGuiStyle& style = ImGui::GetStyle();
|
||||||
|
// style.ScaleAllSizes(main_scale); // Bake a fixed style scale. (until we have a solution for dynamic style scaling, changing
|
||||||
|
// this
|
||||||
|
// // requires resetting Style + calling this again)
|
||||||
|
// style.FontSizeBase = 13 * main_scale; // Set initial font scale. (using io.ConfigDpiScaleFonts=true makes this unnecessary. We
|
||||||
|
// leave
|
||||||
|
// // both here for documentation purpose)
|
||||||
|
|
||||||
|
|
||||||
|
ImFontConfig cfg;
|
||||||
|
cfg.SizePixels = 13 * main_scale * 2;
|
||||||
|
io.Fonts->AddFontDefault(&cfg);
|
||||||
|
|
||||||
|
// Setup Platform/Renderer backends
|
||||||
|
ImGui_ImplSDL3_InitForOpenGL(m_Window, m_GLContext);
|
||||||
|
ImGui_ImplOpenGL3_Init("#version 330");
|
||||||
LoadTheme();
|
LoadTheme();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -37,66 +136,62 @@ void Display::Close() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Display::PollEvents() {
|
void Display::PollEvents() {
|
||||||
// PollInputEvents();
|
SDL_Event event;
|
||||||
// SDL_Event event;
|
while (SDL_PollEvent(&event)) {
|
||||||
// while (SDL_PollEvent(&event)) {
|
switch (event.type) {
|
||||||
// switch (event.type) {
|
case SDL_EVENT_QUIT:
|
||||||
// case SDL_EVENT_QUIT:
|
case SDL_EVENT_WINDOW_CLOSE_REQUESTED: {
|
||||||
// case SDL_EVENT_WINDOW_CLOSE_REQUESTED: {
|
m_ShouldClose = true;
|
||||||
// m_ShouldClose = true;
|
break;
|
||||||
// break;
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
// case SDL_EVENT_WINDOW_RESIZED: {
|
case SDL_EVENT_WINDOW_RESIZED: {
|
||||||
// m_LastWidth = event.window.data1;
|
m_LastWidth = event.window.data1;
|
||||||
// m_LastHeight = event.window.data2;
|
m_LastHeight = event.window.data2;
|
||||||
// m_AspectRatio = (float)m_LastWidth / m_LastHeight;
|
m_AspectRatio = (float)m_LastWidth / m_LastHeight;
|
||||||
// OnAspectRatioChange(m_AspectRatio);
|
OnAspectRatioChange(m_AspectRatio);
|
||||||
// break;
|
break;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// case SDL_EVENT_KEY_DOWN: {
|
case SDL_EVENT_KEY_DOWN: {
|
||||||
// if (!event.key.repeat)
|
if (!event.key.repeat)
|
||||||
// OnKeyDown(event.key.key);
|
OnKeyDown(event.key.key);
|
||||||
// break;
|
break;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// default:
|
default:
|
||||||
// break;
|
break;
|
||||||
// }
|
}
|
||||||
// ImGui_ImplSDL3_ProcessEvent(&event);
|
ImGui_ImplSDL3_ProcessEvent(&event);
|
||||||
// }
|
}
|
||||||
// // Start the Dear ImGui frame
|
// Start the Dear ImGui frame
|
||||||
// ImGui_ImplOpenGL3_NewFrame();
|
ImGui_ImplOpenGL3_NewFrame();
|
||||||
// ImGui_ImplSDL3_NewFrame();
|
ImGui_ImplSDL3_NewFrame();
|
||||||
// ImGui::NewFrame();
|
ImGui::NewFrame();
|
||||||
if (WindowShouldClose())
|
|
||||||
m_ShouldClose = true;
|
|
||||||
BeginDrawing();
|
|
||||||
rlImGuiBegin();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Display::Update(float a_Delta) {
|
void Display::Update(float a_Delta) {
|
||||||
StateMachine::Update(a_Delta);
|
StateMachine::Update(a_Delta);
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
ImGui::ShowDemoWindow();
|
ImGui::ShowDemoWindow();
|
||||||
#endif
|
#endif
|
||||||
ImGui::Render();
|
ImGui::Render();
|
||||||
rlImGuiEnd();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
EndDrawing();
|
glViewport(0, 0, (int)io.DisplaySize.x, (int)io.DisplaySize.y);
|
||||||
ClearBackground(DARKGRAY);
|
// glClearColor(clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear_color.z * clear_color.w, clear_color.w);
|
||||||
// ImGuiIO& io = ImGui::GetIO();
|
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
||||||
// glViewport(0, 0, (int)io.DisplaySize.x, (int)io.DisplaySize.y);
|
SDL_GL_SwapWindow(m_Window);
|
||||||
// // glClearColor(clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear_color.z * clear_color.w, clear_color.w);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
// ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
|
||||||
// SDL_GL_SwapWindow(m_Window);
|
|
||||||
// glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Display::~Display() {
|
Display::~Display() {
|
||||||
rlImGuiShutdown();
|
ImGui_ImplOpenGL3_Shutdown();
|
||||||
CloseWindow();
|
ImGui_ImplSDL3_Shutdown();
|
||||||
|
ImGui::DestroyContext();
|
||||||
|
SDL_GL_DestroyContext(m_GLContext);
|
||||||
|
SDL_DestroyWindow(m_Window);
|
||||||
|
SDL_Quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace td
|
} // namespace td
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
#include <td/display/ImGuiTheme.h>
|
#include <td/display/ImGuiTheme.h>
|
||||||
|
|
||||||
#include <td/render/RayGui.h>
|
#include <imgui.h>
|
||||||
|
|
||||||
namespace td {
|
namespace td {
|
||||||
|
|
||||||
void LoadTheme() {
|
void LoadTheme() {
|
||||||
|
|
||||||
static const bool bStyleDark_ = true;
|
static const bool bStyleDark_ = true;
|
||||||
static const float alpha_ = 0.8f;
|
static const float alpha_ = 0.8f;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include <td/display/menu/CreatePartyMenu.h>
|
#include <td/display/menu/CreatePartyMenu.h>
|
||||||
|
|
||||||
#include <td/render/RayGui.h>
|
#include <imgui.h>
|
||||||
|
|
||||||
namespace td {
|
namespace td {
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include <td/display/menu/JoinPartyMenu.h>
|
#include <td/display/menu/JoinPartyMenu.h>
|
||||||
|
|
||||||
#include <td/render/RayGui.h>
|
#include <imgui.h>
|
||||||
|
|
||||||
namespace td {
|
namespace td {
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include <td/display/menu/MainMenu.h>
|
#include <td/display/menu/MainMenu.h>
|
||||||
|
|
||||||
#include <td/render/RayGui.h>
|
#include <imgui.h>
|
||||||
#include <td/display/menu/CreatePartyMenu.h>
|
#include <td/display/menu/CreatePartyMenu.h>
|
||||||
#include <td/display/menu/JoinPartyMenu.h>
|
#include <td/display/menu/JoinPartyMenu.h>
|
||||||
#include <td/display/menu/SettingsMenu.h>
|
#include <td/display/menu/SettingsMenu.h>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include <td/display/menu/SettingsMenu.h>
|
#include <td/display/menu/SettingsMenu.h>
|
||||||
|
|
||||||
#include <td/render/RayGui.h>
|
#include <imgui.h>
|
||||||
|
|
||||||
namespace td {
|
namespace td {
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
#include <td/display/state/DebugWorldState.h>
|
#include <td/display/state/DebugWorldState.h>
|
||||||
|
|
||||||
#include <td/display/Display.h>
|
#include <chrono>
|
||||||
#include <td/display/state/DebugWorldState.h>
|
#include <iostream>
|
||||||
|
|
||||||
#include <td/game/World.h>
|
#include <td/game/World.h>
|
||||||
#include <td/protocol/packet/Packets.h>
|
#include <td/protocol/packet/Packets.h>
|
||||||
#include <td/render/renderer/EntityRenderer.h>
|
#include <td/render/renderer/EntityRenderer.h>
|
||||||
@@ -19,9 +20,12 @@
|
|||||||
#include <client/state/GameState.h>
|
#include <client/state/GameState.h>
|
||||||
#include <client/state/LoggingState.h>
|
#include <client/state/LoggingState.h>
|
||||||
|
|
||||||
|
#include <td/display/Display.h>
|
||||||
|
#include <td/display/state/DebugWorldState.h>
|
||||||
|
|
||||||
namespace td {
|
namespace td {
|
||||||
|
|
||||||
DebugWorldState::DebugWorldState(Display& a_Display) : DisplayState(a_Display), m_ClientState(nullptr) {
|
DebugWorldState::DebugWorldState(Display& a_Display) : DisplayState(a_Display) {
|
||||||
// server
|
// server
|
||||||
m_ServerSocket = std::make_shared<server::FakeSocket>();
|
m_ServerSocket = std::make_shared<server::FakeSocket>();
|
||||||
m_Server = std::make_unique<server::Server>(m_ServerSocket);
|
m_Server = std::make_unique<server::Server>(m_ServerSocket);
|
||||||
@@ -35,12 +39,12 @@ DebugWorldState::DebugWorldState(Display& a_Display) : DisplayState(a_Display),
|
|||||||
if (auto gameState = dynamic_cast<client::GameState*>(&a_State)) {
|
if (auto gameState = dynamic_cast<client::GameState*>(&a_State)) {
|
||||||
// render
|
// render
|
||||||
auto clientWorld = gameState->GetWorld();
|
auto clientWorld = gameState->GetWorld();
|
||||||
m_Renderer.AddRenderer<render::WorldRenderer>(static_cast<raylib::Camera&>(m_Camera), clientWorld);
|
m_Renderer.AddRenderer<render::WorldRenderer>(m_Camera, clientWorld);
|
||||||
m_Renderer.AddRenderer<render::EntityRenderer>(static_cast<raylib::Camera&>(m_Camera), clientWorld);
|
m_Renderer.AddRenderer<render::EntityRenderer>(m_Camera, clientWorld);
|
||||||
m_Renderer.AddRenderer<render::TowerRenderer>(static_cast<raylib::Camera&>(m_Camera), clientWorld);
|
m_Renderer.AddRenderer<render::TowerRenderer>(m_Camera, clientWorld);
|
||||||
m_Renderer.AddRenderer<render::TimerRenderer, client::GameState&>(*gameState);
|
m_Renderer.AddRenderer<render::TimerRenderer>(*gameState);
|
||||||
|
|
||||||
auto& list = m_Renderer.AddRenderer<render::PlayerListRenderer, const td::client::PlayerManager&>(m_Client->GetPlayers());
|
auto& list = m_Renderer.AddRenderer<render::PlayerListRenderer>(m_Client->GetPlayers());
|
||||||
|
|
||||||
list.OnPlayerCreate.Connect([this]() {
|
list.OnPlayerCreate.Connect([this]() {
|
||||||
auto newSocket = client::FakeSocket::Connect(m_ServerSocket);
|
auto newSocket = client::FakeSocket::Connect(m_ServerSocket);
|
||||||
@@ -66,52 +70,45 @@ DebugWorldState::DebugWorldState(Display& a_Display) : DisplayState(a_Display),
|
|||||||
m_Client->ChangeState<client::LoggingState>("Player0");
|
m_Client->ChangeState<client::LoggingState>("Player0");
|
||||||
|
|
||||||
// camera
|
// camera
|
||||||
// m_Camera = Camera{{0}};
|
m_Camera.SetCamPos({77, 7, 13});
|
||||||
m_Camera.position = (Vector3){77.0f, 7.0f, 13.0f}; // Camera position
|
m_Camera.UpdatePerspective(m_StateMachine.GetAspectRatio());
|
||||||
m_Camera.target = (Vector3){0.0f, 1.0f, -1.0f}; // Camera looking at point
|
|
||||||
m_Camera.up = (Vector3){0.0f, 1.0f, 0.0f}; // Camera up vector (rotation towards target)
|
|
||||||
m_Camera.fovy = 45.0f; // Camera field-of-view Y
|
|
||||||
m_Camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
|
|
||||||
|
|
||||||
// m_Camera.SetCamPos({77, 7, 13});
|
|
||||||
// m_Camera.UpdatePerspective(m_StateMachine.GetAspectRatio());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebugWorldState::Update(float a_Delta) {
|
void DebugWorldState::Update(float a_Delta) {
|
||||||
m_Server->Update(a_Delta * m_PlaySpeed);
|
m_Server->Update(a_Delta * m_PlaySpeed);
|
||||||
m_Client->Update(a_Delta * m_PlaySpeed);
|
m_Client->Update(a_Delta * m_PlaySpeed);
|
||||||
UpdateCamera(&m_Camera, CAMERA_FREE);
|
if (m_ClientState)
|
||||||
|
m_Renderer.Render(m_ClientState->GetCurrentLerp());
|
||||||
if (m_ClientState) {
|
|
||||||
float lerp = m_ClientState->GetCurrentLerp();
|
|
||||||
BeginMode3D(m_Camera);
|
|
||||||
m_Renderer.Render(lerp);
|
|
||||||
EndMode3D();
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr int SECONDS = 10;
|
|
||||||
if (IsKeyPressed(KEY_Q)) {
|
|
||||||
m_Client->SendPacket(td::protocol::packets::SpawnTroopPacket(td::EntityType::Zombie, 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (IsKeyPressed(KEY_Z))
|
|
||||||
m_Client->SendPacket(td::protocol::packets::PlaceTowerPacket(td::TowerType::Archer, td::TowerCoords(77, 13)));
|
|
||||||
|
|
||||||
if (IsKeyPressed(KEY_F)) {
|
|
||||||
m_Server->Update(SECONDS);
|
|
||||||
m_Client->Update(SECONDS);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (IsKeyPressed(KEY_P))
|
|
||||||
m_PlaySpeed = 1 - m_PlaySpeed;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebugWorldState::OnAspectRatioChange(float a_Ratio) {
|
void DebugWorldState::OnAspectRatioChange(float a_Ratio) {
|
||||||
// m_Camera.UpdatePerspective(a_Ratio);
|
m_Camera.UpdatePerspective(a_Ratio);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebugWorldState::OnKeyDown(int a_Key) {
|
void DebugWorldState::OnKeyDown(SDL_Keycode a_Key) {
|
||||||
// temporary tests
|
// temporary tests
|
||||||
|
constexpr int SECONDS = 10;
|
||||||
|
switch (a_Key) {
|
||||||
|
case SDLK_A:
|
||||||
|
m_Client->SendPacket(td::protocol::packets::SpawnTroopPacket(td::EntityType::Zombie, 1));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SDLK_Z:
|
||||||
|
m_Client->SendPacket(td::protocol::packets::PlaceTowerPacket(td::TowerType::Archer, td::TowerCoords(77, 13)));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SDLK_F:
|
||||||
|
m_Server->Update(SECONDS);
|
||||||
|
m_Client->Update(SECONDS);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SDLK_P:
|
||||||
|
m_PlaySpeed = 1 - m_PlaySpeed;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DebugWorldState::~DebugWorldState() {}
|
DebugWorldState::~DebugWorldState() {}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include <td/display/state/MainMenuState.h>
|
#include <td/display/state/MainMenuState.h>
|
||||||
|
|
||||||
#include <td/render/RayGui.h>
|
#include <imgui.h>
|
||||||
#include <td/display/menu/MainMenu.h>
|
#include <td/display/menu/MainMenu.h>
|
||||||
#include <td/display/state/DebugWorldState.h>
|
#include <td/display/state/DebugWorldState.h>
|
||||||
|
|
||||||
@@ -34,8 +34,8 @@ void MainMenuState::RenderBackButton() {
|
|||||||
PopState();
|
PopState();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainMenuState::OnKeyDown(int a_Key) {
|
void MainMenuState::OnKeyDown(SDL_Keycode a_Key) {
|
||||||
if (a_Key == KEY_ESCAPE)
|
if (a_Key == SDLK_ESCAPE)
|
||||||
PopState();
|
PopState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
33
src/td/render/Camera.cpp
Normal file
33
src/td/render/Camera.cpp
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
#include "td/Maths.h"
|
||||||
|
#include <td/render/Camera.h>
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
|
namespace td {
|
||||||
|
namespace render {
|
||||||
|
|
||||||
|
void Camera::UpdatePerspective(float a_AspectRatio) {
|
||||||
|
m_ProjectionMatrix = maths::Perspective(80.0f / 180.0f * PI, a_AspectRatio, 0.1f, 160.0f);
|
||||||
|
m_InvProjectionMatrix = maths::Inverse(m_ProjectionMatrix);
|
||||||
|
OnPerspectiveChange();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Camera::SetCamPos(const Vec3f& a_NewPos) {
|
||||||
|
Vec3f front = {
|
||||||
|
std::cos(m_Yaw) * std::cos(m_Pitch),
|
||||||
|
std::sin(m_Pitch),
|
||||||
|
std::sin(m_Yaw) * std::cos(m_Pitch)
|
||||||
|
};
|
||||||
|
|
||||||
|
m_CamPos = a_NewPos;
|
||||||
|
m_ViewMatrix = maths::Look(m_CamPos, front, { 0, 1, 0 });
|
||||||
|
m_InvViewMatrix = maths::Transpose(maths::Inverse(m_ViewMatrix)); // why transpose ? I don't know
|
||||||
|
OnViewChange();
|
||||||
|
}
|
||||||
|
|
||||||
|
const Vec3f& Camera::GetCamPos() const {
|
||||||
|
return m_CamPos;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace render
|
||||||
|
} // namespace td
|
||||||
@@ -1,23 +1,32 @@
|
|||||||
#include <td/render/Renderer.h>
|
#include <td/render/Renderer.h>
|
||||||
|
|
||||||
|
#include <td/render/OpenGL.h>
|
||||||
|
|
||||||
namespace td {
|
namespace td {
|
||||||
namespace render {
|
namespace render {
|
||||||
|
|
||||||
void BasicRenderer::Render(const GL::VertexArray& a_Vao) {
|
void BasicRenderer::Render(const GL::VertexArray& a_Vao) {
|
||||||
a_Vao.Bind();
|
a_Vao.Bind();
|
||||||
// rlDrawArrays(RL_TRIANGLES, 0, a_Vao.GetVertexCount());
|
glDrawArrays(GL_TRIANGLES, 0, a_Vao.GetVertexCount());
|
||||||
// rlDrawElements(RL_TRIANrlES, a_Vao.GetVertexCount(), RL_UNSIGNED_INT, nullptr);
|
|
||||||
a_Vao.Unbind();
|
a_Vao.Unbind();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BasicRenderer::Render(const Model& a_Model) {
|
||||||
|
for (const auto& vao : a_Model.m_Vaos) {
|
||||||
|
vao->Bind();
|
||||||
|
glDrawElements(GL_TRIANGLES, vao->GetVertexCount(), GL_UNSIGNED_INT, nullptr);
|
||||||
|
vao->Unbind();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
RenderPipeline::RenderPipeline() {
|
RenderPipeline::RenderPipeline() {
|
||||||
// rlEnable(RL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
// rlEnable(RL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
// rlEnable(RL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
// rlEnable(RL_CULL_FACE);
|
glEnable(GL_CULL_FACE);
|
||||||
// rlBlendFunc(RL_SRC_ALPHA, RL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
// rlDepthFunc(RL_LESS);
|
glDepthFunc(GL_LESS);
|
||||||
// rlFrontFace(RL_CCW);
|
glFrontFace(GL_CCW);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace render
|
} // namespace render
|
||||||
|
|||||||
128
src/td/render/loader/FbxLoader.cpp
Normal file
128
src/td/render/loader/FbxLoader.cpp
Normal file
@@ -0,0 +1,128 @@
|
|||||||
|
#include <td/render/loader/FbxLoader.h>
|
||||||
|
|
||||||
|
#include <assimp/Importer.hpp> // C++ importer interface
|
||||||
|
#include <assimp/postprocess.h> // Post processing flags
|
||||||
|
#include <assimp/scene.h> // Output data structure
|
||||||
|
#include <iostream>
|
||||||
|
#include <memory>
|
||||||
|
#include <sp/common/DataBuffer.h>
|
||||||
|
#include <td/render/loader/GLLoader.h>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#define VERTEX_SIZE 3
|
||||||
|
#define UV_SIZE 2
|
||||||
|
|
||||||
|
#define VERTEX_POSITION_INDEX 0
|
||||||
|
#define VERTEX_UV_INDEX 1
|
||||||
|
#define VERTEX_NORMAL_INDEX 2
|
||||||
|
|
||||||
|
namespace td {
|
||||||
|
namespace ModelLoader {
|
||||||
|
|
||||||
|
static std::unique_ptr<GL::VertexArray> ProcessMesh(aiMesh* mesh, const aiScene* scene, const aiMatrix4x4& transform) {
|
||||||
|
std::vector<float> positions;
|
||||||
|
std::vector<float> textureCoords;
|
||||||
|
std::vector<float> normals;
|
||||||
|
|
||||||
|
std::vector<unsigned int> indicies;
|
||||||
|
|
||||||
|
aiFace* faces = mesh->mFaces;
|
||||||
|
std::size_t faceNumber = mesh->mNumFaces;
|
||||||
|
|
||||||
|
for (std::size_t j = 0; j < faceNumber; j++) {
|
||||||
|
std::size_t offset = indicies.size();
|
||||||
|
std::size_t numIndices = faces[j].mNumIndices;
|
||||||
|
|
||||||
|
indicies.resize(indicies.size() + numIndices);
|
||||||
|
std::memcpy(indicies.data() + offset, faces[j].mIndices, numIndices * sizeof(unsigned int));
|
||||||
|
}
|
||||||
|
|
||||||
|
std::size_t vertNumber = mesh->mNumVertices;
|
||||||
|
aiVector3D* vertecies = mesh->mVertices;
|
||||||
|
|
||||||
|
for (std::size_t j = 0; j < vertNumber; j++) {
|
||||||
|
aiVector3D vertex = transform * vertecies[j];
|
||||||
|
|
||||||
|
positions.push_back(vertex.x);
|
||||||
|
positions.push_back(vertex.y);
|
||||||
|
positions.push_back(vertex.z);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mesh->HasNormals()) {
|
||||||
|
aiVector3D* vertexNormals = mesh->mNormals;
|
||||||
|
|
||||||
|
for (std::size_t j = 0; j < vertNumber; j++) {
|
||||||
|
aiVector3D normal = transform * vertexNormals[j];
|
||||||
|
|
||||||
|
normals.push_back(normal.x);
|
||||||
|
normals.push_back(normal.y);
|
||||||
|
normals.push_back(normal.z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
aiVector3D** vertexTexture = mesh->mTextureCoords;
|
||||||
|
|
||||||
|
for (std::size_t j = 0; j < vertNumber; j++) {
|
||||||
|
textureCoords.push_back(vertexTexture[0][j].x);
|
||||||
|
textureCoords.push_back(vertexTexture[0][j].y);
|
||||||
|
}
|
||||||
|
|
||||||
|
GL::VertexBuffer positionVBO(positions, VERTEX_SIZE);
|
||||||
|
positionVBO.AddVertexAttribPointer(VERTEX_POSITION_INDEX, VERTEX_SIZE, 0);
|
||||||
|
|
||||||
|
GL::VertexBuffer textureVBO(textureCoords, UV_SIZE);
|
||||||
|
textureVBO.AddVertexAttribPointer(VERTEX_UV_INDEX, UV_SIZE, 0);
|
||||||
|
|
||||||
|
GL::VertexBuffer normalVBO(normals, VERTEX_SIZE);
|
||||||
|
normalVBO.AddVertexAttribPointer(VERTEX_NORMAL_INDEX, VERTEX_SIZE, 0);
|
||||||
|
|
||||||
|
auto Vao = std::make_unique<GL::VertexArray>(GL::ElementBuffer{indicies});
|
||||||
|
Vao->Bind();
|
||||||
|
Vao->BindVertexBuffer(std::move(positionVBO));
|
||||||
|
Vao->BindVertexBuffer(std::move(textureVBO));
|
||||||
|
Vao->BindVertexBuffer(std::move(normalVBO));
|
||||||
|
Vao->Unbind();
|
||||||
|
|
||||||
|
return Vao;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ProcessNode(
|
||||||
|
aiNode* node, const aiScene* scene, std::vector<std::unique_ptr<GL::VertexArray>>& meshes, const aiMatrix4x4& transform) {
|
||||||
|
// recursive
|
||||||
|
for (unsigned int i = 0; i < node->mNumChildren; i++) {
|
||||||
|
ProcessNode(node->mChildren[i], scene, meshes, transform * node->mTransformation);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < node->mNumMeshes; i++) {
|
||||||
|
aiMesh* mesh = scene->mMeshes[node->mMeshes[i]];
|
||||||
|
meshes.push_back(ProcessMesh(mesh, scene, transform * node->mTransformation));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Model LoadModel(const std::string& fileName) {
|
||||||
|
// DataBuffer fileData = utils::AssetsManager::GetAsset(fileName);
|
||||||
|
sp::DataBuffer fileData;
|
||||||
|
fileData.ReadFile(fileName);
|
||||||
|
|
||||||
|
Assimp::Importer importer;
|
||||||
|
|
||||||
|
const aiScene* scene = importer.ReadFile(fileName, aiProcess_CalcTangentSpace | aiProcess_Triangulate | aiProcess_SortByPType |
|
||||||
|
aiProcess_OptimizeGraph | aiProcess_OptimizeMeshes | aiProcess_GlobalScale | aiProcess_FlipUVs);
|
||||||
|
|
||||||
|
if (!scene) {
|
||||||
|
std::cerr << "[ModelLoader] Failed to load model !\n";
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
// utils::LOGD(utils::Format("[ModelLoader]\tModel nodes : %i", scene->mRootNode->mNumMeshes));
|
||||||
|
|
||||||
|
Model model;
|
||||||
|
ProcessNode(scene->mRootNode, scene, model.m_Vaos, {});
|
||||||
|
|
||||||
|
std::cout << "Loaded " << model.m_Vaos.size() << " vaos !\n";
|
||||||
|
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace ModelLoader
|
||||||
|
} // namespace td
|
||||||
@@ -1,26 +1,28 @@
|
|||||||
#include <td/render/loader/GLLoader.h>
|
#include <td/render/loader/GLLoader.h>
|
||||||
|
|
||||||
|
#include <td/render/OpenGL.h>
|
||||||
|
|
||||||
namespace td {
|
namespace td {
|
||||||
namespace GL {
|
namespace GL {
|
||||||
|
|
||||||
VertexArray::~VertexArray() {
|
VertexArray::~VertexArray() {
|
||||||
// if (m_ID != 0)
|
if (m_ID != 0)
|
||||||
// glDeleteVertexArrays(1, &m_ID);
|
glDeleteVertexArrays(1, &m_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
VertexArray::VertexArray(ElementBuffer&& indicies) : m_ElementBuffer(std::move(indicies)) {
|
VertexArray::VertexArray(ElementBuffer&& indicies) : m_ElementBuffer(std::move(indicies)) {
|
||||||
// glGenVertexArrays(1, &m_ID);
|
glGenVertexArrays(1, &m_ID);
|
||||||
Bind();
|
Bind();
|
||||||
BindElementArrayBuffer();
|
BindElementArrayBuffer();
|
||||||
// Unbind();
|
// Unbind();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VertexArray::Bind() const {
|
void VertexArray::Bind() const {
|
||||||
// glBindVertexArray(m_ID);
|
glBindVertexArray(m_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VertexArray::Unbind() const {
|
void VertexArray::Unbind() const {
|
||||||
// glBindVertexArray(0);
|
glBindVertexArray(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VertexArray::BindVertexBuffer(VertexBuffer&& VertexBuffer) {
|
void VertexArray::BindVertexBuffer(VertexBuffer&& VertexBuffer) {
|
||||||
@@ -34,24 +36,24 @@ void VertexArray::BindElementArrayBuffer() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
VertexBuffer::~VertexBuffer() {
|
VertexBuffer::~VertexBuffer() {
|
||||||
// if (m_ID != 0)
|
if (m_ID != 0)
|
||||||
// glDeleteBuffers(1, &m_ID);
|
glDeleteBuffers(1, &m_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
VertexBuffer::VertexBuffer(const std::vector<float>& data, unsigned int stride) : m_DataStride(stride) {
|
VertexBuffer::VertexBuffer(const std::vector<float>& data, unsigned int stride) : m_DataStride(stride) {
|
||||||
// glGenBuffers(1, &m_ID);
|
glGenBuffers(1, &m_ID);
|
||||||
Bind();
|
Bind();
|
||||||
// glBufferData(GL_ARRAY_BUFFER, static_cast<GLsizeiptr>(data.size() * sizeof(float)), nullptr, GL_STATIC_DRAW);
|
glBufferData(GL_ARRAY_BUFFER, static_cast<GLsizeiptr>(data.size() * sizeof(float)), nullptr, GL_STATIC_DRAW);
|
||||||
// glBufferSubData(GL_ARRAY_BUFFER, 0, static_cast<GLsizeiptr>(data.size() * sizeof(float)), data.data());
|
glBufferSubData(GL_ARRAY_BUFFER, 0, static_cast<GLsizeiptr>(data.size() * sizeof(float)), data.data());
|
||||||
Unbind();
|
Unbind();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VertexBuffer::Bind() const {
|
void VertexBuffer::Bind() const {
|
||||||
// glBindBuffer(GL_ARRAY_BUFFER, m_ID);
|
glBindBuffer(GL_ARRAY_BUFFER, m_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VertexBuffer::Unbind() const {
|
void VertexBuffer::Unbind() const {
|
||||||
// glBindBuffer(GL_ARRAY_BUFFER, 0);
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VertexBuffer::AddVertexAttribPointer(unsigned int index, unsigned int coordinateSize, unsigned int offset) {
|
void VertexBuffer::AddVertexAttribPointer(unsigned int index, unsigned int coordinateSize, unsigned int offset) {
|
||||||
@@ -65,32 +67,32 @@ void VertexBuffer::AddVertexAttribPointer(unsigned int index, unsigned int coord
|
|||||||
|
|
||||||
void VertexBuffer::BindVertexAttribs() const {
|
void VertexBuffer::BindVertexAttribs() const {
|
||||||
for (const VertexAttribPointer& pointer : m_VertexAttribs) {
|
for (const VertexAttribPointer& pointer : m_VertexAttribs) {
|
||||||
// glVertexAttribPointer(pointer.m_Index, static_cast<GLint>(pointer.m_Size), GL_FLOAT, false, m_DataStride * sizeof(float),
|
glVertexAttribPointer(pointer.m_Index, static_cast<GLint>(pointer.m_Size), GL_FLOAT, false, m_DataStride * sizeof(float),
|
||||||
// reinterpret_cast<GLvoid*>(static_cast<std::size_t>(pointer.m_Offset)));
|
reinterpret_cast<GLvoid*>(static_cast<std::size_t>(pointer.m_Offset)));
|
||||||
// glEnableVertexAttribArray(pointer.m_Index);
|
glEnableVertexAttribArray(pointer.m_Index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ElementBuffer::ElementBuffer(const std::vector<unsigned int>& indicies) {
|
ElementBuffer::ElementBuffer(const std::vector<unsigned int>& indicies) {
|
||||||
m_TriangleCount = indicies.size();
|
m_TriangleCount = indicies.size();
|
||||||
// glGenBuffers(1, &m_ID);
|
glGenBuffers(1, &m_ID);
|
||||||
Bind();
|
Bind();
|
||||||
// glBufferData(GL_ELEMENT_ARRAY_BUFFER, static_cast<GLsizeiptr>(indicies.size() * sizeof(unsigned int)), nullptr, GL_STATIC_DRAW);
|
glBufferData(GL_ELEMENT_ARRAY_BUFFER, static_cast<GLsizeiptr>(indicies.size() * sizeof(unsigned int)), nullptr, GL_STATIC_DRAW);
|
||||||
// glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, static_cast<GLsizeiptr>(indicies.size() * sizeof(unsigned int)), indicies.data());
|
glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, static_cast<GLsizeiptr>(indicies.size() * sizeof(unsigned int)), indicies.data());
|
||||||
Unbind();
|
Unbind();
|
||||||
}
|
}
|
||||||
|
|
||||||
ElementBuffer::~ElementBuffer() {
|
ElementBuffer::~ElementBuffer() {
|
||||||
// if (m_ID != 0)
|
if (m_ID != 0)
|
||||||
// glDeleteBuffers(1, &m_ID);
|
glDeleteBuffers(1, &m_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ElementBuffer::Bind() const {
|
void ElementBuffer::Bind() const {
|
||||||
// glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ID);
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ElementBuffer::Unbind() const {
|
void ElementBuffer::Unbind() const {
|
||||||
// glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace GL
|
} // namespace GL
|
||||||
|
|||||||
89
src/td/render/loader/TextureLoader.cpp
Normal file
89
src/td/render/loader/TextureLoader.cpp
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
/*
|
||||||
|
* TextureLoader.cpp
|
||||||
|
*
|
||||||
|
* Created on: 15 nov. 2020
|
||||||
|
* Author: simon
|
||||||
|
*/
|
||||||
|
|
||||||
|
// #include "render/loader/TextureLoader.h"
|
||||||
|
// #include "render/loader/stb_image.h"
|
||||||
|
// #include "render/GL.h"
|
||||||
|
// #include "misc/Log.h"
|
||||||
|
// #include "misc/Format.h"
|
||||||
|
|
||||||
|
#include <td/render/loader/TextureLoader.h>
|
||||||
|
|
||||||
|
#include <stdexcept>
|
||||||
|
#include <td/misc/Log.h>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
|
#define STB_IMAGE_IMPLEMENTATION
|
||||||
|
#include <stb_image.h>
|
||||||
|
|
||||||
|
#include <td/render/OpenGL.h>
|
||||||
|
|
||||||
|
namespace td {
|
||||||
|
namespace TextureLoader {
|
||||||
|
|
||||||
|
GL::Texture LoadTexture(const std::string& fileName) {
|
||||||
|
|
||||||
|
int width, height, comp;
|
||||||
|
|
||||||
|
unsigned char* image = stbi_load(fileName.c_str(), &width, &height, &comp, STBI_rgb_alpha);
|
||||||
|
|
||||||
|
if (image == nullptr) {
|
||||||
|
utils::LOGE("Erreur lors du chargement de la texture !");
|
||||||
|
throw std::runtime_error("Failed to load texture");
|
||||||
|
}
|
||||||
|
|
||||||
|
GL::Texture texture(reinterpret_cast<const char*>(image), width, height, comp);
|
||||||
|
|
||||||
|
stbi_image_free(image);
|
||||||
|
|
||||||
|
// utils::LOGD(utils::format("Texture %s chargée !", fileName.c_str()));
|
||||||
|
|
||||||
|
return texture;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace TextureLoader
|
||||||
|
|
||||||
|
namespace GL {
|
||||||
|
|
||||||
|
Texture::Texture(const char* textureData, int width, int height, int comp) {
|
||||||
|
glGenTextures(1, &m_ID);
|
||||||
|
|
||||||
|
Bind();
|
||||||
|
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
|
|
||||||
|
assert(comp == 3 || comp == 4);
|
||||||
|
|
||||||
|
if (comp == 3)
|
||||||
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, textureData);
|
||||||
|
else
|
||||||
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, textureData);
|
||||||
|
|
||||||
|
Unbind();
|
||||||
|
}
|
||||||
|
|
||||||
|
Texture::Texture(Texture&& a_Other) {
|
||||||
|
std::swap(m_ID, a_Other.m_ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
Texture::~Texture() {
|
||||||
|
glDeleteTextures(1, &m_ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Texture::Bind() const {
|
||||||
|
glBindTexture(GL_TEXTURE_2D, m_ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Texture::Unbind() const {
|
||||||
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace GL
|
||||||
|
|
||||||
|
} // namespace td
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
#include <td/render/loader/WorldLoader.h>
|
#include <td/render/loader/WorldLoader.h>
|
||||||
|
|
||||||
#include <cstring>
|
#include <iostream>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include <td/game/World.h>
|
#include <td/game/World.h>
|
||||||
|
|
||||||
namespace td {
|
namespace td {
|
||||||
@@ -9,12 +11,11 @@ namespace render {
|
|||||||
namespace WorldLoader {
|
namespace WorldLoader {
|
||||||
|
|
||||||
const static int POSITION_VERTEX_SIZE = 3;
|
const static int POSITION_VERTEX_SIZE = 3;
|
||||||
const static int COLOR_VERTEX_SIZE = 4;
|
// const static int TEXTURE_VERTEX_SIZE = 2;
|
||||||
|
|
||||||
Mesh LoadWorldModel(const td::game::World* world) {
|
GL::VertexArray LoadWorldModel(const td::game::World* world) {
|
||||||
Mesh mesh = {0};
|
|
||||||
std::vector<float> positions;
|
std::vector<float> positions;
|
||||||
std::vector<unsigned char> colors;
|
std::vector<float> colors;
|
||||||
|
|
||||||
for (const auto& [coords, chunk] : world->GetChunks()) {
|
for (const auto& [coords, chunk] : world->GetChunks()) {
|
||||||
std::int32_t chunkX = coords.x * td::game::Chunk::ChunkWidth;
|
std::int32_t chunkX = coords.x * td::game::Chunk::ChunkWidth;
|
||||||
@@ -41,10 +42,15 @@ Mesh LoadWorldModel(const td::game::World* world) {
|
|||||||
const td::Color* tileColor = world->GetTileColor(tile);
|
const td::Color* tileColor = world->GetTileColor(tile);
|
||||||
|
|
||||||
for (int i = 0; i < 6; i++) {
|
for (int i = 0; i < 6; i++) {
|
||||||
colors.push_back(tileColor->r);
|
int color = 255;
|
||||||
colors.push_back(tileColor->g);
|
color |= tileColor->r << 24;
|
||||||
colors.push_back(tileColor->b);
|
color |= tileColor->g << 16;
|
||||||
colors.push_back(255);
|
color |= tileColor->b << 8;
|
||||||
|
|
||||||
|
int newColorIndex = colors.size();
|
||||||
|
colors.push_back(0);
|
||||||
|
|
||||||
|
memcpy(colors.data() + newColorIndex, &color, 1 * sizeof(int));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -58,10 +64,15 @@ Mesh LoadWorldModel(const td::game::World* world) {
|
|||||||
positions.insert(positions.end(), {fromX, 0, fromY, fromX, 0, toY, toX, 0, fromY, fromX, 0, toY, toX, 0, toY, toX, 0, fromY});
|
positions.insert(positions.end(), {fromX, 0, fromY, fromX, 0, toY, toX, 0, fromY, fromX, 0, toY, toX, 0, toY, toX, 0, fromY});
|
||||||
|
|
||||||
for (int i = 0; i < 6; i++) {
|
for (int i = 0; i < 6; i++) {
|
||||||
colors.push_back(world->GetSpawnColor(TeamColor(spawnColor)).r);
|
int color = 255;
|
||||||
colors.push_back(world->GetSpawnColor(TeamColor(spawnColor)).g);
|
color |= world->GetSpawnColor(TeamColor(spawnColor)).r << 24;
|
||||||
colors.push_back(world->GetSpawnColor(TeamColor(spawnColor)).b);
|
color |= world->GetSpawnColor(TeamColor(spawnColor)).g << 16;
|
||||||
colors.push_back(255);
|
color |= world->GetSpawnColor(TeamColor(spawnColor)).b << 8;
|
||||||
|
|
||||||
|
int newColorIndex = colors.size();
|
||||||
|
colors.push_back(0);
|
||||||
|
|
||||||
|
memcpy(colors.data() + newColorIndex, &color, 1 * sizeof(int));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,31 +84,162 @@ Mesh LoadWorldModel(const td::game::World* world) {
|
|||||||
positions.insert(positions.end(), {fromX, 0, fromY, fromX, 0, toY, toX, 0, fromY, fromX, 0, toY, toX, 0, toY, toX, 0, fromY});
|
positions.insert(positions.end(), {fromX, 0, fromY, fromX, 0, toY, toX, 0, fromY, fromX, 0, toY, toX, 0, toY, toX, 0, fromY});
|
||||||
|
|
||||||
for (int i = 0; i < 6; i++) {
|
for (int i = 0; i < 6; i++) {
|
||||||
colors.push_back(world->GetSpawnColor(TeamColor(castleColor)).r);
|
int color = 255;
|
||||||
colors.push_back(world->GetSpawnColor(TeamColor(castleColor)).g);
|
color |= world->GetSpawnColor(TeamColor(castleColor)).r << 24;
|
||||||
colors.push_back(world->GetSpawnColor(TeamColor(castleColor)).b);
|
color |= world->GetSpawnColor(TeamColor(castleColor)).g << 16;
|
||||||
colors.push_back(255);
|
color |= world->GetSpawnColor(TeamColor(castleColor)).b << 8;
|
||||||
|
|
||||||
|
int newColorIndex = colors.size();
|
||||||
|
colors.push_back(0);
|
||||||
|
|
||||||
|
memcpy(colors.data() + newColorIndex, &color, 1 * sizeof(int));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mesh.vertexCount = positions.size() / 3;
|
GL::VertexBuffer positionVBO(positions, POSITION_VERTEX_SIZE);
|
||||||
mesh.triangleCount = mesh.vertexCount / 3;
|
positionVBO.AddVertexAttribPointer(0, POSITION_VERTEX_SIZE, 0);
|
||||||
|
GL::VertexBuffer colorVBO(colors, 1);
|
||||||
|
colorVBO.AddVertexAttribPointer(1, 1, 0);
|
||||||
|
|
||||||
const std::size_t verteciesSize = mesh.vertexCount * POSITION_VERTEX_SIZE * sizeof(float);
|
std::vector<unsigned int> indexes(positions.size() / 3, 0);
|
||||||
const std::size_t colorsSize = mesh.vertexCount * COLOR_VERTEX_SIZE * sizeof(unsigned char);
|
for (size_t i = 0; i < indexes.size(); i++) {
|
||||||
|
indexes[i] = i + 1;
|
||||||
|
}
|
||||||
|
|
||||||
mesh.vertices = (float*)MemAlloc(verteciesSize);
|
GL::ElementBuffer indexVBO(indexes);
|
||||||
mesh.colors = (unsigned char*)MemAlloc(colorsSize);
|
|
||||||
|
|
||||||
std::memcpy(reinterpret_cast<char*>(mesh.vertices), reinterpret_cast<const char*>(positions.data()), verteciesSize);
|
GL::VertexArray worldVao(std::move(indexVBO)); // each pos = 3 vertecies
|
||||||
std::memcpy(reinterpret_cast<char*>(mesh.colors), reinterpret_cast<const char*>(colors.data()), colorsSize);
|
worldVao.Bind();
|
||||||
|
worldVao.BindVertexBuffer(std::move(positionVBO));
|
||||||
UploadMesh(&mesh, false);
|
worldVao.BindVertexBuffer(std::move(colorVBO));
|
||||||
|
worldVao.Unbind();
|
||||||
return mesh;
|
return worldVao;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GL::VertexArray LoadTileSelectModel() {
|
||||||
|
std::vector<float> positions = {
|
||||||
|
-0.5f,
|
||||||
|
-0.5f,
|
||||||
|
-1.0f,
|
||||||
|
|
||||||
|
0.5f,
|
||||||
|
-0.5f,
|
||||||
|
-1.0f,
|
||||||
|
|
||||||
|
0.0f,
|
||||||
|
0.5f,
|
||||||
|
-1.0f,
|
||||||
|
|
||||||
|
1,
|
||||||
|
.01,
|
||||||
|
1,
|
||||||
|
|
||||||
|
0,
|
||||||
|
.01,
|
||||||
|
1,
|
||||||
|
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
};
|
||||||
|
|
||||||
|
int color = 255 << 24 | 255 << 16 | 255 << 8 | 150;
|
||||||
|
float colorFloat;
|
||||||
|
|
||||||
|
memcpy(reinterpret_cast<std::uint8_t*>(&colorFloat), &color, sizeof(float));
|
||||||
|
|
||||||
|
std::vector<float> colors(6, colorFloat);
|
||||||
|
|
||||||
|
GL::VertexBuffer positionVBO(positions, POSITION_VERTEX_SIZE);
|
||||||
|
positionVBO.AddVertexAttribPointer(0, POSITION_VERTEX_SIZE, 0);
|
||||||
|
GL::VertexBuffer colorVBO(colors, 1);
|
||||||
|
colorVBO.AddVertexAttribPointer(1, 1, 0);
|
||||||
|
|
||||||
|
std::vector<unsigned int> indexes(positions.size() / 3, 0);
|
||||||
|
// for (size_t i = 0; i < indexes.size(); i++) {
|
||||||
|
// indexes[i] = i + 1;
|
||||||
|
// }
|
||||||
|
GL::ElementBuffer indexVBO(indexes);
|
||||||
|
|
||||||
|
GL::VertexArray tileSelectVao(std::move(indexVBO));
|
||||||
|
tileSelectVao.Bind();
|
||||||
|
tileSelectVao.BindVertexBuffer(std::move(positionVBO));
|
||||||
|
tileSelectVao.BindVertexBuffer(std::move(colorVBO));
|
||||||
|
tileSelectVao.Unbind();
|
||||||
|
|
||||||
|
return tileSelectVao;
|
||||||
|
}
|
||||||
|
|
||||||
|
RenderData LoadTowerModel(const game::TowerPtr& tower) {
|
||||||
|
RenderData renderData;
|
||||||
|
|
||||||
|
float towerX, towerDX;
|
||||||
|
float towerY, towerDY;
|
||||||
|
|
||||||
|
if (tower->GetSize() == game::TowerSize::Little) {
|
||||||
|
towerX = tower->GetCenterX() - 1.5f;
|
||||||
|
towerDX = tower->GetCenterX() + 1.5f;
|
||||||
|
|
||||||
|
towerY = tower->GetCenterY() - 1.5f;
|
||||||
|
towerDY = tower->GetCenterY() + 1.5f;
|
||||||
|
} else {
|
||||||
|
towerX = tower->GetCenterX() - 2.5f;
|
||||||
|
towerDX = tower->GetCenterX() + 2.5f;
|
||||||
|
|
||||||
|
towerY = tower->GetCenterY() - 2.5f;
|
||||||
|
towerDY = tower->GetCenterY() + 2.5f;
|
||||||
|
}
|
||||||
|
std::vector<float> positions = {towerDX, 0.001, towerY, towerX, 0.001, towerY, towerX, 0.001, towerDY, towerDX, 0.001, towerY,
|
||||||
|
towerX, 0.001, towerDY, towerDX, 0.001, towerDY};
|
||||||
|
|
||||||
|
renderData.positions = positions;
|
||||||
|
|
||||||
|
std::uint8_t towerType = static_cast<std::uint8_t>(tower->GetType());
|
||||||
|
std::uint8_t r = 10 * towerType + 40, g = 5 * towerType + 30, b = 10 * towerType + 20;
|
||||||
|
|
||||||
|
float colorFloat;
|
||||||
|
int color = r << 24 | g << 16 | b << 8 | 255;
|
||||||
|
memcpy(&colorFloat, &color, sizeof(int));
|
||||||
|
|
||||||
|
std::vector<float> colors(6, colorFloat);
|
||||||
|
renderData.colors = colors;
|
||||||
|
|
||||||
|
return renderData;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
GL::VertexArray LoadMobModel() {
|
||||||
|
std::vector<float> positions = {
|
||||||
|
-0.5, 0, -0.5,
|
||||||
|
-0.5, 0, 0.5,
|
||||||
|
0.5, 0, -0.5,
|
||||||
|
|
||||||
|
0.5, 0, -0.5,
|
||||||
|
-0.5, 0, 0.5,
|
||||||
|
0.5, 0, 0.5
|
||||||
|
};
|
||||||
|
|
||||||
|
std::vector<unsigned int> indexes(positions.size() / 3, 0);
|
||||||
|
// for (size_t i = 0; i < indexes.size(); i++) {
|
||||||
|
// indexes[i] = i + 1;
|
||||||
|
// }
|
||||||
|
GL::ElementBuffer indexVBO(indexes);
|
||||||
|
|
||||||
|
GL::VertexBuffer positionVBO(positions, POSITION_VERTEX_SIZE);
|
||||||
|
positionVBO.AddVertexAttribPointer(0, POSITION_VERTEX_SIZE, 0);
|
||||||
|
|
||||||
|
GL::VertexArray mobVao(std::move(indexVBO)); // each pos = 1 color
|
||||||
|
mobVao.Bind();
|
||||||
|
mobVao.BindVertexBuffer(std::move(positionVBO));
|
||||||
|
mobVao.Unbind();
|
||||||
|
return mobVao;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} // namespace WorldLoader
|
} // namespace WorldLoader
|
||||||
|
|
||||||
|
|
||||||
} // namespace render
|
} // namespace render
|
||||||
} // namespace td
|
} // namespace td
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
#include <cassert>
|
#include "td/render/Renderer.h"
|
||||||
|
#include "td/render/loader/TextureLoader.h"
|
||||||
|
#include <memory>
|
||||||
#include <td/render/renderer/EntityRenderer.h>
|
#include <td/render/renderer/EntityRenderer.h>
|
||||||
|
|
||||||
#include <td/render/loader/WorldLoader.h>
|
#include <td/render/loader/WorldLoader.h>
|
||||||
@@ -6,21 +8,27 @@
|
|||||||
namespace td {
|
namespace td {
|
||||||
namespace render {
|
namespace render {
|
||||||
|
|
||||||
EntityRenderer::EntityRenderer(raylib::Camera& a_Camera, const game::WorldPtr& a_World) : Renderer(a_Camera), m_World(a_World), m_ZombieModel("assets/zombie.glb") {
|
EntityRenderer::EntityRenderer(Camera& a_Camera, const game::WorldPtr& a_World) : Renderer(a_Camera), m_World(a_World) {
|
||||||
|
m_EntityModel = ModelLoader::LoadModel("assets/zombie.fbx");
|
||||||
|
m_EntityTexture = std::make_unique<GL::Texture>(TextureLoader::LoadTexture("assets/zombie.png"));
|
||||||
|
m_Shader->Start();
|
||||||
|
m_Shader->SetColorEffect({1, 1, 1});
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityRenderer::~EntityRenderer() {
|
EntityRenderer::~EntityRenderer() {}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void EntityRenderer::Render(float a_Lerp) {
|
void EntityRenderer::Render(float a_Lerp) {
|
||||||
|
m_Shader->Start();
|
||||||
for (const auto& mob : m_World->GetMobList()) {
|
for (const auto& mob : m_World->GetMobList()) {
|
||||||
|
|
||||||
float x = Lerp<game::Mob>(*mob, a_Lerp, [](const game::Mob& a_Mob) { return static_cast<float>(a_Mob.m_Position.x); });
|
float x = Lerp<game::Mob>(*mob, a_Lerp, [](const game::Mob& a_Mob) { return static_cast<float>(a_Mob.m_Position.x); });
|
||||||
float z = Lerp<game::Mob>(*mob, a_Lerp, [](const game::Mob& a_Mob) { return static_cast<float>(a_Mob.m_Position.y); });
|
float z = Lerp<game::Mob>(*mob, a_Lerp, [](const game::Mob& a_Mob) { return static_cast<float>(a_Mob.m_Position.y); });
|
||||||
|
|
||||||
m_ZombieModel.Draw({x, .001, z}, 1.0f, {255, 255, 255, 255});
|
m_Shader->SetModelPos({x, .001, z});
|
||||||
|
m_EntityTexture->Bind();
|
||||||
|
Renderer::Render(m_EntityModel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include <td/render/renderer/PlayerListRenderer.h>
|
#include <td/render/renderer/PlayerListRenderer.h>
|
||||||
|
|
||||||
#include <td/render/RayGui.h>
|
#include <imgui.h>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
|
||||||
namespace td {
|
namespace td {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include <client/state/GameState.h>
|
#include <client/state/GameState.h>
|
||||||
#include <td/render/renderer/TimerRenderer.h>
|
#include <td/render/renderer/TimerRenderer.h>
|
||||||
|
|
||||||
#include <td/render/RayGui.h>
|
#include <imgui.h>
|
||||||
|
|
||||||
namespace td {
|
namespace td {
|
||||||
namespace render {
|
namespace render {
|
||||||
|
|||||||
@@ -5,18 +5,21 @@
|
|||||||
namespace td {
|
namespace td {
|
||||||
namespace render {
|
namespace render {
|
||||||
|
|
||||||
TowerRenderer::TowerRenderer(raylib::Camera& a_Camera, const game::WorldPtr& a_World) : Renderer(a_Camera), m_World(a_World), m_TowerModel("assets/turret.obj"), m_TowerTexture("assets/turret_diffuse.png") {
|
TowerRenderer::TowerRenderer(Camera& a_Camera, const game::WorldPtr& a_World) : Renderer(a_Camera), m_World(a_World) {
|
||||||
m_TowerModel.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = m_TowerTexture;
|
m_EntityVao = std::make_unique<GL::VertexArray>(WorldLoader::LoadMobModel());
|
||||||
|
m_Shader->Start();
|
||||||
|
m_Shader->SetColorEffect({0, 0, 1});
|
||||||
}
|
}
|
||||||
|
|
||||||
TowerRenderer::~TowerRenderer() {
|
TowerRenderer::~TowerRenderer() {}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void TowerRenderer::Render(float a_Lerp) {
|
void TowerRenderer::Render(float a_Lerp) {
|
||||||
|
m_Shader->Start();
|
||||||
for (const auto& tower : m_World->GetTowers()) {
|
for (const auto& tower : m_World->GetTowers()) {
|
||||||
m_TowerModel.Draw({tower->GetCenterX(), .001, tower->GetCenterY()}, 0.3f, {255, 255, 255, 255});
|
m_Shader->SetModelPos({tower->GetCenterX(), .001, tower->GetCenterY()});
|
||||||
|
Renderer::Render(*m_EntityVao);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,33 +1,32 @@
|
|||||||
|
#include <td/Maths.h>
|
||||||
#include <td/render/renderer/WorldRenderer.h>
|
#include <td/render/renderer/WorldRenderer.h>
|
||||||
|
|
||||||
#include <td/Maths.h>
|
|
||||||
#include <td/render/loader/WorldLoader.h>
|
#include <td/render/loader/WorldLoader.h>
|
||||||
|
|
||||||
#include <td/render/RayGui.h>
|
#include <imgui.h>
|
||||||
|
|
||||||
namespace td {
|
namespace td {
|
||||||
namespace render {
|
namespace render {
|
||||||
|
|
||||||
WorldRenderer::WorldRenderer(raylib::Camera& a_Camera, const game::WorldPtr& a_World) : Renderer(a_Camera) {
|
WorldRenderer::WorldRenderer(Camera& a_Camera, const game::WorldPtr& a_World) : Renderer(a_Camera) {
|
||||||
Mesh mesh = WorldLoader::LoadWorldModel(a_World.get());
|
m_WorldVao = std::make_unique<GL::VertexArray>(WorldLoader::LoadWorldModel(a_World.get()));
|
||||||
m_WorldModel = std::make_unique<raylib::Model>(mesh);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WorldRenderer::~WorldRenderer() {
|
WorldRenderer::~WorldRenderer() {}
|
||||||
}
|
|
||||||
|
|
||||||
void WorldRenderer::UpdateControls() {
|
void WorldRenderer::UpdateControls() {
|
||||||
if (ImGui::IsMouseDown(ImGuiMouseButton_Left)) {
|
if (ImGui::IsMouseDown(ImGuiMouseButton_Left)) {
|
||||||
constexpr float sensitivity = 1.0f;
|
constexpr float sensitivity = 1.0f;
|
||||||
float delta = ImGui::GetIO().DeltaTime;
|
float delta = ImGui::GetIO().DeltaTime;
|
||||||
auto mouseDelta = ImGui::GetIO().MouseDelta;
|
auto mouseDelta = ImGui::GetIO().MouseDelta;
|
||||||
m_Camera.position.x -= mouseDelta.x * delta * sensitivity;
|
m_Camera.SetCamPos(m_Camera.GetCamPos() + Vec3f{-mouseDelta.x * delta * sensitivity, 0, -mouseDelta.y * delta * sensitivity});
|
||||||
m_Camera.position.z -= mouseDelta.y * delta * sensitivity;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldRenderer::Render(float a_Lerp) {
|
void WorldRenderer::Render(float a_Lerp) {
|
||||||
m_WorldModel->Draw({}, 1.0f, {255, 255, 255, 255});
|
UpdateControls();
|
||||||
|
m_Shader->Start();
|
||||||
|
Renderer::Render(*m_WorldVao);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace render
|
} // namespace render
|
||||||
|
|||||||
@@ -4,16 +4,16 @@ namespace td {
|
|||||||
namespace shader {
|
namespace shader {
|
||||||
|
|
||||||
void CameraShaderProgram::SetProjectionMatrix(const Mat4f& proj) const {
|
void CameraShaderProgram::SetProjectionMatrix(const Mat4f& proj) const {
|
||||||
// LoadMat4(m_LocationProjection, proj);
|
LoadMat4(m_LocationProjection, proj);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CameraShaderProgram::SetViewMatrix(const Mat4f& view) const {
|
void CameraShaderProgram::SetViewMatrix(const Mat4f& view) const {
|
||||||
// LoadMat4(m_LocationView, view);
|
LoadMat4(m_LocationView, view);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CameraShaderProgram::GetAllUniformLocation() {
|
void CameraShaderProgram::GetAllUniformLocation() {
|
||||||
// m_LocationProjection = static_cast<unsigned int>(GetUniformLocation("projectionMatrix"));
|
m_LocationProjection = static_cast<unsigned int>(GetUniformLocation("projectionMatrix"));
|
||||||
// m_LocationView = static_cast<unsigned int>(GetUniformLocation("viewMatrix"));
|
m_LocationView = static_cast<unsigned int>(GetUniformLocation("viewMatrix"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -53,12 +53,16 @@ static const char vertexSource[] = R"(
|
|||||||
#version 330
|
#version 330
|
||||||
|
|
||||||
layout(location = 0) in vec3 position;
|
layout(location = 0) in vec3 position;
|
||||||
|
layout(location = 1) in vec2 texCoords;
|
||||||
|
|
||||||
uniform mat4 viewMatrix;
|
uniform mat4 viewMatrix;
|
||||||
uniform mat4 projectionMatrix;
|
uniform mat4 projectionMatrix;
|
||||||
uniform vec3 modelPosition;
|
uniform vec3 modelPosition;
|
||||||
|
|
||||||
|
out vec2 pass_textureCoords;
|
||||||
|
|
||||||
void main(void){
|
void main(void){
|
||||||
|
pass_textureCoords = texCoords;
|
||||||
gl_Position = projectionMatrix * viewMatrix * vec4(position + modelPosition, 1.0);
|
gl_Position = projectionMatrix * viewMatrix * vec4(position + modelPosition, 1.0);
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
@@ -66,40 +70,44 @@ void main(void){
|
|||||||
static const char fragmentSource[] = R"(
|
static const char fragmentSource[] = R"(
|
||||||
#version 330
|
#version 330
|
||||||
|
|
||||||
|
in vec2 pass_textureCoords;
|
||||||
|
|
||||||
out vec4 out_color;
|
out vec4 out_color;
|
||||||
|
|
||||||
uniform vec3 ColorEffect;
|
uniform vec3 ColorEffect;
|
||||||
|
uniform sampler2D textureSampler;
|
||||||
|
|
||||||
void main(void){
|
void main(void){
|
||||||
|
|
||||||
vec4 color = vec4(ColorEffect, 1.0);
|
vec4 color = vec4(ColorEffect, 1.0) * texture(textureSampler, pass_textureCoords);
|
||||||
|
|
||||||
if (color.a <= 0.1)
|
if (color.a <= 0.1)
|
||||||
discard;
|
discard;
|
||||||
|
|
||||||
out_color = color;
|
out_color = color;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
EntityShader::EntityShader() : CameraShaderProgram() {
|
EntityShader::EntityShader() : CameraShaderProgram() {
|
||||||
// ShaderProgram::LoadProgram(vertexSource, fragmentSource);
|
ShaderProgram::LoadProgram(vertexSource, fragmentSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EntityShader::GetAllUniformLocation() {
|
void EntityShader::GetAllUniformLocation() {
|
||||||
// CameraShaderProgram::GetAllUniformLocation();
|
CameraShaderProgram::GetAllUniformLocation();
|
||||||
// m_LocationColorEffect = static_cast<unsigned int>(GetUniformLocation("ColorEffect"));
|
m_LocationColorEffect = static_cast<unsigned int>(GetUniformLocation("ColorEffect"));
|
||||||
// m_LocationPosition = static_cast<unsigned int>(GetUniformLocation("modelPosition"));
|
m_LocationPosition = static_cast<unsigned int>(GetUniformLocation("modelPosition"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityShader::SetColorEffect(const Vec3f& color) {
|
void EntityShader::SetColorEffect(const Vec3f& color) {
|
||||||
// LoadVector(m_LocationColorEffect, color);
|
LoadVector(m_LocationColorEffect, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityShader::SetModelPos(const Vec3f& pos) const {
|
void EntityShader::SetModelPos(const Vec3f& pos) const {
|
||||||
// LoadVector(m_LocationPosition, pos);
|
LoadVector(m_LocationPosition, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace shader
|
} // namespace shader
|
||||||
|
|||||||
145
src/td/render/shader/ShaderProgram.cpp
Executable file
145
src/td/render/shader/ShaderProgram.cpp
Executable file
@@ -0,0 +1,145 @@
|
|||||||
|
/*
|
||||||
|
* ShaderProgram.cpp
|
||||||
|
*
|
||||||
|
* Created on: 31 janv. 2020
|
||||||
|
* Author: simon
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <td/render/shader/ShaderProgram.h>
|
||||||
|
#include <td/misc/Log.h>
|
||||||
|
#include <td/misc/Format.h>
|
||||||
|
|
||||||
|
#include <fstream>
|
||||||
|
#include <iostream>
|
||||||
|
#include <sstream>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
namespace td {
|
||||||
|
namespace shader {
|
||||||
|
|
||||||
|
ShaderProgram::ShaderProgram() :
|
||||||
|
m_ProgramID(0), m_VertexShaderID(0), m_FragmentShaderID(0) {
|
||||||
|
}
|
||||||
|
|
||||||
|
ShaderProgram::~ShaderProgram() {
|
||||||
|
CleanUp();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ShaderProgram::Start() const {
|
||||||
|
glUseProgram(m_ProgramID);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ShaderProgram::Stop() const {
|
||||||
|
glUseProgram(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int ShaderProgram::GetUniformLocation(const std::string& uniformName) const {
|
||||||
|
const int location = glGetUniformLocation(m_ProgramID, uniformName.c_str());
|
||||||
|
if (location == -1) {
|
||||||
|
utils::LOGD(utils::Format("Warning ! Uniform variable %s not found !", uniformName.c_str()));
|
||||||
|
}
|
||||||
|
return location;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ShaderProgram::LoadFloat(unsigned int location, float value) const {
|
||||||
|
glUniform1f(static_cast<GLint>(location), value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ShaderProgram::LoadInt(unsigned int location, int value) const {
|
||||||
|
glUniform1i(static_cast<GLint>(location), value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ShaderProgram::LoadVector(unsigned int location,
|
||||||
|
const Vec2f& vector) const {
|
||||||
|
glUniform2f(static_cast<GLint>(location), vector.x, vector.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ShaderProgram::LoadVector(unsigned int location,
|
||||||
|
const Vec3f& vector) const {
|
||||||
|
glUniform3f(static_cast<GLint>(location), vector.x, vector.y, vector.z);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ShaderProgram::LoadBoolean(unsigned int location, bool value) const {
|
||||||
|
glUniform1i(static_cast<GLint>(location), value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ShaderProgram::LoadMat4(unsigned int location, const Mat4f& mat) const {
|
||||||
|
glUniformMatrix4fv(static_cast<GLint>(location), 1, false, reinterpret_cast<const float*>(&mat));
|
||||||
|
}
|
||||||
|
|
||||||
|
void ShaderProgram::CleanUp() const {
|
||||||
|
Stop();
|
||||||
|
glDetachShader(m_ProgramID, m_VertexShaderID);
|
||||||
|
glDetachShader(m_ProgramID, m_FragmentShaderID);
|
||||||
|
glDeleteShader(m_VertexShaderID);
|
||||||
|
glDeleteShader(m_FragmentShaderID);
|
||||||
|
glDeleteProgram(m_ProgramID);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ShaderProgram::LoadProgramFile(const std::string& vertexFile,
|
||||||
|
const std::string& fragmentFile) {
|
||||||
|
m_VertexShaderID = static_cast<unsigned int>(LoadShaderFromFile(vertexFile, GL_VERTEX_SHADER));
|
||||||
|
m_FragmentShaderID = static_cast<unsigned int>(LoadShaderFromFile(fragmentFile, GL_FRAGMENT_SHADER));
|
||||||
|
m_ProgramID = glCreateProgram();
|
||||||
|
glAttachShader(m_ProgramID, m_VertexShaderID);
|
||||||
|
glAttachShader(m_ProgramID, m_FragmentShaderID);
|
||||||
|
glLinkProgram(m_ProgramID);
|
||||||
|
glValidateProgram(m_ProgramID);
|
||||||
|
GetAllUniformLocation();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ShaderProgram::LoadProgram(const std::string& vertexSource,
|
||||||
|
const std::string& fragmentSource) {
|
||||||
|
m_VertexShaderID = static_cast<unsigned int>(LoadShader(vertexSource, GL_VERTEX_SHADER));
|
||||||
|
m_FragmentShaderID = static_cast<unsigned int>(LoadShader(fragmentSource, GL_FRAGMENT_SHADER));
|
||||||
|
m_ProgramID = glCreateProgram();
|
||||||
|
glAttachShader(m_ProgramID, m_VertexShaderID);
|
||||||
|
glAttachShader(m_ProgramID, m_FragmentShaderID);
|
||||||
|
glLinkProgram(m_ProgramID);
|
||||||
|
glValidateProgram(m_ProgramID);
|
||||||
|
GetAllUniformLocation();
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int ShaderProgram::LoadShader(const std::string& source, GLenum type) {
|
||||||
|
unsigned int shaderID = glCreateShader(type);
|
||||||
|
|
||||||
|
const char* c_str = source.c_str();
|
||||||
|
int* null = 0;
|
||||||
|
glShaderSource(shaderID, 1, &c_str, null); // @suppress("Function cannot be resolved")
|
||||||
|
glCompileShader(shaderID);
|
||||||
|
GLint compilesuccessful;
|
||||||
|
glGetShaderiv(shaderID, GL_COMPILE_STATUS, &compilesuccessful);
|
||||||
|
if (!compilesuccessful) {
|
||||||
|
GLsizei size;
|
||||||
|
glGetShaderiv(shaderID, GL_INFO_LOG_LENGTH, &size);
|
||||||
|
std::vector<char> shaderError(static_cast<std::size_t>(size));
|
||||||
|
glGetShaderInfoLog(shaderID, size, &size, shaderError.data());
|
||||||
|
|
||||||
|
utils::LOGE("Could not compile shader !");
|
||||||
|
|
||||||
|
utils::LOGE(shaderError.data());
|
||||||
|
|
||||||
|
utils::LOGD(utils::Format("\nShader source : \n"
|
||||||
|
"------------------------------------------------------------------------------------------------------------------------------------\n"
|
||||||
|
"%s\n"
|
||||||
|
"------------------------------------------------------------------------------------------------------------------------------------\n"
|
||||||
|
, source.c_str()));
|
||||||
|
}
|
||||||
|
return shaderID;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int ShaderProgram::LoadShaderFromFile(const std::string& file, GLenum type) {
|
||||||
|
std::stringstream stream;
|
||||||
|
std::ifstream fileStream(file);
|
||||||
|
|
||||||
|
if (fileStream) {
|
||||||
|
stream << fileStream.rdbuf();
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return LoadShader(stream.str(), type);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace shader
|
||||||
|
} // namespace td
|
||||||
@@ -82,7 +82,7 @@ void main(void){
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
WorldShader::WorldShader() : CameraShaderProgram() {
|
WorldShader::WorldShader() : CameraShaderProgram() {
|
||||||
// ShaderProgram::LoadProgram(vertexSource, fragmentSource);
|
ShaderProgram::LoadProgram(vertexSource, fragmentSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace shader
|
} // namespace shader
|
||||||
|
|||||||
@@ -46,9 +46,6 @@ class DirectionTileVisitor : public game::TileHandler {
|
|||||||
|
|
||||||
void EntityMove::Tick(const game::World& a_World, WorldSnapshot& a_State, FpFloat a_Delta) {
|
void EntityMove::Tick(const game::World& a_World, WorldSnapshot& a_State, FpFloat a_Delta) {
|
||||||
for (auto& mob : a_State.m_Mobs) {
|
for (auto& mob : a_State.m_Mobs) {
|
||||||
if (mob->m_HasReachedCastle)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
auto tile = a_World.GetTile(static_cast<std::int32_t>(mob->m_Position.x), static_cast<std::int32_t>(mob->m_Position.y));
|
auto tile = a_World.GetTile(static_cast<std::int32_t>(mob->m_Position.x), static_cast<std::int32_t>(mob->m_Position.y));
|
||||||
Direction direction = mob->m_Direction;
|
Direction direction = mob->m_Direction;
|
||||||
if (tile) {
|
if (tile) {
|
||||||
@@ -59,8 +56,6 @@ void EntityMove::Tick(const game::World& a_World, WorldSnapshot& a_State, FpFloa
|
|||||||
auto directVector = GetUnitDirection(direction);
|
auto directVector = GetUnitDirection(direction);
|
||||||
mob->m_Position.x += directVector.x * a_Delta;
|
mob->m_Position.x += directVector.x * a_Delta;
|
||||||
mob->m_Position.y += directVector.y * a_Delta;
|
mob->m_Position.y += directVector.y * a_Delta;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,8 @@ add_rules("mode.debug", "mode.release")
|
|||||||
|
|
||||||
add_repositories("persson-repo https://git.ale-pri.com/Persson-dev/xmake-repo.git")
|
add_repositories("persson-repo https://git.ale-pri.com/Persson-dev/xmake-repo.git")
|
||||||
|
|
||||||
add_requires("rlimgui", "raylib-cpp", "splib 2.3.2", "zlib", "fpm", "enet6")
|
add_requires("imgui 1.92.0", {configs = {sdl3 = true, opengl3 = true}})
|
||||||
|
add_requires("libsdl3 3.2.16", "splib 2.3.2", "zlib", "glew", "fpm", "enet6", "assimp", "stb")
|
||||||
|
|
||||||
set_languages("c++20")
|
set_languages("c++20")
|
||||||
|
|
||||||
@@ -20,8 +21,9 @@ target("Tower-Defense2")
|
|||||||
add_includedirs("include", {public = true})
|
add_includedirs("include", {public = true})
|
||||||
set_kind("binary")
|
set_kind("binary")
|
||||||
add_files("src/**.cpp")
|
add_files("src/**.cpp")
|
||||||
add_packages("rlimgui", "raylib-cpp", "splib", "zlib", "fpm", "enet6", {public = true})
|
add_packages("libsdl3", "imgui", "glew", "splib", "zlib", "fpm", "assimp", "enet6", "stb", {public = true})
|
||||||
set_rundir(".")
|
set_rundir(".")
|
||||||
|
add_defines("TD_GL_LOADER_GLEW")
|
||||||
|
|
||||||
|
|
||||||
-- Tests
|
-- Tests
|
||||||
|
|||||||
Reference in New Issue
Block a user