//#include <stdafx.h>
#include <iostream> //line_poly_file.cpp
#include <fstream>
#include <windows.h>
#include <glut.h>
GLsizei wh = 250;
GLsizei ww = 250;
void DisplayLines ( void ) ;
void MyInit ( ) ;
void DisplayLines ( void ) {
GLint 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
for (j=1; j<=7; 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 R in blue
//glLineWidth(5.0); //try different line thicknesses
glMatrixMode ( GL_PROJECTION );
glLoadIdentity ( ) ;
gluOrtho2D ( 0.0, (GLdouble)ww, 0.0,(GLdouble)wh );
//draw R in this space
}
void main(int argc, char **argv) {
glutInit ( &argc, argv );
glutInitDisplayMode ( GLUT_SINGLE | GLUT_RGB );
glutInitWindowSize ( ww, wh );
glutInitWindowPosition ( 150, 90 );
glutCreateWindow ( "Display R" );
MyInit ( );
glutDisplayFunc ( DisplayLines );
glutMainLoop ( );
}
scobi 0 Newbie Poster
scobi 0 Newbie Poster
sfuo 111 Practically a Master Poster
scobi 0 Newbie Poster
nightcrew 17 Newbie Poster
scobi 0 Newbie Poster
scobi 0 Newbie Poster
scobi 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.