== Assignment 1 - Generative Art == '''Goal''': To familiarize yourself with the basics of OpenGL and GLUT by creating a simple OpenGL application. '''Due Date''': January 18, 2007 '''Steps''' 1. Download the skeleton code and setup GLUT with your development environment to get the code to compile and run. The ["GLUT HOWTO"] explains how to do this if you aren't familiar with setting up and using libraries with your development environment. 1. Read up on OpenGL and GLUT and answer the following questions. Be sure you can answer all these questions before moving on. 1. In a GLUT program, how is control passed back to the programmer? How is this set up during initialization? 1. What does the parameter to glutInitDisplayMode() in main() specify? 1. What do the calls to glOrtho() and glViewport() in the reshape() function accomplish? If the window is to be resized, why might we want to change this? 1. Add to the program to draw something (anything!). Your completed program should at a minimum: * Draw using at least two primitives (e.g. lines and triangles) * Draw using multiple colors * Use some user input to do something in the program. This could be as simple as using the number keys to select one of multiple modes. 1. Write up and submit your program. Your write up should contain both the answers to the questions and any notes we should know about running your program. '''Skeleton Code''' [[BR]] The skeleton code contains a very simple GLUT based OpenGL program. All it does is create a window and draw a blank screen. We are providing the code packaged for various platforms/IDEs. || Just the code || [http://graphics.stanford.edu/courses/cs148-07/assignments/assignment1/main.cpp main.cpp] || || Code + Visual Studio Project || [http://graphics.stanford.edu/courses/cs148-07/assignments/assignment1/assignment1_vs.zip assignment1_vs.zip] || || Code + XCode Project || [http://graphics.stanford.edu/courses/cs148-07/assignments/assignment1/assignment1_xcode.zip assignment1_xcode.zip] || || Code + Cross Platform Makefile (Linux, MacOS X) || [http://graphics.stanford.edu/courses/cs148-07/assignments/assignment1/assignment1_unix.tar.gz assignment1_unix.tar.gz] || '''Resources''' * ["OpenGL Resources"] * ["GLUT HOWTO"] '''Inspiration for What to Draw''' [[BR]] You may draw anything interesting, but here are some ideas to get you started. * [http://mathworld.wolfram.com/Spirograph.html Spirographs] or similar functions (note the "See Also" pages too). * Fractals, drawn to a certain level, see e.g. the [http://en.wikipedia.org/wiki/Koch_snowflake Koch Snowflake] * Simple [http://en.wikipedia.org/wiki/Space-filling_curve space filling curves] * Simple [http://en.wikipedia.org/wiki/L-system L-systems], e.g. use them to create simple trees (lines for branches, triangles for leaves) * [http://en.wikipedia.org/wiki/Conway's_Game_of_Life Conway's game of life] * [http://www.jwz.org/xscreensaver/screenshots/ XScreenSaver] has many good examples '''Grading Scale''' Grading for this and all future assignments is based on a four star scale. On this assignment you can receive: * 4 stars for a complete assignment * 1 star if you give only the answers to the questions * 0 stars otherwise '''How to submit''' * Create a new wiki page with your answers to the questions and link to it from your personal wiki page. * Email a copy of your updated main.cpp to the instructors. '''FAQ''' 1. I've ssh'd into or used vnc to connect to a myth computer and compiled the code successfully, but when I try to run it I get an error like this: freeglut (./assignment1): OpenGL GLX extension not supported by display ':1.0'. What's going on? When using an X based system, you need the GLX extension to be present to run OpenGL programs. The vnc server installed on the myth computers doesn't support this. If you have an X server installed locally, you can forward X (including GLX) through your ssh session by adding the -Y option to your ssh command. On Mac you can use their X11 server, you'll just need to install it, run it, and then ssh using the -Y option. Then, any X program you run remotely will display locally. On Windows you need to install an X server. One free one comes from cygwin (cygwin.com). See [http://x.cygwin.com/docs/ug/setup-cygwin-x-installing.html Installing Cygwin/X] for instructions on installing and using it. Note you'll have to install the version of the server with GLX support (labelled experimental, but seems to work well). You may also have to fiddle with the startx script to get it to start the correct X server. Needless to say, this can be a lot of trouble. We encourage you to develop on your personal computer if possible.