Sign in to follow this  

IndexBuffers and the Texturing problem

This topic is 3338 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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..

Share this post


Link to post
Share on other sites
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..

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

This topic is 3338 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this