Fixing up Windows build.

This commit is contained in:
jamgroga 2021-09-26 21:42:35 +01:00
parent 32ace0fcac
commit 5d32592126
22 changed files with 247994 additions and 53 deletions

View file

@ -1,18 +1,9 @@
list(APPEND graphics_LIB_INCLUDES
DrawingContext.cpp
DrawingManager.cpp
DrawingSurface.cpp
opengl/OpenGlInterface.cpp
cairo/CairoInterface.cpp
cairo/CairoDrawingSurface.cpp
cairo/CairoDrawingContext.cpp)
list(APPEND graphics_HEADERS
opengl/OpenGlInterface.h
cairo/CairoInterface.h
INativeDrawingSurface.h
INativeDrawingContext.h)
set(platform_LIB_INCLUDES "")
set(platform_INCLUDE_DIRS "")
set(platform_HEADERS "")
set(platform_LIBS "")
if (UNIX)
find_package(PkgConfig)
PKG_CHECK_MODULES(PC_CAIRO cairo)
FIND_PATH(CAIRO_INCLUDE_DIRS
@ -27,13 +18,48 @@ FIND_LIBRARY(CAIRO_LIBRARIES
HINTS ${PC_CAIRO_LIBDIR}
${PC_CAIRO_LIBRARY_DIRS}
)
list(APPEND platform_LIB_INCLUDES
cairo/CairoInterface.cpp
cairo/CairoDrawingSurface.cpp
cairo/CairoDrawingContext.cpp
)
list(APPEND platform_INCLUDE_DIRS
${CAIRO_INCLUDE_DIRS}
)
list(APPEND platform_HEADERS
cairo/CairoInterface.h
)
list(APPEND platform_LIBS
${CAIRO_LIBRARIES}
GL
)
else()
list(APPEND platform_LIBS
OpenGL32.lib
)
endif()
list(APPEND graphics_LIB_INCLUDES
DrawingContext.cpp
DrawingManager.cpp
DrawingSurface.cpp
opengl/OpenGlInterface.cpp
${platform_LIB_INCLUDES}
)
list(APPEND graphics_HEADERS
opengl/OpenGlInterface.h
${platform_HEADERS}
INativeDrawingSurface.h
INativeDrawingContext.h)
add_library(graphics SHARED
${graphics_LIB_INCLUDES}
${graphics_HEADERS})
target_include_directories(graphics PUBLIC
${CAIRO_INCLUDE_DIRS}
${platform_INCLUDE_DIRS}
"${CMAKE_CURRENT_SOURCE_DIR}"
"${CMAKE_CURRENT_SOURCE_DIR}/cairo"
"${CMAKE_CURRENT_SOURCE_DIR}/opengl"
@ -41,6 +67,7 @@ target_include_directories(graphics PUBLIC
"${PROJECT_SOURCE_DIR}/src/visual_elements/"
)
target_link_libraries(graphics PUBLIC visual_elements GL ${CAIRO_LIBRARIES})
target_link_libraries(graphics PUBLIC visual_elements ${platform_LIBS})
set_property(TARGET graphics PROPERTY FOLDER src)
set_property(TARGET graphics PROPERTY FOLDER src)
set_target_properties( graphics PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON )

View file

@ -3,11 +3,15 @@
#include "INativeDrawingContext.h"
#include "DrawingSurface.h"
#include "DrawingContext.h"
#ifdef __linux__
#include "CairoInterface.h"
#endif
DrawingManager::DrawingManager()
{
#ifdef __linux__
mCairoInterface = CairoInterface::Create();
#endif
}
std::unique_ptr<DrawingManager> DrawingManager::Create()
@ -19,21 +23,23 @@ void DrawingManager::InitalizeSurface(unsigned width, unsigned height)
{
mDrawingSurface = DrawingSurface::Create();
mDrawingSurface->SetSize(width, height);
#ifdef __linux__
if (mCairoInterface)
{
mCairoInterface->InitializeSurface(mDrawingSurface.get());
}
#endif
}
void DrawingManager::InitializeContext()
{
mDrawingContext = DrawingContext::Create();
#ifdef __linux__
if (mCairoInterface && mDrawingSurface)
{
mCairoInterface->InitializeContext(mDrawingContext.get(), mDrawingSurface.get());
}
#endif
}
void DrawingManager::AddText(TextElement* text)
@ -47,17 +53,20 @@ void DrawingManager::AddText(TextElement* text)
{
return;
}
#ifdef __linux__
if (mCairoInterface)
{
mCairoInterface->AddText(text, mDrawingContext.get());
}
#endif
}
void DrawingManager::RenderToFile(const std::string& path)
{
#ifdef __linux__
if (mDrawingSurface && mCairoInterface)
{
mCairoInterface->RenderToFile(mDrawingSurface.get(), path);
}
#endif
}

View file

@ -1,9 +1,12 @@
#pragma once
#include <memory>
#include <string>
#include "INativeDrawingContext.h"
#include "INativeDrawingSurface.h"
#ifdef __linux__
#include "CairoInterface.h"
#endif
class TextElement;
@ -25,7 +28,9 @@ public:
private:
DrawingSurfacePtr mDrawingSurface {nullptr};
DrawingContextPtr mDrawingContext {nullptr};
#ifdef __linux__
CairoInterfacePtr mCairoInterface {nullptr};
#endif
};
using DrawingManagerPtr = std::unique_ptr<DrawingManager>;

View file

@ -1,4 +1,7 @@
#include "OpenGlInterface.h"
#ifdef _WIN32
#include <windows.h>
#endif
#include <GL/gl.h>