Example usage for com.badlogic.gdx.graphics GL10 glLightfv

List of usage examples for com.badlogic.gdx.graphics GL10 glLightfv

Introduction

In this page you can find the example usage for com.badlogic.gdx.graphics GL10 glLightfv.

Prototype

public void glLightfv(int light, int pname, FloatBuffer params);

Source Link

Usage

From source file:org.interreg.docexplore.reader.book.BookEngineRenderer.java

License:Open Source License

public void render() {
    BookSpecification spec = engine.book;
    BookModel model = engine.model;/*from  w ww .j  ava 2  s  .c om*/

    GL10 gl = Gdx.gl10;

    cnt += .01;

    engine.attractor.attract(engine.camera, .075f);

    gl.glMatrixMode(GL10.GL_MODELVIEW);
    gl.glPushMatrix();
    gl.glMatrixMode(GL10.GL_PROJECTION);
    gl.glPushMatrix();
    engine.camera.apply(gl);

    gl.glEnable(GL10.GL_LIGHTING);
    gl.glEnable(GL10.GL_LIGHT0);
    gl.glLightfv(GL10.GL_LIGHT0, GL10.GL_AMBIENT, ambient);
    gl.glLightfv(GL10.GL_LIGHT0, GL10.GL_DIFFUSE, diffuse);
    gl.glLightfv(GL10.GL_LIGHT0, GL10.GL_POSITION, position);

    gl.glMatrixMode(GL10.GL_MODELVIEW);
    gl.glTranslatef((float) engine.globalTrans, 0, 0);
    gl.glRotatef((float) (engine.globalRot * 180 / Math.PI), 0, 1, 0);

    boolean pageIsActive = engine.hand.pageIsActive;
    int leftPageIndex = model.leftStack.nStackPages > 0 ? 1 + 2 * (model.leftStack.nStackPages - 1) : -1;
    int rightPageIndex = model.rightStack.nStackPages > 0 ? leftPageIndex + 1 + (pageIsActive ? 2 : 0) : -1;

    Bindable leftPage = leftPageIndex >= 0 ? spec.pages.get(leftPageIndex).getTexture() : null;
    Bindable rightPage = rightPageIndex >= 0 ? spec.pages.get(rightPageIndex).getTexture() : null;
    Bindable pageFront = pageIsActive ? spec.pages.get(leftPageIndex + 1).getTexture() : null;
    Bindable pageBack = pageIsActive ? spec.pages.get(leftPageIndex + 2).getTexture() : null;

    Gdx.gl10.glEnable(GL10.GL_CULL_FACE);
    gl.glPolygonMode(GL10.GL_FRONT_AND_BACK, GL10.GL_FILL);

    boolean zoomed = engine.zoom.active;
    model.render(leftPage, rightPage, pageFront, pageBack, engine.book.coverTex, engine.book.innerCoverTex,
            zoomed ? null : leftRoiMask, zoomed ? null : rightRoiMask);

    for (Component extension : engine.components)
        extension.render();

    gl.glMatrixMode(GL10.GL_MODELVIEW);
    gl.glPopMatrix();
    gl.glMatrixMode(GL10.GL_PROJECTION);
    gl.glPopMatrix();
}

From source file:se.claremont.android.wallpaper.ClaremontWallpaper.java

License:Apache License

@Override
public void render() {

    ///*from www .  j a  va  2 s  .co m*/
    // Set GL state
    //
    GL10 gl = Gdx.graphics.getGL10();
    gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
    gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    gl.glDisable(GL10.GL_DITHER);
    gl.glEnable(GL10.GL_DEPTH_TEST);
    gl.glEnable(GL10.GL_CULL_FACE);
    gl.glEnable(GL10.GL_COLOR_MATERIAL);
    gl.glHint(GL10.GL_POLYGON_SMOOTH_HINT, GL10.GL_NICEST);
    gl.glEnable(GL10.GL_LIGHTING);
    gl.glEnable(GL10.GL_LIGHT0);

    //
    // Update light position
    //
    lightPosition.put(0, perspectiveCamera.position.x);
    lightPosition.put(1, perspectiveCamera.position.y);
    lightPosition.put(2, perspectiveCamera.position.z);
    gl.glLightfv(GL10.GL_LIGHT0, GL10.GL_POSITION, lightPosition);

    //
    // Update camera position/direction
    //
    perspectiveCamera.position.set(perspectiveCameraCurrentPosition);
    perspectiveCamera.direction.set(perspectiveCameraCurrentDirection);
    perspectiveCamera.position.rotate(Gdx.graphics.getDeltaTime(), 0f, 1f, 0f);
    perspectiveCamera.direction.rotate(Gdx.graphics.getDeltaTime(), 0f, 1f, 0f);
    perspectiveCameraCurrentPosition = perspectiveCamera.position;
    perspectiveCameraCurrentDirection = perspectiveCamera.direction;
    perspectiveCamera.update();
    perspectiveCamera.apply(gl);

    //
    // Render Claremont text model
    //
    gl.glPushMatrix();
    gl.glColor4f(1f, 1f, 1f, 1f);
    gl.glRotatef(0.25f, 1f, 0f, 0f);
    claremontText.render(GL10.GL_TRIANGLES);
    gl.glPopMatrix();

    //
    // Render Claremont orb model
    //
    gl.glPushMatrix();
    gl.glColor4f(0.36862745f, 0.63921569f, 0.82352941f, 1f);
    gl.glRotatef(0.25f, 1f, 0f, 0f);
    claremontOrb.render(GL10.GL_TRIANGLES);
    gl.glPopMatrix();

}