1 /***********************************************************
2 * Copyright (C) 1997, Be Inc. Copyright (C) 1999, Jake Hamby.
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.
11 * DESCRIPTION: convert display string into a Be options variable
12 ***********************************************************/
14 /***********************************************************
16 ***********************************************************/
21 #include "glutState.h"
23 /***********************************************************
24 * FUNCTION: glutInitDisplayString
26 * DESCRIPTION: sets the display string variable
27 ***********************************************************/
29 glutInitDisplayString(const char *string
)
31 if (gState
.displayString
) {
32 free(gState
.displayString
);
35 gState
.displayString
= strdup(string
);
36 if (!gState
.displayString
)
37 __glutFatalError("out of memory.");
39 gState
.displayString
= NULL
;
42 /***********************************************************
43 * FUNCTION: __glutConvertDisplayModeFromString
45 * DESCRIPTION: converts the current display mode into a BGLView
46 * display mode, printing warnings as appropriate.
48 * PARAMETERS: if options is non-NULL, the current display mode is
51 * RETURNS: 1 if the current display mode is possible, else 0
52 ***********************************************************/
53 int __glutConvertDisplayModeFromString(unsigned long *options
) {
56 char *word
= strtok(gState
.displayString
, " \t");
58 char *cstr
= strpbrk(word
, "=><!~");
61 // this is the most minimal possible parser. scan for
62 // options that we support, and add them to newoptions
63 // this will certainly cause it to accept things that we
64 // don't actually support, but if we don't support it, the
65 // program's probably not going to work anyway.
66 if(!strcmp(word
, "alpha")) {
67 newoptions
|= BGL_ALPHA
;
68 } else if((!strcmp(word
, "acc")) || (!strcmp(word
, "acca"))) {
69 newoptions
|= BGL_ACCUM
;
70 } else if(!strcmp(word
, "depth")) {
71 newoptions
|= BGL_DEPTH
;
72 } else if(!strcmp(word
, "double")) {
73 newoptions
|= BGL_DOUBLE
;
74 } else if(!strcmp(word
, "stencil")) {
75 newoptions
|= BGL_STENCIL
;
77 } while((word
= strtok(0, " \t")) != 0);
80 *options
= newoptions
;
82 return 1; // assume we support it