{"record":{"id":"1a9f4457d3342d9b","repo":"FyroxEngine/Fyrox","slug":"only-rectangle-textures-can-be-used-as-render-targ","errorCode":null,"errorMessage":"only rectangle textures can be used as render target!","messagePattern":"only rectangle textures can be used as render target!","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"fyrox-impl/src/engine/mod.rs","lineNumber":1723,"sourceCode":"            let inner_size = ctx.window.inner_size();\n            let window_size = Vector2::new(inner_size.width as f32, inner_size.height as f32);\n            ctx.renderer.update_caches(&self.resource_manager, dt);\n            window_size\n        } else {\n            Vector2::new(1.0, 1.0)\n        };\n\n        for (handle, scene) in self.scenes.pair_iter_mut().filter(|(_, s)| *s.enabled) {\n            let frame_size =\n                scene\n                    .rendering_options\n                    .render_target\n                    .as_ref()\n                    .map_or(window_size, |rt| {\n                        if let TextureKind::Rectangle { width, height } = rt.data_ref().kind() {\n                            Vector2::new(width as f32, height as f32)\n                        } else {\n                            panic!(\"only rectangle textures can be used as render target!\");\n                        }\n                    });\n\n            scene.update(\n                frame_size,\n                dt,\n                switches.get(&handle).cloned().unwrap_or_default(),\n            );\n        }\n    }\n\n    /// Performs post update for the engine.\n    ///\n    /// Normally, this is called from `Engine::update()`.\n    /// You should only call this manually if you don't use that method.\n    pub fn post_update(\n        &mut self,\n        dt: f32,","sourceCodeStart":1705,"sourceCodeEnd":1741,"githubUrl":"https://github.com/FyroxEngine/Fyrox/blob/76c91aad8eca488ce527b1af707be8b3b24ad72d/fyrox-impl/src/engine/mod.rs#L1705-L1741","documentation":"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.","triggerScenarios":"Assigning a texture whose kind is not TextureKind::Rectangle to camera render_target (or the engine render target) and then running Engine::update.","commonSituations":"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.","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"],"exampleFix":"// before\nlet tex = TextureBuilder::new().with_kind(TextureKind::D2 { width: 1024, height: 768 })...\ncamera.set_render_target(Some(tex));\n// after\nlet tex = TextureBuilder::new().with_kind(TextureKind::Rectangle { width: 1024, height: 768 })...\ncamera.set_render_target(Some(tex));","handlingStrategy":"validation","validationCode":"assert!(matches!(rt.data_ref().kind(), TextureKind::Rectangle{..}), \"render target must be a Rectangle texture\");","typeGuard":"fn rect_size(t: &Texture) -> Option<Vector2<u32>> { if let TextureKind::Rectangle{width,height} = t.kind() { Some(Vector2::new(width,height)) } else { None } }","tryCatchPattern":null,"preventionTips":["Always build render targets with TextureKind::Rectangle","Keep a TextureBuilder preset for render targets","Check kind() before assigning render_target"],"tags":["render-target","texture","panic","fyrox"],"backgroundTag":"incompatible-source-type","analyzedSha":"76c91aad8eca488ce527b1af707be8b3b24ad72d","analyzedAt":"2026-09-10T16:04:01.633Z","contentChangedAt":"2026-09-10T16:04:01.633Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}