I’d really recommend staying away from DirectPlay. It’s not been updated in ages, provides very little advantage over plain Windows Sockets, is a pain to set up, and isn’t at all portable.
Pure Devices
DirectX 8.0 introduces the concept of a “pure” device. When using a pure device the runtime does not track state or state blocks or perform any software vertex processing on behalf of the hardware. Furthermore, the application cannot query back state from the runtime. The lack of state tracking, particularly when state blocks are being used, can result in a significant performance boost for the application.
Only vertex processing directly supported by the hardware is available to the application when using a pure device. For example, for cards that do not support hardware transform and lighting, only pretransformed vertices can be passed to Direct3D. Furthermore, the API functions SetClipStatus, GetClipStatus and ProcessVertices cannot be used with the pure device.
In order to use a pure device the application must request it with the device creation flag D3DCREATE_PUREDEVICE and the driver must report its ability to act as a pure device.
if(FAILED(CoInitialize(NULL))) return false;
CoInitialize() return value:
S_OK
The COM library was initialized successfully on this thread.
S_FALSE
The COM library is already initialized on this thread.
so, we should use
if(S_FALSE == CoInitialize(NULL) ) return false;
返回E_FAIL,是告诉调用程序--某些地方出错,必须进行处理。否则,程序不能进行下去了。
而返回S_FALSE,不是表示出现错误, 而是一种返回值。\
S_OK和S_FALSE,就是程序返回值的不同表示。如果将它们表示成S_1和S_2可能更好理解些!
调用程序只需对返回的S_OK和S_FALSE进行判断,然后决定程序的走向。
最主要的误解是由S_FALSE的名称带来的。
关键--S_FALSE不是错误,是返回值。
当出现播放音乐不能播放的时候,可能是因为初始化音乐后立刻播放,影响了正常播放具体原因哥也不知道
Device->SetRenderState( D3DRS_SHADEMODE, D3DSHADE_GOURAUD );
You have to turn off the light, i.e.
Device->SetRenderState( D3DRS_LIGHTING, false );
将坐标移到坐标原点
float dx = x - col;
float dz = z - row;\
(x,z)相对于(col,row)的坐标,即(x-col,z-row),即(col,row)在坐标原点,(dx,dz)为变换后的坐标.
Single view:[ebp + (edx - 1)*1]:寄存器减1后还要与其他的相乘的话就必须得先暂存edx-1的结果,所以是错的
缺省实参只在单个文件有效,因为实参是在编译时刻提取出来,而不同文件在在链接时刻,即runtime.
CBoneMesh *boneMesh = new CBoneMesh;
memset( boneMesh, 0, sizeof(CBoneMesh) );
// 不能将CBoneMesh替换为boneMesh,因boneMesh为指针.
耗费两天
void *pDest = NULL;
hr = pExXMeshContainer->_pXMeshSkin->LockVertexBuffer(
0, reinterpret_cast<void **>(&pDest) );
&pDest漏了pDest,于是,每次lock的时候都直接崩溃,弄得我都快崩溃了.
静态链接库中尽量避免定义静态成员
两个类,其中一个类想要另外一个类的内容,可以定义那个类的引用.
My guess:像D3DXVec3Transform、D3DXVec3TransformCoord等之类的旋转某个点的,其实都是绕着通过原点的轴旋转的.
My guess:SetRenderState你设置了并不代表会立刻执行,这只是通知一下等下应该以这样的状态执行而已.
VertexShader = compile vs_1_1 Main();\
这大小写不敏感的丫,vertexshader也可以,VertexShader也可以,我勒个去.(貌似就这个大小写不敏感)
CTTransform->SetMatrix( Device, HWorldViewProj, &(MatObjWorld*MatView*MatProj) );
是MatObjWorld * MatView * MatProj而不是MatView * MatProj * MatObjWorld,那是因为MatObjWorld在world space,然后变换至view space,然后进行投影,所以可以正常使用,反过来就不行了.
CTTransform->SetDefaults( Device );
// .fx:
vector Blue = {0.0f, 0.0f, 1.0f, 1.0f};
若是CTTransform->SetDefaults( Device );不设置的话,则Blue就不会自动赋值.
调试的时候语句是正常的,但是调试的时候却跳过了如此正常的语句,那是因为修改了代码,由于某种原因,编译器没有识别出来,所以必须重建工程,重新导入源文件编译才可以.
eg:
按一下F10后
直接跳过了
这两个变量的定义
My guess: void fun( int *&a );\
a本质上还是指针的指针,*&a只是让它增加可读性而已,仅此而已,从本质上并不能称作引用.
.hpp文件定义模板:\ 定义template<class T>竟然不行(error C2061: 语法错误: 标识符“c1ass”),得换成template<typename T>
引用未初始化的指针变量:
eg:
stNode *head;
head = Create(head, arr, C_SIZE );
必须改为
stNode *head = NULL;
head = Create(head, arr, C_SIZE );
warning C4700: 使用了未初始化的局部变量“head”
** memset对指针的指针置数注意**
<和>比较的操作数顺序问题
eg:
if( min > a ) min = a;
对于比较操作符,需要修改的放在左边.
delete指针的指针
eg:
// int **D;
for( int i = 0; i < n; i++ )
delete []*(D + i); // not delete ;
delete []D;
subclass
eg:
create A, by subclassing B.
class A: public B{};
(++a)+=3;
C++中,++a的结果是左值,返回给值本身,也就是说上面合法
四舍五入
inline
int round( double number ){ return static_cast<int>( floor(number + 0.5) );}
引用注意点
程序一直不退出
析构函数无法正常退出,比如死循环.
私有继承
vector在类构造函数中初始化的问题
运算开销
大多数运算开销需要约 10ns,而取模运算接近100ns.<<编程珠玑9.2>>
itoa小技巧
p = “0123456789abcdef”[2%16];
(1) C++ 11中似乎支持如下语法
(2)加上static
(3)用vector来代替
picking\
picking操作的时候,出了问题,无法正确获取射线与平面y=0的交点,原来是我设置
Device->SetTranform( D3DTS_VIEW, &(view*proj) );
这应该换为
Device->SetTransform( D3DTS_VIEW, &view );
Device->SetTransform( D3DTS_PROJECTION, &proj );
头文件中声明同时定义函数
必须加上inline,这并不是成员函数,成员函数倒是可以不加.\
inline D3DXMATRIX MatOfIdentity(){ D3DXMATRIX identity; return *D3DXMatrixIdentity(&identity); }
否则会显示[已在 Utility.obj 中定义;已忽略第二个定义]之类的信息.
strlen( NULL )果然崩溃
cout << pNode -> _data << endl;毫无问题,原来空格不要紧.
15升的水杯和27升的水杯,装入容器中,能准确量出多少L的水.\
比如这个问题的话,很容易知道,通过不断的加减法运算量出不同L的水,但是会发现一个规律,15L和27L水加减法运算总是可以提取公因子的3*(5和9),所以最后量出来的水肯定是3的倍数.
若从programming pipeline转为fixed
pipeline,无法正常显示,则可能是projection,view未设置.
eg:
Device->SetTransform( D3DTS_PROJECTION, &ProjMatrix );
Device->SetTransform( D3DTS_VIEW, &view );
pow(f, e) will not work for negative f
就算加条件判断也无法阻止pow报错
改成
cmd命令
\>cd android-sdk-window
\android-sdk-windows>
.m和.mm文件
.m文件是object-c文件
.mm文件相当于c++或者c文件
DLL全局指针分配内存释放后要将指针设为NULL
cmd命令\
rename E:\Workspaces\syjt\trunk\project\android\obj\local\armeabi\libsyjt.so a.so // 将libsyjt.so文件重命名为a.so
RenderMonkey:
My guess:RenderMonkey1.82上当你定义一个mat4x4 color_filter.
在pixel shader中这样写的时候
float4 col = tex2D(Texture0, texCoord);
return mul(color_filter,col);
按理来说颜色是会变成红色的,但是却没有变,而shaders for game programmers and artists中却能正常变红色.我勒个去,如果转置一下就可以正常显示了.(只要替换成mul(col,color_filter)即可,直接想象成rendermonkey会自动换成color_filter*col,不然在DirectX环境下它就会先实行转置,然后再color_filter*col,在DirectX下直接mul(col,color_filter)这样就相当于让DirectX不会自动去转置了,rendermonkey便执行正确).
vertex shader的输入参数设置为vs_main( float4 pos : POSITION,
float2 tex : TEXCOORD ){}
则相应的Stream Mapping也应作相应设置。
printf打印十六进制
%08x表示打印8位十六进制数,不足8位则在前面补0
内存对齐More