diff --git a/core/src/avm2/globals.rs b/core/src/avm2/globals.rs index 884895ac59d9..aaac4d7e071d 100644 --- a/core/src/avm2/globals.rs +++ b/core/src/avm2/globals.rs @@ -201,6 +201,9 @@ pub struct SystemClassDefs<'gc> { pub graphicssolidfill: Class<'gc>, pub graphicsshaderfill: Class<'gc>, pub graphicsstroke: Class<'gc>, + + pub cubetexture: Class<'gc>, + pub rectangletexture: Class<'gc>, } impl<'gc> SystemClasses<'gc> { @@ -357,6 +360,9 @@ impl<'gc> SystemClassDefs<'gc> { graphicssolidfill: object, graphicsshaderfill: object, graphicsstroke: object, + + cubetexture: object, + rectangletexture: object, } } } @@ -959,6 +965,8 @@ pub fn init_native_system_classes(activation: &mut Activation<'_, '_>) { ), ("flash.display", "GraphicsSolidFill", graphicssolidfill), ("flash.display", "GraphicsStroke", graphicsstroke), + ("flash.display3D.textures", "CubeTexture", cubetexture), + ("flash.display3D.textures", "RectangleTexture", rectangletexture), ] ); } diff --git a/core/src/avm2/globals/flash/display3D/context_3d.rs b/core/src/avm2/globals/flash/display3D/context_3d.rs index 3c6f0a222148..8fa7e0f0a16d 100644 --- a/core/src/avm2/globals/flash/display3D/context_3d.rs +++ b/core/src/avm2/globals/flash/display3D/context_3d.rs @@ -599,6 +599,25 @@ pub fn set_render_to_texture<'gc>( let surface_selector = args.get_u32(activation, 3)?; let color_output_index = args.get_u32(activation, 4)?; + let mut error = None; + if texture.instance_class() == activation.avm2().class_defs().cubetexture { + if surface_selector > 5 { + error = Some((3772, "Error #3772: Cube textures need to have surfaceSelector [0..5].")); + } + } else if texture.instance_class() == activation.avm2().class_defs().rectangletexture { + if surface_selector != 0 { + error = Some((3773, "Error #3773: Rectangle textures need to have surfaceSelector = 0.")); + } + } else { + // normal Texture or video texture (but the latter should probably not be supported here anyway) + if surface_selector != 0 { + error = Some((3771, "Error #3771: 2D textures need to have surfaceSelector = 0.")); + } + } + if let Some((code, message)) = error { + return Err(Error::AvmError(argument_error(activation, message, code)?)); + } + if anti_alias != 0 { avm2_stub_method!( activation,