OpenGL线宽函数
使用下面的OpenGL函数可以设定线宽:glLineWidth (width);参数width赋以实数,该值舍入到最近的非负整数。如果输人值舍入到0.0,则线段用默认的标准宽度1.0显示。然而,在对线段进行反走样时,其边界进行光滑处理以减少阶梯现象,因而有可能出现小数宽度。有些线宽函数的实现仅支持有限的几种线宽,其他一些则不支持1.0以外的线宽。
OpenGL线型函数
默认状态下,直线段显示成实线。但也可以显示划线、点线或短划和点混合的线段。还可改变短划及短划或点之间的长度。可以利用下面的OpenGL函数设定当前线型:glLineStripple(repeatFactor,pattern);参数pattern用来引入描述如何显示线段的一个16位整数。值为1的位对应一个“开”像素,值为0的位对应一个“关”像素。该模式从低位开始应用于线路径。默认模式为0xFFFF(每一位的值均为1),它生成实线。整数参数repeatFactor说明模式中每一位重复应用多少次才轮到下一位。默认的重复值是1。
glEnable(GL_LINE_STIPPLE);如果忘记使用这一激活函数,则显示实线;即使用默认模式0xFFFF显示线段。在任何时候都可以使用下列函数来关闭线型特性:
glDisable(GL_LINE_STIPPLE);该函数使用默认模式(实线)取代当前线型。
/* Define a two-dimensional world-coordinate data type. */
typedef struct { float x, y; } wcPt2D;
wcPt2D dataPts [5];
void linePlot (wcPt2D dataPts [5])
{
	int k;
	glBegin (GL_LINE_STRIP);
	for (k = 0; k < 5; k++)
	glVertex2f (dataPts [k].x, dataPts [k].y);
	glFlush ();
	glEnd ();
}
/*Invoke a procedure here to draw coordinate axes. */
	glEnable (GL_LINE_STIPPLE);
	
/* Input first set of (x, y) data values. */
	glLineStipple (1, 0x1C47); // Plot a dash-dot, standard-width polyline.
	linePlot (dataPts);
/* Input second set of (x, y) data values. */
	glLineStipple (1, 0x00FF); // Plot a dashed, double-width polyline.
	glLineWidth (2.0);
	linePlot (dataPts);
/* Input third set of (x, y) data values. */
	glLineStipple (1, 0x0101); // Plot a dotted, triple-width polyline.
	glLineWidth (3.0);
	linePlot (dataPts);
	
	glDisable (GL_LINE_STIPPLE);原文:http://blog.csdn.net/heyuchang666/article/details/52280064