XNA Creators Club Online
Page 1 of 1 (2 items)
Sort Posts: Previous Next

System.InvalidOperationException when running on xbox 360

Last post 12/3/2008 10:37 AM by Dark Tetsuo. 1 replies.
  • 12/3/2008 8:27 AM

    System.InvalidOperationException when running on xbox 360

    Hey everybody,

    After spending a lot of time expanding my own small engine under windows, i started deploying to xbox again yesterday. But when I finished deploying the project and started a debug run, i got an System.InvalidOperationException telling me that i need to set a valid pixel and vertex shader on the device. This was very weird, because the code runs perfectly on the windows platform.

    First i thought it was the .fx file not being compatible with xbox 360, but after trying to use different shaders (ones i used on xbox before and very simple ones) I kinda came to the conclusion this is not the problem. I have a materialsystem loading a material for every model from an XML (this includes the effectfile, parameters and values). This Material is then used to set all of the shaders parameters. After this, we draw the model with its effect contained by its material.

    The drawcall is handled by a scenegraph which just passes on the draw(graphicsdevice device) towards a modelclass.

    I know the Xbox 360 is a little more specific when it comes to D3D debug stuff. I am able to see my device while debugging, but just like the exception tells me, it can not validate the pixelshader and vertexshader properties after i've called the Begin on the effect and pass. So i kinda guess the myEffect.Begin() and Pass.Begin() aren't working as they should, and because of this the graphics device doesn't get a working pixel and vertex shader.

    The final drawing code in the modelclass: (the error finally occures when myDevice.DrawIndexedPrimitives(...) is called)




            public void RenderChildren(GraphicsDevice myDevice) 
            { 
                // We start by grabbing the current shader from the Material and 
                // setting up the parameters for the current MeshPart 
     
                myMaterial.SetTechnique(); 
                myMaterial.SetParameters(this); 
     
                foreach (ModelMesh mesh in myModel.Meshes) 
                { 
                     
                    myMaterial.MyEffect.Begin(); 
                    foreach (EffectPass pass in myMaterial.MyEffect.CurrentTechnique.Passes) 
                    { 
                        pass.Begin(); 
     
                        myDevice.Indices = mesh.IndexBuffer; 
     
                        for (int i = 0; i < mesh.MeshParts.Count; i++) 
                        { 
                            ModelMeshPart part = mesh.MeshParts[i]; 
     
                            if (part.NumVertices > 0) 
                            { 
                                myDevice.VertexDeclaration = part.VertexDeclaration; 
                                myDevice.Vertices[0].SetSource(mesh.VertexBuffer, part.StreamOffset, part.VertexStride); 
                                myDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, part.BaseVertex, 0, 
                                    part.NumVertices, part.StartIndex, part.PrimitiveCount); 
            
     
                            } 
                        } 
                        pass.End(); 
                    } 
                    myMaterial.MyEffect.End(); 
                } 
            } 
     

    Any help would be greatly appreciated!

    Cheers

    Tetsuo

  • 12/3/2008 10:37 AM In reply to

    Re: System.InvalidOperationException when running on xbox 360

    Already solved the problem...

    I was stupid enough to already initialize some shader before the Base.initialize itself.... probably giving them an invalid graphic device... and not setting the correct one when being called on Begin().

    Cheers

    Tetsuo
Page 1 of 1 (2 items) Previous Next