Exemplo n.º 1
0
 void test(int loops, SkCanvas* canvas) {
     SkPaint paint;
     for (int i = 0; i < loops; i++) {
         SkAutoTUnref<SkColorFilter> colorCube(
             SkColorCubeFilter::Create(fCubeData, fCubeDimension));
         paint.setColorFilter(colorCube);
         canvas->drawBitmap(fBitmap, 0, 0, &paint);
     }
 }
Exemplo n.º 2
0
Arquivo: p4.c Projeto: ksitbbb/cg
void display(void){
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
    glLoadIdentity();
    gluLookAt(viewer[0],viewer[1],viewer[2],0.0,0.0,0.0,0.0,1.0,0.0);
    glRotatef(theta[0],1.0,0.0,0.0);
    glRotatef(theta[1],0.0,1.0,0.0);
    glRotatef(theta[2],0.0,0.0,1.0);
    colorCube();
    glFlush();
    glutSwapBuffers();
}
Exemplo n.º 3
0
int main( int argc, char *argv[] ) {
  
  Engine::instance()->init( &argc, argv, "wow!" );
  
  // New Initialization includes default Camera and Shader.
  // Scene and Camlist default to using this shader.
  Object *cube = Engine::instance()->rootScene()->addObject( "cube" );
  colorCube( cube, 1.0 );
  cube->buffer();
  
  Engine::instance()->registerIdle( sgIdle );
  glutMainLoop();
  return EXIT_SUCCESS;
}
Exemplo n.º 4
0
Arquivo: glcube.c Projeto: defdef/iup
/* function called when the canvas is exposed in the screen */
static int repaint_cb(Ihandle *self) 
{
  IupGLMakeCurrent(self);
  glClearColor(0.3f, 0.3f, 0.3f, 1.0f);  /* White */
  glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
  glEnable(GL_DEPTH_TEST);

  glMatrixMode(GL_MODELVIEW);
  glPushMatrix();  /* saves current model view in a stack */
      glTranslatef( 0.0f, 0.0f , 0.0f );
      glScalef( 1.0f, 1.0f, 1.0f );
      glRotatef(t,0,0,1);
      colorCube();
   glPopMatrix();
 
  IupGLSwapBuffers(self);  /* change the back buffer with the front buffer */

  return IUP_DEFAULT; /* returns the control to the main loop */
}
/**
 init will initialize this particular flythrough,
 by creating and instantiating a shader, a camera,
 and a number of initial objects.

 @return void.
 **/
