如何在另一种颜色的顶点缓冲区中绘制顶点 [英] How to draw vertices in a vertex buffer in another color
问题描述
我使用Direct3D 9画线。
I'm using Direct3D 9 to draw lines.
现在使用的顶点格式为 D3DFVF_XYZ | D3DFVF_DIFFUSE
并存储在顶点缓冲区中。它们以 DrawPrimitive
作为 D3DPT_LINELIST
绘制。
The vertices I am using now have the format D3DFVF_XYZ|D3DFVF_DIFFUSE
and are stored in a vertex buffer. They are drawn with DrawPrimitive
as D3DPT_LINELIST
.
我改变整个绘制的顶点缓冲区的绘制颜色,甚至一个特定的顶点,而不锁定顶点缓冲区来修改它的内容?这必须在每一帧。
How do I change the drawn color of a the whole drawn vertex buffer or even a specific vertex without locking the vertex buffer to modify it's content? This has to be done every frame.
这是否可能与顶点缓冲区?我更喜欢没有自定义着色器的解决方案(使用默认的direct3d 9流水线)。
Is this possible with a vertex buffer? I would prefer a solution without a custom shader (using the default direct3d 9 pipeline).
如果这是不可能的, ?我只能想到锁定顶点缓冲区或使用 DrawPrimitiveUP
。
If this is not possible, what would be the next best thing to do performance wise? I can only think of locking the vertex buffer or using DrawPrimitiveUP
. Both are pretty terrible performance wise.
更新为解决方案代码:
m_pDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
m_pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
m_pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_CONSTANT);
m_pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_CONSTANT);
m_pDevice->SetTextureStageState(0, D3DTSS_CONSTANT, D3DCOLOR_ARGB(120,0,255,0));
顶点不需要 FVF_DIFFUSE
。
推荐答案
使用固定函数管道你可以使用 SetTextureStageState
a href =http://msdn.microsoft.com/en-us/library/windows/desktop/bb174462%28v=vs.85%29.aspx =nofollow> doc )指定一个常量颜色,应与 D3DTSS_CONSTANT
( doc )。使用此选项,您可以为整个drawcall设置颜色。
With the fixed function pipeline you could use SetTextureStageState
(doc) to specify a constant color, which should be used with D3DTSS_CONSTANT
(doc). With this option you could set a color for the whole drawcall.
这篇关于如何在另一种颜色的顶点缓冲区中绘制顶点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!