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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:45:26+00:00 2026-05-30T17:45:26+00:00

This is for a Terrain Generation and rendering program. I have a loop that

  • 0

This is for a Terrain Generation and rendering program.

I have a loop that looks like this:

x = -MAX_SIGHT_DISTANCE;
y = -MAX_SIGHT_WIDTH;
while (x < MAX_SIGHT_DISTANCE)
{
    while (y < MAX_SIGHT_WIDTH)
    {
        value = noise2d(x+camera.x, y+camera.y);
        if (pointInFrustum(x-camera.x, y-camera.y, value, direction, FOV, MAX_SIGHT_DISTANCE) == 1)
        {
            // TODO: STORE VALUE TO AN ARRAY....SOMEHOW...
        }
        dz = value-camera.z;
        distance = sqrt(x*x + y*y + (dz)*(dz));
        x += DISTANCE_FUNCTION(distance);
        y += DISTANCE_FUNCTION(distance);
    }
}

It’s supposed to find a semi-random height value at different resolutions: Much higher resolution up close, and lower resolution farther away.

Later,

for x
{
    glBegin(GL_TRIANGLE_STRIP);
    for y
    {
        glVertex(x, y);
        glVertex(x+1, y);
    }
    glEnd();
}

This is supposed to be the rendering code (in pseudo-code, of course).
I have to specify the coordinates of each point. I’d really like to use triangle strips here, so I need to have all points in one strip following each other.

Comes my question: How do I store these points? In python I’d create a list, and then just render everything in the list.
Problem is this is in C, arrays aren’t dynamic. So I need a size. How can I know that size? How can I loop through it in an intelligent way (since it has variable widths)? And how can I prevent stuff like the end of one row joining with the beginning of another row?

Or am I doing the whole thing wrong?

  • 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-30T17:45:27+00:00Added an answer on May 30, 2026 at 5:45 pm

    How about you use a dynamic data structure like a stack of linked-lists?

    Each linked list would hold the points for each triangle strip.
    The stack would contain the a linked list for each triange strip.
    Linked list would suit your problem because you dont really need to index your elements.

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

Sidebar

Related Questions

I have code like this that sets the map type to Terrain View: map
I am trying to make terrain mesh, and for now got something like this:
I've been pondering this question awhile now... many 3d engines support advanced terrain rendering
I have a program which draws some terrain and simulates water flowing over it
So I have what is essentially a game... There is terrain in this game.
I have this seemingly innocent piece of code: void generate_heightmap(float **terrain) { } int
My terrain gets weird colors like this: http://tinypic.com/view.php?pic=307w421&s=7 Does anyone have any idea what
I need some help setting up a particular terrain. I have a world that
This might seem like a stupid question I admit. But I'm in a small
I have coded a 3d-terrain engine with simplistic model engine on top of it.

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.