Added protected OnEvent functions for inheritance

This commit is contained in:
Robert 2020-05-16 19:38:57 +02:00
parent 0611493afd
commit 10d19f7f58
6 changed files with 98 additions and 18 deletions

View file

@ -1,2 +1,30 @@
#pragma once
#include "SDLU.hpp"
#include "SDLU.hpp"
#include <iostream>
class MyWindow :
public sdlu::RenderWindow
{
public:
MyWindow(Uint32 width, Uint32 height, const char* title) :
RenderWindow(sdlu::Vector2u(width, height), title, NULL, NULL)
{
// Empty
}
};
void sdlu::RenderWindow::OnCreate()
{
std::cout << "Window was Created!" << std::endl;
}
bool sdlu::RenderWindow::OnResize()
{
std::cout << "Window was Resized!" << std::endl;
return false;
}
void sdlu::RenderWindow::OnClose()
{
std::cout << "Window was Closed!" << std::endl;
}

View file

@ -1,7 +1,5 @@
#include "header.hpp"
#include <iostream>
int main(int argc, char** argv)
{
sdlu::Vector2f vecA(.4f, -2.3f);
@ -13,7 +11,13 @@ int main(int argc, char** argv)
vec *= 1.8f;
std::cout << "Vector2f: " << vec.x << ", " << vec.y << std::endl;
sdlu::RenderWindow window;
window.Create(sdlu::Vec2u(800, 800), "First test window", NULL, NULL);
try {
MyWindow window(800, 800, "Test");
}
catch (sdlu::ObjectCreationException e)
{
std::cerr << e.what() << std::endl;
std::cerr << SDL_GetError() << std::endl;
}
return 0;
}