转到正文

存档

标签: directx

When you build a new DirectX9 or DirectX10 project using Visual Studio2005 or higher verion, you may meet a strange error :

1>DXUTCORE_D_64.lib(DXUT.obj) : error LNK2019: unresolved external symbol __imp_InitCommonControls referenced in function "long __cdecl DXUTInit(bool,bool,wchar_t *,bool)" (?DXUTInit@@YAJ_N0PEA_W0@Z)
1>DXUTCORE_D_64.lib(DXUTmisc.obj) : error LNK2019: unresolved external symbol DXTraceW referenced in function "long __cdecl DXUTTrace(char const *,unsigned long,long,wchar_t const *,bool)" (?DXUTTrace@@YAJPEBDKJPEB_W_N@Z)
1>DXUTOptional_D_64.lib(SDKmisc.obj) : error LNK2001: unresolved external symbol DXTraceW
1>DXUTOptional_D_64.lib(SDKmisc.obj) : error LNK2019: unresolved external symbol D3DXCreateTextureFromFileExW referenced in function "public: long __cdecl CDXUTResourceCache::CreateTextureFromFileEx(struct IDirect3DDevice9 *,wchar_t const *,unsigned int,unsigned int,unsigned int,unsigned long,enum _D3DFORMAT,enum _D3DPOOL,unsigned long,unsigned long,unsigned long,struct _D3DXIMAGE_INFO *,struct tagPALETTEENTRY *,struct IDirect3DTexture9 * *)" (?CreateTextureFromFileEx@CDXUTResourceCache@@QEAAJPEAUIDirect3DDevice9@@PEB_WIIIKW4_D3DFORMAT@@W4_D3DPOOL@@KKKPEAU_D3DXIMAGE_INFO@@PEAUtagPALETTEENTRY@@PEAPEAUIDirect3DTexture9@@@Z)
1>DXUTOptional_D_64.lib(SDKmisc.obj) : error LNK2019: unresolved external symbol D3DX10CreateTextureFromFileW referenced in function "public: long __cdecl CDXUTResourceCache::CreateTextureFromFileEx(struct ID3D10Device *,wchar_t const *,struct D3DX10_IMAGE_LOAD_INFO *,struct ID3DX10ThreadPump *,struct ID3D10ShaderResourceView * *,bool)"
.....

You may think that all your work is pretty good, and you are all right!

It's very obvious that the problem is caused by missing some libraries.( Because error: error LNK2019: unresolved external symbol ) However, You jsut build a new project ,and you link the DXUT library corrrectly, Why Compiler always always have so many complains?  Is it crazy?

继续阅读

It's well known that if you want to create a BMP file, the raw image data memory should be written in the sequence of "BGR"[1], and not the ordinary sequence of "RGB".

So, you may write your code as follows if you want to create a RED pixel:

unsigned char *image = new unsigned char[4];
image[0] = 0;  // Blue
image[1] = 0;  // Green
image[2] = 255;  // Red
image[3] = 255;  // alpha

继续阅读

There is a little differences of Texture Coordinate between OpenGl and DirectX.

In the "OBJ" file, the texture coordinate is the same with OpengGL. You don't have to modify anything in OpengGL when you want to do some texture mapping for "Obj" file. However, if you want to render "Obj" file in DirectX, you have to make some changes for the coordinate of "OBJ" file.

Suppose the texture coordinate in "OBJ" which has been read from is (U1,V1), so the DirectX's texture coordinate should be (U2,V2) = (U1, 1-V1)

Don't forget this simple fact when you want to deal with "OBJ" file using DirectX.

继续阅读

刚拿到DirectX Dec2005 SDK,发现竟然有D3D10的文档和例子,速研究了一下,以下只是个人的读书笔记,仅作参考

  1. 去掉了固定管线
    文档里列出了用DX10特性模拟的一些固定管线的操作,MS那么大度把DX都开源了(^O^)。
  2. 去掉了以前版本DX的设备能力检查(CAPS)
    为DX10和Windows Vista提供的显示硬件必须满足DX10的所有硬件特性。这样对于开发者就比较可以放心的使用各种硬件特性了,很类似Console平台的开发。
  3. 状态对象(State Object)
    "从100多个渲染状态中解脱出来吧!"
    D3D10对渲染状态这个概念进行淡化,一方面使用全Shader化的架构使得状态的前后设置和互相影响对渲染成功率降低到最少
    另外对API架构也更为简洁,另一方面对一些关键渲染状态进行封装和分类。主要分类有:
    Input Layout Object 输入层对象 。这个东西很类似D3D9里的顶点声明,也就是对用户输入数据进行整合和系统化
    Rasterizer Object 光栅化对象。 这部分主要控制光栅器的行为:填充模式(FILL_MODE),剔除模式(CULL_MODE),多采样,DepthBias等等
    DepthStencil Object 深度缓冲对象。 主要控制深度缓冲的行为,像Z-buffer Enable之类的
    Blend Object 混合对象。 设置象素混合的方法,类似AlphaBlend SrcAlpha ,DestAlpha等等
    Sampler Object 采样器对象 。设置纹理采样状态,包括过滤器和MipMap
  4. 继续阅读

You may be very familiar with writing DirectX10 codes at Visual Studio 2005 or 2008. It's very obvious that you should add a .fx rule file (download) for your project. By adding this file, you can compile .fx file independently.

When you run visual studio 2010, it's different from 2008/2005. There is not rule file in VS2010 and it has .target, .props to take place of rule file.

I'll introduce the method how to add .fx file 's "Rule" file in Visual Studio 2010:

  1. first, we should copy three files (.props, .targets, .xml) to your project. (download)
  2. add .target files for your project ( in build Customizations)
    继续阅读

如何处理Dx10 Shader出错:
编译出错:global variables are implicitly constantenable compatibility mode to allow modification

其实是不存在 在shader和外部应用都可写的变量
shader可以写的寄存器只有临时寄存器和输出寄存器,这些寄存器CPU都不能访问;
剩下的寄存器shader都是只读不能写.

Texture对于CPU和GPU来说都可以写,但是不能同时,CPU要写Texture必须Lock,Texture一旦Lock对应的shader就会停掉不会运行.

所以,无论什么类型的变量都需要放到以上类型的寄存器中,所以不存在CPU和GPU可以同时改写的变量类型.

www.liaoqiqi.com网站PR查询 博客简洁版 博客Google_Site_Map 博客Baidu_Site_Map ?