Primitive Attributes
- Attributes are properties that you assign to a primitive.
- Color is one attribute that all primitives share. Others are
dependent on the object.
- Points have a single attributes, size
- This is set with glPointSize
- It takes a single float parameter, which must be positive
- And if it is not an int, it is rounded to one.
- Remember this cannot be inside of a glBegin-glEnd pair (it really doesn't work)
- You can turn antialiasing on to make "round" points.
- glEnable(GL_POINT_SMOOTH)
- or turn it off with glDisable(GL_POINT_SMOOTH)
- This is one of those switch things, on until your turn it off.
- It is off by default.
- More on antialiasing when we learn to draw lines (for real).
- Lines have more attributes
- Line Width, (glLineWidth).
- Like points, this is a float value, that is rounded to integer.
- And can be antialiased (GL_LINE_SMOOTH)
- Line stipple, or pattern
- This must be enabled/disabled
- glEnable(GL_LINE_STIPPLE)
- The command is glLineStipple(repeat, pattern)
- The first parameter is an integer between 1 and 256
- It is a scale factor.
- The second is a int, between 0 and 0xFFFF
- it specifies a bit mask for drawing the line.
- a pattern of 0x1000 would draw the first pixel on and the next 15 off.
- a pattern of 0xAAAA would be every other pixel on, starting with the first.
- Stipples mark fragments as not drawn, and thus are not sent to the
fragment processor.
- The pattern starts over at 0 when a glBegin is called
- Polygons
- glPolygonMode(face, mode)
- Allows to draw polygons as (mode parameter)
- points (GL_POINT)
- lines (GL_LINE)
- filled (GL_FILL)
- And this effects
- The front face (GL_FRONT)
- The back face (GL_BACK)
- or both (GL_FRONT_AND_BACK)
- Front and rear is determined by the direction the points are
specified.
- You can determine this.
- glFrontFace(mode)
- GL_CCW, counter clockwise
- GL_CW , clockwise
- if 1/2∑ i=0i=n xiyi+1 -xi+1yi > 0, it is CCW front
- if 1/2∑ i=0i=n xiyi+1 -xi+1yi < 0, it is CW front
- Try the triangle (0,0), (1,1), (2,0)
- Polygons can be stippled as well.
- glPolygonStipple(const GLUubyte * mask)
- the mask is a 32x32 bitmask.
- GLubyet mask[] = { 0x00, 0x01, 0x04, ...};
- This is upside down. (0,0) maps to the bottom of the
picture.
- This must be enabled
- glEnable(GL_POLYGON_STIPPLE);
- Some example code