Skip to content

Commit a56ff97

Browse files
committed
Split OpenGL2 and OpenGL3 implementations into separate files
Signed-off-by: falkTX <[email protected]>
1 parent 7a79c96 commit a56ff97

File tree

17 files changed

+1459
-960
lines changed

17 files changed

+1459
-960
lines changed

.github/workflows/build.yml

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,24 +98,52 @@ jobs:
9898
run: |
9999
make clean >/dev/null
100100
make -j ${{ env.JOBS }}
101-
- name: With OpenGL 3.x
101+
- name: Without Cairo
102102
env:
103103
CFLAGS: -Werror
104104
CXXFLAGS: -Werror
105105
run: |
106106
make clean >/dev/null
107-
make -j ${{ env.JOBS }} USE_OPENGL3=true
108-
- name: Without Cairo
107+
make -j ${{ env.JOBS }} HAVE_CAIRO=false
108+
- name: Without OpenGL
109109
env:
110110
CFLAGS: -Werror
111111
CXXFLAGS: -Werror
112112
run: |
113113
make clean >/dev/null
114-
make -j ${{ env.JOBS }} HAVE_CAIRO=false
115-
- name: Without OpenGL
114+
make -j ${{ env.JOBS }} HAVE_OPENGL=false
115+
- name: With UI_TYPE=generic
116116
env:
117117
CFLAGS: -Werror
118118
CXXFLAGS: -Werror
119119
run: |
120120
make clean >/dev/null
121-
make -j ${{ env.JOBS }} HAVE_OPENGL=false
121+
make -j ${{ env.JOBS }} -C examples/Parameters UI_TYPE=generic
122+
- name: With UI_TYPE=gles2
123+
env:
124+
CFLAGS: -Werror
125+
CXXFLAGS: -Werror
126+
run: |
127+
make clean >/dev/null
128+
make -j ${{ env.JOBS }} -C examples/Parameters UI_TYPE=gles2
129+
- name: With UI_TYPE=gles3
130+
env:
131+
CFLAGS: -Werror
132+
CXXFLAGS: -Werror
133+
run: |
134+
make clean >/dev/null
135+
make -j ${{ env.JOBS }} -C examples/Parameters UI_TYPE=gles3
136+
- name: With UI_TYPE=opengl
137+
env:
138+
CFLAGS: -Werror
139+
CXXFLAGS: -Werror
140+
run: |
141+
make clean >/dev/null
142+
make -j ${{ env.JOBS }} -C examples/Parameters UI_TYPE=opengl
143+
- name: With UI_TYPE=opengl3
144+
env:
145+
CFLAGS: -Werror
146+
CXXFLAGS: -Werror
147+
run: |
148+
make clean >/dev/null
149+
make -j ${{ env.JOBS }} -C examples/Parameters UI_TYPE=opengl3

Makefile.plugins.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# extra useful variables to define before including this file:
1010
# - DPF_BUILD_DIR: where to place temporary build files
1111
# - DPF_TARGET_DIR: where to place final binary files
12-
# - UI_TYPE: one of cairo, gles2, gles3, opengl, opengl3 or external, with opengl being default
12+
# - UI_TYPE: one of cairo, external, gles2, gles3, opengl, opengl3 or webview, with opengl being default
1313
# ("generic" is also allowed if only using basic DPF classes like image widgets)
1414

1515
# override the "all" target after including this file to define which plugin formats to build, like so:

cmake/DPF-plugin.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,6 +1003,7 @@ function(dpf__add_dgl_gles2 SHARED_RESOURCES USE_FILE_BROWSER USE_WEB_VIEW)
10031003
"${DPF_ROOT_DIR}/dgl/src/Window.cpp"
10041004
"${DPF_ROOT_DIR}/dgl/src/WindowPrivateData.cpp"
10051005
"${DPF_ROOT_DIR}/dgl/src/OpenGL.cpp"
1006+
"${DPF_ROOT_DIR}/dgl/src/OpenGL3.cpp"
10061007
"${DPF_ROOT_DIR}/dgl/src/NanoVG.cpp")
10071008
if(SHARED_RESOURCES)
10081009
target_sources(dgl-gles2 PRIVATE "${DPF_ROOT_DIR}/dgl/src/Resources.cpp")
@@ -1101,6 +1102,7 @@ function(dpf__add_dgl_gles3 SHARED_RESOURCES USE_FILE_BROWSER USE_WEB_VIEW)
11011102
"${DPF_ROOT_DIR}/dgl/src/Window.cpp"
11021103
"${DPF_ROOT_DIR}/dgl/src/WindowPrivateData.cpp"
11031104
"${DPF_ROOT_DIR}/dgl/src/OpenGL.cpp"
1105+
"${DPF_ROOT_DIR}/dgl/src/OpenGL3.cpp"
11041106
"${DPF_ROOT_DIR}/dgl/src/NanoVG.cpp")
11051107
if(SHARED_RESOURCES)
11061108
target_sources(dgl-gles3 PRIVATE "${DPF_ROOT_DIR}/dgl/src/Resources.cpp")
@@ -1194,6 +1196,7 @@ function(dpf__add_dgl_opengl SHARED_RESOURCES USE_FILE_BROWSER USE_WEB_VIEW)
11941196
"${DPF_ROOT_DIR}/dgl/src/Window.cpp"
11951197
"${DPF_ROOT_DIR}/dgl/src/WindowPrivateData.cpp"
11961198
"${DPF_ROOT_DIR}/dgl/src/OpenGL.cpp"
1199+
"${DPF_ROOT_DIR}/dgl/src/OpenGL2.cpp"
11971200
"${DPF_ROOT_DIR}/dgl/src/NanoVG.cpp")
11981201
if(SHARED_RESOURCES)
11991202
target_sources(dgl-opengl PRIVATE "${DPF_ROOT_DIR}/dgl/src/Resources.cpp")
@@ -1289,6 +1292,7 @@ function(dpf__add_dgl_opengl3 SHARED_RESOURCES USE_FILE_BROWSER USE_WEB_VIEW)
12891292
"${DPF_ROOT_DIR}/dgl/src/Window.cpp"
12901293
"${DPF_ROOT_DIR}/dgl/src/WindowPrivateData.cpp"
12911294
"${DPF_ROOT_DIR}/dgl/src/OpenGL.cpp"
1295+
"${DPF_ROOT_DIR}/dgl/src/OpenGL3.cpp"
12921296
"${DPF_ROOT_DIR}/dgl/src/NanoVG.cpp")
12931297
if(SHARED_RESOURCES)
12941298
target_sources(dgl-opengl3 PRIVATE "${DPF_ROOT_DIR}/dgl/src/Resources.cpp")

dgl/Base.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@
4949
# error DGL_FILE_BROWSER_DISABLED has been replaced by DGL_USE_FILE_BROWSER (opt-in vs opt-out)
5050
#endif
5151

52+
#ifndef DGL_ALLOW_DEPRECATED_METHODS
53+
# define DGL_ALLOW_DEPRECATED_METHODS 1
54+
#endif
55+
5256
// --------------------------------------------------------------------------------------------------------------------
5357
// Define namespace
5458

dgl/Cairo.hpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* DISTRHO Plugin Framework (DPF)
3-
* Copyright (C) 2012-2022 Filipe Coelho <[email protected]>
3+
* Copyright (C) 2012-2025 Filipe Coelho <[email protected]>
44
*
55
* Permission to use, copy, modify, and/or distribute this software for any purpose with
66
* or without fee is hereby granted, provided that the above copyright notice and this
@@ -165,10 +165,9 @@ class CairoBaseWidget : public BaseWidget
165165
Widget display function.
166166
Implemented internally to pass context into the drawing function.
167167
*/
168-
void onDisplay() override
168+
void onDisplay() final
169169
{
170-
const CairoGraphicsContext& context((const CairoGraphicsContext&)BaseWidget::getGraphicsContext());
171-
onCairoDisplay(context);
170+
onCairoDisplay(static_cast<const CairoGraphicsContext&>(BaseWidget::getGraphicsContext()));
172171
}
173172

174173
DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CairoBaseWidget);

dgl/Geometry.hpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* DISTRHO Plugin Framework (DPF)
3-
* Copyright (C) 2012-2021 Filipe Coelho <[email protected]>
3+
* Copyright (C) 2012-2025 Filipe Coelho <[email protected]>
44
*
55
* Permission to use, copy, modify, and/or distribute this software for any purpose with
66
* or without fee is hereby granted, provided that the above copyright notice and this
@@ -360,25 +360,23 @@ class Line
360360
*/
361361
bool isNotNull() const noexcept;
362362

363-
#ifndef DPF_TEST_POINT_CPP
364363
/**
365364
Draw this line using the provided graphics context, optionally specifying line width.
366365
*/
367366
void draw(const GraphicsContext& context, T width = 1);
368-
#endif
369367

370368
Line<T>& operator=(const Line<T>& line) noexcept;
371369
bool operator==(const Line<T>& line) const noexcept;
372370
bool operator!=(const Line<T>& line) const noexcept;
373371

