Getting 2 lines when I draw 1

Using Code::Blocks 17.12 on Windows 10 with SDL 2.0.9.

I am drawing various lines as part of my program and I noticed that in one instance I am seeing 2 lines when I only want to draw 1. Here is the code snippet:

double angle = 0.0;
double x = 200.0;
double angle2 = 0.0;
double y = 200.0;

while(true)
{
  angle -= 0.5 * switcher; // switcher value may be 1 or -1
  SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
  SDL_RenderClear(renderer);
  SDL_SetRenderDrawColor(renderer, 0, 0, 255, 255);
  SDL_RenderDrawLine(renderer, x + 100 * cos(angle),
                               y - 100 * sin(angle),
                               x - 100 * cos(angle),
                               y + 100 * sin(angle));
  SDL_SetRenderDrawColor(renderer, 0, 255, 0, 255);
  SDL_RenderDrawLine(renderer, x + 100 * cos(angle2),
                               y - 100 * sin(angle2),
                               x - 100 * cos(angle2),
                               y + 100 * sin(angle2));
  SDL_RenderPresent(renderer);
}

The static line (angle2) seems to have no issues, nor have any other lines I tested. I have tried changing the colors and the number 100 to see if that matters, but it does not. Even the order doesn’t affect anything. As an additional test, I tried making some of the angles static, but as long as 1 or more were changing, I got the double lines.

Edit: The double line does not show up on screenshots, which is strange since I have been able to capture other irregularities in the past. See the screen shot below. The top line usually has another line tilted slightly down at 10-20 degrees.

nosplit

Any ideas?

I see 2 “RenderDrawLine” functions.
Not sure how you could miss that one.

There are two lines, but when I move one of the lines it splits or even triples. In other words, you see the line and its last 1 or 2 states on the screen. I showed it to multiple people to make sure it wasn’t just my eyes, and it even shows up on camera, just not in screen shots.

I’m not sure if it is a monitor refresh rate problem or what. I believe the SDL loop rate is usually 60/sec, so maybe I need to slow down the rate of change, because it is making the use of moving lines look awful.

yes, if you add SDL_Delay(17) everything should go well

I tried SDL_Delay(17) and it now looks like the line is stuttering in the path of motion, and all “extra” lines are still visible. I increased the number, and by about 70 it slows down enough not to appear to produce ghost lines. Unfortunately the line motion looks slow now.

Is there another solution where I can have fast motion without the blur, so to speak? My refresh rate on my monitor is 144 and the program is using my integrated graphics card instead of my dedicated one. Is it possible to have SDL automatically switch to the dedicated card, and would that help?

Just so people can understand whats happening am I correct in saying.

You are seen multiple lines when you only draw 1 and move the line.

This does not show when you take a screenshot ?

If this is the case then it could be normal. Your monitor could be the issue or you eyes could be seen the previous image especially if the background and line color are very distinct.

Have a look at this and play around with the settings.

That is correct. I see multiple lines when I draw only one. I realize that my question is a bit confusing, as I did not add the moving code and I have the other test line (blue) present. The green line for example, when moved each frame, appears as either 2 or 3 lines, though a screenshot shows that only one is actually there. A camera on the other hand will capture the extra lines.

I showed the animation to other people to see if they saw the extra lines, and they see them too. As I mentioned above, I have a 144 Hz refresh on my monitor, so maybe I need to do something with the FPS to match that or a multiple of it?

Is it possible to send me on the current code with movement ?
I would also like to run this please.