   User Interface with Index Buffers
  HelloI am currently working on a user interface using vertex and index buffers. The idea was that each window will be made of 4 vertices and 6 indices. For each window I''ll be saving 2*CUSTOMVERTEXSIZE which, assuming that the UI will likely have hundreds of windows(widgets) will save a lot of space.However, I am having trouble rendering the individual quads to the screen. My first (root) quad renders correctly but no sub windows. I believe this to be due to my misuse of DrawIndexedPrimitive but I cannot seem to find the correct combination of parameters to solve it.I am creating the root window with vertices at0,0; Width,0; Height,0; Width,Height.This successfully fills the screen. The vertices are stored into vertex index 0,1,2,3; and index buffer indices 0,1,2,3,4,5.I them add a new quad to the vertex buffer into indices 4,5,6,7;and index buffer indices 6,7,8,9,10,11.After those are setup (and I have verified that the values are correct and my buffers have enough memory and are correct AFAIK then I make two calls to DrawIndexedPrimitive like so:lpD3D->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, 4, 0, 2);lpD3D->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 4, 0, 4, 6, 2);I am assuning that parameter 2 is the index of the VERTEX BUFFER that this call will start at. Parameter 4 is the number of vertices in a quad (4), parameter 5 is the start index in the INDEX BUFFER which should increment by 6 for each subsequent call and parameter 6 is the number of triangles in a quad.The first call succeeds but the second call does not show anything.I''ve looked at depth buffers. All vertices have Z value = 1.5 and are pretransformed vertices.I''ve adjusted the Z values accordingly but since I am wanting the second window on top of the first, Z distance shouldn''t be affecting this anyway. I''ve also tried drawing two small 100x100 windows onto the screen in separate places and still only the first one is drawn. Frustrated,Webby 
  Are you taking into account the ordering of vertices in the IB? Maybe you have a culling problem. Mariano RuggieroLead ProgrammerONIRIC GAMES;  if you want to draw stuff on top of other stuff the easiest way to do it is just to turn off the zbuffer and draw back to front. ;  Well I got it to work, though I'm a little annoyed with how it is working.lpD3D->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, 4, 0, 2);lpD3D->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 6, 4, 6, 2);It turns out that the THIRD parameter needs to be the index of the INDEX BUFFER where the object starts and the 5th parameter is ALSO the index of the INDEX BUFFER.The 5th parameter makes complete sense but not the 2nd and 3rd. I have supplied a copy/paste portion of the SDK docs below and added comments to it to clear this up for others. Type[in] Member of the D3DPRIMITIVETYPE enumerated type, describingthe type of primitive to render. D3DPT_POINTLIST is notsupported with this method. See Remarks. BaseVertexIndex[in] Offset from the start of the index buffer to the firstvertex index. /*To draw multiple objects from the same vertexbuffer you can just leave this set to 0 if your buffer is 0based (your vertices start at index 0) */MinIndex[in] Minimum vertex index for vertices used during this call./*This needs to be the index of your INDEX BUFFER where yourobject starts. So for a quad, you will have 6 indices. If thefirst quad starts at index 0, the nxt quad will start at 6. Sofor quads, this number will increment 0,6,12,18,... */NumVertices[in] Number of vertices used during this call, starting from BaseVertexIndex + MinIndex /*This is simply the number of vertices that will be used in this object on this call. So if you aer drawing a quad (whichis made of 2 triangles, using a TRIANGLELIST, then this numberwill be 4 */StartIndex[in] Location in the index array to start reading vertices./* This is the actual index into the INDEX BUFFER where yourobject is to start. AFAICT, this is the same number as MinIndexabove. So for quads, this will increment 0,6,12...etc. */PrimitiveCount[in] Number of primitives to render. The number of verticesused is a function of the primitive count and the primitivetype. The maximum number of primitives allowed is determined bychecking the MaxPrimitiveCount member of the D3DCAPS9 structure./*This one is standard. If you are drawing a quadmade from two triangles using a TRIANGLELIST then set this to 2.If you are drawing a single triangle per call, set this to 3.If you are drawing a terrain with 500 triangles all in one shot, set this to 500 */I hope this helps others as this seems to be a very common question on these forums. And the other posts were correct in that it's never explained very well and the SDK docs appear to be simply incorrect. From the SDK, it would appear that parameter 2 would correspond to the first index of each item and would take the values of 0,6,12,18... for a quad, but this is simply not the case.I stumbled upon the correct combination by simply testing out a few things and FINALLY found one that works...I may still be using the parameters incorrectly but at least the quads are displaying as they should be.Input on this is appreciated, especially if I'm misusing any parameters.Webby   [edited by - websitewill on December 18, 2003 11:01:32 AM];  I ran into this problem just this last weekend.  After searching some, I found a PDF from the Game Developers Conference that has a very nice diagram on this very issue.www.ati.com/developer/gdc/ D3DTutorial0_Intro_And_Features.pdfThe diagram is on page 18. ;  Broke linkWebby ;quote:Original post by WebsiteWill  Broke linkWebby   There''s an extra space in the URL. Remove it and the link will work.Rick 