Added Exceptions to RenderWindow
This commit is contained in:
parent
fac88781aa
commit
615c297b3b
|
@ -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)
|
|
@ -1,4 +0,0 @@
|
|||
target_sources(${PNAME} PRIVATE
|
||||
${CMAKE_CURRENT_SORUCE_DIR}/Exceptions.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/ObjectCreationException.hpp
|
||||
)
|
|
@ -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 )
|
|
@ -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."));
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
Loading…
Reference in a new issue