1 /***********************************************************
2 * Copyright (C) 1997, Be Inc. All rights reserved.
6 * DESCRIPTION: convert display string into a Be options variable
7 ***********************************************************/
9 /***********************************************************
11 ***********************************************************/
16 #include "glutState.h"
18 /***********************************************************
19 * FUNCTION: glutInitDisplayString
21 * DESCRIPTION: sets the display string variable
22 ***********************************************************/
24 glutInitDisplayString(const char *string
)
26 if (gState
.displayString
) {
27 free(gState
.displayString
);
30 gState
.displayString
= strdup(string
);
31 if (!gState
.displayString
)
32 __glutFatalError("out of memory.");
34 gState
.displayString
= NULL
;
37 /***********************************************************
38 * FUNCTION: __glutConvertDisplayModeFromString
40 * DESCRIPTION: converts the current display mode into a BGLView
41 * display mode, printing warnings as appropriate.
43 * PARAMETERS: if options is non-NULL, the current display mode is
46 * RETURNS: 1 if the current display mode is possible, else 0
47 ***********************************************************/
48 int __glutConvertDisplayModeFromString(unsigned long *options
) {
49 ulong newoptions
= BGL_DOUBLE
;
50 gState
.swapHack
= true; // assume single buffered
52 char *word
= strtok(gState
.displayString
, " \t");
54 char *cstr
= strpbrk(word
, "=><!~");
57 // this is the most minimal possible parser. scan for
58 // options that we support, and add them to newoptions
59 // this will certainly cause it to accept things that we
60 // don't actually support, but if we don't support it, the
61 // program's probably not going to work anyway.
62 if(!strcmp(word
, "alpha")) {
63 newoptions
|= BGL_ALPHA
;
64 } else if((!strcmp(word
, "acc")) || (!strcmp(word
, "acca"))) {
65 newoptions
|= BGL_ACCUM
;
66 } else if(!strcmp(word
, "depth")) {
67 newoptions
|= BGL_DEPTH
;
68 } else if(!strcmp(word
, "double")) {
69 gState
.swapHack
= false;
70 } else if(!strcmp(word
, "stencil")) {
71 newoptions
|= BGL_STENCIL
;
73 } while((word
= strtok(0, " \t")) != 0);
76 *options
= newoptions
;
78 return 1; // assume we support it