Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 20 additions & 98 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ set(DOENGINE_PREFERED_LANGUAGE 17)
set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_CXX_STANDARD ${DOENGINE_PREFERED_LANGUAGE})

set(SDL2IMAGE_INSTALL OFF)
set(BUILD_SHARED_LIBS FALSE)
set(SDL2_DISABLE_INSTALL OFF)
set(SDL2TTF_VENDORED TRUE)

Comment on lines -20 to -24
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Decided to move to fetchSDL cmake module

if(FETCH_SDL_FROM_GIT)
include(cmake-module/fetchSDLProjectFromSource.cmake)
else()
Expand All @@ -30,6 +25,26 @@ endif()

set(ASSETS_DIR ${CMAKE_SOURCE_DIR}/assets)

set(DOENGINE_LIBRARIES )
if(FETCH_SDL_FROM_GIT)
set(DOENGINE_LIBRARIES ${DOENGINE_LIBRARIES}
SDL2::SDL2
SDL2::SDL2main
SDL2_ttf
SDL2_image
SDL2_mixer
)
else()
set(DOENGINE_LIBRARIES ${DOENGINE_LIBRARIES}
SDL2
SDL2main
SDL2_ttf
SDL2_image
SDL2_mixer
GL
)
endif()

if(DOENGINE_TESTS)
enable_testing()
add_subdirectory(src/test)
Expand Down Expand Up @@ -131,103 +146,10 @@ add_library(${PROJECT_NAME}
${DOENGINE_SRC}
)

set(DOENGINE_LIBRARIES )
if(FETCH_SDL_FROM_GIT)
set(DOENGINE_LIBRARIES ${DOENGINE_LIBRARIES}
SDL2::SDL2
SDL2::SDL2main
SDL2_ttf
SDL2_image
SDL2_mixer
)
else()
set(DOENGINE_LIBRARIES ${DOENGINE_LIBRARIES}
SDL2
SDL2main
SDL2_ttf
SDL2_image
SDL2_mixer
GL
)
endif()

target_link_libraries(${PROJECT_NAME} PRIVATE ${DOENGINE_LIBRARIES})

