Added Exceptions to RenderWindow

This commit is contained in:
Robert 2020-05-16 16:03:55 +02:00
parent fac88781aa
commit 615c297b3b
5 changed files with 10 additions and 17 deletions

View file

@ -13,6 +13,5 @@ target_link_libraries(${PNAME} PRIVATE
${CMAKE_BINARY_DIR}/3rdparty/SDL/SDL2d.lib
)
add_subdirectory(exceptions)
add_subdirectory(structures)
add_subdirectory(graphics)

View file

@ -1,4 +0,0 @@
target_sources(${PNAME} PRIVATE
${CMAKE_CURRENT_SORUCE_DIR}/Exceptions.hpp
${CMAKE_CURRENT_SOURCE_DIR}/ObjectCreationException.hpp
)

View file

@ -8,5 +8,5 @@
#include "ObjectCreationException.hpp"
#define THROW_IF_NOT( condition, exception ) ( condition ? throw execption : false )
#define THROW_IF( condition, exception ) ( condition ? false : throw execption )
#define THROW_IF_NOT( condition, exception ) ( condition ? throw exception : false )
#define THROW_IF( condition, exception ) ( condition ? false : throw exception )

View file

@ -1,4 +1,5 @@
#include "RenderWindow.hpp"
#include "../exceptions/Exceptions.hpp"
#define IS_NULLPTR( x ) (x == nullptr)
@ -28,17 +29,11 @@ namespace sdlu
SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
dimension.x, dimension.y,
windowFlags);
if (IS_NULLPTR(m_pWindow))
{
// TODO: Implement exception
return
}
THROW_IF(IS_NULLPTR(m_pWindow),
ObjectCreationException("Failed to create SDL_Window."));
m_pRenderer = SDL_CreateRenderer(m_pWindow, -1, rendererFlags);
if (IS_NULLPTR(m_pRenderer))
{
// TODO: Implement exception
return
}
THROW_IF(IS_NULLPTR(m_pRenderer),
ObjectCreationException("Failed to create SDL_Renderer."));
}
}

View file

@ -12,5 +12,8 @@ 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);
return 0;
}