Java Code Examples for javax.microedition.khronos.opengles.GL11#glEnableClientState()

The following examples show how to use javax.microedition.khronos.opengles.GL11#glEnableClientState() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GLES11Canvas.java    From PhotoMovie with Apache License 2.0 6 votes vote down vote up
public GLES11Canvas(GL11 gl) {
    mGL = gl;
    mGLState = new GLState(gl);
    // First create an nio buffer, then create a VBO from it.
    int size = BOX_COORDINATES.length * Float.SIZE / Byte.SIZE;
    FloatBuffer xyBuffer = allocateDirectNativeOrderBuffer(size).asFloatBuffer();
    xyBuffer.put(BOX_COORDINATES, 0, BOX_COORDINATES.length).position(0);

    int[] name = new int[1];
    mGLId.glGenBuffers(1, name, 0);
    mBoxCoords = name[0];

    gl.glBindBuffer(GL11.GL_ARRAY_BUFFER, mBoxCoords);
    gl.glBufferData(GL11.GL_ARRAY_BUFFER, xyBuffer.capacity() * (Float.SIZE / Byte.SIZE), xyBuffer, GL11.GL_STATIC_DRAW);

    gl.glVertexPointer(2, GL11.GL_FLOAT, 0, 0);
    gl.glTexCoordPointer(2, GL11.GL_FLOAT, 0, 0);

    // Enable the texture coordinate array for Texture 1
    gl.glClientActiveTexture(GL11.GL_TEXTURE1);
    gl.glTexCoordPointer(2, GL11.GL_FLOAT, 0, 0);
    gl.glClientActiveTexture(GL11.GL_TEXTURE0);
    gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);

    // mMatrixValues and mAlpha will be initialized in setSize()
}
 
Example 2
Source File: GLES11Canvas.java    From PhotoMovie with Apache License 2.0 6 votes vote down vote up
public GLState(GL11 gl) {
    mGL = gl;

    // Disable unused state
    gl.glDisable(GL11.GL_LIGHTING);

    // Enable used features
    gl.glEnable(GL11.GL_DITHER);

    gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
    gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
    gl.glEnable(GL11.GL_TEXTURE_2D);

    gl.glTexEnvf(GL11.GL_TEXTURE_ENV,
            GL11.GL_TEXTURE_ENV_MODE, GL11.GL_REPLACE);

    // Set the background color
    gl.glClearColor(0f, 0f, 0f, 0f);
    gl.glClearStencil(0);

    gl.glEnable(GL11.GL_BLEND);
    gl.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);

    // We use 565 or 8888 format, so set the alignment to 2 bytes/pixel.
    gl.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 2);
}
 
Example 3
Source File: GLCanvasImpl.java    From document-viewer with GNU General Public License v3.0 6 votes vote down vote up
public GLState(final GL11 gl) {
    mGL = gl;

    // Disable unused state
    gl.glDisable(GL10.GL_LIGHTING);

    // Enable used features
    gl.glEnable(GL10.GL_DITHER);

    gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
    gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
    gl.glEnable(GL10.GL_TEXTURE_2D);

    gl.glTexEnvf(GL10.GL_TEXTURE_ENV, GL10.GL_TEXTURE_ENV_MODE, GL10.GL_REPLACE);

    // Set the background color
    gl.glClearColor(0f, 0f, 0f, 0f);
    gl.glClearStencil(0);

    gl.glEnable(GL10.GL_BLEND);
    gl.glBlendFunc(GL10.GL_ONE, GL10.GL_ONE_MINUS_SRC_ALPHA);

    // We use 565 or 8888 format, so set the alignment to 2 bytes/pixel.
    gl.glPixelStorei(GL10.GL_UNPACK_ALIGNMENT, 2);
}
 
Example 4
Source File: GLCanvasImpl.java    From document-viewer with GNU General Public License v3.0 5 votes vote down vote up
private void initialize() {
    final GL11 gl = mGL;

    // First create an nio buffer, then create a VBO from it.
    final int size = BOX_COORDINATES.length * Float.SIZE / Byte.SIZE;
    final FloatBuffer xyBuffer = allocateDirectNativeOrderBuffer(size).asFloatBuffer();
    xyBuffer.put(BOX_COORDINATES, 0, BOX_COORDINATES.length).position(0);

    final int[] name = new int[1];
    GLId.glGenBuffers(1, name, 0);
    mBoxCoords = name[0];

    gl.glBindBuffer(GL11.GL_ARRAY_BUFFER, mBoxCoords);
    gl.glBufferData(GL11.GL_ARRAY_BUFFER, xyBuffer.capacity() * (Float.SIZE / Byte.SIZE), xyBuffer,
            GL11.GL_STATIC_DRAW);

    gl.glVertexPointer(2, GL10.GL_FLOAT, 0, 0);
    gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, 0);

    // Enable the texture coordinate array for Texture 1
    gl.glClientActiveTexture(GL10.GL_TEXTURE1);
    gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, 0);
    gl.glClientActiveTexture(GL10.GL_TEXTURE0);
    gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);

    gl.glHint(GL10.GL_LINE_SMOOTH_HINT, GL10.GL_NICEST);
    gl.glHint(GL10.GL_POLYGON_SMOOTH_HINT, GL10.GL_NICEST);

    gl.glEnable(GL10.GL_LINE_SMOOTH);
    gl.glLineWidth(1.5f);
    gl.glEnable(GL10.GL_BLEND);
    gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
    // mMatrixValues and mAlpha will be initialized in setSize()
}