message("Copying asssets to buils dir.")
file(COPY ${ASSETS_DIR}
DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
# install(TARGETS ${PROJECT_NAME} DESTINATION /home/afl/Desktop/doengine )


#add_executable(${PROJECT_NAME}-sample
# sample/ignored_main.cpp
#)
add_executable(${PROJECT_NAME}-pong-sample
sample/pong/SimplePong.cpp
)

add_executable(${PROJECT_NAME}-SpaceInvader-sample
sample/SpaceInvader/SpaceInvader.cpp
)

add_executable(${PROJECT_NAME}-Tetris-sample
sample/tetris/Tetris.cpp
)

add_executable(${PROJECT_NAME}-MusicPlayer-sample
sample/MusicPlayer/MusicPlayer.cpp
)
add_executable(BattleSpawn
sample/BattleSpawn/BattleSpawn.cpp
)
add_executable(PacmanClone
sample/Pacman/Pacman.cpp
)

add_executable(BattleCityRecreation
sample/BattleCityRecreation/BattleCityRecreation.cpp
)

# to build sample needs
# Zip support, ubuntu sudo apt-get install libzip-dev
#target_link_libraries(${PROJECT_NAME}-sample PRIVATE
# ${PROJECT_NAME}
# ${DOENGINE_LIBRARIES}
#)

target_link_libraries(${PROJECT_NAME}-pong-sample PRIVATE
${PROJECT_NAME}
${DOENGINE_LIBRARIES}
)

target_link_libraries(${PROJECT_NAME}-SpaceInvader-sample PRIVATE
${PROJECT_NAME}
${DOENGINE_LIBRARIES}
)

target_link_libraries(${PROJECT_NAME}-Tetris-sample PRIVATE
${PROJECT_NAME}
${DOENGINE_LIBRARIES}
)

target_link_libraries(${PROJECT_NAME}-MusicPlayer-sample PRIVATE
${PROJECT_NAME}
${DOENGINE_LIBRARIES}
)

target_link_libraries(BattleSpawn PRIVATE
${PROJECT_NAME}
${DOENGINE_LIBRARIES}
)

target_link_libraries(PacmanClone PRIVATE
${PROJECT_NAME}
${DOENGINE_LIBRARIES}
)


target_link_libraries(BattleCityRecreation PRIVATE
${PROJECT_NAME}
${DOENGINE_LIBRARIES}
)

Comment on lines -161 to -233
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to sample/CMakeLists.txt

11 changes: 11 additions & 0 deletions cmake-module/fetchSDLProjectFromSource.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@

include(FetchContent)

SET(SDL2IMAGE_INSTALL OFF)
SET(BUILD_SHARED_LIBS FALSE)
SET(SDL2_DISABLE_INSTALL OFF)
SET(SDL2TTF_VENDORED ON)

SET(SDL2IMAGE_SAMPLES OFF)
SET(SDL2IMAGE_TESTS OFF)
SET(SDL2IMAGE_AVIF OFF)
SET(SDL2IMAGE_VENDORED ON)

message("Fecthing SDL Source code")
# SDL2
# SET(SDL_SHARED FALSE)
Expand Down
6 changes: 3 additions & 3 deletions includes/DOEngine_SDL_includes.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ extern "C"
#include <SDL2/SDL_events.h>
#include <SDL2/SDL_joystick.h>
#include <SDL2/SDL_log.h>
#include <SDL2/SDL_image.h>
#include <SDL2/SDL_ttf.h>
#include <SDL2/SDL_mixer.h>
#include <SDL_image.h>
#include <SDL_ttf.h>
#include <SDL_mixer.h>
Comment on lines -11 to +13
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verify if this causes you problems @aneury1

}

#endif
140 changes: 105 additions & 35 deletions sample/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@ project(DOSAMPLE)
include_directories(DOSAMPLE PRIVATE ../includes)
include_directories(MUSIC_SAMPLE PRIVATE ../includes)

set(ASSETS_DIR_OUTPUT_DIR "")

if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
message(STATUS "Linux")
set(ASSETS_DIR_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}")
elseif (CMAKE_SYSTEM_NAME STREQUAL "Windows")
message(STATUS "Windows")
set(ASSETS_DIR_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}")
endif ()

file(COPY ${ASSETS_DIR}
DESTINATION "${ASSETS_DIR_OUTPUT_DIR}")

add_executable(DoSample
main.cpp
)
Expand All @@ -20,52 +33,109 @@ add_executable(Sound
add_executable(Particles
Particles/Particles.cpp
)
add_executable(VideoPlayer
VideoPlayer/VideoPlayer.cpp
)

file(COPY ${ASSETS_DIR}
DESTINATION ${CMAKE_CURRENT_BINARY_DIR})


target_link_libraries(DoSample PRIVATE
DOENGINE
SDL2
SDL2main
SDL2_ttf SDL2_image
SDL2_mixer)
${DOENGINE_LIBRARIES}
)

target_link_libraries(Music PRIVATE
DOENGINE
SDL2
SDL2main
SDL2_ttf SDL2_image
SDL2_mixer)
${DOENGINE_LIBRARIES}
)

target_link_libraries(Sound PRIVATE
DOENGINE
SDL2
SDL2main
SDL2_ttf SDL2_image
SDL2_mixer)
${DOENGINE_LIBRARIES}
)

target_link_libraries(Particles PRIVATE
DOENGINE
SDL2
SDL2main
SDL2_ttf SDL2_image
SDL2_mixer)
${DOENGINE_LIBRARIES}
)

if(NOT FETCH_SDL_FROM_GIT)
add_executable(VideoPlayer
VideoPlayer/VideoPlayer.cpp
)
# sudo apt install libsdl2-dev libavcodec-dev libavformat-dev libavutil-dev libswscale-dev
target_link_libraries(VideoPlayer PRIVATE
DOENGINE
${DOENGINE_LIBRARIES}
avformat
avcodec
avutil
swscale
)
endif()

