Sign in to follow this  
perkbrian

Wierd D3DERR_INVALIDCALL

Recommended Posts

perkbrian    122
im attempting to use ODE physics, and i have a demo that lets you put cubes on screen and they are affected by physics, so im attempting to add the EXACT same thing into my program, but i get a D3DERR_INVALIDCALL whenever i try to render a plane (Mesh.Box) in exactly the same way that the writer of the demo app did... heres the code...
public void RenderPlane(ModelViewerCamera camera)
{
  //Setting up the matrices
  Matrix worldViewProj = Matrix.Translation(0.0f, -11.0f, 0.0f) *  camera.ViewMatrix * camera.ProjectionMatrix;
  
  //Set variables for the effect
  //Set the technique
  diffuseEffect.Technique = "diffuse";

  //Set the textures
  diffuseEffect.SetValue("hasTexture", false);

  //Set the matrices
  diffuseEffect.SetValue("worldViewProjection", worldViewProj);

  //Render the plane
  diffuseEffect.Begin(0);
  diffuseEffect.BeginPass(0);
  plane.DrawSubset(0);
  diffuseEffect.EndPass();
  diffuseEffect.End();
}


and heres the shader im using
//-----------------------------------------------------------------------------
// Title : Simple Diffuse
// Author: Pieter Germishuys
//-----------------------------------------------------------------------------

//--------------------------------------------------------------------------------------
// Global variables
//--------------------------------------------------------------------------------------
float4x4 worldViewProjection;
bool hasTexture;

//--------------------------------------------------------------------------------------
// Textures and Samplers
//--------------------------------------------------------------------------------------
texture texture0;
sampler2D texSampler0 : TEXUNIT0 = sampler_state
{
	Texture	  = (texture0);
    MIPFILTER = LINEAR;
    MAGFILTER = LINEAR;
    MINFILTER = LINEAR;
};
 
//--------------------------------------------------------------------------------------
// Structures
//--------------------------------------------------------------------------------------
//Application to Vertex Shader
struct a2v
{ 
    float4 position   : POSITION0;
    float2 texCoord	  : TEXCOORD0;
};
 
//--------------------------------------------------------------------------------------
// Vertex Shader to Pixel Shader
//--------------------------------------------------------------------------------------
struct v2p
{
    float4 position	  : POSITION0;
    float2 texCoord	  : TEXCOORD0;
};

//--------------------------------------------------------------------------------------
// Pixel Shader to Screen
//--------------------------------------------------------------------------------------
struct p2f
{
    float4 color	  : COLOR0;
};
 
//--------------------------------------------------------------------------------------
// Vertex Shader
//--------------------------------------------------------------------------------------
void VertexShader( in a2v IN, out v2p OUT ) 
{
    //getting to position to object space
    OUT.position = mul(IN.position, worldViewProjection);
    OUT.texCoord = IN.texCoord;
}

void PixelShader( in v2p IN, out p2f OUT)
{
	if(hasTexture)
		OUT.color = tex2D(texSampler0, IN.texCoord);
	else
		OUT.color = float4(0.4f, 0.4f, 0.4f, 1.0f);
}

//--------------------------------------------------------------------------------------
// Techniques
//--------------------------------------------------------------------------------------
technique diffuse
{
    pass p0
    {
        vertexshader = compile vs_1_1 VertexShader();
        pixelshader = compile ps_1_1 PixelShader();
    }
}

note that if i take out the diffuseEffect.Begin(0); and diffuseEffect.BeginPass(0); and diffuseEffect.EndPass(); diffuseEffect.End(); i dont get the error.. also, the error occurs on the plane.DrawSubset(0); almost exactly the smae code works fine for meshes loaded from file(all that is changed is the texture) and no error shows up... anyone know what might be causing this?

Share this post


Link to post
Share on other sites
sirob    1181
Could be lots of things. I gather you're using MDX?

I'll make a guess at one thing:
If you're using the Dec. SDK or any later SDK, PS1.1 is no longer supported by the HLSL compiler. Try using PS2.0.

If that isn't it, try the debug runtimes to check for any error messages.

Share this post


Link to post
Share on other sites
perkbrian    122
the thing that i find wierd is that the EXACT same cde works in one project but not in another...

same references, and yes Managed DirectX,

Here is the Sample... which works

and what exactly are the "debug runtimes" / how do i use them?

Share this post


Link to post
Share on other sites
perkbrian    122

Direct3D9: (ERROR) :Vertex shader function usage (D3DDECLUSAGE_TEXCOORD, 0) does not have corresponding usage in the current vertex declaration

Direct3D9: (INFO) :The vertex declaration is (Stream, Offset, Type, Method, Usage, UsageIndex):

Direct3D9: (INFO) :0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0

Direct3D9: (INFO) :0, 12, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0

First-chance exception at 0x7c812a5b in Demo.exe: Microsoft C++ exception: long at memory location 0x0012e39c..
Direct3D9: (ERROR) :DrawIndexedPrimitive failed.

A first chance exception of type 'Microsoft.DirectX.Direct3D.Direct3DXException' occurred in Microsoft.DirectX.Direct3DX.dll




that is what i get, but i have no clue what it means

Share this post


Link to post
Share on other sites

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