374-
#ifndef DPF_TEST_POINT_CPP
372+
#ifdef DGL_ALLOW_DEPRECATED_METHODS
375373
/**
376374
Draw this line using the current OpenGL state.@n
377375
DEPRECATED Please use draw(const GraphicsContext&) instead.
378376
*/
379377
DISTRHO_DEPRECATED_BY("draw(const GraphicsContext&)")
380378
void draw();
381-
#endif
379+
#endif
382380

383381
private:
384382
Point<T> posStart, posEnd;
@@ -489,7 +487,7 @@ class Circle
489487
bool operator==(const Circle<T>& cir) const noexcept;
490488
bool operator!=(const Circle<T>& cir) const noexcept;
491489

492-
#ifndef DPF_TEST_POINT_CPP
490+
#ifdef DGL_ALLOW_DEPRECATED_METHODS
493491
/**
494492
Draw this circle using the current OpenGL state.@n
495493
DEPRECATED Please use draw(const GraphicsContext&) instead.
@@ -503,7 +501,7 @@ class Circle
503501
*/
504502
DISTRHO_DEPRECATED_BY("drawOutline(const GraphicsContext&)")
505503
void drawOutline();
506-
#endif
504+
#endif
507505

508506
private:
509507
Point<T> fPos;
@@ -582,7 +580,7 @@ class Triangle
582580
bool operator==(const Triangle<T>& tri) const noexcept;
583581
bool operator!=(const Triangle<T>& tri) const noexcept;
584582

585-
#ifndef DPF_TEST_POINT_CPP
583+
#ifdef DGL_ALLOW_DEPRECATED_METHODS
586584
/**
587585
Draw this triangle using the current OpenGL state.@n
588586
DEPRECATED Please use draw(const GraphicsContext&) instead.
@@ -596,7 +594,7 @@ class Triangle
596594
*/
597595
DISTRHO_DEPRECATED_BY("drawOutline(const GraphicsContext&)")
598596
void drawOutline();
599-
#endif
597+
#endif
600598

601599
private:
602600
Point<T> pos1, pos2, pos3;
@@ -813,6 +811,7 @@ class Rectangle
813811
bool operator==(const Rectangle<T>& size) const noexcept;
814812
bool operator!=(const Rectangle<T>& size) const noexcept;
815813

814+
#ifdef DGL_ALLOW_DEPRECATED_METHODS
816815
/**
817816
Draw this rectangle using the current OpenGL state.@n
818817
DEPRECATED Please use draw(const GraphicsContext&) instead.
@@ -826,6 +825,7 @@ class Rectangle
826825
*/
827826
DISTRHO_DEPRECATED_BY("drawOutline(const GraphicsContext&)")
828827
void drawOutline();
828+
#endif
829829

830830
private:
831831
Point<T> pos;

dgl/Image.hpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* DISTRHO Plugin Framework (DPF)
3-
* Copyright (C) 2012-2021 Filipe Coelho <[email protected]>
3+
* Copyright (C) 2012-2025 Filipe Coelho <[email protected]>
44
*
55
* Permission to use, copy, modify, and/or distribute this software for any purpose with
66
* or without fee is hereby granted, provided that the above copyright notice and this
@@ -17,17 +17,21 @@
1717
#ifndef DGL_IMAGE_HPP_INCLUDED
1818
#define DGL_IMAGE_HPP_INCLUDED
1919

20-
#ifdef DGL_CAIRO
21-
#include "Cairo.hpp"
20+
#if defined(DGL_CAIRO)
21+
# include "Cairo.hpp"
22+
#elif defined(DGL_OPENGL)
23+
# include "OpenGL.hpp"
24+
#elif defined(DGL_VULKAN)
25+
# include "Vulkan.hpp"
2226
#else
23-
#include "OpenGL.hpp"
27+
# include "Base.hpp"
2428
#endif
2529

2630
START_NAMESPACE_DGL
2731

28-
#ifdef DGL_CAIRO
32+
#if defined(DGL_CAIRO)
2933
typedef CairoImage Image;
30-
#else
34+
#elif defined(DGL_OPENGL)
3135
typedef OpenGLImage Image;
3236
#endif
3337

dgl/Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ endif
7373

7474
OBJS_gles2 = $(OBJS_common) \
7575
$(BUILD_DIR)/dgl/OpenGL.cpp.gles2.o \
76+
$(BUILD_DIR)/dgl/OpenGL3.cpp.gles2.o \
7677
$(BUILD_DIR)/dgl/NanoVG.cpp.gles2.o
7778

