DevPresentParameters = new PresentParameters();
DevPresentParameters.PresentationInterval = PresentInterval.Immediate;
DevPresentParameters.BackBufferCount = 1;
if (setup.pleinecran == true)
{
GRAP.logs.Ajout("Ecran init> "+GRAP.GetDonnee(TypesDonnee.Langage, "err22"));
DevPresentParameters.Windowed = false;
this.FormBorderstyle = FormBorderstyle.None;
//this.Size = setup.primaire_res; //On sais pas si cette ligne est utile
this.ClientSize = setup.primaire_res; //La résolution
DevPresentParameters.BackBufferHeight = this.ClientRectangle.Bottom - this.ClientRectangle.Top; //this.Size.Height;
DevPresentParameters.BackBufferWidth = this.ClientRectangle.Right - this.ClientRectangle.Left; //this.Size.Width;
DevPresentParameters.BackBufferFormat = setup.primaire_format;
}
else
{
GRAP.logs.Ajout("Ecran init> "+GRAP.GetDonnee(TypesDonnee.Langage, "err23"));
DevPresentParameters.Windowed = true;
this.FormBorderstyle = FormBorderstyle.FixedDialog;
this.Size = setup.primaire_res; //Taille externe, formulaire compris
}
GRAP.logs.Ajout("Ecran init> Paramètre présentation");
DevPresentParameters.SwapEffect = SwapEffect.Discard;
//Z-buffer
DevPresentParameters.EnableAutoDepthStencil = true;
DevPresentParameters.AutoDepthStencilFormat = DepthFormat.D16;
//Le Device
GRAP.logs.Ajout("Ecran init> "+GRAP.GetDonnee(TypesDonnee.Langage, "err24"));
try
{
try
{
GRAP.logs.Ajout("Ecran init> CreateFlags.HardwareVertexProcessing");
device = new Device(0, DeviceType.Hardware, this, CreateFlags.HardwareVertexProcessing, DevPresentParameters);
}
catch
{
GRAP.logs.Ajout("Ecran init> CreateFlags.SoftwareVertexProcessing");
device = new Device(0, DeviceType.Hardware, this, CreateFlags.SoftwareVertexProcessing, DevPresentParameters);
}
device.DeviceLost += new EventHandler(GRAP.onDeviceLost);
device.DeviceReset += new EventHandler(GRAP.onDeviceReset);
device.DeviceResizing += new CancelEventHandler(GRAP.onDeviceResizing);
device.Disposing += new EventHandler(GRAP.onDisposing);
}
catch (Exception e)
{
GRAP.logs.Ajout("Ecran init> "+GRAP.GetDonnee(TypesDonnee.Langage, "err25")+" : "+e.Message);
GRAP.Status = GRA_Status.exit;
return;
}
public void SwitchWindowedMode()
{
logs.Ajout("GRA> SwitchWindowedMode");
PresentParameters pres = ecran_primaire.DevPresentParameters;
GRA_Setup setup = (GRA_Setup)GetDonnee(TypesDonnee.Objets, "setup");
pres.Windowed = !pres.Windowed;
pres.BackBufferHeight = ecran_primaire.ClientRectangle.Bottom - ecran_primaire.ClientRectangle.Top; //this.Size.Height;
pres.BackBufferWidth = ecran_primaire.ClientRectangle.Right - ecran_primaire.ClientRectangle.Left; //this.Size.Width;
if (pres.Windowed == false)
{
ecran_primaire.ClientSize = setup.primaire_res; //La résolution
}
else
{
ecran_primaire.ClientSize = new Size(320,240);
ecran_primaire.Size = setup.primaire_res;
ecran_primaire.FormBorderstyle = FormBorderstyle.FixedDialog;
}
pres.BackBufferFormat = setup.primaire_format;
ecran_primaire.device.Reset(pres);
}