Doxygen Source Code Documentation
glut_init.c File Reference
#include <stdlib.h>#include <string.h>#include <stdio.h>#include <X11/Xlib.h>#include <GL/glut.h>#include "glutint.h"Go to the source code of this file.
| Functions | |
| void | __glutOpenXConnection (char *display) | 
| void | __glutInitTime (struct timeval *beginning) | 
| void | removeArgs (int *argcp, char **argv, int numToRemove) | 
| void | glutInit (int *argcp, char **argv) | 
| void | glutInitWindowPosition (int x, int y) | 
| void | glutInitWindowSize (int width, int height) | 
| void | glutInitDisplayMode (unsigned int mask) | 
| Variables | |
| char * | __glutProgramName = NULL | 
| int | __glutArgc = 0 | 
| char ** | __glutArgv = NULL | 
| char * | __glutGeometry = NULL | 
| Display * | __glutDisplay = NULL | 
| int | __glutScreen | 
| Window | __glutRoot | 
| int | __glutScreenHeight | 
| int | __glutScreenWidth | 
| GLboolean | __glutIconic = GL_FALSE | 
| GLboolean | __glutDebug = GL_FALSE | 
| unsigned int | __glutDisplayMode | 
| int | __glutConnectionFD | 
| XSizeHints | __glutSizeHints = {0} | 
| int | __glutInitWidth = 300 | 
| int | __glutInitHeight = 300 | 
| int | __glutInitX = -1 | 
| int | __glutInitY = -1 | 
| GLboolean | __glutForceDirect = GL_FALSE | 
| GLboolean | __glutTryDirect = GL_TRUE | 
| Atom | __glutWMDeleteWindow | 
| Bool | synchronize = False | 
Function Documentation
| 
 | 
| 
 Definition at line 80 of file glut_init.c. References GETTIMEOFDAY. Referenced by glutGet(), and glutInit(). 
 00081 {
00082   static int beenhere = 0;
00083   static struct timeval genesis;
00084 
00085   if (!beenhere) {
00086     GETTIMEOFDAY(&genesis);
00087     beenhere = 1;
00088   }
00089   *beginning = genesis;
00090 }
 | 
| 
 | 
| 
 Definition at line 55 of file glut_init.c. References __glutConnectionFD, __glutDisplay, __glutFatalError(), __glutRoot, __glutScreen, __glutScreenHeight, __glutScreenWidth, __glutWMDeleteWindow, and display. Referenced by __glutCreateWindow(), glutCreateMenu(), and glutInit(). 
 00056 {
00057   int errorBase, eventBase;
00058 
00059   __glutDisplay = XOpenDisplay(display);
00060   if (!__glutDisplay)
00061     __glutFatalError("could not open display: %s",
00062       XDisplayName(display));
00063   if (synchronize)
00064     XSynchronize(__glutDisplay, True);
00065   if (!glXQueryExtension(__glutDisplay, &errorBase, &eventBase))
00066     __glutFatalError(
00067       "OpenGL GLX extension not supported by display: %s",
00068       XDisplayName(display));
00069   __glutScreen = DefaultScreen(__glutDisplay);
00070   __glutRoot = RootWindow(__glutDisplay, __glutScreen);
00071   __glutScreenWidth = DisplayWidth(__glutDisplay, __glutScreen);
00072   __glutScreenHeight = DisplayHeight(__glutDisplay,
00073     __glutScreen);
00074   __glutConnectionFD = ConnectionNumber(__glutDisplay);
00075   __glutWMDeleteWindow = XInternAtom(__glutDisplay,
00076     "WM_DELETE_WINDOW", False);
00077 }
 | 
| 
 | ||||||||||||
