This commit is contained in:
Robert 2020-08-18 19:29:04 +02:00
parent 5cf2c2442b
commit 47c7d729df
6 changed files with 107 additions and 1 deletions

View file

@ -2,6 +2,7 @@
# and include sub-projects here.
#
cmake_minimum_required (VERSION 3.8)
set(CMAKE_CXX_STANDARD 17)
project ("ComplexPlotting")

View file

@ -14,7 +14,7 @@ endif()
# Add source to this project's executable.
add_executable (ComplexPlotting
"main.cpp"
)
"PlotWindow.hpp" "PlotWindow.cpp" "PlotWindowFactory.hpp" "PlotWindowManager.hpp")
target_include_directories(ComplexPlotting PRIVATE
${SDL2_INCLUDES}

View 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;
}

View 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:
};

View 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;
};

View file

@ -1,5 +1,8 @@
#include <stdio.h>
#include <vector>
#include <SDL.h>
#include "PlotWindow.hpp"
#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);
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;
}