All pastes #183689 Raw Edit

Anonymous

public c v1 · immutable
#183689 ·published 2006-09-27 03:20 UTC
rendered paste body
/* Assignment 1 - Duy Nguyen: September 12, 2006 *  This program draws a grid and allows the user to draw lines and polygons. * It handles techniques to draw lines at the pixel level, as well as filling * polygons as required. * *  Just to note, this program uses triangle.c as a template for many of the *  Glut functions. */#include <stdio.h>       #include <stdlib.h>      #include <string.h> /*// Sometimes glu.h includes glut.h--sometimes not.*/#ifdef MAC_OSX#    include <OpenGL/glu.h>#    include <GLUT/glut.h>#else #    include <GL/glu.h>       #    include <GL/glut.h>       #endif/* -------------------------------------------------------------------------- */// Function Declarationsint main(int argc, char *argv[]);static void display_CB(void);            /* Called whenever redisplay needed */static void key_CB(unsigned char key, int x, int y);     /* Called on key press */static void mouse_CB(int button, int state, int x, int y);  /* Called on mouse click */static void parseFile();static void saveFile();/* -------------------------------------------------------------------------- */// Instance Variable Declarations/* -------------------------------------------------------------------------- */int main(int argc, char *argv[]){    int win;    int submenu;    glutInit(&argc, argv);                /* initialize GLUT system */    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);    glutInitWindowSize(630, 630);     win = glutCreateWindow("Assignment 1");   /* create window */    /* set background to black */    glClearColor((GLclampf)0.0,(GLclampf)0.0,(GLclampf)0.0,(GLclampf)0.0);      gluOrtho2D(0.0, 630.0, 0.0, 630.0); /* how object is mapped to window */    glutDisplayFunc(display_CB);        /* set window's display callback */    glutKeyboardFunc(key_CB);           /* set window's key callback */    glutMouseFunc(mouse_CB);            /* set window's mouse callback */    parseFile(); // Read in any predone code    glutMainLoop();                       /* start processing events... */    /* Execution never reaches this point, so return value is failure */    return EXIT_FAILURE;}static void parseFile(){	if(!isatty(fileno(stdin)))	{		char* temp[500];		while( fgets(temp, 500, stdin) != NULL)		{		}	}}static void saveFile(){	int i = 0;	//for(i = 0; i < cmSize; i++)	{			}}/*  /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\   *//*// Function called whenever redisplay needed (try hiding the window and then// exposing it. The debug macro should print something.)*/static void display_CB(void){    glClear(GL_COLOR_BUFFER_BIT);         /* clear the display */    glEnd();           /* OpenGL draws the filled triangle */    glFlush();         /* Complete any pending operations */    glutSwapBuffers(); /* Make the drawing buffer the frame buffer                           and vice versa */}/*  /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\   *//* Function called on key press */static void key_CB(unsigned char key, int x, int y) {    	if( key == 'q' ) 	{		saveFile();		exit(0);	}}/*  /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\   *//* Function called on mouse click */static void mouse_CB(int button, int state, int x, int y)  {}