| 
 Definition at line 105 of file glut_init.c. References __glutArgc, __glutArgv, __glutDebug, __glutDisplay, __glutFatalError(), __glutForceDirect, __glutIconic, __glutInitHeight, __glutInitTime(), __glutInitWidth, __glutInitX, __glutInitY, __glutOpenXConnection(), __glutProgramName, __glutScreen, __glutSizeHints, __glutTryDirect, __glutWarning(), display, flags, glutInitWindowPosition(), glutInitWindowSize(), i, malloc, removeArgs(), and synchronize. 
 00106 {
00107   char *display = NULL;
00108   char *str;
00109   struct timeval unused;
00110   int i;
00111 
00112   if (__glutDisplay) {
00113     __glutWarning("glutInit being called a second time.");
00114     return;
00115   }
00116   /* determine temporary program name */
00117   str = strrchr(argv[0], '/');
00118   if (str == NULL) {
00119     __glutProgramName = argv[0];
00120   } else {
00121     __glutProgramName = str + 1;
00122   }
00123 
00124   /* make private copy of command line arguments */
00125   __glutArgc = *argcp;
00126   __glutArgv = (char **) malloc(__glutArgc * sizeof(char *));
00127   if (!__glutArgv)
00128     __glutFatalError("out of memory.");
00129   for (i = 0; i < __glutArgc; i++) {
00130     __glutArgv[i] = strdup(argv[i]);
00131     if (!__glutArgv[i])
00132       __glutFatalError("out of memory.");
00133   }
00134 
00135   /* determine permanent program name */
00136   str = strrchr(__glutArgv[0], '/');
00137   if (str == NULL) {
00138     __glutProgramName = __glutArgv[0];
00139   } else {
00140     __glutProgramName = str + 1;
00141   }
00142 
00143   /* parse arguments for standard options */
00144   for (i = 1; i < __glutArgc; i++) {
00145     if (!strcmp(__glutArgv[i], "-display")) {
00146       if (++i >= __glutArgc) {
00147         __glutFatalError(
00148           "follow -display option with X display name.");
00149       }
00150       display = __glutArgv[i];
00151       removeArgs(argcp, &argv[1], 2);
00152     } else if (!strcmp(__glutArgv[i], "-geometry")) {
00153       int flags, x, y, width, height;
00154 
00155       if (++i >= __glutArgc) {
00156         __glutFatalError(
00157           "follow -geometry option with geometry parameter.");
00158       }
00159       /* Fix bogus "{width|height} may be used before set"
00160          warning */
00161       width = 0;
00162       height = 0;
00163 
00164       flags = XParseGeometry(__glutArgv[i], &x, &y,
00165         (unsigned int *) &width, (unsigned int *) &height);
00166       if (WidthValue & flags) {
00167         /* Careful because X does not allow zero or negative
00168            width windows */
00169         if (width > 0)
00170           __glutInitWidth = width;
00171       }
00172       if (HeightValue & flags) {
00173         /* Careful because X does not allow zero or negative
00174            height windows */
00175         if (height > 0)
00176           __glutInitHeight = height;
00177       }
00178       glutInitWindowSize(__glutInitWidth, __glutInitHeight);
00179       if (XValue & flags) {
00180         if (XNegative & flags)
00181           x = DisplayWidth(__glutDisplay, __glutScreen) +
00182             x - __glutSizeHints.width;
00183         /* Play safe: reject negative X locations */
00184         if (x >= 0)
00185           __glutInitX = x;
00186       }
00187       if (YValue & flags) {
00188         if (YNegative & flags)
00189           y = DisplayHeight(__glutDisplay, __glutScreen) +
00190             y - __glutSizeHints.height;
00191         /* Play safe: reject negative Y locations */
00192         if (y >= 0)
00193           __glutInitY = y;
00194       }
00195       glutInitWindowPosition(__glutInitX, __glutInitY);
00196       removeArgs(argcp, &argv[1], 2);
00197     } else if (!strcmp(__glutArgv[i], "-direct")) {
00198       if (!__glutTryDirect)
00199         __glutFatalError(
00200           "cannot force both direct and indirect rendering.");
00201       __glutForceDirect = GL_TRUE;
00202       removeArgs(argcp, &argv[1], 1);
00203     } else if (!strcmp(__glutArgv[i], "-indirect")) {
00204       if (__glutForceDirect)
00205         __glutFatalError(
00206           "cannot force both direct and indirect rendering.");
00207       __glutTryDirect = GL_FALSE;
00208       removeArgs(argcp, &argv[1], 1);
00209     } else if (!strcmp(__glutArgv[i], "-iconic")) {
00210       __glutIconic = GL_TRUE;
00211       removeArgs(argcp, &argv[1], 1);
00212     } else if (!strcmp(__glutArgv[i], "-gldebug")) {
00213       __glutDebug = GL_TRUE;
00214       removeArgs(argcp, &argv[1], 1);
00215     } else if (!strcmp(__glutArgv[i], "-sync")) {
00216       synchronize = GL_TRUE;
00217       removeArgs(argcp, &argv[1], 1);
00218     } else {
00219       /* once unknown option encountered, stop command line
00220          processing */
00221       break;
00222     }
00223   }
00224   __glutOpenXConnection(display);
00225   __glutInitTime(&unused);
00226 }
 | 
