I am trying to use SDL, OpenGL, and Skia to draw and display in a window, But all I get is a black window. I know that the GPU rendering is working, becuase I am able to save the GPU-backed surface into a PNG file, where I see the correct drawing.Here's a minimal example of what I'm doing:void f(SDL_Window *window)
{
SDL_GLContext sdl_gl_context = SDL_GL_CreateContext(window);
sk_sp<GrDirectContext> skia_gl_context = GrDirectContext::MakeGL();
int w, h;
SDL_GetWindowSizeInPixels(window, &w, &h);
SkImageInfo skia_gl_context_info = SkImageInfo::MakeN32Premul(w, h);
sk_sp<SkSurface> surface(
SkSurface::MakeRenderTarget(skia_gl_context.get(),
SkBudgeted::kNo, skia_gl_context_info));
SkCanvas *canvas = surface->getCanvas();
draw(canvas, w, h);
SDL_GL_SwapWindow(window);
write_png(surface);
SDL_GL_DeleteContext(sdl_gl_context);
}What am I missing?On Wednesday, December 14, 2022 at 3:51:06 PM UTC-5 Evan Davis wrote:Nevermind, the function is defined in "GrDirectContext.h", but I needed to add the line:#define SK_GLbefore including that file.On Wednesday, December 14, 2022 at 3:20:05 PM UTC-5 Evan Davis wrote:The example for creating an OpenGL-backed canvas mentions the function:GrDirectContext::MakeGL(interface)But my compiler complains:no member named 'MakeGL' in 'GrDirectContext'
--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/skia-discuss/4a97ce2e-4c5a-4018-b9c4-5541ea28a05fn%40googlegroups.com.
Brian Salomon | | Office Hours: go/bsalomon-office | | bsal...@google.com |
Thanks!Now I just need to figure out how to get GrRecordingContext and GrBackendRenderTarget from the GL context created by SDL..
--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/skia-discuss/1a1c8837-b57d-454f-8718-9e4f597ab382n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/skia-discuss/1436f490-d96c-4afd-a230-26699c575a89n%40googlegroups.com.