glut.c (1884B)
1 /* 21oct07abu 2 * 03apr08jk 3 * (c) Software Lab. Alexander Burger 4 */ 5 6 #include "../../src/pico.h" 7 8 #if defined(__APPLE__) || defined(MACOSX) 9 #include <GLUT/glut.h> 10 #include <OpenGL/glu.h> 11 #include <OpenGL/gl.h> 12 #else 13 #include <GL/glut.h> 14 #include <GL/glu.h> 15 #include <GL/gl.h> 16 #endif 17 18 #define SCL 10000.0 19 20 #define boxCnt box 21 22 int evCnt(any ex, any x) { 23 any y = EVAL(car(x)); 24 NeedNum(ex, y); 25 return unBox(y); 26 } 27 28 // (glut:Init 'arg ..) -> T 29 any Init(any ex) { 30 any x, y; 31 int i, ac = length(x = cdr(ex)); 32 char *av[ac+1]; 33 34 for (i = 0; i < ac; ++i) { 35 y = evSym(x), x = cdr(x); 36 av[i] = alloc(NULL, bufSize(y)), bufString(y, av[i]); 37 } 38 av[ac] = NULL; 39 glutInit(&ac, av); 40 for (i = 0; i < ac; ++i) 41 free(av[i]); 42 return T; 43 } 44 45 // (glut:BitmapCharacter 'fontNum 'character) -> T 46 any BitmapCharacter(any ex) { 47 void* font; 48 int fontNum; 49 int character; 50 51 fontNum = (int)evCnt(ex, cdr(ex)); 52 character = (int)evCnt(ex, cddr(ex)); 53 switch (fontNum) { 54 // These GLUT_BITMAP values are system dependent. 55 case 2: font = GLUT_BITMAP_9_BY_15; break; 56 case 3: font = GLUT_BITMAP_8_BY_13; break; 57 case 4: font = GLUT_BITMAP_TIMES_ROMAN_10; break; 58 case 5: font = GLUT_BITMAP_TIMES_ROMAN_24; break; 59 case 6: font = GLUT_BITMAP_HELVETICA_10; break; 60 case 7: font = GLUT_BITMAP_HELVETICA_12; break; 61 case 8: font = GLUT_BITMAP_HELVETICA_18; break; 62 default: font = GLUT_BITMAP_TIMES_ROMAN_24; break; 63 } 64 //printf("BitmapCharacter, font = %10p\n", font); 65 glutBitmapCharacter(font, character); 66 return T; 67 } 68 69 // (glut:StrokeCharacter 'mono 'character) -> T 70 any StrokeCharacter(any ex) { 71 void* font = GLUT_STROKE_ROMAN; 72 int mono; 73 int character; 74 75 mono = (int)evCnt(ex, cdr(ex)); // correct? - jk 76 character = (int)evCnt(ex, cddr(ex)); 77 if (mono) font = GLUT_STROKE_MONO_ROMAN; 78 glutStrokeCharacter(font, character); 79 return T; 80 }