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 7949177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T01:55:16+00:00 2026-06-04T01:55:16+00:00

I am working on some simple terrain with DirectX9 by manually assembling the verts

  • 0

I am working on some simple terrain with DirectX9 by manually assembling the verts for the ground.

On the part of my code where I set up the indices I get an error though:

Windows has triggered a breakpoint in test.exe.

This may be due to a corruption of the heap, which indicates a bug in test.exe or any of the DLLs it has loaded.

Here is the part of my code that is giving me problems, and I’m almost 100% sure that it is linked to my indices pointer, but I delete it when I’m finished… so I’m not sure what the problem is.

int total = widthQuads * heightQuads * 6;
DWORD *indices = new DWORD[totalIdx];
for (int y = 0; y < heightQuads; y++)
{
    for (int x = 0; x < widthQuads; x++)
    { //Width of nine:
        int lowerLeft = x + y * 9;
        int lowerRight = (x + 1) + y * 9;
        int topLeft = x + (y + 1) * 9;
        int topRight = (x + 1) + (y + 1) * 9;
        //First triangle:
        indices[counter++] = topLeft;
        indices[counter++] = lowerRight;
        indices[counter++] = lowerLeft;
        //Second triangle:
        indices[counter++] = topLeft;
        indices[counter++] = topRight;
        indices[counter++] = lowerRight;
    }
}

d3dDevice->CreateIndexBuffer(sizeof(DWORD)* total, 0, D3DFMT_INDEX16, 
    D3DPOOL_MANAGED, &groundindex, 0);
void* mem = 0;
groundindex->Lock(0, 0, &mem, 0);
memcpy(mem, indices, total * sizeof (DWORD));
groundindex->Unlock();

delete[] indices;

When I remove this block my program runs OK.

  • 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-04T01:55:18+00:00Added an answer on June 4, 2026 at 1:55 am

    The code you’ve given looks OK – with one caveat: the initial value of counter is not in the code itself. So either you don’t start at counter = 0, or some other piece of code is stomping on your indices buffer.

    That’s the beauty of heap corruptions. There is no guarantee that the bug is in the removed portion on the code. It may simply hide the bug that exists somewhere else in your code.

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

Sidebar

Related Questions

I'm trying to get some simple code working to log the pitch, roll, and
So I'm just working on some simple arithmetic code. Here's what I got: echo
I have written some simple and working assembly code on 8085 trainer hardware. But
I am trying to get some simple UDP communication working on my local network.
So I have some simple code but it seems to not be working.. any
Im trying to get some simple javascript working in gwt but keep failing. The
I am working on some simple object-oriented code in MATLAB. I am trying to
I've some simple code below that uses a ToggleButton.IsChecked property to set the Visibility
I am currently working on some simple custom allocators in c++ which generally works
I am working though some simple DX tutorials, and have hit an early snag.

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.