Forum
Contact





DirectX using C#
DirectX using C++
DirectX using Visual Basic



Latest Forum posts

 Tutorial 3 for Windows Phone 7
  Posted by: Anonymous
  When: 20/05/2013 at 02:30:13

 No download link for 2d series: shooter
  Posted by: zaboleq
  When: 07/05/2013 at 15:46:28

 Collision Class?
  Posted by: Anonymous
  When: 05/05/2013 at 19:03:59

 stack overflow
  Posted by: cityguy
  When: 07/04/2013 at 01:58:38

 Meshes looks strange.
  Posted by: ab_saratov
  When: 01/04/2013 at 04:31:08

 Lamppost Not loaded
  Posted by: Anonymous
  When: 22/03/2013 at 06:43:52

 Collision Class?
  Posted by: Da_Boom
  When: 21/03/2013 at 01:23:09

 Math boggles me
  Posted by: cityguy
  When: 17/03/2013 at 03:44:48

 Collision Class?
  Posted by: Da_Boom
  When: 16/03/2013 at 03:44:42

 Tree update
  Posted by: Anonymous
  When: 15/03/2013 at 21:11:22

 XNA 4.0
  Posted by: Anonymous
  When: 15/03/2013 at 19:43:57

 Error when I try to run.
  Posted by: Anonymous
  When: 15/03/2013 at 19:21:06

 Error With the Effect File
  Posted by: Anonymous
  When: 15/03/2013 at 18:21:01

 Can only get shadowmap
  Posted by: Anonymous
  When: 15/03/2013 at 15:48:52

 Vertex and Pixel Shader Versions?
  Posted by: Anonymous
  When: 15/03/2013 at 15:07:16

 Unsupported properties
  Posted by: Anonymous
  When: 15/03/2013 at 14:23:00

 Problem Loading Skybox
  Posted by: Rana
  When: 15/03/2013 at 10:34:45

 Black Screen Of Death - Help!
  Posted by: Anonymous
  When: 15/03/2013 at 03:43:43

 2.0 anyone?
  Posted by: Anonymous
  When: 15/03/2013 at 02:19:48

 Defitinition of tha rotation axis
  Posted by: Anonymous
  When: 15/03/2013 at 00:55:14




Topic: Error in lesson



  
Goto parent category
  
Create a new user account


   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 !!

  
Post a new reply
 





Google
 
Web www.riemers.net
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


News
Home
Forum
XNA 2.0 Recipes Book (8)
XNA 3.0 Recipes Book (8)
Downloads
Extra Reading (3)
Matrices: geometrical
Matrix Mathematics
Homogenous matrices
Community Projects (1)
Tutorials (160)
XNA 4.0 using C# (89)
DirectX using C# (54)
Series 1:Terrain (14)
Opening a window
Linking to the Device
Drawing a triangle
Camera
Rotation - Translation
Indices
Terrain creation
Terrain from file
DirectInput
Importing bmp files
Colored vertices
DirectX Light basics
Mesh creation
Mesh lighting
Series 2: Flightsim (19)
Series 3: HLSL (19)
Short Tuts (2)
Resizing problem
Checking Device caps
DirectX using C++ (15)
DirectX using VB (2)