how to use opengl blend mode/functions to brighten/darken a texture.

Posted by Jigar on Game Development See other posts from Game Development or by Jigar
Published on 2011-02-19T19:37:39Z Indexed on 2011/02/19 23:33 UTC
Read the original article Hit count: 294

Filed under:
|
|

Tried this code, but the texture didnot get any lighter.

    try {
        texture = TextureLoader.getTexture("png",                                
           Game.class.getResourceAsStream("/brick.png"), true, GL_NEAREST);
    } catch (IOException e) {
        e.printStackTrace();
    }

    GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture.getTextureID());


    glEnable(GL_BLEND);
    glBlendFunc(GL_CONSTANT_ALPHA, GL_CONSTANT_ALPHA);
    GL14.glBlendColor(1.0f, 1.0f, 1.0f, 0.5f);


    glColor4f(1, 1, 1, 0.5f);
    GL11.glBegin(GL11.GL_QUADS);                            // Start Drawing Quads
    // Front Face
    GL11.glNormal3f(0.0f, 0.0f, 1.0f);                 // Normal Pointing Towards Viewer
    GL11.glTexCoord2f(0.0f, 0.0f);
    GL11.glVertex3f(-1.0f, -1.0f, 1.0f);    // Point 1 (Front)
    GL11.glTexCoord2f(1.0f, 0.0f);
    GL11.glVertex3f(1.0f, -1.0f, 1.0f);    // Point 2 (Front)
    GL11.glTexCoord2f(1.0f, 1.0f);
    GL11.glVertex3f(1.0f, 1.0f, 1.0f);    // Point 3 (Front)
    GL11.glTexCoord2f(0.0f, 1.0f);
    GL11.glVertex3f(-1.0f, 1.0f, 1.0f);    // Point 4 (Front)
    glEnd();

© Game Development or respective owner

Related posts about opengl

Related posts about java