Fix up minimal dependency case and clang support.
This commit is contained in:
parent
925f0c3ccd
commit
1adc9272f8
17 changed files with 183 additions and 226 deletions
|
@ -1,3 +1,7 @@
|
|||
set(APP_NAME sample_gui)
|
||||
|
||||
message(STATUS "Checking dependencies for app: " ${APP_NAME})
|
||||
|
||||
list(APPEND client_HEADERS
|
||||
MediaTool.h
|
||||
text_editor/TextEditorView.h
|
||||
|
@ -31,18 +35,22 @@ list(APPEND client_LIB_INCLUDES
|
|||
web_client/WebClientView.cpp
|
||||
MediaTool.cpp)
|
||||
|
||||
set(DEPENDENCIES_FOUND True)
|
||||
if(WIN32)
|
||||
add_executable(sample_gui WIN32 gui-main-win.cpp ${client_LIB_INCLUDES})
|
||||
add_executable(${APP_NAME} WIN32 gui-main-win.cpp ${client_LIB_INCLUDES})
|
||||
else()
|
||||
find_package(X11 QUIET)
|
||||
if(X11_FOUND)
|
||||
add_executable(sample_gui gui-main.cpp ${client_LIB_INCLUDES} ${client_HEADERS})
|
||||
add_executable(${APP_NAME} gui-main.cpp ${client_LIB_INCLUDES} ${client_HEADERS})
|
||||
else()
|
||||
message(STATUS "Skipping sample GUI as no X11 dev support")
|
||||
message(STATUS "X11 not found - skipping")
|
||||
set(DEPENDENCIES_FOUND FALSE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
target_include_directories(sample_gui PUBLIC
|
||||
|
||||
if(DEPENDENCIES_FOUND)
|
||||
target_include_directories(${APP_NAME} PUBLIC
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/text_editor"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/audio_editor"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/image_editor"
|
||||
|
@ -50,7 +58,7 @@ target_include_directories(sample_gui PUBLIC
|
|||
"${CMAKE_CURRENT_SOURCE_DIR}/canvas"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/mesh_viewer"
|
||||
)
|
||||
target_link_libraries(sample_gui PUBLIC client windows console core network database geometry audio web)
|
||||
set_property(TARGET sample_gui PROPERTY FOLDER apps)
|
||||
|
||||
target_link_libraries(${APP_NAME} PUBLIC client windows console core network database geometry audio web)
|
||||
set_property(TARGET ${APP_NAME} PROPERTY FOLDER apps)
|
||||
endif()
|
||||
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
#include "AudioManager.h"
|
||||
|
||||
#ifdef __linux__
|
||||
#ifdef HAS_ALSA
|
||||
#include "AlsaInterface.h"
|
||||
#else
|
||||
#include "NullAudioInterface.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
AudioManager::AudioManager()
|
||||
|
@ -9,7 +13,11 @@ AudioManager::AudioManager()
|
|||
mAudioInterface()
|
||||
{
|
||||
#ifdef __linux__
|
||||
#ifdef HAS_ALSA
|
||||
mAudioInterface = AlsaInterface::Create();
|
||||
#else
|
||||
mAudioInterface = NullAudioInterface::Create();
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -1,38 +1,38 @@
|
|||
set(MODULE_NAME audio)
|
||||
|
||||
set(platform_HEADERS "")
|
||||
set(platform_INCLUDES "")
|
||||
|
||||
message(STATUS "Checking dependencies for module: " ${MODULE_NAME})
|
||||
if (UNIX)
|
||||
find_package(ALSA QUIET)
|
||||
if(ALSA_FOUND)
|
||||
list(APPEND platform_HEADERS
|
||||
list(APPEND PLATFORM_HEADERS
|
||||
audio_interfaces/AlsaInterface.h
|
||||
${ALSA_INCLUDE_DIRS})
|
||||
list(APPEND platform_INCLUDES
|
||||
list(APPEND PLATFORM_SOURCES
|
||||
audio_interfaces/AlsaInterface.cpp
|
||||
)
|
||||
list(APPEND platform_LIBS
|
||||
list(APPEND PLATFORM_LIBS
|
||||
${ALSA_LIBRARIES}
|
||||
)
|
||||
)
|
||||
list(APPEND DEFINES "HAS_ALSA")
|
||||
else()
|
||||
message(STATUS "ALSA package not found - not building audio interface.")
|
||||
list(APPEND platform_HEADERS
|
||||
message(STATUS "ALSA not found - skipping support")
|
||||
list(APPEND PLATFORM_HEADERS
|
||||
audio_interfaces/NullAudioInterface.h
|
||||
)
|
||||
list(APPEND platform_INCLUDES
|
||||
list(APPEND PLATFORM_SOURCES
|
||||
audio_interfaces/NullAudioInterface.cpp
|
||||
)
|
||||
endif()
|
||||
else()
|
||||
list(APPEND platform_HEADERS
|
||||
list(APPEND PLATFORM_HEADERS
|
||||
audio_interfaces/WasapiInterface.h
|
||||
)
|
||||
list(APPEND platform_INCLUDES
|
||||
list(APPEND PLATFORM_SOURCES
|
||||
audio_interfaces/WasapiInterface.cpp
|
||||
)
|
||||
endif (UNIX)
|
||||
|
||||
list(APPEND audio_HEADERS
|
||||
list(APPEND TARGET_HEADERS
|
||||
AudioDevice.h
|
||||
AudioManager.h
|
||||
AudioTrack.h
|
||||
|
@ -47,9 +47,9 @@ list(APPEND audio_HEADERS
|
|||
midi/MidiEvent.h
|
||||
midi/MetaMidiEvent.h
|
||||
midi/MidiChannelEvent.h
|
||||
${platform_HEADERS})
|
||||
${PLATFORM_HEADERS})
|
||||
|
||||
list(APPEND audio_LIB_INCLUDES
|
||||
list(APPEND TARGET_SOURCES
|
||||
AudioDevice.cpp
|
||||
AudioManager.cpp
|
||||
AudioSample.cpp
|
||||
|
@ -65,16 +65,17 @@ list(APPEND audio_LIB_INCLUDES
|
|||
midi/MidiEvent.cpp
|
||||
midi/MetaMidiEvent.cpp
|
||||
midi/MidiChannelEvent.cpp
|
||||
${platform_INCLUDES})
|
||||
${PLATFORM_SOURCES})
|
||||
|
||||
add_library(audio SHARED ${audio_LIB_INCLUDES} ${platform_INCLUDES} ${audio_HEADERS} ${platform_HEADERS})
|
||||
target_include_directories(audio PUBLIC
|
||||
add_library(${MODULE_NAME} SHARED ${TARGET_HEADERS} ${TARGET_SOURCES})
|
||||
target_include_directories(${MODULE_NAME} PUBLIC
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/audio_interfaces"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/midi"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/midi/reader"
|
||||
)
|
||||
|
||||
target_link_libraries(audio PUBLIC core ${platform_LIBS})
|
||||
set_target_properties( audio PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON )
|
||||
set_property(TARGET audio PROPERTY FOLDER src)
|
||||
target_compile_definitions(${MODULE_NAME} PRIVATE ${DEFINES})
|
||||
target_link_libraries(${MODULE_NAME} PUBLIC core ${PLATFORM_LIBS})
|
||||
set_target_properties(${MODULE_NAME} PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON)
|
||||
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER src)
|
|
@ -1,141 +1,31 @@
|
|||
#include "AlsaInterface.h"
|
||||
#include "NullAudioInterface.h"
|
||||
#include "FileLogger.h"
|
||||
|
||||
#include "AudioSynth.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
AlsaInterface::AlsaInterface()
|
||||
:mHandle(),
|
||||
mHardwareParams(),
|
||||
mPeriodSize(8192)
|
||||
NullAudioInterface::NullAudioInterface()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
AlsaInterface::~AlsaInterface()
|
||||
NullAudioInterface::~NullAudioInterface()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::unique_ptr<AlsaInterface> AlsaInterface::Create()
|
||||
std::unique_ptr<NullAudioInterface> NullAudioInterface::Create()
|
||||
{
|
||||
return std::make_unique<AlsaInterface>();
|
||||
return std::make_unique<NullAudioInterface>();
|
||||
}
|
||||
|
||||
void AlsaInterface::OpenDevice(const AudioDevicePtr& device)
|
||||
void NullAudioInterface::OpenDevice(const AudioDevicePtr& device)
|
||||
{
|
||||
MLOG_INFO("Opening Device");
|
||||
snd_pcm_stream_t stream = SND_PCM_STREAM_PLAYBACK;
|
||||
if (snd_pcm_open(&mHandle, device->GetName().c_str(), stream, 0) < 0)
|
||||
{
|
||||
MLOG_ERROR("Error opening PCM device: " + device->GetName());
|
||||
return;
|
||||
}
|
||||
|
||||
snd_pcm_hw_params_alloca(&mHardwareParams);
|
||||
if (snd_pcm_hw_params_any(mHandle, mHardwareParams) < 0)
|
||||
{
|
||||
MLOG_ERROR("Can not configure this PCM device.");
|
||||
return;
|
||||
}
|
||||
|
||||
SetAccessType(device);
|
||||
SetSampleFormat(device);
|
||||
SetSampleRate(device);
|
||||
SetPeriod(device);
|
||||
SetBufferSize(device);
|
||||
SetChannelNumber(device);
|
||||
|
||||
/* Apply HW parameter settings to */
|
||||
/* PCM device and prepare device */
|
||||
if (snd_pcm_hw_params(mHandle, mHardwareParams) < 0) {
|
||||
MLOG_ERROR("Error setting HW params.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void AlsaInterface::SetAccessType(const AudioDevicePtr& device)
|
||||
void NullAudioInterface::Play(const AudioDevicePtr& device)
|
||||
{
|
||||
if (snd_pcm_hw_params_set_access(mHandle, mHardwareParams, SND_PCM_ACCESS_RW_INTERLEAVED) < 0) {
|
||||
MLOG_ERROR("Error setting device access.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void AlsaInterface::SetSampleFormat(const AudioDevicePtr& device)
|
||||
{
|
||||
/* Set sample format */
|
||||
if (snd_pcm_hw_params_set_format(mHandle, mHardwareParams, SND_PCM_FORMAT_S16_LE) < 0) {
|
||||
MLOG_ERROR("Error setting format. ");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void AlsaInterface::SetSampleRate(const AudioDevicePtr& device)
|
||||
{
|
||||
unsigned rate = device->GetSampleRate();
|
||||
unsigned exact_rate = rate;
|
||||
if (snd_pcm_hw_params_set_rate_near(mHandle, mHardwareParams, &exact_rate, 0) < 0)
|
||||
{
|
||||
MLOG_ERROR("Error setting rate. ");
|
||||
return;
|
||||
}
|
||||
if (rate != exact_rate) {
|
||||
MLOG_ERROR("The rate is not supported by your hardware.");
|
||||
}
|
||||
}
|
||||
|
||||
void AlsaInterface::SetPeriod(const AudioDevicePtr& device)
|
||||
{
|
||||
/* Set number of periods. Periods used to be called fragments. */
|
||||
if (snd_pcm_hw_params_set_periods(mHandle, mHardwareParams, device->GetPeriod(), 0) < 0)
|
||||
{
|
||||
MLOG_ERROR("Error setting periods. ");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void AlsaInterface::SetBufferSize(const AudioDevicePtr& device)
|
||||
{
|
||||
int periods = static_cast<int>(device->GetPeriod());
|
||||
|
||||
/* Set buffer size (in frames). The resulting latency is given by */
|
||||
/* latency = periodsize * periods / (rate * bytes_per_frame) */
|
||||
if (snd_pcm_hw_params_set_buffer_size(mHandle, mHardwareParams, (mPeriodSize * periods)>>2) < 0)
|
||||
{
|
||||
MLOG_ERROR("Error setting buffersize. ");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void AlsaInterface::SetChannelNumber(const AudioDevicePtr& device)
|
||||
{
|
||||
/* Set number of channels */
|
||||
if (snd_pcm_hw_params_set_channels(mHandle, mHardwareParams, device->GetNumChannels()) < 0)
|
||||
{
|
||||
MLOG_ERROR("Error setting channels");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void AlsaInterface::Play(const AudioDevicePtr& device)
|
||||
{
|
||||
MLOG_INFO("Playing audio");
|
||||
AudioSynth synth;
|
||||
const unsigned duration = 100;
|
||||
double freq = 440;
|
||||
auto data = synth.GetSineWave(freq, duration)->GetChannelData(0);
|
||||
|
||||
int numFrames = mPeriodSize >> 2;
|
||||
for(int count = 0; count < duration; count++)
|
||||
{
|
||||
const auto offset= count*4*numFrames;
|
||||
unsigned char frame[4] = {data[offset], data[offset+1], data[offset+2], data[offset+3]};
|
||||
while ((snd_pcm_writei(mHandle, frame, numFrames)) < 0)
|
||||
{
|
||||
snd_pcm_prepare(mHandle);
|
||||
MLOG_ERROR("<<<<<<<<<<<<<<< Buffer Underrun >>>>>>>>>>>>>>>");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,37 +4,21 @@
|
|||
#include "AudioDevice.h"
|
||||
|
||||
#include <memory>
|
||||
#include <alsa/asoundlib.h>
|
||||
|
||||
class AlsaInterface : public IAudioInterface
|
||||
class NullAudioInterface : public IAudioInterface
|
||||
{
|
||||
snd_pcm_t* mHandle;
|
||||
snd_pcm_hw_params_t* mHardwareParams;
|
||||
snd_pcm_uframes_t mPeriodSize;
|
||||
|
||||
public:
|
||||
|
||||
AlsaInterface();
|
||||
NullAudioInterface();
|
||||
|
||||
~AlsaInterface();
|
||||
~NullAudioInterface();
|
||||
|
||||
static std::unique_ptr<AlsaInterface> Create();
|
||||
static std::unique_ptr<NullAudioInterface> Create();
|
||||
|
||||
void OpenDevice(const AudioDevicePtr& device) override;
|
||||
|
||||
void SetAccessType(const AudioDevicePtr& device);
|
||||
|
||||
void SetSampleFormat(const AudioDevicePtr& device);
|
||||
|
||||
void SetSampleRate(const AudioDevicePtr& device);
|
||||
|
||||
void SetPeriod(const AudioDevicePtr& device);
|
||||
|
||||
void SetBufferSize(const AudioDevicePtr& device);
|
||||
|
||||
void SetChannelNumber(const AudioDevicePtr& device);
|
||||
|
||||
void Play(const AudioDevicePtr& device) override;
|
||||
};
|
||||
|
||||
using AlsaInterfacePtr = std::shared_ptr<AlsaInterface>;
|
||||
using NullAudioInterfacePtr = std::shared_ptr<NullAudioInterface>;
|
||||
|
|
|
@ -1,25 +1,27 @@
|
|||
list(APPEND client_HEADERS
|
||||
set(MODULE_NAME client)
|
||||
|
||||
list(APPEND TARGET_HEADERS
|
||||
TopBar.h
|
||||
StatusBar.h
|
||||
GuiApplication.h
|
||||
TabbedPanelWidget.h)
|
||||
|
||||
list(APPEND client_LIB_INCLUDES
|
||||
list(APPEND TARGET_SOURCES
|
||||
TopBar.cpp
|
||||
StatusBar.cpp
|
||||
GuiApplication.cpp
|
||||
TabbedPanelWidget.cpp)
|
||||
|
||||
add_library(client SHARED ${client_LIB_INCLUDES} ${client_HEADERS})
|
||||
add_library(${MODULE_NAME} SHARED ${TARGET_SOURCES} ${TARGET_HEADERS})
|
||||
|
||||
target_link_libraries(client ui_elements windows core console database geometry)
|
||||
target_link_libraries(${MODULE_NAME} ui_elements windows core console database geometry)
|
||||
|
||||
target_include_directories(client PUBLIC
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/text_editor"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/audio_editor"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/image_editor"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/web_client"
|
||||
target_include_directories(${MODULE_NAME} PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/text_editor
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/audio_editor
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/image_editor
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/web_client
|
||||
)
|
||||
set_property(TARGET client PROPERTY FOLDER src)
|
||||
set_target_properties( client PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON )
|
||||
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER src)
|
||||
set_target_properties( ${MODULE_NAME} PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON )
|
|
@ -1,24 +1,25 @@
|
|||
list(APPEND compiler_HEADERS
|
||||
set(MODULE_NAME compiler)
|
||||
|
||||
list(APPEND TARGET_HEADERS
|
||||
Lexer.h
|
||||
TemplatingEngine.h
|
||||
TemplateFile.h
|
||||
TemplateNodes.h
|
||||
)
|
||||
|
||||
list(APPEND compiler_LIB_INCLUDES
|
||||
list(APPEND TARGET_SOURCES
|
||||
Lexer.cpp
|
||||
TemplatingEngine.cpp
|
||||
TemplateFile.cpp
|
||||
TemplateNodes.cpp
|
||||
)
|
||||
|
||||
add_library(compiler SHARED ${compiler_LIB_INCLUDES} ${compiler_HEADERS})
|
||||
add_library(${MODULE_NAME} SHARED ${TARGET_SOURCES} ${TARGET_HEADERS})
|
||||
|
||||
target_include_directories(compiler PUBLIC
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
target_include_directories(${MODULE_NAME} PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
set_target_properties( compiler PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON )
|
||||
target_link_libraries( ${MODULE_NAME} PUBLIC core)
|
||||
|
||||
target_link_libraries( compiler PUBLIC core)
|
||||
|
||||
set_property(TARGET compiler PROPERTY FOLDER src)
|
||||
set_target_properties( ${MODULE_NAME} PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON )
|
||||
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER src)
|
|
@ -1,3 +1,5 @@
|
|||
set(MODULE_NAME fonts)
|
||||
message(STATUS "Checking dependencies for module: " ${MODULE_NAME})
|
||||
|
||||
set(fonts_LIB_DEPENDS "")
|
||||
|
||||
|
@ -18,17 +20,20 @@ if(UNIX)
|
|||
list(APPEND fonts_LIB_DEPENDS
|
||||
Freetype::Freetype
|
||||
)
|
||||
list(APPEND DEFINES "HAS_FREETYPE")
|
||||
else()
|
||||
message(STATUS "Did not find freetype - skipping font engine")
|
||||
message(STATUS "Freetype not found - skipping support")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_library(fonts SHARED ${fonts_LIB_INCLUDES})
|
||||
add_library(${MODULE_NAME} SHARED ${fonts_LIB_INCLUDES})
|
||||
|
||||
target_include_directories(fonts PUBLIC
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
target_include_directories(${MODULE_NAME} PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
target_link_libraries(fonts PUBLIC core image ${fonts_LIB_DEPENDS})
|
||||
set_property(TARGET fonts PROPERTY FOLDER src)
|
||||
set_target_properties( fonts PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON )
|
||||
target_link_libraries(${MODULE_NAME} PUBLIC core image ${fonts_LIB_DEPENDS})
|
||||
|
||||
target_compile_definitions(${MODULE_NAME} PRIVATE ${DEFINES})
|
||||
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER src)
|
||||
set_target_properties( ${MODULE_NAME} PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON )
|
|
@ -1,12 +1,19 @@
|
|||
#include "FontsManager.h"
|
||||
|
||||
#ifdef HAS_FREETYPE
|
||||
#include "FreeTypeFontEngine.h"
|
||||
#else
|
||||
#include "BasicFontEngine.h"
|
||||
#endif
|
||||
|
||||
|
||||
FontsManager::FontsManager()
|
||||
: mFontEngine(std::make_unique<FreeTypeFontEngine>())
|
||||
{
|
||||
#ifdef HAS_FREETYPE
|
||||
mFontEngine = std::make_unique<FreeTypeFontEngine>();
|
||||
#else
|
||||
mFontEngine = std::make_unique<BasicFontEngine>();
|
||||
#endif
|
||||
mFontEngine->initialize();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
set(MODULE_NAME graphics)
|
||||
|
||||
message(STATUS "Checking dependencies for module: " ${MODULE_NAME})
|
||||
|
||||
set(platform_LIB_INCLUDES "")
|
||||
set(platform_INCLUDE_DIRS "")
|
||||
set(platform_HEADERS "")
|
||||
|
@ -28,27 +32,29 @@ if (OpenGL_FOUND)
|
|||
opengl/OpenGlFontTexture.cpp
|
||||
opengl/OpenGlShaderProgram.cpp
|
||||
)
|
||||
list(APPEND graphics_HEADERS
|
||||
list(APPEND ${MODULE_NAME}
|
||||
opengl/OpenGlPainter.h
|
||||
opengl/OpenGlTextPainter.h
|
||||
opengl/OpenGlMeshPainter.h
|
||||
opengl/OpenGlFontTexture.h
|
||||
opengl/OpenGlShaderProgram.h)
|
||||
list(APPEND DEFINES "HAS_OPENGL")
|
||||
else()
|
||||
message(STATUS "OpenGL headers not found - skipping OpenGL support")
|
||||
message(STATUS "OpenGL not found - skipping support")
|
||||
endif()
|
||||
|
||||
add_library(graphics SHARED
|
||||
add_library(${MODULE_NAME} SHARED
|
||||
${graphics_LIB_INCLUDES}
|
||||
${graphics_HEADERS})
|
||||
|
||||
target_include_directories(graphics PUBLIC
|
||||
target_include_directories(${MODULE_NAME} PUBLIC
|
||||
${platform_INCLUDE_DIRS}
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/opengl"
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/opengl
|
||||
)
|
||||
|
||||
target_link_libraries(graphics PUBLIC geometry mesh fonts image visual_elements ${platform_LIBS})
|
||||
target_compile_definitions(${MODULE_NAME} PRIVATE ${DEFINES})
|
||||
target_link_libraries(${MODULE_NAME} PUBLIC geometry mesh fonts image visual_elements ${platform_LIBS})
|
||||
|
||||
set_property(TARGET graphics PROPERTY FOLDER src)
|
||||
set_target_properties( graphics PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON )
|
||||
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER src)
|
||||
set_target_properties( ${MODULE_NAME} PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON )
|
|
@ -1,10 +1,12 @@
|
|||
#include "PainterFactory.h"
|
||||
|
||||
#ifdef HAS_OPENGL
|
||||
#include "OpenGlPainter.h"
|
||||
#include "OpenGlMeshPainter.h"
|
||||
#include "OpenGlTextPainter.h"
|
||||
#include "OpenGlShaderProgram.h"
|
||||
#include "OpenGlFontTexture.h"
|
||||
#endif
|
||||
|
||||
#include "Grid.h"
|
||||
|
||||
|
@ -14,6 +16,7 @@
|
|||
|
||||
std::unique_ptr<AbstractPainter> PainterFactory::Create(DrawingMode drawMode)
|
||||
{
|
||||
#ifdef HAS_OPENGL
|
||||
if (drawMode == DrawingMode::GRAPH)
|
||||
{
|
||||
return std::make_unique<OpenGlPainter>();
|
||||
|
@ -22,6 +25,9 @@ std::unique_ptr<AbstractPainter> PainterFactory::Create(DrawingMode drawMode)
|
|||
{
|
||||
return std::make_unique<RasterPainter>();
|
||||
}
|
||||
#else
|
||||
return std::make_unique<RasterPainter>();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -69,8 +69,8 @@ void UnixSocketInterface::Write(const SocketPtr& socket, const std::string& mess
|
|||
return;
|
||||
}
|
||||
|
||||
char buffer[mBufferSize] = {0};
|
||||
int res = read(socket->GetHandle(), buffer, mBufferSize);
|
||||
char buffer[BUFFER_SIZE] = {0};
|
||||
int res = read(socket->GetHandle(), buffer, BUFFER_SIZE);
|
||||
if (res < 0)
|
||||
{
|
||||
std::cerr << "Error on read" << std::endl;
|
||||
|
@ -124,8 +124,8 @@ void UnixSocketInterface::Run(const SocketPtr& socket)
|
|||
return;
|
||||
}
|
||||
|
||||
char buffer[mBufferSize] = {0};
|
||||
int n = read(new_socket_handle, buffer, mBufferSize);
|
||||
char buffer[BUFFER_SIZE] = {0};
|
||||
int n = read(new_socket_handle, buffer, BUFFER_SIZE);
|
||||
if (n < 0)
|
||||
{
|
||||
std::cerr << "Error on read" << std::endl;
|
||||
|
|
|
@ -29,6 +29,7 @@ public:
|
|||
|
||||
private:
|
||||
|
||||
static constexpr unsigned BUFFER_SIZE{1024};
|
||||
std::size_t mBufferSize { 0 };
|
||||
std::unique_ptr<ISocketMessageHandler> mMessageHandler;
|
||||
};
|
||||
|
|
|
@ -13,7 +13,7 @@ list(APPEND video_LIB_INCLUDES
|
|||
|
||||
list(APPEND video_DEFINES "")
|
||||
|
||||
message(STATUS "Checking optional dependencies for module: " ${MODULE_NAME})
|
||||
message(STATUS "Checking dependencies for module: " ${MODULE_NAME})
|
||||
find_package(PkgConfig QUIET)
|
||||
set(_HAS_FFMPEG Off)
|
||||
if(PkgConfig_FOUND)
|
||||
|
@ -38,17 +38,15 @@ if(PkgConfig_FOUND)
|
|||
list(APPEND video_DEFINES "HAS_FFMPEG")
|
||||
set(_HAS_FFMPEG ON)
|
||||
else()
|
||||
message(STATUS "libavdevice not found - disabling ffmpeg support")
|
||||
message(STATUS "ffmpeg not found - skipping support")
|
||||
endif()
|
||||
else()
|
||||
message(STATUS "PkgConfig not found - disabling ffmpeg support")
|
||||
message(STATUS "ffmpeg not found - skipping support")
|
||||
endif()
|
||||
|
||||
set(HAS_FFMPEG ${_HAS_FFMPEG} CACHE BOOL "Can build with FFMPEG")
|
||||
|
||||
add_library(${MODULE_NAME} SHARED ${video_LIB_INCLUDES} ${video_HEADERS})
|
||||
|
||||
target_include_directories(video PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
target_include_directories(${MODULE_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
set_target_properties( video PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON )
|
||||
|
||||
list(APPEND video_LIBS image)
|
||||
|
|
|
@ -4,7 +4,7 @@ set (platform_INCLUDES "")
|
|||
set (platform_LIBS "")
|
||||
|
||||
if(UNIX)
|
||||
message(STATUS "Checking optional dependencies for module: window")
|
||||
message(STATUS "Checking dependencies for module: window")
|
||||
find_package(X11 QUIET)
|
||||
if(X11_FOUND)
|
||||
list(APPEND platform_INCLUDES
|
||||
|
@ -20,9 +20,10 @@ if(UNIX)
|
|||
ui_interfaces/x11/XcbGlWindowInterface.cpp
|
||||
)
|
||||
list(APPEND platform_LIBS ${X11_LIBRARIES} ${X11_xcb_LIB} ${X11_X11_xcb_LIB} ${X11_xkbcommon_LIB} ${X11_xkbcommon_X11_LIB} libxcb-image.so)
|
||||
list(APPEND X11_INCLUDE_DIRS ${X11_xkbcommon_INCLUDE_PATH})
|
||||
list(APPEND X11_INCLUDE_DIRS ${X11_xkbcommon_INCLUDE_PATH})
|
||||
list(APPEND DEFINES "HAS_X11")
|
||||
else()
|
||||
message(STATUS "x11 development headers not found - skipping support")
|
||||
message(STATUS "X11 not found - skipping support")
|
||||
endif()
|
||||
|
||||
find_package(Wayland QUIET)
|
||||
|
@ -47,7 +48,7 @@ if(UNIX)
|
|||
list(APPEND platform_LIBS ${WAYLAND_LIBRARIES})
|
||||
endif()
|
||||
else()
|
||||
Message(STATUS "Wayland dependencies not found - disabling Wayland support")
|
||||
Message(STATUS "Wayland not found - skipping support")
|
||||
endif()
|
||||
else()
|
||||
list(APPEND platform_INCLUDES
|
||||
|
|
27
src/windows/ui_interfaces/NullUiInterface.h
Normal file
27
src/windows/ui_interfaces/NullUiInterface.h
Normal file
|
@ -0,0 +1,27 @@
|
|||
#pragma once
|
||||
|
||||
#include "AbstractUiInterface.h"
|
||||
#include "DesktopManager.h"
|
||||
#include "FontsManager.h"
|
||||
|
||||
class NullUIInterface : public AbstractUIInterface
|
||||
{
|
||||
public:
|
||||
|
||||
NullUIInterface(DesktopManager* desktopManager, std::unique_ptr<FontsManager> fontsManager, bool useHardware = false)
|
||||
: AbstractUIInterface(desktopManager, std::move(fontsManager), useHardware)
|
||||
{
|
||||
};
|
||||
|
||||
virtual ~NullUIInterface() = default;
|
||||
|
||||
void loop() override{};
|
||||
|
||||
void showWindow(mt::Window* window) override{};
|
||||
|
||||
void addWindow(mt::Window* window) override{};
|
||||
|
||||
protected:
|
||||
void initialize() override{};
|
||||
void shutDown() override{};
|
||||
};
|
|
@ -1,7 +1,9 @@
|
|||
#include "UiInterfaceFactory.h"
|
||||
|
||||
#ifdef __linux__
|
||||
#ifdef HAS_X11
|
||||
#include "XcbInterface.h"
|
||||
#endif
|
||||
#ifdef HAS_WAYLAND
|
||||
#include "WaylandInterface.h"
|
||||
#endif
|
||||
|
@ -9,6 +11,8 @@
|
|||
#include "Win32UiInterface.h"
|
||||
#endif
|
||||
|
||||
#include "NullUiInterface.h"
|
||||
|
||||
#include "FontsManager.h"
|
||||
|
||||
std::unique_ptr<AbstractUIInterface> UiInterfaceFactory::create(DesktopManager* desktopManager, Backend backend)
|
||||
|
@ -18,18 +22,26 @@ std::unique_ptr<AbstractUIInterface> UiInterfaceFactory::create(DesktopManager*
|
|||
#ifdef __linux__
|
||||
if (backend == Backend::UNSET || backend == Backend::X11 || backend == Backend::X11_RASTER)
|
||||
{
|
||||
#ifdef HAS_X11
|
||||
const bool use_hardware = (backend != Backend::X11_RASTER);
|
||||
return std::make_unique<XcbInterface>(desktopManager, std::move(fonts_manager), use_hardware);
|
||||
#else
|
||||
return std::make_unique<NullUIInterface>(desktopManager, std::move(fonts_manager));
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef HAS_WAYLAND
|
||||
const bool use_hardware = (backend != Backend::WAYLAND_RASTER);
|
||||
return std::make_unique<WaylandInterface>(desktopManager, std::move(fonts_manager), use_hardware);
|
||||
#else
|
||||
const bool use_hardware = (backend != Backend::X11_RASTER);
|
||||
return std::make_unique<XcbInterface>(desktopManager, std::move(fonts_manager), use_hardware);
|
||||
#endif
|
||||
#ifdef HAS_WAYLAND
|
||||
const bool use_hardware = (backend != Backend::WAYLAND_RASTER);
|
||||
return std::make_unique<WaylandInterface>(desktopManager, std::move(fonts_manager), use_hardware);
|
||||
#else
|
||||
#ifdef HAS_X11
|
||||
const bool use_hardware = (backend != Backend::X11_RASTER);
|
||||
return std::make_unique<XcbInterface>(desktopManager, std::move(fonts_manager), use_hardware);
|
||||
#else
|
||||
return std::make_unique<NullUIInterface>(desktopManager, std::move(fonts_manager));
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
return std::make_unique<Win32UiInterface>();
|
||||
|
|
Loading…
Reference in a new issue