| Name/Element | Value |
|---|
CMPS-4350 Lab-5
Lab Title: Drawing in OpenGL
glBegin(GL_TRIANGLES); to start drawing a triangle.glVertex2f(x1, y1); for the first vertex.glVertex2f(x2, y2); for the second vertex.glVertex2f(x3, y3); for the third vertex.glEnd(); to finish drawing the triangle.Copy the setup code using this command:
cp /home/stu/sgonzales/4350/5/lab5.cpp .
cp /home/stu/sgonzales/4350/5/Makefile .
cx, cy), radius, and the number of segments (to approximate the circle).glBegin(GL_TRIANGLE_FAN); to start drawing a filled circle.glVertex2f(cx, cy);.numSegments (inclusive) to compute and add vertices on the circle's circumference:
angle = 2.0f * PI * i / numSegments;x = cx + cos(angle) * radius;y = cy + sin(angle) * radius;glVertex2f(x, y);glEnd(); to finish drawing the circle.glColor3f(1.0f, 0.5f, 0.0f);glBegin(GL_POLYGON); to start drawing a tapered polygon for the carrot.glVertex2f(x, y); calls.glEnd(); to finish the carrot body.glColor3f(0.0f, 1.0f, 0.0f);glBegin(GL_LINES);, define two vertices with glVertex2f(x, y); calls, and then call glEnd();.GL_POLYGON and define multiple vertices.x and y position, scale (size), rotation, and rotation speed.x position and set y at the top of the screen.glPushMatrix() to save the current transformation state.x and y position.glRotatef() with the carrot's rotation.glScalef() using the carrot's scale.glPopMatrix() to restore the transformation state.y position to the top.
Code Images