Add the call to bcm_host_init/deinit() on raspberry pi.
This commit is contained in:
parent
0d2f584229
commit
6cf749c82c
2 changed files with 51 additions and 3 deletions
|
@ -7,10 +7,14 @@ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -std=c++11 -Wall -Wextra
|
|||
|
||||
option(WITH_BUILTIN_PHYSFS "Force using the version of PhysFS accompanying the code even if a system library is available" OFF)
|
||||
option(FORCE_OPENGLES "Try to chose the openGL ES renderer if available. Enable this on Raspberry Pi" OFF)
|
||||
option(RASPBERRY_PI "Compile for Raspberry Pi" OFF)
|
||||
|
||||
if (FORCE_OPENGLES)
|
||||
if (FORCE_OPENGLES OR RASPBERRY_PI)
|
||||
add_definitions(-DFORCE_OPENGLES)
|
||||
endif (FORCE_OPENGLES)
|
||||
if (RASPBERRY_PI)
|
||||
add_definitions(-DRASPBERRY_PI)
|
||||
endif(RASPBERRY_PI)
|
||||
endif (FORCE_OPENGLES OR RASPBERRY_PI)
|
||||
|
||||
include(FindPkgConfig)
|
||||
PKG_SEARCH_MODULE(SDL2 REQUIRED sdl2)
|
||||
|
@ -35,6 +39,16 @@ add_definitions(
|
|||
-DWITH_VERBOSE_COLLIDER
|
||||
)
|
||||
|
||||
if (RASPBERRY_PI)
|
||||
message(STATUS "Will build for Raspberry Pi")
|
||||
include_directories(SYSTEM
|
||||
/opt/vc/include
|
||||
)
|
||||
link_directories(
|
||||
/opt/vc/lib
|
||||
)
|
||||
endif (RASPBERRY_PI)
|
||||
|
||||
include_directories(SYSTEM
|
||||
${SDL2_INCLUDE_DIR}
|
||||
${PNG_INCLUDE_DIRS}
|
||||
|
@ -93,3 +107,9 @@ target_link_libraries(${PROJECT_NAME}
|
|||
${PHYSFS_LIBRARY}
|
||||
${PNG_LIBRARIES}
|
||||
)
|
||||
|
||||
if (RASPBERRY_PI)
|
||||
target_link_libraries(${PROJECT_NAME}
|
||||
bcm_host
|
||||
)
|
||||
endif(RASPBERRY_PI)
|
||||
|
|
|
@ -28,6 +28,10 @@
|
|||
#include <cstring>
|
||||
#include <utility>
|
||||
|
||||
#if defined(RASPBERRY_PI)
|
||||
#include <bcm_host.h>
|
||||
#endif
|
||||
|
||||
namespace cloonel {
|
||||
namespace {
|
||||
///----------------------------------------------------------------------
|
||||
|
@ -74,6 +78,9 @@ namespace cloonel {
|
|||
SizeRatio sizeratio;
|
||||
ObserversManager<SizeNotifiableBase*> resChangeNotifList;
|
||||
bool initialized;
|
||||
#if defined(RASPBERRY_PI)
|
||||
bool bcmInitialized;
|
||||
#endif
|
||||
};
|
||||
|
||||
///------------------------------------------------------------------------
|
||||
|
@ -83,12 +90,19 @@ namespace cloonel {
|
|||
m_localData(new LocalData)
|
||||
{
|
||||
m_localData->sizeratio.SetOriginal(static_cast<float2>(parReferenceRes), static_cast<float2>(parRes));
|
||||
m_localData->initialized = false;
|
||||
#if defined(RASPBERRY_PI)
|
||||
m_localData->bcmInitialized = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
///------------------------------------------------------------------------
|
||||
///------------------------------------------------------------------------
|
||||
SDLMain::~SDLMain() noexcept {
|
||||
ClearIFN(*m_localData);
|
||||
#if defined(RASPBERRY_PI)
|
||||
assert(not m_localData->bcmInitialized);
|
||||
#endif
|
||||
}
|
||||
|
||||
///------------------------------------------------------------------------
|
||||
|
@ -109,6 +123,12 @@ namespace cloonel {
|
|||
throw std::runtime_error(SDL_GetError());
|
||||
parInitSDL.initialized = true;
|
||||
|
||||
#if defined(RASPBERRY_PI)
|
||||
assert(not parInitSDL.bcmInitialized);
|
||||
bcm_host_init();
|
||||
parInitSDL.bcmInitialized = true;
|
||||
#endif
|
||||
|
||||
#if defined(FORCE_OPENGLES)
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
|
||||
#endif
|
||||
|
@ -134,8 +154,16 @@ namespace cloonel {
|
|||
SDL_DestroyRenderer(parInitSDL.renderer);
|
||||
if (parInitSDL.window)
|
||||
SDL_DestroyWindow(parInitSDL.window);
|
||||
if (parInitSDL.initialized)
|
||||
if (parInitSDL.initialized) {
|
||||
parInitSDL.initialized = false;
|
||||
SDL_Quit();
|
||||
}
|
||||
#if defined(RASPBERRY_PI)
|
||||
if (parInitSDL.bcmInitialized) {
|
||||
parInitSDL.bcmInitialized = false;
|
||||
bcm_host_deinit();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
///------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in a new issue