scobi 0 Newbie Poster

Another problem is my program draw lines not Polygon but I want to show POLYGON.HElP ME ASAP.Check my txt file attachement

#include <stdafx.h>
#include <iostream> //line_poly_file.cpp
#include <fstream>
#include <windows.h>
#include <glut.h>

using namespace std;
GLsizei wh = 250;
GLsizei ww = 250;
void DisplayLines ( void ) ;
void MyInit ( ) ;
void DisplayPOLYGON ( void ) {
    GLfloat xj, yj, j;
    glClear ( GL_COLOR_BUFFER_BIT ) ;
   fstream inStream;
   inStream.open("R.txt", ios :: in);
	//inStream.open("R.txt", "r");
    if(!inStream) {
            cout << "File would not open\n";
            return;
        }
	
    //glBegin(GL_LINE_STRIP); //render a series of vertices
	glBegin(GL_POLYGON);
    for (j=1; j<=10; j++) {
        inStream >> xj >> yj; //read from disc file
        cout << xj << " " << yj <<"\n";
        glVertex2i(xj,yj);
    }
glEnd();
glFlush();
}
void MyInit ( void ) {
    glClearColor ( 1.0, 1.0, 0.0, 0.0 );//set window buffer as yellow
    glColor3f(0.0f, 0.0f,1.0f); //draw in blue
    //glLineWidth(5.0); //try different line thicknesses
    glMatrixMode ( GL_PROJECTION );
    glLoadIdentity ( ) ;
    //gluOrtho2D ( 0.0, (GLdouble)ww, 0.0,(GLdouble)wh );
    glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
	//draw R in this space
}
void main(int argc, char **argv) {
    glutInit ( &argc, argv );
    glutInitDisplayMode ( GLUT_SINGLE | GLUT_RGB );
    glutInitWindowSize ( ww, wh );
    glutInitWindowPosition ( 100, 100 );
    glutCreateWindow ( "Display House" );
    MyInit ( );
    //glutDisplayFunc ( DisplayLines );
	glutDisplayFunc (DisplayPOLYGON);
    glutMainLoop ( );
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.