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?