void init() {

    Scene *theScene = Engine::instance()->rootScene();
    Screen *myScreen = Engine::instance()->mainScreen();

    // Load the shaders.
    GLuint gShader = Angel::InitShader( "shaders/vEngine.glsl",
                                        "shaders/fTerrainTex.glsl" );

    // Give the shader handle to the Scene Graph and the Camera List.
    theScene->shader( gShader );
    myScreen->_camList.shader( gShader );

    // Activate "Vertical Division"
    myScreen->_camList.toggleDivision();

    /*
     NOTE:
     ==========================
     Please do not give the Terrain children.
     The terrain generation animation applies directly to the terrain,
     which of course propegates the animation to all child objects.

     You'll pancake any child objects.
     */

    // Let's create some objects.
    Object *terrain = theScene->addObject( "terrain" );

    terrain->texture( "../Textures/GoodTextures_0013423.jpg" ); // Dirt/Mud
    terrain->texture( "../Textures/GoodTextures_0013779.jpg" ); // Sand
    terrain->texture( "../Textures/GrassGreenTexture0002.jpg" ); // Grass
    terrain->texture( "../Textures/GoodTextures_0013418.jpg" ); // Rock
    terrain->texture( "../Textures/GoodTextures_0013291.jpg" ); // Snow
    terrain->drawMode( GL_TRIANGLE_STRIP );
    randomize_terrain();// This call depends upon "terrain" existing within theScene.

    Object *pyramid = theScene->addObject( "pyramid" );

    /*
     Object *box   = theScene.addObject( "box" ) ;
     loadModelFromFile( box, "../models/box-a.obj");
     box->_trans._offset.SetY(100.0);
     box->_trans._offset.SetX(100.0);
     box->_buffer();
     */

    sierpinskiPyramid( pyramid, vec4( 0, 1, 0, 1 ), vec4( -1, -0.999, 1, 1 ),
                       vec4( 1, -0.999, 1, 1 ), vec4( 0, -0.999, -1, 1 ), 4 );
    pyramid->buffer();

    Object *cube_base = theScene->addObject( "basecube" );
    colorCube( cube_base, 1.0 );
    cube_base->buffer();

    Object *moon_cube = pyramid->addObject( "moon" );
    colorCube( moon_cube, 0.5 );
    moon_cube->buffer();

    // These models came from VALVE,
    // From their game "Team Fortress 2."
    // The model processing was done in Blender.
    Object *heavy = theScene->addObject( "heavy" );
    ObjLoader::loadModelFromFile( heavy, "../models/heavyT.obj" );
    heavy->buffer();
    heavy->_trans._scale.set( 0.10 );
    heavy->_trans._offset.set( 0, 2, 0 );

    // Valve's TF2 Medic
    Object *medic = heavy->addObject( "medic" );
    ObjLoader::loadModelFromFile( medic, "../models/medicT.obj" );
    medic->_trans._offset.set( 0, 20, 0 );
    medic->buffer();

    // Valve's TF2 Spy
    Object *spy = medic->addObject( "spy" );
    ObjLoader::loadModelFromFile( spy, "../models/spyT.obj" );
    spy->_trans._offset.set( 0, 20, 0 );
    spy->buffer();

    Object *ball = theScene->addObject( "ball" );
    sphere( ball );
    ball->_trans._scale.set( 1000 );
    ball->buffer();

    /*
     Object *sun = theScene.addObject ("sun");
     //loadModelFromFile( sun, "../models/heavyT.obj" );
     sphere(sun);
     sun->_trans._offset.SetX(500.0);
     sun->_trans._scale.set(16.0) ;
     sun->_buffer();
     */

    /*
     Object *actualMoon = theScene.addObject ("actualMoon");
     //loadModelFromFile( actualMoon, "../models/spyT.obj" );
     sphere(actualMoon);
     actualMoon->_trans._offset.SetX(-500.0);
     actualMoon->_trans._scale.set(12.0);
     actualMoon->_buffer();
     */

    // The water gets generated last -- In order for our fake transparency to work.
    Object *agua = theScene->addObject( "agua" );
    makeAgua( terrain, agua );
    agua->buffer();
    agua->drawMode( GL_TRIANGLES );

    glClearColor( 0.3, 0.5, 0.9, 1.0 );

    //Attach a model to the Camera.
    Object *cam = myScreen->_camList.active();
    ObjLoader::loadModelFromFile( cam, "../models/rainbow_dashT.obj" );
    // http://kp-shadowsquirrel.deviantart.com/
    //   art/Pony-Model-Download-Center-215266264
    cam->buffer();
    cam->drawMode( GL_TRIANGLES );
    cam->_trans._scale.set( 0.05 );
    cam->_trans._preRotation.rotateY( 180 );
    cam->propagateOLD();

    /*
     Object *rcam = cam->addObject( "right-cam" );
     ObjLoader::loadModelFromFile( rcam, "../models/rainbow_dashT.obj" );
     rcam->buffer();
     rcam->drawMode( GL_TRIANGLES );
     rcam->_trans._offset.set( 10, 0, 0 );
     cam->propagateOLD();
     rcam->propagateOLD();
     */

    // Add the propagateOLD method to the Scene Graph directly, instead of this:
    // Note: Terrain doesn't/shouldn't have children ...
    terrain->propagateOLD();

}