Java 类org.lwjgl.opengl.GL13 实例源码

项目:MRCEngine    文件:EntityRenderer.java   
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();

    if(texture.isHasTransparency()) {
        MasterRenderer.disableCulling();
    }

    shader.loadFakeLightingVariable(texture.isUseFakeLighting());
    shader.loadShineVariables(texture.getShineDamper(), texture.getReflectivity());

    GL13.glActiveTexture(GL13.GL_TEXTURE0);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, model.getTexture().getID());
}
项目:betaexpansion    文件:EntityPickupFX.java   
public void renderParticle(Tessellator tessellator, float f, float f1, float f2, float f3, float f4, float f5)
{
    float f6 = ((float)field_678_p + f) / (float)field_677_q;
    f6 *= f6;
    double d = field_675_a.posX;
    double d1 = field_675_a.posY;
    double d2 = field_675_a.posZ;
    double d3 = field_679_o.lastTickPosX + (field_679_o.posX - field_679_o.lastTickPosX) * (double)f;
    double d4 = field_679_o.lastTickPosY + (field_679_o.posY - field_679_o.lastTickPosY) * (double)f + (double)field_676_r;
    double d5 = field_679_o.lastTickPosZ + (field_679_o.posZ - field_679_o.lastTickPosZ) * (double)f;
    double d6 = d + (d3 - d) * (double)f6;
    double d7 = d1 + (d4 - d1) * (double)f6;
    double d8 = d2 + (d5 - d2) * (double)f6;
    int i = MathHelper.floor_double(d6);
    int j = MathHelper.floor_double(d7 + (double)(yOffset / 2.0F));
    int k = MathHelper.floor_double(d8);
    int l = getRenderBrightness(f);
    int i1 = l % 0x10000;
    int j1 = l / 0x10000;
    GL13.glMultiTexCoord2f(33985 /*GL_TEXTURE1_ARB*/, (float)i1 / 1.0F, (float)j1 / 1.0F);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);        
    d6 -= interpPosX;
    d7 -= interpPosY;
    d8 -= interpPosZ;
    RenderManager.instance.renderEntityWithPosYaw(field_675_a, (float)d6, (float)d7, (float)d8, field_675_a.rotationYaw, f);
}
项目:open-world    文件:WaterRegion.java   
/**
    * Renders the water.
    * @param camera
    */
   public void render(final PerspectiveCamera camera, final DirectionalLight light) {
shader.bind();
shader.setUniform("m_model", transformation);
shader.setUniform("m_view", camera.getView());
shader.setUniform("m_proj", camera.getProjection());
shader.setUniform("move_factor", moveFactor);
shader.setUniform("camera_pos", camera.getPosition());
shader.setUniform("light_pos", light.getDirection().negate(null));

framebuffer.bindTexture();
dudvTexture.bind(GL13.GL_TEXTURE1);
normalTexture.bind(GL13.GL_TEXTURE2);

MESH.render();
   }
项目:open-world    文件:Application.java   
/**
    * Initialize OpenGL to default settings
    */
   private void initGL() {
// Set the clear color
GL11.glClearColor(0, 0, 0, 1);

// Setup viewport
GL11.glViewport(0, 0, WINDOW.getWidth(), WINDOW.getHeight());

// Setup depth testing
GL11.glEnable(GL11.GL_DEPTH_TEST);

// Setup face culling (ccw)
GL11.glFrontFace(GL11.GL_CCW);
GL11.glCullFace(GL11.GL_BACK);
GL11.glEnable(GL11.GL_CULL_FACE);

// Setup blending
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);

// Enable MSAA
GL11.glEnable(GL13.GL_MULTISAMPLE);
   }
