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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T21:49:52+00:00 2026-05-11T21:49:52+00:00

I have gotten my basic L-System working and I decided to try and optimize

  • 0

I have gotten my basic L-System working and I decided to try and optimize the rendering of the application. Previously I was looping through the whole string of the L-System with a switch case and drawing. Better yet I will show you what I was doing:

for(unsigned int stringLoop = 0; stringLoop < _buildString.length(); stringLoop++)
{
    
        switch(_buildString.at(stringLoop))
        {
        case'X':
            //Do Nothing
            //X is there just to facilitate the Curve of the plant
            break;
        case'F':

            _prevState = _currState;
            _currState.position += _currState.direction * stdBranchLength; 
            //Set the previous state to the current state
            _graphics.SetColour3f(0.0f, 1.0f, 0.0f);
            
            _graphics.Begin(OGLFlags::LINE_STRIP);
                _graphics.Vertex3f(_prevState.position.X(), _prevState.position.Y(), _prevState.position.Z());
                _graphics.Vertex3f(_currState.position.X(), _currState.position.Y(), _currState.position.Z());
            _graphics.End();

            break;
        case'[':
            _prevStack.push(_currState);
            break;
        case']':
            _prevState = _currState;
            _currState = _prevStack.top();
            _prevStack.pop();               
            break;
        case'-':
            
            _currState.direction = _currState.direction.RotatedAboutZ(-(ROTATION) * Math::DegreesToRadians);

            break;
        case'+':
            _currState.direction = _currState.direction.RotatedAboutZ(ROTATION * Math::DegreesToRadians);

            break;
        };

}

I removed all of this because I was literally resolving the tree every single frame, I changed this loop so that it would save all of the verticies in a std vector.

    for(unsigned int stringLoop = 0; stringLoop < _buildString.length(); stringLoop++)
{
    
        switch(_buildString.at(stringLoop))
        {
        case'X':
            break;
        case'F':

            //_prevState = _currState;
            _currState.position += _currState.direction * stdBranchLength;
            _vertexVector.push_back(_currState.position);
        
            break;
        case'[':
            _prevStack.push(_currState);
            break;
        case']':
            _currState = _prevStack.top();
            _prevStack.pop();               
            break;
        case'-':            
            _currState.direction = _currState.direction.RotatedAboutZ(-(ROTATION) * Math::DegreesToRadians);
            break;
        case'+':
            _currState.direction = _currState.direction.RotatedAboutZ(ROTATION * Math::DegreesToRadians);
            break;
        };
}

Now I changed my render loop so I just read straight from the vector array.

    DesignPatterns::Facades::OpenGLFacade _graphics = DesignPatterns::Facades::openGLFacade::Instance();

_graphics.Begin(OGLFlags::LINE_STRIP);
    for(unsigned int i = 0; i < _vertexVector.size(); i++)
    {
        _graphics.Vertex3f(_vertexVector.at(i).X(), _vertexVector.at(i).Y(), _vertexVector.at(i).Z());
    }
_graphics.End();

Now my problem is that when I am using a vector array and I use Line Stip, I get extra artifact.

The first image is the original render that is the unoptimized one, then the second is the newer render which runs faster, and the thirds is a render of a dragon curve which uses no push and pops like the first two are using (I am pretty sure the push and pop is where the problems are coming in).

Is the problem with my logic here of storing verticies, or is it because I am using a line strip? I would just use lines, but it doesn’t really work at all, it ends up looking more of a line_stipple.

Also sorry about the length of this post.

alt text http://img197.imageshack.us/img197/8030/bettera.jpg
alt text http://img23.imageshack.us/img23/3924/buggyrender.jpg
alt text http://img8.imageshack.us/img8/627/dragoncurve.jpg

  • 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-11T21:49:52+00:00Added an answer on May 11, 2026 at 9:49 pm

    You are getting those extra lines because you are using a LINE_STRIP.

    In your ‘F’ case, push both end points of your line into the vector (like you were doing originally).

    _vertexVector.push_back(_prevState.position);
    _vertexVector.push_back(_currState.position);
    

    And when you draw, use LINE_LIST instead.

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

Sidebar

Ask A Question

Stats

  • Questions 157k
  • Answers 157k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer If you need a solution for Windows this should be… May 12, 2026 at 11:03 am
  • Editorial Team
    Editorial Team added an answer If you increment the end iterator, the result is undefined… May 12, 2026 at 11:03 am
  • Editorial Team
    Editorial Team added an answer Couple things going on here I see so far: type… May 12, 2026 at 11:03 am

Related Questions

I know that generally speaking, this cant be done, that is get another PC
Since I've gotten no answer at all to my question Is there an alternative
I'm working on a basic Issue Management System in order to learn ASP.NET MVC.
I've been experimenting with ASP.NET MVC and following this tutorial to create the basic

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.