DX SetFVF
自由顶点格式(flexible vertex format,FVF)
http://www.cnblogs.com/xmzyl/articles/1604096.html
if( SUCCEEDED( g_pd3dDevice->BeginScene() ) )
{
// Draw the triangles in the vertex buffer. This is broken into a few
// steps. We are passing the Vertices down a "stream", so first we need
// to specify the source of that stream, which is our vertex buffer. Then
// we need to let D3D know what vertex shader to use. Full, custom vertex
// shaders are an advanced topic, but in most cases the vertex shader is
// just the FVF, so that D3D knows what type of Vertices we are dealing
// with. Finally, we call DrawPrimitive() which does the actual rendering
// of our geometry (in this case, just one triangle).
g_pd3dDevice->SetStreamSource( 0, g_pVB, 0, sizeof( CUSTOMVERTEX ) );
g_pd3dDevice->SetFVF( D3DFVF_CUSTOMVERTEX );
g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, 1 );
// End the scene
g_pd3dDevice->EndScene();
}
通过setFVF 按照我的理解 就是告诉shader 他要处理的vertices里面的格式
注释那段话已经说的很详细了 我们自己定义vertex buffer里的结构类型 ,比如D3DFVF_XYZ,D3DFVF_NORMAL,D3DFVF_TEX0.....
很眼熟吧,你规定的这些是可以在shader中使用的。
------------------------------------------------------------------------------
因为很多链接会失效,我还是把那段抄过来吧 ,有关fvf的使用步骤
struct CustomerVertex
{
FLOAT x,y,z,rhw;
DWORD color;
};
#define D3DFVF_CUSTOMVERTEX(D3DFVF_XYZRHW|D3DFVF_DIFFUSE)
g_pd3dDevice->CreateVertexBuffer(3*sizeof(CUSTOMVERTEX),
0,
D3DFVF_CUSTOMVERTEX,
D3DPOOL_DEFAULT,
&g_pVB, NULL )
CUSTOMVERTEX vertices[] =
{
{ 100.0f, 400.0f, 0.5f, 1.0f, 0xffff0000, },
{ 300.0f, 50.0f, 0.5f, 1.0f, 0xff00ff00, },
{ 500.0f, 400.0f, 0.5f, 1.0f, 0xff0000ff, },
};
然后将数据写入缓冲区:
VOID* pVertices;
if( FAILED( g_pVB->Lock( 0, sizeof(vertices), (void**)&pVertices, 0 ) ) )
return E_FAIL;
memcpy( pVertices, vertices, sizeof(vertices) );
g_pVB->Unlock();
这里写入的过程用的是Lock函数得到的缓冲区的地址,然后用memcpy函数将自己写好的数据写进去。到这里,顶点就算是创建好了。
DX SetFVF的更多相关文章
- 计算ffff:0~ffff:b数据的和,结果存在dx中
代码: assume cs:sad sad segment start: mov ax, 0ffffh mov ds, ax mov dx, ; add ds:0bh~ds:1h mov cx, 0b ...
- 桌面 透明 三角形 分层窗口 DX
//桌面 透明 三角形 分层窗口 DX //IDirect3DSurface9 GetDC UpdateLayeredWindow #include <Windows.h> #includ ...
- DEV中dx:ASPxPopupControl 控件的使用(在窗口关闭或隐藏时,清楚文本框中的内容)
//在窗口关闭或隐藏时,清楚文本框中的内容(核心代码) function(s, e) { ASPxClientEdit.ClearGroup('entryGroup'); } <asp:Cont ...
- Dx unsupported class file version 52.0
最近用ADT时遇到这个bug,折腾了好几天. 报错信息: Dx unsupported class file version 52.0 Conversion to Dalvik format fail ...
- Devexpress GridView内嵌dx:ASPxGridLookup取得控件值乱跳解决方案
一 页面嵌入ASPxGridLookup控件 <dx:ASPxGridView ID="gridDetail" runat="server" ...
- [Zz] DX depth buffer
声明:本文完全翻译自DX SDK Documentation depth buffer,通常被称为z-buffer或者w-buffer,是设备的一个属性,用来存储深度信息,被D3D使用.当D3D渲染一 ...
- dx wpf的各种坑
这篇随笔总结dx wpf使用中的各种坑,持续更新~ LookUpEdit里内嵌的DXGrid的名字必须是"PART_GridControl",不能不写.也不能写错.我对比了2个小时 ...
- Android java.lang.UnsupportedClassVersionError: com/android/dx/command/Main : Unsupported major.minor ver
java.lang.UnsupportedClassVersionError: com/android/dx/command/Main : Unsupported major.minor ver 解决 ...
- DX 的.x 文件
template Header { <3D82AB43-62DA-11cf-AB39-0020AF71E433> WORD major; WORD minor; DWORD flags;} ...
随机推荐
- Apache windows多线程设置
# WinNT MPM # ThreadsPerChild: constant number of worker threads in the server process # MaxRequests ...
- 2015-0306—DataLList
DataList具有repeater的所有功能,不同的是DataList自动将模板绘制成为一个表格,每一行数据都绘制成<tr>. 一.SQL的准备工作: 按照以下代码创建: create ...
- 初识sass
大图:http://images2015.cnblogs.com/blog/730765/201605/730765-20160529113743209-72994369.png
- 《JavaScript高级程序设计》心得笔记-----第四篇章
第十六章 1. 跨文档消息传送: postMessage("消息", "发送消息的文档所在域") 2. 拖放事件: 1) 拖动某元素会依次触发:drag ...
- [Apache Maven Shade Plugin] [example] [001] 官方例子:includes-excludes
链接地址:[Selecting Contents for Uber JAR](http://maven.apache.org/plugins/maven-shade-plugin/examples/i ...
- POJ1056 IMMEDIATE DECODABILITY【数据结构】
题目地址:http://poj.org/problem?id=1056 Description An encoding of a set of symbols is said to be immedi ...
- Linux 下安装服务器安全狗
1.网上下载服务器安全狗的软件包 32位和64位 wget http://www.safedog.cn/server_safedog_linux.html/safedog_linux32.tar ...
- silverlight 文本框只能输入数字
void mobile_KeyUp(object sender, KeyEventArgs e) { Regex rg = new Regex("^[0-9]{1,11}$"); ...
- linux命令详解之useradd命令
useradd命令使用方法,还包括用户账号的添加.删除与修改.用户口令的管理.用户组的管理方法. Linux系统是一个多用户多任务的分时操作系统,任何一个要使用系统资源的用户,都必须首先向系统管理员申 ...
- 通信录分组并且分组标签悬停划入划出(包含错误信息及修改)--第三方开源--PinnedSectionListView
PinnedSectionListView在github上的链接地址是:https://github.com/beworker/pinned-section-listview . 下载下来后直接将Pi ...