|
 | Error in lesson | |  |
| Poster | : fuzzykris | | Posts | : 2 | | Country | : Canada | | City | : Oakville |
| | | | Posted by fuzzykris on 19/10/2006 at 20:19:46
| | I don't know if anyone has spotted it but there is an error in this lesson(actually the error goes back to 'Linking to the Device').
The Device.Clear command should be as follows:
Device.Clear( ClearFlags.Target | ClearFlags.ZBuffer, Color.DarkSlateBlue, 1.0f, 0 );
rather than
Device.Clear( ClearFlags.Target, Color.DarkSlateBlue, 1.0f, 0 );
The previous ensures the Z-buffer is cleared as well as the render target. If you don't clear the Z-buffer the triangle may appear broken up or may not appear at all.
In previous lessons the Z-Buffer was not used so it wouldn't show up until now. | |
|
| | | | | | Poster | : fuzzykris | | Posts | : 2 | | Country | : Canada | | City | : Oakville |
| | | | Posted by fuzzykris on 19/10/2006 at 20:34:24
| | | My mistake - I've been moving code from C++ to C# and was using these lessons to help me with the differences so my code wasn't identical to the lesson. I had constructed the ZBuffer out of habit without realizing the lessons had not done that. | |
|
| | | | | | Poster | : riemer | | Posts | : 1392 | | Country | : Belgium | | City | : Antwerp |
| | | | Posted by riemer on 20/10/2006 at 02:49:54
| | | Thanks for taking the effort anyway | |
|
| | | | | | Poster | : cpu90 | | Posts | : 1 | | Country | : USA | | City | : rochester |
| | | | Posted by cpu90 on 01/11/2006 at 10:53:51
| | In fact, with
Device.Clear( ClearFlags.Target, Color.DarkSlateBlue, 1.0f, 0 );
the scene is all blue, and cannot see any triangle..
so i tried the fix from the post.
Device.Clear( ClearFlags.Target | ClearFlags.ZBuffer, Color.DarkSlateBlue, 1.0f, 0 );
Compiles fine, but when i run it, it gives me an exception, says:
************** Exception Text **************
Error in the application.
-2005530516 (D3DERR_INVALIDCALL)
at Microsoft.DirectX.Direct3D.Device.Clear(ClearFlags flags, Int32 color, Single zdepth, Int32 stencil, Rectangle[] regions)
at Microsoft.DirectX.Direct3D.Device.Clear(ClearFlags flags, Color color, Single zdepth, Int32 stencil)
at dxTest.Form1.OnPaint(PaintEventArgs e) in C:\Documents and Settings\Chen-Ping Yu\My Documents\Programming Skills\dxTest\dxTest\Form1.cs:line 61
at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs)
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
so adding the zbuffer in clear is causing me problems....is it because my laptop does not have a graphic card, it uses its centrino's intel graphic card with 128 mb shared memory? Thank you for helping out, GREAT tutorial by the way. | |
|
| | | | | | Poster | : riemer | | Posts | : 1392 | | Country | : Belgium | | City | : Antwerp |
| | | | Posted by riemer on 02/11/2006 at 15:39:38
| | | You can check if your graphics card supports a zbuffer, by reading the device capabilities. Ive written an article on this, its in the ShortTuts section | |
|
| | | | | | Poster | : Lintford | | Posts | : 7 | | Country | : England | | City | : Manchester |
| | | | Posted by Lintford on 14/02/2007 at 04:50:56
| | Hi, first of all, great tutorial,
just something to try for cpu90. Maybe the reason that clearing the Z-Buffer causes the problem is, at least i think, you have to specify that you are using a Z-Buffer in the PresentParams structure (when you defined windowed mode).
I'm also learning so please don't 'flame' me, but you could try :
PresentParameters m_d3dPP = new PresentParameters();
m_d3dPP.Windowed = true;
m_d3dPP.SwapEffect = SwapEffect.Discard;
m_d3dPP.EnableAutoDepthStencil = true;
m_d3dPP.AutoDepthStencilFormat = DepthFormat.D16; | |
|
| | | | | | Poster | : Serendipity | | Posts | : 27 | | Country | : Pakistan | | City | : Rawalpindi |
| | | | Posted by Serendipity on 25/07/2008 at 04:11:21
| | Hey!
Although this is a long time off, but this page helped me in solving the same problem, so thanks !! | |
|
|
 | | |  |
|
|
|
If you appreciate the amount of time I spend creating and updating these pages, feel free to donate -- any amount is welcome !
|
- Website design & DirectX code : Riemer Grootjans - ©2006 Riemer Grootjans
|
|