1 /* QuesoGLC
2 * A free implementation of the OpenGL Character Renderer (GLC)
3 * Copyright (c) 2002-2005, Bertrand Coconnier
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19 /* $Id: tutorial.c 458 2006-09-01 22:24:14Z bcoconni $ */
20
21 #include "GL/glc.h"
22 #if defined __APPLE__ && defined __MACH__
23 #include <GLUT/glut.h>
24 #else
25 #include <GL/glut.h>
26 #endif
27 #include <stdlib.h>
28
reshape(int width,int height)29 void reshape(int width, int height)
30 {
31 glClearColor(0., 0., 0., 0.);
32 glViewport(0, 0, width, height);
33 glMatrixMode(GL_PROJECTION);
34 glLoadIdentity();
35 gluOrtho2D(0., width, 0., height);
36 glMatrixMode(GL_MODELVIEW);
37 glLoadIdentity();
38 glFlush();
39 }
40
keyboard(unsigned char key,int x,int y)41 void keyboard(unsigned char key, int x, int y)
42 {
43 switch(key) {
44 case 27: /* Escape Key */
45 exit(0);
46 default:
47 break;
48 }
49 }
50
display(void)51 void display(void)
52 {
53 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
54
55 /* Render "Hello world!" */
56 glColor3f(1.f, 0.f, 0.f);
57 glRasterPos2f(50.f, 50.f);
58 glcRenderString("Hello world!");
59
60 glFlush();
61 }
62
main(int argc,char ** argv)63 int main(int argc, char **argv)
64 {
65 GLint ctx = 0;
66 GLint myFont = 0;
67
68 glutInit(&argc, argv);
69 glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
70 glutInitWindowSize(640, 180);
71 glutCreateWindow("Tutorial");
72 glutDisplayFunc(display);
73 glutReshapeFunc(reshape);
74 glutKeyboardFunc(keyboard);
75
76 /* Set up and initialize GLC */
77 ctx = glcGenContext();
78 glcContext(ctx);
79 glcAppendCatalog("/usr/lib/X11/fonts/Type1");
80
81 /* Create a font "Palatino Bold" */
82 myFont = glcGenFontID();
83 #ifdef __WIN32__
84 glcNewFontFromFamily(myFont, "Palatino Linotype");
85 #else
86 glcNewFontFromFamily(myFont, "Palatino");
87 #endif
88 glcFontFace(myFont, "Bold");
89 glcFont(myFont);
90
91 /* Render the text at a size of 100 points */
92 glcScale(100.f, 100.f);
93
94 glutMainLoop();
95 return 0;
96 }
97