项目:bia-engine    文件:EntityRenderer.java   
private void prepareTexturedModel(final TexturedModel model) {
    GL30.glBindVertexArray(model.getRawModel().getVaoId());
    GL20.glEnableVertexAttribArray(0);
    GL20.glEnableVertexAttribArray(1);
    GL20.glEnableVertexAttribArray(2);
    if (model.getTexture().isHasTransparency()) {
        MasterRenderer.disableCulling();
    }
    shader.loadFakeLightingVariable(model.getTexture().isUseFakeLighting());
    shader.loadShineVariables(
            model.getTexture().getShineDamper(),
            model.getTexture().getReflectivity()
    );
    GL13.glActiveTexture(GL13.GL_TEXTURE0);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, model.getTexture().getTextureId());
}
项目:lambda    文件:Texture.java   
/**
 * Creates an OpenGL texture based on a given Image
 * @param id OpenGL reference id to create texture in
 * @param image 
 */
private void createTexture(int id, Image image) {
    // Set as texture 0
    GL13.glActiveTexture(GL13.GL_TEXTURE0);

    bind();

    // Set pixel storage mode
    GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1);

    // Setup texture
    GL11.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    GL11.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

    GL11.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, image.width, image.height, 0, GL_RGBA, GL_UNSIGNED_BYTE, image.buffer);
    GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D);

    unbind();
}
项目:Elgin-Plant-Game    文件:TerrainRenderer.java   
/**
 * Binds each texture to a the terrain shaders.
 * @param terrain - Terrain containing the textures to blend.
 */
private void bindTextures(Terrain terrain) {
    TerrainTexturePack texturePack = terrain.getTexturePack();

    GL13.glActiveTexture(GL13.GL_TEXTURE0);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, texturePack.getBackgroundTexture().getTextureID());

    GL13.glActiveTexture(GL13.GL_TEXTURE1);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, texturePack.getRedTexture().getTextureID());

    GL13.glActiveTexture(GL13.GL_TEXTURE2);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, texturePack.getGreenTexture().getTextureID());

    GL13.glActiveTexture(GL13.GL_TEXTURE3);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, texturePack.getBlueTexture().getTextureID());

    GL13.glActiveTexture(GL13.GL_TEXTURE4);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, texturePack.getBlendMap().getTextureID());

}
项目:BaseClient    文件:OpenGlHelper.java   
/**
 * Sets the current coordinates of the given lightmap texture
 */
public static void setLightmapTextureCoords(int target, float p_77475_1_, float p_77475_2_)
{
    if (arbMultitexture)
    {
        ARBMultitexture.glMultiTexCoord2fARB(target, p_77475_1_, p_77475_2_);
    }
    else
    {
        GL13.glMultiTexCoord2f(target, p_77475_1_, p_77475_2_);
    }

    if (target == lightmapTexUnit)
    {
        lastBrightnessX = p_77475_1_;
        lastBrightnessY = p_77475_2_;
    }
}
项目:BaseClient    文件:GlStateManager.java   
public static void checkBoundTexture()
{
    if (Config.isMinecraftThread())
    {
        int i = GL11.glGetInteger(GL13.GL_ACTIVE_TEXTURE);
        int j = GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D);
        int k = getActiveTextureUnit();
        int l = getBoundTexture();

        if (l > 0)
        {
            if (i != k || j != l)
            {
                Config.dbg("checkTexture: act: " + k + ", glAct: " + i + ", tex: " + l + ", glTex: " + j);
            }
        }
    }
}
项目:BaseClient    文件:OpenGlHelper.java   
/**
 * Sets the current coordinates of the given lightmap texture
 */
public static void setLightmapTextureCoords(int target, float p_77475_1_, float p_77475_2_)
{
    if (arbMultitexture)
    {
        ARBMultitexture.glMultiTexCoord2fARB(target, p_77475_1_, p_77475_2_);
    }
    else
    {
        GL13.glMultiTexCoord2f(target, p_77475_1_, p_77475_2_);
    }

    if (target == lightmapTexUnit)
    {
        lastBrightnessX = p_77475_1_;
        lastBrightnessY = p_77475_2_;
    }
}
项目:Backmemed    文件:OpenGlHelper.java   
/**
 * Sets the current coordinates of the given lightmap texture
 */
