Click here to Skip to main content
15,893,487 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
/* * hello.c
* This is a simple, introductory OpenGL program.
*/


C++
#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>
Posted
Updated 7-Oct-11 4:40am
v2
Comments
khalid _farooq 7-Oct-11 12:53pm    
it doesn;t solve the problem screen gets halted nothing is displayed even black screen

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900