7879
ifeq ($(MACOS),true)
@@ -85,6 +86,7 @@ endif
8586

8687
OBJS_gles3 = $(OBJS_common) \
8788
$(BUILD_DIR)/dgl/OpenGL.cpp.gles3.o \
89+
$(BUILD_DIR)/dgl/OpenGL3.cpp.gles3.o \
8890
$(BUILD_DIR)/dgl/NanoVG.cpp.gles3.o
8991

9092
ifeq ($(MACOS),true)
@@ -97,6 +99,7 @@ endif
9799

98100
OBJS_opengl = $(OBJS_common) \
99101
$(BUILD_DIR)/dgl/OpenGL.cpp.opengl.o \
102+
$(BUILD_DIR)/dgl/OpenGL2.cpp.opengl.o \
100103
$(BUILD_DIR)/dgl/NanoVG.cpp.opengl.o
101104

102105
ifeq ($(MACOS),true)
@@ -109,6 +112,7 @@ endif
109112

110113
OBJS_opengl3 = $(OBJS_common) \
111114
$(BUILD_DIR)/dgl/OpenGL.cpp.opengl3.o \
115+
$(BUILD_DIR)/dgl/OpenGL3.cpp.opengl3.o \
112116
$(BUILD_DIR)/dgl/NanoVG.cpp.opengl3.o
113117

114118
ifeq ($(MACOS),true)
@@ -146,7 +150,10 @@ TARGETS += $(BUILD_DIR)/libdgl-cairo.a
146150
endif
147151

148152
ifeq ($(HAVE_OPENGL),true)
153+
TARGETS += $(BUILD_DIR)/libdgl-gles2.a
154+
TARGETS += $(BUILD_DIR)/libdgl-gles3.a
149155
TARGETS += $(BUILD_DIR)/libdgl-opengl.a
156+
TARGETS += $(BUILD_DIR)/libdgl-opengl3.a
150157
endif
151158

152159
ifeq ($(HAVE_STUB),true)

dgl/OpenGL.hpp

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,7 @@
2424

2525
START_NAMESPACE_DGL
2626

27-
// -----------------------------------------------------------------------
28-
29-
/**
30-
OpenGL Graphics context.
31-
*/
32-
struct OpenGLGraphicsContext : GraphicsContext
33-
{
34-
#ifdef DGL_USE_OPENGL3
35-
#endif
36-
};
37-
38-
// -----------------------------------------------------------------------
27+
// --------------------------------------------------------------------------------------------------------------------
3928

4029
static inline
4130
ImageFormat asDISTRHOImageFormat(const GLenum format)
@@ -87,7 +76,7 @@ GLenum asOpenGLImageFormat(const ImageFormat format)
8776
return 0x0;
8877
}
8978

90-
// -----------------------------------------------------------------------
79+
// --------------------------------------------------------------------------------------------------------------------
9180

9281
/**
9382
OpenGL Image class.
@@ -157,6 +146,7 @@ class OpenGLImage : public ImageBase
157146
inline void drawAt(const GraphicsContext& context, int x, int y)
158147
{ drawAt(context, Point<int>(x, y)); }
159148

149+
#ifdef DGL_ALLOW_DEPRECATED_METHODS
160150
/**
161151
Constructor using raw image data, specifying an OpenGL image format.
162152
@note @a rawData must remain valid for the lifetime of this Image.
@@ -200,22 +190,23 @@ class OpenGLImage : public ImageBase
200190
*/
201191
DISTRHO_DEPRECATED
202192
GLenum getType() const noexcept { return GL_UNSIGNED_BYTE; }
193+
#endif // DGL_ALLOW_DEPRECATED_METHODS
203194

204195
private:
205196
bool setupCalled;
206197
bool textureInit;
207198
GLuint textureId;
208199
};
209200

210-
// -----------------------------------------------------------------------
201+
// --------------------------------------------------------------------------------------------------------------------
211202

212203
typedef ImageBaseAboutWindow<OpenGLImage> OpenGLImageAboutWindow;
213204
typedef ImageBaseButton<OpenGLImage> OpenGLImageButton;
214205
typedef ImageBaseKnob<OpenGLImage> OpenGLImageKnob;
215206
typedef ImageBaseSlider<OpenGLImage> OpenGLImageSlider;
216207
typedef ImageBaseSwitch<OpenGLImage> OpenGLImageSwitch;
217208

218-
// -----------------------------------------------------------------------
209+
// --------------------------------------------------------------------------------------------------------------------
219210

220211
END_NAMESPACE_DGL
221212

0 commit comments

Comments
 (0)