public static void setLightmapTextureCoords(int target, float p_77475_1_, float t)
{
    if (arbMultitexture)
    {
        ARBMultitexture.glMultiTexCoord2fARB(target, p_77475_1_, t);
    }
    else
    {
        GL13.glMultiTexCoord2f(target, p_77475_1_, t);
    }

    if (target == lightmapTexUnit)
    {
        lastBrightnessX = p_77475_1_;
        lastBrightnessY = t;
    }
}
项目:Backmemed    文件:GlStateManager.java   
public static void checkBoundTexture()
{
    if (Config.isMinecraftThread())
    {
        int i = GL11.glGetInteger(GL13.GL_ACTIVE_TEXTURE);
        int j = GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D);
        int k = getActiveTextureUnit();
        int l = getBoundTexture();

        if (l > 0)
        {
            if (i != k || j != l)
            {
                Config.dbg("checkTexture: act: " + k + ", glAct: " + i + ", tex: " + l + ", glTex: " + j);
            }
        }
    }
}
项目:OpenGL-Animation    文件:DisplayManager.java   
public static void createDisplay() {
    try {
        Display.setDisplayMode(new DisplayMode(WIDTH, HEIGHT));
        ContextAttribs attribs = new ContextAttribs(3, 2).withProfileCore(true).withForwardCompatible(true);
        Display.create(new PixelFormat().withDepthBits(24).withSamples(4), attribs);
        Display.setTitle(TITLE);
        Display.setInitialBackground(1, 1, 1);
        GL11.glEnable(GL13.GL_MULTISAMPLE);
    } catch (LWJGLException e) {
        e.printStackTrace();
        System.err.println("Couldn't create display!");
        System.exit(-1);
    }
    GL11.glViewport(0, 0, WIDTH, HEIGHT);
    lastFrameTime = getCurrentTime();
}
项目:CustomWorldGen    文件:OpenGlHelper.java   
/**
 * Sets the current coordinates of the given lightmap texture
 */
public static void setLightmapTextureCoords(int target, float p_77475_1_, float t)
{
    if (arbMultitexture)
    {
        ARBMultitexture.glMultiTexCoord2fARB(target, p_77475_1_, t);
    }
    else
    {
        GL13.glMultiTexCoord2f(target, p_77475_1_, t);
    }

    if (target == lightmapTexUnit)
    {
        lastBrightnessX = p_77475_1_;
        lastBrightnessY = t;
    }
}
项目:OcclusionQueries    文件:TextureUtils.java   
public static int loadCubeMap(MyFile[] textureFiles) {
    int texID = GL11.glGenTextures();
    GL13.glActiveTexture(GL13.GL_TEXTURE0);
    GL11.glBindTexture(GL13.GL_TEXTURE_CUBE_MAP, texID);
    GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1);
    for (int i = 0; i < textureFiles.length; i++) {
        TextureData data = decodeTextureFile(textureFiles[i]);
        GL11.glTexImage2D(GL13.GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL11.GL_RGBA, data.getWidth(),
                data.getHeight(), 0, GL12.GL_BGRA, 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);
    GL11.glBindTexture(GL13.GL_TEXTURE_CUBE_MAP, 0);
    return texID;
}
项目:3d-Engine    文件:GuiRenderer.java   
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();
}
项目:3d-Engine    文件:EntityRenderer.java   
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.loadFakeLightingVariable(texture.isUseFakeLighting());
    shader.loadShineVariables(texture.getShineDamper(), texture.getReflectivity());
    GL13.glActiveTexture(GL13.GL_TEXTURE0);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, model.getTexture().getID());
}
项目:3d-Engine    文件:DisplayManager.java   
public static void createDisplay() {
    ContextAttribs attribs = new ContextAttribs(3, 3)
            .withForwardCompatible(true)
            .withProfileCore(true);
    try {
        Display.setDisplayMode(new DisplayMode(WIDTH, HEIGHT));
        Display.create(new PixelFormat(), attribs);
        Display.setTitle("Our First Display!");
        GL11.glEnable(GL13.GL_MULTISAMPLE);
    } catch (LWJGLException e) {
        e.printStackTrace();
    }

    GL11.glViewport(0, 0, WIDTH, HEIGHT);
    lastFrameTime = getCurrentTime();
}
项目:3d-Engine    文件:WaterRenderer.java   
private void prepareRender(Camera camera, Light sun){
    shader.start();
    shader.loadViewMatrix(camera);
    moveFactor += WAVE_SPEED * DisplayManager.getFrameTimeSeconds();
    moveFactor %= 1;
    shader.loadMoveFactor(moveFactor);
    shader.loadLight(sun);
    GL30.glBindVertexArray(quad.getVaoID());
    GL20.glEnableVertexAttribArray(0);
    GL13.glActiveTexture(GL13.GL_TEXTURE0);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, fbos.getReflectionTexture());
    GL13.glActiveTexture(GL13.GL_TEXTURE1);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, fbos.getRefractionTexture());
    GL13.glActiveTexture(GL13.GL_TEXTURE2);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, dudvTexture);
    GL13.glActiveTexture(GL13.GL_TEXTURE3);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, normalMap);
    GL13.glActiveTexture(GL13.GL_TEXTURE4);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, fbos.getRefractionDepthTexture());
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
}
项目:3d-Engine    文件:NormalMappingRenderer.java   
private void prepareTexturedModel(TexturedModel model) {
    RawModel rawModel = model.getRawModel();
    GL30.glBindVertexArray(rawModel.getVaoID());
    GL20.glEnableVertexAttribArray(0);
    GL20.glEnableVertexAttribArray(1);
    GL20.glEnableVertexAttribArray(2);
    GL20.glEnableVertexAttribArray(3);
    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());
    GL13.glActiveTexture(GL13.GL_TEXTURE1);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, model.getTexture().getNormalMap());
}
项目:opsu-dance    文件:CurveRenderState.java   
/**
 * Restore the old OpenGL state that's backed up in {@code state}.
 * @param state the old state to restore
 */
