Wednesday, July 6, 2011

My first ASCII Text using OpenGL

//OpenGL include goes here

GLfloat year=0;
GLfloat day=0;

void reshape(int w, int h)
{
    glViewport(0,0,w,h);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(60,1,0.5,400);
    glMatrixMode(GL_MODELVIEW);   
    glLoadIdentity();
}

void display(void)
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glEnable(GL_DEPTH_TEST);
    glLoadIdentity();

    glRasterPos2f(0,0);
    //glRasterPos3f(0,1,0);
    glutBitmapCharacter(GLUT_BITMAP_9_BY_15,72);   
    glutBitmapCharacter(GLUT_BITMAP_9_BY_15,65);   
    glutBitmapCharacter(GLUT_BITMAP_9_BY_15,70);
    glutBitmapCharacter(GLUT_BITMAP_9_BY_15,73);
    glutBitmapCharacter(GLUT_BITMAP_9_BY_15,90);
    glutBitmapCharacter(GLUT_BITMAP_9_BY_15,65);
    glutBitmapCharacter(GLUT_BITMAP_9_BY_15,72);
   
    gluLookAt(0,0,-2,0,0,0,0,1,0);
    glutSwapBuffers();
}

int main(int argc, char **argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
    glutInitWindowPosition(100,100);
    glutCreateWindow("Text Example");
   
    glutDisplayFunc(display);
    glutReshapeFunc(reshape);   

    glutMainLoop();
    return(0);
}

No comments:

Post a Comment

Question 1: Introduction to Variable

Based on code below, create a dynamic program that solve problem below: Source Code: #include <iostream> using na...