We know that in OpenGL ES 1.1, glLineStipple() is used to draw the dotted line. Following piece of codes shows how the dotted line is drawn in OpenGL ES 1.1.
In the code to draw the lines, I pass in the coordinate system origin to the uniform vector u_sourcePoint:
//define the point will be passed in to shader as u_sourcePoint
float sp[] ={
0.0f, 0.0f, 0.0f, 0.0f, // [0] Coordinate system origin;
};
//draw axies by full_coords_vertices
glVertexAttribPointer(ad->idx_position, 3, GL_FLOAT, GL_FALSE,
3 * sizeof(float), full_coords_vertices);
glVertexAttribPointer(ad->idx_color, 4, GL_FLOAT, GL_FALSE,
4 * sizeof(float), full_coords_colors);
glEnableVertexAttribArray(ad->idx_position);
glEnableVertexAttribArray(ad->idx_color);
glUniformMatrix4fv(ad->idx_mvp, 1, GL_FALSE, ad->mvp);
glUniformMatrix4fv(ad->idx_sp, 1, GL_FALSE, sp);
glDrawElements(GL_LINES, full_coords_indices_count, GL_UNSIGNED_SHORT,
full_coords_indices);
The dotted lines is drawn by assign different colors to gl_FragColor based on the result of the geometric mathematical expression. You can define whatever geometric mathematical expression used to define your dotted line pattern. Below are the effect above shader generated.
But it seems the effect not perfect.
It still cannot draw the line as glLineStipple by define pixels pattern.
Anyone know if there are some good way to draw dotted line on OpenGL ES 2.0?
glLineStipple deprecated in OpenGL ES 2.0
glLineStipple deprecated in OpenGL ES 2.0
We know that in OpenGL ES 1.1, glLineStipple() is used to draw the dotted line. Following piece of codes shows how the dotted line is drawn in OpenGL ES 1.1.
But this function is deprecated in OpenGL ES 2.0.
I can use following shader codes to simulate the dotted lines, but the effect seems not perfect.
In the code to draw the lines, I pass in the coordinate system origin to the uniform vector u_sourcePoint:
The dotted lines is drawn by assign different colors to gl_FragColor based on the result of the geometric mathematical expression. You can define whatever geometric mathematical expression used to define your dotted line pattern. Below are the effect above shader generated.
But it seems the effect not perfect.
It still cannot draw the line as glLineStipple by define pixels pattern.
Anyone know if there are some good way to draw dotted line on OpenGL ES 2.0?
BY
16 Apr 2025
Tizen Studio
BY
04 Nov 2024
Tizen Studio
BY
02 Apr 2024
Tizen Studio