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

  • Home
  • SEARCH
  • 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 8797071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:46:19+00:00 2026-06-13T23:46:19+00:00

I have been learning DirectX for a while now & I got to the

  • 0

I have been learning DirectX for a while now & I got to the point of drawing multiple objects to the screen from .obj files. My problem is that if I draw 2 objects, the 2nd draw will be on top of the 1st.

Example:
Obj1 = Cardboard box
Obj2 = Cube

loadStuff_&_draw(Obj1);  
loadStuff_&_draw(Obj2);

That would draw the cube outside/front the box even if it is in/behind.

How would I make multiple objects draw together so that they overlap correctly?

The only drawing things I know of are:

  • Load vertex, index, constant buffers
  • updateSubresource()
  • drawIndexed()

Edit:
Here is a picture of a cube in a box. It shows that the cube is behind the box rather than inside. It also shows that the rim of the box clips behind the box. Not sure what happened.

I drew the cube, then drew the hollow box.

Render of a cube in a box

  • 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-06-13T23:46:20+00:00Added an answer on June 13, 2026 at 11:46 pm

    This is what the depth buffer (sometimes called the z-buffer) is for. When you write a pixel during the drawing of one object, it records the distance from the viewpoint for that pixel in the depth buffer. Then when you draw a second object that would also write to that pixel, it can compare the new object’s depth value at that pixel with the buffered value (from previous objects) and only overwrites the pixel if the new value would be nearer than the old one. If the pixel gets drawn, then the depth value is updated to reflect the closer value.

    Some links that might give you some ideas on how to implement this:

    http://msdn.microsoft.com/en-gb/library/windows/desktop/bb205074%28v=vs.85%29.aspx

    http://www.rastertek.com/dx11tut35.html

    https://stackoverflow.com/a/8641210/28875

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

Sidebar

Related Questions

I have been learning python for some time now. While starting this learning python
I have been learning Python for a while, and now I'd like to learn
I have been learning C++ for a while now, and so far I love
I have been learning to use Emacs for a little while now. So far
I have been learning Python for a little while now, and I feel that
I have been learning css & jquery. <!DOCTYPE html> <html> <head> <style type=text/css> #box
I have been learning Scala for the past couple of months and now I
I have been learning C++ with some books from school that are from the
I have been learning php for sometime now. Besides reading books and doing tutorials
I have been learning about various functional languages for some time now including Haskell,

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.