简体   繁体   English

未设置顶点缓冲区中的最后一个顶点

[英]Last vertex in vertex buffer not being set

I'm attempting to render a sphere in Direct11 using SharpDX. 我正在尝试使用SharpDX在Direct11中渲染球体。 I have correctly read in the OBJ model, created the vertex buffers, and set the buffers on the context for rendering. 我已经正确读取了OBJ模型,创建了顶点缓冲区,并在上下文中设置了缓冲区以进行渲染。

My problem is that everything rendering perfectly EXCEPT the very last vertex, which is rendered as if it were at 0, 0, 0. Below is a screen shot of this: 我的问题是,除了最后一个顶点(好像位于0、0、0处一样),所有渲染都完美地呈现了。以下是此屏幕截图: 在此处输入图片说明

I have checked the vectors that get used when creating the buffers and there is no missing data in there, I even changed the last element in the array like this: 我已经检查了创建缓冲区时使用的向量,并且那里没有丢失的数据,我什至更改了数组中的最后一个元素,如下所示:

vertexBufferArray[vertexBufferArray.Length - 1].X = 1.0f;

and had no result. 而且没有结果。 Whereas if I change the second to last element like this: 而如果我像这样将倒数第二个元素更改为:

vertexBufferArray[vertexBufferArray.Length - 2].X = 1.0f;

I get this result: 我得到这个结果: 在此处输入图片说明

The vertex count that I am passing to the render call is correct because if I pass it VertexCount - 1, I don't get the last triangle at all, and if I pass it VertexCount + 100, nothing changes at all. 我传递给render调用的顶点数是正确的,因为如果我将其传递给VertexCount-1,则根本不会获得最后一个三角形,并且如果将其传递给VertexCount + 100,则没有任何改变。

Any ideas? 有任何想法吗?

As usual I end up fixing the problem 10 mins after I make a big post about it. 像往常一样,我在发布大量有关该问题的10分钟后最终解决了该问题。

The problem was my Input Assembler, my input elements for POSITION and NORMAL were of Format.R32G32B32A32_Float, when they should have been Format.R32G32B32_Float since I was giving my vertices in as Vector3s. 问题出在我的输入汇编程序上,我的POSITION和NORMAL输入元素是Format.R32G32B32A32_Float,当它们应该是Format.R32G32B32_Float时,因为我将顶点作为Vector3s输入了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM