Beispiel #1
0
  public void render(int x, int y, float extra) {
    setExtraLevel(extra);
    glPushMatrix();
    shader.bind();
    glBindVertexArray(vao);
    glEnableVertexAttribArray(0);
    glEnableVertexAttribArray(1);
    {
      glTranslatef(x, y, 0);
      glActiveTexture(GL_TEXTURE1);
      glBindTexture(GL_TEXTURE_2D, texture);
      glActiveTexture(GL_TEXTURE2);
      glBindTexture(GL_TEXTURE_2D, Texture.Lava);
      glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vio);
      glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, 0);
      glActiveTexture(GL_TEXTURE1);
      glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
      glBindTexture(GL_TEXTURE_2D, 0);

      /*
       * glTranslatef(x, y, 0); glBindTexture(GL_TEXTURE_2D, texture); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vio); glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); glBindTexture(GL_TEXTURE_2D, 0);
       */
    }
    glDisableVertexAttribArray(1);
    glDisableVertexAttribArray(0);
    glBindVertexArray(0);
    shader.release();
    glPopMatrix();
  }
Beispiel #2
0
  /**
   * Part of the deferred lighting technique, this method applies lighting through screen-space
   * calculations to the previously flat-lit world rendering stored in the primary FBO. // TODO:
   * rename sceneOpaque* FBOs to primaryA/B
   *
   * <p>See http://en.wikipedia.org/wiki/Deferred_shading as a starting point.
   */
  public void applyLightBufferPass() {

    int texId = 0;

    GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId);
    buffers.sceneOpaque.bindTexture();
    materials.lightBufferPass.setInt("texSceneOpaque", texId++);

    GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId);
    buffers.sceneOpaque.bindDepthTexture();
    materials.lightBufferPass.setInt("texSceneOpaqueDepth", texId++);

    GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId);
    buffers.sceneOpaque.bindNormalsTexture();
    materials.lightBufferPass.setInt("texSceneOpaqueNormals", texId++);

    GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId);
    buffers.sceneOpaque.bindLightBufferTexture();
    materials.lightBufferPass.setInt("texSceneOpaqueLightBuffer", texId, true);

    buffers.sceneOpaquePingPong.bind();
    graphicState.setRenderBufferMask(buffers.sceneOpaquePingPong, true, true, true);

    setViewportTo(buffers.sceneOpaquePingPong.dimensions());
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // TODO: verify this is necessary

    renderFullscreenQuad();

    graphicState.bindDisplay(); // TODO: verify this is necessary
    setViewportToWholeDisplay(); // TODO: verify this is necessary

    renderingProcess.swapSceneOpaqueFBOs();
    buffers.sceneOpaque.attachDepthBufferTo(buffers.sceneReflectiveRefractive);
  }
Beispiel #3
0
 public void start(ResourceLocation texture) {
   this.useProgram();
   GL13.glActiveTexture(GL13.GL_TEXTURE0 + MASK_TEXID);
   GL11.glEnable(GL11.GL_TEXTURE_2D);
   RenderUtils.loadTexture(texture);
   GL13.glActiveTexture(GL13.GL_TEXTURE0);
 }
Beispiel #4
0
 public static void beginWater() {
   useProgram(Shaders.ProgramWater);
   glActiveTexture(GL_TEXTURE2);
   glBindTexture(GL_TEXTURE_2D, mc.renderEngine.getTexture("/terrain_nh.png"));
   glActiveTexture(GL_TEXTURE3);
   glBindTexture(GL_TEXTURE_2D, mc.renderEngine.getTexture("/terrain_s.png"));
   glActiveTexture(GL_TEXTURE0);
 }
