/* * ex1.c -- An example program for SOOGL. * * Draw a simple sphere in the middle of the screen. The lights and camera * are positioned absolutely (there are no transformations applied to them). * * 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, group, sphere; /* initialize the package */ sooglInit(&argc, argv); /* create a window */ glutInitWindowPosition(10, 10); glutInitWindowSize(500, 500); window = glutCreateWindow("SOOGL Example Program"); /* 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. */ root = sooglNewRoot(window, camera); /* create an ambient light and add it to the scene graph. */ lightAmb = sooglNewAmbient(0.2, 0.2, 0.2); sooglAddChild(root, lightAmb); /* create a directional light and add it to the scene graph. */ light1 = sooglNewDirectionalLight(0.4, 1.0, 0.4, /* green-tinted */ 6.0, 0.0, 0.0); /* from the x axis */ light1 = sooglNewPositionalLight(0.4, 1.0, 0.4, /* green-tinted */ 6.0, 0.0, 0.0, /* on the x axis */ 1.0, 0.0, 0.0); sooglAddChild(root, light1); /* create a group and add it to the root. */ group = sooglNewGroup(); sooglAddChild(root, group); /* create a simple sphere with some properties, and put it in the group. */ sphere = sooglNewSphere(4.0, 13); sooglSetShadeModel(sphere, SOOGL_SMOOTH_SHADE); sooglSetMaterial(sphere, 1.0, 0.5, 0.5); sooglAddChild(group, sphere); /* go! */ glutMainLoop(); return 0; /* ANSI C requires main to return int. */ }