diff options
author | ftrapero <frantracer@gmail.com> | 2017-06-27 12:08:38 +0200 |
---|---|---|
committer | ftrapero <frantracer@gmail.com> | 2017-06-27 12:08:38 +0200 |
commit | 663631725ee2d633d9ec5821cd48953ffd188d00 (patch) | |
tree | 6d5cd671dd0fd27072661ab83a43f650295a980d /src/glut/beos/glutDstr.cpp | |
download | nx-libs-663631725ee2d633d9ec5821cd48953ffd188d00.tar.gz nx-libs-663631725ee2d633d9ec5821cd48953ffd188d00.tar.bz2 nx-libs-663631725ee2d633d9ec5821cd48953ffd188d00.zip |
Squashed 'nx-X11/extras/Mesa_6.4.2/' content from commit 475b1f7
git-subtree-dir: nx-X11/extras/Mesa_6.4.2
git-subtree-split: 475b1f7b56fa36ef4f3b22a749f88a98ddc0d502
Diffstat (limited to 'src/glut/beos/glutDstr.cpp')
-rw-r--r-- | src/glut/beos/glutDstr.cpp | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/src/glut/beos/glutDstr.cpp b/src/glut/beos/glutDstr.cpp new file mode 100644 index 000000000..281a03970 --- /dev/null +++ b/src/glut/beos/glutDstr.cpp @@ -0,0 +1,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 +} |