Beispiel #5
0
 public static void beginTerrain() {
   useProgram(Shaders.ProgramTerrain);
   glActiveTexture(GL_TEXTURE2);
   glBindTexture(GL_TEXTURE_2D, mc.renderEngine.getTexture("/terrain_nh.png"));
   glActiveTexture(GL_TEXTURE3);
   glBindTexture(GL_TEXTURE_2D, mc.renderEngine.getTexture("/terrain_s.png"));
   glActiveTexture(GL_TEXTURE0);
   FloatBuffer projection = BufferUtils.createFloatBuffer(16);
 }
 private void bindTextures(Terrain terrain) {
   TerrainTexturePack pack = terrain.getTexturePack();
   GL13.glActiveTexture(GL13.GL_TEXTURE0);
   GL11.glBindTexture(GL11.GL_TEXTURE_2D, pack.getBackgroundTexture().getTextureID());
   GL13.glActiveTexture(GL13.GL_TEXTURE1);
   GL11.glBindTexture(GL11.GL_TEXTURE_2D, pack.getRedTexture().getTextureID());
   GL13.glActiveTexture(GL13.GL_TEXTURE2);
   GL11.glBindTexture(GL11.GL_TEXTURE_2D, pack.getGreenTexture().getTextureID());
   GL13.glActiveTexture(GL13.GL_TEXTURE3);
   GL11.glBindTexture(GL11.GL_TEXTURE_2D, pack.getBlueTexture().getTextureID());
   GL13.glActiveTexture(GL13.GL_TEXTURE4);
   GL11.glBindTexture(GL11.GL_TEXTURE_2D, terrain.getBlendMap().getTextureID());
 }
Beispiel #7
0
  public void createShader(Shader shader) {
    this.shader = shader;

    glActiveTexture(GL_TEXTURE1);
    shader.bind();

    int uniform = glGetUniformLocation(shader.getID(), "texture");
    glUniform1i(uniform, 1);

    glActiveTexture(GL_TEXTURE2);
    uniform = glGetUniformLocation(shader.getID(), "extraTexture");
    glUniform1i(uniform, 2);
    shader.release();
  }
Beispiel #8
0
 public static void func_77473_a(int p_77473_0_) {
   if (field_77477_c) {
     ARBMultitexture.glActiveTextureARB(p_77473_0_);
   } else {
     GL13.glActiveTexture(p_77473_0_);
   }
 }
Beispiel #9
0
  public void thing() {

    glFrontFace(GL_CW);
    glCullFace(GL_BACK);

    glEnable(GL_TEXTURE_2D);
    glEnable(GL_CULL_FACE);
    glEnable(GL_DEPTH_TEST);
    glActiveTexture(GL_TEXTURE0);

    GL11.glViewport(0, 0, window.getCanvas().getWidth(), window.getCanvas().getHeight());

    scene.init(this);
    // these variables are here purely for ease of reading
    // i could just pass in the lastTime and time into update.
    // delta is necessary to not see any Jumps if the framerates gets lower(if you have a framerate
    // of 60 and do something like move(5) it will move 5 units 60 times per seconds
    // while if you have 30 fps it would only update 30 times per second so if you do move(5 *
    // delta) it doesnt matter what fps you have the object will move the same distance;
    float lastTime = (float) System.nanoTime() / (float) 1000000000L;
    float delta = 0;

    while (running) {
      float time = (float) System.nanoTime() / (float) 1000000000L;
      delta = time - lastTime;
      update(delta);
      delta = 0;
      render();
      lastTime = time;
    }
    destroy();
  }
  public void renderSprite(Transform transform, Texture texture, boolean hFlip, boolean vFlip) {
    GL20.glUseProgram(spriteShaderProgram.getProgramId());

    spriteVAO.bind();

    GL13.glActiveTexture(GL13.GL_TEXTURE0);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture.getTextureId());

    Matrix4f finalMatrix =
        rs.getCamera()
            .getProjectionMatrix()
            .multiply(rs.getCamera().getWorldMatrix().multiply(transform.toMatrix()));

    GL20.glUniformMatrix4fv(
        spriteShaderProgram.getUniform("mvpMatrix").getLocation(), false, finalMatrix.toBuffer());
    GL20.glUniform1i(
        spriteShaderProgram.getUniform("horizontalFlip").getLocation(),
        (hFlip) ? GL11.GL_TRUE : GL11.GL_FALSE);
    GL20.glUniform1i(
        spriteShaderProgram.getUniform("verticalFlip").getLocation(),
        (vFlip) ? GL11.GL_TRUE : GL11.GL_FALSE);
    GL20.glUniform1i(spriteShaderProgram.getUniform("sprite").getLocation(), 0);

    GL11.glDrawArrays(GL11.GL_TRIANGLE_STRIP, 0, SPRITE_NUM_VERTICES);
  }
