CE325: 3D Computer Graphics

Laboratory Session 1

The purpose of the lab session is very simple:

If you are an experienced Linux user, this entire session should take only about half an hour — but please do it anyway.

You should work through the following stages.

  1. If your machine isn't already running Linux, re-boot it to do so and log in. The machines are set up so that the default window manager is fairly similar to Windows, so you should find it reasonably straightforward to use — though there are subtle differences.

  2. Although it is possible to use Linux in a similar way to Windows, most users learn that the most efficient way to use it is via the command line. So bring up a terminal window and be prepared to type commands into it.

  3. It's a good idea to create a directory for your CE325 labs and do your work within it:

      mkdir ce325
      cd ce325
    

  4. Download into your CE325 directory copies of:

    You will have to rename Makefile.txt to Makefile before using it: this is because the web-server refuses to serve files without a filetype. The Unix rename command is called mv, so a suitable incantation is

      mv -i Makefile.txt Makefile
    

    Here, the -i qualifier makes mv ask for confirmation before overwriting an existing file with the one you're renaming. If you don't use the qualifier, mv will silently do what you have told it. In fact, that's a feature of Linux in particular and Unix in general: it normally does what you tell it, even if what you tell it is stupid. Experienced users like this.

  5. Compile and run the program by typing:

      make
      ./opengl-01
    

    It should pop up a black window, just as when demonstrated in lectures. There is no interaction with this window set up, so you have to kill the program by typing ^C (control-C) in the terminal window from which you ran it. If you don't understand why you have to prefix the last command with ./ and want to find out, speak to a demonstrator.

  6. The final step is simply to modify opengl-01.c to become opengl-03.c, and then to build it. To do that, you will have to edit both Makefile and opengl-01.c — this should give you enough familiarity with the tools we shall require in the remainder of these lab sessions.

    You will find the source code of opengl-03.c linked to from the CE325 home page. You can, of course, just cut-and-paste the code into the editor window; but that means you don't get to learn how to use the editor properly and will slow you down in the future.

    The editor you're recommended to use is Emacs. Although it has been around for a long time and has a reputation for being somewhat baroque, Emacs is a excellent programmer's editor with syntax highlighting and a number of other good features. Moreover, I shall show you how to use a symbolic debugger in Emacs in lectures, which should greatly speed up any debugging you have to do. So please start up Emacs by finding it in one of the menus or by typing

      emacs &
    
    in your terminal window. (The trailing & runs it "in the background" so that you can carry on entering commands into the window.)

    Emacs will normally start up with a window that is 80 columns wide. Feel free to make it longer but please do not make it wider. When you come to submit your assignments for this module, there will be constraints on the way you lay out your code, the principal one being that its lines have to be no longer than 80 characters — so you might as well start getting used to working that way now. In any case, this makes it easier to put your browser window alongside the Emacs one.

    When you have created opengl-03.c and edited the Makefile, compile it and run the resulting executable — you should be able to see how to do that from above. Then simply show off your good work to a demonstrator and you are free to leave.

A Note for MacOS Users

If you have a Mac and would like to do OpenGL work on it, there are some minor differences to the locations of include files and the compile commands stored in the Makefile; feel free to download Mac versions of opengl-01.c and Makefile. Note that you will still have to submit code that compiles and runs on Linux for your assignments.


© Adrian F. Clark 2010-11