Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
Anonymous
unregistriert
C-/C++-Quelltext |
|
1 |
device = new Device(0, DeviceType.Hardware, this, CreateFlags.SoftwareVertexProcessing, presentParams); |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
//----------------------------------------------------------------------------- // File: CreateDevice.cs // // Desc: This is the first tutorial for using Direct3D. In this tutorial, all // we are doing is creating a Direct3D device and using it to clear the // window. // // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- using System; using System.Drawing; using System.Windows.Forms; using Microsoft.DirectX; using Microsoft.DirectX.Direct3D; namespace DeviceTutorial { public class CreateDevice : Form { // Our global variables for this project Device device = null; // Our rendering device public CreateDevice() { // Set the initial size of our form this.ClientSize = new System.Drawing.Size(400,300); // And it's caption this.Text = "D3D Tutorial 01: CreateDevice"; } public bool InitializeGraphics() { try { // Now let's setup our D3D stuff PresentParameters presentParams = new PresentParameters(); presentParams.Windowed=true; presentParams.SwapEffect = SwapEffect.Discard; device = new Device(0, DeviceType.Hardware, this, CreateFlags.SoftwareVertexProcessing, presentParams); return true; } catch (DirectXException e) { MessageBox.Show(e.ToString()); return false; } } private void Render() { if (device == null) return; //Clear the backbuffer to a blue color device.Clear(ClearFlags.Target, System.Drawing.Color.Blue, 1.0f, 0); //Begin the scene device.BeginScene(); // Rendering of scene objects can happen here //End the scene device.EndScene(); device.Present(); } protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { this.Render(); // Render on painting } protected override void OnKeyPress(System.Windows.Forms.KeyPressEventArgs e) { if ((int)(byte)e.KeyChar == (int)System.Windows.Forms.Keys.Escape) this.Close(); // Esc was pressed } /// <summary> /// The main entry point for the application. /// </summary> static void Main() { using (CreateDevice frm = new CreateDevice()) { if (!frm.InitializeGraphics()) // Initialize Direct3D { MessageBox.Show("Could not initialize Direct3D. This tutorial will exit."); return; } frm.Show(); // While the form is still valid, render and process messages while(frm.Created) { frm.Render(); Application.DoEvents(); } } } } } |
Administrator