Oracle
New member
Hey guys i just started a opengl course this semester and all the code i run at uni machines works fine but i wanted to try it at home so i downloaded the virgin code and tried to run it and it ran fine
but
if i run another opengl project the previous graphic will appear along side the new one i.e
prog 1 spiral
close down c++
Start C++
new prog circle
output spiral within a circle (looks good but wrong)
and i cant understand why? below is the circle code
can ne one help?
//////////////////////////////////////////////////////////////////////
#include <windows.h>
#include <math.h>
#include <glut.h>
#define PI 3.1415926535898
void init(void)
{
glClearColor(0.0f, 0.0f, 0.0f, 0.0f) ;
glShadeModel(GL_SMOOTH) ; //or GL_FLAT
}
void display(void)
{
int i,c_points = 100;
float angle;
glBegin(GL_LINE_LOOP);
for(i=0; i<c_points; i++){
angle = 2*PI*i/c_points;
glVertex2f(cos(angle), sin(angle));
}
glEnd();
glutSwapBuffers();
}
int main(int argc, char** argv)
{
glutInit (&argc, argv) ;
glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB) ;
glutInitWindowSize (500, 500) ;
glutInitWindowPosition (100, 100) ;
glutCreateWindow ("example1") ;
//init() ; //initialise opengl settings
glutDisplayFunc (display) ; //set up call back for display
glutMainLoop () ;
return 0 ;
}
but
if i run another opengl project the previous graphic will appear along side the new one i.e
prog 1 spiral
close down c++
Start C++
new prog circle
output spiral within a circle (looks good but wrong)
and i cant understand why? below is the circle code
can ne one help?
//////////////////////////////////////////////////////////////////////
#include <windows.h>
#include <math.h>
#include <glut.h>
#define PI 3.1415926535898
void init(void)
{
glClearColor(0.0f, 0.0f, 0.0f, 0.0f) ;
glShadeModel(GL_SMOOTH) ; //or GL_FLAT
}
void display(void)
{
int i,c_points = 100;
float angle;
glBegin(GL_LINE_LOOP);
for(i=0; i<c_points; i++){
angle = 2*PI*i/c_points;
glVertex2f(cos(angle), sin(angle));
}
glEnd();
glutSwapBuffers();
}
int main(int argc, char** argv)
{
glutInit (&argc, argv) ;
glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB) ;
glutInitWindowSize (500, 500) ;
glutInitWindowPosition (100, 100) ;
glutCreateWindow ("example1") ;
//init() ; //initialise opengl settings
glutDisplayFunc (display) ; //set up call back for display
glutMainLoop () ;
return 0 ;
}