Buildfix.

Don't use surfaces, SDL2_image lets you create a texture
directly.
This is missing the graphic files that the code seeks to
load so it will not run.
This commit is contained in:
Michele Santullo 2015-05-21 18:14:07 +02:00
parent bb7de4f4dd
commit 20a7e0450d
4 changed files with 9 additions and 9 deletions

View file

@ -4,6 +4,8 @@ set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -std=c++11 -g -O0 -Wall -Wex
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -std=c++11 -O3 -Wall -Wextra") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -std=c++11 -O3 -Wall -Wextra")
#string(COMPARE EQUAL CMAKE_BINARY_DIR CMAKE_SOURCE_DIR IN_SOURCE_BUILD) #string(COMPARE EQUAL CMAKE_BINARY_DIR CMAKE_SOURCE_DIR IN_SOURCE_BUILD)
add_definitions(-DWITH_VECTOR_IOSTREAM)
find_library(Boost 1.21.0 REQUIRED) find_library(Boost 1.21.0 REQUIRED)
include_directories(SYSTEM include_directories(SYSTEM

View file

@ -27,7 +27,7 @@
#include <algorithm> #include <algorithm>
#include <cassert> #include <cassert>
#if !defined(NDEBUG) #if defined(WITH_VECTOR_IOSTREAM)
#include <iostream> #include <iostream>
#endif #endif
@ -134,7 +134,7 @@ namespace cloonel {
#endif #endif
typedef Vector<int32_t, 2> int2; typedef Vector<int32_t, 2> int2;
#if !defined(NDEBUG) #if defined(WITH_VECTOR_IOSTREAM)
template <typename T, uint32_t S> template <typename T, uint32_t S>
std::ostream& operator<< ( std::ostream& parStream, const Vector<T, S>& parVector ) { std::ostream& operator<< ( std::ostream& parStream, const Vector<T, S>& parVector ) {
parStream << "<"; parStream << "<";

View file

@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
project(doorkeepertest CXX) project(doorkeepertest CXX)
include(FindPkgConfig) include(FindPkgConfig)
pkg_search_module(SDL2 REQUIRED sdl2 image) pkg_search_module(SDL2 REQUIRED sdl2)
pkg_search_module(SDL2IMAGE REQUIRED SDL2_image>=2.0.0) pkg_search_module(SDL2IMAGE REQUIRED SDL2_image>=2.0.0)
configure_file( configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}Config.h.in" "${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}Config.h.in"
@ -23,4 +23,5 @@ add_executable(${PROJECT_NAME}
target_link_libraries(${PROJECT_NAME} target_link_libraries(${PROJECT_NAME}
doorkeeper doorkeeper
${SDL2_LIBRARIES} ${SDL2_LIBRARIES}
${SDL2IMAGE_LIBRARIES}
) )

View file

@ -26,7 +26,6 @@ struct LayerWithData {
namespace { namespace {
typedef std::unique_ptr<SDL_Renderer, void(*)(SDL_Renderer*)> SDLRendererUPtr; typedef std::unique_ptr<SDL_Renderer, void(*)(SDL_Renderer*)> SDLRendererUPtr;
typedef std::unique_ptr<SDL_Window, void(*)(SDL_Window*)> SDLWindowUPtr; typedef std::unique_ptr<SDL_Window, void(*)(SDL_Window*)> SDLWindowUPtr;
typedef std::unique_ptr<SDL_Surface, void(*)(SDL_Surface*)> SDLSurfaceUPtr;
typedef std::unique_ptr<SDL_Texture, void(*)(SDL_Texture*)> SDLTextureUPtr; typedef std::unique_ptr<SDL_Texture, void(*)(SDL_Texture*)> SDLTextureUPtr;
struct SDLSimple { struct SDLSimple {
@ -81,12 +80,10 @@ int main() {
std::cout << "Total tiles: " << tiler.tiles_count() << '\n'; std::cout << "Total tiles: " << tiler.tiles_count() << '\n';
//Load resources //Load resources
SDLTextureUPtr tile_0, tile_1; SDLTextureUPtr tile_0(nullptr, &SDL_DestroyTexture), tile_1(nullptr, &SDL_DestroyTexture);
{ {
SDLSurfaceUPtr surf_0(IMG_Load("tile_0.png"), &SDL_FreeSurface); tile_0 = SDLTextureUPtr(IMG_LoadTexture(sdl_renderer.get(), "tile_0.png"), &SDL_DestroyTexture);
SDLSurfaceUPtr surf_1(IMG_Load("tile_1.png"), &SDL_FreeSurface); tile_1 = SDLTextureUPtr(IMG_LoadTexture(sdl_renderer.get(), "tile_1.png"), &SDL_DestroyTexture);
tile_0 = SDLTextureUPtr(SDL_CreateTextureFromSurface(sdl_renderer.get(), surf_0.get()), &SDL_DestroyTexture);
tile_1 = SDLTextureUPtr(SDL_CreateTextureFromSurface(sdl_renderer.get(), surf_1.get()), &SDL_DestroyTexture);
} }
//Main loop //Main loop