Answer the question
In order to leave comments, you need to log in
How to draw a multi-colored polyline in OpenGL without a gradient?
In PyQt in QOpenGLWidget I draw a scene using OpenGL. It has a multi-colored trajectory. Some of the segments in the trajectory are yellow, some are green.
I do not need a gradual color transition, I need an instant color change for areas with different parameters.
for i in np_list:
if new != old:
if new == 0:
glColor3f(*OpenGL_color_1)
else:
glColor3f(*OpenGL_color_2)
old = new
glVertex3f(i[4], i[5], i[6])
Answer the question
In order to leave comments, you need to log in
And the answer will be very simple.
At the color change point, you need to put two vertices. The first vertex is to finish the line of the previous color, and the second one is to start the line of the next color.
It won't affect performance in any way.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question