# issues with drawing primitive

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

## Recommended Posts

ok so im attempting to use a vertex buffer and the draw primitive funtion to create a simple square plane the has a texture repeating in it. I know this can be done easily by drawing one large 4 vertice triangle strip and set it to repeat the texture. but what if i wanted to draw each texture block seperately? when i try this nothing shows up? I have a loop set to create 1.0f x 1.0f blocks in a square, so right now i increase a counter and then translate to the counter and call draw primitive again. any thoughts? here is what i am attempting.. static float iposx = 32.0f; static float iposz = 32.0f; while(iposz >= 0.0f) { while(iposx >= 0.0f) { D3DXMatrixTranslation(&matTranslate, iposx, 0.0f, iposz); d3ddev->SetTransform(D3DTS_WORLD, &(matTranslate)); // set the world transform // set the texture d3ddev->SetTexture(0, texture_1); // draw the textured cube d3ddev->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2); iposx -= 1.0f; } iposz -= 1.0f; } the field is on the x and z axis so the camera is up the y axis looking down on it. and my vertices are defined as this... CUSTOMVERTEX t_vert[] = { // floor { 32.0f, 0.0f, 0.0f, 0, 1, 0, 1, 0, }, { 0.0f, 0.0f, 0.0f, 0, 1, 0, 0, 0, }, { 32.0f, 0.0f, 32.0f, 0, 1, 0, 1, 1, }, { 0.0f, 0.0f, 32.0f, 0, 1, 0, 0, 1, }, };

##### Share on other sites
Have you got the quad(s) visible before? If not, there's all sorts of things that could be wrong. Assuming you have:

Your vertex buffer looks a bit odd - check the vertices are specified in the correct order (Easiest way is to call d3ddev->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE); and see if that fixes it - if it does, then your vertices are in the wrong order (Counter clockwise instead of clockwise).

As for using one quad, you can just use 4 vertices with texture coordinates of 0..X instead of 0..1, where X is the number of times you want to repeat the texture on the quad.

##### Share on other sites
i believe my vertices are in correct order, when i draw just one single one with the same vertices it will draw the two triangle (one square)

##### Share on other sites
ok i fixed my problem, i changed the while loop to for loops that work off of ints instead of the float values, and reset iposx and the x counter every time the z decrements. Thanks for your time.

daedric

1. 1
Rutin
31
2. 2
3. 3
4. 4
5. 5

• 13
• 17
• 11
• 10
• 14
• ### Forum Statistics

• Total Topics
632962
• Total Posts
3009506
• ### Who's Online (See full list)

There are no registered users currently online

×