Example usage for com.badlogic.gdx.graphics.glutils ImmediateModeRenderer20 begin

List of usage examples for com.badlogic.gdx.graphics.glutils ImmediateModeRenderer20 begin

Introduction

In this page you can find the example usage for com.badlogic.gdx.graphics.glutils ImmediateModeRenderer20 begin.

Prototype

public void begin(Matrix4 projModelView, int primitiveType) 

Source Link

Usage

From source file:ta.shape3D.mesh.MeshTA.java

License:Apache License

/**
 * draw all triangles of the Mesh in the OpenGL environment.
 * @param rendu the renderer which is used for drawing triangle, you don't need to call the begin() method of this renderer
 * before using this method./*w  w w  .  j a  va2 s  .co  m*/
 * @param rendu 
 * @param projectionMatrix The projection matrix in which the mesh will be represented 
 */
final public void render(ImmediateModeRenderer20 rendu, Matrix4 projectionMatrix) {
    projectionMatrix.translate(tX, tY, tZ);
    projectionMatrix.rotateRad(Vector3.X, rX);
    projectionMatrix.rotateRad(Vector3.Y, rY);
    projectionMatrix.rotateRad(Vector3.Z, rZ);
    projectionMatrix.scale(scaleX, scaleY, scaleZ);
    if (image != null) {
        Gdx.gl20.glEnable(GL20.GL_TEXTURE_2D);
        Gdx.gl20.glBindTexture(image.glTarget, image.getTextureObjectHandle());
    }
    rendu.begin(projectionMatrix, GL20.GL_TRIANGLES);
    for (Triangle3D t : triangles) {
        t.render(rendu);
    }
    rendu.end();
    Gdx.gl20.glDisable(GL20.GL_TEXTURE_BINDING_2D);
    for (MeshTA m : sousMesh) {
        m.render(rendu, projectionMatrix);
    }
    projectionMatrix.scale(1 / scaleX, 1 / scaleY, 1 / scaleZ);
    projectionMatrix.rotateRad(Vector3.X, -rX);
    projectionMatrix.rotateRad(Vector3.Y, -rY);
    projectionMatrix.rotateRad(Vector3.Z, -rZ);
    projectionMatrix.translate(-tX, -tY, -tZ);
}