Skip to content

Commit dd46b54

Browse files
committed
ProM and GL3 fixes
Signed-off-by: falkTX <falktx@falktx.com>
1 parent cbb6c04 commit dd46b54

File tree

6 files changed

+92
-63
lines changed

6 files changed

+92
-63
lines changed

dpf/dgl/src/WindowPrivateData.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -266,17 +266,6 @@ void Window::PrivateData::initPre(const uint width, const uint height, const boo
266266
#endif
267267
puglSetViewHint(view, PUGL_STENCIL_BITS, 8);
268268

269-
#if defined(DGL_USE_OPENGL3) || defined(DGL_USE_GLES3)
270-
puglSetViewHint(view, PUGL_USE_COMPAT_PROFILE, PUGL_FALSE);
271-
puglSetViewHint(view, PUGL_CONTEXT_VERSION_MAJOR, 3);
272-
#elif defined(DGL_USE_GLES2)
273-
puglSetViewHint(view, PUGL_USE_COMPAT_PROFILE, PUGL_FALSE);
274-
puglSetViewHint(view, PUGL_CONTEXT_VERSION_MAJOR, 2);
275-
#else
276-
puglSetViewHint(view, PUGL_USE_COMPAT_PROFILE, PUGL_TRUE);
277-
puglSetViewHint(view, PUGL_CONTEXT_VERSION_MAJOR, 2);
278-
#endif
279-
280269
// PUGL_SAMPLES ??
281270
puglSetEventFunc(view, puglEventCallback);
282271

dpf/dgl/src/nanovg/nanovg.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,37 @@
3232

3333
#ifndef NVG_NO_STB
3434
#define STB_IMAGE_IMPLEMENTATION
35+
#define stbi_convert_iphone_png_to_rgb dpf_stbi_convert_iphone_png_to_rgb
36+
#define stbi_failure_reason dpf_stbi_failure_reason
37+
#define stbi_hdr_to_ldr_gamma dpf_stbi_hdr_to_ldr_gamma
38+
#define stbi_hdr_to_ldr_scale dpf_stbi_hdr_to_ldr_scale
39+
#define stbi_image_free dpf_stbi_image_free
40+
#define stbi_info dpf_stbi_info
41+
#define stbi_info_from_callbacks dpf_stbi_info_from_callbacks
42+
#define stbi_info_from_file dpf_stbi_info_from_file
43+
#define stbi_info_from_memory dpf_stbi_info_from_memory
44+
#define stbi_is_hdr dpf_stbi_is_hdr
45+
#define stbi_is_hdr_from_callbacks dpf_stbi_is_hdr_from_callbacks
46+
#define stbi_is_hdr_from_file dpf_stbi_is_hdr_from_file
47+
#define stbi_is_hdr_from_memory dpf_stbi_is_hdr_from_memory
48+
#define stbi_ldr_to_hdr_gamma dpf_stbi_ldr_to_hdr_gamma
49+
#define stbi_ldr_to_hdr_scale dpf_stbi_ldr_to_hdr_scale
50+
#define stbi_load dpf_stbi_load
51+
#define stbi_load_from_callbacks dpf_stbi_load_from_callbacks
52+
#define stbi_load_from_file dpf_stbi_load_from_file
53+
#define stbi_load_from_memory dpf_stbi_load_from_memory
54+
#define stbi_loadf dpf_stbi_loadf
55+
#define stbi_loadf_from_callbacks dpf_stbi_loadf_from_callbacks
56+
#define stbi_loadf_from_file dpf_stbi_loadf_from_file
57+
#define stbi_loadf_from_memory dpf_stbi_loadf_from_memory
58+
#define stbi_set_flip_vertically_on_load dpf_stbi_set_flip_vertically_on_load
59+
#define stbi_set_unpremultiply_on_load dpf_stbi_set_unpremultiply_on_load
60+
#define stbi_zlib_decode_buffer dpf_stbi_zlib_decode_buffer
61+
#define stbi_zlib_decode_malloc dpf_stbi_zlib_decode_malloc
62+
#define stbi_zlib_decode_malloc_guesssize dpf_stbi_zlib_decode_malloc_guesssize
63+
#define stbi_zlib_decode_malloc_guesssize_headerflag dpf_stbi_zlib_decode_malloc_guesssize_headerflag
64+
#define stbi_zlib_decode_noheader_buffer dpf_stbi_zlib_decode_noheader_buffer
65+
#define stbi_zlib_decode_noheader_malloc dpf_stbi_zlib_decode_noheader_malloc
3566
#include "stb_image.h"
3667
#endif
3768

dpf/dgl/src/pugl.cpp

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,6 @@
4444
# ifdef DGL_CAIRO
4545
# include <cairo-quartz.h>
4646
# endif
47-
# ifdef DGL_OPENGL
48-
# include <OpenGL/gl.h>
49-
# endif
5047
# ifdef DGL_VULKAN
5148
# import <QuartzCore/CAMetalLayer.h>
5249
# include <vulkan/vulkan_macos.h>
@@ -204,17 +201,35 @@ bool puglBackendLeave(PuglView* const view)
204201

205202
void puglSetMatchingBackendForCurrentBuild(PuglView* const view)
206203
{
207-
#ifdef DGL_CAIRO
204+
#ifdef DGL_CAIRO
208205
puglSetBackend(view, puglCairoBackend());
209-
#endif
210-
#ifdef DGL_OPENGL
206+
#endif
207+
#ifdef DGL_OPENGL
211208
puglSetBackend(view, puglGlBackend());
212-
#endif
213-
#ifdef DGL_VULKAN
209+
#endif
210+
#ifdef DGL_VULKAN
214211
puglSetBackend(view, puglVulkanBackend());
215-
#endif
216-
if (view->backend == nullptr)
212+
#endif
213+
214+
if (view->backend != nullptr)
215+
{
216+
#ifdef DGL_OPENGL
217+
#if defined(DGL_USE_OPENGL3) || defined(DGL_USE_GLES3)
218+
puglSetViewHint(view, PUGL_USE_COMPAT_PROFILE, PUGL_FALSE);
219+
puglSetViewHint(view, PUGL_CONTEXT_VERSION_MAJOR, 3);
220+
#elif defined(DGL_USE_GLES2)
221+
puglSetViewHint(view, PUGL_USE_COMPAT_PROFILE, PUGL_FALSE);
222+
puglSetViewHint(view, PUGL_CONTEXT_VERSION_MAJOR, 2);
223+
#else
224+
puglSetViewHint(view, PUGL_USE_COMPAT_PROFILE, PUGL_TRUE);
225+
puglSetViewHint(view, PUGL_CONTEXT_VERSION_MAJOR, 2);
226+
#endif
227+
#endif
228+
}
229+
else
230+
{
217231
puglSetBackend(view, puglStubBackend());
232+
}
218233
}
219234

220235
// --------------------------------------------------------------------------------------------------------------------
@@ -406,37 +421,37 @@ PuglStatus puglSetSizeAndDefault(PuglView* view, uint width, uint height)
406421

407422
void puglOnDisplayPrepare(PuglView*)
408423
{
409-
#ifdef DGL_OPENGL
424+
#ifdef DGL_OPENGL
410425
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
411-
# ifndef DGL_USE_GLES
426+
#ifndef DGL_USE_OPENGL3
412427
glLoadIdentity();
413-
# endif
414-
#endif
428+
#endif
429+
#endif
415430
}
416431

417432
// --------------------------------------------------------------------------------------------------------------------
418433
// DGL specific, build-specific fallback resize
419434

420435
void puglFallbackOnResize(PuglView* const view)
421436
{
422-
#ifdef DGL_OPENGL
437+
#ifdef DGL_OPENGL
423438
glEnable(GL_BLEND);
424439
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
425-
# ifndef DGL_USE_GLES
440+
#ifdef DGL_USE_OPENGL3
441+
glViewport(0, 0, static_cast<GLsizei>(view->frame.width), static_cast<GLsizei>(view->frame.height));
442+
#else
426443
glMatrixMode(GL_PROJECTION);
427444
glLoadIdentity();
428445
glOrtho(0.0, static_cast<GLdouble>(view->frame.width), static_cast<GLdouble>(view->frame.height), 0.0, 0.0, 1.0);
429446
glViewport(0, 0, static_cast<GLsizei>(view->frame.width), static_cast<GLsizei>(view->frame.height));
430447
glMatrixMode(GL_MODELVIEW);
431448
glLoadIdentity();
432-
# else
433-
glViewport(0, 0, static_cast<GLsizei>(view->frame.width), static_cast<GLsizei>(view->frame.height));
434-
# endif
435-
#else
449+
#endif
450+
#else
436451
return;
437452
// unused
438453
(void)view;
439-
#endif
454+
#endif
440455
}
441456

442457
// --------------------------------------------------------------------------------------------------------------------

plugins/ProM/DistrhoUIProM.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,14 @@ bool DistrhoUIProM::onKeyboard(const KeyboardEvent& ev)
297297
return true;
298298
}
299299

