Tutorial Week 4 - Introduction To OpenGL
Tutorial Week 4 - Introduction To OpenGL
Outcome:
Know how to setup your OpenGL programming environment Compile and run sample code Understand basic building blocks of the code Modify sample code Some exercises to try out
What is OpenGL?
OpenGL is a hardware-independent software interface to graphics hardware. It consists of various commands that the user can use to generate graphical objects, and perform operations on them. However, this does not mean that one can use OpenGL to directly render highlevel models of three-dimensional objects (such as parts of body, airplanes, cars etc.). Instead, OpenGL allows one to build up desired model from a small set of geometric primitives (such as lines, points, curves, polygons etc.)
1. Download the JoglEnvironment.zip le from blackboard website. (Tutorial Week 4 Programming Resources ) 2. Unzip the le to your U: drive The zip le will expand out to provide a few .bat les compile.bat is a windows shell script to compile the OpenGL program source run.bat will execute the compiled program To ensure that the right compiler is used, and right source is being compiled, make sure that these bat les contain correct paths, and source names. 3. Search for the absolute path of the java compiler located on the machine. You can do this by searching for javac.exe le. Usually, the path would be C:\JAVAJDK\bin 4. Modify the bat les and ensure they have correct path for the Java compiler 5. Download SampleCodeJava.zip le from blackboard, and unzip them in the same folder containing bat les. 6. Modify compile.bat and run.bat les to ensure they have the correct name of sample program that you would like to try (eg. SampleJOGL) 7. compile.bat will generate the java bytecode, and run.bat will execute the program This completes the environment setup for Java. Note that in order to have the same setup working on your own personal computers, you must have Java and OpenGL installed on them before trying to compile this code. C++ Standard Visual C++ would usually have all OpenGL libraries pre-installed and setup in them. On all machines in this lab, you will not have to do anything special to compile the code. Just download the SampleCodeC++.zip from blackboard website. Unzip the code in some folder. Open the project using VC++. If there is a warning about migrating the project to new version editor, accept it. Build and run the code. This is enough for Visual Studio licensed version. On the other hand, if you happen to use Visual Studio Express Edition, there is a little amount of work required to be done. Follow the following steps: 1. Download the VSEELibraries.zip le from blackboard website and unzip them into the Visual Studio directory. 2. Copy the glud.dll le into the system folder. 3. If you are unable to copy these les due to administrative privileges, then unzip the les into a separate folder under the C: drive, and make sure that Visual studio compiler is able to see them. To do this, goto Tools>Options>Projects and Solutions> VC++ Directories. Then add the lib and include directories here. You will also have to make sure that the glut.dll is in same directory as the executable generated by the compiler.
NEHE
More explanation of these functions can be derived from the comments provided in the source code, and NEHE Lesson 01 and Lesson 02. NEHE has an excellent collection of tutorials to get you going in programming your group project. The current VC++ sample programs was adapted from NEHE website. I suggest that you experiment with a few of the tutorials and get a grasp of the essential concepts that you want incorporated into your group project early on in the semester. Follow this link for Lesson 01 to 05. The website will provide detailed explanation of each line of code. http://nehe.gamedev.net/tutorial/lessons_01__05/22004/ Once again, remember to reference particular tutorials on NEHE or any other sites which your programming codes are based on.