Пример #1
0
void display(void)
{
  glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
  glMatrixPushEXT(GL_MODELVIEW); {
    Transform3x2 mat;

    mul(mat, view, model);
    MatrixLoadToGL(mat);
    drawTigerRange(filling, stroking, 0, path_count);
  } glMatrixPopEXT(GL_MODELVIEW);
  glutSwapBuffers();
}
Пример #2
0
void StCVisitor::loadCurrentMatrix()
{
    GLfloat *m = reinterpret_cast<GLfloat*>(&matrix_stack.top()[0][0]);
    if (makingDlist) {
        // "Pop, then Push" allows us to combine with a base view transform.
        glMatrixPopEXT(GL_MODELVIEW);
        glMatrixPushEXT(GL_MODELVIEW);
        glMatrixMultTransposefEXT(GL_MODELVIEW, m);
    } else {
        glMatrixLoadTransposefEXT(GL_MODELVIEW, m);
    }
}
Пример #3
0
void popMatrix( GLenum mode )
{
	if ( isDSAEnabled() )
	{
		glMatrixPopEXT( mode );
	}
	else
	{
		glMatrixMode( mode );
		glPopMatrix();
	}
}
Пример #4
0
void dreamTorusDisplay( bool clear )
{
    static float r = 0.0f;
    static int count = 0;

    if( count == 0 ) {
        init();
    }

    glPushGroupMarkerEXT(0, "display");

#if 1
    if( count == 0 ) {
        RegalSetErrorCallback( regalerr );
    } else if( count == 11 ) {
        RegalSetErrorCallback( NULL );
    }
    count++;
#endif

    glUseProgram( 0 );
    if( clear ) {
        glClearDepth( 1.0 );
        glClearColor( r / 400.f, 0, 0, 0);
        glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
    }
    glEnable( GL_DEPTH_TEST );

    for( int i = 0; i < 8; i++ ) {
        glActiveTexture( GL_TEXTURE0 + i );
        glDisable( GL_TEXTURE_2D );
    }

    glBindMultiTextureEXT( texunit, GL_TEXTURE_2D, tex );
    glActiveTexture( texunit );
    glEnable( GL_TEXTURE_2D );


    float sc = 2.0f * fabs( ( count % 800 ) / 400.0f - 1.0f ) + 1.0f;

    glMatrixLoadIdentityEXT( texunit );
    glMatrixScalefEXT( texunit, sc, 1, 1 );

    float osc = sc * 0.5f;


    glEnable( GL_FOG );

    if( ( count % 7 ) == 0 || ( count % 17 ) == 0 ) {
        glDisable( GL_NORMALIZE );
        glEnable( GL_RESCALE_NORMAL );
        glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
        glMatrixMode( GL_MODELVIEW );
        glPushMatrix();
        glRotatef( (float) count, -1.0f, 1.0f, 0.0f );
        glScalef( osc, osc, osc );
        drawAnObject();
        glPopMatrix();
    } else {
        glEnable( GL_NORMALIZE );
        glDisable( GL_RESCALE_NORMAL );
        glMultiTexEnviEXT( texunit, GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
        glMatrixPushEXT( GL_MODELVIEW );
        glMatrixRotatefEXT( GL_MODELVIEW, (float) count, -1.0f, 1.0f, 0.0f );
        glMatrixScalefEXT( GL_MODELVIEW, osc, osc, osc );
        drawAnObject();
        glMatrixPopEXT( GL_MODELVIEW );
    }

    r += 1.0f;
    if( r > 399 ) {
        r = 0.0f;
    }

    glPopGroupMarkerEXT();

  //printf( "Draw with r=%f\n", r );
}
Пример #5
0
static void init()
{
    glPushGroupMarkerEXT(0, "init");

    glGenTextures( 1, &tex );
    GLubyte pix[] = {
        0x60, 0xff, 0x00, 0xff,  0xff, 0x00, 0x00, 0xff,  0xff, 0x00, 0xff, 0xff,  0x00, 0xff, 0xff, 0xff,
        0xff, 0xff, 0xff, 0xff,  0x00, 0x00, 0xff, 0xff,  0x00, 0x00, 0x00, 0xff,  0xff, 0x80, 0x00, 0xff,
        0x80, 0x80, 0xff, 0xff,  0xff, 0x00, 0x00, 0xff,  0x80, 0x80, 0x80, 0xff,  0x00, 0x80, 0x80, 0xff,
        0x00, 0xff, 0xff, 0xff,  0x00, 0x80, 0x00, 0xff,  0x80, 0x00, 0xff, 0xff,  0x00, 0x00, 0x80, 0xff
    };
    glTextureImage2DEXT( tex, GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, pix );
    glTextureParameteriEXT( tex, GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
    glTextureParameteriEXT( tex, GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
    glBindMultiTextureEXT( texunit, GL_TEXTURE_2D, tex );

    GLfloat mat_specular[]   = { 0.0f, 0.0f, 1.0f, 1.0f };
    GLfloat mat_shininess[]  = { 50.0f };
    GLfloat light_position[] = { 1.0f, 1.0f, 0.2f, 1.0f };
    GLfloat light_atten[]    = { 1.0f, 1.0f, 1.0f };
    GLfloat light_diffuse[]  = { 10.0f, 10.0f, 10.0f, 10.0f };
    GLfloat light_specular[] = { 10.0f, 10.0f, 10.0f, 10.0f };
    GLfloat light_spotdir[]  = { -0.1f, -0.1f, -1.0f };
    GLfloat light_spotcut[]  = { 30.0f };
    GLfloat light_spotexp[]  = { 3.0f };
    glClearColor (0.0, 0.0, 0.0, 0.0);
    //glShadeModel (GL_SMOOTH);

    glMatrixPushEXT( GL_MODELVIEW );
    glMatrixLoadIdentityEXT( GL_MODELVIEW );

    glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
    glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, mat_shininess);
    //glMaterialfv(GL_BACK, GL_SHININESS, mat_shininess);
    glLightfv(GL_LIGHT0, GL_POSITION, light_position);
    glLightf( GL_LIGHT0, GL_LINEAR_ATTENUATION, light_atten[1] );
    glLightf( GL_LIGHT0, GL_QUADRATIC_ATTENUATION, light_atten[2] );
    glLightfv( GL_LIGHT0, GL_DIFFUSE, light_diffuse );
    glLightfv( GL_LIGHT0, GL_SPECULAR, light_specular );
    glLightfv( GL_LIGHT0, GL_SPOT_DIRECTION, light_spotdir );
    glLightfv( GL_LIGHT0, GL_SPOT_CUTOFF, light_spotcut );
    glLightfv( GL_LIGHT0, GL_SPOT_EXPONENT, light_spotexp );
    //GLfloat light_ambient[] = { 0.0, -1.0, 0.0, 0.0 };
    //glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient);

    glMatrixPopEXT( GL_MODELVIEW );

    glLightModeli( GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE );
    glLightModelf( GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR );

    glEnable( GL_COLOR_MATERIAL ) ;
    glColorMaterial( GL_BACK, GL_SPECULAR );

    glLightModeli( GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE );

    glEnable(GL_LIGHTING);
    glEnable(GL_LIGHT0);

    glFogi( GL_FOG_MODE, GL_LINEAR );
    glFogf( GL_FOG_START, 2.0f );
    glFogf( GL_FOG_END, 4.0f );
    GLfloat fog_color[] = { 1.0, 1.0, 0.0, 0.0 };
    glFogfv( GL_FOG_COLOR, fog_color );

    glEnable( GL_CLIP_PLANE3 );
    GLdouble clip[] = { 1, 1, -1, 0 };
    glClipPlane( GL_CLIP_PLANE3, clip );

    glPopGroupMarkerEXT();
}
Пример #6
0
void Draw::validateClipPath()
{
    if (!clip_path_valid) {
        glEnable(GL_STENCIL_TEST);
        glStencilMask(clip_msb | (clip_msb - 1));
        glColorMask(0,0,0,0);
        glDepthMask(0);

        if (clip_bounds.isValid()) {
            // A clip path is already etched into the stencil buffer; erase it
            if (!makingDlist) {
                glDisable(GL_SCISSOR_TEST);
            }
            glStencilFunc(GL_ALWAYS, 0, 0);
            glStencilOp(GL_ZERO, GL_ZERO, GL_ZERO);
            coverRect(clip_bounds);
            clip_bounds.invalidate();
        }

        for (size_t i = 0; i < clip_stack.size(); i++) {
            RectBounds bounds = clip_stack[i].clip->getClipBounds();
            clip_bounds &= bounds.transform(clip_stack[i].matrix);
        }
        if (clip_bounds.isValid()) {
            if (makingDlist) {
                // Don't put the scissor in display lists since scissor
                // is positioned absolutely.
            } else {
                int4 bbox = clipScissorBox();
                glEnable(GL_SCISSOR_TEST);
                glScissor(bbox.x, bbox.y, bbox.z-bbox.x, bbox.w-bbox.y);
            }

            RectBounds current_clip_bounds;
            for (size_t i = 0; i < clip_stack.size(); i++) {
                // Stencil the first clip path into the msb and the rest
                // into the 2nd msb. They will do the intersection in end_fill()
                ClipVisitorPtr clip_visitor(new ClipVisitor(
                                                i == 0 ? clip_msb : clip_msb>>1, clip_msb,
                                                clip_stack[i].clip->clip_merge, renderer,
                                                clip_stack[i].matrix, current_clip_bounds));

                if (makingDlist) {
                    glMatrixPopEXT(GL_MODELVIEW);
                    glMatrixPushEXT(GL_MODELVIEW);
                    glMatrixMultTransposefEXT(GL_MODELVIEW, reinterpret_cast<GLfloat*>(&clip_stack[i].matrix));
                } else {
                    glMatrixLoadTransposefEXT(GL_MODELVIEW,
                                              reinterpret_cast<GLfloat*>(&clip_stack[i].matrix));
                }

                clip_visitor->beginFill();
                clip_stack[i].clip->path->traverse(clip_visitor);
                clip_visitor->endFill();
            }

            loadCurrentMatrix();
        }

        glColorMask(1,1,1,1);
        glDepthMask(1);
        clip_path_valid = true;
    }