Jump to content
  • Advertisement
Sign in to follow this  

[.net] DirectX and .NET 2.0

This topic is 4320 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi.. I'm trying to run Hazy mind tutorials on .NET 2.0 but i can't make it work. Here's the code for my vertex group class, it compiles but it generates nothing on screen. The method ReloadResources is called on initialization and Render is called between BeginScene(); and EndScene();
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;
using Microsoft.DirectX.Direct3D.CustomVertex;
using Microsoft.DirectX.Generic;

namespace ClientEngine
    public class EVertexGroup : EObject
        private PositionTextured[] verts;
        private int[] inds;
        private Texture myTexture;
        private string myPath;

        private VertexBuffer vb;
        private IndexBuffer ib;

        public EVertexGroup(PositionTextured[] vertex, int[] index, string imagePath, Device myDevice)
            verts = vertex;
            inds = index;
            myPath = imagePath;

        public override void ReloadResources(Device myDevice)
            myTexture = new Texture(myDevice, myPath);

            vb = VertexBuffer.CreateGeneric<PositionTextured>(myDevice, verts.Length, Usage.WriteOnly, PositionTextured.Format, Pool.Managed, null);
            GraphicsBuffer<PositionTextured> vertBuffData = vb.Lock<PositionTextured>(0, 0, 0);

            ib = new IndexBuffer(myDevice, inds.Length, Usage.WriteOnly, Pool.Default, false, null);
            GraphicsBuffer<int> indexBuffData = ib.Lock<int>(0, 0, 0);            

        public override void Render(Device myDevice)
            myDevice.VertexFormat = PositionTextured.Format;
            myDevice.SetTexture(0, myTexture);
            myDevice.SetStreamSource(0, vb, 0);
            myDevice.Indices = ib;
            myDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, verts.Length, 0, inds.Length / 3);

Is this the right way to do things when one's using .NET 2.0? Thanks in advance! Leandro

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!