Browse Source

Adjustments for Cairo, and general cleanup

Signed-off-by: falkTX <falktx@gmail.com>
pull/99/head
falkTX 6 years ago
parent
commit
204fbeb807
Signed by: falkTX <falktx@gmail.com> GPG Key ID: 2D3445A829213837
40 changed files with 1153 additions and 675 deletions
  1. +5
    -2
      Makefile
  2. +71
    -30
      Makefile.base.mk
  3. +50
    -12
      Makefile.plugins.mk
  4. +5
    -108
      dgl/Base.hpp
  5. +40
    -0
      dgl/Cairo.hpp
  6. +1
    -5
      dgl/Color.hpp
  7. +13
    -24
      dgl/Geometry.hpp
  8. +30
    -52
      dgl/Image.hpp
  9. +125
    -0
      dgl/ImageBase.hpp
  10. +87
    -19
      dgl/Makefile
  11. +2
    -1
      dgl/NanoVG.hpp
  12. +121
    -0
      dgl/OpenGL.hpp
  13. +1
    -3
      dgl/Widget.hpp
  14. +2
    -2
      dgl/Window.hpp
  15. +27
    -0
      dgl/src/Cairo.cpp
  16. +13
    -39
      dgl/src/Color.cpp
  17. +13
    -103
      dgl/src/Geometry.cpp
  18. +29
    -73
      dgl/src/Image.cpp
  19. +106
    -0
      dgl/src/ImageBase.cpp
  20. +5
    -1
      dgl/src/ImageWidgets.cpp
  21. +20
    -1
      dgl/src/NanoVG.cpp
  22. +157
    -0
      dgl/src/OpenGL.cpp
  23. +1
    -6
      dgl/src/Widget.cpp
  24. +92
    -0
      dgl/src/WidgetPrivateData.cpp
  25. +3
    -60
      dgl/src/WidgetPrivateData.hpp
  26. +16
    -18
      dgl/src/Window.cpp
  27. +35
    -41
      dgl/src/pugl/pugl.h
  28. +2
    -2
      dgl/src/pugl/pugl_internal.h
  29. +11
    -11
      dgl/src/pugl/pugl_osx.m
  30. +20
    -20
      dgl/src/pugl/pugl_win.cpp
  31. +23
    -23
      dgl/src/pugl/pugl_x11.c
  32. +8
    -1
      distrho/DistrhoUI.hpp
  33. +3
    -3
      distrho/src/DistrhoPluginChecks.h
  34. +2
    -2
      distrho/src/DistrhoUI.cpp
  35. +2
    -1
      dpf.doxygen
  36. +2
    -2
      examples/Info/Makefile
  37. +3
    -3
      examples/Meters/Makefile
  38. +3
    -3
      examples/Parameters/Makefile
  39. +3
    -3
      examples/States/Makefile
  40. +1
    -1
      utils/lv2-ttl-generator/GNUmakefile

+ 5
- 2
Makefile View File

@@ -11,9 +11,7 @@ all: dgl examples gen
# -------------------------------------------------------------- # --------------------------------------------------------------


dgl: dgl:
ifeq ($(HAVE_DGL),true)
$(MAKE) -C dgl $(MAKE) -C dgl
endif


examples: dgl examples: dgl
$(MAKE) all -C examples/Info $(MAKE) all -C examples/Info
@@ -23,6 +21,10 @@ examples: dgl
$(MAKE) all -C examples/Parameters $(MAKE) all -C examples/Parameters
$(MAKE) all -C examples/States $(MAKE) all -C examples/States


ifeq ($(HAVE_CAIRO),true)
$(MAKE) all -C examples/CairoUI
endif

ifneq ($(MACOS_OR_WIN32),true) ifneq ($(MACOS_OR_WIN32),true)
# ExternalUI is WIP # ExternalUI is WIP
$(MAKE) all -C examples/ExternalUI $(MAKE) all -C examples/ExternalUI
@@ -50,6 +52,7 @@ endif


clean: clean:
$(MAKE) clean -C dgl $(MAKE) clean -C dgl
$(MAKE) clean -C examples/CairoUI
$(MAKE) clean -C examples/ExternalUI $(MAKE) clean -C examples/ExternalUI
$(MAKE) clean -C examples/Info $(MAKE) clean -C examples/Info
$(MAKE) clean -C examples/Latency $(MAKE) clean -C examples/Latency


+ 71
- 30
Makefile.base.mk View File

@@ -16,7 +16,7 @@ ifneq ($(HAIKU),true)
ifneq ($(HURD),true) ifneq ($(HURD),true)
ifneq ($(LINUX),true) ifneq ($(LINUX),true)
ifneq ($(MACOS),true) ifneq ($(MACOS),true)
ifneq ($(WIN32),true)
ifneq ($(WINDOWS),true)


TARGET_MACHINE := $(shell $(CC) -dumpmachine) TARGET_MACHINE := $(shell $(CC) -dumpmachine)
ifneq (,$(findstring bsd,$(TARGET_MACHINE))) ifneq (,$(findstring bsd,$(TARGET_MACHINE)))
@@ -35,7 +35,7 @@ ifneq (,$(findstring apple,$(TARGET_MACHINE)))
MACOS=true MACOS=true
endif endif
ifneq (,$(findstring mingw,$(TARGET_MACHINE))) ifneq (,$(findstring mingw,$(TARGET_MACHINE)))
WIN32=true
WINDOWS=true
endif endif


endif endif
@@ -57,14 +57,20 @@ LINUX_OR_MACOS=true
endif endif


# --------------------------------------------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------------------------------------------
# Set MACOS_OR_WIN32
# Set MACOS_OR_WINDOWS and HAIKU_OR_MACOS_OR_WINDOWS

ifeq ($(HAIKU),true)
HAIKU_OR_MACOS_OR_WINDOWS=true
endif


ifeq ($(MACOS),true) ifeq ($(MACOS),true)
MACOS_OR_WIN32=true
MACOS_OR_WINDOWS=true
HAIKU_OR_MACOS_OR_WINDOWS=true
endif endif


ifeq ($(WIN32),true)
MACOS_OR_WIN32=true
ifeq ($(WINDOWS),true)
MACOS_OR_WINDOWS=true
HAIKU_OR_MACOS_OR_WINDOWS=true
endif endif


# --------------------------------------------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------------------------------------------
@@ -108,7 +114,7 @@ ifeq ($(NOOPT),true)
BASE_OPTS = -O2 -ffast-math -fdata-sections -ffunction-sections BASE_OPTS = -O2 -ffast-math -fdata-sections -ffunction-sections
endif endif


ifeq ($(WIN32),true)
ifeq ($(WINDOWS),true)
# mingw has issues with this specific optimization # mingw has issues with this specific optimization
# See https://github.com/falkTX/Carla/issues/696 # See https://github.com/falkTX/Carla/issues/696
BASE_OPTS += -fno-rerun-cse-after-loop BASE_OPTS += -fno-rerun-cse-after-loop
@@ -141,7 +147,7 @@ ifeq ($(MACOS_OLD),true)
BUILD_CXX_FLAGS = $(BASE_FLAGS) $(CXXFLAGS) -DHAVE_CPP11_SUPPORT=0 BUILD_CXX_FLAGS = $(BASE_FLAGS) $(CXXFLAGS) -DHAVE_CPP11_SUPPORT=0
endif endif


ifeq ($(WIN32),true)
ifeq ($(WINDOWS),true)
# Always build statically on windows # Always build statically on windows
LINK_FLAGS += -static LINK_FLAGS += -static
endif endif
@@ -170,46 +176,81 @@ CXXFLAGS += -Weffc++ -Wnon-virtual-dtor -Woverloaded-virtual
endif endif


# --------------------------------------------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------------------------------------------
# Check for optional libs
# Check for required libraries


ifeq ($(MACOS_OR_WIN32),true)
HAVE_DGL = true
HAVE_CAIRO = $(shell pkg-config --exists cairo && echo true)

ifeq ($(HAIKU_OR_MACOS_OR_WINDOWS),true)
HAVE_OPENGL = true
else else
HAVE_DGL = $(shell pkg-config --exists gl x11 && echo true)
HAVE_JACK = $(shell pkg-config --exists jack && echo true)
HAVE_LIBLO = $(shell pkg-config --exists liblo && echo true)
HAVE_OPENGL = $(shell pkg-config --exists gl && echo true)
HAVE_X11 = $(shell pkg-config --exists x11 && echo true)
endif

# ---------------------------------------------------------------------------------------------------------------------
# Check for optional libraries

HAVE_JACK = $(shell pkg-config --exists jack && echo true)
HAVE_LIBLO = $(shell pkg-config --exists liblo && echo true)

# ---------------------------------------------------------------------------------------------------------------------
# Set Generic DGL stuff

ifeq ($(MACOS),true)
DGL_LIBS += -framework Cocoa
endif endif


ifneq ($(HAVE_DGL),true)
$(error DGL missing 22)
ifeq ($(WINDOWS),true)
DGL_LIBS += -lgdi32
endif

ifneq ($(HAIKU_OR_MACOS_OR_WINDOWS),true)
DGL_FLAGS += $(shell pkg-config --cflags x11)
DGL_LIBS += $(shell pkg-config --libs x11)
endif endif


# --------------------------------------------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------------------------------------------
# Set libs stuff
# Set Cairo specific stuff

ifeq ($(HAVE_CAIRO),true)


ifeq ($(HAVE_DGL),true)
DGL_FLAGS += -DHAVE_CAIRO


DGL_FLAGS += -DHAVE_DGL
CAIRO_FLAGS = $(shell pkg-config --cflags cairo)
CAIRO_LIBS = $(shell pkg-config --libs cairo)

HAVE_CAIRO_OR_OPENGL = true

endif

# ---------------------------------------------------------------------------------------------------------------------
# Set OpenGL specific stuff

ifeq ($(HAVE_OPENGL),true)

DGL_FLAGS += -DHAVE_OPENGL


ifeq ($(MACOS),true) ifeq ($(MACOS),true)
DGL_LIBS = -framework OpenGL -framework Cocoa
OPENGL_LIBS = -framework OpenGL
endif endif


ifeq ($(WIN32),true)
DGL_LIBS = -lopengl32 -lgdi32
ifeq ($(WINDOWS),true)
OPENGL_LIBS = -lopengl32
endif endif


ifneq ($(MACOS_OR_WIN32),true)
DGL_FLAGS += $(shell pkg-config --cflags gl x11)
DGL_LIBS += $(shell pkg-config --libs gl x11)
ifneq ($(MACOS_OR_WINDOWS),true)
OPENGL_FLAGS = $(shell pkg-config --cflags gl x11)
OPENGL_LIBS = $(shell pkg-config --libs gl x11)
endif endif


endif # HAVE_DGL
HAVE_CAIRO_OR_OPENGL = true

endif


# --------------------------------------------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------------------------------------------
# Set app extension # Set app extension


ifeq ($(WIN32),true)
ifeq ($(WINDOWS),true)
APP_EXT = .exe APP_EXT = .exe
endif endif


@@ -222,17 +263,17 @@ ifeq ($(MACOS),true)
LIB_EXT = .dylib LIB_EXT = .dylib
endif endif


ifeq ($(WIN32),true)
ifeq ($(WINDOWS),true)
LIB_EXT = .dll LIB_EXT = .dll
endif endif


# --------------------------------------------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------------------------------------------
# Set shared library CLI arg # Set shared library CLI arg


SHARED = -shared

ifeq ($(MACOS),true) ifeq ($(MACOS),true)
SHARED = -dynamiclib SHARED = -dynamiclib
else
SHARED = -shared
endif endif


# --------------------------------------------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------------------------------------------

+ 50
- 12
Makefile.plugins.mk View File

@@ -15,10 +15,6 @@ endif


include $(DPF_PATH)/Makefile.base.mk include $(DPF_PATH)/Makefile.base.mk


ifeq ($(FILES_UI),)
HAVE_DGL = false
endif

# --------------------------------------------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------------------------------------------
# Basic setup # Basic setup


@@ -28,8 +24,12 @@ BUILD_DIR = ../../build/$(NAME)
BUILD_C_FLAGS += -I. BUILD_C_FLAGS += -I.
BUILD_CXX_FLAGS += -I. -I$(DPF_PATH)/distrho -I$(DPF_PATH)/dgl BUILD_CXX_FLAGS += -I. -I$(DPF_PATH)/distrho -I$(DPF_PATH)/dgl


ifeq ($(HAVE_DGL),true)
BASE_FLAGS += -DHAVE_DGL
ifeq ($(HAVE_CAIRO),true)
DGL_FLAGS += -DHAVE_CAIRO
endif

ifeq ($(HAVE_OPENGL),true)
DGL_FLAGS += -DHAVE_OPENGL
endif endif


ifeq ($(HAVE_JACK),true) ifeq ($(HAVE_JACK),true)
@@ -59,7 +59,37 @@ lv2_ui = $(TARGET_DIR)/$(NAME).lv2/$(NAME)_ui$(LIB_EXT)
vst = $(TARGET_DIR)/$(NAME)-vst$(LIB_EXT) vst = $(TARGET_DIR)/$(NAME)-vst$(LIB_EXT)


# --------------------------------------------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------------------------------------------
# Handle plugins without UI
# Handle UI stuff, disable UI support automatically

ifeq ($(FILES_UI),)
UI_TYPE = none
endif

ifeq ($(UI_TYPE),)
UI_TYPE = opengl
endif

ifeq ($(UI_TYPE),cairo)
ifeq ($(HAVE_CAIRO),true)
DGL_FLAGS += $(CAIRO_FLAGS) -DDGL_CAIRO
DGL_LIBS += $(CAIRO_LIBS)
DGL_LIB = $(DPF_PATH)/build/libdgl-cairo.a
HAVE_DGL = true
else
HAVE_DGL = false
endif
endif

ifeq ($(UI_TYPE),opengl)
ifeq ($(HAVE_OPENGL),true)
DGL_FLAGS += $(OPENGL_FLAGS) -DDGL_OPENGL
DGL_LIBS += $(OPENGL_LIBS)
DGL_LIB = $(DPF_PATH)/build/libdgl-opengl.a
HAVE_DGL = true
else
HAVE_DGL = false
endif
endif


ifneq ($(HAVE_DGL),true) ifneq ($(HAVE_DGL),true)
dssi_ui = dssi_ui =
@@ -68,6 +98,9 @@ DGL_LIBS =
OBJS_UI = OBJS_UI =
endif endif


# TODO split dsp and ui object build flags
BASE_FLAGS += $(DGL_FLAGS)

# --------------------------------------------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------------------------------------------
# all needs to be first # all needs to be first


@@ -81,6 +114,11 @@ $(BUILD_DIR)/%.c.o: %.c
@echo "Compiling $<" @echo "Compiling $<"
@$(CC) $< $(BUILD_C_FLAGS) -c -o $@ @$(CC) $< $(BUILD_C_FLAGS) -c -o $@


