vs 2010managed directx의 14

2025 단어 Direct3DHLSLMDXC#
개요
그리고 3D를 하고 싶어요.
hlsl을 만들어 봤어요.
사진.

샘플 코드
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;

namespace WindowsFormsApplication11
{
    public partial class Form1 : Form
    {
        Device device = null;
        PresentParameters ppr = new PresentParameters();
        Effect effect;
        Mesh m;

        public Form1()
        {
            InitializeComponent();
            this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque, true);
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            ppr.Windowed = true;
            ppr.SwapEffect = SwapEffect.Discard;
            device = new Device(0, DeviceType.Hardware, this, CreateFlags.SoftwareVertexProcessing, ppr);
            m = Mesh.Teapot(device);
            try
            {
                string a;
                effect = Effect.FromFile(device, "my0.fx", null, null, ShaderFlags.None, null, out a);
             }
            catch
            {
                MessageBox.Show("ng1");
            }
        }
        private void Form1_Paint(object sender, PaintEventArgs e)
        {      
            device.BeginScene();
            device.RenderState.CullMode = Cull.None;
            device.RenderState.ZBufferEnable = true;
            device.Clear(ClearFlags.Target, Color.DarkBlue, 1f, 0);
            effect.Begin(FX.None);
            effect.BeginPass(0);            
            m.DrawSubset(0);
            effect.EndPass();
            effect.End();
            device.EndScene();
            device.Present();
            this.Invalidate();
        }
    }
}



이상.

좋은 웹페이지 즐겨찾기