300+
bool DistrhoUIProM::onMouse(const MouseEvent& ev)
301+
{
302+
if (ev.press)
303+
getWindow().focus();
304+
305+
return false;
306+
}
307+
300308
// -----------------------------------------------------------------------
301309

302310
UI* createUI()

plugins/ProM/DistrhoUIProM.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class DistrhoUIProM : public UI
4949

5050
void onDisplay() override;
5151
bool onKeyboard(const KeyboardEvent&) override;
52+
bool onMouse(const MouseEvent& ev) override;
5253

5354
private:
5455
ScopedPointer<projectM> fPM;

plugins/ProM/ResizeHandle.hpp

Lines changed: 16 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,17 @@
1616

1717
#pragma once
1818

19-
#include "TopLevelWidget.hpp"
20-
#include "Color.hpp"
19+
#include "NanoVG.hpp"
2120

2221
START_NAMESPACE_DGL
2322

2423
/** Resize handle for DPF windows, will sit on bottom-right. */
25-
class ResizeHandle : public TopLevelWidget
24+
class ResizeHandle : public NanoTopLevelWidget
2625
{
2726
public:
2827
/** Overloaded constructor, will fetch the window from an existing top-level widget. */
2928
explicit ResizeHandle(TopLevelWidget* const tlw)
30-
: TopLevelWidget(tlw->getWindow()),
29+
: NanoTopLevelWidget(tlw->getWindow()),
3130
handleSize(16),
3231
hasCursor(false),
3332
isResizing(false)
@@ -44,22 +43,19 @@ class ResizeHandle : public TopLevelWidget
4443
}
4544