Beispiel #11
0
  public int loadCubeMap(String[] textures) {
    int textureID = GL11.glGenTextures();

    GL13.glActiveTexture(GL13.GL_TEXTURE0);
    GL11.glBindTexture(GL13.GL_TEXTURE_CUBE_MAP, textureID);

    for (int i = 0; i < textures.length; i++) {
      TextureData data = decodeTextureFile("res/Textures/" + textures[i] + ".png");

      GL11.glTexImage2D(
          GL13.GL_TEXTURE_CUBE_MAP_POSITIVE_X + i,
          0,
          GL11.GL_RGBA,
          data.getWidth(),
          data.getHeight(),
          0,
          GL11.GL_RGBA,
          GL11.GL_UNSIGNED_BYTE,
          data.getBuffer());
    }

    GL11.glTexParameteri(GL13.GL_TEXTURE_CUBE_MAP, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
    GL11.glTexParameteri(GL13.GL_TEXTURE_CUBE_MAP, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
    GL11.glTexParameteri(GL13.GL_TEXTURE_CUBE_MAP, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE);
    GL11.glTexParameteri(GL13.GL_TEXTURE_CUBE_MAP, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE);

    this.textures.add(textureID);

    return textureID;
  }
  public void renderAnimationFrame(
      Transform transform, int frame, Texture tex, boolean horizontalFlip) {
    GL20.glUseProgram(animSpriteShaderProgram.getProgramId());

    spriteVAO.bind();
    // GL30.glBindVertexArray(flatPlane.getVaoId());

    Matrix4f finalMatrix =
        rs.getCamera()
            .getProjectionMatrix()
            .multiply(rs.getCamera().getWorldMatrix().multiply(transform.toMatrix()));

    // Diffuse Texture
    GL13.glActiveTexture(GL13.GL_TEXTURE0);
    GL11.glBindTexture(GL30.GL_TEXTURE_2D_ARRAY, tex.getTextureId());

    GL20.glUniformMatrix4fv(
        animSpriteShaderProgram.getUniform("mvpMatrix").getLocation(),
        false,
        finalMatrix.toBuffer());
    GL20.glUniform1i(animSpriteShaderProgram.getUniform("diffuseTextureAtlas").getLocation(), 0);
    GL20.glUniform1i(animSpriteShaderProgram.getUniform("currentFrame").getLocation(), frame);
    GL20.glUniform1i(
        animSpriteShaderProgram.getUniform("horizontalFlip").getLocation(),
        (horizontalFlip) ? GL11.GL_TRUE : GL11.GL_FALSE);

    GL11.glDrawArrays(GL11.GL_TRIANGLE_STRIP, 0, SPRITE_NUM_VERTICES);
  }
Beispiel #13
0
  protected void compile() {
    vao = glGenVertexArrays();
    glBindVertexArray(vao);
    {
      vbo = glGenBuffers();
      glBindBuffer(GL_ARRAY_BUFFER, vbo);
      {
        glBufferData(GL_ARRAY_BUFFER, Buffer.createFloatBuffer(vertices), GL_STATIC_DRAW);
        glVertexAttribPointer(0, 3, GL_FLOAT, false, 0, 0);
      }
      glBindBuffer(GL_ARRAY_BUFFER, 0);

      vio = glGenBuffers();
      glBindBuffer(GL_ARRAY_BUFFER, vio);
      {
        glBufferData(GL_ARRAY_BUFFER, Buffer.createByteBuffer(indices), GL_STATIC_DRAW);
      }
      glBindBuffer(GL_ARRAY_BUFFER, 0);

      vto = glGenBuffers();
      glBindBuffer(GL_ARRAY_BUFFER, vto);
      {
        glBufferData(GL_ARRAY_BUFFER, Buffer.createByteBuffer(texCoords), GL_STATIC_DRAW);
        glVertexAttribPointer(1, 3, GL_UNSIGNED_BYTE, false, 0, 1);
      }
      glBindBuffer(GL_ARRAY_BUFFER, 0);
    }
    glBindVertexArray(0);

    glActiveTexture(GL_TEXTURE1);
    shader.bind();
    int uniform = glGetUniformLocation(shader.getID(), "texture");
    glUniform1i(uniform, 1);
    shader.release();
  }
  @Override
  public void applyParameters(ShaderProgram program) {
    super.applyParameters(program);

    DefaultRenderingProcess.FBO sceneOpaque =
        DefaultRenderingProcess.getInstance().getFBO("sceneOpaque");

    int texId = 0;
    GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId);
    sceneOpaque.bindTexture();
    program.setInt("texSceneOpaque", texId++);

    GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId);
    sceneOpaque.bindDepthTexture();
    program.setInt("texSceneOpaqueDepth", texId++);

    GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId);
    sceneOpaque.bindNormalsTexture();
    program.setInt("texSceneOpaqueNormals", texId++);

    DefaultRenderingProcess.FBO sceneTransparent =
        DefaultRenderingProcess.getInstance().getFBO("sceneTransparent");

    GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId);
    sceneTransparent.bindTexture();
    program.setInt("texSceneTransparent", texId++);

    GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId);
    sceneTransparent.bindDepthTexture();
    program.setInt("texSceneTransparentDepth", texId++);

    GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId);
    sceneTransparent.bindNormalsTexture();
    program.setInt("texSceneTransparentNormals", texId++);

    if (CoreRegistry.get(Config.class).getRendering().isSsao()) {
      DefaultRenderingProcess.FBO ssao =
          DefaultRenderingProcess.getInstance().getFBO("ssaoBlurred1");
      GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId);
      ssao.bindTexture();
      program.setInt("texSsao", texId++);
    }

    if (CoreRegistry.get(Config.class).getRendering().isOutline()) {
      DefaultRenderingProcess.FBO sobel = DefaultRenderingProcess.getInstance().getFBO("sobel");
      GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId);
      sobel.bindTexture();
      program.setInt("texEdges", texId++);

      program.setFloat("outlineDepthThreshold", (Float) outlineDepthThreshold.getValue());
      program.setFloat("outlineThickness", (Float) outlineThickness.getValue());
    }

    program.setFloat("shoreStart", (Float) shoreStart.getValue());
    program.setFloat("shoreEnd", (Float) shoreEnd.getValue());
  }
  public void applyParameters(ShaderProgram program) {
    LocalPlayer localPlayer = CoreRegistry.get(LocalPlayer.class);

    GL13.glActiveTexture(GL13.GL_TEXTURE0);
    glBindTexture(GL11.GL_TEXTURE_2D, terrainTex.getId());

    if (localPlayer != null) program.setInt("carryingTorch", localPlayer.isCarryingTorch() ? 1 : 0);
  }
  @Override
  public void applyParameters(Material program) {
    super.applyParameters(program);

    int texId = 0;
    GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId);
    LwjglRenderingProcess.getInstance().bindFboTexture("sceneFinal");
    program.setInt("texSceneFinal", texId++, true);
  }
    void unbind() {
      GL11.glPopAttrib();

      GL11.glMatrixMode(GL11.GL_PROJECTION);
      GL11.glPopMatrix();

      GL11.glMatrixMode(GL11.GL_MODELVIEW);
      GL11.glPopMatrix();

      if (lightmapEnabled) {
        GL13.glActiveTexture(GL13.GL_TEXTURE1);
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        GL13.glActiveTexture(GL13.GL_TEXTURE0);
      }
      GL11.glEnable(GL11.GL_BLEND);
      GLAPI.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

      EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, 0);
    }