private void restoreRenderState(RenderState state) {
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glPopMatrix();
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glPopMatrix();
    GL11.glEnable(GL11.GL_BLEND);
    GL20.glUseProgram(state.oldProgram);
    GL13.glActiveTexture(state.texUnit);
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, state.oldArrayBuffer);
    if (!state.depthWriteEnabled)
        GL11.glDepthMask(false);
    if (!state.depthEnabled)
        GL11.glDisable(GL11.GL_DEPTH_TEST);
    if (state.texEnabled)
        GL11.glEnable(GL11.GL_TEXTURE_2D);
    if (state.smoothedPoly)
        GL11.glEnable(GL11.GL_POLYGON_SMOOTH);
    if (!state.blendEnabled)
        GL11.glDisable(GL11.GL_BLEND);
}
项目:geoxygene    文件:BinaryGradientTexture.java   
/**
 * initialize the texture rendering
 */
@Override
public boolean initializeRendering(int programId) {
    Integer texIndex = this.getTextureId();
    if (texIndex == null) {
        GL11.glDisable(GL_TEXTURE_2D);
        return false;
    }
    glEnable(GL_TEXTURE_2D);
    GL13.glActiveTexture(this.textureSlot);
    glBindTexture(GL_TEXTURE_2D, texIndex);
    // vMin has a special value '-1' = out of polygon
    // consider that vMin is always equal to zero
    float uMin = (float) (double) this.binaryGradientImage.getuMin();
    float vMin = 0;
    float uRange = (float) (this.binaryGradientImage.getuMax() - this.binaryGradientImage
            .getuMin());
    float vRange = (float) (double) (this.binaryGradientImage.getvMax());
    GL20.glUniform2f(GL20.glGetUniformLocation(programId,
            gradientUVMinUniformVarname), uMin, vMin);
    GL20.glUniform2f(GL20.glGetUniformLocation(programId,
            gradientUVRangeUniformVarname), uRange, vRange);
    return true;
}
项目:geoxygene    文件:RasterImage.java   
/**
     * initialize the texture rendering
     * 
     * @param programId
     */

    public boolean initializeRendering(int programId) {

        // Enable GL texture
//        glEnable(GL_TEXTURE_2D);

        // Go find imageID and pass buffer of data to GPU
        Integer imageIndex = this.getImageId(); 

        // Very important, activate the texture Slot
        GL13.glActiveTexture(this.getTextureSlot());
        // Send the uniform to shader and bind it
//        glUniform1i(GL20.glGetUniformLocation(programId, "bufferImage"), imageIndex);
        glBindTexture(GL_TEXTURE_2D, imageIndex);

        return true;
    }
