CIC 3620 - Computer Graphics
Assignment #3 - Turtle Graphics in OpenGL

Overview

Turtle graphics is a graphics system which models the movements of a turtle on a two-dimensional drawing surface.

This assignment, which will be presented in stages, will play a bit with various implementations and applications of a turtle graphics system.

The Turtle

Part 1. A Set of Turtle Functions for OpenGL

This is exercise 2.4 of the text.

Implement the following set of functions in OpenGL that provides turtle graphics (I've also coded it as the source file Turtle.h):

Getting Started

For this portion of the assignment, simply code the above a a set of C-like functions. Feel free to implement this in any manner you wish; however, here are some tips you might find useful:

A Simple Turtle Application Program

Here is a simple test application program for the system as described above (this is also available as the source file TurtleApp.cpp):
#define GLUT_DISABLE_ATEXIT_HACK
#include 

#include 
#include 

#include "Turtle.h"

using namespace std;

void init() {
    glClearColor(1, 1, 1, 1);
    gluOrtho2D(-100, 100, -100, 100);
}

static void display(void) {
    glClear (GL_COLOR_BUFFER_BIT);
    glColor3f (1.0, 0.0, 0.0);

    init(0, 0, 0);

    penUp();
    forward(25);
    penDown();
    left(90);
    forward(25);
    left(90);
    forward(50);
    left(90);
    forward(50);
    left(90);
    forward(50);
    left(90);
    forward(25);
}

int main(int argc, char *argv[]) {
    glutInit(&argc, argv);
    glutInitWindowPosition (0, 0);
    glutInitWindowSize (200, 200);
    glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
    glutCreateWindow ("Turtle");

    glutDisplayFunc(display);

    init();

    glutMainLoop();

    return 0;
}
			
and here is the output:

Some More Implementation Details

Part 2 - A More Complex Turtle Image

Here is an image generated by a turtle graphics program (it's the one from the Wiki entry above):

Write a turtle app that reproduces the above image (it doesn't have to be exact). (Click the picture to see the Wiki picture page -- it also contains pseudocode for the spiral-- you can either try to decipher it, or alternatively, examine the image and figure out how to reproduce it.)

Here is my quick and dirty attempt:

Files for Assignment 2