diff --git a/Makefile.base.mk b/Makefile.base.mk index 6568471e..0ce426fc 100644 --- a/Makefile.base.mk +++ b/Makefile.base.mk @@ -219,6 +219,7 @@ endif # Check for required libraries HAVE_CAIRO = $(shell $(PKG_CONFIG) --exists cairo && echo true) +HAVE_VULKAN = $(shell $(PKG_CONFIG) --exists vulkan && echo true) ifeq ($(MACOS_OR_WINDOWS),true) HAVE_OPENGL = true @@ -316,6 +317,18 @@ HAVE_CAIRO_OR_OPENGL = true endif +# --------------------------------------------------------------------------------------------------------------------- +# Set Vulkan specific stuff + +ifeq ($(HAVE_VULKAN),true) + +DGL_FLAGS += -DHAVE_VULKAN + +VULKAN_FLAGS = $(shell $(PKG_CONFIG) --cflags vulkan) +VULKAN_LIBS = $(shell $(PKG_CONFIG) --libs vulkan) + +endif + # --------------------------------------------------------------------------------------------------------------------- # Set optional libraries specific stuff diff --git a/dgl/Makefile b/dgl/Makefile index d9390462..ff7fa1e7 100644 --- a/dgl/Makefile +++ b/dgl/Makefile @@ -55,8 +55,8 @@ endif # --------------------------------------------------------------------------------------------------------------------- OBJS_opengl = $(OBJS_common) \ - ../build/dgl/ImageWidgets.cpp.o \ ../build/dgl/OpenGL.cpp.opengl.o \ + ../build/dgl/ImageWidgets.cpp.o \ ../build/dgl/NanoVG.cpp.opengl.o ifeq ($(MACOS),true) @@ -68,7 +68,7 @@ endif # --------------------------------------------------------------------------------------------------------------------- OBJS_vulkan = $(OBJS_common) \ - ../build/dgl/Cairo.cpp.vulkan.o + ../build/dgl/Vulkan.cpp.vulkan.o ifeq ($(MACOS),true) OBJS_vulkan += ../build/dgl/pugl.mm.vulkan.o diff --git a/dgl/Vulkan.hpp b/dgl/Vulkan.hpp new file mode 100644 index 00000000..c636a8a3 --- /dev/null +++ b/dgl/Vulkan.hpp @@ -0,0 +1,39 @@ +/* + * DISTRHO Plugin Framework (DPF) + * Copyright (C) 2012-2021 Filipe Coelho + * + * Permission to use, copy, modify, and/or distribute this software for any purpose with + * or without fee is hereby granted, provided that the above copyright notice and this + * permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + * TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef DGL_VULKAN_HPP_INCLUDED +#define DGL_VULKAN_HPP_INCLUDED + +#include "Base.hpp" + +#include + +START_NAMESPACE_DGL + +// -------------------------------------------------------------------------------------------------------------------- + +/** + Vulkan Graphics context. + */ +struct VulkanGraphicsContext : GraphicsContext +{ +}; + +// -------------------------------------------------------------------------------------------------------------------- + +END_NAMESPACE_DGL + +#endif diff --git a/dgl/src/Vulkan.cpp b/dgl/src/Vulkan.cpp new file mode 100644 index 00000000..ed499222 --- /dev/null +++ b/dgl/src/Vulkan.cpp @@ -0,0 +1,213 @@ +/* + * DISTRHO Plugin Framework (DPF) + * Copyright (C) 2012-2021 Filipe Coelho + * + * Permission to use, copy, modify, and/or distribute this software for any purpose with + * or without fee is hereby granted, provided that the above copyright notice and this + * permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD + * TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN + * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include "../Vulkan.hpp" +#include "../Color.hpp" + +#include "SubWidgetPrivateData.hpp" +#include "TopLevelWidgetPrivateData.hpp" +#include "WidgetPrivateData.hpp" +#include "WindowPrivateData.hpp" + +START_NAMESPACE_DGL + +// ----------------------------------------------------------------------- + +static void notImplemented(const char* const name) +{ + d_stderr2("vulkan function not implemented: %s", name); +} + +// ----------------------------------------------------------------------- +// Color + +void Color::setFor(const GraphicsContext&, bool) +{ + notImplemented("Color::setFor"); +} + +// ----------------------------------------------------------------------- +// Line + +template +void Line::draw(const GraphicsContext&, T) +{ + notImplemented("Line::draw"); +} + +template +void Line::draw() +{ + notImplemented("Line::draw"); +} + +template class Line; +template class Line; +template class Line; +template class Line; +template class Line; +template class Line; + +// ----------------------------------------------------------------------- +// Circle + +template +void Circle::draw(const GraphicsContext&) +{ + notImplemented("Circle::draw"); +} + +template +void Circle::drawOutline(const GraphicsContext&, T) +{ + notImplemented("Circle::drawOutline"); +} + +template +void Circle::draw() +{ + notImplemented("Circle::draw"); +} + +template +void Circle::drawOutline() +{ + notImplemented("Circle::drawOutline"); +} + +template class Circle; +template class Circle; +template class Circle; +template class Circle; +template class Circle; +template class Circle; + +// ----------------------------------------------------------------------- +// Triangle + +template +void Triangle::draw(const GraphicsContext&) +{ + notImplemented("Triangle::draw"); +} + +template +void Triangle::drawOutline(const GraphicsContext&, T) +{ + notImplemented("Triangle::drawOutline"); +} + +template +void Triangle::draw() +{ + notImplemented("Triangle::draw"); +} + +template +void Triangle::drawOutline() +{ + notImplemented("Triangle::drawOutline"); +} + +template class Triangle; +template class Triangle; +template class Triangle; +template class Triangle; +template class Triangle; +template class Triangle; + + +// ----------------------------------------------------------------------- +// Rectangle + +template +void Rectangle::draw(const GraphicsContext&) +{ + notImplemented("Rectangle::draw"); +} + +template +void Rectangle::drawOutline(const GraphicsContext&, T) +{ + notImplemented("Rectangle::drawOutline"); +} + +template +void Rectangle::draw() +{ + notImplemented("Rectangle::draw"); +} + +template +void Rectangle::drawOutline() +{ + notImplemented("Rectangle::drawOutline"); +} + +template class Rectangle; +template class Rectangle; +template class Rectangle; +template class Rectangle; +template class Rectangle; +template class Rectangle; + +// ----------------------------------------------------------------------- + +void SubWidget::PrivateData::display(const uint width, const uint height, const double autoScaleFactor) +{ + // TODO + + selfw->pData->displaySubWidgets(width, height, autoScaleFactor); +} + +// ----------------------------------------------------------------------- + +void TopLevelWidget::PrivateData::display() +{ + const Size size(window.getSize()); + const uint width = size.getWidth(); + const uint height = size.getHeight(); + + const double autoScaleFactor = window.pData->autoScaleFactor; + + // FIXME anything needed here? +#if 0 + // full viewport size + if (window.pData->autoScaling) + glViewport(0, -(height * autoScaleFactor - height), width * autoScaleFactor, height * autoScaleFactor); + else + glViewport(0, 0, width, height); +#endif + + // main widget drawing + self->onDisplay(); + + // now draw subwidgets if there are any + selfw->pData->displaySubWidgets(width, height, autoScaleFactor); +} + +// ----------------------------------------------------------------------- + +const GraphicsContext& Window::PrivateData::getGraphicsContext() const noexcept +{ + return (const GraphicsContext&)graphicsContext; +} + +// ----------------------------------------------------------------------- + +END_NAMESPACE_DGL + +// -----------------------------------------------------------------------