本文整理汇总了C#中PresentParameters类的典型用法代码示例。如果您正苦于以下问题:C# PresentParameters类的具体用法?C# PresentParameters怎么用?C# PresentParameters使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PresentParameters类属于命名空间,在下文中一共展示了PresentParameters类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateDevice
private static Device CreateDevice()
{
var presentParameters = new PresentParameters()
{
Windowed = true,
SwapEffect = SwapEffect.Discard,
BackBufferFormat = Format.Unknown,
AutoDepthStencilFormat = DepthFormat.D16,
EnableAutoDepthStencil = true
};
var deviceCaps = Manager.GetDeviceCaps(Manager.Adapters.Default.Adapter, DeviceType.Hardware).DeviceCaps;
var createFlags = ((deviceCaps.SupportsHardwareTransformAndLight)
? CreateFlags.HardwareVertexProcessing
: CreateFlags.SoftwareVertexProcessing);
if (deviceCaps.SupportsPureDevice)
createFlags |= CreateFlags.PureDevice;
var device = new Device(0, DeviceType.Hardware, RenderForm, createFlags, presentParameters);
device.RenderState.CullMode = Cull.None;
device.RenderState.Lighting = false;
device.DeviceReset += (sender, e) =>
{
System.Diagnostics.Debug.WriteLine("DeviceReset");
var d = (Device)sender;
d.RenderState.CullMode = Cull.None;
d.RenderState.Lighting = false;
};
device.DeviceLost += (sender, e) => { System.Diagnostics.Debug.WriteLine("DeviceLost"); };
device.DeviceResizing += (sender, e) => { System.Diagnostics.Debug.WriteLine("DeviceResizing"); };
return device;
}
示例2: InitializeDevice
public void InitializeDevice()
{
PresentParameters presentParameters = new PresentParameters();
presentParameters.Windowed = true;
presentParameters.SwapEffect = SwapEffect.Discard;
Device = new Device(0, DeviceType.Hardware, this, CreateFlags.SoftwareVertexProcessing, presentParameters);
}
示例3: DxScreenCapture
public DxScreenCapture()
{
PresentParameters present_params = new PresentParameters();
present_params.Windowed = true;
present_params.SwapEffect = SwapEffect.Discard;
d = new Device(new Direct3D(), 0, DeviceType.Hardware, IntPtr.Zero, CreateFlags.SoftwareVertexProcessing, present_params);
}
示例4: DXControl
public DXControl()
{
// start timer
_sw.Start();
// initialize d3d device
_direct3d = new Direct3D();
_presentParam = new PresentParameters()
{
BackBufferWidth = ClientSize.Width,
BackBufferHeight = ClientSize.Height,
Windowed = true,
BackBufferFormat = Format.X8R8G8B8,
BackBufferCount = 1,
SwapEffect = SwapEffect.Discard,
EnableAutoDepthStencil = true,
AutoDepthStencilFormat = Format.D24S8,
};
_device = new Device(_direct3d, 0,
DeviceType.Hardware, Handle,
CreateFlags.HardwareVertexProcessing, _presentParam);
// event handlers
Resize += OnResize;
}
示例5: InitializeGraphics
/// <summary>
///
/// </summary>
public void InitializeGraphics()
{
PresentParameters presentParams = new PresentParameters();
presentParams.Windowed = true;
presentParams.SwapEffect = SwapEffect.Discard;
presentParams.AutoDepthStencilFormat = DepthFormat.D16;
presentParams.EnableAutoDepthStencil = true;
// Create our device
this.dxDevice = new Device(0, DeviceType.Hardware, this.Handle, CreateFlags.SoftwareVertexProcessing, presentParams);
this.dxDevice.RenderState.ZBufferEnable = true;
this.dxDevice.RenderState.ZBufferFunction = Compare.LessEqual;
this.dxDevice.RenderState.MultiSampleAntiAlias = true;
this.vtrOrigin[0] = new Vector3(-1.0f * this.fOriginBounds, 0, 0);
this.vtrOrigin[1] = new Vector3(this.fOriginBounds, 0, 0);
this.vtrOrigin[2] = new Vector3(0, 0, 0);
this.vtrOrigin[3] = new Vector3(0, -1.0f * this.fOriginBounds, 0);
this.vtrOrigin[4] = new Vector3(0, this.fOriginBounds, 0);
this.vtrOrigin[5] = new Vector3(0, 0, 0);
this.vtrOrigin[6] = new Vector3(0, 0, -1.0f * this.fOriginBounds);
this.vtrOrigin[7] = new Vector3(0, 0, this.fOriginBounds);
this.boxMesh = Mesh.Box(this.dxDevice, 4, 0.7f, 6); //change to robot model :-)
this.boxMaterial = new Material();
this.boxMaterial.Emissive = Color.DarkOliveGreen;
this.boxMaterial.Ambient = Color.WhiteSmoke;
this.boxMaterial.Diffuse = Color.WhiteSmoke;
}
示例6: D3dManager
public D3dManager(Form i_main_window, NyARParam i_nyparam, int i_profile_id)
{
PresentParameters pp = new PresentParameters();
// ウインドウモードなら true、フルスクリーンモードなら false を指定
pp.Windowed = true;
// スワップとりあえずDiscardを指定。
pp.SwapEffect = SwapEffect.Discard;
pp.EnableAutoDepthStencil = true;
pp.AutoDepthStencilFormat = DepthFormat.D16;
pp.BackBufferCount = 0;
pp.BackBufferFormat = Format.R5G6B5;
this._d3d_device = new Device(0, DeviceType.Default, i_main_window.Handle, CreateFlags.None, pp);
//ビューポートを指定
float scale = setupView(i_nyparam,i_main_window.ClientSize);
this._scale = scale;
// ライトを無効
this._d3d_device.RenderState.Lighting = false;
//カメラ画像の転写矩形を作成
Viewport vp=this._d3d_device.Viewport;
this._view_rect = new Rectangle(vp.X, vp.Y, vp.Width, vp.Height);
NyARIntSize cap_size = i_nyparam.getScreenSize();
this._background_size = new Size(cap_size.w, cap_size.h);
return;
}
示例7: load_image
public void load_image(string DDS)
{
if (this.gs != null)
{
this.gs.Dispose();
}
try
{
PresentParameters presentParameters = new PresentParameters();
presentParameters.SwapEffect = SwapEffect.Discard;
Format format = Manager.Adapters[0].CurrentDisplayMode.Format;
presentParameters.Windowed = true;
Device device = new Device(0, DeviceType.Hardware, this, CreateFlags.SoftwareVertexProcessing, new PresentParameters[]
{
presentParameters
});
Texture texture = TextureLoader.FromFile(device, DDS);
this.gs = TextureLoader.SaveToStream(ImageFileFormat.Png, texture);
texture.Dispose();
this.pictureBox.Image = Image.FromStream(this.gs);
device.Dispose();
this.gs.Close();
}
catch (Exception var_4_B4)
{
}
}
示例8: PrepareD3dDevice
/* Direct3Dデバイスを準備する関数
*/
private Device PrepareD3dDevice(Control i_window)
{
PresentParameters pp = new PresentParameters();
pp.Windowed = true;
pp.SwapEffect = SwapEffect.Flip;
pp.BackBufferFormat = Format.X8R8G8B8;
pp.BackBufferCount = 1;
pp.EnableAutoDepthStencil = true;
pp.AutoDepthStencilFormat = DepthFormat.D16;
CreateFlags fl_base = CreateFlags.FpuPreserve;
try{
return new Device(0, DeviceType.Hardware, i_window.Handle, fl_base|CreateFlags.HardwareVertexProcessing, pp);
}catch (Exception ex1){
Debug.WriteLine(ex1.ToString());
try{
return new Device(0, DeviceType.Hardware, i_window.Handle, fl_base | CreateFlags.SoftwareVertexProcessing, pp);
}catch (Exception ex2){
// 作成に失敗
Debug.WriteLine(ex2.ToString());
try{
return new Device(0, DeviceType.Reference, i_window.Handle, fl_base | CreateFlags.SoftwareVertexProcessing, pp);
}catch (Exception ex3){
throw ex3;
}
}
}
}
示例9: Init
public static void Init(PictureBox handle)
{
try
{
presentParams = new PresentParameters();
presentParams.Windowed = true;
presentParams.EnableAutoDepthStencil = true;
presentParams.AutoDepthStencilFormat = DepthFormat.D24S8;
presentParams.SwapEffect = SwapEffect.Discard;
device = new Device(0, DeviceType.Hardware, handle, CreateFlags.SoftwareVertexProcessing, presentParams);
if (device == null)
return;
SetupEnvironment();
CreateCoordLines();
CamDistance = 4;
init = true;
cam = new Vector3(0, 0, 0);
dir = new Vector3(1, 1, 1);
camdist = 3f;
DebugLog.PrintLn(presentParams.ToString());
DebugLog.PrintLn(device.DeviceCaps.ToString());
DebugLog.PrintLn("DirectX Init succeeded...");
}
catch (DirectXException ex)
{
string s = "DirectX Init error:"
+ "\n\n" + ex.ToString()
+ "\n\n" + presentParams.ToString();
if (device != null)
s += "\n\n" + device.DeviceCaps.ToString();
DebugLog.PrintLn(s);
error = true;
}
}
示例10: DeviceContext9
internal DeviceContext9(Form form, DeviceSettings9 settings)
{
if (form.Handle == IntPtr.Zero)
throw new ArgumentException("Value must be a valid window handle.", "handle");
if (settings == null)
throw new ArgumentNullException("settings");
this.settings = settings;
PresentParameters = new PresentParameters();
PresentParameters.BackBufferFormat = Format.X8R8G8B8;
PresentParameters.BackBufferCount = 1;
PresentParameters.BackBufferWidth = form.ClientSize.Width;
PresentParameters.BackBufferHeight = form.ClientSize.Height;
PresentParameters.Multisample = settings.MultisampleType;
PresentParameters.SwapEffect = SwapEffect.Discard;
PresentParameters.EnableAutoDepthStencil = true;
PresentParameters.AutoDepthStencilFormat = Format.D24S8;
PresentParameters.PresentFlags = PresentFlags.DiscardDepthStencil;
PresentParameters.PresentationInterval = PresentInterval.Immediate;
PresentParameters.Windowed = settings.Windowed;
PresentParameters.DeviceWindowHandle = form.Handle;
direct3D = new Direct3D();
Device = new Device(direct3D, settings.AdapterOrdinal, DeviceType.Hardware, form.Handle, settings.CreationFlags, PresentParameters);
}
示例11: ScreenCapture
public ScreenCapture()
{
PresentParameters _presentParameters =new PresentParameters();
_presentParameters.Windowed = true;
_presentParameters.SwapEffect=SwapEffect.Discard;
_device = new Device(new Direct3D(), 0, DeviceType.Hardware, IntPtr.Zero, CreateFlags.MixedVertexProcessing, _presentParameters);
}
示例12: D3DDeviceService
private D3DDeviceService(IntPtr windowIntPtr)
{
isDeviceLost = false;
m_pp = new PresentParameters
{
Windowed = true,
SwapEffect = SwapEffect.Discard,
PresentationInterval = PresentInterval.One,
BackBufferFormat = Manager.Adapters.Default.CurrentDisplayMode.Format,
BackBufferWidth = Manager.Adapters.Default.CurrentDisplayMode.Width,
BackBufferHeight = Manager.Adapters.Default.CurrentDisplayMode.Height,
};
CreateFlags flags = new CreateFlags();
Caps caps = Manager.GetDeviceCaps(0, DeviceType.Hardware);
if(caps.DeviceCaps.SupportsHardwareTransformAndLight)
flags |= CreateFlags.HardwareVertexProcessing;
else
flags |= CreateFlags.SoftwareVertexProcessing;
if(caps.DeviceCaps.SupportsPureDevice)
flags |= CreateFlags.PureDevice;
D3DDevice = new Device(0, caps.DeviceType, windowIntPtr, flags, m_pp);
}
示例13: D3DDevice
public D3DDevice(IntPtr windowPtr, bool bWindowed, long Width, long Height)
{
m_bWindowed = bWindowed;
m_Format = Find16BitMode();
PresentParameters presentParameters = new PresentParameters();
presentParameters.Windowed = m_bWindowed;
presentParameters.SwapEffect = SwapEffect.Discard;
presentParameters.BackBufferCount = 1;
presentParameters.PresentationInterval = PresentInterval.Immediate;
presentParameters.AutoDepthStencilFormat = DepthFormat.D16;
presentParameters.EnableAutoDepthStencil = true;
if(!bWindowed)
{
presentParameters.BackBufferFormat = m_Format;
presentParameters.BackBufferWidth = (int)Width;
presentParameters.BackBufferHeight = (int)Height;
}
else
{
presentParameters.BackBufferFormat = Format.Unknown;
presentParameters.BackBufferWidth = (int)Width;
presentParameters.BackBufferHeight = (int)Height;
}
m_D3DDevice = new Microsoft.DirectX.Direct3D.Device(0,
DeviceType.Hardware, windowPtr,
CreateFlags.SoftwareVertexProcessing, presentParameters);
}
示例14: DeviceContext9
/// <summary>
/// Initializes a new instance of the <see cref="DeviceContext9"/> class.
/// </summary>
/// <param name="handle">The window handle to associate with the device.</param>
/// <param name="settings">The settings used to configure the device.</param>
internal DeviceContext9(IntPtr handle, DeviceSettings9 settings)
{
if (handle == IntPtr.Zero)
throw new ArgumentException("Value must be a valid window handle.", "handle");
if (settings == null)
throw new ArgumentNullException("settings");
this.settings = settings;
PresentParameters = new PresentParameters();
PresentParameters.BackBufferFormat = Format.X8R8G8B8;
PresentParameters.BackBufferCount = 1;
PresentParameters.BackBufferWidth = settings.Width;
PresentParameters.BackBufferHeight = settings.Height;
PresentParameters.Multisample = MultisampleType.None;
PresentParameters.SwapEffect = SwapEffect.Discard;
PresentParameters.EnableAutoDepthStencil = true;
PresentParameters.AutoDepthStencilFormat = Format.D24X8;
PresentParameters.PresentFlags = PresentFlags.DiscardDepthStencil;
PresentParameters.PresentationInterval = PresentInterval.Default;
PresentParameters.Windowed = true;
PresentParameters.DeviceWindowHandle = handle;
direct3D = new Direct3D();
int msaaQuality = 0;
if (direct3D.CheckDeviceMultisampleType(settings.AdapterOrdinal, DeviceType.Hardware, Format.A8R8G8B8, true, MultisampleType.FourSamples, out msaaQuality))
{
this.MultisampleType = SlimDX.Direct3D9.MultisampleType.FourSamples;
this.MultisampleQuality = msaaQuality - 1;
PresentParameters.Multisample = MultisampleType.FourSamples;
PresentParameters.MultisampleQuality = msaaQuality - 1;
}
Device = new Device(direct3D, settings.AdapterOrdinal, DeviceType.Hardware, handle, settings.CreationFlags, PresentParameters);
}
示例15: InitializeGraphics
public void InitializeGraphics()
{
try
{
PresentParameters presentParams = new PresentParameters();
presentParams.Windowed = true;
presentParams.SwapEffect = SwapEffect.Discard;
DirectXGraphicsCard = new Device(0,
DeviceType.Hardware,
this,
CreateFlags.HardwareVertexProcessing,
presentParams);
// Create a new Event Handler which is triggered if somebody resizes the window or something
DirectXGraphicsCard.DeviceReset += new System.EventHandler(this.OnResetDevice);
// Currently nobody is resizing any windows so the trigger is set to off
OnResetDevice(DirectXGraphicsCard, null);
}
catch (DirectXException e)
{
MessageBox.Show(null,
"Error intializing graphics: "
+ e.Message, "Error");
Close();
}
}