Getting a Surface from a Texture OpenGL

220 views
Skip to first unread message

pingutz

unread,
Sep 26, 2023, 12:26:29 PM9/26/23
to skia-discuss
Hi guys,

I am trying to learn graphics programming and getting an opengl texture I can use in my game engine. First I rendered directly to the FBO0 and my surface was created successfully, now I only get a nullptr. This is my initskia function.

`
auto nativeInterface = GrGLMakeNativeInterface();
sContext = GrDirectContext::MakeGL(nativeInterface).release();
GrGLTextureInfo textureInfo;
GrBackendTexture allocated_texture = sContext->createBackendTexture(
400, 400, GrBackendFormats::MakeGL(GL_RGB8, GL_TEXTURE_2D), GrMipmapped::k, GrRenderable::kYes);
if (!GrBackendTextures::GetGLTextureInfo(allocated_texture,
&textureInfo)) {
std::cout << "allocating texture failed" << std::endl;
}
sSurface = SkSurfaces::WrapBackendTexture(sContext, allocated_texture, kTopLeft_GrSurfaceOrigin, 1, SkColorType::kRGBA_8888_SkColorType, nullptr,
nullptr, nullptr, nullptr).release();
` I am using SDL and I created a context and made it current. I would be very thankful for telling me what I am doing wrong or giving me a working code sample.

Brian Salomon

unread,
Sep 26, 2023, 1:10:49 PM9/26/23
to skia-d...@googlegroups.com
I think your problem is that you're telling Skia that your texture doesn't have an alpha channel (GL_RGB8 not GL_RGBA8) and then asking for the surface to use an SkColorType that does have alpha (kRGBA_8888_SkColorType).

--
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/65a12604-8fc3-4d8e-b253-04219c1171efn%40googlegroups.com.

pingutz

unread,
Sep 26, 2023, 3:43:09 PM9/26/23
to skia-discuss
Really obvious in hindsight,

thanks a lot!
Reply all
Reply to author
Forward
0 new messages