Skip to main content
GameDev.net gamedev.net
🔒 Locked

IndexBuffers and the Texturing problem

Started by Ninja2008 Oct 23, 2008 at 1:07 PM 2 replies 900+ views
Original Post
Ninja2008
Ninja2008
Hi all.. This is my first post here in the forum,and I am very happy to join all the programmers here.. I use DirectX 8.0 with VB6 to design 2D and 3D games...I made a simple demo representing FPS game..but here comes a problem..I use .x files for objects..it works fine but a friend told me to use index buffers for rendering..I searched and could implement that but the problem is if the mesh has more than one texture I will not be able to put all of them I just can put one only.. Mr.Jack Hoxley in his very good lessons in Directx4VB said that yes there is this problem and can be avoided by using multi-stage texturing and some other techniques,he did not explain how that happens,so is there someone here can help me.. in the loading of the mesh I get the vertex and index buffers like this: Set vertexBuffer = Mesh.GetVertexBuffer vertexBuffer.GetDesc vertexBufferDesc Set indexBuffer = Mesh.GetIndexBuffer indexBuffer.GetDesc indexBufferDesc then in the rendering section I use: Sub renderVI() Dim n As Integer n = 32 D3DDevice.SetMaterial MeshMaterials(0) D3DDevice.SetTexture 0, MeshTextures(1) D3DDevice.SetStreamSource 0, vertexBuffer, n D3DDevice.SetIndices indexBuffer, 0 D3DDevice.DrawIndexedPrimitive D3DPT_TRIANGLELIST, 0, Mesh.GetNumVertices, 0, Mesh.GetNumFaces End Sub notice that the MeshMaterials() and MeshTextures() are the materials and textures extracted in a previous step and I chose the index 0 and 1 respectively to have something as texture,now you understand what my problem is ,how can I put more than one texture on a mesh created by index buffer? Thanks..
Ninja2008
Ninja2008
Hey guys can anyone answer my above question,I posted it yesterday and today I saw my post becomes in the second page so that no one will answer me..

Please I really need those info about index buffers and texturing,and this forum seems the only source for the answers..

Thanks..
mickeyren
mickeyren
You can set multiple textures at a time by calling SetTexture(...). The first parameter sets the index texture, so if you like to use 2 textures and blend them together you would call SetTexture( 0, ...) and SetTexture( 1, ... ) to apply 2 textures to the vertex buffer.

Do note that the texture applies to the vertex buffer and not the index buffer, as the index buffer are just indices to the actual vertices to reduce the number of vertices for performance gains.

Hope that helps.
Ninja2008
Ninja2008
Thank you mickeyren,but it didn't work as I wished,I think I will use the inedxbuffer method to render objects with single texture only..

Thanks..

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.