flicker when drawing 4 models for the first time

i have some models that i only draw at a certain moment in the game (after some seconds since the game has started). The problem is that in that first second when i start to draw the models, i see a flicker (in the sence that everything besides those models, dissapears, the background gets purple). The flicker only lasts for that frame, and then everything seems to run the way it should.

UPDATE I see now that regardless of the moment i draw the models, the first frame has always the flickering aspect

What could this be about? i'll share my draw method:

int temp = 0;
foreach (MeshObject meshObj in ShapeList)
{
foreach (BasicEffect effect in meshObj.mesh.Effects)
{
#region color elements

int i = int.Parse(meshObj.mesh.Name.ElementAt(1) + "");
int j = int.Parse(meshObj.mesh.Name.ElementAt(2) + "");
int getShapeColor = shapeColorList.ElementAt(i * 4 + j);
if (getShapeColor == (int)Constants.shapeColor.yellow)
effect.DiffuseColor = yellow;
else if (getShapeColor == (int)Constants.shapeColor.red)
effect.DiffuseColor = red;
else if (getShapeColor == (int)Constants.shapeColor.green)
effect.DiffuseColor = green;
else if (getShapeColor == (int)Constants.shapeColor.blue)
effect.DiffuseColor = blue;

#endregion

#region lighting

effect.LightingEnabled = true;
effect.AmbientLightColor = new Vector3(0.25f, 0.25f, 0.25f);

effect.DirectionalLight0.Enabled = true;
effect.DirectionalLight0.Direction = new Vector3(-0.3f, -0.3f, -0.9f);
effect.DirectionalLight0.SpecularColor = new Vector3(.7f, .7f, .7f);

Vector3 v = Vector3.Normalize(new Vector3(-100, 0, -100));
effect.DirectionalLight1.Enabled = true;
effect.DirectionalLight1.Direction = v;
effect.DirectionalLight1.SpecularColor = new Vector3(0.6f, 0.6f, .6f);

#endregion

effect.Projection = camera.projectionMatrix;
effect.View = camera.viewMatrix;
if (meshObj.isSetInPlace == true)
{
effect.World = transforms[meshObj.mesh.ParentBone.Index] * gameobject.orientation; // draw in original cube-placed position
meshObj.mesh.Draw();
}
else
{
effect.World = meshObj.Orientation; // draw inSetInPlace position
meshObj.mesh.Draw();
}
}
temp++;
}

• For starters, I don't think you should be doing meshObj.mesh.Draw() inside the inner foreach loop, because that way you'll be potentially drawing the mesh several times per frame. Move that call to the bottom of the outer foreach instead. – David Gouveia Mar 1 '12 at 16:12
• thanks! good point but it still doesn't solve my problem. – Alex Mar 1 '12 at 16:19
• Yeah, I didn't think it would. I think the purple background usually shows when you're not clearing the graphics device at the top of your Draw method. Are you calling GraphicsDevice.Clear() properly? – David Gouveia Mar 1 '12 at 16:24
• yes, i am calling .Clear() on every draw – Alex Mar 1 '12 at 16:48

 spriteBatch.Begin();

• The documentation says that you should call elementRenderer.Render(); before SpriteBatch.Begin() not after. See if that makes any difference. Also I think you should have added this as an edit to your question, not as an answer, since it didn't really solve your problem, only identified it. – David Gouveia Mar 2 '12 at 13:26