Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 559141
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T12:12:23+00:00 2026-05-13T12:12:23+00:00

I’ve been unsuccessful at getting a simple cube geometry with shading turned on to

  • 0

I’ve been unsuccessful at getting a simple cube geometry with shading turned on to display correctly.

This is c# code, but the values are being passed through SlimDX directly to C++ code.

            pParams.BackBufferWidth = 0;
            pParams.BackBufferHeight = 0;
            pParams.BackBufferCount = 1;
            pParams.BackBufferFormat = Format::X8R8G8B8;
            pParams.Multisample = MultisampleType::None;
            pParams.MultisampleQuality = 0;
            pParams.DeviceWindowHandle = this.Handle;
            pParams.Windowed = true;
            pParams.AutoDepthStencilFormat = Format.D24X8;
            pParams.EnableAutoDepthStencil = true;
            pParams.PresentFlags = PresentFlags.None;
            pParams.FullScreenRefreshRateInHertz = 0;
            pParams.PresentationInterval = PresentInterval.Immediate;
            pParams.SwapEffect = SwapEffect.Discard;

… are the values in the PresentParameter struct used to set up my Direct3D9Device object.

During a rendering, SetRenderState is called as follows:

        this.D3DDevice.Clear(ClearFlags.Target | ClearFlags.ZBuffer, this.BackColor, 10000.0f, 0);
        this.D3DDevice.SetRenderState(RenderState.Ambient, false);
        this.D3DDevice.SetRenderState(RenderState.ZEnable, ZBufferType.UseZBuffer);
        this.D3DDevice.SetRenderState(RenderState.ZWriteEnable, true);
        this.D3DDevice.SetRenderState(RenderState.ZFunc, Compare.LessEqual);
        this.D3DDevice.BeginScene();

Again, this is passed through to C++ code, which marshals the values in to calls a C++ programmer would not fear.

The primitives are diffuse colored vertices (D3DFVF_XYZ | D3DFVF_DIFFUSE). The wireframe view looks like this:
wireframe view http://gallery.me.com/robert.perkins/100045/z-fightingwireframe/web.jpg

The nearer pair of larger triangles is the near face of a cube.

The filled view looks like this:
full view 1 http://gallery.me.com/robert.perkins/100045/Z-fighting/web.jpg

Or this, on a subsequent rendering call:
full view 2 http://gallery.me.com/robert.perkins/100045/zfight2/web.jpg

I’m not sure how to fix this. Where should I begin looking?

Edit: The camera projection matrix looks about like this for one of the frames:

{[[M11:0.6281456 M12:0.7659309 M13:0.1370506 M14:0] 
  [M21:0.7705086 M22:-0.5877584 M23:-0.2466911 M24:0] 
  [M31:-0.1083957 M32:0.2605566 M33:-0.9593542 M34:0] 
  [M41:-3.225646 M42:-1.096823 M43:20.91392 M44:1]]}

And, the view matrix looks like this:

camera.ViewMatrix = {[[M11:0.6281456 M12:0.7659309 M13:0.1370506 M14:0] 
                      [M21:0.7705086 M22:-0.5877584 M23:-0.2466911 M24:0] 
                      [M31:-0.1083957 M32:0.2605566 M33:-0.9593542 M34:0] 
                      [M41:-3.225646 M42:-1.096823 M43:20.91392 M44:1]]}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T12:12:24+00:00Added an answer on May 13, 2026 at 12:12 pm

    Clear the Z-Buffer to 1.0f not 10000.0f.

    From the Clear docs in the SDK:

    [in] Clear the depth buffer to this new z value which ranges from 0 to 1.. 
    

    It may also be useful to see your projection matrix and viewport settings …

    Edit: How do you build that projection matrix? You have set zNear to 0 and zFar to 1. Try setting your zNear to 0.001f and zFar to 1000.0f and see whether that helps you at all…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a jquery bug and I've been looking for hours now, I can't
I'm looking for suggestions for debugging... If you view this site in Firefox or
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
That's pretty much it. I'm using Nokogiri to scrape a web page what has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.