aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/extras/Mesa_6.4.2/src/glut/beos/glutDstr.cpp
blob: 281a039701775f24163853c33e1c27270b5e6f64 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/***********************************************************
 *      Copyright (C) 1997, Be Inc.  Copyright (C) 1999, Jake Hamby.
 *
 * This program is freely distributable without licensing fees
 * and is provided without guarantee or warrantee expressed or
 * implied. This program is -not- in the public domain.
 *
 *
 *  FILE:	glutDstr.cpp
 *
 *	DESCRIPTION:	convert display string into a Be options variable
 ***********************************************************/

/***********************************************************
 *	Headers
 ***********************************************************/
#include <GL/glut.h>
#include <string.h>
#include <stdlib.h>
#include "glutint.h"
#include "glutState.h"

/***********************************************************
 *	FUNCTION:	glutInitDisplayString
 *
 *	DESCRIPTION:  sets the display string variable
 ***********************************************************/
void APIENTRY 
glutInitDisplayString(const char *string)
{
  if (gState.displayString) {
    free(gState.displayString);
  }
  if (string) {
    gState.displayString = strdup(string);
    if (!gState.displayString)
      __glutFatalError("out of memory.");
  } else
    gState.displayString = NULL;
}

/***********************************************************
 *	FUNCTION:	__glutConvertDisplayModeFromString
 *
 *	DESCRIPTION:  converts the current display mode into a BGLView
 *		display mode, printing warnings as appropriate.
 *
 *	PARAMETERS:	 if options is non-NULL, the current display mode is
 *		returned in it.
 *
 *	RETURNS:	1 if the current display mode is possible, else 0
 ***********************************************************/
int __glutConvertDisplayModeFromString(unsigned long *options) {
	ulong newoptions = 0;
	
	char *word = strtok(gState.displayString, " \t");
	do {
		char *cstr = strpbrk(word, "=><!~");
		if(cstr)
			*cstr = '\0';
		// this is the most minimal possible parser.  scan for
		// options that we support, and add them to newoptions
		// this will certainly cause it to accept things that we
		// don't actually support, but if we don't support it, the
		// program's probably not going to work anyway.
		if(!strcmp(word, "alpha")) {
			newoptions |= BGL_ALPHA;
		} else if((!strcmp(word, "acc")) || (!strcmp(word, "acca"))) {
			newoptions |= BGL_ACCUM;
		} else if(!strcmp(word, "depth")) {
			newoptions |= BGL_DEPTH;
		} else if(!strcmp(word, "double")) {
			newoptions |= BGL_DOUBLE;
		} else if(!strcmp(word, "stencil")) {
			newoptions |= BGL_STENCIL;
		}
	} while((word = strtok(0, " \t")) != 0);

	if (options)
		*options = newoptions;

	return 1;	// assume we support it
}