Skip to content
Snippets Groups Projects
Commit 1fc94990 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

nicer

parent 62133e0b
No related branches found
No related tags found
No related merge requests found
/* $Id: gl2psTestSimple.c,v 1.6 2005-01-01 19:16:53 geuzaine Exp $ */
/* $Id: gl2psTestSimple.c,v 1.7 2005-06-19 18:56:47 geuzaine Exp $ */
/*
* GL2PS, an OpenGL to PostScript Printing Library
* Copyright (C) 1999-2005 Christophe Geuzaine <geuz@geuz.org>
......@@ -49,43 +49,23 @@
#include <string.h>
#include "gl2ps.h"
static float rotation = -60.;
void init(void){
float pos[4]={1.,1.,-1.,0.};
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
glShadeModel(GL_SMOOTH);
glEnable(GL_LIGHT0);
glLightfv(GL_LIGHT0, GL_POSITION, pos);
}
void display(void){
int i;
char *help = "Press 's' to save image or 'q' to quit";
glClearColor(0.3, 0.5, 0.8, 0.);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glRotatef(-60., 2., 0., 1.);
glEnable(GL_LIGHTING);
glRotatef(rotation, 2., 0., 1.);
/*
glBegin(GL_TRIANGLES);
glNormal3f(0,0,1);
glVertex3f(0,0,0);
glVertex3f(0.5,0,0);
glVertex3f(0.5,0.5,0);
glNormal3f(0,1,0);
glVertex3f(0,0,0);
glVertex3f(0.5,0,0);
glVertex3f(0.5,0,0.5);
glEnd();
*/
glutSolidTorus(0.3, 0.6, 30, 30);
/* glutSolidTeapot(0.7); */
glDisable(GL_LIGHTING);
glPopMatrix();
glColor3f(1.,1.,1.);
glRasterPos2d(-0.9,-0.9);
gl2psText(help, "Times-Roman", 24);
for (i = 0; i < strlen(help); i++)
glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, help[i]);
glFlush();
}
......@@ -98,12 +78,10 @@ void keyboard(unsigned char key, int x, int y){
exit(0);
break;
case 's':
printf("Writing file...\n");
fp = fopen("test.eps", "wb");
while(state == GL2PS_OVERFLOW){
buffsize += 1024*1024;
gl2psBeginPage("test", "test", NULL, GL2PS_EPS,
GL2PS_SIMPLE_SORT /* GL2PS_BSP_SORT */,
gl2psBeginPage("test", "test", NULL, GL2PS_EPS, GL2PS_BSP_SORT,
GL2PS_DRAW_BACKGROUND | GL2PS_USE_CURRENT_VIEWPORT,
GL_RGBA, 0, NULL, 0, 0, 0, buffsize, fp, "test.eps");
display();
......@@ -115,23 +93,22 @@ void keyboard(unsigned char key, int x, int y){
}
}
void motion(int x, int y){
rotation += 10.;
display();
}
int main(int argc, char **argv){
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_DEPTH);
glutInitDisplayMode(GLUT_DEPTH);
glutInitWindowSize(400, 400);
glutInitWindowPosition(100, 100);
glutCreateWindow(argv[0]);
init();
GLfloat pos[4]={1.,1.,-1.,0.};
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
glShadeModel(GL_SMOOTH);
glEnable(GL_LIGHT0);
glLightfv(GL_LIGHT0, GL_POSITION, pos);
glutDisplayFunc(display);
glutKeyboardFunc(keyboard);
glutMotionFunc(motion);
printf("Press 's' to save image or 'q' to quit\n");
glutMainLoop();
return 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment