Пример #1
0
        private RenderWindow(RenderWindowThread t)
        {
            myThread = t;

            InitializeComponent();
            SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque, true);

            PresentParameters presentationParameters = new PresentParameters();

            presentationParameters.Windowed   = true;
            presentationParameters.SwapEffect = SwapEffect.Discard;

            DeviceType dt = DeviceType.Hardware;

            if (Manager.GetDeviceCaps(0, DeviceType.Hardware).PixelShaderVersion.Major < 3)
            {
                dt    = DeviceType.Reference;
                Text += " (emulated in SW)";
            }
            myDevice = new Device(0, dt, this, CreateFlags.HardwareVertexProcessing, presentationParameters);

            // gamma-correct rendering
            myDevice.RenderState.SrgbWriteEnable = true;

            Assembly assem = Assembly.GetAssembly(typeof(RenderWindow));
            Stream   st    = assem.GetManifestResourceStream("BilievelTextureMagnification.Shader.fx");

            myEffect = Effect.FromStream(myDevice, st, null, null, ShaderFlags.None, null);
            st.Close();
            st = null;
            myEffect.Technique = "threshold";

            VertexElement[] vertexElements = new VertexElement[]
            {
                new VertexElement(0, 0, DeclarationType.Float3, DeclarationMethod.Default, DeclarationUsage.Position, 0),
                new VertexElement(0, 3 * 4, DeclarationType.Float2, DeclarationMethod.Default, DeclarationUsage.TextureCoordinate, 0),
                new VertexElement(0, 5 * 4, DeclarationType.Float2, DeclarationMethod.Default, DeclarationUsage.TextureCoordinate, 1),
                VertexElement.VertexDeclarationEnd
            };
            myVertexDeclaration = new VertexDeclaration(myDevice, vertexElements);
        }
Пример #2
0
        internal static RenderWindow Create()
        {
            RenderWindowThread t = new RenderWindowThread();

            return(t.Window);
        }