FyroxEngine/Fyrox · error
only rectangle textures can be used as render target!
Error message
only rectangle textures can be used as render target!
What it means
Engine::update derives the frame size from the scene render target; if a render-target texture is set, it must be a Rectangle texture. Any other TextureKind (e.g. D2, Cube) panics because its dimensions cannot be used as a framebuffer size.
Solutions
- Build the render-target texture with TextureKind::Rectangle { width, height }
- Verify rt.data_ref().kind() is Rectangle before assigning it as render target
- Leave render_target as None to use the window backbuffer size
Example fix
// before
let tex = TextureBuilder::new().with_kind(TextureKind::D2 { width: 1024, height: 768 })...
camera.set_render_target(Some(tex));
// after
let tex = TextureBuilder::new().with_kind(TextureKind::Rectangle { width: 1024, height: 768 })...
camera.set_render_target(Some(tex)); Defensive patterns
Strategy: validation
Validate before calling
assert!(matches!(rt.data_ref().kind(), TextureKind::Rectangle{..}), "render target must be a Rectangle texture"); Type guard
fn rect_size(t: &Texture) -> Option<Vector2<u32>> { if let TextureKind::Rectangle{width,height} = t.kind() { Some(Vector2::new(width,height)) } else { None } } Prevention
- Always build render targets with TextureKind::Rectangle
- Keep a TextureBuilder preset for render targets
- Check kind() before assigning render_target
When it happens
Trigger: Assigning a texture whose kind is not TextureKind::Rectangle to camera render_target (or the engine render target) and then running Engine::update.
Common situations: Using TextureBuilder with kind D2 for an offscreen render target; reusing a sampled 2D texture as a render target; version differences where render targets required Rectangle kinds.
Understand the failure class
Background: "is not a compatible type" / "cannot merge" errors: when a value's type doesn't match what the library requires — this error's family across 65 libraries.
Related errors
- only rectangle textures can be used as render target!
- Missing hole mask texture
- Graphics context is uninitialized!
- Graph pool must be empty on load!
- Invalid pixel position
AI-assisted analysis of FyroxEngine/Fyrox@76c91aad8e (2026-09-10).
Data as JSON: /api/errors/1a9f4457d3342d9b.
Report an issue: GitHub.
Appendix: source
Thrown at fyrox-impl/src/engine/mod.rs:1723
let inner_size = ctx.window.inner_size();
let window_size = Vector2::new(inner_size.width as f32, inner_size.height as f32);
ctx.renderer.update_caches(&self.resource_manager, dt);
window_size
} else {
Vector2::new(1.0, 1.0)
};
for (handle, scene) in self.scenes.pair_iter_mut().filter(|(_, s)| *s.enabled) {
let frame_size =
scene
.rendering_options
.render_target
.as_ref()
.map_or(window_size, |rt| {
if let TextureKind::Rectangle { width, height } = rt.data_ref().kind() {
Vector2::new(width as f32, height as f32)
} else {
panic!("only rectangle textures can be used as render target!");
}
});
scene.update(
frame_size,
dt,
switches.get(&handle).cloned().unwrap_or_default(),
);
}
}
/// Performs post update for the engine.
///
/// Normally, this is called from `Engine::update()`.
/// You should only call this manually if you don't use that method.
pub fn post_update(
&mut self,
dt: f32,View on GitHub (pinned to 76c91aad8e)