项目:geoxygene    文件:LayerViewGL4Canvas.java   
/**
 * Allow to read the ping-pong textures stored by the FBO. Depending on the
 * current ping-pong state, the first or second ping-pong texture will be
 * activated and set to the given {@link GLProgram}.
 * 
 * @param program
 *            the {@link GLProgram} that will use the FBO ping-pong texture
 * @throws GLException
 */
public void readFromPingPong(GLProgram program) throws GLException {
    if (this.currentFboPingPongIndex == 2) {
        GLTools.glCheckError("FBO ATTACHMENT  bound");
        GL13.glActiveTexture(GL13.GL_TEXTURE0 + 2);
        GLTools.glCheckError("FBO bound texture 1");
        glBindTexture(GL_TEXTURE_2D, this.getFboPingPongTextureId1());
        GLTools.glCheckError("FBO bound texture");
        program.setUniform("colorTexture1", 2);
    } else {
        GLTools.glCheckError("FBO ATTACHMENT 2 bound");
        GL13.glActiveTexture(GL13.GL_TEXTURE0 + 3);
        GLTools.glCheckError("FBO bound texture 2");
        glBindTexture(GL_TEXTURE_2D, this.getFboPingPongTextureId2());
        GLTools.glCheckError("FBO bound texture");
        program.setUniform("colorTexture1", 3);
    }

}
项目:FEMultiPlayer-V2    文件:PaletteSwapper.java   
/**
 * Setup.
 *
 * @param u the u
 * @return the shader args
 */
public static ShaderArgs setup(FightUnit u) {
    Unit unit = u.getUnit();
    ShaderArgs args = new ShaderArgs();
    if(unit.getTheClass().name.equals("Lord")) return args;
    String c = unit.functionalClassName();

    Texture t = palettes.get(c);
    if(t == null) return args;
    if(lookup.get(c) == null) return args;
    int offset = lookup.get(c).indexOf(unit.name);
    if(offset < 0) return args;
    args.programName = "paletteSwap";
    args.args = new float[] {t.getTextureWidth(), t.getTextureHeight(), offset, t.getImageWidth()};
    GL13.glActiveTexture(GL13.GL_TEXTURE8);
    t.bind();
    GL13.glActiveTexture(GL13.GL_TEXTURE0);
    return args;
}
项目:sandbox    文件:ShadowMapEntityRenderer.java   
public 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);
}
项目:sandbox    文件:GuiRenderer.java   
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.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL20.glDisableVertexAttribArray(0);
    GL30.glBindVertexArray(0);
    shader.stop();
}
项目:sandbox    文件:Loader.java   
public int loadCubeMap(String path, String[] textureFiles) {
    int texId = GL11.glGenTextures();
    GL13.glActiveTexture(GL13.GL_TEXTURE0);
    GL11.glBindTexture(GL13.GL_TEXTURE_CUBE_MAP, texId);
    if (textureFiles.length != 6) Log.warn("Cube map should have only 6 textures by defualt");
    for (int i = 0; i < textureFiles.length; i++) {
        String file = textureFiles[i];
        if (!file.toLowerCase().endsWith(".png")) file += ".png";
        TextureData data = decodeTextureFile("assets/textures/skyboxs/" + path + "/" + file);
        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);
    textures.add(texId);
    return texId;
}
项目:Null-Engine    文件:GuiRenderer.java   
/**
 * Render the framebuffer to the window
 * @param flags The render flags
 */
