Fix invalid enums passed to MapBuffer
[mesa.git] / src / glut / dos / util.c
1 /*
2 * DOS/DJGPP Mesa Utility Toolkit
3 * Version: 1.0
4 *
5 * Copyright (C) 2005 Daniel Borca All Rights Reserved.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * DANIEL BORCA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
21 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
25
26 #include "internal.h"
27
28
29 extern GLUTStrokeFont glutStrokeRoman, glutStrokeMonoRoman;
30 extern GLUTBitmapFont glutBitmap8By13, glutBitmap9By15, glutBitmapTimesRoman10, glutBitmapTimesRoman24, glutBitmapHelvetica10, glutBitmapHelvetica12, glutBitmapHelvetica18;
31
32 /* To get around the fact that DJGPP DXEs only allow functions
33 to be exported and no data addresses (as Unix DSOs support), the
34 GLUT API constants such as GLUT_STROKE_ROMAN have to get passed
35 through a case statement to get mapped to the actual data structure
36 address. */
37 void *
38 _glut_font (void *font)
39 {
40 switch ((int)font) {
41 case (int)GLUT_STROKE_ROMAN:
42 return &glutStrokeRoman;
43 case (int)GLUT_STROKE_MONO_ROMAN:
44 return &glutStrokeMonoRoman;
45 case (int)GLUT_BITMAP_9_BY_15:
46 return &glutBitmap9By15;
47 case (int)GLUT_BITMAP_8_BY_13:
48 return &glutBitmap8By13;
49 case (int)GLUT_BITMAP_TIMES_ROMAN_10:
50 return &glutBitmapTimesRoman10;
51 case (int)GLUT_BITMAP_TIMES_ROMAN_24:
52 return &glutBitmapTimesRoman24;
53 case (int)GLUT_BITMAP_HELVETICA_10:
54 return &glutBitmapHelvetica10;
55 case (int)GLUT_BITMAP_HELVETICA_12:
56 return &glutBitmapHelvetica12;
57 case (int)GLUT_BITMAP_HELVETICA_18:
58 return &glutBitmapHelvetica18;
59 default:
60 if ((font == &glutStrokeRoman) ||
61 (font == &glutStrokeMonoRoman) ||
62 (font == &glutBitmap9By15) ||
63 (font == &glutBitmap8By13) ||
64 (font == &glutBitmapTimesRoman10) ||
65 (font == &glutBitmapTimesRoman24) ||
66 (font == &glutBitmapHelvetica10) ||
67 (font == &glutBitmapHelvetica12) ||
68 (font == &glutBitmapHelvetica18)) {
69 return font;
70 }
71 _glut_fatal("bad font!");
72 return NULL;
73 }
74 }