Beispiel #18
0
 private void prepareTexturedModel(TexturedModel model) {
   RawModel rawModel = model.getRawModel();
   GL30.glBindVertexArray(rawModel.getVaoID());
   GL20.glEnableVertexAttribArray(0);
   GL20.glEnableVertexAttribArray(1);
   GL20.glEnableVertexAttribArray(2);
   ModelTexture texture = model.getTexture();
   shader.loadNumberOfRows(texture.getNumberOfRows());
   if (texture.isHasTransparency()) {
     MasterRenderer.disableCulling();
   }
   shader.loadShineVariables(texture.getShineDamper(), texture.getReflectivity());
   GL13.glActiveTexture(GL13.GL_TEXTURE0);
   GL11.glBindTexture(GL11.GL_TEXTURE_2D, model.getTexture().getID());
   shader.loadUseSpecularMap(texture.hasSpecularMap());
   if (texture.hasSpecularMap()) {
     GL13.glActiveTexture(GL13.GL_TEXTURE1);
     GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture.getSpecularMap());
   }
 }
 public void render(Camera camera) {
   shader.start();
   shader.loadViewMatrix(camera);
   GL30.glBindVertexArray(cube.getVaoID());
   GL20.glEnableVertexAttribArray(0);
   GL13.glActiveTexture(GL13.GL_TEXTURE0);
   GL11.glBindTexture(GL13.GL_TEXTURE_CUBE_MAP, texture);
   GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, cube.getVertexCount());
   GL20.glDisableVertexAttribArray(0);
   GL30.glBindVertexArray(0);
   shader.stop();
 }
    void bind() {
      EXTFramebufferObject.glBindFramebufferEXT(
          EXTFramebufferObject.GL_FRAMEBUFFER_EXT, frameBuffer);

      GL11.glPushAttrib(glAttributes);
      GL11.glViewport(x0, y0, width, height);
      GL11.glEnable(GL11.GL_SCISSOR_TEST);
      GL11.glScissor(x0, y0, width, height);

      lightmapEnabled = false;
      if (gl13Supported) {
        GL13.glActiveTexture(GL13.GL_TEXTURE1);
        lightmapEnabled = GL11.glIsEnabled(GL11.GL_TEXTURE_2D);
        if (lightmapEnabled) {
          GL11.glDisable(GL11.GL_TEXTURE_2D);
        }
        GL13.glActiveTexture(GL13.GL_TEXTURE0);
      }
      GL11.glEnable(GL11.GL_TEXTURE_2D);
      GL11.glDisable(GL11.GL_DEPTH_TEST);
      GLAPI.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
      GL11.glDisable(GL11.GL_LIGHTING);
      GL11.glEnable(GL11.GL_ALPHA_TEST);
      GLAPI.glAlphaFunc(GL11.GL_GREATER, 0.01f);
      if (useGL13) {
        GL11.glDisable(GL13.GL_MULTISAMPLE);
      }

      GLAPI.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
      GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);

      GL11.glMatrixMode(GL11.GL_PROJECTION);
      GL11.glPushMatrix();
      GL11.glLoadIdentity();
      GL11.glOrtho(-1.0f, 1.0f, -1.0f, 1.0f, -1.0f, 1.0f);

      GL11.glMatrixMode(GL11.GL_MODELVIEW);
      GL11.glPushMatrix();
      GL11.glLoadIdentity();
    }
  public void render(Camera camera) {
    shader.start();
    shader.loadViewMatrix(camera);
    GL30.glBindVertexArray(sun.getRawModel().getVaoID());
    GL20.glEnableVertexAttribArray(0);
    GL20.glEnableVertexAttribArray(1);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    shader.loadBlendFactor();
    GL13.glActiveTexture(GL13.GL_TEXTURE0);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture);
    GL13.glActiveTexture(GL13.GL_TEXTURE1);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, redSunTexture);
    billboardRotation(camera);
    GL11.glDrawElements(
        GL11.GL_TRIANGLES, sun.getRawModel().getVertexCount(), GL11.GL_UNSIGNED_INT, 0);

    GL11.glDisable(GL11.GL_BLEND);
    GL20.glDisableVertexAttribArray(0);
    GL20.glDisableVertexAttribArray(1);
    GL30.glBindVertexArray(0);
    shader.stop();
  }
