Jump to content
  • Advertisement
Sign in to follow this  
mccalljohn90

[XNA 4.0] Newbie needs help with textured cube

This topic is 2563 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.)

Share this post


Link to post
Share on other sites
Advertisement
Have you poked around with this in a debugger while it's stopped?

What object is null that shouldn't be?

Share this post


Link to post
Share on other sites

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);

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!