コード例 #1
0
void render()
{
    glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
    glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT );
    glEnable( GL_TEXTURE_2D );
    
    glMatrixMode( GL_PROJECTION );
    glLoadIdentity();
    glOrtho( 0.0, 1.0, 0.0, 1.0, -1.0, 1.0 );
    
    glMatrixMode( GL_MODELVIEW );
    glLoadIdentity();
    
    // Draw background quad
    GLfloat vertices[][3] = {
        { 0.0f, 0.0f, 0.0f }, { 1.0f, 0.0f, 0.0f },
        { 1.0f, 1.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }
    };
    GLfloat texcoords[][2] = {
        {0.0f, 1.0f}, {1.0f, 1.0f}, {1.0f, 0.0f}, {0.0f, 0.0f}
    };
    VertexData meshData = { &(vertices[0][0]), NULL, NULL, &(texcoords[0][0]) };
    
    TextureManager::Inst()->BindTexture( backgroundTexID );
    drawSimpleMesh( WITH_POSITION|WITH_TEXCOORD, 4, meshData, GL_QUADS );
    
    glEnable( GL_BLEND );
    glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
    glTranslatef( 0.0f, 0.0f, 0.1f );
    
    glBindTexture( GL_TEXTURE_2D, playerColorTexture->id );
    drawSimpleMesh( WITH_POSITION|WITH_TEXCOORD, 4, meshData, GL_QUADS );
    
    glDisable( GL_BLEND );
    glutSwapBuffers();
}
コード例 #2
0
ファイル: filmstrip.c プロジェクト: Abhishekh-TEL/pdroid
int main(int index)
{
    float mat1[16];

    float trans = Pos->translate;
    float rot = Pos->rotate;

    matrixLoadScale(mat1, 2.f, 2.f, 2.f);
    matrixTranslate(mat1, 0.f, 0.f, trans);
    matrixRotate(mat1, 90.f, 0.f, 0.f, 1.f);
    matrixRotate(mat1, rot, 1.f, 0.f, 0.f);
    vpLoadModelMatrix(mat1);

    // Draw the lighting effect in the strip and fill the Z buffer.
    drawSimpleMesh(NAMED_mesh);

    // Start of images.
    bindProgramStore(NAMED_PSImages);
    bindProgramFragment(NAMED_PFImages);
    bindProgramVertex(NAMED_PVImages);

    float focusPos = Pos->focus;
    int focusID = 0;
    int lastFocusID = loadI32(2, STATE_LAST_FOCUS);
    int imgCount = 13;

    if (trans > (-.3f)) {
        focusID = -1.0f - focusPos;
        if (focusID >= imgCount) {
            focusID = -1;
        }
    } else {
        focusID = -1;
    }

    /*
    if (focusID != lastFocusID) {
        if (lastFocusID >= 0) {
            uploadToTexture(con, env->tex[lastFocusID], 1);
        }
        if (focusID >= 0) {
            uploadToTexture(con, env->tex[focusID], 0);
        }
    }
    */
    lastFocus = focusID;

    int triangleOffsetsCount = Pos->triangleOffsetCount;

    int imgId = 0;
    for (imgId=1; imgId <= imgCount; imgId++) {
        float pos = focusPos + imgId + 0.4f;
        int offset = (int)floorf(pos * 2.f);
        pos = pos - 0.75f;

        offset = offset + triangleOffsetsCount / 2;
        if (!((offset < 0) || (offset >= triangleOffsetsCount))) {
            int start = offset -2;
            int end = offset + 2;

            if (start < 0) {
                start = 0;
            }
            if (end >= triangleOffsetsCount) {
                end = triangleOffsetsCount-1;
            }

            bindTexture(NAMED_PFImages, 0, loadI32(0, imgId - 1));
            matrixLoadTranslate(mat1, -pos - loadF(5, triangleOffsetsCount / 2), 0, 0);
            vpLoadTextureMatrix(mat1);
            drawSimpleMeshRange(NAMED_mesh, loadI32(4, start), (loadI32(4, end) - loadI32(4, start)));
        }
    }
    return 0;
}