#add_executable(${PROJECT_NAME}-sample
# sample/ignored_main.cpp
#)
add_executable(SimplePong
pong/SimplePong.cpp
)

add_executable(SpaceInvader
SpaceInvader/SpaceInvader.cpp
)

add_executable(Tetris
tetris/Tetris.cpp
)

add_executable(MusicPlayer
MusicPlayer/MusicPlayer.cpp
)
add_executable(BattleSpawn
BattleSpawn/BattleSpawn.cpp
)
add_executable(PacmanClone
Pacman/Pacman.cpp
)

add_executable(BattleCityRecreation
BattleCityRecreation/BattleCityRecreation.cpp
)

# to build sample needs
# Zip support, ubuntu sudo apt-get install libzip-dev
#target_link_libraries(${PROJECT_NAME}-sample PRIVATE
# ${PROJECT_NAME}
# ${DOENGINE_LIBRARIES}
#)

target_link_libraries(SimplePong PRIVATE
DOENGINE
${DOENGINE_LIBRARIES}
)

target_link_libraries(SpaceInvader PRIVATE
DOENGINE
${DOENGINE_LIBRARIES}
)

target_link_libraries(Tetris PRIVATE
DOENGINE
${DOENGINE_LIBRARIES}
)

target_link_libraries(MusicPlayer PRIVATE
DOENGINE
${DOENGINE_LIBRARIES}
)

target_link_libraries(BattleSpawn PRIVATE
DOENGINE
${DOENGINE_LIBRARIES}
)

target_link_libraries(PacmanClone PRIVATE
DOENGINE
${DOENGINE_LIBRARIES}
)

# sudo apt install libsdl2-dev libavcodec-dev libavformat-dev libavutil-dev libswscale-dev
target_link_libraries(VideoPlayer PRIVATE
target_link_libraries(BattleCityRecreation PRIVATE
DOENGINE
SDL2
SDL2main
SDL2_ttf
SDL2_image
SDL2_mixer
avformat
avcodec
avutil
swscale
)
${DOENGINE_LIBRARIES}
)
4 changes: 2 additions & 2 deletions sample/SpaceInvader/SpaceInvader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,13 +291,13 @@ struct SpacerInvaderState : public doengine::GameState
float gap = (wscreen - (wobstacle * cnt)) / 5;
for(int i=0;i<cnt;i++){
float offset_x = (i + 1) * gap + i * wobstacle;
obstacles.push_back(Obstacle{doengine::Rect{offset_x, 400,0,0}});
obstacles.push_back(Obstacle{doengine::Rect{static_cast<int>(offset_x), 400,0,0}});
}
bool practice_mode = false;
if(practice_mode){
for(int i=0;i<cnt;i++){
float offset_x = (i + 1) * gap + i * wobstacle;
obstacles.push_back(Obstacle{doengine::Rect{offset_x, 200,0,0}});
obstacles.push_back(Obstacle{doengine::Rect{static_cast<int>(offset_x), 200,0,0}});
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Application/SDLTTFText.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "SDLTTFText.h"
#include "Application.h"
#include "Logger.h"
#include <SDL2/SDL_ttf.h>
#include "DOEngine_SDL_includes.h"
#include <map>
#include <string>

Expand Down
4 changes: 1 addition & 3 deletions src/Application/SDLTexture.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
#include <SDL2/SDL_ttf.h>
#include "DOEngine_SDL_includes.h"
#include <iostream>

#include "Application.h"
Expand Down
4 changes: 2 additions & 2 deletions src/Application/SDLWindowManager.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "SDLWindowManager.h"
#include <SDL2/SDL_ttf.h>
#include <SDL2/SDL_image.h>
#include "DOEngine_SDL_includes.h"

namespace doengine
{
bool SDLWindowManager::createWindow()
Expand Down