/ / 最新

swk's log - OpenGL sort

2011-05-21

* OpenGL sort [tech]

こうですか!? わかりません><

#include <GL/glut.h>

void
drawnum(int n)
{
    glPushMatrix();
    glTranslated(0, 0, n / 100.0);
    glScaled(0.0005, 0.0005, 0.0005);
    do {
        glutStrokeCharacter(GLUT_STROKE_MONO_ROMAN, "0123456789"[n % 10]);
        glTranslated(-200, 0, 0);
    } while ((n /= 10) > 0);
    glPopMatrix();
}

void
display()
{
    int i;
    int d[] = { 52, 23, 132, 5, 98 };
    
    glClear(GL_COLOR_BUFFER_BIT);
    for (i = 0; i < sizeof(d) / sizeof(d[0]); i++) {
        drawnum(d[i]);
    }
    glFlush();
}

int
main(int argc, char *argv[])
{
    glutInitWindowSize(640, 480);
    glutInit(&argc, argv);
    glutCreateWindow("OpenGL Sort");

    glMatrixMode(GL_PROJECTION);
    gluPerspective(60, 1, 0.5, 1000);
    glMatrixMode(GL_MODELVIEW);
    gluLookAt(-1, 1, 2, 0, 0, 0, 0, 1, 0);
    
    glutDisplayFunc(display);
    glutMainLoop();
    /* NOTREACHED */
}

glsort/glsort.png

[ コメントを全部見る / コメントを書く] [ TrackBack ( )] [固定リンク]

* [RichardDooke] Curcumin is an antioxidant extract from ... (2018-06-22 13:42:41)

* [DavidLar] "China has adopted a strategic appr... (2018-06-22 12:54:44)

* [enhanohob] "At this stage, coral mortality als... (2018-06-20 18:20:31)

* [DavidLar] You can also find an offer that suits yo... (2018-06-12 20:12:01)

* [RichardDooke] by Christine Lagat and David MusyokaNAIR... (2018-06-12 19:49:02)

* ...

最終更新時間: 2011-06-19 02:04


Shingo W. Kagami - swk(at)kagami.org