#include #include int WIN1; //Dichiarazione CLASSE Template Punto2D template class point2D{ public: point2D(){}; point2D(T ascissa, T ordinata){ x=ascissa; y=ordinata; r=1.0; g=0.0; b=0.0; }; void SetPxy(T ascissa, T ordinata) { x=ascissa; y=ordinata; }; void SetColorP(GLfloat rosso, GLfloat verde, GLfloat blu){ r=rosso; g=verde; b=rosso; }; void DrawPoint(void){ glPointSize(3.0); glColor3f(r,g,b); glBegin(GL_POINTS); glVertex2i(x,y); glEnd(); glFlush(); }; private: T x;//Coordinata X T y;//Coordinata Y GLfloat r,g,b;//Colore }; // FINE CLASSE PUNTO 2D point2D p1; point2D p2(150,150); void WIN1Display(void){ glClearColor(0.0,0.0,0.0,0.0); glClear(GL_COLOR_BUFFER_BIT); p1.SetColorP(1.0,0.0,0.0); p1.DrawPoint(); p2.SetColorP(0.0,1.0,1.0); p2.DrawPoint(); glFlush(); } void WIN1Reshape(int w, int h){ glViewport(0,0,(GLsizei)w,(GLsizei)h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(0,(GLfloat)300,0,(GLfloat)300); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); } void InitGLUT(void){ p1.SetPxy(45,100); glutInitDisplayMode(GLUT_RGB|GLUT_SINGLE); glutInitWindowPosition(0, 0); glutInitWindowSize(300,300); WIN1=glutCreateWindow("Punto"); glutDisplayFunc(WIN1Display); glutReshapeFunc(WIN1Reshape); } void main(int argc, char *argv[]) { glutInit(&argc, argv); InitGLUT(); glutMainLoop(); }