49 #pragma comment(linker, "/entry:\"mainCRTStartup\"") 56 # include <GLUT/glut.h> 66 static GLboolean
blend = GL_FALSE;
69 "****************************************************************",
70 "*..............................................................*",
71 "*..................++++++++++++++++++++++++++..................*",
72 "*.............+++++++++++++++++++++++++++++++++++++............*",
73 "*.......++++++++++++aaaaaaaaaaaaaaaaaaaaaaaa++++++++++++.......*",
74 "*.......++++++aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa++++++.......*",
75 "*.......++aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa++.......*",
76 "*.......++aaaa++++aa+aaaaaaaa++++aaa++++++aaa+++++aaaa++.......*",
77 "*.......++aaa+aaaa+a+aaaaaaa+aaaa+aa+aaaaa+a+aaaaa+aaa++.......*",
78 "*.......++aa+aaaaaaa+aaaaaaaaaaa+aaa+aaaaa+a+aaaaaaaaa++.......*",
79 "*.......++aa+aaa+++a+aaaaaaaaaa+aaaa++++++aaa+++++aaaa++.......*",
80 "*.......++aa+aaaaa+a+aaaaaaaaa+aaaaa+aaaaaaaaaaaaa+aaa++.......*",
81 "*.......++aaa+aaaa+a+aaaaaaaa+aaaaaa+aaaaaaa+aaaaa+aaa++.......*",
82 "*.......++aaaa+++++a++++++aa++++++aa+aaaaaaaa+++++aaaa++.......*",
83 "*.......++aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa++.......*",
84 "*.......++aaaaaaaaa++++++++++++++++++++++++++aaaaaaaaa++.......*",
85 "*.......++aaa+++++++@@@@@@@@@@@+++++++++++++++++++aaaa++.......*",
86 "*.......++++++@@+@@@+@@@++@@@@@+++++++++++++++++++++++++.......*",
87 "*.......++@@@@@+@@@+@@@+@@@@+@@+++++++++++++++++++++++++.......*",
88 "*.......++@@@@+@@@+@@+++++++@@@+++++++++++++++++++++++++.......*",
89 "*.......++@@@@+++++++@@@@@@++@@++#####################++.......*",
90 "*.......++@+++++@@@@@@@@@@@@@@@++#####################++.......*",
91 "*.......++@+++@@@@@@@@@@@@@@@@@++#####################++.......*",
92 "*.......++@++@@@@@@@+@@+@@@@@@@++#####################++.......*",
93 "*.......++@@@@@+@@@+@@+@@@@@@@@++#####################++.......*",
94 "*.......++@@@@+@@@+@@+@@++++++++++++++++++++++++++++++++.......*",
95 "*.......++@@@@+@+++++++++@++++@+@+@+++++++++++++++++++++.......*",
96 "*.......++@@@@+++@@@@@@@+@++@+++@+@+@+@+++++++++++++++++.......*",
97 "*.......++@++++@@@@@@@@@@+@+++@+@+@+++++++++++++++++++++.......*",
98 "*.......++@+++@@@@@@@@@@+@@@@@@@@@@@@@@+++++++++++++++++.......*",
99 "*.......++@++@@@@@@+@@+@+@@@+++@@@@@@@@+++++++++++++++++.......*",
100 "*.......++@@@@@+@@+@@+@@+@@+++++@@@@@@@+##############++.......*",
101 "*.......++@@@@+@@+@@+@@++@@+@+++@@@@@+@+##############++.......*",
102 "*.......++@@@@+@+++++++@+@@@@+++@@@@++@+##############++.......*",
103 "*.......++@++++++@@@@@@++@@@@+++@@@@++@+##############++.......*",
104 "*.......++@+++@@@@@@@@@@+@@@+++++@@@+@@+##############++.......*",
105 "*.......++@++@@@@@@@@@@@+@+++++++++++@@+##############++.......*",
106 "*.......+++++++++++++++++@+@+++++++++@@+++++++++++++++++.......*",
107 "*.......+++++++++++++++++@+@+@@@@++++@@+@@@@@@@@@@@@@@++.......*",
108 "*.......+++++++++++++++++@@@+@@@@@+@+@@+@@@+@@+@@@@@@@++.......*",
109 "*........++++++++++++++++@@@@+@@@++@++@+@@+@@+@@@+@@@++........*",
110 "*........++++++++++++++++@@@@@@@@+@@+@@+@+@@+@@@+@@@@++........*",
111 "*........+++++++++++++++++@@@@@@+@@+@@+@++++++++++@@@++........*",
112 "*.........++##############+@@@@@@@@@@++++@@@@@@@@++@++.........*",
113 "*.........++###############+@@@@@@@@++++@@@@@@@@@@@@++.........*",
114 "*..........++###############++++++++@@@@@@@+@@+@@@@++..........*",
115 "*..........++##################++@@@@@+@@@+@@+@@+@@++..........*",
116 "*...........++#################++@@@@+@@@+@@+@@+@@++...........*",
117 "*...........++#################++@@@+@@++++++++@@@++...........*",
118 "*............++++++++++++++++++++@@@++++@@@@@@++@++............*",
119 "*.............+++++++++++++++++++@@+++@@@@@@@@@@@+.............*",
120 "*.............+++++++++++++++++++@+++@@@@@@@@@@@++.............*",
121 "*..............++++++++++++++++++@++@@@@+@@@@@@++..............*",
122 "*...............+++++++++++++++++@@@+@@+@@+@@@++...............*",
123 "*................++++++++++++++++@@+@@+@@+@@@++................*",
124 "*.................++###########++@@+++++++@@++.................*",
125 "*..................++##########++@+++@@@@+@++..................*",
126 "*...................++#########++@++@@@@@@++...................*",
127 "*....................+++#######++@++@@@@+++....................*",
128 "*.....................++++#####++@@@@@++++.....................*",
129 "*.......................++++###++@@@++++.......................*",
130 "*.........................++++#++@++++.........................*",
131 "*...........................++++++++...........................*",
132 "*.............................++++.............................*",
133 "*..............................................................*",
134 "****************************************************************"};
139 glBegin(GL_TRIANGLES);
141 glColor3f(1., 0., 0.);
142 glVertex3f(-1., 0.9, 0.);
143 glColor4f(1., 1., 0., 0.1);
144 glVertex3f(-1., 0., 0.);
145 glColor4f(1., 0., 1., 1.0);
146 glVertex3f(1., 0., 0.2);
148 glColor3f(0., 1., 0.);
149 glVertex3f(1., 0., 0.);
150 glColor3f(0., 1., 1.);
151 glVertex3f(1., 0.5, 0.);
152 glColor3f(0., 1., 1.);
153 glVertex3f(-1., 0.5, 0.1);
160 glColor3f(1., 0., 0.);
165 glVertex3f(-1., 1.0, 0.);
171 glVertex3f(-0.8, 1.0, 0.);
177 glVertex3f(-0.6, 1.0, 0.);
183 glVertex3f(-0.4, 1.0, 0.);
189 glVertex3f(-0.2, 1.05, 0.);
190 glVertex3f(0.2, 1.05, 0.);
193 glEnable(GL_LINE_STIPPLE);
194 glLineStipple(1, 0x087F);
197 glVertex3f(-0.2, 0.95, 0.);
198 glVertex3f(0.2, 0.95, 0.);
200 glDisable(GL_LINE_STIPPLE);
206 glVertex3f(0.4, 1.05, 0.);
207 glVertex3f(0.8, 1.05, 0.);
210 glEnable(GL_LINE_STIPPLE);
211 glLineStipple(2, 0x0F0F);
215 glVertex3f(0.4, 0.95, 0.);
216 glVertex3f(0.8, 0.95, 0.);
218 glDisable(GL_LINE_STIPPLE);
230 glEnable(GL_LIGHTING);
232 glColor4d(0.2, 0.2, 0.9, 0.2);
234 glutSolidTeapot(0.7);
237 glutSolidTorus(0.3, 0.6, 20, 20);
239 glDisable(GL_LIGHTING);
246 const char *fonts[] =
247 {
"Times-Roman",
"Times-Bold",
"Times-Italic",
"Times-BoldItalic",
248 "Helvetica",
"Helvetica-Bold",
"Helvetica-Oblique",
"Helvetica-BoldOblique",
249 "Courier",
"Courier-Bold",
"Courier-Oblique",
"Courier-BoldOblique",
250 "Symbol",
"ZapfDingbats" };
256 for (i = 0; i < strlen(
string); i++)
257 glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12,
string[i]);
262 double x = -1.25, y = -0.33, dy = 0.13;
264 glColor3f(1., 1., 0.);
270 printstring(
" p: to change the print format (PS, EPS, PDF, ...)", 0.);
276 printstring(
" t: to alternate between teapot and torus", 0.);
279 printstring(
" v: to alternate between single and multiple viewport modes", 0.);
282 printstring(
" b: to change the blending mode (transparency)", 0.);
288 printstring(
"Click and move the mouse to rotate the objects", 0.);
290 glRasterPos2d(0, 0.75);
293 glRasterPos2d(x, 1.15);
301 glColor3d (0.0,1.0,0.);
303 glVertex3d( 0.5,-0.5,-0.5);
304 glColor4d (0.0,1.0,0.,0.2);
305 glVertex3d( 0.5, 0.5,-0.5);
306 glVertex3d(-0.5, 0.5,-0.5);
307 glColor4d (0.0,1.0,0.,1);
308 glVertex3d(-0.5,-0.5,-0.5);
311 glColor3d (1.0,0.0,0.);
313 glColor4d (1.0,0.0,0.,0.1);
314 glVertex3d( 0.5,-0.5,0.5);
315 glColor4d (1.0,0.5,1.,0.9);
316 glVertex3d( 0.5, 0.5,0.5);
317 glVertex3d(-0.5, 0.5,0.5);
318 glColor4d (1.0,0.5,1.,0.1);
319 glVertex3d(-0.5,-0.5,0.5);
322 glColor3d (1.0,1.0,0.);
324 glVertex3d( 0.5,-0.5, 0.5);
325 glVertex3d( 0.5,-0.5,-0.5);
326 glVertex3d( 0.5, 0.5, 0.5);
327 glVertex3d( 0.5, 0.5,-0.5);
328 glVertex3d(-0.5, 0.5, 0.5);
329 glVertex3d(-0.5, 0.5,-0.5);
330 glVertex3d(-0.5,-0.5, 0.5);
331 glVertex3d(-0.5,-0.5,-0.5);
335 void image(
float x,
float y, GLboolean opaque)
337 int w = 64, h = 66, row, col, pos = 0;
338 float *pixels, r = 0., g = 0., b = 0.;
342 pixels = (opaque == GL_TRUE)
343 ? (
float*)malloc(3 * w * h *
sizeof(
float))
344 : (
float*)malloc(4 * w * h *
sizeof(
float));
346 for(row = h-1; row >= 0; row--){
347 for(col = 0; col < w; col++){
349 case '.' : r = 255.; g = 255.; b = 255.;
break;
350 case '+' : r = 0. ; g = 0. ; b = 0. ;
break;
351 case '@' : r = 255.; g = 209.; b = 0. ;
break;
352 case '#' : r = 255.; g = 0. ; b = 0. ;
break;
353 case 'a' : r = 255.; g = 209.; b = 0. ;
break;
354 case '*' : r = 0.; g = 0. ; b = 20. ;
break;
356 r /= 255.; g /= 255.; b /= 255.;
357 pixels[pos] = r; pos++;
358 pixels[pos] = g; pos++;
359 pixels[pos] = b; pos++;
365 case '.' : pixels[pos] = col / (float)w ;
break;
366 case 'a' : pixels[pos] = 1 - col / ((float)w - 7) ;
break;
367 default : pixels[pos] = 1. ;
break;
378 gl2psDrawPixels((GLsizei)w, (GLsizei)h, 0, 0, GL_RGB, GL_FLOAT, pixels);
379 glDrawPixels((GLsizei)w, (GLsizei)h, GL_RGB, GL_FLOAT, pixels);
382 gl2psDrawPixels((GLsizei)w, (GLsizei)h, 0, 0, GL_RGBA, GL_FLOAT, pixels);
383 glDrawPixels((GLsizei)w, (GLsizei)h, GL_RGBA, GL_FLOAT, pixels);
392 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
406 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
413 glClearColor(0.2, 0.2, 0.2, 0.);
414 glGetIntegerv(GL_VIEWPORT, viewport);
418 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
419 glMatrixMode(GL_PROJECTION);
421 glOrtho(-1.3,1.3, -1.3,1.3, -1.3,1.3);
422 glMatrixMode(GL_MODELVIEW);
436 glClearColor(0.8, 0.8, 0.8, 0.);
437 glGetIntegerv(GL_VIEWPORT, viewport);
441 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
442 glMatrixMode(GL_PROJECTION);
444 glOrtho(-1.3,1.3, -1.3,1.3, -1.3,1.3);
445 glMatrixMode(GL_MODELVIEW);
449 image(-0.8, -0.3, GL_TRUE);
452 image(-0.8, 0.4, GL_FALSE);
457 glClearColor(0.5, 0.5, 0.5, 0.);
463 GLfloat spec[4] = {0.6, 0.6, 0.6, 1.0};
464 glEnable(GL_DEPTH_TEST);
465 glDepthFunc(GL_LESS);
466 glShadeModel(GL_SMOOTH);
468 glEnable(GL_SCISSOR_TEST);
469 glEnable(GL_COLOR_MATERIAL);
470 glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
471 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, spec);
472 glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 60);
475 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
494 glMatrixMode(GL_PROJECTION);
496 glOrtho(-1.3,1.3, -1.3,1.3, -1.3,1.3);
497 glMatrixMode(GL_MODELVIEW);
499 glClearColor(0.5, 0.5, 0.5, 0.);
500 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
503 void writefile(
int format,
int sort,
int options,
int nbcol,
504 const char *filename,
const char *extension)
511 strcpy(file, filename);
513 strcat(file, extension);
520 fp = fopen(file,
"wb");
523 printf(
"Unable to open file %s for writing\n", file);
527 printf(
"Saving image to file %s... ", file);
531 buffsize += 1024*1024;
532 gl2psBeginPage(file,
"gl2psTest", viewport, format, sort, options,
533 GL_RGBA, 0, NULL, nbcol, nbcol, nbcol,
602 #ifdef GL2PS_HAVE_ZLIB 605 else if(format ==
GL2PS_SVG) strcat(ext,
"z");
621 int main(
int argc,
char **argv)
623 glutInit(&argc, argv);
624 glutInitDisplayMode(GLUT_SINGLE | GLUT_DEPTH);
625 glutInitWindowSize(400, 600);
626 glutInitWindowPosition(100, 100);
627 glutCreateWindow(argv[0]);
GL2PSDLL_API GLint gl2psBeginPage(const char *title, const char *producer, GLint viewport[4], GLint format, GLint sort, GLint options, GLint colormode, GLint colorsize, GL2PSrgba *colormap, GLint nr, GLint ng, GLint nb, GLint buffersize, FILE *stream, const char *filename)
static const char * pixmap[]
GL2PSDLL_API GLint gl2psBeginViewport(GLint viewport[4])
#define GL2PS_DRAW_BACKGROUND
void motion(int x, int y)
#define GL2PS_EXTRA_VERSION
void image(float x, float y, GLboolean opaque)
#define GL2PS_MAJOR_VERSION
#define GL2PS_OCCLUSION_CULL
#define GL2PS_LINE_STIPPLE
void reshape(int w, int h)
int main(int argc, char **argv)
void printstring(const char *string, float angle)
GL2PSDLL_API GLint gl2psSpecial(GLint format, const char *str)
void keyboard(unsigned char key, int x, int y)
#define GL2PS_PATCH_VERSION
GL2PSDLL_API GLint gl2psEndPage(void)
GL2PSDLL_API const char * gl2psGetFileExtension(GLint format)
#define GL2PS_TIGHT_BOUNDING_BOX
#define GL2PS_MINOR_VERSION
#define GL2PS_SIMPLE_SORT
GL2PSDLL_API GLint gl2psPointSize(GLfloat value)
GL2PSDLL_API const char * gl2psGetFormatDescription(GLint format)
GL2PSDLL_API GLint gl2psDisable(GLint mode)
GL2PSDLL_API GLint gl2psDrawPixels(GLsizei width, GLsizei height, GLint xorig, GLint yorig, GLenum format, GLenum type, const void *pixels)
static GLboolean display_multi
void writefile(int format, int sort, int options, int nbcol, const char *filename, const char *extension)
GL2PSDLL_API GLint gl2psEnable(GLint mode)
GL2PSDLL_API GLint gl2psTextOpt(const char *str, const char *fontname, GLshort fontsize, GLint alignment, GLfloat angle)
GL2PSDLL_API GLint gl2psLineWidth(GLfloat value)
#define GL2PS_NO_PS3_SHADING
static const char * format_string
GL2PSDLL_API GLint gl2psEndViewport(void)