@Override
public void postRender(BitFieldInt flags) {
    if (Application.get().getRenderTarget() != null) {
        Application.get().getRenderTarget().bind();
    } else {
        Framebuffer2D.unbind();
    }
    GL11.glDisable(GL11.GL_BLEND);
    BasicShader.INSTANCE.bind();
    BasicShader.INSTANCE.loadMVP(Matrix4f.IDENTITY);
    GL13.glActiveTexture(GL13.GL_TEXTURE0);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, framebuffer.getColorTextureID());
    GL11.glEnable(GL11.GL_BLEND);
    Quad.get().render();
    GL11.glDisable(GL11.GL_BLEND);
}
项目:Null-Engine    文件:DeferredRenderer.java   
private void renderToTarget(int out) {
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    if (Application.get().getRenderTarget() != null)
        Application.get().getRenderTarget().bind();
    else
        Framebuffer2D.unbind();

    GammaShader.INSTANCE.bind();
    GammaShader.INSTANCE.loadMVP(Matrix4f.IDENTITY);
    GL13.glActiveTexture(GL13.GL_TEXTURE0);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, out);
    Quad.get().lazyRender(0);

    GL11.glDisable(GL11.GL_BLEND);
}
项目:Null-Engine    文件:PostFX.java   
/**
 * Render this post processing effect
 * @param viewMatrix The view matrix
 */
@Override
public void render(Matrix4f viewMatrix) {
    if (!renderedThisFrame) {
        renderedThisFrame = true;
        for (PostFXOutput input : inputs) {
            input.render(viewMatrix);
        }
        for (int i = 0; i < inputs.length; i++) {
            GL13.glActiveTexture(GL13.GL_TEXTURE0 + i);
            GL11.glBindTexture(GL11.GL_TEXTURE_2D, inputs[i].getTextureID());
        }
        shader.bind();
        shader.updateViewMatrix(viewMatrix);
        updateUniforms(shader);
        buffer.bind();
        Quad.get().lazyRender(0);
    }
}
项目:OpenGB    文件:Screen.java   
private void drawFrame()
{
    model.identity(); // reset our model to the identity matrix.
    baseShaderProgram.bind();

    model.translate(0, 0, 1.0f);
    model.translate(0.5f * texture.getWidth(), 0.5f * texture.getHeight(), 0.0f);
    model.translate(-0.5f * texture.getWidth(), -0.5f * texture.getHeight(), 0.0f);
    model.scale(texture.getWidth() * 4, texture.getHeight() * 4, 1.0f);

    baseShaderProgram.setMatrix4f(baseShaderProgram.getCachedLoc(UniformIndexesUtil.MODEL), model);
    baseShaderProgram.setVector3f(baseShaderProgram.getCachedLoc(UniformIndexesUtil.TEXTURE_COLOR), new Vector3f(1.0f, 1.0f, 1.0f)); // White base color
    this.texCoordTransform.set(1, 0, 0, 0, 1, 0, 0, 0, 1.0f);

    baseShaderProgram.setMatrix3f(baseShaderProgram.getCachedLoc(UniformIndexesUtil.TEX_COORD_TRANSFORM), this.texCoordTransform);

    GL13.glActiveTexture(GL13.GL_TEXTURE0);
    texture.bind();
    glBindVertexArray(this.quadVAO);
    glEnableVertexAttribArray(0);
    glDrawArrays(GL_TRIANGLES, 0, 6);
    glDisableVertexAttribArray(0);
    glBindVertexArray(0);
}
项目:origin    文件:ViewScreen.java   
@Override
    public void onRender3D()
    {
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
        Gdx.gl.glEnable(GL20.GL_CULL_FACE);
        Gdx.gl.glCullFace(GL20.GL_BACK);
        Gdx.gl.glEnable(GL20.GL_DEPTH_TEST);

        _gameCamera.update(false);

        // ======================================================

        _modelBatch.begin(_gameCamera, _shader, false);
        prepareShader();
        if (_activeModel != null)
        {
            _modelBatch.render(_activeModel);
        }
//      _modelBatch.render(_equip);
        _modelBatch.end();

        // ======================================================
        Gdx.gl.glDisable(GL20.GL_CULL_FACE);
        Gdx.gl.glActiveTexture(GL13.GL_TEXTURE0);
    }