$(BUILD_DIR)/%.cc.o: %.cc
-@mkdir -p "$(shell dirname $(BUILD_DIR)/$<)"
@echo "Compiling $<"
@$(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@

$(BUILD_DIR)/%.cpp.o: %.cpp $(BUILD_DIR)/%.cpp.o: %.cpp
-@mkdir -p "$(shell dirname $(BUILD_DIR)/$<)" -@mkdir -p "$(shell dirname $(BUILD_DIR)/$<)"
@echo "Compiling $<" @echo "Compiling $<"
@@ -118,7 +156,7 @@ $(BUILD_DIR)/DistrhoUIMain_DSSI.cpp.o: $(DPF_PATH)/distrho/DistrhoUIMain.cpp
jack: $(jack) jack: $(jack)


ifeq ($(HAVE_DGL),true) ifeq ($(HAVE_DGL),true)
$(jack): $(OBJS_DSP) $(OBJS_UI) $(BUILD_DIR)/DistrhoPluginMain_JACK.cpp.o $(BUILD_DIR)/DistrhoUIMain_JACK.cpp.o $(DPF_PATH)/build/libdgl.a
$(jack): $(OBJS_DSP) $(OBJS_UI) $(BUILD_DIR)/DistrhoPluginMain_JACK.cpp.o $(BUILD_DIR)/DistrhoUIMain_JACK.cpp.o $(DGL_LIB)
else else
$(jack): $(OBJS_DSP) $(BUILD_DIR)/DistrhoPluginMain_JACK.cpp.o $(jack): $(OBJS_DSP) $(BUILD_DIR)/DistrhoPluginMain_JACK.cpp.o
endif endif
@@ -148,7 +186,7 @@ $(dssi_dsp): $(OBJS_DSP) $(BUILD_DIR)/DistrhoPluginMain_DSSI.cpp.o
@echo "Creating DSSI plugin library for $(NAME)" @echo "Creating DSSI plugin library for $(NAME)"
@$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(SHARED) -o $@ @$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(SHARED) -o $@


$(dssi_ui): $(OBJS_UI) $(BUILD_DIR)/DistrhoUIMain_DSSI.cpp.o $(DPF_PATH)/build/libdgl.a
$(dssi_ui): $(OBJS_UI) $(BUILD_DIR)/DistrhoUIMain_DSSI.cpp.o $(DGL_LIB)
-@mkdir -p $(shell dirname $@) -@mkdir -p $(shell dirname $@)
@echo "Creating DSSI UI for $(NAME)" @echo "Creating DSSI UI for $(NAME)"
@$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(DGL_LIBS) $(shell pkg-config --libs liblo) -o $@ @$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(DGL_LIBS) $(shell pkg-config --libs liblo) -o $@
@@ -160,7 +198,7 @@ lv2: $(lv2)
lv2_dsp: $(lv2_dsp) lv2_dsp: $(lv2_dsp)
lv2_sep: $(lv2_dsp) $(lv2_ui) lv2_sep: $(lv2_dsp) $(lv2_ui)


$(lv2): $(OBJS_DSP) $(OBJS_UI) $(BUILD_DIR)/DistrhoPluginMain_LV2.cpp.o $(BUILD_DIR)/DistrhoUIMain_LV2.cpp.o $(DPF_PATH)/build/libdgl.a
$(lv2): $(OBJS_DSP) $(OBJS_UI) $(BUILD_DIR)/DistrhoPluginMain_LV2.cpp.o $(BUILD_DIR)/DistrhoUIMain_LV2.cpp.o $(DGL_LIB)
-@mkdir -p $(shell dirname $@) -@mkdir -p $(shell dirname $@)
@echo "Creating LV2 plugin for $(NAME)" @echo "Creating LV2 plugin for $(NAME)"
@$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(DGL_LIBS) $(SHARED) -o $@ @$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(DGL_LIBS) $(SHARED) -o $@
@@ -170,7 +208,7 @@ $(lv2_dsp): $(OBJS_DSP) $(BUILD_DIR)/DistrhoPluginMain_LV2.cpp.o
@echo "Creating LV2 plugin library for $(NAME)" @echo "Creating LV2 plugin library for $(NAME)"
@$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(SHARED) -o $@ @$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(SHARED) -o $@


$(lv2_ui): $(OBJS_UI) $(BUILD_DIR)/DistrhoUIMain_LV2.cpp.o $(DPF_PATH)/build/libdgl.a
$(lv2_ui): $(OBJS_UI) $(BUILD_DIR)/DistrhoUIMain_LV2.cpp.o $(DGL_LIB)
-@mkdir -p $(shell dirname $@) -@mkdir -p $(shell dirname $@)
@echo "Creating LV2 plugin UI for $(NAME)" @echo "Creating LV2 plugin UI for $(NAME)"
@$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(DGL_LIBS) $(SHARED) -o $@ @$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(DGL_LIBS) $(SHARED) -o $@
@@ -181,7 +219,7 @@ $(lv2_ui): $(OBJS_UI) $(BUILD_DIR)/DistrhoUIMain_LV2.cpp.o $(DPF_PATH)/build/lib
vst: $(vst) vst: $(vst)


ifeq ($(HAVE_DGL),true) ifeq ($(HAVE_DGL),true)
$(vst): $(OBJS_DSP) $(OBJS_UI) $(BUILD_DIR)/DistrhoPluginMain_VST.cpp.o $(BUILD_DIR)/DistrhoUIMain_VST.cpp.o $(DPF_PATH)/build/libdgl.a
$(vst): $(OBJS_DSP) $(OBJS_UI) $(BUILD_DIR)/DistrhoPluginMain_VST.cpp.o $(BUILD_DIR)/DistrhoUIMain_VST.cpp.o $(DGL_LIB)
else else
$(vst): $(OBJS_DSP) $(BUILD_DIR)/DistrhoPluginMain_VST.cpp.o $(vst): $(OBJS_DSP) $(BUILD_DIR)/DistrhoPluginMain_VST.cpp.o
endif endif


+ 5
- 108
dgl/Base.hpp View File

@@ -31,104 +31,6 @@
#define END_NAMESPACE_DGL } #define END_NAMESPACE_DGL }
#define USE_NAMESPACE_DGL using namespace DGL_NAMESPACE; #define USE_NAMESPACE_DGL using namespace DGL_NAMESPACE;


#ifdef DISTRHO_OS_WINDOWS
// -----------------------------------------------------------------------
// Fix OpenGL includes for Windows, based on glfw code

#ifndef APIENTRY
# define APIENTRY __stdcall
#endif // APIENTRY

/* We need WINGDIAPI defined */
#ifndef WINGDIAPI
# if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__POCC__)
# define WINGDIAPI __declspec(dllimport)
# elif defined(__LCC__)
# define WINGDIAPI __stdcall
# else
# define WINGDIAPI extern
# endif
# define DGL_WINGDIAPI_DEFINED
#endif // WINGDIAPI

/* Some <GL/glu.h> files also need CALLBACK defined */
#ifndef CALLBACK
# if defined(_MSC_VER)
# if (defined(_M_MRX000) || defined(_M_IX86) || defined(_M_ALPHA) || defined(_M_PPC)) && !defined(MIDL_PASS)
# define CALLBACK __stdcall
# else
# define CALLBACK
# endif
# else
# define CALLBACK __stdcall
# endif
# define DGL_CALLBACK_DEFINED
#endif // CALLBACK

/* Most GL/glu.h variants on Windows need wchar_t */
#include <cstddef>

#endif // DISTRHO_OS_WINDOWS

// -----------------------------------------------------------------------
// OpenGL includes

#ifdef HAVE_DGL

#ifdef DISTRHO_OS_MAC
# include <OpenGL/gl.h>
#else
# ifndef DISTRHO_OS_WINDOWS
# define GL_GLEXT_PROTOTYPES
# endif
# include <GL/gl.h>
# include <GL/glext.h>
#endif

#endif

// -----------------------------------------------------------------------
// Cairo includes

#ifdef HAVE_DCAIRO
# include <cairo/cairo.h>
#endif

// -----------------------------------------------------------------------
// Missing OpenGL defines

#ifdef HAVE_DGL

#if defined(GL_BGR_EXT) && ! defined(GL_BGR)
# define GL_BGR GL_BGR_EXT
#endif

#if defined(GL_BGRA_EXT) && ! defined(GL_BGRA)
# define GL_BGRA GL_BGRA_EXT
#endif

#ifndef GL_CLAMP_TO_BORDER
# define GL_CLAMP_TO_BORDER 0x812D
#endif

#endif

#ifdef DISTRHO_OS_WINDOWS
// -----------------------------------------------------------------------
// Fix OpenGL includes for Windows, based on glfw code

#ifdef DGL_WINGDIAPI_DEFINED
# undef WINGDIAPI
# undef DGL_WINGDIAPI_DEFINED
#endif

#ifdef DGL_CALLBACK_DEFINED
# undef CALLBACK
# undef DGL_CALLBACK_DEFINED
#endif

#endif // DISTRHO_OS_WINDOWS

START_NAMESPACE_DGL START_NAMESPACE_DGL


// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
@@ -187,6 +89,11 @@ enum Key {
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// Base DGL classes // Base DGL classes


/**
Graphics context, definition depends on build type.
*/
struct GraphicsContext;

/** /**
Idle callback. Idle callback.
*/ */
@@ -197,16 +104,6 @@ public:
virtual void idleCallback() = 0; virtual void idleCallback() = 0;
}; };


/**
Graphics context.
*/
struct Context
{
#ifdef HAVE_DCAIRO
cairo_t* cairo;
#endif
};

// ----------------------------------------------------------------------- // -----------------------------------------------------------------------


END_NAMESPACE_DGL END_NAMESPACE_DGL


+ 40
- 0
dgl/Cairo.hpp View File

@@ -0,0 +1,40 @@
/*
* DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2019 Filipe Coelho <falktx@falktx.com>
*
* 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_CAIRO_HPP_INCLUDED
#define DGL_CAIRO_HPP_INCLUDED

#include "Base.hpp"

#include <cairo/cairo.h>

START_NAMESPACE_DGL

// -----------------------------------------------------------------------

/**
Graphics context.
*/
struct GraphicsContext
{
cairo_t* cairo; // FIXME proper name..
};

// -----------------------------------------------------------------------

END_NAMESPACE_DGL

#endif

+ 1
- 5
dgl/Color.hpp View File

@@ -1,6 +1,6 @@
/* /*
* DISTRHO Plugin Framework (DPF) * DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2016 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2012-2019 Filipe Coelho <falktx@falktx.com>
* *
* Permission to use, copy, modify, and/or distribute this software for any purpose with * 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 * or without fee is hereby granted, provided that the above copyright notice and this
@@ -19,9 +19,7 @@


#include "Base.hpp" #include "Base.hpp"


#ifndef HAVE_DCAIRO
struct NVGcolor; struct NVGcolor;
#endif


START_NAMESPACE_DGL START_NAMESPACE_DGL


@@ -97,14 +95,12 @@ struct Color {
*/ */
void fixBounds() noexcept; void fixBounds() noexcept;


#ifndef HAVE_DCAIRO
/** /**
@internal @internal
Needed for NanoVG compatibility. Needed for NanoVG compatibility.
*/ */
Color(const NVGcolor&) noexcept; Color(const NVGcolor&) noexcept;
operator NVGcolor() const noexcept; operator NVGcolor() const noexcept;
#endif
}; };


// ----------------------------------------------------------------------- // -----------------------------------------------------------------------


+ 13
- 24
dgl/Geometry.hpp View File

@@ -346,12 +346,10 @@ public:
*/ */
void moveBy(const Point<T>& pos) noexcept; void moveBy(const Point<T>& pos) noexcept;


#ifdef HAVE_DGL
/** /**
Draw this line using the current OpenGL state. Draw this line using the current OpenGL state.
*/ */
void draw(); void draw();
#endif


/** /**
Return true if line is null (start and end pos are equal). Return true if line is null (start and end pos are equal).
@@ -462,7 +460,6 @@ public:
*/ */
void setNumSegments(const uint num); void setNumSegments(const uint num);


#ifdef HAVE_DGL
/** /**
Draw this circle using the current OpenGL state. Draw this circle using the current OpenGL state.
*/ */
@@ -472,7 +469,6 @@ public:
Draw lines (outline of this circle) using the current OpenGL state. Draw lines (outline of this circle) using the current OpenGL state.
*/ */
void drawOutline(); void drawOutline();
#endif


Circle<T>& operator=(const Circle<T>& cir) noexcept; Circle<T>& operator=(const Circle<T>& cir) noexcept;
bool operator==(const Circle<T>& cir) const noexcept; bool operator==(const Circle<T>& cir) const noexcept;
@@ -486,9 +482,8 @@ private:
// cached values // cached values
float fTheta, fCos, fSin; float fTheta, fCos, fSin;


#ifdef HAVE_DGL
/** @internal */
void _draw(const bool outline); void _draw(const bool outline);
#endif
}; };


// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
@@ -522,18 +517,6 @@ public:
*/ */
Triangle(const Triangle<T>& tri) noexcept; Triangle(const Triangle<T>& tri) noexcept;


#ifdef HAVE_DGL
/**
Draw this triangle using the current OpenGL state.
*/
void draw();

/**
Draw lines (outline of this triangle) using the current OpenGL state.
*/
void drawOutline();
#endif

/** /**
Return true if triangle is null (all its points are equal). Return true if triangle is null (all its points are equal).
An null triangle is also invalid. An null triangle is also invalid.
@@ -557,6 +540,16 @@ public:
*/ */
bool isInvalid() const noexcept; bool isInvalid() const noexcept;


/**
Draw this triangle using the current OpenGL state.
*/
void draw();

/**
Draw lines (outline of this triangle) using the current OpenGL state.
*/
void drawOutline();

Triangle<T>& operator=(const Triangle<T>& tri) noexcept; Triangle<T>& operator=(const Triangle<T>& tri) noexcept;
bool operator==(const Triangle<T>& tri) const noexcept; bool operator==(const Triangle<T>& tri) const noexcept;
bool operator!=(const Triangle<T>& tri) const noexcept; bool operator!=(const Triangle<T>& tri) const noexcept;
@@ -564,9 +557,8 @@ public:
private: private:
Point<T> fPos1, fPos2, fPos3; Point<T> fPos1, fPos2, fPos3;


#ifdef HAVE_DGL
/** @internal */
void _draw(const bool outline); void _draw(const bool outline);
#endif
}; };


// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
@@ -730,7 +722,6 @@ public:
*/ */
bool containsY(const T& y) const noexcept; bool containsY(const T& y) const noexcept;


#ifdef HAVE_DGL
/** /**
Draw this rectangle using the current OpenGL state. Draw this rectangle using the current OpenGL state.
*/ */
@@ -740,7 +731,6 @@ public:
Draw lines (outline of this rectangle) using the current OpenGL state. Draw lines (outline of this rectangle) using the current OpenGL state.
*/ */
void drawOutline(); void drawOutline();
#endif


