OpenGL Programming/Basics/LinesPoints

Drawing pointsEdit

glBegin(GL_POINTS);
  glVertex2f(0.5f, 0.5f); 
  glVertex2f(0.5f, -0.5f); 
  glVertex2f(-0.5f, 0.5f); 
  glVertex2f(-0.5f, -0.5f); 
glEnd();

Drawing linesEdit

/* Draws two horizontal lines */
glBegin(GL_LINES);
  glVertex2f(0.5f, 0.5f); 
  glVertex2f(-0.5f, 0.5f); 
  glVertex2f(-0.5f, -0.5f); 
  glVertex2f(0.5f, -0.5f); 
glEnd();

Loop of linesEdit

/* Draws a square */
glBegin(GL_LINE_LOOP);
  glVertex2f(0.5f, 0.5f); 
  glVertex2f(-0.5f, 0.5f); 
  glVertex2f(-0.5f, -0.5f); 
  glVertex2f(0.5f, -0.5f); 
glEnd();

Connected linesEdit

/* Draws a 'C' */
glBegin(GL_LINE_STRIP);
  glVertex2f(0.5f, 0.5f); 
  glVertex2f(-0.5f, 0.5f); 
  glVertex2f(-0.5f, -0.5f); 
  glVertex2f(0.5f, -0.5f); 
glEnd();
Last modified on 11 May 2010, at 11:33