Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cmake/yup.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ function (_yup_module_setup_plugin_client_clap target_name plugin_client_target

_yup_glob_recurse ("${module_path}/clap/*" all_module_files_clap)
target_sources (${custom_target_name} PRIVATE ${all_module_files_clap})
source_group (TREE ${module_path}/clap/ FILES ${all_module_files_clap})
set_source_files_properties (${all_module_files_clap} PROPERTIES HEADER_FILE_ONLY TRUE)

endfunction()
Expand Down Expand Up @@ -622,6 +623,7 @@ function (yup_add_module module_path)

_yup_glob_recurse ("${module_path}/*" all_module_files)
target_sources (${module_name} PRIVATE ${all_module_files})
source_group (TREE ${module_path}/ FILES ${all_module_files})
set_source_files_properties (${all_module_files} PROPERTIES HEADER_FILE_ONLY TRUE)

# ==== Setup parent scope variables
Expand Down
2 changes: 1 addition & 1 deletion examples/graphics/source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class CustomWindow
{
public:
CustomWindow()
: yup::DocumentWindow (yup::ComponentNative::defaultFlags, yup::Color (0xff404040))
: yup::DocumentWindow ({}, yup::Color (0xff404040))
{
rive::Factory* factory = getNativeComponent()->getFactory();
if (factory == nullptr)
Expand Down
3 changes: 2 additions & 1 deletion examples/render/source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ class CustomWindow
public:
CustomWindow()
// Fluid and continuous animations needs continuous repainting
: yup::DocumentWindow (yup::ComponentNative::defaultFlags | yup::ComponentNative::renderContinuous, {}, 60.0f)
: yup::DocumentWindow (yup::ComponentNative::Options()
.withFlags(yup::ComponentNative::defaultFlags | yup::ComponentNative::renderContinuous), {})
{
// Set title
setTitle ("main");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,9 @@ bool AudioPluginWrapperCLAP::initialise()
if (wrapper->audioProcessorEditor->shouldRenderContinuous())
flags.set (yup::ComponentNative::renderContinuous);

wrapper->audioProcessorEditor->addToDesktop (flags, window->cocoa);
yup::ComponentNative::Options options;
options.flags = flags;
wrapper->audioProcessorEditor->addToDesktop (options, window->cocoa);
wrapper->audioProcessorEditor->attachedToNative();

return true;
Expand Down
18 changes: 9 additions & 9 deletions modules/yup_graphics/context/yup_GraphicsContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ class JUCE_API GraphicsContext
{
public:
//==============================================================================
/** Enumerates supported graphics APIs. */
enum Api
{
OpenGL, ///< Specifies the use of OpenGL for rendering.
Direct3D, ///< Specifies the use of Direct3D for rendering.
Metal, ///< Specifies the use of Metal for rendering.
Dawn ///< Specifies the use of Dawn, a Vulkan-like API.
};

/** Configuration options for creating a graphics context. */
struct Options
{
Expand All @@ -48,15 +57,6 @@ class JUCE_API GraphicsContext
bool disableRasterOrdering = false; ///< Disables specific raster ordering features for performance.
};

/** Enumerates supported graphics APIs. */
enum Api
{
OpenGL, ///< Specifies the use of OpenGL for rendering.
Direct3D, ///< Specifies the use of Direct3D for rendering.
Metal, ///< Specifies the use of Metal for rendering.
Dawn ///< Specifies the use of Dawn, a Vulkan-like API.
};

//==============================================================================
/** Default constructor. */
GraphicsContext() noexcept = default;
Expand Down
2 changes: 2 additions & 0 deletions modules/yup_graphics/native/yup_GraphicsContext_d3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
==============================================================================
*/

#if YUP_RIVE_USE_D3D
#include "rive/renderer/rive_renderer.hpp"
#include "rive/renderer/d3d/render_context_d3d_impl.hpp"
#include "rive/renderer/d3d/d3d11.hpp"
Expand Down Expand Up @@ -171,3 +172,4 @@ std::unique_ptr<GraphicsContext> juce_constructDirect3DGraphicsContext (Graphics
}

} // namespace yup
#endif
13 changes: 0 additions & 13 deletions modules/yup_graphics/native/yup_GraphicsContext_dawn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,17 +280,4 @@ std::unique_ptr<GraphicsContext> juce_constructDawnGraphicsContext (GraphicsCont
}

} // namespace yup

#else

namespace yup
{

std::unique_ptr<GraphicsContext> juce_constructDawnGraphicsContext (GraphicsContext::Options options)
{
return nullptr;
}

} // namespace yup

#endif
21 changes: 11 additions & 10 deletions modules/yup_graphics/native/yup_GraphicsContext_gl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
==============================================================================
*/

#if YUP_RIVE_USE_OPENGL || JUCE_LINUX || JUCE_WASM || JUCE_ANDROID
#include "rive/renderer/rive_renderer.hpp"
#include "rive/renderer/gl/gles3.hpp"
#include "rive/renderer/gl/render_buffer_gl_impl.hpp"
Expand Down Expand Up @@ -75,12 +76,6 @@ class LowLevelRenderContextGL : public GraphicsContext
public:
LowLevelRenderContextGL()
{
if (! m_plsContext)
{
fprintf (stderr, "Failed to create a renderer.\n");
exit (-1);
}

#if RIVE_DESKTOP_GL
// Load the OpenGL API using glad.
if (! gladLoadCustomLoader ((GLADloadproc) glfwGetProcAddress))
Expand All @@ -90,6 +85,13 @@ class LowLevelRenderContextGL : public GraphicsContext
}
#endif

m_plsContext = rive::gpu::RenderContextGLImpl::MakeContext (rive::gpu::RenderContextGLImpl::ContextOptions());
if (! m_plsContext)
{
fprintf (stderr, "Failed to create a renderer.\n");
exit (-1);
}

printf ("GL_VENDOR: %s\n", glGetString (GL_VENDOR));
printf ("GL_RENDERER: %s\n", glGetString (GL_RENDERER));
printf ("GL_VERSION: %s\n", glGetString (GL_VERSION));
Expand Down Expand Up @@ -148,15 +150,13 @@ class LowLevelRenderContextGL : public GraphicsContext

void end (void*) override
{
m_plsContext->flush ({ .renderTarget = m_renderTarget.get() });
m_plsContext->flush ({ m_renderTarget.get() });

m_plsContext->static_impl_cast<rive::gpu::RenderContextGLImpl>()->unbindGLInternalResources();
}

private:
std::unique_ptr<rive::gpu::RenderContext> m_plsContext =
rive::gpu::RenderContextGLImpl::MakeContext (rive::gpu::RenderContextGLImpl::ContextOptions());

std::unique_ptr<rive::gpu::RenderContext> m_plsContext;
rive::rcp<rive::gpu::RenderTargetGL> m_renderTarget;
};

Expand All @@ -166,3 +166,4 @@ std::unique_ptr<GraphicsContext> juce_constructOpenGLGraphicsContext (GraphicsCo
}

} // namespace yup
#endif
49 changes: 34 additions & 15 deletions modules/yup_graphics/native/yup_GraphicsContext_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,37 +24,56 @@ namespace yup

std::unique_ptr<GraphicsContext> GraphicsContext::createContext (Options options)
{
#if JUCE_MAC || JUCE_IOS
#if (JUCE_MAC || JUCE_IOS)
#if YUP_RIVE_USE_METAL
return createContext (Api::Metal, options);
#else
return createContext (Api::OpenGL, options);
#endif

#elif JUCE_WINDOWS
#if YUP_RIVE_USE_D3D
return createContext (Api::Direct3D, options);
#else
return createContext (Api::OpenGL, options);
#endif

#elif JUCE_LINUX || JUCE_WASM || JUCE_ANDROID
return createContext (Api::OpenGL, options);

#else
return nullptr;

#endif
}

std::unique_ptr<GraphicsContext> GraphicsContext::createContext (Api graphicsApi, Options options)
{
switch (graphicsApi)
{
#if JUCE_MAC || JUCE_IOS
case Api::Metal:
return juce_constructMetalGraphicsContext (options);
#elif JUCE_WINDOWS
case Api::Direct3D:
return juce_constructDirect3DGraphicsContext (options);
#elif JUCE_LINUX || JUCE_WASM || JUCE_ANDROID
case Api::OpenGL:
return juce_constructOpenGLGraphicsContext (options);
#if YUP_RIVE_USE_METAL && (JUCE_MAC || JUCE_IOS)
case Api::Metal:
return juce_constructMetalGraphicsContext (options);
#endif

#if YUP_RIVE_USE_D3D && JUCE_WINDOWS
case Api::Direct3D:
return juce_constructDirect3DGraphicsContext (options);
#endif

#if YUP_RIVE_USE_OPENGL || JUCE_LINUX || JUCE_WASM || JUCE_ANDROID
case Api::OpenGL:
return juce_constructOpenGLGraphicsContext (options);
#endif

#if YUP_RIVE_USE_DAWN
case Api::Dawn:
return juce_constructDawnGraphicsContext (options);
#endif
case Api::Dawn:
return juce_constructDawnGraphicsContext (options);

default:
Logger::outputDebugString ("Invalid API requested for current platform");
return nullptr;
default:
Logger::outputDebugString ("Invalid API requested for current platform");
return nullptr;
}

Logger::outputDebugString ("Failed to create the graphics context");
Expand Down
2 changes: 2 additions & 0 deletions modules/yup_graphics/native/yup_GraphicsContext_metal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
==============================================================================
*/

#if YUP_RIVE_USE_METAL
#include "rive/renderer/rive_renderer.hpp"
#include "rive/renderer/metal/render_context_metal_impl.h"

Expand Down Expand Up @@ -122,3 +123,4 @@ std::unique_ptr<GraphicsContext> juce_constructMetalGraphicsContext (GraphicsCon
}

} // namespace yup
#endif
26 changes: 26 additions & 0 deletions modules/yup_graphics/yup_graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,38 @@
//==============================================================================

#if JUCE_WINDOWS

#if YUP_RIVE_USE_D3D
#include <array>
#include <dxgi1_2.h>

#include "native/yup_GraphicsContext_d3d.cpp"
#endif

#if YUP_RIVE_USE_OPENGL
#include "native/yup_GraphicsContext_gl.cpp"
#endif

//==============================================================================

#elif JUCE_MAC || JUCE_IOS

#if YUP_RIVE_USE_METAL
#import <Metal/Metal.h>
#import <Cocoa/Cocoa.h>
#import <QuartzCore/CAMetalLayer.h>

#include "native/yup_GraphicsContext_metal.cpp"
#endif

#if YUP_RIVE_USE_OPENGL
#include "native/yup_GraphicsContext_gl.cpp"
#endif

//==============================================================================

#elif JUCE_LINUX || JUCE_WASM || JUCE_ANDROID

#if JUCE_EMSCRIPTEN && RIVE_WEBGL
#include <emscripten/emscripten.h>
#include <emscripten/html5.h>
Expand All @@ -55,8 +74,15 @@

#endif

//==============================================================================

#if YUP_RIVE_USE_DAWN
#include "native/yup_GraphicsContext_dawn.cpp"
#include "native/yup_GraphicsContext_dawn_helper.cpp"
#endif

//==============================================================================

#include "native/yup_GraphicsContext_impl.cpp"

//==============================================================================
Expand Down
5 changes: 3 additions & 2 deletions modules/yup_graphics/yup_graphics.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,13 @@

#include <juce_core/juce_core.h>

#include <rive_renderer/rive_renderer.h>

//==============================================================================

JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wattributes")
#include <rive/rive.h>
#include <rive/text/utf.hpp>

JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wattributes")
#include <rive/renderer/render_context.hpp>
#include <rive/renderer/render_context_impl.hpp>
JUCE_END_IGNORE_WARNINGS_GCC_LIKE
Expand Down
4 changes: 2 additions & 2 deletions modules/yup_gui/component/yup_Component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ bool Component::isOnDesktop() const
return options.onDesktop;
}

void Component::addToDesktop (ComponentNative::Flags flags, void* parent, std::optional<float> framerateRedraw)
void Component::addToDesktop (const ComponentNative::Options& nativeOptions, void* parent)
{
if (options.onDesktop)
removeFromDesktop();
Expand All @@ -342,7 +342,7 @@ void Component::addToDesktop (ComponentNative::Flags flags, void* parent, std::o

options.onDesktop = true;

native = ComponentNative::createFor (*this, flags, parent, framerateRedraw);
native = ComponentNative::createFor (*this, nativeOptions, parent);

setBounds (getBounds()); // This is needed to update based on scaleDpi
}
Expand Down
4 changes: 1 addition & 3 deletions modules/yup_gui/component/yup_Component.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,7 @@ class JUCE_API Component

//==============================================================================
bool isOnDesktop() const;
void addToDesktop (ComponentNative::Flags flags,
void* parent = nullptr,
std::optional<float> framerateRedraw = std::nullopt);
void addToDesktop (const ComponentNative::Options& nativeOptions, void* parent);
void removeFromDesktop();

virtual void userTriedToCloseWindow();
Expand Down
Loading