Jump to content

  • Log In with Google      Sign In   
  • Create Account

Vertex Declaration doesn't have corresponding usage


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 Muzzy A   Members   -  Reputation: 642

Like
0Likes
Like

Posted 23 May 2012 - 04:57 AM

I made a sphere with 'D3DXCreateSphere()', pretty simple

I try to draw the sphere with a texture on it, pretty simple
In order to draw a texture you need uv's 'TEXCOORD', a 'float2'

but when i try to draw my simple little sphere it keeps telling me TEXCOORD0 doesn't correspond with the current vertex declaration
which im pretty sure the vertex declaration for these premade meshes is
POSITION
NORMAL
TEXCOORD
COLOR

ive used TEXCOORD0 with a sphere several times and it worked

what could be causing this error, i dont know how long i've been trying to figure this out. Maybe i'm not initializing something write when i initialize D3D?

This is what my code looks like
// HLSL
struct VS_INPUT
{
	float3 untransformed_pos	: POSITION0;
	float2 uv					: TEXCOORD0;
};

// C++
ID3DXMesh *mesh;
IDirect3DTexture9 *texture;
ID3DXEffect *shader;

// Load the spere mesh in, and the texture
D3DXCreateSphere(d3dDevice,.5f,30,30,&mesh,nullptr);
D3DXCreateTextureFromFileA(d3dDevice,"sun.png",&texture);

unsigned passes(0);
shader->Begin(&passes,0);

for(unsigned i = 0;i < passes;++i)
{
	shader->BeginPass(i);
	shader->SetMatrix(gWorldViewProjection,&(Transform*Camera*proj));
	shader->SetTexture(gTexture,texture);
	shader->CommitChanges();

	mesh->DrawSubset(0);

	shader->EndPass();
}

shader->End();

// I don't know what's wrong

Edited by Muzzy A, 23 May 2012 - 04:59 AM.


Sponsor:

#2 jamby   Members   -  Reputation: 147

Like
1Likes
Like

Posted 23 May 2012 - 07:15 AM

I'm not so sure that texture coords are included in the vertices. I just took a look at the D3D10 DXUT code and the vertices only have positions and normals.

#3 NickUdell   Members   -  Reputation: 288

Like
0Likes
Like

Posted 23 May 2012 - 08:01 AM

Maybe it's best to create your own geometry yourself? That way you can be sure of the exact format of your vertices every time.

Also what version of DirectX are you using? It's often best to specify this in the post as implementations can vary wildly between versions. For instance, I'm a DX11 guy, and I know that the vertex format should be set up in the input assembler, which you don't appear to have.

Also if you're expecting Position, Normal, TexCoord and Color, then why are you only accepting position and texcoord in your vertex shader input?
Sole Creator of Pigment - a procedural, block-base space trading sim.

PhD student working on medical imaging at the University of Southampton.

Enjoyer of games, films, books and cider.

#4 mhagain   Crossbones+   -  Reputation: 8000

Like
2Likes
Like

Posted 23 May 2012 - 08:11 AM

Use of IDirect3DTexture9 in the supplied code suggests that the OP is using D3D9. Correct that D3DXCreateSphere will create a sphere without texcoords - that's documented in the SDK:

This function creates a mesh with the D3DXMESH_MANAGED creation option and D3DFVF_XYZ | D3DFVF_NORMAL flexible vertex format (FVF).


The OP is correct that these functions are simple, but they're also quite simplistic and limited too. That's the tradeoff. If you want anything more you have to do a certain amount of setup yourself.

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.


#5 NickUdell   Members   -  Reputation: 288

Like
0Likes
Like

Posted 23 May 2012 - 08:17 AM

Use of IDirect3DTexture9 in the supplied code suggests that the OP is using D3D9. Correct that D3DXCreateSphere will create a sphere without texcoords - that's documented in the SDK:

This function creates a mesh with the D3DXMESH_MANAGED creation option and D3DFVF_XYZ | D3DFVF_NORMAL flexible vertex format (FVF).


The OP is correct that these functions are simple, but they're also quite simplistic and limited too. That's the tradeoff. If you want anything more you have to do a certain amount of setup yourself.


Hadn't spotted the call to DX9, oops! You're right, OP's best bet is to craft his/her own geometry. OP: Wikipedia the formula for a sphere, it's actually fairly easy to make a vertex sphere.
Sole Creator of Pigment - a procedural, block-base space trading sim.

PhD student working on medical imaging at the University of Southampton.

Enjoyer of games, films, books and cider.

#6 Muzzy A   Members   -  Reputation: 642

Like
0Likes
Like

Posted 24 May 2012 - 02:06 AM

wow i could have sworn there was a texcoord in there, im a failure. lol Thanks for the help guys!




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS