GLError when using RenderTarget to render at an external GL texture
- Dominant language
- C++
- Stars
- 20.5k
- Forks
- 2.3k
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 83
Description
### Discussed in https://github.com/google/filament/discussions/6223
Originally posted by **starccode** October 26, 2022
Hi,
I'm trying to render the engine's output into an external openGL texture that created outside of filament. Besides all of the work is at iOS platform and openGL backend, here is my solution:
First, create engine with shareGLContext, and a headless swapChain instead of CAEGLayer surface:
`_engine = Engine::create(Engine::Backend::OPENGL, nullptr, sharedGLContext)`
`_swapChain = _engine->createSwapChain(width, height);`
Then, create renderTarget with a import texture and config the view:
```
_color = Texture::Builder()
.width(width).height(height).levels(1)
.import(textureId)
.usage(Texture::Usage::COLOR_ATTACHMENT | Texture::Usage::SAMPLEABLE |
Texture::Usage::STENCIL_ATTACHMENT)
.format(Texture::InternalFormat::RGBA8).build(*_engine);
_renderTarget = RenderTarget::Builder()
.texture(RenderTarget::AttachmentPoint::COLOR, _color)
.build(*_engine);
_view = _engine->createView();
_view->setScene(_scene);
_view->setCamera(_camera);
_view->setRenderTarget(_renderTarget);
_view->
```
Finally, render the result to the view:
```
if (_renderer->beginFrame(_swapChain)) {
_renderer->render(_view);
_renderer->endFrame();
}
```
But the problem I met is that when I run the code with debug mode, I receive "GLError 1282" message as following:

and when I run it with release mode, it can render the result to the import texture as following:
but the fps is lower than render to a CAEGLayer.
**If there anyone can explain the "GLError 1282" error, and how to solve this problem?** Besides, the problem can reproduce at gltf-view sample workspace.
Contributor guide
Assessment
This issue has not been assessed yet.