OpenGL

O que é

API dedicada a gráficos 3D, muito conhecida. Ela é um padrão aberto gerenciada agora pelo Khronos group e muito usada em jogos e nos mais variados aplicativos comerciais ou não. Além disso é muito plataforma e conta com amplo suporte dos fabricantes de placa 3D para oferecer aceleração de vídeo por hardware.

GLUTDoubleBuffer Exemplo de double Buffer em GLUT
GLUTCamera Movimentacao da Camera com auxilio do GLUT
GLUTOverlay Colocando overlays na aplicacao

Codigo que poe um retangulo 2D na tela com a ajuda da API GLUT

#include <GL/glut.h>

// Called to render scene
void renderScene(){
    glClear(  GL_COLOR_BUFFER_BIT );

    // set the current drawing color to red
    glColor3f( 1.0f, 0.0f, 0.0f );

    // draw a filled rectangle with current color
    glRectf( -25.0f, 25.0f, 25.0f, -25.0f );

    // flush drawing commands
    glFlush();
}

// setup the rendering state
void setupRC(){
    glClearColor( 0.0f, 0.0f, 1.0f, 1.0f );
}

// called by GLUT library when the windows has changed size
void changeSize( GLsizei w, GLsizei h ){
    GLfloat aspectRatio;

    if( h == 0 ) h =1;

    // set the viewport to windows dimensions
    glViewport( 0, 0, w, h );

    // reset coordinate system
    glMatrixMode( GL_PROJECTION );
    glLoadIdentity();

    // Establish clipping volume
    aspectRatio = (GLfloat) w/ (GLfloat)h;

    if( w <= h )
        glOrtho( -100.0, 100.0, -100/aspectRatio, 100.0/aspectRatio, 1.0, -1.0 );
    else
        glOrtho( -100.0 * aspectRatio, 100.0 * aspectRatio, -100, 100.0, 1.0, -1.0 );

        glMatrixMode( GL_MODELVIEW );
        glLoadIdentity();
}

int main(){
    glutInitDisplayMode( GLUT_SINGLE | GLUT_RGB );
    glutCreateWindow( "GLRect" );
    glutDisplayFunc( renderScene );
    glutReshapeFunc( changeSize );

    setupRC();

    glutMainLoop();

    return 0;
}

Relacionados

Glut Gl Utility Toolkit

Links

site oficial da API
Site muito bom com bastante conteúdo de OpenGL
Site sobre JOGL - Java Bindings for OpenGL
Site sobre JOGL - Outra Binding de Java para OpenGL

page_revision: 4, last_edited: 1244432133|%e %b %Y, %H:%M %Z (%O ago)
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Share Alike 2.5 License.