[XNA 4.0] Newbie needs help with textured cube

Started by
1 comment, last by mccalljohn90 12 years, 9 months ago
I'm quite new to XNA and I've been experimenting with cubes. But I can't get this code to work. This is from http://stackoverflow.com/questions/4674804/drawing-a-textured-cube-with-multiple-sides-in-xna-4-0

The
Error I get is on the line: cubeEffect.CurrentTechnique = cubeEffect.Techniques["Textured"];

I get the message: "This method does not accept null for this parameter."

My basic variables:

public Texture2D cubeTexture;
float aspectRatio = 0.0f;
public BasicEffect cubeEffect;

This is in my LoadContent method:

cubeTexture = Content.Load<Texture2D>(@"Textures\text1");
aspectRatio = GraphicsDevice.Viewport.AspectRatio;
cubeEffect = new BasicEffect(GraphicsDevice);

This is in my Draw method:

cubeEffect.CurrentTechnique = cubeEffect.Techniques["Textured"];
foreach (EffectPass pass in cubeEffect.CurrentTechnique.Passes)
{
pass.Apply();
BasicShape s = new BasicShape(new Vector3(1, 1, 1), new Vector3(0, 0, 3));
s.SetTopTexture(cubeTexture);
s.SetSideTexture(cubeTexture);
s.SetBottomTexture(cubeTexture);
s.RenderShape(GraphicsDevice, cubeEffect);
}

(The BasicShape code is the same as in the link to the post; it's lengthy, so I won't paste it here.)
Advertisement
Have you poked around with this in a debugger while it's stopped?

What object is null that shouldn't be?

Have you poked around with this in a debugger while it's stopped?

What object is null that shouldn't be?


Yes, I've tried commenting out the line, but the same error occurs with a very similar line of cone in a BasicShapes render method:

effect.Parameters["xTexture"].SetValue(topTexture);

This topic is closed to new replies.

Advertisement