예제 #1
0
  /**
   * Renders the skybox using VBO
   *
   * @param drawable current rendering context
   */
  public void display(GLAutoDrawable drawable) {
    GL gl = drawable.getGL();

    // Enable arrays
    gl.glEnableClientState(GL.GL_VERTEX_ARRAY);
    gl.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY);

    if (nVertices == 0) {
      createVBO(gl);
    }

    // gl.glDisable(GL.GL_CULL_FACE);
    gl.glTexEnvf(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE, GL.GL_REPLACE);
    gl.glEnable(GL.GL_TEXTURE_2D);
    texture.load(gl);

    // Vertex coordinates
    gl.glBindBufferARB(GL.GL_ARRAY_BUFFER_ARB, VBOIds[0]);
    gl.glVertexPointer(3, GL.GL_FLOAT, 0, 0);

    gl.glBindBufferARB(GL.GL_ARRAY_BUFFER_ARB, VBOIds[1]);
    gl.glTexCoordPointer(2, GL.GL_FLOAT, 0, 0);

    // Render
    // Draw All Of The Triangles At Once
    gl.glDrawArrays(GL.GL_TRIANGLES, 0, nVertices);

    // Disable Vertex Arrays
    gl.glDisableClientState(GL.GL_VERTEX_ARRAY);
    gl.glDisableClientState(GL.GL_TEXTURE_COORD_ARRAY);

    gl.glTexEnvf(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE, GL.GL_MODULATE);
    // gl.glEnable(GL.GL_CULL_FACE);
  }
  private void display(GL gl, GLU glu, final JoglFrameBufferObject theFBO) {
    final int w = theFBO.getPixelWidth();
    final int h = theFBO.getPixelHeight();

    /* bind position data */
    gl.glEnableClientState(GL.GL_VERTEX_ARRAY);
    gl.glBindBuffer(GL.GL_ARRAY_BUFFER, _myVBO);
    gl.glVertexPointer(4, GL.GL_FLOAT, 0, 0);

    /* bind point size data */
    _myShaderManager.enable(_myPointSpriteShader);
    final int myPointSizeAttrib =
        gl.glGetAttribLocation(_myPointSpriteShader.getOpenGLID(), "vertexAttribute");
    gl.glEnableVertexAttribArray(myPointSizeAttrib);
    gl.glBindBuffer(GL.GL_ARRAY_BUFFER, _myIBO);
    gl.glVertexAttribPointer(myPointSizeAttrib, 3, GL.GL_FLOAT, false, 0, 0);
    gl.glEnable(GL.GL_VERTEX_PROGRAM_POINT_SIZE_ARB);

    /* --- */
    final JoglFrameBufferObject READ_FBO = _myFBO;
    _myShaderManager.setUniform(
        _myPointSpriteShader,
        "textureVelocity",
        READ_FBO.additional_texture(BufferInfo.SECONDARY).getTextureUnit() - GL.GL_TEXTURE0);
    _myShaderManager.setUniform(_myPointSpriteShader, "velocityThreshold", velocity_threshold);
    _myShaderManager.setUniform(_myPointSpriteShader, "sizeThreshold", size_threshold);
    _myShaderManager.setUniform(_myPointSpriteShader, "pointSize", point_size);
    _myShaderManager.setUniform(_myPointSpriteShader, "flowdirection", flow_direction);
    _myShaderManager.setUniform(_myPointSpriteShader, "collisionratio", collision_ratio);

    gl.glActiveTexture(READ_FBO.additional_texture(BufferInfo.SECONDARY).getTextureUnit());
    gl.glBindTexture(
        READ_FBO.additional_texture(BufferInfo.SECONDARY).getTextureTarget(),
        READ_FBO.additional_texture(BufferInfo.SECONDARY).getTextureID());

    JoglUtil.printGLError(gl, glu, "binding texture", true);

    gl.glDrawArrays(GL.GL_POINTS, 0, w * h);

    gl.glBindBuffer(GL.GL_ARRAY_BUFFER, 0);
    gl.glDisableClientState(GL.GL_VERTEX_ARRAY);
    gl.glDisableVertexAttribArray(myPointSizeAttrib);
    _myShaderManager.disable();
    gl.glDisable(GL.GL_VERTEX_PROGRAM_POINT_SIZE_ARB);
    gl.glBindTexture(READ_FBO.additional_texture(BufferInfo.SECONDARY).getTextureTarget(), 0);

    JoglUtil.printGLError(gl, glu, "display()", true);
  }
예제 #3
0
  private void sendLeavesInfo(GL gl) {
    // Vertex coordinates
    gl.glBindBufferARB(GL.GL_ARRAY_BUFFER_ARB, leafVBOIds[0]);
    gl.glVertexPointer(
        3,
        GL.GL_FLOAT,
        0,
        0); // specifies the location and data of an array of vertex coordinates to use when
            // rendering

    gl.glBindBufferARB(GL.GL_ARRAY_BUFFER_ARB, leafVBOIds[1]);
    gl.glTexCoordPointer(2, GL.GL_FLOAT, 0, 0);

    // Render
    // Draw All Of The Triangles At Once
    gl.glDrawArrays(GL.GL_TRIANGLES, 0, nLeafVertices);
    gl.glBindBufferARB(GL.GL_ARRAY_BUFFER, 0);
  }
