Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

build options for gles and clang-tidy cleanup #16596

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ option(MBGL_WITH_SANITIZER "Use [address|thread|undefined] here" OFF)
option(MBGL_WITH_RTTI "Compile with runtime type information" OFF)
option(MBGL_WITH_OPENGL "Build with OpenGL renderer" ON)
option(MBGL_WITH_WERROR "Make all compilation warnings errors" ON)
option(MBGL_WITH_GLES2 "Build with GLES2" OFF)

if(MBGL_WITH_GLES2)
add_compile_definitions(MBGL_USE_GLES2)
endif()

add_library(
mbgl-compiler-options INTERFACE
Expand Down Expand Up @@ -57,6 +62,7 @@ target_compile_options(
$<$<CXX_COMPILER_ID:GNU>:-Wno-error=maybe-uninitialized>
$<$<CXX_COMPILER_ID:GNU>:-Wno-error=return-type>
$<$<CXX_COMPILER_ID:GNU>:-Wno-error=unknown-pragmas>
$<$<CXX_COMPILER_ID:GNU>:-Wno-error=type-limits>
$<$<CXX_COMPILER_ID:AppleClang>:-Wno-error=deprecated-declarations>
$<$<CXX_COMPILER_ID:AppleClang>:-Wno-error=unused-parameter>
$<$<CXX_COMPILER_ID:AppleClang>:-Wno-error=unused-property-ivar>
Expand Down
24 changes: 24 additions & 0 deletions platform/glfw/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ find_package(PkgConfig REQUIRED)

pkg_search_module(GLFW glfw3 REQUIRED)

# build glfw3 with GLFW_USE_WAYLAND=ON
if(CMAKE_SYSTEM_NAME STREQUAL Linux)
pkg_check_modules(WAYLAND
wayland-client>=0.2.7
wayland-cursor>=0.2.7
wayland-egl>=0.2.7
xkbcommon)
endif()

add_executable(
mbgl-glfw
${PROJECT_SOURCE_DIR}/platform/glfw/main.cpp
Expand Down Expand Up @@ -53,6 +62,7 @@ target_link_libraries(
Mapbox::Map
mbgl-compiler-options
Mapbox::Base::cheap-ruler-cpp
${WAYLAND_LINK_LIBRARIES}
)

if(MBGL_WITH_OPENGL)
Expand All @@ -62,6 +72,20 @@ if(MBGL_WITH_OPENGL)
)
endif()

if(MBGL_WITH_GLES2)
target_compile_definitions(
mbgl-glfw
PRIVATE MBGL_WITH_EGL
)
endif()

if(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
target_compile_definitions(
mbgl-glfw
PRIVATE DEBUG
)
endif()

set_property(TARGET mbgl-glfw PROPERTY FOLDER Executables)

install(TARGETS mbgl-glfw RUNTIME DESTINATION bin)
8 changes: 4 additions & 4 deletions platform/glfw/glfw_backend.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ class GLFWBackend {
public:
explicit GLFWBackend() = default;
GLFWBackend(const GLFWBackend&) = delete;
GLFWBackend& operator=(const GLFWBackend&) = delete;
auto operator=(const GLFWBackend&) -> GLFWBackend& = delete;
virtual ~GLFWBackend() = default;

static std::unique_ptr<GLFWBackend> Create(GLFWwindow* window, bool capFrameRate) {
static auto Create(GLFWwindow* window, bool capFrameRate) -> std::unique_ptr<GLFWBackend> {
return mbgl::gfx::Backend::Create<GLFWBackend, GLFWwindow*, bool>(window, capFrameRate);
}

virtual mbgl::gfx::RendererBackend& getRendererBackend() = 0;
virtual mbgl::Size getSize() const = 0;
virtual auto getRendererBackend() -> mbgl::gfx::RendererBackend& = 0;
virtual auto getSize() const -> mbgl::Size = 0;
virtual void setSize(mbgl::Size) = 0;
};
8 changes: 4 additions & 4 deletions platform/glfw/glfw_gl_backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void GLFWGLBackend::deactivate() {
glfwMakeContextCurrent(nullptr);
}

mbgl::gl::ProcAddress GLFWGLBackend::getExtensionFunctionPointer(const char* name) {
auto GLFWGLBackend::getExtensionFunctionPointer(const char* name) -> mbgl::gl::ProcAddress {
return glfwGetProcAddress(name);
}

Expand All @@ -61,7 +61,7 @@ void GLFWGLBackend::updateAssumedState() {
setViewport(0, 0, size);
}

mbgl::Size GLFWGLBackend::getSize() const {
auto GLFWGLBackend::getSize() const -> mbgl::Size {
return size;
}

Expand All @@ -77,8 +77,8 @@ namespace mbgl {
namespace gfx {

template <>
std::unique_ptr<GLFWBackend>
Backend::Create<mbgl::gfx::Backend::Type::OpenGL>(GLFWwindow* window, bool capFrameRate) {
auto
Backend::Create<mbgl::gfx::Backend::Type::OpenGL>(GLFWwindow* window, bool capFrameRate) -> std::unique_ptr<GLFWBackend> {
return std::make_unique<GLFWGLBackend>(window, capFrameRate);
}

Expand Down
11 changes: 4 additions & 7 deletions platform/glfw/glfw_gl_backend.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,14 @@ class GLFWGLBackend final : public GLFWBackend,
void swap();

// GLFWRendererBackend implementation
public:
mbgl::gfx::RendererBackend& getRendererBackend() override {
auto getRendererBackend() -> mbgl::gfx::RendererBackend& override {
return *this;
}
mbgl::Size getSize() const override;
auto getSize() const -> mbgl::Size override;
void setSize(mbgl::Size) override;

// mbgl::gfx::RendererBackend implementation
public:
mbgl::gfx::Renderable& getDefaultRenderable() override {
auto getDefaultRenderable() -> mbgl::gfx::Renderable& override {
return *this;
}

Expand All @@ -35,8 +33,7 @@ class GLFWGLBackend final : public GLFWBackend,
void deactivate() override;

// mbgl::gl::RendererBackend implementation
protected:
mbgl::gl::ProcAddress getExtensionFunctionPointer(const char*) override;
auto getExtensionFunctionPointer(const char*) -> mbgl::gl::ProcAddress override;
void updateAssumedState() override;

private:
Expand Down
2 changes: 1 addition & 1 deletion platform/glfw/glfw_renderer_frontend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void GLFWRendererFrontend::render() {
renderer->render(updateParameters_);
}

mbgl::Renderer* GLFWRendererFrontend::getRenderer() {
auto GLFWRendererFrontend::getRenderer() -> mbgl::Renderer* {
assert(renderer);
return renderer.get();
}
2 changes: 1 addition & 1 deletion platform/glfw/glfw_renderer_frontend.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class GLFWRendererFrontend : public mbgl::RendererFrontend {
void update(std::shared_ptr<mbgl::UpdateParameters>) override;
void render();

mbgl::Renderer* getRenderer();
auto getRenderer() -> mbgl::Renderer*;

private:
GLFWView& glfwView;
Expand Down
Loading