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++;
}