예제 #1
0
  void onCreate() {

    loadProgram(program, "resources/billboard");
    rh.loadTexture(texture, "resources/eye.png");

    camera = Camera(glm::radians(60.0), (float)width/(float)height, 0.01, 100.0).translate(vec3(0.0,0.0,-2.0));


    Utils::randomSeed();
    MeshData points;

    for (int i = 0; i < 1; i++) {
      MeshUtils::addPoint(points, Utils::randomVec3(-1.0,1.0), Utils::randomVec3(0.0,1.0));

    }

    mb1.init(points, posLoc, -1, texCoordLoc, -1);

    proj = glm::perspective(glm::radians(45.0), 1.0, 0.1, 100.0);
    view = glm::lookAt(vec3(0,0,-2), vec3(0,0,0), vec3(0,1,0) );
    model = glm::mat4();

    glDisable(GL_DEPTH_TEST);


    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    glViewport(0, 0, width, height);
    glClearColor(0.3,0.3,0.3,1.0);
  }
예제 #2
0
  void onCreate() {
    
    rh.loadTexture(texture, "resources/hubble.jpg");
    texture.minFilter(GL_NEAREST);
    texture.maxFilter(GL_NEAREST);
    
    rh.loadProgram(textureProgram, "resources/texture", posLoc, -1, texCoordLoc, -1);
    rh.loadProgram(phongProgram, "resources/phong", posLoc, normalLoc, texCoordLoc, -1);
    rh.loadProgram(programColor, "resources/color", posLoc, normalLoc, -1, colorLoc);
    
    MeshData md1;
    addCube(md1, true, 0.95);
    
    MeshData md2;
    addCube(md2, true, 0.5);
    
    MeshData md3;
    addCube(md3, 0.33); //this version makes normals, texcoords, and colors each side with a different default color
    
    cubeMeshBuffer1.init(md1, posLoc, normalLoc, texCoordLoc, -1);
    cubeMeshBuffer2.init(md2, posLoc, normalLoc, texCoordLoc, -1);
    
    cubeMeshBuffer3.init(md3, posLoc, normalLoc, -1, colorLoc);
    
    
    fbo.create(32, 32);

millisToNano(1000);
    
    rotateBehavior = Behavior(now()).delay(1000).length(5000).range(vec3(3.14, 3.14, 3.14)).reversing(true).repeats(-1).sine();
    
    
    proj = glm::perspective(45.0, 1.0, 0.1, 100.0);
    view = glm::lookAt(vec3(0.0,0.0,5), vec3(0,0,0), vec3(0,1,0) );
    model = glm::mat4();
    
    glEnable(GL_DEPTH_TEST);
    glViewport(0, 0, width, height);
  }