Beispiel #22
0
  private void prepareTexturedModel(TexturedModel model) {
    RawModel rawModel = model.getModel();
    GL30.glBindVertexArray(rawModel.getVaoID());
    GL20.glEnableVertexAttribArray(0); // vertices array
    GL20.glEnableVertexAttribArray(1); // textures array
    GL20.glEnableVertexAttribArray(2); // normals array

    { // Load Texture and shine
      ModelTexture texture = model.getTexture();
      shader.loadShineVariables(texture.getShineDamper(), texture.getReflectivity());

      GL13.glActiveTexture(GL13.GL_TEXTURE0);
      GL11.glBindTexture(GL11.GL_TEXTURE_2D, model.getTexture().getTextureID());
    }
  }
Beispiel #23
0
    @Override
    public void prepare(Object texObj, float alpha, int fbufWidth, int fbufHeight) {
      ctx.checkGLError("textureShader.prepare start");
      boolean wasntAlreadyActive = super.prepare(fbufWidth, fbufHeight);
      if (wasntAlreadyActive) {
        glActiveTexture(GL_TEXTURE0);
        glUniform1i(uTexture, 0);
      }

      int tex = (Integer) texObj;
      if (wasntAlreadyActive || tex != lastTex || alpha != lastAlpha) {
        flush();
        glUniform1f(uAlpha, alpha);
        lastAlpha = alpha;
        lastTex = tex;
        ctx.checkGLError("textureShader.prepare end");
      }
    }
