/* * ex2.c -- A more complex example program for SOOGL. * * Draw a teapot in the middle of the screen, with two lights. * * Copyright (c) Blair MacIntyre, The Georgia Institute of Technology, 1999. */ #include "soogl.h" #include int main(int argc, char **argv) { int camera, window, root, lightAmb, light1, group1, group2, teapot, sphere; /* initialize the retained mode package, including initializing GLUT */ sooglInit(&argc, argv); /* create a window */ glutInitWindowPosition(10, 10); glutInitWindowSize(500, 500); window = glutCreateWindow("Lit teapot"); /* create a camera */ camera = sooglNewCamera(0.0, 0.0, 30.0, /* eye is at (0,0,30) */ 0.0, 0.0, 0.0, /* center is at (0,0,0) */ 0.0, 1.0, 0.0, /* up is in positive Y direction */ 40.0, /* field of view in degree */ 1.0, /* aspect ratio */ 1.0, /* Z near */ 100.0);/* Z far */ /* create a root object, using this window and camera, and using a viewport that covers the entire window */ root = sooglNewRoot(window, camera); sooglSetShadeModel(root, SOOGL_SMOOTH_SHADE); /* create an ambient light */ lightAmb = sooglNewAmbient(0.2, 0.2, 0.2); sooglAddChild(root, lightAmb); /*********************** * Create two point light sources, with little icons for them (small spheres) ***********************/ /* Add a group to the root. */ group1 = sooglNewGroup(); sooglAddChild(root, group1); /* Next add a small green sphere to group1, and translate it to (6,3,3) */ sphere = sooglNewSphere(0.25, 10); sooglTranslate(sphere, 6, 3.0, 3.0); sooglSetMaterial(sphere, 0.2, 1.0, 0.2); /* Next, add a green point light at (6,3,3) */ light1 = sooglNewPositionalLight(0.6, 1.5, 0.4, /* green-tinted */ 6.0, 3.0, 3.0, /* out on the x axis */ 1.0, 0.0, 0.0); sooglAddChild(group1, sphere); sooglAddChild(group1, light1); /* Create a red point light source that is on the opposite side * of the teapot. */ sphere = sooglNewSphere(0.25, 10); sooglTranslate(sphere, -6.0, -3.0, -3.0); sooglSetMaterial(sphere, 1.0, 0.2, 0.2); light1 = sooglNewPositionalLight(1.5, 0.4, 0.6, /* red-tinted */ -6.0, -3.0, -3.0, /* out on the x axis */ 1.0, 0.0, 0.0); sooglAddChild(group1, sphere); sooglAddChild(group1, light1); /****************** * Add a group containing a teapot to the root ******************/ /* First, create a group */ group2 = sooglNewGroup(); sooglAddChild(root, group2); teapot = sooglNewTeapot(4.0); sooglRotateY(teapot, -45.0); sooglAddChild(group2, teapot); /* go! */ glutMainLoop(); return 0; /* ANSI C requires main to return int. */ }