posts - 25,  comments - 21,  trackbacks - 0
这样的错误,怎么找呢,
就是在每个opengl调用后面加glGetError(),看看错误在哪行之后有提示。
我这个问题最后是嵌入式设备,索引不支持32位。
re: 用cocos2dx来渲染3d场景 Sherk 2014-07-17 15:06
The topics covered in the first half of this primer still exist and are relevant to OpenGL ES 2.0 however anything that can now be produced using the programmable pipeline has had its fixed functionality removed. Capabilities such as matrix operations, the lighting system and fog no longer exist in OpenGL ES 2.0 since they can easily be reproduced by the programmer if required and since they are no longer fixed can be customized in ways that were simply not possible with OpenGL ES 1.1.

OPEN gl es 2.0全部用shader了,fog需要自己计算。麻烦
re: 用cocos2dx来渲染3d场景 Sherk 2014-07-07 14:50
glGenBuffers — generate buffer object names
glBindBuffer — bind a named buffer object
glBufferData — create and initialize a buffer object's data store

创建vbo对象名字,绑定,上传,3步走。
re: 用cocos2dx来渲染3d场景 Sherk 2014-07-07 10:39
openGL使用右手坐标

从左到右,x递增
从下到上,y递增
从远到近,z递增
F,,,,头晕,dx的matrix存储上讲是row-major矩阵,但其数学意义上讲是column-major矩阵,所以如果你使用d3dx的矩阵算法得到一个矩阵,然后通过接口ID3DXConstantTable::SetMatrix将其upload进去,默认shader code也是column-major方式,所以底层驱动会将内存布局为row-major的d3dx逐列取出,一列存放到一个register中。
另外可能有些新人问,为啥变换坐标时w时1.0,变换方向变量时w使用0.0f,这个其实你只有自己手工做个矩阵计算就很容易明白,当w时1.0f时,变换时乘的时候保留了矩阵最后一行的tanslation,而0.0时translation就清零了。
如果懒得深究,记住结论就是:
Summary
In summary, pixels and texels are actually points, not solid blocks. Screen space originates at the top-left pixel, but texture coordinates originate at the top-left corner of the texture's grid. Most importantly, remember to subtract 0.5 units from the x and y components of your vertex positions when working in transformed screen space in order to correctly align texels with pixels.
D3DVERTEXELEMENT9 decl[] =
{
{0 ,0 ,D3DDECLTYPE_SHORT4N ,D3DDECLMETHOD_DEFAULT ,D3DDECLUSAGE_POSITION ,0},
{0 ,8 ,D3DDECLTYPE_UBYTE4 ,D3DDECLMETHOD_DEFAULT ,D3DDECLUSAGE_BLENDINDICES ,0},
{0 ,12 ,D3DDECLTYPE_UBYTE4N ,D3DDECLMETHOD_DEFAULT ,D3DDECLUSAGE_BLENDWEIGHT ,0},
{0 ,16 ,D3DDECLTYPE_UBYTE4N ,D3DDECLMETHOD_DEFAULT ,D3DDECLUSAGE_NORMAL ,0},
{0 ,20 ,D3DDECLTYPE_UBYTE4N ,D3DDECLMETHOD_DEFAULT ,D3DDECLUSAGE_TANGENT ,0},
{0 ,24 ,D3DDECLTYPE_FLOAT16_2 ,D3DDECLMETHOD_DEFAULT ,D3DDECLUSAGE_TEXCOORD ,0},
{0 ,12 ,D3DDECLTYPE_FLOAT16_2 ,D3DDECLMETHOD_DEFAULT ,D3DDECLUSAGE_TEXCOORD ,1},
D3DDECL_END()
};


vs_3_0
def c10, 3, 1, 2, -1
dcl_position v0
dcl_normal v1
dcl_tangent v2
dcl_blendindices v3
dcl_texcoord v4
dcl_position o0
dcl_texcoord o1
dcl_texcoord1 o2.xyz
dcl_texcoord2 o3.xy
dcl_texcoord3 o4.xyz
dcl_texcoord4 o5.xyz
dcl_texcoord5 o6.xyz
如果这个样子,实际又是什么意思呢?
其实输入流这个vertex buffer中具有7个members,而vertex shader只使用了其中5个members,其中blendweight和texcoord1被vs忽略掉。简单吧。
At draw time, Direct3D looks for the same "usage - usage index" combination in the current vertex declaration and the current vertex shader function. When the combination is found, the register from shader function DCL is used as the destination for the vertex element.
When a vertex element in the current vertex declaration has a usage which is not found in the current vertex shader, that vertex element is ignored.
When using a vertex shaders version less than 2.0, all semantics mentioned in the shader code need to be present in the declaration bound at draw time. When using vertex shaders 2.0 and above, this restriction that allows applications to use different vertex declarations with the same vertex shader does not exist. This is useful when a vertex shader reads input data based on static conditions. Vertex shader registers not initialized because of this will have undefined values.
终于可以贴个图了,现在引擎已经完成碰撞检测、室内室外渲染(室内室外过渡还有点问题)、多线程加载、人物换装等。。。
<2009年2月>
25262728293031
1234567
891011121314
15161718192021
22232425262728
1234567

常用链接

留言簿(3)

随笔档案

相册

好友

搜索

  •  

最新评论

阅读排行榜

评论排行榜