Snapshot
This commit is contained in:
parent
5cf2c2442b
commit
47c7d729df
|
@ -2,6 +2,7 @@
|
||||||
# and include sub-projects here.
|
# and include sub-projects here.
|
||||||
#
|
#
|
||||||
cmake_minimum_required (VERSION 3.8)
|
cmake_minimum_required (VERSION 3.8)
|
||||||
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
|
||||||
project ("ComplexPlotting")
|
project ("ComplexPlotting")
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ endif()
|
||||||
# Add source to this project's executable.
|
# Add source to this project's executable.
|
||||||
add_executable (ComplexPlotting
|
add_executable (ComplexPlotting
|
||||||
"main.cpp"
|
"main.cpp"
|
||||||
)
|
"PlotWindow.hpp" "PlotWindow.cpp" "PlotWindowFactory.hpp" "PlotWindowManager.hpp")
|
||||||
|
|
||||||
target_include_directories(ComplexPlotting PRIVATE
|
target_include_directories(ComplexPlotting PRIVATE
|
||||||
${SDL2_INCLUDES}
|
${SDL2_INCLUDES}
|
||||||
|
|
33
ComplexPlotting/PlotWindow.cpp
Normal file
33
ComplexPlotting/PlotWindow.cpp
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
#include "PlotWindow.hpp"
|
||||||
|
|
||||||
|
PlotWindow::PlotWindow(std::string title) :
|
||||||
|
IWindow::IWindow(
|
||||||
|
UnitVector2u * 400,
|
||||||
|
UnitVector2i * SDL_WINDOWPOS_UNDEFINED,
|
||||||
|
title,
|
||||||
|
NULL)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void PlotWindow::OnEvent(const SDL_Event& e)
|
||||||
|
{
|
||||||
|
if (e.window.windowID != m_uWindowID)
|
||||||
|
return;
|
||||||
|
|
||||||
|
switch (e.window.type)
|
||||||
|
{
|
||||||
|
case SDL_WINDOWEVENT_CLOSE:
|
||||||
|
m_isWindowOpen = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PlotWindow::OnUpdate(double frametime)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PlotWindow::OnRender(SDL_Renderer* renderer)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
20
ComplexPlotting/PlotWindow.hpp
Normal file
20
ComplexPlotting/PlotWindow.hpp
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <SDL.h>
|
||||||
|
|
||||||
|
#include "Window.hpp"
|
||||||
|
|
||||||
|
using namespace sf;
|
||||||
|
|
||||||
|
class PlotWindow :
|
||||||
|
public IWindow
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PlotWindow(std::string title);
|
||||||
|
|
||||||
|
void OnEvent(const SDL_Event& e) override;
|
||||||
|
bool OnUpdate(double frametime) override;
|
||||||
|
void OnRender(SDL_Renderer* renderer) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
};
|
26
ComplexPlotting/PlotWindowManager.hpp
Normal file
26
ComplexPlotting/PlotWindowManager.hpp
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
#include "PlotWindow.hpp"
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
class PlotWindowManager
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PlotWindowManager() = delete;
|
||||||
|
PlotWindowManager& operator=(const PlotWindowManager& other) = delete;
|
||||||
|
|
||||||
|
static void MakeNew()
|
||||||
|
{
|
||||||
|
PlotWindows.emplace_back("Plot " + std::to_string(PlotWindowCount));
|
||||||
|
PlotWindowCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void HandleEvents()
|
||||||
|
{
|
||||||
|
for(auto plot : PlotWIndows)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
static inline Uint32 PlotWindowCount;
|
||||||
|
static std::vector<PlotWindow> PlotWindows;
|
||||||
|
};
|
|
@ -1,5 +1,8 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
|
#include "PlotWindow.hpp"
|
||||||
|
|
||||||
#undef main
|
#undef main
|
||||||
|
|
||||||
|
@ -7,5 +10,28 @@ int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
printf("Running on SDL %i.%i.%i\n", SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL);
|
printf("Running on SDL %i.%i.%i\n", SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL);
|
||||||
|
|
||||||
|
SDL_Init(SDL_INIT_VIDEO);
|
||||||
|
|
||||||
|
// Create and open some windows
|
||||||
|
PlotWindow window("Plot");
|
||||||
|
|
||||||
|
// Wait for window processes to end
|
||||||
|
SDL_Event e;
|
||||||
|
bool quit = false;
|
||||||
|
while (!quit)
|
||||||
|
{
|
||||||
|
while (SDL_PollEvent(&e))
|
||||||
|
{
|
||||||
|
if (e.type == SDL_QUIT)
|
||||||
|
quit = true;
|
||||||
|
|
||||||
|
window.OnEvent(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
window.OnUpdate(0);
|
||||||
|
|
||||||
|
window.OnRender(nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
Loading…
Reference in a new issue