1
0
Fork 0
mirror of https://github.com/gwm17/Specter.git synced 2024-11-22 18:28:52 -05:00

Re-enabled windows support. Event builder now instanced outside application. Some premake cleanup.

This commit is contained in:
Gordon McCann 2022-01-08 22:36:16 -05:00
parent 58b6612a3e
commit 34bf7e741b
34 changed files with 104 additions and 62 deletions

View File

@ -9,7 +9,7 @@ int main(int argc, const char** argv)
NAV_TRACE("Logger Initialized!");
auto app = Navigator::CreateApplication();
auto evb = Navigator::CreatePhysicsEventBuilder();
app->Run();
delete app;

View File

@ -1,6 +1,7 @@
#ifndef NAVIGATOR_H
#define NAVIGATOR_H
#include <iostream>
#include <fstream>
#include <memory>

View File

@ -17,7 +17,6 @@ namespace Navigator {
/*order is important, must be pMap then evb*/
CreateParameterMap();
CreatePhysicsEventBuilder();
NavParameter par("joseph","mama");
par.SetValue(8);
@ -110,8 +109,8 @@ namespace Navigator {
void Application::Run()
{
PhysicsStartEvent junk("/media/gordon/GordonData/gwm17/NavTests/data/", DataSource::SourceType::CompassOffline, 2000000);
OnEvent(junk);
//PhysicsStartEvent junk("/media/gordon/GordonData/gwm17/NavTests/data/", DataSource::SourceType::CompassOffline, 2000000);
//OnEvent(junk);
while(m_runFlag)
{

View File

@ -14,7 +14,7 @@
namespace Navigator {
class Application
class NAV_API Application
{
public:
Application();
@ -49,7 +49,7 @@ namespace Navigator {
static Application* s_instance;
};
Application* CreateApplication();
NAV_API Application* CreateApplication();
}
#endif

View File

@ -1,11 +1,12 @@
#ifndef APP_EVENT_H
#define APP_EVENT_H
#include "Navigator/NavCore.h"
#include "Event.h"
namespace Navigator {
class WindowCloseEvent : public Event
class NAV_API WindowCloseEvent : public Event
{
public:
WindowCloseEvent() {};
@ -14,7 +15,7 @@ namespace Navigator {
EVENT_TYPE_SETUP(WindowClose)
};
class WindowResizeEvent : public Event
class NAV_API WindowResizeEvent : public Event
{
public:
WindowResizeEvent(float x, float y) :
@ -38,7 +39,7 @@ namespace Navigator {
float m_xSize, m_ySize;
};
class AppUpdateEvent : public Event
class NAV_API AppUpdateEvent : public Event
{
public:
AppUpdateEvent() = default;

View File

@ -5,7 +5,7 @@
namespace Navigator {
enum class EventType
enum class NAV_API EventType
{
None=0,
WindowClose, WindowResize, WindowFocus, WindowLostFocus, WindowMoved,
@ -15,7 +15,7 @@ namespace Navigator {
PhysicsStart, PhysicsStop
};
enum EventCategory
enum NAV_API EventCategory
{
EventCategoryNone=0,
EventCategoryApp=BIT(0),
@ -33,7 +33,7 @@ namespace Navigator {
virtual EventType GetEventType() const override { return GetStaticType(); } \
virtual const char* GetName() const override { return #type; }
class Event
class NAV_API Event
{
friend class EventDispatcher;
public:
@ -45,7 +45,7 @@ namespace Navigator {
bool handledFlag = false;
};
class EventDispatcher
class NAV_API EventDispatcher
{
template<typename T>
using EventFunc = std::function<bool(T&)>;
@ -74,7 +74,7 @@ namespace Navigator {
Event& m_event;
};
inline std::ostream& operator<<(std::ostream& os, const Event& e)
NAV_API inline std::ostream& operator<<(std::ostream& os, const Event& e)
{
return os << e.ToString();
}

View File

@ -1,11 +1,12 @@
#ifndef KEY_EVENT_H
#define KEY_EVENT_H
#include "Navigator/NavCore.h"
#include "Event.h"
namespace Navigator {
class KeyEvent : public Event
class NAV_API KeyEvent : public Event
{
public:
inline int GetKeycode() const { return m_keycode; }
@ -20,7 +21,7 @@ namespace Navigator {
};
class KeyPressedEvent : public KeyEvent
class NAV_API KeyPressedEvent : public KeyEvent
{
public:
KeyPressedEvent(int code, int count) :
@ -44,7 +45,7 @@ namespace Navigator {
int m_repeatCount;
};
class KeyReleasedEvent : public KeyEvent
class NAV_API KeyReleasedEvent : public KeyEvent
{
public:
KeyReleasedEvent(int code) :
@ -63,7 +64,7 @@ namespace Navigator {
};
class KeyTypedEvent : public KeyEvent
class NAV_API KeyTypedEvent : public KeyEvent
{
public:
KeyTypedEvent(int code) :

View File

@ -1,12 +1,12 @@
#ifndef MOUSE_EVENT_H
#define MOUSE_EVENT_H
#include "Navigator/NavCore.h"
#include "Event.h"
namespace Navigator {
class MouseMovedEvent : public Event
class NAV_API MouseMovedEvent : public Event
{
public:
MouseMovedEvent(float x, float y) :
@ -30,7 +30,7 @@ namespace Navigator {
float m_xPos, m_yPos;
};
class MouseScrolledEvent : public Event
class NAV_API MouseScrolledEvent : public Event
{
public:
MouseScrolledEvent(float x, float y) :
@ -54,7 +54,7 @@ namespace Navigator {
float m_xOffset, m_yOffset;
};
class MouseButtonPressedEvent : public Event
class NAV_API MouseButtonPressedEvent : public Event
{
public:
MouseButtonPressedEvent(int code) :
@ -77,7 +77,7 @@ namespace Navigator {
int m_buttonCode;
};
class MouseButtonReleasedEvent : public Event
class NAV_API MouseButtonReleasedEvent : public Event
{
public:
MouseButtonReleasedEvent(int code) :

View File

@ -1,12 +1,13 @@
#ifndef PHYSICS_EVENT_H
#define PHYSICS_EVENT_H
#include "Navigator/NavCore.h"
#include "Event.h"
#include "Navigator/Physics/DataSource.h"
namespace Navigator {
class PhysicsStartEvent : public Event
class NAV_API PhysicsStartEvent : public Event
{
public:
PhysicsStartEvent(const std::string& loc, DataSource::SourceType type, uint64_t window) :
@ -31,7 +32,7 @@ namespace Navigator {
uint64_t m_coincidenceWindow;
};
class PhysicsStopEvent : public Event
class NAV_API PhysicsStopEvent : public Event
{
public:
PhysicsStopEvent() {}

View File

@ -3,7 +3,7 @@
namespace Navigator {
class GraphicsContext
class NAV_API GraphicsContext
{
public:
virtual void Init() = 0;

View File

@ -1,9 +1,11 @@
#ifndef HISTOGRAM_H
#define HISTOGRAM_H
#include "NavCore.h"
namespace Navigator {
class Histogram
class NAV_API Histogram
{
public:
Histogram(const std::string& name, const std::string& param_x, const std::string& param_y="None") :
@ -26,7 +28,7 @@ namespace Navigator {
bool m_initFlag;
};
class Histogram1D : public Histogram
class NAV_API Histogram1D : public Histogram
{
public:
Histogram1D(const std::string& name, const std::string& param, int bins, double min, double max);
@ -47,7 +49,7 @@ namespace Navigator {
double m_xMax;
};
class Histogram2D : public Histogram
class NAV_API Histogram2D : public Histogram
{
public:
Histogram2D(const std::string& name, const std::string& param_x, const std::string& param_y, int bins_x, double min_x, double max_x,

View File

@ -1,11 +1,12 @@
#ifndef IMGUI_LAYER_H
#define IMGUI_LAYER_H
#include "Navigator/NavCore.h"
#include "Navigator/Layer.h"
namespace Navigator {
class ImGuiLayer : public Layer
class NAV_API ImGuiLayer : public Layer
{
public:
ImGuiLayer();

View File

@ -1,11 +1,12 @@
#ifndef LAYER_H
#define LAYER_H
#include "NavCore.h"
#include "Events/Event.h"
namespace Navigator {
class Layer
class NAV_API Layer
{
public:
Layer(const std::string& name="Layer");

View File

@ -6,7 +6,7 @@
namespace Navigator {
class LayerStack
class NAV_API LayerStack
{
public:
LayerStack();

View File

@ -1,12 +1,13 @@
#ifndef LOGGER_H
#define LOGGER_H
#include "NavCore.h"
#include "spdlog/spdlog.h"
#include "spdlog/fmt/ostr.h"
namespace Navigator {
class Logger
class NAV_API Logger
{
public:

View File

@ -1,8 +1,15 @@
#ifndef NAVCORE_H
#define NAVCORE_H
#ifdef NAV_WINDOWS
#error "Navigator is not compatible with Windows!"
#ifdef NAV_EXPORT
#define NAV_API __declspec(dllexport)
#else
#define NAV_API __declspec(dllimport)
#endif
#else
#define NAV_API
#endif

View File

@ -1,11 +1,12 @@
#ifndef PARAMETER_MAP_H
#define PARAMETER_MAP_H
#include "NavCore.h"
#include <atomic>
namespace Navigator {
struct ParameterData
struct NAV_API ParameterData
{
std::atomic<double> value=0.0;
std::atomic<bool> validFlag=false;
@ -15,7 +16,7 @@ namespace Navigator {
For use inside of the physics thread only!!!!!! Do not use elsewhere as complex operations on parameter values are !not!
guaranteed to be thread-safe, only the accesing is!
*/
class NavParameter
class NAV_API NavParameter
{
public:
@ -36,7 +37,7 @@ namespace Navigator {
/*
Global parameter accesing, storage
*/
class ParameterMap
class NAV_API ParameterMap
{
public:
@ -62,7 +63,7 @@ namespace Navigator {
};
ParameterMap* CreateParameterMap();
NAV_API ParameterMap* CreateParameterMap();
}
#endif

View File

@ -13,7 +13,7 @@
namespace Navigator {
class AnalysisStack
class NAV_API AnalysisStack
{
public:
AnalysisStack();

View File

@ -1,11 +1,12 @@
#ifndef ANALYSIS_STAGE_H
#define ANALYSIS_STAGE_H
#include "Navigator/NavCore.h"
#include "CompassHit.h"
namespace Navigator {
class AnalysisStage
class NAV_API AnalysisStage
{
public:
using RawPhysicsEvent = std::vector<CompassHit>;

View File

@ -11,12 +11,13 @@
#ifndef COMPASSFILE_H
#define COMPASSFILE_H
#include "Navigator/NavCore.h"
#include "CompassHit.h"
#include "ShiftMap.h"
namespace Navigator {
class CompassFile
class NAV_API CompassFile
{
public:

View File

@ -1,9 +1,11 @@
#ifndef COMPASS_HIT_H
#define COMPASS_HIT_H
#include "Navigator/NavCore.h"
namespace Navigator {
struct CompassHit
struct NAV_API CompassHit
{
uint16_t board = 0;
uint16_t channel = 0;

View File

@ -10,6 +10,7 @@
#ifndef COMPASSRUN_H
#define COMPASSRUN_H
#include "Navigator/NavCore.h"
#include "DataSource.h"
#include "CompassFile.h"
#include "ShiftMap.h"
@ -17,7 +18,7 @@
namespace Navigator {
class CompassRun : public DataSource
class NAV_API CompassRun : public DataSource
{
public:

View File

@ -1,11 +1,12 @@
#ifndef DATA_SOURCE_H
#define DATA_SOURCE_H
#include "Navigator/NavCore.h"
#include "CompassHit.h"
namespace Navigator {
class DataSource
class NAV_API DataSource
{
public:
enum class SourceType
@ -28,9 +29,9 @@ namespace Navigator {
bool m_validFlag;
};
DataSource* CreateDataSource(const std::string& loc, DataSource::SourceType type);
NAV_API DataSource* CreateDataSource(const std::string& loc, DataSource::SourceType type);
std::string ConvertDataSourceTypeToString(DataSource::SourceType type);
NAV_API std::string ConvertDataSourceTypeToString(DataSource::SourceType type);
}
#endif

View File

@ -11,7 +11,7 @@
namespace Navigator {
class PhysicsEventBuilder
class NAV_API PhysicsEventBuilder
{
public:
PhysicsEventBuilder();
@ -26,7 +26,7 @@ namespace Navigator {
void PushStage(AnalysisStage* stage);
bool IsRunning() { return m_runFlag; }
inline static PhysicsEventBuilder& Get() { return *s_instance; }
static PhysicsEventBuilder& Get() { return *s_instance; }
private:
AnalysisStack m_physStack;
@ -40,7 +40,7 @@ namespace Navigator {
};
PhysicsEventBuilder* CreatePhysicsEventBuilder();
NAV_API PhysicsEventBuilder* CreatePhysicsEventBuilder();
}

View File

@ -1,11 +1,12 @@
#ifndef PHYSICS_HIT_SORT_H
#define PHYSICS_HIT_SORT_H
#include "Navigator/NavCore.h"
#include "CompassHit.h"
namespace Navigator {
class PhysicsHitSort
class NAV_API PhysicsHitSort
{
public:
using RawPhysicsEvent = std::vector<CompassHit>;

View File

@ -12,9 +12,11 @@
#ifndef SHIFTMAP_H
#define SHIFTMAP_H
#include "Navigator/NavCore.h"
namespace Navigator {
class ShiftMap
class NAV_API ShiftMap
{
public:
ShiftMap();

View File

@ -1,11 +1,12 @@
#ifndef RENDER_COMMAND_H
#define RENDER_COMMAND_H
#include "Navigator/NavCore.h"
#include "RendererAPI.h"
namespace Navigator {
class RenderCommand
class NAV_API RenderCommand
{
public:
inline static void SetClearColor(const float* color_array) { s_api->SetClearColor(color_array); }

View File

@ -1,12 +1,13 @@
#ifndef RENDERER_H
#define RENDERER_H
#include "Navigator/NavCore.h"
#include "RendererAPI.h"
#include "RenderCommand.h"
namespace Navigator {
class Renderer
class NAV_API Renderer
{
public:

View File

@ -1,9 +1,11 @@
#ifndef RENDERER_API_H
#define RENDERER_API_H
#include "Navigator/NavCore.h"
namespace Navigator {
class RendererAPI
class NAV_API RendererAPI
{
public:
enum class API

View File

@ -6,7 +6,7 @@
namespace Navigator {
class WindowProperties
class NAV_API WindowProperties
{
public:
unsigned int width, height;
@ -19,7 +19,7 @@ namespace Navigator {
};
class Window
class NAV_API Window
{
public:

View File

@ -1,13 +1,14 @@
#ifndef OPEGL_CONTEXT_H
#define OPEGL_CONTEXT_H
#include "Navigator/NavCore.h"
#include "Navigator/GraphicsContext.h"
struct GLFWwindow;
namespace Navigator {
class OpenGLContext : public GraphicsContext
class NAV_API OpenGLContext : public GraphicsContext
{
public:
OpenGLContext(GLFWwindow* window);

View File

@ -1,11 +1,12 @@
#ifndef OPENGL_RENDERER_API_H
#define OPENGL_RENDERER_API_H
#include "Navigator/NavCore.h"
#include "Navigator/Renderer/RendererAPI.h"
namespace Navigator {
class OpenGLRendererAPI : public RendererAPI
class NAV_API OpenGLRendererAPI : public RendererAPI
{
public:
virtual void Clear() override;

View File

@ -1,13 +1,14 @@
#ifndef OPENGL_WINDOW_H
#define OPENGL_WINDOW_H
#include "Navigator/NavCore.h"
#include "Navigator/Window.h"
#include "Navigator/GraphicsContext.h"
#include "GLFW/glfw3.h"
namespace Navigator {
class OpenGLWindow : public Window
class NAV_API OpenGLWindow : public Window
{
public:

View File

@ -24,7 +24,6 @@ project "Navigator"
kind "SharedLib"
language "C++"
cppdialect "C++17"
staticruntime "on"
targetdir ("lib/" .. outputdir .. "/%{prj.name}")
objdir ("bin-int/" .. outputdir .. "/%{prj.name}")
@ -84,8 +83,6 @@ project "Navigator"
defines "NAV_LINUX"
links {
"GL",
"GLU",
"glut",
"X11",
"dl"
}
@ -106,6 +103,14 @@ project "Navigator"
"-pthread",
"-undefined dynamic_lookup"
}
filter "system:windows"
defines "NAV_EXPORT"
postbuildcommands {
("{COPY} %{cfg.buildtarget.relpath} \"../bin/" .. outputdir .. "/NavProject/\"")
}
links {
"opengl32.lib"
}
filter "configurations:Debug"
defines "NAV_DEBUG"
@ -147,6 +152,7 @@ project "NavProject"
systemversion "latest"
filter "system:macosx"
defines "NAV_APPLE"
sysincludedirs {
"Navigator/vendor/spdlog/include/",
"%{IncludeDirs.glfw}",
@ -154,6 +160,10 @@ project "NavProject"
"%{IncludeDirs.glad}",
"%{IncludeDirs.ImPlot}"
}
filter "system:windows"
defines "NAV_WINDOWS"
filter "system:linux"
defines "NAV_LINUX"