4645
protected:
47-
void onDisplay() override
46+
void onNanoDisplay() override
4847
{
49-
const GraphicsContext& context(getGraphicsContext());
5048
const double lineWidth = 1.0 * getScaleFactor();
51-
52-
glMatrixMode(GL_MODELVIEW);
53-
glLineWidth(lineWidth);
49+
strokeWidth(lineWidth);
5450

5551
// draw white lines, 1px wide
56-
glColor3f(1.0f, 1.0f, 1.0f);
52+
strokeColor(Color(1.0f, 1.0f, 1.0f));
5753
drawLine(l1);
5854
drawLine(l2);
5955
drawLine(l3);
6056

6157
// draw black lines, offset by 1px and 1px wide
62-
glColor3f(0.0f, 0.0f, 0.0f);
58+
strokeColor(Color(0.0f, 0.0f, 0.0f));
6359
Line<double> l1b(l1), l2b(l2), l3b(l3);
6460
l1b.moveBy(lineWidth, lineWidth);
6561
l2b.moveBy(lineWidth, lineWidth);
@@ -69,6 +65,14 @@ class ResizeHandle : public TopLevelWidget
6965
drawLine(l3b);
7066
}
7167

68+
void drawLine(const Line<double>& line)
69+
{
70+
beginPath();
71+
moveTo(line.getStartPos().getX(), line.getStartPos().getY());
72+
lineTo(line.getEndPos().getX(), line.getEndPos().getY());
73+
stroke();
74+
}
75+
7276
bool onMouse(const MouseEvent& ev) override
7377
{
7478
if (ev.button != 1)
@@ -155,7 +159,7 @@ class ResizeHandle : public TopLevelWidget
155159
void resetArea()
156160
{
157161
const double scaleFactor = getScaleFactor();
158-
const uint margin = 0.0 * scaleFactor;
162+
const uint margin = 1.5 * scaleFactor;
159163
const uint size = handleSize * scaleFactor;
160164

161165
area = Rectangle<uint>(getWidth() - size - margin,
@@ -187,25 +191,6 @@ class ResizeHandle : public TopLevelWidget
187191
l3.setEndPos(x + offset, y + linesize + offset);
188192
}
189193

190-
void drawLine(const Line<double>& line)
191-
{
192-
drawLine(line.getStartPos(), line.getEndPos());
193-
}
194-
195-
void drawLine(const Point<double>& posStart, const Point<double>& posEnd)
196-
{
197-
DISTRHO_SAFE_ASSERT_RETURN(posStart != posEnd,);
198-
199-
glBegin(GL_LINES);
200-
201-
{
202-
glVertex2d(posStart.getX(), posStart.getY());
203-
glVertex2d(posEnd.getX(), posEnd.getY());
204-
}
205-
206-
glEnd();
207-
}
208-
209194
DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ResizeHandle)
210195
};
211196

0 commit comments

Comments
 (0)