Contents


Exercise: OpenGL and JOGL

  1. Hello JOGL:
    1. Copy and paste the JOGL program template into your own project and compile and run it.
      You may as well use C++ combined with GLUT or Qt.
      The result should be a black window.


  2. Points and Lines:
    1. Draw a point with JOGL and try to change its size.
      Determine the min and max point-size via GL.GL_POINT_SIZE_RANGE and try them.
    2. Draw a white triangle on a black background using lines.
    3. Draw the house using GL_LINE_STRIP (in one stroke).
    4. Draw the house with wide and stippled lines.
    5. Re-draw the house in 3D.
    6. Cut out a door and windows, by modeling around them.
    7. Experiment with different camera positions.
    8. Turn anti-aliasing on. Does it make a difference?
    9. Turn fog on. What happens when you change the fog color?


  3. Polygons:
    1. Draw a 2D house using GL.GL_POLYGON.
    2. Remove the inner edges of the house applying glEdgeFlag().
    3. Program an algorithm (using Math.sin(), etc.) that draws a polygon-circle approximation made of a variable number triangle-segments using GL_TRIANGLE_FAN.
    4. Fill the circle with white color.
    5. Draw your 3D house using polygon primitves and fill it with white color.


  4. Stippled Polygon Pattern:
    1. Display a stipple pattern for polygons as "wallpaper".
    2. What happens, if a non-convex or non-simple polygon is filled with a stipple pattern?
    3. Invent YOUR OWN 32 by 32 stipple pattern for polygons and show it with a "wallpaper" program.


  5. Animation:
    1. Moving Camera: Enable interactive camera movements, so that you can fly through the 3D-house.
    2. Program an algorithm that draws a wire-frame sphere approximation.
    3. Animate the wire-frame sphere, it may change in radius, position, resolution, rotation angle and shape.
    4. Create an invisible cube with 7 sphere moving randomly inside. The sphere should bounce form the walls and collide with each other.




  6. Color and Transparency:
    1. Colored Circles: Draw three intersecting circles with the primary colors. They should have different z-values. Change the drawing order.
    2. Colorize your 3D-Spheres.
    3. Gradient Fill: Draw a color circle with the primary colors and a gradient circular fill. Try GL_FLAT and GL_SMOOTH as shading model. Assign different colors to the vertices on the circle not only to the center (as in the example image).
    4. Try flat and smooth shading on your 3D-Sphere.
    5. Blending: Draw three colored circles with the primary colors intersecting and blending each other. The intersection regions should show the secondary colors. Use: glClearColor(), glBlendFuncSeparate() and do not forget to enable blending. Why are the secondary colors less bright?
    6. Look at the circles from front and back. Why are they rendered differently? Can you do something to make them look the same independent from where the camera is?
    7. Make your sphere slightly transparent and observe it from different directions.




  7. Z-Buffer and Blending:
    1. Fill the 3D house with color. Try enable/disable of the depth test and blending:
       gl.glEnable( GL.GL_DEPTH_TEST );
       gl.glEnable( GL.GL_BLEND );
      
    2. Depth Test and Blending: Insert a colored glass pane into the window and door of your 3D house. Put an object (e.g. a wire-frame sphere) into the house that can be seen through the window. How do GL_DEPTH_TEST and GL_BLEND influence each other (look through the window at the door and vice versa, then enter the house)?
    3. Polygons Offset: Draw your 3D-sphere two times on top of each other, once in GL_LINE and once in GL_FILL mode. Highlight the lines using glPolygonOffset().


  8. Transformations:
    1. Moving Object: Change the interaction in a way that the camera stays fixed but the object turns setting "operateOnModel". Look at the code in "View.java", what happens when you try to move and why?
    2. Use gluLookAt() instead of "operateOnModel" to look at your 3D-House (try the wire-frame model first) from different directions.
      Comment out the line where the camera is set, use and modify the LookAt function instead:
       // Viewing Transformation.
       //view.setCamera( gl );
       setCameraLookAt( glu );
      
    3. Try different Up-vectors. How should the interaction be implemented to work with gluLookAt()?
    4. Projections: Make your 3D-house very long in z-direction. Investigate the difference between an orthographic and a perspective projection.
    5. Translation and Rotation: Let your colorful 3D-house rotate around all three principle axes with different velocities and move it on some path using glRotate() and glTranslate().


  9. Matrix Stacks:
    1. Solar System: Draw a solar system with a sun and one planet which has a moon, using your sphere function. Group the different Elements as you would in a 3D-Modeling Software (as Maya) using push/popMatrix(). Translate all objects along the X-axis than rotate. Planets should stay in the X-Z-plane, moons can have any orbit you like.
      Use a perspective projection and look at solar system from a distance.
    2. Moving Planets: Animate the planets and Moons in your solar system.
      Planets should have orbits around the sun and moons around the planet they belong to.
    3. Depth Test: Enable the depth test, so that a moon disappears behind a planet which in turn disappears behind the sun when it is appropriate.
    4. Add one more planet with two moons and a little satellite that is circling one of the moons to the solar system.


  10. Display Lists:
    1. Wrap the sun, planet and moon sphere drawings into display lists. Does the performance improve?
    2. Display a lot of rotating 3D-houses. Wrap the house model in a display list (you may include the tanslation using nested lists). Compare the performance (rotation speed with max fps in the animator) with and without display lists.


  11. GLU and GLUT:
    1. Round Planets: Change the planets in your solar system into colored wire-frame GLU-spheres. Are they drawn faster than your handmade spheres?
    2. Teapot: Display the GLUT Utah teapot and make it turn around itself.


  12. Lighting and Material
    1. Make the celestial bodies in your solar system solid and light them properly with key, back and fill lights.
    2. Three-Point Lighting for 3D Renderings:
      The Key Light creates the subject's main illumination, and defines the most visible lighting and shadows. Create a spot light to serve as the Key. From the top view, offset the Key Light 15 to 45 degrees to the side (to the left or right) of the camera. From a side view, raise the Key Light above the camera, so that it hits your subject from about 15 to 45 degrees higher than the camera angle.
      The Fill Light softens and extends the illumination provided by the key light, and makes more of the subject visible. Fill Light can simulate light from the sky (other than the sun), secondary light sources such as table lamps, or reflected and bounced light in your scene.
      The Rim Light (also called Back Light) creates a bright line around the edge of the object, to help visually separate the object from the background.
    3. Teapot: Display the GLUT Utah teapot with white material in spectral light.
    4. Light Color: Experiment with different colors for light and teapot material.
    5. Light the teapot applying ambient and spotlight with different material for in- and outside (use glClipPlane to cut it open).




  13. Images
    1. Image: Display the Duke Image.
    2. Display of photo of yourself in openGL.
    3. Blended Image: Put the image behind red glass pane, when in front of the pane. Is there a difference?


  14. Bitmaps and Fonts
    1. Font: Write out the font from the lecture and color it nicely. :


  15. Texture
    1. Texture your 3D house.
    2. Add some (back-)ground.


  16. Particle Effects
    1. Fire and Smoke: Take the red water fountain and transform it into fire with smoke by changing the texture of a particle at some point in his lifetime.
    2. Make particles disappear be reducing their size gradually. How can the blending function be used for a similar effect?


  17. Curves and Surfaces:
    1. Parametric curve: Define a 3D parametric curve C(u) that describes a spiral with decreasing radius. Plot it (evaluate it).
    2. Bezier Curve: Draw a 2D Bezier curve with glMap1f() and glEvalCoord1f. Try to use more control points.
    3. Bezier Curve: Re-draw your curve using glMapGrid1f() and glEvalMesh1() with 20 sampling points.
    4. Bezier Surface: Draw a 3D Bezier surface with at least 12 control points.
    5. Bezier Surface: Draw a 3D Bezier surface with 5x4 control points that faces the camera.
    6. Bezier Surface:Move the control points to fold and bump your surface.


  18. Shadows
    1. Challenge: Draw a Plane under the solar-system and add shadows to the sun and the plants.