/ / 最新

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 ( )] [固定リンク]

* [semechkaparl] [url=https://семечка-джа.com/ua/%D1%84%D... (2017-03-26 23:17:14)

* [Agrnodab] Спасибо за инфу[url=http... (2017-03-20 12:37:23)

* [RobertoFus] [img]https... (2017-03-19 15:15:48)

* [RobertoFus] [img]https... (2017-03-18 22:05:27)

* [FrankAbump] [url=http... (2017-03-15 03:57:01)

* ...

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


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