Sign in to follow this  
aradhya

Programm doesn't work

Recommended Posts

aradhya    100
I think, I am doing everything write here. Still, it doesn't work. Please Help! #include "stdafx.h" #include<stdlib.h> #include <iostream> #include<glut.h> #include<windows.h> #include<math.h> #include<fstream> #include<gl.h> #include<glu.h> using namespace std; //<<<<<<<<<<<<<<<<<<setting the display window>>>>>>>>>>>>> void setWindow(int left,int right,int bottom,int top) { glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(left,right,bottom,top); } //<<<<<<<<<<<<<<<the intializing function>>>>>>>>>>>>>>> void myInit(void) { glClearColor(0.2,0.2,0.0,0.0); glColor3f(0.0f,1.0f,0.0f); glPointSize(2.0); } //<<<<<<<<<<<<<<<<<<newmethod>>>>>>>>>>>>>>>>>>> void newmethod(char *fileName) { fstream inStream; inStream.open(fileName, ios::in); // Open The File if(inStream.fail()) return; glClear(GL_COLOR_BUFFER_BIT); // Clear the screen GLint numpolys, numLines, x,y; inStream >> numpolys; // read the number of polylines for(int j = 0; j < numpolys; j++)//read each polyline { inStream>>numLines; glBegin(GL_LINE_STRIP); //draw the next polyline for (int i = 0; i < numLines; i++) { inStream >> x >> y; // read the next x, y pair glVertex2i(x,y); } glEnd(); } glFlush(); inStream.close(); } //<<<<<<<<<<<<drawPolyLine>>>>>>>>>>>>>>>> void drawPolyLine(void) { glClear(GL_COLOR_BUFFER_BIT); for(int i=1;i<10;i++) { for(int j=1;j<10;j++) { int a=i*70; int b=j*80; glViewport(a,b,70,80); newmethod("dino.dat"); glFlush(); } } } // //<<<<<<<<<<<<<main>>>>>>>>>>>>>>>>> void main(int argc, char **argv) { glutInit(&argc, argv); //Initialize the toolkit glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);//Set display mode glutInitWindowSize(1024,768); glutInitWindowPosition(100,150); glutCreateWindow("Dino"); //Open the screen Window glutDisplayFunc(drawPolyLine); //Register Redraw function myInit(); setWindow(0,700,0,800); glutMainLoop(); //Go into Perpetual Loop }

Share this post


Link to post
Share on other sites
aradhya    100
i am just starting with opengl. I am learning from this book-Computer graphics using openGl. The program is mentioned in the book. It is supposed to copy the image in different viewports and give a sequence but instead it is showing only 1 image.

Share this post


Link to post
Share on other sites
karwosts    840
You are trying to do too much at once. It doesn't do you any good for us to debug some random program from a book if you don't understand what is going on.

Start small, and don't try to run programs if you don't understand them. Break this down into smaller parts that make sense to you, play with the variables, tweak it a little bit, and add back little pieces of the original program as you learn what they do. Then you can debug it as you go and try to learn something while you do it.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this