ProjectsForTest/TriFormsApp/TriForm.cs
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.ComponentModel;
using System.Windows.Forms;
using SharpDX;
using SharpDX.D3DCompiler;
using SharpDX.Direct3D;
using SharpDX.Direct3D11;
using SharpDX.DXGI;
using SharpDX.Windows;
using Buffer = SharpDX.Direct3D11.Buffer;
using Device = SharpDX.Direct3D11.Device;
namespace TriFormsApp
{
public partial class TriForm : Form
{
// Create Device and SwapChain
Device device;
SwapChain swapChain;
DeviceContext context;
Factory factory;
Texture2D backBuffer;
RenderTargetView renderView;
Buffer vertices;
CompilationResult vertexShaderByteCode;
CompilationResult pixelShaderByteCode;
VertexShader vertexShader;
PixelShader pixelShader;
InputLayout layout;
public TriForm()
{
InitializeComponent();
var desc = new SwapChainDescription()
{
BufferCount = 1,
ModeDescription = new ModeDescription(this.ClientSize.Width, this.ClientSize.Height, new Rational(60, 1), Format.R8G8B8A8_UNorm),
IsWindowed = true,
OutputHandle = this.Handle,
SampleDescription = new SampleDescription(1, 0),
SwapEffect = SwapEffect.Discard,
Usage = Usage.RenderTargetOutput
};
Device.CreateWithSwapChain(DriverType.Hardware, DeviceCreationFlags.None, desc, out device, out swapChain);
context = device.ImmediateContext;
// Ignore all windows events
factory = swapChain.GetParent<Factory>();
factory.MakeWindowAssociation(this.Handle, WindowAssociationFlags.IgnoreAll);
// New RenderTargetView from the backbuffer
backBuffer = Texture2D.FromSwapChain<Texture2D>(swapChain, 0);
renderView = new RenderTargetView(device, backBuffer);
// Compile Vertex and Pixel shaders
vertexShaderByteCode = ShaderBytecode.CompileFromFile("MiniTri.fx", "VS", "vs_4_0", ShaderFlags.None, EffectFlags.None);
vertexShader = new VertexShader(device, vertexShaderByteCode);
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。