Rectangle<T>& operator=(const Rectangle<T>& rect) noexcept; Rectangle<T>& operator=(const Rectangle<T>& rect) noexcept;
Rectangle<T>& operator*=(double m) noexcept; Rectangle<T>& operator*=(double m) noexcept;
@@ -752,9 +742,8 @@ private:
Point<T> fPos; Point<T> fPos;
Size<T> fSize; Size<T> fSize;


#ifdef HAVE_DGL
/** @internal */
void _draw(const bool outline); void _draw(const bool outline);
#endif
}; };


// ----------------------------------------------------------------------- // -----------------------------------------------------------------------


+ 30
- 52
dgl/Image.hpp View File

@@ -1,6 +1,6 @@
/* /*
* DISTRHO Plugin Framework (DPF) * DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2016 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2012-2019 Filipe Coelho <falktx@falktx.com>
* *
* Permission to use, copy, modify, and/or distribute this software for any purpose with * 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 * or without fee is hereby granted, provided that the above copyright notice and this
@@ -17,14 +17,15 @@
#ifndef DGL_IMAGE_HPP_INCLUDED #ifndef DGL_IMAGE_HPP_INCLUDED
#define DGL_IMAGE_HPP_INCLUDED #define DGL_IMAGE_HPP_INCLUDED


#include "Geometry.hpp"
#include "ImageBase.hpp"
#include "OpenGL.hpp"


START_NAMESPACE_DGL START_NAMESPACE_DGL


// ----------------------------------------------------------------------- // -----------------------------------------------------------------------


/** /**
Base DGL Image class.
OpenGL Image class.


This is an Image class that handles raw image data in pixels. This is an Image class that handles raw image data in pixels.
You can init the image data on the contructor or later on by calling loadFromMemory(). You can init the image data on the contructor or later on by calling loadFromMemory().
@@ -35,7 +36,7 @@ START_NAMESPACE_DGL


Images are drawn on screen via 2D textures. Images are drawn on screen via 2D textures.
*/ */
class Image
class Image : public ImageBase
{ {
public: public:
/** /**
@@ -47,13 +48,20 @@ public:
Constructor using raw image data. Constructor using raw image data.
@note @a rawData must remain valid for the lifetime of this Image. @note @a rawData must remain valid for the lifetime of this Image.
*/ */
Image(const char* const rawData, const uint width, const uint height, const GLenum format = GL_BGRA, const GLenum type = GL_UNSIGNED_BYTE);
Image(const char* const rawData,
const uint width,
const uint height,
const GLenum format = GL_BGRA,
const GLenum type = GL_UNSIGNED_BYTE);


/** /**
Constructor using raw image data. Constructor using raw image data.
@note @a rawData must remain valid for the lifetime of this Image. @note @a rawData must remain valid for the lifetime of this Image.
*/ */
Image(const char* const rawData, const Size<uint>& size, const GLenum format = GL_BGRA, const GLenum type = GL_UNSIGNED_BYTE);
Image(const char* const rawData,
const Size<uint>& size,
const GLenum format = GL_BGRA,
const GLenum type = GL_UNSIGNED_BYTE);


/** /**
Constructor using another image data. Constructor using another image data.
@@ -63,44 +71,26 @@ public:
/** /**
Destructor. Destructor.
*/ */
~Image();
~Image() override;


/** /**
Load image data from memory. Load image data from memory.
@note @a rawData must remain valid for the lifetime of this Image. @note @a rawData must remain valid for the lifetime of this Image.
*/ */
void loadFromMemory(const char* const rawData, const uint width, const uint height, const GLenum format = GL_BGRA, const GLenum type = GL_UNSIGNED_BYTE) noexcept;
void loadFromMemory(const char* const rawData,
const uint width,
const uint height,
const GLenum format = GL_BGRA,
const GLenum type = GL_UNSIGNED_BYTE) noexcept;


/** /**
Load image data from memory. Load image data from memory.
@note @a rawData must remain valid for the lifetime of this Image. @note @a rawData must remain valid for the lifetime of this Image.
*/ */
void loadFromMemory(const char* const rawData, const Size<uint>& size, const GLenum format = GL_BGRA, const GLenum type = GL_UNSIGNED_BYTE) noexcept;

/**
Check if this image is valid.
*/
bool isValid() const noexcept;

/**
Get width.
*/
uint getWidth() const noexcept;

/**
Get height.
*/
uint getHeight() const noexcept;

/**
Get size.
*/
const Size<uint>& getSize() const noexcept;

/**
Get the raw image data.
*/
const char* getRawData() const noexcept;
void loadFromMemory(const char* const rawData,
const Size<uint>& size,
const GLenum format = GL_BGRA,
const GLenum type = GL_UNSIGNED_BYTE) noexcept;


/** /**
Get the image format. Get the image format.
@@ -113,27 +103,15 @@ public:
GLenum getType() const noexcept; GLenum getType() const noexcept;


/** /**
Draw this image at (0, 0) point.
*/
void draw();

/**
Draw this image at (x, y) point.
TODO document this.
*/ */
void drawAt(const int x, const int y);

/**
Draw this image at position @a pos.
*/
void drawAt(const Point<int>& pos);

Image& operator=(const Image& image) noexcept; Image& operator=(const Image& image) noexcept;
bool operator==(const Image& image) const noexcept;
bool operator!=(const Image& image) const noexcept;

protected:
/** @internal */
void _drawAt(const Point<int>& pos) override;


private: private:
const char* fRawData;
Size<uint> fSize;
GLenum fFormat; GLenum fFormat;
GLenum fType; GLenum fType;
GLuint fTextureId; GLuint fTextureId;
@@ -144,4 +122,4 @@ private:


END_NAMESPACE_DGL END_NAMESPACE_DGL


#endif // DGL_IMAGE_HPP_INCLUDED
#endif

+ 125
- 0
dgl/ImageBase.hpp View File

@@ -0,0 +1,125 @@
/*
* DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2019 Filipe Coelho <falktx@falktx.com>
*
* 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_IMAGE_BASE_HPP_INCLUDED
#define DGL_IMAGE_BASE_HPP_INCLUDED

#include "Geometry.hpp"

START_NAMESPACE_DGL

// -----------------------------------------------------------------------

/**
Base DGL Image class.

This is an Image class that handles raw image data in pixels.
It is an abstract class that provides the common methods to build on top.
Cairo and OpenGL Image classes are based upon this one.

@see Image
*/
class ImageBase
{
protected:
/**
Constructor for a null Image.
*/
ImageBase();

/**
Constructor using raw image data.
@note @a rawData must remain valid for the lifetime of this Image.
*/
ImageBase(const char* const rawData, const uint width, const uint height);

/**
Constructor using raw image data.
@note @a rawData must remain valid for the lifetime of this Image.
*/
ImageBase(const char* const rawData, const Size<uint>& size);

/**
Constructor using another image data.
*/
ImageBase(const ImageBase& image);

public:
/**
Destructor.
*/
virtual ~ImageBase();

/**
Check if this image is valid.
*/
bool isValid() const noexcept;

/**
Get width.
*/
uint getWidth() const noexcept;

/**
Get height.
*/
uint getHeight() const noexcept;

/**
Get size.
*/
const Size<uint>& getSize() const noexcept;

/**
Get the raw image data.
*/
const char* getRawData() const noexcept;

/**
Draw this image at (0, 0) point.
*/
void draw();

/**
Draw this image at (x, y) point.
*/
void drawAt(const int x, const int y);

/**
Draw this image at position @a pos.
*/
void drawAt(const Point<int>& pos);

/**
TODO document this.
*/
ImageBase& operator=(const ImageBase& image) noexcept;
bool operator==(const ImageBase& image) const noexcept;
bool operator!=(const ImageBase& image) const noexcept;

protected:
/** @internal */
virtual void _drawAt(const Point<int>& pos) = 0;

const char* fRawData;
Size<uint> fSize;
};

// -----------------------------------------------------------------------

END_NAMESPACE_DGL

#endif // DGL_IMAGE_HPP_INCLUDED

+ 87
- 19
dgl/Makefile View File

@@ -9,7 +9,7 @@ include ../Makefile.base.mk
# --------------------------------------------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------------------------------------------


BUILD_C_FLAGS += $(DGL_FLAGS) -I. -Isrc BUILD_C_FLAGS += $(DGL_FLAGS) -I. -Isrc
BUILD_CXX_FLAGS += $(DGL_FLAGS) -I. -Isrc
BUILD_CXX_FLAGS += $(DGL_FLAGS) -I. -Isrc -Wno-unused-parameter
LINK_FLAGS += $(DGL_LIBS) LINK_FLAGS += $(DGL_LIBS)


# ifneq ($(MACOS_OLD),true) # ifneq ($(MACOS_OLD),true)
@@ -19,36 +19,78 @@ LINK_FLAGS += $(DGL_LIBS)


# --------------------------------------------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------------------------------------------


OBJS = \
OBJS_common = \
../build/dgl/Application.cpp.o \ ../build/dgl/Application.cpp.o \
../build/dgl/Color.cpp.o \ ../build/dgl/Color.cpp.o \
../build/dgl/Geometry.cpp.o \ ../build/dgl/Geometry.cpp.o \
../build/dgl/Image.cpp.o \
../build/dgl/ImageWidgets.cpp.o \
../build/dgl/NanoVG.cpp.o \
../build/dgl/ImageBase.cpp.o \
../build/dgl/Resources.cpp.o \ ../build/dgl/Resources.cpp.o \
../build/dgl/Widget.cpp.o ../build/dgl/Widget.cpp.o


# TODO: ImageWidgets.cpp

# ---------------------------------------------------------------------------------------------------------------------

OBJS_cairo = $(OBJS_common) \
../build/dgl/Cairo.cpp.cairo.o \
../build/dgl/WidgetPrivateData.cpp.cairo.o

ifeq ($(MACOS),true)
OBJS_cairo += ../build/dgl/Window.mm.cairo.o
else
OBJS_cairo += ../build/dgl/Window.cpp.cairo.o
endif

# ---------------------------------------------------------------------------------------------------------------------

OBJS_opengl = $(OBJS_common) \
../build/dgl/OpenGL.cpp.opengl.o \
../build/dgl/Image.cpp.opengl.o \
../build/dgl/ImageWidgets.cpp.opengl.o \
../build/dgl/NanoVG.cpp.opengl.o \
../build/dgl/WidgetPrivateData.cpp.opengl.o

ifeq ($(MACOS),true) ifeq ($(MACOS),true)
OBJS += ../build/dgl/Window.mm.o
OBJS_opengl += ../build/dgl/Window.mm.opengl.o
else else
OBJS += ../build/dgl/Window.cpp.o
OBJS_opengl += ../build/dgl/Window.cpp.opengl.o
endif endif


TARGET = ../build/libdgl.a
# ---------------------------------------------------------------------------------------------------------------------

ifeq ($(HAVE_CAIRO),true)
TARGETS += ../build/libdgl-cairo.a
endif

ifeq ($(HAVE_OPENGL),true)
TARGETS += ../build/libdgl-opengl.a
# Compat name, to be removed soon
TARGETS += ../build/libdgl.a
endif


# --------------------------------------------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------------------------------------------


all: $(TARGET)
all: $(TARGETS)


# --------------------------------------------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------------------------------------------


../build/libdgl.a: $(OBJS)
../build/libdgl-cairo.a: $(OBJS_cairo)
-@mkdir -p ../build
@echo "Creating libdgl-cairo.a"
@rm -f $@
@$(AR) crs $@ $^

../build/libdgl-opengl.a: $(OBJS_opengl)
-@mkdir -p ../build -@mkdir -p ../build
@echo "Creating libdgl.a"
@echo "Creating libdgl-opengl.a"
@rm -f $@ @rm -f $@
@$(AR) crs $@ $^ @$(AR) crs $@ $^


# Compat name, to be removed soon
../build/libdgl.a: ../build/libdgl-opengl.a
@echo "Symlinking libdgl.a"
@ln -s $< $@

# --------------------------------------------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------------------------------------------


../build/dgl/%.c.o: src/%.c ../build/dgl/%.c.o: src/%.c
@@ -61,26 +103,52 @@ all: $(TARGET)
@echo "Compiling $<" @echo "Compiling $<"
@$(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@ @$(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@


../build/dgl/Window.cpp.o: src/Window.cpp src/sofd/* src/pugl/*
# ---------------------------------------------------------------------------------------------------------------------

../build/dgl/%.cpp.cairo.o: src/%.cpp
-@mkdir -p ../build/dgl -@mkdir -p ../build/dgl
@echo "Compiling $<"
@$(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@
@echo "Compiling $< (Cairo variant)"
@$(CXX) $< $(BUILD_CXX_FLAGS) -DDGL_CAIRO -c -o $@


../build/dgl/Window.mm.o: src/Window.cpp src/sofd/* src/pugl/*
../build/dgl/Window.cpp.cairo.o: src/Window.cpp src/sofd/* src/pugl/*
-@mkdir -p ../build/dgl -@mkdir -p ../build/dgl
@echo "Compiling $<"
@$(CXX) $< $(BUILD_CXX_FLAGS) -ObjC++ -c -o $@
@echo "Compiling $< (Cairo variant)"
@$(CXX) $< $(BUILD_CXX_FLAGS) -DDGL_CAIRO -c -o $@

../build/dgl/Window.mm.cairo.o: src/Window.cpp src/sofd/* src/pugl/*
-@mkdir -p ../build/dgl
@echo "Compiling $< (Cairo variant)"
@$(CXX) $< $(BUILD_CXX_FLAGS) -DDGL_CAIRO -ObjC++ -c -o $@

# ---------------------------------------------------------------------------------------------------------------------

../build/dgl/%.cpp.opengl.o: src/%.cpp
-@mkdir -p ../build/dgl
@echo "Compiling $< (OpenGL variant)"
@$(CXX) $< $(BUILD_CXX_FLAGS) -DDGL_OPENGL -c -o $@

../build/dgl/Window.cpp.opengl.o: src/Window.cpp src/sofd/* src/pugl/*
-@mkdir -p ../build/dgl
@echo "Compiling $< (OpenGL variant)"
@$(CXX) $< $(BUILD_CXX_FLAGS) -DDGL_OPENGL -c -o $@

../build/dgl/Window.mm.opengl.o: src/Window.cpp src/sofd/* src/pugl/*
-@mkdir -p ../build/dgl
@echo "Compiling $< (OpenGL variant)"
@$(CXX) $< $(BUILD_CXX_FLAGS) -DDGL_OPENGL -ObjC++ -c -o $@


# --------------------------------------------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------------------------------------------


clean: clean:
rm -rf ../build/dgl ../build/libdgl.*
rm -rf ../build/dgl ../build/libdgl*.*


debug: debug:
$(MAKE) DEBUG=true $(MAKE) DEBUG=true


# --------------------------------------------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------------------------------------------


-include $(OBJS:%.o=%.d)
-include $(OBJS_common:%.o=%.d)
-include $(OBJS_cairo:%.o=%.d)
-include $(OBJS_opengl:%.o=%.d)


# --------------------------------------------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------------------------------------------

+ 2
- 1
dgl/NanoVG.hpp View File

@@ -1,6 +1,6 @@
/* /*
* DISTRHO Plugin Framework (DPF) * DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2016 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2012-2019 Filipe Coelho <falktx@falktx.com>
* *
* Permission to use, copy, modify, and/or distribute this software for any purpose with * 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 * or without fee is hereby granted, provided that the above copyright notice and this
@@ -18,6 +18,7 @@
#define DGL_NANO_WIDGET_HPP_INCLUDED #define DGL_NANO_WIDGET_HPP_INCLUDED


#include "Color.hpp" #include "Color.hpp"
#include "OpenGL.hpp"
#include "Widget.hpp" #include "Widget.hpp"


#ifndef DGL_NO_SHARED_RESOURCES #ifndef DGL_NO_SHARED_RESOURCES


+ 121
- 0
dgl/OpenGL.hpp View File

@@ -0,0 +1,121 @@
/*
* DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2019 Filipe Coelho <falktx@falktx.com>
*
* 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_OPENGL_HPP_INCLUDED
#define DGL_OPENGL_HPP_INCLUDED

#include "ImageBase.hpp"

// -----------------------------------------------------------------------
// Fix OpenGL includes for Windows, based on glfw code (part 1)

#undef DGL_CALLBACK_DEFINED
#undef DGL_WINGDIAPI_DEFINED

#ifdef DISTRHO_OS_WINDOWS

#ifndef APIENTRY
# define APIENTRY __stdcall
#endif // APIENTRY

/* We need WINGDIAPI defined */
#ifndef WINGDIAPI
# if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__POCC__)
# define WINGDIAPI __declspec(dllimport)
# elif defined(__LCC__)
# define WINGDIAPI __stdcall
# else
# define WINGDIAPI extern
# endif
# define DGL_WINGDIAPI_DEFINED
#endif // WINGDIAPI

/* Some <GL/glu.h> files also need CALLBACK defined */
#ifndef CALLBACK
# if defined(_MSC_VER)
# if (defined(_M_MRX000) || defined(_M_IX86) || defined(_M_ALPHA) || defined(_M_PPC)) && !defined(MIDL_PASS)
# define CALLBACK __stdcall
# else
# define CALLBACK
# endif
# else
# define CALLBACK __stdcall
# endif
# define DGL_CALLBACK_DEFINED
#endif // CALLBACK

/* Most GL/glu.h variants on Windows need wchar_t */
#include <cstddef>

#endif // DISTRHO_OS_WINDOWS

// -----------------------------------------------------------------------
// OpenGL includes

#ifdef DISTRHO_OS_MAC
# include <OpenGL/gl.h>
#else
# ifndef DISTRHO_OS_WINDOWS
# define GL_GLEXT_PROTOTYPES
# endif
# include <GL/gl.h>
# include <GL/glext.h>
#endif

// -----------------------------------------------------------------------
// Missing OpenGL defines

#if defined(GL_BGR_EXT) && !defined(GL_BGR)
# define GL_BGR GL_BGR_EXT
#endif

#if defined(GL_BGRA_EXT) && !defined(GL_BGRA)
# define GL_BGRA GL_BGRA_EXT
#endif

#ifndef GL_CLAMP_TO_BORDER
# define GL_CLAMP_TO_BORDER 0x812D
#endif

// -----------------------------------------------------------------------
// Fix OpenGL includes for Windows, based on glfw code (part 2)

#ifdef DGL_CALLBACK_DEFINED
# undef CALLBACK
# undef DGL_CALLBACK_DEFINED
#endif

#ifdef DGL_WINGDIAPI_DEFINED
# undef WINGDIAPI
# undef DGL_WINGDIAPI_DEFINED
#endif

START_NAMESPACE_DGL

// -----------------------------------------------------------------------

/**
Graphics context.
*/
struct GraphicsContext
{
};

// -----------------------------------------------------------------------

END_NAMESPACE_DGL

#endif

+ 1
- 3
dgl/Widget.hpp View File

@@ -1,6 +1,6 @@
/* /*
* DISTRHO Plugin Framework (DPF) * DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2016 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2012-2019 Filipe Coelho <falktx@falktx.com>
* *
* Permission to use, copy, modify, and/or distribute this software for any purpose with * 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 * or without fee is hereby granted, provided that the above copyright notice and this
@@ -312,8 +312,6 @@ public:
*/ */
Window& getParentWindow() const noexcept; Window& getParentWindow() const noexcept;


const Context& getContext() const noexcept;

/** /**
Check if this widget contains the point defined by @a x and @a y. Check if this widget contains the point defined by @a x and @a y.
*/ */


+ 2
- 2
dgl/Window.hpp View File

@@ -1,6 +1,6 @@
/* /*
* DISTRHO Plugin Framework (DPF) * DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2016 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2012-2019 Filipe Coelho <falktx@falktx.com>
* *
* Permission to use, copy, modify, and/or distribute this software for any purpose with * 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 * or without fee is hereby granted, provided that the above copyright notice and this
@@ -119,7 +119,7 @@ public:
Application& getApp() const noexcept; Application& getApp() const noexcept;
intptr_t getWindowId() const noexcept; intptr_t getWindowId() const noexcept;


const Context& getContext() const noexcept;
const GraphicsContext& getGraphicsContext() const noexcept;


void addIdleCallback(IdleCallback* const callback); void addIdleCallback(IdleCallback* const callback);
void removeIdleCallback(IdleCallback* const callback); void removeIdleCallback(IdleCallback* const callback);


+ 27
- 0
dgl/src/Cairo.cpp View File

@@ -0,0 +1,27 @@
/*
* DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2019 Filipe Coelho <falktx@falktx.com>
*
* 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 "../Base.hpp"

START_NAMESPACE_DGL

// -----------------------------------------------------------------------

// nothing here yet

// -----------------------------------------------------------------------

END_NAMESPACE_DGL

+ 13
- 39
dgl/src/Color.cpp View File

@@ -24,6 +24,19 @@ START_NAMESPACE_DGL


// ----------------------------------------------------------------------- // -----------------------------------------------------------------------


static float computeHue(float h, float m1, float m2)
{
if (h < 0) h += 1;
if (h > 1) h -= 1;
if (h < 1.0f/6.0f)
return m1 + (m2 - m1) * h * 6.0f;
if (h < 3.0f/6.0f)
return m2;
if (h < 4.0f/6.0f)
return m1 + (m2 - m1) * (2.0f/3.0f - h) * 6.0f;
return m1;
}

static void fixRange(float& value) static void fixRange(float& value)
{ {
/**/ if (value < 0.0f) /**/ if (value < 0.0f)
@@ -105,26 +118,8 @@ Color::Color(const Color& color1, const Color& color2, float u) noexcept
interpolate(color2, u); interpolate(color2, u);
} }


#ifndef HAVE_DGL
static float computeHue(float h, float m1, float m2)
{
if (h < 0) h += 1;
if (h > 1) h -= 1;
if (h < 1.0f/6.0f)
return m1 + (m2 - m1) * h * 6.0f;
else if (h < 3.0f/6.0f)
return m2;
else if (h < 4.0f/6.0f)
return m1 + (m2 - m1) * (2.0f/3.0f - h) * 6.0f;
return m1;
}
#endif

Color Color::fromHSL(float hue, float saturation, float lightness, float alpha) Color Color::fromHSL(float hue, float saturation, float lightness, float alpha)
{ {
#ifdef HAVE_DGL
return nvgHSLA(hue, saturation, lightness, static_cast<uchar>(getFixedRange(alpha)*255.0f));
#else
float m1, m2; float m1, m2;
Color col; Color col;
hue = fmodf(hue, 1.0f); hue = fmodf(hue, 1.0f);
@@ -139,7 +134,6 @@ Color Color::fromHSL(float hue, float saturation, float lightness, float alpha)
col.alpha = alpha; col.alpha = alpha;
col.fixBounds(); col.fixBounds();
return col; return col;
#endif
} }


Color Color::fromHTML(const char* rgb, float alpha) Color Color::fromHTML(const char* rgb, float alpha)
@@ -258,24 +252,4 @@ void Color::fixBounds() noexcept


// ----------------------------------------------------------------------- // -----------------------------------------------------------------------


#ifndef HAVE_DCAIRO
Color::Color(const NVGcolor& c) noexcept
: red(c.r), green(c.g), blue(c.b), alpha(c.a)
{
fixBounds();
}

Color::operator NVGcolor() const noexcept
{
NVGcolor nc;
nc.r = red;
nc.g = green;
nc.b = blue;
nc.a = alpha;
return nc;
}
#endif

// -----------------------------------------------------------------------

END_NAMESPACE_DGL END_NAMESPACE_DGL

+ 13
- 103
dgl/src/Geometry.cpp View File

@@ -1,6 +1,6 @@
/* /*
* DISTRHO Plugin Framework (DPF) * DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2016 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2012-2019 Filipe Coelho <falktx@falktx.com>
* *
* Permission to use, copy, modify, and/or distribute this software for any purpose with * 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 * or without fee is hereby granted, provided that the above copyright notice and this
@@ -441,23 +441,6 @@ void Line<T>::moveBy(const Point<T>& pos) noexcept
fPosEnd.moveBy(pos); fPosEnd.moveBy(pos);
} }


#ifdef HAVE_DGL
template<typename T>
void Line<T>::draw()
{
DISTRHO_SAFE_ASSERT_RETURN(fPosStart != fPosEnd,);

glBegin(GL_LINES);

{
glVertex2d(fPosStart.fX, fPosStart.fY);
glVertex2d(fPosEnd.fX, fPosEnd.fY);
}

glEnd();
}
#endif

template<typename T> template<typename T>
bool Line<T>::isNull() const noexcept bool Line<T>::isNull() const noexcept
{ {
@@ -616,7 +599,6 @@ void Circle<T>::setNumSegments(const uint num)
fSin = std::sin(fTheta); fSin = std::sin(fTheta);
} }


#ifdef HAVE_DGL
template<typename T> template<typename T>
void Circle<T>::draw() void Circle<T>::draw()
{ {
@@ -628,7 +610,6 @@ void Circle<T>::drawOutline()
{ {
_draw(true); _draw(true);
} }
#endif


template<typename T> template<typename T>
Circle<T>& Circle<T>::operator=(const Circle<T>& cir) noexcept Circle<T>& Circle<T>::operator=(const Circle<T>& cir) noexcept
@@ -654,29 +635,6 @@ bool Circle<T>::operator!=(const Circle<T>& cir) const noexcept
return (fPos != cir.fPos || d_isNotEqual(fSize, cir.fSize) || fNumSegments != cir.fNumSegments); return (fPos != cir.fPos || d_isNotEqual(fSize, cir.fSize) || fNumSegments != cir.fNumSegments);
} }


#ifdef HAVE_DGL
template<typename T>
void Circle<T>::_draw(const bool outline)
{
DISTRHO_SAFE_ASSERT_RETURN(fNumSegments >= 3 && fSize > 0.0f,);

double t, x = fSize, y = 0.0;

glBegin(outline ? GL_LINE_LOOP : GL_POLYGON);

for (uint i=0; i<fNumSegments; ++i)
{
glVertex2d(x + fPos.fX, y + fPos.fY);

t = x;
x = fCos * x - fSin * y;
y = fSin * t + fCos * y;
}

glEnd();
}
#endif

// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// Triangle // Triangle


@@ -704,20 +662,6 @@ Triangle<T>::Triangle(const Triangle<T>& tri) noexcept
fPos2(tri.fPos2), fPos2(tri.fPos2),
fPos3(tri.fPos3) {} fPos3(tri.fPos3) {}


#ifdef HAVE_DGL
template<typename T>
void Triangle<T>::draw()
{
_draw(false);
}

template<typename T>
void Triangle<T>::drawOutline()
{
_draw(true);
}
#endif

template<typename T> template<typename T>
bool Triangle<T>::isNull() const noexcept bool Triangle<T>::isNull() const noexcept
{ {
@@ -742,6 +686,18 @@ bool Triangle<T>::isInvalid() const noexcept
return fPos1 == fPos2 || fPos1 == fPos3; return fPos1 == fPos2 || fPos1 == fPos3;
} }


template<typename T>
void Triangle<T>::draw()
{
_draw(false);
}

template<typename T>
void Triangle<T>::drawOutline()
{
_draw(true);
}

template<typename T> template<typename T>
Triangle<T>& Triangle<T>::operator=(const Triangle<T>& tri) noexcept Triangle<T>& Triangle<T>::operator=(const Triangle<T>& tri) noexcept
{ {
@@ -763,24 +719,6 @@ bool Triangle<T>::operator!=(const Triangle<T>& tri) const noexcept
return (fPos1 != tri.fPos1 || fPos2 != tri.fPos2 || fPos3 != tri.fPos3); return (fPos1 != tri.fPos1 || fPos2 != tri.fPos2 || fPos3 != tri.fPos3);
} }


#ifdef HAVE_DGL
template<typename T>
void Triangle<T>::_draw(const bool outline)
{
DISTRHO_SAFE_ASSERT_RETURN(fPos1 != fPos2 && fPos1 != fPos3,);

glBegin(outline ? GL_LINE_LOOP : GL_TRIANGLES);

{
glVertex2d(fPos1.fX, fPos1.fY);
glVertex2d(fPos2.fX, fPos2.fY);
glVertex2d(fPos3.fX, fPos3.fY);
}

glEnd();
}
#endif

// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// Rectangle // Rectangle


@@ -962,7 +900,6 @@ bool Rectangle<T>::containsY(const T& y) const noexcept
return (y >= fPos.fY && y <= fPos.fY + fSize.fHeight); return (y >= fPos.fY && y <= fPos.fY + fSize.fHeight);
} }


#ifdef HAVE_DGL
template<typename T> template<typename T>
void Rectangle<T>::draw() void Rectangle<T>::draw()
{ {
@@ -974,7 +911,6 @@ void Rectangle<T>::drawOutline()
{ {
_draw(true); _draw(true);
} }
#endif


template<typename T> template<typename T>
Rectangle<T>& Rectangle<T>::operator=(const Rectangle<T>& rect) noexcept Rectangle<T>& Rectangle<T>::operator=(const Rectangle<T>& rect) noexcept
@@ -1010,32 +946,6 @@ bool Rectangle<T>::operator!=(const Rectangle<T>& rect) const noexcept
return (fPos != rect.fPos || fSize != rect.fSize); return (fPos != rect.fPos || fSize != rect.fSize);
} }


#ifdef HAVE_DGL
template<typename T>
void Rectangle<T>::_draw(const bool outline)
{
DISTRHO_SAFE_ASSERT_RETURN(fSize.isValid(),);

glBegin(outline ? GL_LINE_LOOP : GL_QUADS);

{
glTexCoord2f(0.0f, 0.0f);
glVertex2d(fPos.fX, fPos.fY);

glTexCoord2f(1.0f, 0.0f);
glVertex2d(fPos.fX+fSize.fWidth, fPos.fY);

glTexCoord2f(1.0f, 1.0f);
glVertex2d(fPos.fX+fSize.fWidth, fPos.fY+fSize.fHeight);

glTexCoord2f(0.0f, 1.0f);
glVertex2d(fPos.fX, fPos.fY+fSize.fHeight);
}

glEnd();
}
#endif

// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// Possible template data types // Possible template data types




+ 29
- 73
dgl/src/Image.cpp View File

@@ -1,6 +1,6 @@
/* /*
* DISTRHO Plugin Framework (DPF) * DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2016 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2012-2019 Filipe Coelho <falktx@falktx.com>
* *
* Permission to use, copy, modify, and/or distribute this software for any purpose with * 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 * or without fee is hereby granted, provided that the above copyright notice and this
@@ -21,8 +21,7 @@ START_NAMESPACE_DGL
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------


Image::Image() Image::Image()
: fRawData(nullptr),
fSize(0, 0),
: ImageBase(),
fFormat(0), fFormat(0),
fType(0), fType(0),
fTextureId(0), fTextureId(0),
@@ -31,20 +30,18 @@ Image::Image()
glGenTextures(1, &fTextureId); glGenTextures(1, &fTextureId);
} }


Image::Image(const char* const rawData, const uint width, const uint height, const GLenum format, const GLenum type)
: fRawData(rawData),
fSize(width, height),
fFormat(format),
fType(type),
Image::Image(const Image& image)
: ImageBase(image),
fFormat(image.fFormat),
fType(image.fType),
fTextureId(0), fTextureId(0),
fIsReady(false) fIsReady(false)
{ {
glGenTextures(1, &fTextureId); glGenTextures(1, &fTextureId);
} }


Image::Image(const char* const rawData, const Size<uint>& size, const GLenum format, const GLenum type)
: fRawData(rawData),
fSize(size),
Image::Image(const char* const rawData, const uint width, const uint height, const GLenum format, const GLenum type)
: ImageBase(rawData, width, height),
fFormat(format), fFormat(format),
fType(type), fType(type),
fTextureId(0), fTextureId(0),
@@ -53,11 +50,10 @@ Image::Image(const char* const rawData, const Size<uint>& size, const GLenum for
glGenTextures(1, &fTextureId); glGenTextures(1, &fTextureId);
} }


Image::Image(const Image& image)
: fRawData(image.fRawData),
fSize(image.fSize),
fFormat(image.fFormat),
fType(image.fType),
Image::Image(const char* const rawData, const Size<uint>& size, const GLenum format, const GLenum type)
: ImageBase(rawData, size),
fFormat(format),
fType(type),
fTextureId(0), fTextureId(0),
fIsReady(false) fIsReady(false)
{ {
@@ -75,12 +71,19 @@ Image::~Image()
} }
} }


void Image::loadFromMemory(const char* const rawData, const uint width, const uint height, const GLenum format, const GLenum type) noexcept
void Image::loadFromMemory(const char* const rawData,
const uint width,
const uint height,
const GLenum format,
const GLenum type) noexcept
{ {
loadFromMemory(rawData, Size<uint>(width, height), format, type); loadFromMemory(rawData, Size<uint>(width, height), format, type);
} }


void Image::loadFromMemory(const char* const rawData, const Size<uint>& size, const GLenum format, const GLenum type) noexcept
void Image::loadFromMemory(const char* const rawData,
const Size<uint>& size,
const GLenum format,
const GLenum type) noexcept
{ {
fRawData = rawData; fRawData = rawData;
fSize = size; fSize = size;
@@ -89,31 +92,6 @@ void Image::loadFromMemory(const char* const rawData, const Size<uint>& size, co
fIsReady = false; fIsReady = false;
} }


bool Image::isValid() const noexcept
{
return (fRawData != nullptr && fSize.getWidth() > 0 && fSize.getHeight() > 0);
}

uint Image::getWidth() const noexcept
{
return fSize.getWidth();
}

uint Image::getHeight() const noexcept
{
return fSize.getHeight();
}

const Size<uint>& Image::getSize() const noexcept
{
return fSize;
}

const char* Image::getRawData() const noexcept
{
return fRawData;
}

GLenum Image::getFormat() const noexcept GLenum Image::getFormat() const noexcept
{ {
return fFormat; return fFormat;
@@ -124,17 +102,17 @@ GLenum Image::getType() const noexcept
return fType; return fType;
} }


void Image::draw()
{
drawAt(0, 0);
}

void Image::drawAt(const int x, const int y)
Image& Image::operator=(const Image& image) noexcept
{ {
drawAt(Point<int>(x, y));
fRawData = image.fRawData;
fSize = image.fSize;
fFormat = image.fFormat;
fType = image.fType;
fIsReady = false;
return *this;
} }


void Image::drawAt(const Point<int>& pos)
void Image::_drawAt(const Point<int>& pos)
{ {
if (fTextureId == 0 || ! isValid()) if (fTextureId == 0 || ! isValid())
return; return;
@@ -169,26 +147,4 @@ void Image::drawAt(const Point<int>& pos)


// ----------------------------------------------------------------------- // -----------------------------------------------------------------------


Image& Image::operator=(const Image& image) noexcept
{
fRawData = image.fRawData;
fSize = image.fSize;
fFormat = image.fFormat;
fType = image.fType;
fIsReady = false;
return *this;
}

bool Image::operator==(const Image& image) const noexcept
{
return (fRawData == image.fRawData && fSize == image.fSize);
}

bool Image::operator!=(const Image& image) const noexcept
{
return !operator==(image);
}

// -----------------------------------------------------------------------

END_NAMESPACE_DGL END_NAMESPACE_DGL

+ 106
- 0
dgl/src/ImageBase.cpp View File

@@ -0,0 +1,106 @@
/*
* DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2019 Filipe Coelho <falktx@falktx.com>
*
* 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 "../ImageBase.hpp"

START_NAMESPACE_DGL

// -----------------------------------------------------------------------

ImageBase::ImageBase()
: fRawData(nullptr),
fSize(0, 0) {}

ImageBase::ImageBase(const char* const rawData, const uint width, const uint height)
: fRawData(rawData),
fSize(width, height) {}

ImageBase::ImageBase(const char* const rawData, const Size<uint>& size)
: fRawData(rawData),
fSize(size) {}

ImageBase::ImageBase(const ImageBase& image)
: fRawData(image.fRawData),
fSize(image.fSize) {}

ImageBase::~ImageBase() {}

// -----------------------------------------------------------------------

bool ImageBase::isValid() const noexcept
{
return (fRawData != nullptr && fSize.isValid());
}

uint ImageBase::getWidth() const noexcept
{
return fSize.getWidth();
}

uint ImageBase::getHeight() const noexcept
{
return fSize.getHeight();
}

const Size<uint>& ImageBase::getSize() const noexcept
{
return fSize;
}

const char* ImageBase::getRawData() const noexcept
{
return fRawData;
}

// -----------------------------------------------------------------------

void ImageBase::draw()
{
_drawAt(Point<int>());
}

void ImageBase::drawAt(const int x, const int y)
{
_drawAt(Point<int>(x, y));
}

void ImageBase::drawAt(const Point<int>& pos)
{
_drawAt(pos);
}

// -----------------------------------------------------------------------

ImageBase& ImageBase::operator=(const ImageBase& image) noexcept
{
fRawData = image.fRawData;
fSize = image.fSize;
return *this;
}

bool ImageBase::operator==(const ImageBase& image) const noexcept
{
return (fRawData == image.fRawData && fSize == image.fSize);
}

bool ImageBase::operator!=(const ImageBase& image) const noexcept
{
return !operator==(image);
}

// -----------------------------------------------------------------------

END_NAMESPACE_DGL

+ 5
- 1
dgl/src/ImageWidgets.cpp View File

@@ -1,6 +1,6 @@
/* /*
* DISTRHO Plugin Framework (DPF) * DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2016 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2012-2019 Filipe Coelho <falktx@falktx.com>
* *
* Permission to use, copy, modify, and/or distribute this software for any purpose with * 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 * or without fee is hereby granted, provided that the above copyright notice and this
@@ -14,9 +14,13 @@
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */


#include "../Image.hpp"
#include "Common.hpp" #include "Common.hpp"
#include "WidgetPrivateData.hpp" #include "WidgetPrivateData.hpp"


// FIXME make this code more generic and move GL specific bits to OpenGL.cpp
#include "../OpenGL.hpp"

START_NAMESPACE_DGL START_NAMESPACE_DGL


// ----------------------------------------------------------------------- // -----------------------------------------------------------------------


+ 20
- 1
dgl/src/NanoVG.cpp View File

@@ -1,6 +1,6 @@
/* /*
* DISTRHO Plugin Framework (DPF) * DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2018 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2012-2019 Filipe Coelho <falktx@falktx.com>
* *
* Permission to use, copy, modify, and/or distribute this software for any purpose with * 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 * or without fee is hereby granted, provided that the above copyright notice and this
@@ -124,6 +124,25 @@ DGL_EXT(PFNGLVERTEXATTRIBPOINTERPROC, glVertexAttribPointer)


START_NAMESPACE_DGL START_NAMESPACE_DGL


// -----------------------------------------------------------------------
// DGL Color class conversion

Color::Color(const NVGcolor& c) noexcept
: red(c.r), green(c.g), blue(c.b), alpha(c.a)
{
fixBounds();
}

Color::operator NVGcolor() const noexcept
{
NVGcolor nc;
nc.r = red;
nc.g = green;
nc.b = blue;
nc.a = alpha;
return nc;
}

// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// NanoImage // NanoImage




+ 157
- 0
dgl/src/OpenGL.cpp View File

@@ -0,0 +1,157 @@
/*
* DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2019 Filipe Coelho <falktx@falktx.com>
*
* 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 "../Geometry.hpp"
#include "../OpenGL.hpp"

START_NAMESPACE_DGL

// -----------------------------------------------------------------------
// Line

template<typename T>
void Line<T>::draw()
{
DISTRHO_SAFE_ASSERT_RETURN(fPosStart != fPosEnd,);

glBegin(GL_LINES);

{
glVertex2d(fPosStart.fX, fPosStart.fY);
glVertex2d(fPosEnd.fX, fPosEnd.fY);
}

glEnd();
}

// -----------------------------------------------------------------------
// Circle

template<typename T>
void Circle<T>::_draw(const bool outline)
{
DISTRHO_SAFE_ASSERT_RETURN(fNumSegments >= 3 && fSize > 0.0f,);

double t, x = fSize, y = 0.0;

glBegin(outline ? GL_LINE_LOOP : GL_POLYGON);

for (uint i=0; i<fNumSegments; ++i)
{
glVertex2d(x + fPos.fX, y + fPos.fY);

t = x;
x = fCos * x - fSin * y;
y = fSin * t + fCos * y;
}

glEnd();
}

// -----------------------------------------------------------------------
// Triangle

template<typename T>
void Triangle<T>::_draw(const bool outline)
{
DISTRHO_SAFE_ASSERT_RETURN(fPos1 != fPos2 && fPos1 != fPos3,);

glBegin(outline ? GL_LINE_LOOP : GL_TRIANGLES);

{
glVertex2d(fPos1.fX, fPos1.fY);
glVertex2d(fPos2.fX, fPos2.fY);
glVertex2d(fPos3.fX, fPos3.fY);
}

glEnd();
}

// -----------------------------------------------------------------------
// Rectangle

template<typename T>
void Rectangle<T>::_draw(const bool outline)
{
DISTRHO_SAFE_ASSERT_RETURN(fSize.isValid(),);

glBegin(outline ? GL_LINE_LOOP : GL_QUADS);

{
glTexCoord2f(0.0f, 0.0f);
glVertex2d(fPos.fX, fPos.fY);

glTexCoord2f(1.0f, 0.0f);
glVertex2d(fPos.fX+fSize.fWidth, fPos.fY);

glTexCoord2f(1.0f, 1.0f);
glVertex2d(fPos.fX+fSize.fWidth, fPos.fY+fSize.fHeight);

glTexCoord2f(0.0f, 1.0f);
glVertex2d(fPos.fX, fPos.fY+fSize.fHeight);
}

glEnd();
}

// -----------------------------------------------------------------------
// Possible template data types

template class Point<double>;
template class Point<float>;
template class Point<int>;
template class Point<uint>;
template class Point<short>;
template class Point<ushort>;

template class Size<double>;
template class Size<float>;
template class Size<int>;
template class Size<uint>;
template class Size<short>;
template class Size<ushort>;

template class Line<double>;
template class Line<float>;
template class Line<int>;
template class Line<uint>;
template class Line<short>;
template class Line<ushort>;

template class Circle<double>;
template class Circle<float>;
template class Circle<int>;
template class Circle<uint>;
template class Circle<short>;
template class Circle<ushort>;

template class Triangle<double>;
template class Triangle<float>;
template class Triangle<int>;
template class Triangle<uint>;
template class Triangle<short>;
template class Triangle<ushort>;

template class Rectangle<double>;
template class Rectangle<float>;
template class Rectangle<int>;
template class Rectangle<uint>;
template class Rectangle<short>;
template class Rectangle<ushort>;

// -----------------------------------------------------------------------

END_NAMESPACE_DGL

+ 1
- 6
dgl/src/Widget.cpp View File

@@ -1,6 +1,6 @@
/* /*
* DISTRHO Plugin Framework (DPF) * DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2016 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2012-2019 Filipe Coelho <falktx@falktx.com>
* *
* Permission to use, copy, modify, and/or distribute this software for any purpose with * 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 * or without fee is hereby granted, provided that the above copyright notice and this
@@ -189,11 +189,6 @@ Window& Widget::getParentWindow() const noexcept
return pData->parent; return pData->parent;
} }


const Context& Widget::getContext() const noexcept
{
return pData->parent.getContext();
}

bool Widget::contains(int x, int y) const noexcept bool Widget::contains(int x, int y) const noexcept
{ {
return (x >= 0 && y >= 0 && static_cast<uint>(x) < pData->size.getWidth() && static_cast<uint>(y) < pData->size.getHeight()); return (x >= 0 && y >= 0 && static_cast<uint>(x) < pData->size.getWidth() && static_cast<uint>(y) < pData->size.getHeight());


+ 92
- 0
dgl/src/WidgetPrivateData.cpp View File

@@ -0,0 +1,92 @@
/*
* DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2019 Filipe Coelho <falktx@falktx.com>
*
* 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 "WidgetPrivateData.hpp"

#ifdef DGL_OPENGL
# include "../OpenGL.hpp"
#endif

START_NAMESPACE_DGL

// -----------------------------------------------------------------------

void Widget::PrivateData::display(const uint width,
const uint height,
const double scaling,
const bool renderingSubWidget)
{
if ((skipDisplay && ! renderingSubWidget) || size.isInvalid() || ! visible)
return;

#ifdef DGL_OPENGL
bool needsDisableScissor = false;

// reset color
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);

if (needsFullViewport || (absolutePos.isZero() && size == Size<uint>(width, height)))
{
// full viewport size
glViewport(0,
-(height * scaling - height),
width * scaling,
height * scaling);
}
else if (needsScaling)
{
// limit viewport to widget bounds
glViewport(absolutePos.getX(),
height - self->getHeight() - absolutePos.getY(),
self->getWidth(),
self->getHeight());
}
else
{
// only set viewport pos
glViewport(absolutePos.getX() * scaling,
-std::round((height * scaling - height) + (absolutePos.getY() * scaling)),
std::round(width * scaling),
std::round(height * scaling));

// then cut the outer bounds
glScissor(absolutePos.getX() * scaling,
height - std::round((self->getHeight() + absolutePos.getY()) * scaling),
std::round(self->getWidth() * scaling),
std::round(self->getHeight() * scaling));

glEnable(GL_SCISSOR_TEST);
needsDisableScissor = true;
}
#endif

// display widget
self->onDisplay();

#ifdef DGL_OPENGL
if (needsDisableScissor)
{
glDisable(GL_SCISSOR_TEST);
needsDisableScissor = false;
}
#endif

displaySubWidgets(width, height, scaling);
}

// -----------------------------------------------------------------------

END_NAMESPACE_DGL

+ 3
- 60
dgl/src/WidgetPrivateData.hpp View File

@@ -1,6 +1,6 @@
/* /*
* DISTRHO Plugin Framework (DPF) * DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2018 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2012-2019 Filipe Coelho <falktx@falktx.com>
* *
* Permission to use, copy, modify, and/or distribute this software for any purpose with * 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 * or without fee is hereby granted, provided that the above copyright notice and this
@@ -63,65 +63,8 @@ struct Widget::PrivateData {
subWidgets.clear(); subWidgets.clear();
} }


void display(const uint width, const uint height, const double scaling, const bool renderingSubWidget)
{
if ((skipDisplay && ! renderingSubWidget) || size.isInvalid() || ! visible)
return;

#ifdef HAVE_DGL
bool needsDisableScissor = false;

// reset color
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);

if (needsFullViewport || (absolutePos.isZero() && size == Size<uint>(width, height)))
{
// full viewport size
glViewport(0,
-(height * scaling - height),
width * scaling,
height * scaling);
}
else if (needsScaling)
{
// limit viewport to widget bounds
glViewport(absolutePos.getX(),
height - self->getHeight() - absolutePos.getY(),
self->getWidth(),
self->getHeight());
}
else
{
// only set viewport pos
glViewport(absolutePos.getX() * scaling,
-std::round((height * scaling - height) + (absolutePos.getY() * scaling)),
std::round(width * scaling),
std::round(height * scaling));

// then cut the outer bounds
glScissor(absolutePos.getX() * scaling,
height - std::round((self->getHeight() + absolutePos.getY()) * scaling),
std::round(self->getWidth() * scaling),
std::round(self->getHeight() * scaling));

glEnable(GL_SCISSOR_TEST);
needsDisableScissor = true;
}
#endif

// display widget
self->onDisplay();

#ifdef HAVE_DGL
if (needsDisableScissor)
{
glDisable(GL_SCISSOR_TEST);
needsDisableScissor = false;
}
#endif

displaySubWidgets(width, height, scaling);
}
// display function is different depending on build type
void display(const uint width, const uint height, const double scaling, const bool renderingSubWidget);


void displaySubWidgets(const uint width, const uint height, const double scaling) void displaySubWidgets(const uint width, const uint height, const double scaling)
{ {


+ 16
- 18
dgl/src/Window.cpp View File

@@ -19,14 +19,13 @@


#include "../Base.hpp" #include "../Base.hpp"


#undef PUGL_HAVE_CAIRO
#undef PUGL_HAVE_GL

#ifdef HAVE_DGL
#define PUGL_HAVE_GL 1
#ifdef DGL_CAIRO
# define PUGL_CAIRO
# include "../Cairo.hpp"
#endif #endif
#ifdef HAVE_DCAIRO
#define PUGL_HAVE_CAIRO 1
#ifdef DGL_OPENGL
# define PUGL_OPENGL
# include "../OpenGL.hpp"
#endif #endif


#include "pugl/pugl.h" #include "pugl/pugl.h"
@@ -1049,10 +1048,10 @@ struct Window::PrivateData {


// ------------------------------------------------------------------- // -------------------------------------------------------------------


Application& fApp;
Window* fSelf;
Context fContext;
PuglView* fView;
Application& fApp;
Window* fSelf;
GraphicsContext fContext;
PuglView* fView;


bool fFirstInit; bool fFirstInit;
bool fVisible; bool fVisible;
@@ -1377,12 +1376,11 @@ intptr_t Window::getWindowId() const noexcept
return puglGetNativeWindow(pData->fView); return puglGetNativeWindow(pData->fView);
} }


const Context& Window::getContext() const noexcept
const GraphicsContext& Window::getGraphicsContext() const noexcept
{ {
Context& context = pData->fContext;
#ifdef HAVE_DCAIRO
if (context.type == kContextCairo)
context.cairo.graphics = (cairo_t*)puglGetContext(pData->fView);
GraphicsContext& context = pData->fContext;
#ifdef DGL_CAIRO
context.cairo = (cairo_t*)puglGetContext(pData->fView);
#endif #endif
return context; return context;
} }
@@ -1422,7 +1420,7 @@ void Window::removeIdleCallback(IdleCallback* const callback)


void Window::onDisplayBefore() void Window::onDisplayBefore()
{ {
#ifdef HAVE_DGL
#ifdef DGL_OPENGL
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity(); glLoadIdentity();
#endif #endif
@@ -1434,7 +1432,7 @@ void Window::onDisplayAfter()


void Window::onReshape(uint width, uint height) void Window::onReshape(uint width, uint height)
{ {
#ifdef HAVE_DGL
#ifdef DGL_OPENGL
glEnable(GL_BLEND); glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);


+ 35
- 41
dgl/src/pugl/pugl.h View File

@@ -30,19 +30,13 @@
platforms so they are included here to allow for pure portable programs. platforms so they are included here to allow for pure portable programs.
*/ */
#ifdef __APPLE__ #ifdef __APPLE__
# include "OpenGL/gl.h"
# include <OpenGL/gl.h>
#else #else
# ifdef _WIN32 # ifdef _WIN32
# include <winsock2.h> # include <winsock2.h>
# include <windows.h> /* Broken Windows GL headers require this */ # include <windows.h> /* Broken Windows GL headers require this */
# endif # endif
# include "GL/gl.h"
#endif

#ifdef _WIN32
# define PUGL_API
#else
# define PUGL_API __attribute__((visibility("hidden")))
# include <GL/gl.h>
#endif #endif


#ifdef __cplusplus #ifdef __cplusplus
@@ -238,31 +232,31 @@ typedef void (*PuglFileSelectedFunc)(PuglView* view, const char* filename);
To create a window, call the various puglInit* functions as necessary, then To create a window, call the various puglInit* functions as necessary, then
call puglCreateWindow(). call puglCreateWindow().
*/ */
PUGL_API PuglView*
PuglView*
puglInit(void); puglInit(void);


/** /**
Set the parent window before creating a window (for embedding). Set the parent window before creating a window (for embedding).
*/ */
PUGL_API void
void
puglInitWindowParent(PuglView* view, PuglNativeWindow parent); puglInitWindowParent(PuglView* view, PuglNativeWindow parent);


/** /**
Set the window size before creating a window. Set the window size before creating a window.
*/ */
PUGL_API void
void
puglInitWindowSize(PuglView* view, int width, int height); puglInitWindowSize(PuglView* view, int width, int height);


/** /**
Set the minimum window size before creating a window. Set the minimum window size before creating a window.
*/ */
PUGL_API void
void
puglInitWindowMinSize(PuglView* view, int width, int height); puglInitWindowMinSize(PuglView* view, int width, int height);


/** /**
Enable or disable resizing before creating a window. Enable or disable resizing before creating a window.
*/ */
PUGL_API void
void
puglInitUserResizable(PuglView* view, bool resizable); puglInitUserResizable(PuglView* view, bool resizable);


/** /**
@@ -271,7 +265,7 @@ puglInitUserResizable(PuglView* view, bool resizable);
On X11, parent_id must be a Window. On X11, parent_id must be a Window.
On OSX, parent_id must be an NSView*. On OSX, parent_id must be an NSView*.
*/ */
PUGL_API void
void
puglInitTransientFor(PuglView* view, uintptr_t parent); puglInitTransientFor(PuglView* view, uintptr_t parent);


/** /**
@@ -289,7 +283,7 @@ puglInitTransientFor(PuglView* view, uintptr_t parent);


@return 1 (pugl does not currently support multiple windows). @return 1 (pugl does not currently support multiple windows).
*/ */
PUGL_API int
int
puglCreateWindow(PuglView* view, const char* title); puglCreateWindow(PuglView* view, const char* title);


/** /**
@@ -300,7 +294,7 @@ puglCreateWindow(PuglView* view, const char* title);
@param height Window height in pixels. @param height Window height in pixels.
@param resizable Whether window should be user resizable. @param resizable Whether window should be user resizable.
*/ */
PUGL_API PuglView*
PuglView*
puglCreate(PuglNativeWindow parent, puglCreate(PuglNativeWindow parent,
const char* title, const char* title,
int min_width, int min_width,
@@ -313,19 +307,19 @@ puglCreate(PuglNativeWindow parent,
/** /**
Show Window (external ui) Show Window (external ui)
*/ */
PUGL_API void
void
puglShowWindow(PuglView* view); puglShowWindow(PuglView* view);


/** /**
Hide Window (external ui) Hide Window (external ui)
*/ */
PUGL_API void
void
puglHideWindow(PuglView* view); puglHideWindow(PuglView* view);


/** /**
Return the native window handle. Return the native window handle.
*/ */
PUGL_API PuglNativeWindow
PuglNativeWindow
puglGetNativeWindow(PuglView* view); puglGetNativeWindow(PuglView* view);


/** /**
@@ -341,13 +335,13 @@ puglGetNativeWindow(PuglView* view);
Note the lack of this facility makes GLUT unsuitable for plugins or Note the lack of this facility makes GLUT unsuitable for plugins or
non-trivial programs; this mistake is largely why Pugl exists. non-trivial programs; this mistake is largely why Pugl exists.
*/ */
PUGL_API void
void
puglSetHandle(PuglView* view, PuglHandle handle); puglSetHandle(PuglView* view, PuglHandle handle);


/** /**
Get the handle to be passed to all callbacks. Get the handle to be passed to all callbacks.
*/ */
PUGL_API PuglHandle
PuglHandle
puglGetHandle(PuglView* view); puglGetHandle(PuglView* view);


/** /**
@@ -355,13 +349,13 @@ puglGetHandle(PuglView* view);
For Cairo contexts, this returns a pointer to a cairo_t. For Cairo contexts, this returns a pointer to a cairo_t.
For everything else, this is unused and returns NULL. For everything else, this is unused and returns NULL.
*/ */
PUGL_API void*
void*
puglGetContext(PuglView* view); puglGetContext(PuglView* view);


/** /**
Return the timestamp (if any) of the currently-processing event. Return the timestamp (if any) of the currently-processing event.
*/ */
PUGL_API uint32_t
uint32_t
puglGetEventTimestamp(PuglView* view); puglGetEventTimestamp(PuglView* view);


/** /**
@@ -369,13 +363,13 @@ puglGetEventTimestamp(PuglView* view);


This should only be called from an event handler. This should only be called from an event handler.
*/ */
PUGL_API int
int
puglGetModifiers(PuglView* view); puglGetModifiers(PuglView* view);


/** /**
Ignore synthetic repeated key events. Ignore synthetic repeated key events.
*/ */
PUGL_API void
void
puglIgnoreKeyRepeat(PuglView* view, bool ignore); puglIgnoreKeyRepeat(PuglView* view, bool ignore);


/** /**
@@ -387,61 +381,61 @@ puglIgnoreKeyRepeat(PuglView* view, bool ignore);
/** /**
Set the function to call when the window is closed. Set the function to call when the window is closed.
*/ */
PUGL_API void
void
puglSetCloseFunc(PuglView* view, PuglCloseFunc closeFunc); puglSetCloseFunc(PuglView* view, PuglCloseFunc closeFunc);


/** /**
Set the display function which should draw the UI using GL. Set the display function which should draw the UI using GL.
*/ */
PUGL_API void
void
puglSetDisplayFunc(PuglView* view, PuglDisplayFunc displayFunc); puglSetDisplayFunc(PuglView* view, PuglDisplayFunc displayFunc);


/** /**
Set the function to call on keyboard events. Set the function to call on keyboard events.
*/ */
PUGL_API void
void
puglSetKeyboardFunc(PuglView* view, PuglKeyboardFunc keyboardFunc); puglSetKeyboardFunc(PuglView* view, PuglKeyboardFunc keyboardFunc);


/** /**
Set the function to call on mouse motion. Set the function to call on mouse motion.
*/ */
PUGL_API void
void
puglSetMotionFunc(PuglView* view, PuglMotionFunc motionFunc); puglSetMotionFunc(PuglView* view, PuglMotionFunc motionFunc);


/** /**
Set the function to call on mouse button events. Set the function to call on mouse button events.
*/ */
PUGL_API void
void
puglSetMouseFunc(PuglView* view, PuglMouseFunc mouseFunc); puglSetMouseFunc(PuglView* view, PuglMouseFunc mouseFunc);


/** /**
Set the function to call on scroll events. Set the function to call on scroll events.
*/ */
PUGL_API void
void
puglSetScrollFunc(PuglView* view, PuglScrollFunc scrollFunc); puglSetScrollFunc(PuglView* view, PuglScrollFunc scrollFunc);


/** /**
Set the function to call on special events. Set the function to call on special events.
*/ */
PUGL_API void
void
puglSetSpecialFunc(PuglView* view, PuglSpecialFunc specialFunc); puglSetSpecialFunc(PuglView* view, PuglSpecialFunc specialFunc);


/** /**
Set the function to call when the window size changes. Set the function to call when the window size changes.
*/ */
PUGL_API void
void
puglSetReshapeFunc(PuglView* view, PuglReshapeFunc reshapeFunc); puglSetReshapeFunc(PuglView* view, PuglReshapeFunc reshapeFunc);


/** /**
Set callback function to change window size. Set callback function to change window size.
*/ */
PUGL_API void
void
puglSetResizeFunc(PuglView* view, PuglResizeFunc resizeFunc); puglSetResizeFunc(PuglView* view, PuglResizeFunc resizeFunc);


/** /**
Set the function to call on file-browser selections. Set the function to call on file-browser selections.
*/ */
PUGL_API void
void
puglSetFileSelectedFunc(PuglView* view, PuglFileSelectedFunc fileSelectedFunc); puglSetFileSelectedFunc(PuglView* view, PuglFileSelectedFunc fileSelectedFunc);


/** /**
@@ -451,13 +445,13 @@ puglSetFileSelectedFunc(PuglView* view, PuglFileSelectedFunc fileSelectedFunc);
/** /**
TODO document this. TODO document this.
*/ */
PUGL_API int
int
puglUpdateGeometryConstraints(PuglView* view, int min_width, int min_height, bool aspect); puglUpdateGeometryConstraints(PuglView* view, int min_width, int min_height, bool aspect);


/** /**
Grab the input focus. Grab the input focus.
*/ */
PUGL_API void
void
puglGrabFocus(PuglView* view); puglGrabFocus(PuglView* view);


/** /**
@@ -466,25 +460,25 @@ puglGrabFocus(PuglView* view);
This handles input events as well as rendering, so it should be called This handles input events as well as rendering, so it should be called
regularly and rapidly enough to keep the UI responsive. regularly and rapidly enough to keep the UI responsive.
*/ */
PUGL_API PuglStatus
PuglStatus
puglProcessEvents(PuglView* view); puglProcessEvents(PuglView* view);


/** /**
Request a redisplay on the next call to puglProcessEvents(). Request a redisplay on the next call to puglProcessEvents().
*/ */
PUGL_API void
void
puglPostRedisplay(PuglView* view); puglPostRedisplay(PuglView* view);


/** /**
Request a resize on the next call to puglProcessEvents(). Request a resize on the next call to puglProcessEvents().
*/ */
PUGL_API void
void
puglPostResize(PuglView* view); puglPostResize(PuglView* view);


/** /**
Destroy a GL window. Destroy a GL window.
*/ */
PUGL_API void
void
puglDestroy(PuglView* view); puglDestroy(PuglView* view);


/** /**


+ 2
- 2
dgl/src/pugl/pugl_internal.h View File

@@ -240,7 +240,7 @@ puglLeaveContext(PuglView* view, bool flush);
static void static void
puglDefaultReshape(int width, int height) puglDefaultReshape(int width, int height)
{ {
#ifdef PUGL_HAVE_GL
#ifdef PUGL_OPENGL
#ifdef ROBTK_HERE #ifdef ROBTK_HERE
glViewport(0, 0, width, height); glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
@@ -259,5 +259,5 @@ puglDefaultReshape(int width, int height)
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
glLoadIdentity(); glLoadIdentity();
#endif #endif
#endif
#endif // PUGL_OPENGL
} }

+ 11
- 11
dgl/src/pugl/pugl_osx.m View File

@@ -21,11 +21,11 @@


#include <stdlib.h> #include <stdlib.h>


#import <Cocoa/Cocoa.h>
#ifdef PUGL_HAVE_CAIRO
#ifdef PUGL_CAIRO
#import <cairo.h> #import <cairo.h>
#import <cairo-quartz.h> #import <cairo-quartz.h>
#endif #endif
#import <Cocoa/Cocoa.h>


#include "pugl_internal.h" #include "pugl_internal.h"


@@ -290,7 +290,7 @@ flagsChanged(NSView<PuglGenericView> *self, NSEvent *event)
} }
} }


#ifdef PUGL_HAVE_GL
#ifdef PUGL_OPENGL
@interface PuglOpenGLView : NSOpenGLView<PuglGenericView> @interface PuglOpenGLView : NSOpenGLView<PuglGenericView>
{ {
@public @public
@@ -530,7 +530,7 @@ flagsChanged(NSView<PuglGenericView> *self, NSEvent *event)
@end @end
#endif #endif


#ifdef PUGL_HAVE_CAIRO
#ifdef PUGL_CAIRO
@interface PuglCairoView : NSView<PuglGenericView> @interface PuglCairoView : NSView<PuglGenericView>
{ {
PuglView* puglview; PuglView* puglview;
@@ -755,10 +755,10 @@ flagsChanged(NSView<PuglGenericView> *self, NSEvent *event)
struct PuglInternalsImpl { struct PuglInternalsImpl {
union { union {
NSView<PuglGenericView>* view; NSView<PuglGenericView>* view;
#ifdef PUGL_HAVE_GL
#ifdef PUGL_OPENGL
PuglOpenGLView* glview; PuglOpenGLView* glview;
#endif #endif
#ifdef PUGL_HAVE_CAIRO
#ifdef PUGL_CAIRO
PuglCairoView* cairoview; PuglCairoView* cairoview;
#endif #endif
}; };
@@ -774,7 +774,7 @@ puglInitInternals()
void void
puglEnterContext(PuglView* view) puglEnterContext(PuglView* view)
{ {
#ifdef PUGL_HAVE_GL
#ifdef PUGL_OPENGL
[[view->impl->glview openGLContext] makeCurrentContext]; [[view->impl->glview openGLContext] makeCurrentContext];
#endif #endif
} }
@@ -783,7 +783,7 @@ void
puglLeaveContext(PuglView* view, bool flush) puglLeaveContext(PuglView* view, bool flush)
{ {
if (flush) { if (flush) {
#ifdef PUGL_HAVE_GL
#ifdef PUGL_OPENGL
if (view->impl->glview->doubleBuffered) { if (view->impl->glview->doubleBuffered) {
[[view->impl->glview openGLContext] flushBuffer]; [[view->impl->glview openGLContext] flushBuffer];
} else { } else {
@@ -802,10 +802,10 @@ puglCreateWindow(PuglView* view, const char* title)
[NSAutoreleasePool new]; [NSAutoreleasePool new];
[NSApplication sharedApplication]; [NSApplication sharedApplication];


#ifdef PUGL_HAVE_GL
#ifdef PUGL_OPENGL
impl->glview = [PuglOpenGLView new]; impl->glview = [PuglOpenGLView new];
#endif #endif
#ifdef PUGL_HAVE_CAIRO
#ifdef PUGL_CAIRO
impl->cairoview = [PuglCairoView new]; impl->cairoview = [PuglCairoView new];
#endif #endif


@@ -919,7 +919,7 @@ puglGetNativeWindow(PuglView* view)
void* void*
puglGetContext(PuglView* view) puglGetContext(PuglView* view)
{ {
#ifdef PUGL_HAVE_CAIRO
#ifdef PUGL_CAIRO
return [view->impl->cairoview cairoContext]; return [view->impl->cairoview cairoContext];
#endif #endif
return NULL; return NULL;


+ 20
- 20
dgl/src/pugl/pugl_win.cpp View File

@@ -19,22 +19,22 @@
@file pugl_win.cpp Windows/WGL Pugl Implementation. @file pugl_win.cpp Windows/WGL Pugl Implementation.
*/ */


#include <ctime>
#include <cstdio>
#include <cstdlib>

#include <winsock2.h> #include <winsock2.h>
#include <windows.h> #include <windows.h>
#include <windowsx.h> #include <windowsx.h>
#ifdef PUGL_HAVE_GL
#include <GL/gl.h>
#endif
#ifdef PUGL_HAVE_CAIRO
#ifdef PUGL_CAIRO
#include <cairo/cairo.h> #include <cairo/cairo.h>
#include <cairo/cairo-win32.h> #include <cairo/cairo-win32.h>
#endif #endif
#ifdef PUGL_OPENGL
#include <GL/gl.h>
#endif


#include <ctime>
#include <cstdio>
#include <cstdlib>

#include "pugl/pugl_internal.h"
#include "pugl_internal.h"


#ifndef WM_MOUSEWHEEL #ifndef WM_MOUSEWHEEL
# define WM_MOUSEWHEEL 0x020A # define WM_MOUSEWHEEL 0x020A
@@ -55,11 +55,11 @@ HINSTANCE hInstance = NULL;


struct PuglInternalsImpl { struct PuglInternalsImpl {
HWND hwnd; HWND hwnd;
#ifdef PUGL_HAVE_GL
#ifdef PUGL_OPENGL
HDC hdc; HDC hdc;
HGLRC hglrc; HGLRC hglrc;
#endif #endif
#ifdef PUGL_HAVE_CAIRO
#ifdef PUGL_CAIRO
cairo_t* buffer_cr; cairo_t* buffer_cr;
cairo_surface_t* buffer_surface; cairo_surface_t* buffer_surface;
#endif #endif
@@ -90,7 +90,7 @@ puglInitInternals()
void void
puglEnterContext(PuglView* view) puglEnterContext(PuglView* view)
{ {
#ifdef PUGL_HAVE_GL
#ifdef PUGL_OPENGL
wglMakeCurrent(view->impl->hdc, view->impl->hglrc); wglMakeCurrent(view->impl->hdc, view->impl->hglrc);
#endif #endif
} }
@@ -98,7 +98,7 @@ puglEnterContext(PuglView* view)
void void
puglLeaveContext(PuglView* view, bool flush) puglLeaveContext(PuglView* view, bool flush)
{ {
#ifdef PUGL_HAVE_GL
#ifdef PUGL_OPENGL
if (flush) { if (flush) {
glFlush(); glFlush();
SwapBuffers(view->impl->hdc); SwapBuffers(view->impl->hdc);
@@ -177,7 +177,7 @@ puglCreateWindow(PuglView* view, const char* title)


SetWindowLongPtr(impl->hwnd, GWLP_USERDATA, (LONG_PTR)view); SetWindowLongPtr(impl->hwnd, GWLP_USERDATA, (LONG_PTR)view);


#ifdef PUGL_HAVE_GL
#ifdef PUGL_OPENGL
impl->hdc = GetDC(impl->hwnd); impl->hdc = GetDC(impl->hwnd);


PIXELFORMATDESCRIPTOR pfd; PIXELFORMATDESCRIPTOR pfd;
@@ -228,12 +228,12 @@ puglDestroy(PuglView* view)


PuglInternals* const impl = view->impl; PuglInternals* const impl = view->impl;


#ifdef PUGL_HAVE_GL
#ifdef PUGL_OPENGL
wglMakeCurrent(NULL, NULL); wglMakeCurrent(NULL, NULL);
wglDeleteContext(impl->hglrc); wglDeleteContext(impl->hglrc);
ReleaseDC(impl->hwnd, impl->hdc); ReleaseDC(impl->hwnd, impl->hdc);
#endif #endif
#ifdef PUGL_HAVE_CAIRO
#ifdef PUGL_CAIRO
cairo_destroy(impl->buffer_cr); cairo_destroy(impl->buffer_cr);
cairo_surface_destroy(impl->buffer_surface); cairo_surface_destroy(impl->buffer_surface);
#endif #endif
@@ -267,7 +267,7 @@ puglDisplay(PuglView* view)


puglEnterContext(view); puglEnterContext(view);


#ifdef PUGL_HAVE_CAIRO
#ifdef PUGL_CAIRO
cairo_t *wc = NULL; cairo_t *wc = NULL;
cairo_t *bc = NULL; cairo_t *bc = NULL;
cairo_surface_t *ws = NULL; cairo_surface_t *ws = NULL;
@@ -298,7 +298,7 @@ puglDisplay(PuglView* view)
if (view->displayFunc) { if (view->displayFunc) {
view->displayFunc(view); view->displayFunc(view);
} }
#ifdef PUGL_HAVE_CAIRO
#ifdef PUGL_CAIRO
cairo_set_source_surface(wc, bs, 0, 0); cairo_set_source_surface(wc, bs, 0, 0);
cairo_paint(wc); cairo_paint(wc);
#endif #endif
@@ -306,7 +306,7 @@ puglDisplay(PuglView* view)


puglLeaveContext(view, success); puglLeaveContext(view, success);


#ifdef PUGL_HAVE_CAIRO
#ifdef PUGL_CAIRO
cairo_destroy(wc); cairo_destroy(wc);
cairo_surface_destroy(ws); cairo_surface_destroy(ws);
#endif #endif
@@ -545,7 +545,7 @@ puglGetNativeWindow(PuglView* view)
void* void*
puglGetContext(PuglView* view) puglGetContext(PuglView* view)
{ {
#ifdef PUGL_HAVE_CAIRO
#ifdef PUGL_CAIRO
return view->impl->buffer_cr; return view->impl->buffer_cr;
#endif #endif
return NULL; return NULL;


+ 23
- 23
dgl/src/pugl/pugl_x11.c View File

@@ -25,14 +25,14 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>


#ifdef PUGL_HAVE_GL
#include <GL/gl.h>
#include <GL/glx.h>
#endif
#ifdef PUGL_HAVE_CAIRO
#ifdef PUGL_CAIRO
#include <cairo/cairo.h> #include <cairo/cairo.h>
#include <cairo/cairo-xlib.h> #include <cairo/cairo-xlib.h>
#endif #endif
#ifdef PUGL_OPENGL
#include <GL/gl.h>
#include <GL/glx.h>
#endif
#include <X11/Xatom.h> #include <X11/Xatom.h>
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <X11/Xutil.h> #include <X11/Xutil.h>
@@ -60,19 +60,19 @@ struct PuglInternalsImpl {
Display* display; Display* display;
int screen; int screen;
Window win; Window win;
#ifdef PUGL_HAVE_CAIRO
#ifdef PUGL_CAIRO
cairo_t* xlib_cr; cairo_t* xlib_cr;
cairo_t* buffer_cr; cairo_t* buffer_cr;
cairo_surface_t* xlib_surface; cairo_surface_t* xlib_surface;
cairo_surface_t* buffer_surface; cairo_surface_t* buffer_surface;
#endif #endif
#ifdef PUGL_HAVE_GL
#ifdef PUGL_OPENGL
GLXContext ctx; GLXContext ctx;
Bool doubleBuffered; Bool doubleBuffered;
#endif #endif
}; };


#ifdef PUGL_HAVE_GL
#ifdef PUGL_OPENGL
/** /**
Attributes for single-buffered RGBA with at least Attributes for single-buffered RGBA with at least
4 bits per color and a 16 bit depth buffer. 4 bits per color and a 16 bit depth buffer.
@@ -129,7 +129,7 @@ puglInitInternals(void)
void void
puglEnterContext(PuglView* view) puglEnterContext(PuglView* view)
{ {
#ifdef PUGL_HAVE_GL
#ifdef PUGL_OPENGL
glXMakeCurrent(view->impl->display, view->impl->win, view->impl->ctx); glXMakeCurrent(view->impl->display, view->impl->win, view->impl->ctx);
#endif #endif
} }
@@ -137,7 +137,7 @@ puglEnterContext(PuglView* view)
void void
puglLeaveContext(PuglView* view, bool flush) puglLeaveContext(PuglView* view, bool flush)
{ {
#ifdef PUGL_HAVE_GL
#ifdef PUGL_OPENGL
if (flush) { if (flush) {
glFlush(); glFlush();
if (view->impl->doubleBuffered) { if (view->impl->doubleBuffered) {
@@ -166,7 +166,7 @@ puglCreateWindow(PuglView* view, const char* title)


XVisualInfo* vi = NULL; XVisualInfo* vi = NULL;


#ifdef PUGL_HAVE_GL
#ifdef PUGL_OPENGL
impl->doubleBuffered = True; impl->doubleBuffered = True;
vi = glXChooseVisual(impl->display, impl->screen, attrListDblMS); vi = glXChooseVisual(impl->display, impl->screen, attrListDblMS);


@@ -182,7 +182,7 @@ puglCreateWindow(PuglView* view, const char* title)
impl->doubleBuffered = False; impl->doubleBuffered = False;
} }
#endif #endif
#ifdef PUGL_HAVE_CAIRO
#ifdef PUGL_CAIRO
XVisualInfo pat; XVisualInfo pat;
int n; int n;
pat.screen = impl->screen; pat.screen = impl->screen;
@@ -196,14 +196,14 @@ puglCreateWindow(PuglView* view, const char* title)
} }


#ifdef PUGL_VERBOSE #ifdef PUGL_VERBOSE
#ifdef PUGL_HAVE_GL
#ifdef PUGL_OPENGL
int glxMajor, glxMinor; int glxMajor, glxMinor;
glXQueryVersion(impl->display, &glxMajor, &glxMinor); glXQueryVersion(impl->display, &glxMajor, &glxMinor);
printf("puGL: GLX-Version : %d.%d\n", glxMajor, glxMinor); printf("puGL: GLX-Version : %d.%d\n", glxMajor, glxMinor);
#endif #endif
#endif #endif


#ifdef PUGL_HAVE_GL
#ifdef PUGL_OPENGL
impl->ctx = glXCreateContext(impl->display, vi, 0, GL_TRUE); impl->ctx = glXCreateContext(impl->display, vi, 0, GL_TRUE);


if (!impl->ctx) { if (!impl->ctx) {
@@ -237,7 +237,7 @@ puglCreateWindow(PuglView* view, const char* title)
CWBorderPixel | CWColormap | CWEventMask, &attr); CWBorderPixel | CWColormap | CWEventMask, &attr);


if (!impl->win) { if (!impl->win) {
#ifdef PUGL_HAVE_GL
#ifdef PUGL_OPENGL
glXDestroyContext(impl->display, impl->ctx); glXDestroyContext(impl->display, impl->ctx);
#endif #endif
XFree(vi); XFree(vi);
@@ -246,7 +246,7 @@ puglCreateWindow(PuglView* view, const char* title)
return 1; return 1;
} }


#ifdef PUGL_HAVE_CAIRO
#ifdef PUGL_CAIRO
impl->xlib_surface = cairo_xlib_surface_create( impl->xlib_surface = cairo_xlib_surface_create(
impl->display, impl->win, vi->visual, view->width, view->height); impl->display, impl->win, vi->visual, view->width, view->height);
if (impl->xlib_surface == NULL || cairo_surface_status(impl->xlib_surface) != CAIRO_STATUS_SUCCESS) { if (impl->xlib_surface == NULL || cairo_surface_status(impl->xlib_surface) != CAIRO_STATUS_SUCCESS) {
@@ -288,7 +288,7 @@ puglCreateWindow(PuglView* view, const char* title)
} }


#ifdef PUGL_VERBOSE #ifdef PUGL_VERBOSE
#ifdef PUGL_HAVE_GL
#ifdef PUGL_OPENGL
if (glXIsDirect(impl->display, impl->ctx)) { if (glXIsDirect(impl->display, impl->ctx)) {
printf("puGL: DRI enabled (to disable, set LIBGL_ALWAYS_INDIRECT=1\n"); printf("puGL: DRI enabled (to disable, set LIBGL_ALWAYS_INDIRECT=1\n");
} else { } else {
@@ -314,10 +314,10 @@ puglDestroy(PuglView* view)
x_fib_close(impl->display); x_fib_close(impl->display);
#endif #endif


#ifdef PUGL_HAVE_GL
#ifdef PUGL_OPENGL
glXDestroyContext(impl->display, impl->ctx); glXDestroyContext(impl->display, impl->ctx);
#endif #endif
#ifdef PUGL_HAVE_CAIRO
#ifdef PUGL_CAIRO
cairo_destroy(impl->xlib_cr); cairo_destroy(impl->xlib_cr);
cairo_destroy(impl->buffer_cr); cairo_destroy(impl->buffer_cr);
cairo_surface_destroy(impl->xlib_surface); cairo_surface_destroy(impl->xlib_surface);
@@ -365,7 +365,7 @@ puglDisplay(PuglView* view)


puglEnterContext(view); puglEnterContext(view);


#ifdef PUGL_HAVE_CAIRO
#ifdef PUGL_CAIRO
cairo_t* bc = impl->buffer_cr; cairo_t* bc = impl->buffer_cr;
cairo_surface_t* xs = impl->xlib_surface; cairo_surface_t* xs = impl->xlib_surface;
cairo_surface_t* bs = impl->buffer_surface; cairo_surface_t* bs = impl->buffer_surface;
@@ -394,7 +394,7 @@ puglDisplay(PuglView* view)
view->displayFunc(view); view->displayFunc(view);
} }


#ifdef PUGL_HAVE_CAIRO
#ifdef PUGL_CAIRO
cairo_t* xc = impl->xlib_cr; cairo_t* xc = impl->xlib_cr;
cairo_set_source_surface(xc, impl->buffer_surface, 0, 0); cairo_set_source_surface(xc, impl->buffer_surface, 0, 0);
cairo_paint(xc); cairo_paint(xc);
@@ -661,7 +661,7 @@ puglProcessEvents(PuglView* view)
} }


if (conf_width != -1) { if (conf_width != -1) {
#ifdef PUGL_HAVE_CAIRO
#ifdef PUGL_CAIRO
// Resize surfaces/contexts before dispatching // Resize surfaces/contexts before dispatching
view->redisplay = true; view->redisplay = true;
cairo_xlib_surface_set_size(view->impl->xlib_surface, cairo_xlib_surface_set_size(view->impl->xlib_surface,
@@ -702,7 +702,7 @@ puglGetNativeWindow(PuglView* view)
void* void*
puglGetContext(PuglView* view) puglGetContext(PuglView* view)
{ {
#ifdef PUGL_HAVE_CAIRO
#ifdef PUGL_CAIRO
return view->impl->buffer_cr; return view->impl->buffer_cr;
#endif #endif
return NULL; return NULL;


+ 8
- 1
distrho/DistrhoUI.hpp View File

@@ -1,6 +1,6 @@
/* /*
* DISTRHO Plugin Framework (DPF) * DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2018 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2012-2019 Filipe Coelho <falktx@falktx.com>
* *
* Permission to use, copy, modify, and/or distribute this software for any purpose with * 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 * or without fee is hereby granted, provided that the above copyright notice and this
@@ -32,6 +32,13 @@ typedef DGL_NAMESPACE::NanoWidget UIWidget;
typedef DGL_NAMESPACE::Widget UIWidget; typedef DGL_NAMESPACE::Widget UIWidget;
#endif #endif


#ifdef DGL_CAIRO
# include "Cairo.hpp"
#endif
#ifdef DGL_OPENGL
# include "OpenGL.hpp"
#endif

START_NAMESPACE_DISTRHO START_NAMESPACE_DISTRHO


/* ------------------------------------------------------------------------------------------------------------ /* ------------------------------------------------------------------------------------------------------------


+ 3
- 3
distrho/src/DistrhoPluginChecks.h View File

@@ -1,6 +1,6 @@
/* /*
* DISTRHO Plugin Framework (DPF) * DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2016 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2012-2019 Filipe Coelho <falktx@falktx.com>
* *
* Permission to use, copy, modify, and/or distribute this software for any purpose with * 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 * or without fee is hereby granted, provided that the above copyright notice and this
@@ -93,7 +93,7 @@
// Define DISTRHO_PLUGIN_HAS_EMBED_UI if needed // Define DISTRHO_PLUGIN_HAS_EMBED_UI if needed


#ifndef DISTRHO_PLUGIN_HAS_EMBED_UI #ifndef DISTRHO_PLUGIN_HAS_EMBED_UI
# if defined(HAVE_DGL) || defined(HAVE_DCAIRO)
# if defined(HAVE_CAIRO) || defined(HAVE_OPENGL)
# define DISTRHO_PLUGIN_HAS_EMBED_UI 1 # define DISTRHO_PLUGIN_HAS_EMBED_UI 1
# else # else
# define DISTRHO_PLUGIN_HAS_EMBED_UI 0 # define DISTRHO_PLUGIN_HAS_EMBED_UI 0
@@ -135,7 +135,7 @@
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// Disable UI if DGL or External UI is not available // Disable UI if DGL or External UI is not available


#if DISTRHO_PLUGIN_HAS_UI && ! DISTRHO_PLUGIN_HAS_EXTERNAL_UI && ! defined(HAVE_DGL) && ! defined(HAVE_DCAIRO)
#if DISTRHO_PLUGIN_HAS_UI && ! DISTRHO_PLUGIN_HAS_EXTERNAL_UI && ! defined(HAVE_CAIRO) && ! defined(HAVE_OPENGL)
# undef DISTRHO_PLUGIN_HAS_UI # undef DISTRHO_PLUGIN_HAS_UI
# define DISTRHO_PLUGIN_HAS_UI 0 # define DISTRHO_PLUGIN_HAS_UI 0
#endif #endif


+ 2
- 2
distrho/src/DistrhoUI.cpp View File

@@ -1,6 +1,6 @@
/* /*
* DISTRHO Plugin Framework (DPF) * DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2018 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2012-2019 Filipe Coelho <falktx@falktx.com>
* *
* Permission to use, copy, modify, and/or distribute this software for any purpose with * 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 * or without fee is hereby granted, provided that the above copyright notice and this
@@ -152,7 +152,7 @@ void UI::uiFileBrowserSelected(const char*)


void UI::uiReshape(uint width, uint height) void UI::uiReshape(uint width, uint height)
{ {
#ifdef HAVE_DGL
#ifdef DGL_OPENGL
glEnable(GL_BLEND); glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);


+ 2
- 1
dpf.doxygen View File

@@ -242,7 +242,8 @@ SEARCH_INCLUDES = YES
INCLUDE_PATH = INCLUDE_PATH =
INCLUDE_FILE_PATTERNS = INCLUDE_FILE_PATTERNS =
PREDEFINED = DOXYGEN \ PREDEFINED = DOXYGEN \
HAVE_DGL=1 \
HAVE_CAIRO=1 \
HAVE_OPENGL=1 \
DISTRHO_PLUGIN_NAME="Plugin Name" \ DISTRHO_PLUGIN_NAME="Plugin Name" \
DISTRHO_PLUGIN_NUM_INPUTS=2 \ DISTRHO_PLUGIN_NUM_INPUTS=2 \
DISTRHO_PLUGIN_NUM_OUTPUTS=2 \ DISTRHO_PLUGIN_NUM_OUTPUTS=2 \


+ 2
- 2
examples/Info/Makefile View File

@@ -26,13 +26,13 @@ include ../../Makefile.plugins.mk
# -------------------------------------------------------------- # --------------------------------------------------------------
# Enable all possible plugin types # Enable all possible plugin types


ifeq ($(HAVE_DGL),true)
ifeq ($(HAVE_JACK),true) ifeq ($(HAVE_JACK),true)
ifeq ($(HAVE_OPENGL),true)
TARGETS += jack TARGETS += jack
endif endif
endif endif


ifeq ($(HAVE_DGL),true)
ifeq ($(HAVE_OPENGL),true)
TARGETS += lv2_sep TARGETS += lv2_sep
else else
TARGETS += lv2_dsp TARGETS += lv2_dsp


+ 3
- 3
examples/Meters/Makefile View File

@@ -26,21 +26,21 @@ include ../../Makefile.plugins.mk
# -------------------------------------------------------------- # --------------------------------------------------------------
# Enable all possible plugin types # Enable all possible plugin types


ifeq ($(HAVE_DGL),true)
ifeq ($(HAVE_JACK),true) ifeq ($(HAVE_JACK),true)
ifeq ($(HAVE_OPENGL),true)
TARGETS += jack TARGETS += jack
endif endif
endif endif


ifeq ($(LINUX),true) ifeq ($(LINUX),true)
ifeq ($(HAVE_DGL),true)
ifeq ($(HAVE_LIBLO),true) ifeq ($(HAVE_LIBLO),true)
ifeq ($(HAVE_OPENGL),true)
TARGETS += dssi TARGETS += dssi
endif endif
endif endif
endif endif


ifeq ($(HAVE_DGL),true)
ifeq ($(HAVE_OPENGL),true)
TARGETS += lv2_sep TARGETS += lv2_sep
else else
TARGETS += lv2_dsp TARGETS += lv2_dsp


+ 3
- 3
examples/Parameters/Makefile View File

@@ -26,22 +26,22 @@ include ../../Makefile.plugins.mk
# -------------------------------------------------------------- # --------------------------------------------------------------
# Enable all possible plugin types # Enable all possible plugin types


ifeq ($(HAVE_DGL),true)
ifeq ($(HAVE_JACK),true) ifeq ($(HAVE_JACK),true)
ifeq ($(HAVE_OPENGL),true)
TARGETS += jack TARGETS += jack
endif endif
endif endif


ifeq ($(LINUX),true) ifeq ($(LINUX),true)
ifeq ($(HAVE_DGL),true)
ifeq ($(HAVE_LIBLO),true) ifeq ($(HAVE_LIBLO),true)
ifeq ($(HAVE_OPENGL),true)
TARGETS += ladspa TARGETS += ladspa
TARGETS += dssi TARGETS += dssi
endif endif
endif endif
endif endif


ifeq ($(HAVE_DGL),true)
ifeq ($(HAVE_OPENGL),true)
TARGETS += lv2_sep TARGETS += lv2_sep
else else
TARGETS += lv2_dsp TARGETS += lv2_dsp


+ 3
- 3
examples/States/Makefile View File

@@ -26,21 +26,21 @@ include ../../Makefile.plugins.mk
# -------------------------------------------------------------- # --------------------------------------------------------------
# Enable all possible plugin types # Enable all possible plugin types


ifeq ($(HAVE_DGL),true)
ifeq ($(HAVE_JACK),true) ifeq ($(HAVE_JACK),true)
ifeq ($(HAVE_OPENGL),true)
TARGETS += jack TARGETS += jack
endif endif
endif endif


ifeq ($(LINUX),true) ifeq ($(LINUX),true)
ifeq ($(HAVE_DGL),true)
ifeq ($(HAVE_LIBLO),true) ifeq ($(HAVE_LIBLO),true)
ifeq ($(HAVE_OPENGL),true)
TARGETS += dssi TARGETS += dssi
endif endif
endif endif
endif endif


ifeq ($(HAVE_DGL),true)
ifeq ($(HAVE_OPENGL),true)
TARGETS += lv2_sep TARGETS += lv2_sep
else else
TARGETS += lv2_dsp TARGETS += lv2_dsp


+ 1
- 1
utils/lv2-ttl-generator/GNUmakefile View File

@@ -2,7 +2,7 @@


all: build all: build


ifeq ($(WIN32),true)
ifeq ($(WINDOWS),true)
build: ../lv2_ttl_generator.exe build: ../lv2_ttl_generator.exe
else else
build: ../lv2_ttl_generator build: ../lv2_ttl_generator


Loading…
Cancel
Save