项目:3D-game-engine    文件:TerrainRenderer.java   
private void bindTextures(Terrain terrain) {
    TerrainTexturePack texturePack = terrain.getTexturePack();

    GL13.glActiveTexture(GL13.GL_TEXTURE0);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, texturePack.getBackgroundTexture().getTextureID());

    GL13.glActiveTexture(GL13.GL_TEXTURE1);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, texturePack.getrTexture().getTextureID());

    GL13.glActiveTexture(GL13.GL_TEXTURE2);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, texturePack.getgTexture().getTextureID());

    GL13.glActiveTexture(GL13.GL_TEXTURE3);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, texturePack.getbTexture().getTextureID());

    GL13.glActiveTexture(GL13.GL_TEXTURE4);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, terrain.getBlendMap().getTextureID());
}
项目:Mystic-Bastion    文件:GuiRenderer.java   
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();
}
项目:Mystic-Bastion    文件:ShadowMapEntityRenderer.java   
/**
 * 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().isHasTransparency()) {
            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().isHasTransparency()) {
            MasterRenderer.enableCulling();
        }
    }
    GL20.glDisableVertexAttribArray(0);
    GL20.glDisableVertexAttribArray(1);
    GL30.glBindVertexArray(0);
}
项目:Mystic-Bastion    文件:EntityRenderer.java   
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.loadFakeLightingVariable(texture.isUseFakeLighting());
    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());
    }
}
项目:Mystic-Bastion    文件:Loader.java   
public int loadCubeMap(String[] textureFiles) {
    int texID = GL11.glGenTextures();
    GL13.glActiveTexture(GL13.GL_TEXTURE0);
    GL11.glBindTexture(GL13.GL_TEXTURE_CUBE_MAP, texID);

    for (int i = 0; i < textureFiles.length; i++) {
        TextureData data = decodeTextureFile(MainGameLoop.fileManager.getTextureFile(textureFiles[i]));
        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);
    textures.add(texID);
    return texID;
}
项目:Mystic-Bastion    文件:WaterRenderer.java   
private void prepareRender(Camera camera, Light sun) {
    shader.start();
    shader.loadViewMatrix(camera);
    moveFactor += WAVE_SPEED * DisplayManager.getFrameTimeSeconds();
    moveFactor %= 1;
    shader.loadMoveFactor(moveFactor);
    shader.loadLight(sun);
    GL30.glBindVertexArray(quad.getVaoID());
    GL20.glEnableVertexAttribArray(0);
    GL13.glActiveTexture(GL13.GL_TEXTURE0);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, fbos.getReflectionTexture());
    GL13.glActiveTexture(GL13.GL_TEXTURE1);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, fbos.getRefractionTexture());
    GL13.glActiveTexture(GL13.GL_TEXTURE2);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, dudvTexture);
    GL13.glActiveTexture(GL13.GL_TEXTURE3);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, normalMap);
    GL13.glActiveTexture(GL13.GL_TEXTURE4);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, fbos.getRefractionDepthTexture());
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
}
项目:Mystic-Bastion    文件:NormalMappingRenderer.java   
private void prepareTexturedModel(TexturedModel model) {
    RawModel rawModel = model.getRawModel();
    GL30.glBindVertexArray(rawModel.getVaoID());
    GL20.glEnableVertexAttribArray(0);
    GL20.glEnableVertexAttribArray(1);
    GL20.glEnableVertexAttribArray(2);
    GL20.glEnableVertexAttribArray(3);
    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());
    GL13.glActiveTexture(GL13.GL_TEXTURE1);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, model.getTexture().getNormalMap());
    shader.loadUseSpecularMap(texture.hasSpecularMap());
    if(texture.hasSpecularMap()){
        GL13.glActiveTexture(GL13.GL_TEXTURE2);
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture.getSpecularMap());
    }
}