Beispiel #24
0
  /**
   * Method called by the World Class to render the Tile.
   *
   * @param x : location to where the Tile is going to be rendered.
   * @param y : location to where the Tile is going to be rendered.
   * @param w : instance of the World Class
   * @param ent : List of entities that emit light.
   */
  public void render(int x, int y, World w, ArrayList<Entity> ent) {
    // Binding the Uniforms to make the light effects.
    bindUniforms(w, ent);

    // Setting up OpenGL for render
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ZERO);

    // Updating the Tile coordinates.
    this.x = x;
    this.y = y;
    glTranslatef(x, y, 0);
    // Activating and Binding the Tile Texture.
    glActiveTexture(GL_TEXTURE0);
    glBindTexture(GL_TEXTURE_2D, this.tex);
    // Sending the texture to the shader.
    glUniform1i(glGetUniformLocation(shade.getShader(), "texture"), 0);

    // Drawing the QUAD.
    glBegin(GL_QUADS);
    {
      glTexCoord2f(0, 0);
      glVertex2f(0, 0);

      glTexCoord2f(0, 1);
      glVertex2f(0, this.height);

      glTexCoord2f(1, 1);
      glVertex2f(this.width, this.height);

      glTexCoord2f(1, 0);
      glVertex2f(this.width, 0);
    }
    glEnd();
    // Releasing the Texture.
    glBindTexture(GL_TEXTURE_2D, 0);
    // Getting the location back to the inicial coordinates.
    glTranslatef(-x, -y, 0);

    // Disabling BLEND and releasing shader for next render.
    glDisable(GL_BLEND);
    shade.release();
    glClear(GL_STENCIL_BUFFER_BIT);
  }
Beispiel #25
0
  private void applyOculusDistortion(FBO inputBuffer) {
    materials.ocDistortion.enable();

    int texId = 0;
    GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId);
    inputBuffer.bindTexture();
    materials.ocDistortion.setInt("texInputBuffer", texId, true);

    if (renderingProcess.isNotTakingScreenshot()) {
      updateOcShaderParametersForVP(
          0,
          0,
          fullScale.width() / 2,
          fullScale.height(),
          WorldRenderer.WorldRenderingStage.LEFT_EYE);
      renderFullscreenQuad(0, 0, Display.getWidth(), Display.getHeight());
      updateOcShaderParametersForVP(
          fullScale.width() / 2 + 1,
          0,
          fullScale.width() / 2,
          fullScale.height(),
          WorldRenderer.WorldRenderingStage.RIGHT_EYE);
      renderFullscreenQuad(0, 0, Display.getWidth(), Display.getHeight());

    } else {
      // what follows -should- work also when there is no screenshot being taken, but somehow it
      // doesn't, hence the block above
      updateOcShaderParametersForVP(
          0,
          0,
          fullScale.width() / 2,
          fullScale.height(),
          WorldRenderer.WorldRenderingStage.LEFT_EYE);
      renderFullscreenQuad(0, 0, fullScale.width(), fullScale.height());
      updateOcShaderParametersForVP(
          fullScale.width() / 2 + 1,
          0,
          fullScale.width() / 2,
          fullScale.height(),
          WorldRenderer.WorldRenderingStage.RIGHT_EYE);
      renderFullscreenQuad(0, 0, fullScale.width(), fullScale.height());
    }
  }
  /**
   * Renders entieis to the shadow map. Each model is first bound and then all of the entities using
   * that model are rendered to the shadow map.
   *
   * @param entities - the entities to be rendered to the shadow map.
   */
  protected void render(Map<TexturedModel, List<Entity>> entities) {
    for (TexturedModel model : entities.keySet()) {
      RawModel rawModel = model.getRawModel();
      bindModel(rawModel);
      GL13.glActiveTexture(GL13.GL_TEXTURE0);
      GL11.glBindTexture(GL11.GL_TEXTURE_2D, model.getTexture().getID());
      if (model.getTexture().hasTransparency()) MasterRenderer.disableCulling();

      for (Entity entity : entities.get(model)) {
        prepareInstance(entity);
        GL11.glDrawElements(GL11.GL_TRIANGLES, rawModel.getVertexCount(), GL11.GL_UNSIGNED_INT, 0);
      }

      if (model.getTexture().hasTransparency()) MasterRenderer.enableCulling();
    }
    GL20.glDisableVertexAttribArray(0);
    GL20.glDisableVertexAttribArray(1);
    GL30.glBindVertexArray(0);
  }
