Sorry, the Forum is closed :(

Unfortunately, the forum is now closed.

Please read the following post for further details.

We apologize for the inconvenience.
The SharpDX team.
Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC: [D3D10] Buffer.Map() fails

[D3D10] Buffer.Map() fails 1 year 4 months ago #1308

Hi all, i've got a trouble with vertex buffer mapping. I want to initialize dynamic vertex buffer and rewrite its content on demand.
Here is the code:
    public struct VertexPositionColor
        public Vector4 Position;
        public Vector4 Color;

        public VertexPositionColor(Vector4 position, Vector4 color)
            Position = position;
            Color = color;


        Buffer dvb;

        void InitializeVertexBuffer(int size)
            var dvbDesc = new BufferDescription(sizeof(VertexPositionColor) * size, 

            var vertices = new VertexPositionColor[maxVerticesCount];
            dvb = Buffer.Create(dev, vertices, dvbDesc);

        private static void FillVertexBuffer()
            var dvbStream = dvb.Map(MapMode.Write); // <- Exception
            dvbStream.Seek(0, SeekOrigin.Begin);
                dvbStream.Write(new VertexPositionColor(new Vector4(0.0f, 0.5f, 0.5f, 1.0f), new Vector4(1.0f, 0.0f, 0.0f, 1.0f)));
                dvbStream.Write(new VertexPositionColor(new Vector4(0.5f, -0.5f, 0.5f, 1.0f), new Vector4(0.0f, 1.0f, 0.0f, 1.0f)));
                dvbStream.Write(new VertexPositionColor(new Vector4(-0.5f, -0.5f, 0.5f, 1.0f), new Vector4(0.0f, 0.0f, 1.0f, 1.0f)));

Exception info:
HRESULT: [0x80070057], Module: [Unknown], ApiCode: [Unknown/Unknown], Message: The parameter is incorrect.

Help to fix, please.
The administrator has disabled public write access.

Re: [D3D10] Buffer.Map() fails 1 year 4 months ago #1314

  • Posts:2
  • poulpi's Avatar
  • poulpi
  • Fresh Boarder

Create the device with DeviceCreationFlags.Debug, and check "Enable native code debugging" in the project properties. You will then have more info about the error from directx in the output log of Visual Studio.
Last Edit: 1 year 4 months ago by xoofx. Reason: Change console to VS output log
The administrator has disabled public write access.
  • Page:
  • 1
Time to create page: 0.260 seconds