OpenGl dots look like dash -
what cause opengl dots dash lines? trying draw 2 separate lines. 1 contains dashes , other 1 contain dots. supposed dotted line, appears dashes when compile , run program. here code:
#include <windows.h> #include <gl/gl.h> #include <gl/glu.h> #include <gl/glut.h> // (or others, depending on system in use) //#include <stdlib.h> void init() { glclearcolor (1.0, 1.0, 1.0, 0.0); /* set display-window color white. r,g,b,alpha alpha 0.0 transparent */ glmatrixmode (gl_projection); // set projection parameters. gluortho2d (0.0, 250.0, 0.0, 250.0); // set display area } void linesegment() { glclear (gl_color_buffer_bit); // clear display window. color buffer glcolor3f (0.0, 0.0, 1.0); // set line segment color green. //glenable(gl_line_stipple); int p1 [] = {0,80}; int p2 [] = {50, 50}; int p3 [] = {100, 100}; int p4 [] = {150, 75}; int p5 [] = {200, 120}; int p6 [] = {0, 50}; int p7 [] = {50, 100}; int p8 [] = {100,80 }; int p9 [] = {150, 150}; int p10 [] = {200, 60}; //double width dashed line glenable(gl_line_stipple); gllinewidth(2); gllinestipple (1, 0x00ff); /* dashed */ glbegin(gl_line_strip); glvertex2iv (p1); glvertex2iv(p2); glvertex2iv (p3); glvertex2iv (p4); glvertex2iv (p5); gldisable (gl_line_stipple); glend(); glcolor3f (1.0, 0.0, 1.0); // set line segment color green. glenable(gl_line_stipple); gllinewidth(3); gllinestipple (1, 0x0101); /* dotted */ glbegin(gl_line_strip); glvertex2iv (p6); glvertex2iv(p7); glvertex2iv (p8); glvertex2iv (p9); glvertex2iv (p10); gldisable (gl_line_stipple); glend(); glflush ( ); // process opengl routines possible. } int main(int argc, char *argv[]) { glutinit (&argc, argv); // initialize glut. glutinitdisplaymode (glut_single | glut_rgb); // set display mode, single buffering. glutinitwindowposition (50, 100); // set top-left display-window position. glutinitwindowsize (400, 300); // set display-window width , height. glutcreatewindow ("dash , dots "); // create display window. init( ); // execute initialization procedure. glutdisplayfunc (linesegment); // send graphics display window. glutmainloop ( ); // display , wait. return exit_success; }
set line width on dotted line 1.0
.
Comments
Post a Comment