Beispiel #27
0
  public void renderBuffer(OpenGLBuffer buffer, ITextureObject texture) {
    GL13.glActiveTexture(GL13.GL_TEXTURE0 + 0);
    texture.bind();
    glEnableClientState(GL_VERTEX_ARRAY);
    glEnableVertexAttribArray(0);
    glEnableVertexAttribArray(1);
    glEnableVertexAttribArray(2);

    glBindBuffer(GL_ARRAY_BUFFER, buffer.getVboID());
    glVertexAttribPointer(0, 3, GL_FLOAT, false, Vertex.SIZE_IN_FLOATS * 4, 0);
    glVertexAttribPointer(1, 2, GL_FLOAT, false, Vertex.SIZE_IN_FLOATS * 4, 12);
    glVertexAttribPointer(2, 3, GL_FLOAT, false, Vertex.SIZE_IN_FLOATS * 4, 20);

    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffer.getIboID());
    glDrawElements(GL_TRIANGLES, buffer.getIndicesCount(), GL_UNSIGNED_INT, 0);

    glDisableVertexAttribArray(2);
    glDisableVertexAttribArray(1);
    glDisableVertexAttribArray(0);
  }
Beispiel #28
0
 public void render(List<GuiTexture> guis) {
   shader.start();
   GL30.glBindVertexArray(quad.getVaoID());
   GL20.glEnableVertexAttribArray(0);
   GL11.glEnable(GL11.GL_BLEND);
   GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
   GL11.glDisable(GL11.GL_DEPTH_TEST);
   for (GuiTexture gui : guis) {
     GL13.glActiveTexture(GL13.GL_TEXTURE0);
     GL11.glBindTexture(GL11.GL_TEXTURE_2D, gui.getTexture());
     Matrix4f matrix = Maths.createTransformationMatrix(gui.getPosition(), gui.getScale());
     shader.loadTransformation(matrix);
     GL11.glDrawArrays(GL11.GL_TRIANGLE_STRIP, 0, quad.getVertexCount());
   }
   GL11.glEnable(GL11.GL_DEPTH_TEST);
   GL11.glDisable(GL11.GL_BLEND);
   GL20.glDisableVertexAttribArray(0);
   GL30.glBindVertexArray(0);
   shader.stop();
 }
Beispiel #29
0
  private void generateHighPass() {
    materials.highPass.enable();
    materials.highPass.setFloat("highPassThreshold", bloomHighPassThreshold, true);

    int texId = 0;
    GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId);
    buffers.sceneOpaque.bindTexture();
    materials.highPass.setInt("tex", texId);

    //        GL13.glActiveTexture(GL13.GL_TEXTURE0 + texId);
    //        buffers.sceneOpaque.bindDepthTexture();
    //        program.setInt("texDepth", texId++);

    buffers.sceneHighPass.bind();

    setViewportTo(buffers.sceneHighPass.dimensions());
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    renderFullscreenQuad();

    graphicState.bindDisplay();
    setViewportToWholeDisplay();
  }
Beispiel #30
0
 public void render() {
   glPushMatrix();
   glEnable(GL_BLEND);
   shader.bind();
   glBindVertexArray(vao);
   glEnableVertexAttribArray(0);
   glEnableVertexAttribArray(1);
   {
     glTranslatef(x, y, 0);
     glActiveTexture(GL_TEXTURE1);
     glBindTexture(GL_TEXTURE_2D, texture);
     glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vio);
     glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, 0);
     glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
     glBindTexture(GL_TEXTURE_2D, 0);
   }
   glDisableVertexAttribArray(1);
   glDisableVertexAttribArray(0);
   glBindVertexArray(0);
   shader.release();
   glDisable(GL_BLEND);
   glPopMatrix();
 }