Sign in to follow this  

issues with drawing primitive

This topic is 3662 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

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 this post


Link to post
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 this post


Link to post
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

Share this post


Link to post
Share on other sites

This topic is 3662 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