예제 #4
0
 /**
  * draw the rotating cube
  *
  * @param OpenGL context
  */
 private void drawOpenCube(GL gl) {
   // send pointers to OpenGL and draw
   gl.glTexCoordPointer(2, GL.GL_FLOAT, 0, texCoords);
   gl.glVertexPointer(3, GL.GL_FLOAT, 0, vertices);
   gl.glDrawArrays(GL.GL_QUADS, 0, 24);
 }
예제 #5
0
  public void sendBoundingBoxInfo(GL gl, int part) {
    int[] VBOIds;
    int nVertices;

    if (part == 0) { // branch / heap of coins
      VBOIds = branchVBOIds;
      nVertices = nBranchVertices;
    } else {
      VBOIds = fruitVBOIds;
      nVertices = nFruitVertices;
    }

    // Vertex coordinates
    gl.glBindBufferARB(GL.GL_ARRAY_BUFFER_ARB, VBOIds[0]);
    gl.glVertexPointer(
        3,
        GL.GL_FLOAT,
        0,
        0); // specifies the location and data of an array of vertex coordinates to use when
            // rendering

    //        //Vertex attributes
    //        int programObject = tree.getProgramObject();
    //
    //        int attribLocation1 = gl.glGetAttribLocation(programObject, "FrustumValues_attrib");
    //        gl.glEnableVertexAttribArray(attribLocation1);
    //        gl.glBindBufferARB(GL.GL_ARRAY_BUFFER_ARB, VBOIds[1]);
    ////        (int index, int size, int type, boolean normalized, int stride, Buffer pointer)
    //        gl.glVertexAttribPointer(attribLocation1, 4, GL.GL_FLOAT, false, 0, 0);
    //
    //        //branch base centers
    //        int attribLocation2 = gl.glGetAttribLocation(programObject,
    // "FrustumBaseCenter_attrib");
    //        gl.glEnableVertexAttribArray(attribLocation2);
    //        gl.glBindBufferARB(GL.GL_ARRAY_BUFFER_ARB, VBOIds[2]);
    //        gl.glVertexAttribPointer(attribLocation2, 3, GL.GL_FLOAT, false, 0, 0);
    //
    //        //branch transformations
    //        int attribLocation3 = gl.glGetAttribLocation(programObject, "Ws2OsXformRow1_attrib");
    //        gl.glEnableVertexAttribArray(attribLocation3);
    //        gl.glBindBufferARB(GL.GL_ARRAY_BUFFER_ARB, VBOIds[3]);
    //        gl.glVertexAttribPointer(attribLocation3, 4, GL.GL_FLOAT, false, 0, 0);
    //
    //        int attribLocation4 = gl.glGetAttribLocation(programObject, "Ws2OsXformRow2_attrib");
    //        gl.glEnableVertexAttribArray(attribLocation4);
    //        gl.glBindBufferARB(GL.GL_ARRAY_BUFFER_ARB, VBOIds[4]);
    //        gl.glVertexAttribPointer(attribLocation4, 4, GL.GL_FLOAT, false, 0, 0);
    //
    //        int attribLocation5 = gl.glGetAttribLocation(programObject, "Ws2OsXformRow3_attrib");
    //        gl.glEnableVertexAttribArray(attribLocation5);
    //        gl.glBindBufferARB(GL.GL_ARRAY_BUFFER_ARB, VBOIds[5]);
    //        gl.glVertexAttribPointer(attribLocation5, 4, GL.GL_FLOAT, false, 0, 0);
    //
    //        int attribLocation6 = gl.glGetAttribLocation(programObject, "Ws2OsXformRow4_attrib");
    //        gl.glEnableVertexAttribArray(attribLocation6);
    //        gl.glBindBufferARB(GL.GL_ARRAY_BUFFER_ARB, VBOIds[6]);
    //        gl.glVertexAttribPointer(attribLocation6, 4, GL.GL_FLOAT, false, 0, 0);
    //
    // Render
    // Draw All Of The Triangles At Once
    gl.glDrawArrays(GL.GL_TRIANGLES, 0, nVertices);
    gl.glBindBufferARB(GL.GL_ARRAY_BUFFER, 0);

    //        gl.glDisableVertexAttribArray(attribLocation1);
    //        gl.glDisableVertexAttribArray(attribLocation2);
    //        gl.glDisableVertexAttribArray(attribLocation3);
    //        gl.glDisableVertexAttribArray(attribLocation4);
    //        gl.glDisableVertexAttribArray(attribLocation5);
    //        gl.glDisableVertexAttribArray(attribLocation6);
  }