More Related Content
Similar to Ass day2 2_rotating my name (robi)
#includefloat angle, move, scene, roadmove,turn, on=1; int i, st.docx#includefloat angle, move, scene, roadmove,turn, on=1; int i, st.docxajoy21
Similar to Ass day2 2_rotating my name (robi) (20)
Ass day2 2_rotating my name (robi)
- 1. #include <GL/glut.h>
double angle = 0;
void initialize()
{
glClearColor(0.0, 0.0, 0.0, 0.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);
}
void draw()
{
glClear(GL_COLOR_BUFFER_BIT);
glRotatef(angle, 0.0, 0.0, 1.0);
//R
glPushMatrix();
glBegin(GL_LINES);
glColor3f(1.0, 0.0, 0.0);
glVertex3f(-0.4, -0.2, 0.0); //1
glVertex3f(-0.4, 0.2, 0.0); //2
glVertex3f(-0.4, 0.2, 0.0); //3
glVertex3f(-0.2, 0.2, 0.0); //4
glVertex3f(-0.2, 0.2, 0.0); //5
glVertex3f(-0.2, -0.001, 0.0); //0.01 is taken for not extending to
//something else rather than R
glVertex3f(-0.4, 0.0, 0.0); //7
glVertex3f(-0.2, 0.0, 0.0);//8
glVertex3f(-0.4, 0.0, 0.0); //R bottom
glVertex3f(-0.2, -0.2, 0.0);//R bottom
glEnd();
//O
glBegin(GL_LINES);
glColor3f(0.0, 0.0, 1.0);
glVertex3f(0.2, -0.2, 0.0);
glVertex3f(0.2, 0.2, 0.0);
glVertex3f(0.0, 0.2, 0.0);//11
glVertex3f(0.0, -0.2, 0.0);//12
glVertex3f(0.0, -0.2, 0.0);//13
glVertex3f(0.2, -0.2, 0.0);//14
glVertex3f(-0.004, 0.2, 0.0);// drawing first line for 'O header
glVertex3f(0.2, 0.2, 0.0);
glEnd();
//B
glBegin(GL_LINES);
glColor3f(0.5, 0.5, 0.0);
glVertex3f(0.3, -0.2, 0.0);
glVertex3f(0.3, 0.2, 0.0);
glVertex3f(0.3, 0.2, 0.0);
glVertex3f(0.5, 0.2, 0.0);
glVertex3f(0.5, 0.2, 0.0);
glVertex3f(0.5, -0.2, 0.0);
glVertex3f(0.5, -0.2, 0.0);
glVertex3f(0.3, -0.2, 0.0);
glVertex3f(0.3, 0.0, 0.0);
glVertex3f(0.5, 0.0, 0.0);
glEnd();
- 2. glPopMatrix();
//I
glBegin(GL_LINES);
glColor3f(0.0, 1.0, 0.0);
glVertex3f( 0.62, 0.2, 0.0);//for drawing 'I' after 'B' we take 0.6 along
x-axis
glVertex3f(0.62, -0.2, 0.0);//10
glEnd();
glutSwapBuffers(); //
}
void update(int value) {
angle = angle + 0.01;
if(angle == 360) angle = 0;
glutPostRedisplay();
glutTimerFunc(30,update,0);
}
int main(int iArgc, char** cppArgv) {
glutInit(&iArgc, cppArgv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
glutInitWindowPosition(200, 200);
glutInitWindowSize(500, 500);
glutCreateWindow("ROBI");
initialize();
glutDisplayFunc(draw);
glutTimerFunc(50, update, 0); //after 10 sec the drawing "ROBI" will start
to sprin faster
glutMainLoop();
}