File: HsGLUT.c

package info (click to toggle)
haskell-glut 2.1.1.1-2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 664 kB
  • ctags: 34
  • sloc: sh: 2,854; haskell: 2,297; makefile: 79; ansic: 53
file content (64 lines) | stat: -rw-r--r-- 1,988 bytes parent folder | download | duplicates (3)
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
/* -----------------------------------------------------------------------------
 *
 * Module      :  C support for Graphics.UI.GLUT.Fonts
 * Copyright   :  (c) Sven Panne 2002-2005
 * License     :  BSD-style (see the file libraries/GLUT/LICENSE)
 *
 * Maintainer  :  sven.panne@aedion.de
 * Stability   :  provisional
 * Portability :  portable
 *
 * -------------------------------------------------------------------------- */

#include "HsGLUT.h"

/* needed only for GLUT_GET_PROC_ADDRESS_IS_BROKEN */
#include "HsGLUTConfig.h"

#if (FREEGLUT || GLUT_API_VERSION >= 5) && GLUT_GET_PROC_ADDRESS_IS_BROKEN
#include <string.h>
#endif

void*
hs_GLUT_marshalBitmapFont(int fontID)
{
  switch (fontID) {
  case 0 : return GLUT_BITMAP_8_BY_13;
  case 1 : return GLUT_BITMAP_9_BY_15;
  case 2 : return GLUT_BITMAP_TIMES_ROMAN_10;
  case 3 : return GLUT_BITMAP_TIMES_ROMAN_24;
  case 4 : return GLUT_BITMAP_HELVETICA_10;
  case 5 : return GLUT_BITMAP_HELVETICA_12;
  case 6 : return GLUT_BITMAP_HELVETICA_18;
  }
  return (void*)0;
}

void*
hs_GLUT_marshalStrokeFont(int fontID)
{
  switch (fontID) {
  case 0 : return GLUT_STROKE_ROMAN;
  case 1 : return GLUT_STROKE_MONO_ROMAN;
  }
  return (void*)0;
}

/* procName is really a const char*, but currently we can't specify this in
   Haskell's FFI and consequently get a warning from the C compiler. */
void*
hs_GLUT_getProcAddress(char *procName)
{
#if (FREEGLUT || GLUT_API_VERSION >= 5)
#if GLUT_GET_PROC_ADDRESS_IS_BROKEN
  /* There are a few typos/omissions in freeglut 2.20 */
  if (strcmp(procName, "glutWireCylinder"         ) == 0) return (void*)glutWireCylinder;
  if (strcmp(procName, "glutSolidCylinder"        ) == 0) return (void*)glutSolidCylinder;
  if (strcmp(procName, "glutWireSierpinskiSponge" ) == 0) return (void*)glutWireSierpinskiSponge;
  if (strcmp(procName, "glutSolidSierpinskiSponge") == 0) return (void*)glutSolidSierpinskiSponge;
#endif
  return glutGetProcAddress(procName);
#else
  return (void*)0;
#endif
}