#include<stdlib.h> #include #include<iostream> #include<fstream> using std::fstream; using namespace std; void draw(void) { /* clear all pixels */ char fileName[] = "house1.txt"; fstream instream; instream.open("c:/house1.txt",ios::in); if(instream.fail()) return; glClear (GL_COLOR_BUFFER_BIT); GLint numstrip,numlines; GLfloat x,y; instream>>numstrip; for(int j=0;j<numstrip;j++)> { instream>>numlines; glBegin(GL_LINE_STRIP); for(int i=0;i<numlines;i++)> { instream>>x>>y; glVertex2f(x,y); } glEnd(); } glFlush (); instream.close(); } void init (void) { /* select clearing color */ glClearColor (0.0, 0.0, 0.0, 0.0); /* initialize viewing values */ glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0); } /* * Declare initial window size, position, and display mode * (single buffer and RGBA). Open window with "hello" * in its title bar. Call initialization routines. * Register callback function to display graphics. * Enter main loop and process events. */ int main(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); glutInitWindowSize (640, 480); glutInitWindowPosition (100, 100); glutCreateWindow ("hello"); init (); glutDisplayFunc(draw); glutMainLoop(); return 0; /* ANSI C requires main to return int. */ }</fstream></iostream></stdlib.h>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)