home *** CD-ROM | disk | FTP | other *** search
/ OpenGL Superbible (2nd Edition) / OpenGL SuperBible e2.iso / tools / GLUT-3.7 / LIB / GLSMAP / smap_create.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-08-12  |  1.8 KB  |  99 lines

  1.  
  2. /* Copyright (c) Mark J. Kilgard, 1998.  */
  3.  
  4. /* This program is freely distributable without licensing fees
  5.    and is provided without guarantee or warrantee expressed or
  6.    implied. This program is -not- in the public domain. */
  7.  
  8. #include <GL/glsmap.h>
  9. #include <stdlib.h>
  10.  
  11. #include "glsmapint.h"
  12.  
  13. static SphereMapMesh *
  14. createSphereMapMesh(void)
  15. {
  16.     SphereMapMesh *mesh;
  17.  
  18.     mesh = (SphereMapMesh*) malloc(sizeof(SphereMapMesh));
  19.     
  20.     mesh->steps = 8;
  21.     mesh->rings = 3;
  22.     mesh->edgeExtend = 1;
  23.  
  24.     mesh->face = NULL;
  25.     mesh->back = NULL;
  26.  
  27.     mesh->refcnt = 0;
  28.  
  29.     return mesh;
  30. }
  31.  
  32. static void
  33. refSphereMapMesh(SphereMapMesh *mesh)
  34. {
  35.     mesh->refcnt++;
  36. }
  37.  
  38. SphereMap *
  39. smapCreateSphereMap(SphereMap *shareSmap)
  40. {
  41.     SphereMap *smap;
  42.     int i;
  43.  
  44.     smap = (SphereMap*) malloc(sizeof(SphereMap));
  45.  
  46.     if (shareSmap) {
  47.         smap->mesh = shareSmap->mesh;
  48.     } else {
  49.         smap->mesh = createSphereMapMesh();
  50.     }
  51.     refSphereMapMesh(smap->mesh);
  52.  
  53.     /* Default texture objects. */
  54.     smap->smapTexObj = 1001;
  55.     for (i=0; i<6; i++) {
  56.         smap->viewTexObjs[i] = i+1002;
  57.     }
  58.     smap->viewTexObj = 1008;
  59.  
  60.     /* Default texture dimensions 64x64 */
  61.     smap->viewTexDim = 64;
  62.     smap->smapTexDim = 64;
  63.  
  64.     /* Default origin at lower left. */
  65.     smap->viewOrigin[X] = 0;
  66.     smap->viewOrigin[Y] = 0;
  67.     smap->smapOrigin[X] = 0;
  68.     smap->smapOrigin[Y] = 0;
  69.  
  70.         /* Flags. */
  71.         smap->flags = (SphereMapFlags) 0;
  72.  
  73.     /* Default eye vector. */
  74.     smap->eye[X] = 0.0;
  75.     smap->eye[Y] = 0.0;
  76.     smap->eye[Z] = -10.0;
  77.  
  78.     /* Default up vector. */
  79.     smap->up[X] = 0.0;
  80.     smap->up[Y] = 0.1;
  81.     smap->up[Z] = 0.0;
  82.  
  83.     /* Default object location vector. */
  84.     smap->obj[X] = 0.0;
  85.     smap->obj[Y] = 0.0;
  86.     smap->obj[Z] = 0.0;
  87.  
  88.     /* Default near and far clip planes. */
  89.     smap->viewNear = 0.1;
  90.     smap->viewFar = 20.0;
  91.  
  92.     smap->positionLights = NULL;
  93.     smap->drawView = NULL;
  94.  
  95.     smap->context = NULL;
  96.  
  97.     return smap;
  98. }
  99.