Jump to content
  • Advertisement
Sign in to follow this  
Calneon

Bizarre graphical anomalies, please help!

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

I'm learning DX10, and following a series of great tutorials on Bobby Anguelov's blog. Been going fine until I wanted to apply textures to the meshes I made by following his tutorial. You can recreate the exact thing I get by downloading the tutorial here (http://takinginitiative.net/2009/02/24/directx-10-tutorial-5-basic-meshes/), and adding any variable to the vertex structure in "vertexTypes.h". For example, edit the file so it says;

D3DXVECTOR3 pos;
D3DXVECTOR4 color;
D3DXVECTOR2 texCoord;

and then compile and run it. You will see some very strange graphical glitches and I have no idea why or how to fix it. Can anyone help? Thanks.

If you don't want to load up the project, this is what you see: http://imgur.com/W4Qbj.png

It's meant to be a cube.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
adding any variable to the vertex structure in "vertexTypes.h". For example, edit the file so it says;

D3DXVECTOR3 pos;
D3DXVECTOR4 color;
D3DXVECTOR2 texCoord;


Did you modify the input declaration to handle color and/or texture coordinates?

Share this post


Link to post
Share on other sites
Quote:
Original post by 16bit_port
Quote:
adding any variable to the vertex structure in "vertexTypes.h". For example, edit the file so it says;

D3DXVECTOR3 pos;
D3DXVECTOR4 color;
D3DXVECTOR2 texCoord;


Did you modify the input declaration to handle color and/or texture coordinates?

No, I added the variable that's it. Not declaring it or using it anywhere. I have tried modifying the rest of the code to enable textures but get the same thing. I managed to remove code step by step and found that adding this variable caused the problem.

It's multiple cubes yes, sorry. Rotating.

Share this post


Link to post
Share on other sites
You definitely need to modify the stride when setting the vertex buffer, as each vertex is larger if you add something to the structure, and in order to use the new parameter you need to modify the vertex declaration and the vertex shader input structure.

Share this post


Link to post
Share on other sites
Quote:
Original post by Erik Rufelt
You definitely need to modify the stride when setting the vertex buffer, as each vertex is larger if you add something to the structure, and in order to use the new parameter you need to modify the vertex declaration and the vertex shader input structure.

I don't know what the stride is, and I'm not using a vertex buffer. What you're saying makes sense, but I'm not sure what to do.

Share this post


Link to post
Share on other sites
Quote:
Original post by Calneon
Quote:
Original post by Erik Rufelt
You definitely need to modify the stride when setting the vertex buffer, as each vertex is larger if you add something to the structure, and in order to use the new parameter you need to modify the vertex declaration and the vertex shader input structure.

I don't know what the stride is, and I'm not using a vertex buffer. What you're saying makes sense, but I'm not sure what to do.


Stride is the size of the vertex struct.
Not just stride, you may have to change some other numbers related to the Vertex structure's size as well. But as I recall, that tutorial series uses sizeof() operator, so it is not needed to change anything in side C++ code. What I doubt here is that you have to change your vertex shader input to match that structure.

Share this post


Link to post
Share on other sites
Quote:
Original post by Calneon
I don't know what the stride is, and I'm not using a vertex buffer. What you're saying makes sense, but I'm not sure what to do.


In your case the vertex buffer is inside the ID3DX10Mesh. In order to make it work, you must add the texcoord to the input-layout as well as to the vertex, as for example "TEXCOORD", 0, DXGI_FORMAT_R32G32, 0, 28, PER_VERTEX, 0. Then you need to change the creation of the input-layout to match this by setting the element count to 3 instead of 2, for D3DX10CreateMesh and CreateInputLayout, and you must also modify the effect so that the vertex shader input contains a float2 texcoord : TEXCOORD.

Share this post


Link to post
Share on other sites
Quote:
Original post by Calneon
I'm learning DX10, and following a series of great tutorials on Bobby Anguelov's blog. Been going fine until I wanted to apply textures to the meshes I made by following his tutorial. You can recreate the exact thing I get by downloading the tutorial here (http://takinginitiative.net/2009/02/24/directx-10-tutorial-5-basic-meshes/), and adding any variable to the vertex structure in "vertexTypes.h". For example, edit the file so it says;

D3DXVECTOR3 pos;
D3DXVECTOR4 color;
D3DXVECTOR2 texCoord;

and then compile and run it. You will see some very strange graphical glitches and I have no idea why or how to fix it. Can anyone help? Thanks.

If you don't want to load up the project, this is what you see: http://imgur.com/W4Qbj.png

It's meant to be a cube.


well,the solution is simple,just turn on z-buffer:
d3dpp.EnableAutoDepthStencil=TRUE;
d3dpp.AutoDepthStencilFormat=D3DFMT_D16;//D16 standard
d3ddev->SetRenderState( D3DRS_ZENABLE, D3DZB_TRUE );

and when render():
d3ddev->Clear(0, 0, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, RGB(255, 255, 255), 1.0f, 0L);

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!