| 
 | 
| 
 Definition at line 257 of file glut_init.c. References __glutDisplayMode. 
 00258 {
00259   __glutDisplayMode = mask;
00260 }
 | 
| 
 | ||||||||||||
| 
 Definition at line 229 of file glut_init.c. References __glutInitX, __glutInitY, and __glutSizeHints. Referenced by glutInit(). 
 00230 {
00231   __glutInitX = x;
00232   __glutInitY = y;
00233   if (x >= 0 && y >= 0) {
00234     __glutSizeHints.x = x;
00235     __glutSizeHints.y = y;
00236     __glutSizeHints.flags |= USPosition;
00237   } else {
00238     __glutSizeHints.flags &= ~USPosition;
00239   }
00240 }
 | 
| 
 | ||||||||||||
| 
 Definition at line 243 of file glut_init.c. References __glutInitHeight, __glutInitWidth, and __glutSizeHints. Referenced by glutInit(). 
 00244 {
00245   __glutInitWidth = width;
00246   __glutInitHeight = height;
00247   if (width > 0 && height > 0) {
00248     __glutSizeHints.width = width;
00249     __glutSizeHints.height = height;
00250     __glutSizeHints.flags |= USSize;
00251   } else {
00252     __glutSizeHints.flags &= ~USSize;
00253   }
00254 }
 | 
| 
 | ||||||||||||||||
| 
 Definition at line 93 of file glut_init.c. References i. Referenced by glutInit(). 
 | 
Variable Documentation
| 
 | 
| 
 Definition at line 18 of file glut_init.c. Referenced by glutInit(). | 
| 
 | 
| 
 Definition at line 19 of file glut_init.c. Referenced by glutInit(). | 
| 
 | 
| 
 Definition at line 30 of file glut_init.c. Referenced by __glutOpenXConnection(). | 
| 
 | 
| 
 Definition at line 27 of file glut_init.c. Referenced by glutInit(). | 
| 
 | 
| 
 Definition at line 21 of file glut_init.c. Referenced by __glutOpenXConnection(), and glutInit(). | 
| 
 | 
| Initial value: Definition at line 28 of file glut_init.c. Referenced by glutInitDisplayMode(). | 
| 
 | 
| 
 Definition at line 34 of file glut_init.c. Referenced by glutInit(). | 
| 
 | 
| 
 Definition at line 20 of file glut_init.c. | 
| 
 | 
| 
 Definition at line 26 of file glut_init.c. Referenced by glutInit(). | 
| 
 | 
| 
 Definition at line 32 of file glut_init.c. Referenced by glutInit(), and glutInitWindowSize(). | 
| 
 | 
| 
 Definition at line 32 of file glut_init.c. Referenced by glutInit(), and glutInitWindowSize(). | 
| 
 | 
| 
 Definition at line 33 of file glut_init.c. Referenced by glutInit(), and glutInitWindowPosition(). | 
| 
 | 
| 
 Definition at line 33 of file glut_init.c. Referenced by glutInit(), and glutInitWindowPosition(). | 
| 
 | 
| 
 Definition at line 17 of file glut_init.c. Referenced by glutInit(). | 
| 
 | 
| 
 Definition at line 23 of file glut_init.c. Referenced by __glutOpenXConnection(). | 
| 
 | 
| 
 Definition at line 22 of file glut_init.c. Referenced by __glutOpenXConnection(), and glutInit(). | 
| 
 | 
| 
 Definition at line 24 of file glut_init.c. Referenced by __glutOpenXConnection(). | 
| 
 | 
| 
 Definition at line 25 of file glut_init.c. Referenced by __glutOpenXConnection(). | 
| 
 | 
| 
 Definition at line 31 of file glut_init.c. Referenced by glutInit(), glutInitWindowPosition(), and glutInitWindowSize(). | 
| 
 | 
| 
 Definition at line 35 of file glut_init.c. Referenced by glutInit(). | 
| 
 | 
| 
 Definition at line 36 of file glut_init.c. Referenced by __glutOpenXConnection(). | 
| 
 | 
| 
 Definition at line 38 of file glut_init.c. Referenced by glutInit(). | 
 
                             
                             
                             
                             
                             
                             
                             
                             
                             
                             
                             
                             
 
 
 
 
       
	   
	   
	   
	  