Programm doesn't work

Started by
2 comments, last by karwosts 13 years, 11 months ago
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 }
Advertisement
What doesn't work? What do you expect it to do? What are you getting as result instead?

Are you checking GL errors?
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.
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.
[size=2]My Projects:
[size=2]Portfolio Map for Android - Free Visual Portfolio Tracker
[size=2]Electron Flux for Android - Free Puzzle/Logic Game

This topic is closed to new replies.

Advertisement