diff --git a/examples/Example.h b/examples/Example.h index 5566efbf..33dc9a76 100644 --- a/examples/Example.h +++ b/examples/Example.h @@ -349,7 +349,7 @@ struct GlWindow : Window void resize() override { //Set the canvas target and draw on it. - verify(static_cast(canvas)->target(0, width, height, tvg::ColorSpace::ABGR8888S)); + verify(static_cast(canvas)->target(context, 0, width, height, tvg::ColorSpace::ABGR8888S)); } void refresh() override diff --git a/examples/MultiCanvas.cpp b/examples/MultiCanvas.cpp index b5712cea..04689bd7 100644 --- a/examples/MultiCanvas.cpp +++ b/examples/MultiCanvas.cpp @@ -218,7 +218,7 @@ void runGl() auto canvas = unique_ptr(tvg::GlCanvas::gen()); // Pass the framebuffer id to the GlCanvas - tvgexam::verify(canvas->target(glFbo.fbo, SIZE, SIZE, tvg::ColorSpace::ABGR8888S)); + tvgexam::verify(canvas->target(context, glFbo.fbo, SIZE, SIZE, tvg::ColorSpace::ABGR8888S)); content(canvas.get()); if (tvgexam::verify(canvas->draw())) { diff --git a/inc/thorvg.h b/inc/thorvg.h index 6443ae62..b64a11b5 100644 --- a/inc/thorvg.h +++ b/inc/thorvg.h @@ -1750,6 +1750,7 @@ public: * This function specifies the drawing target where the rasterization will occur. It can target * a specific framebuffer object (FBO) or the main surface. * + * @param[in] context The GL context assigning to the current canvas rendering. * @param[in] id The GL target ID, usually indicating the FBO ID. A value of @c 0 specifies the main surface. * @param[in] w The width (in pixels) of the raster image. * @param[in] h The height (in pixels) of the raster image. @@ -1763,7 +1764,7 @@ public: * * @note Experimental API */ - Result target(int32_t id, uint32_t w, uint32_t h, ColorSpace cs) noexcept; + Result target(void* context, int32_t id, uint32_t w, uint32_t h, ColorSpace cs) noexcept; /** * @brief Creates a new GlCanvas object. diff --git a/src/bindings/capi/thorvg_capi.h b/src/bindings/capi/thorvg_capi.h index b940302b..397bbf61 100644 --- a/src/bindings/capi/thorvg_capi.h +++ b/src/bindings/capi/thorvg_capi.h @@ -519,6 +519,7 @@ TVG_API Tvg_Canvas* tvg_glcanvas_create(void); * This function specifies the drawing target where the rasterization will occur. It can target * a specific framebuffer object (FBO) or the main surface. * +* @param[in] context The GL context assigning to the current canvas rendering. * @param[in] id The GL target ID, usually indicating the FBO ID. A value of @c 0 specifies the main surface. * @param[in] w The width (in pixels) of the raster image. * @param[in] h The height (in pixels) of the raster image. @@ -530,7 +531,7 @@ TVG_API Tvg_Canvas* tvg_glcanvas_create(void); * * @note Experimental API */ -TVG_API Tvg_Result tvg_glcanvas_set_target(Tvg_Canvas* canvas, int32_t id, uint32_t w, uint32_t h, Tvg_Colorspace cs); +TVG_API Tvg_Result tvg_glcanvas_set_target(Tvg_Canvas* canvas, void* context, int32_t id, uint32_t w, uint32_t h, Tvg_Colorspace cs); /** \} */ // end defgroup ThorVGCapi_GlCanvas diff --git a/src/bindings/capi/tvgCapi.cpp b/src/bindings/capi/tvgCapi.cpp index 8ba203cc..c18e6287 100644 --- a/src/bindings/capi/tvgCapi.cpp +++ b/src/bindings/capi/tvgCapi.cpp @@ -102,10 +102,10 @@ TVG_API Tvg_Result tvg_swcanvas_set_target(Tvg_Canvas* canvas, uint32_t* buffer, } -TVG_API Tvg_Result tvg_glcanvas_set_target(Tvg_Canvas* canvas, int32_t id, uint32_t w, uint32_t h, Tvg_Colorspace cs) +TVG_API Tvg_Result tvg_glcanvas_set_target(Tvg_Canvas* canvas, void* context, int32_t id, uint32_t w, uint32_t h, Tvg_Colorspace cs) { if (!canvas) return TVG_RESULT_INVALID_ARGUMENT; - return (Tvg_Result) reinterpret_cast(canvas)->target(id, w, h, static_cast(cs)); + return (Tvg_Result) reinterpret_cast(canvas)->target(context, id, w, h, static_cast(cs)); } diff --git a/src/renderer/tvgGlCanvas.cpp b/src/renderer/tvgGlCanvas.cpp index b829ced8..f1abecc3 100644 --- a/src/renderer/tvgGlCanvas.cpp +++ b/src/renderer/tvgGlCanvas.cpp @@ -41,7 +41,7 @@ GlCanvas::~GlCanvas() } -Result GlCanvas::target(int32_t id, uint32_t w, uint32_t h, ColorSpace cs) noexcept +Result GlCanvas::target(void* context, int32_t id, uint32_t w, uint32_t h, ColorSpace cs) noexcept { #ifdef THORVG_GL_RASTER_SUPPORT if (cs != ColorSpace::ABGR8888S) return Result::NonSupport;