Package javax.microedition.khronos.opengles

Examples of javax.microedition.khronos.opengles.GL11


        indices.put(_indices);
        indices.rewind();

        _buffers = new int[2];

        final GL11 gl = (GL11) g;
        gl.glGenBuffers(2, _buffers, 0);
        gl.glBindBuffer(GL11.GL_ARRAY_BUFFER, _buffers[0]);
        gl.glBufferData(GL11.GL_ARRAY_BUFFER, _verticesSize + _normalsSize
                + _texcoordsSize, vertices, GL11.GL_STATIC_DRAW);
        gl.glBindBuffer(GL11.GL_ELEMENT_ARRAY_BUFFER, _buffers[1]);
        gl.glBufferData(GL11.GL_ELEMENT_ARRAY_BUFFER, _indicesSize, indices,
                GL11.GL_STATIC_DRAW);
        gl.glBindBuffer(GL11.GL_ARRAY_BUFFER, 0);
        gl.glBindBuffer(GL11.GL_ELEMENT_ARRAY_BUFFER, 0);
    }
View Full Code Here


     *
     * @param g
     *            GL object used for drawing
     */
    public void render(final GL g) {
        final GL11 gl = (GL11) g;
        gl.glBindBuffer(GL11.GL_ARRAY_BUFFER, _buffers[0]);
        gl.glBindBuffer(GL11.GL_ELEMENT_ARRAY_BUFFER, _buffers[1]);

        if (_vertexAttribIndex != -1) {
            gl.glVertexPointer(3, GL10.GL_FLOAT, 0, 0);
            gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
        }

        if (_normalAttribIndex != -1 && _normalsSize > 0) {
            gl.glNormalPointer(GL10.GL_FLOAT, 0, _verticesSize);
            gl.glEnableClientState(GL10.GL_NORMAL_ARRAY);
        }

        if (_texcoordAttribIndex != -1 && _texcoordsSize > 0) {
            gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, _verticesSize
                    + _normalsSize);
            gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
        }

        gl.glDrawElements(GL10.GL_TRIANGLES, _indicesSize / 2,
                GL10.GL_UNSIGNED_SHORT, 0);

        if (_vertexAttribIndex != -1) {
            gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
        }

        if (_normalAttribIndex != -1 && _normalsSize > 0) {
            gl.glDisableClientState(GL10.GL_NORMAL_ARRAY);
        }

        if (_texcoordAttribIndex != -1 && _texcoordsSize > 0) {
            gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
        }

        gl.glBindBuffer(GL11.GL_ARRAY_BUFFER, 0);
        gl.glBindBuffer(GL11.GL_ELEMENT_ARRAY_BUFFER, 0);
    }
View Full Code Here

    /**
     * @see net.rim.device.api.opengles.GLField#initialize(GL)
     */
    public void initialize(final GL renderer) {
        final GL11 gl = (GL11) renderer;

        _transform = new Matrix4f();
        _transform.translate(0, 0, -4.0f);
        _transform.scale(1.5f);

        // Create the cube for "instanced" rendering
        _cube = new Cube(gl);

        gl.glEnable(GL10.GL_TEXTURE_2D);

        // Load the texture bitmap
        final Bitmap bitmap = Bitmap.getBitmapResource("BlackBerry.png");
        if (bitmap != null) {
            final int[] textureIds = new int[1];
            gl.glGenTextures(1, textureIds, 0);
            final int _texture = textureIds[0];
            gl.glBindTexture(GL10.GL_TEXTURE_2D, _texture);
            GLUtils.glTexImage2D(gl, 0, GL10.GL_RGB,
                    GL10.GL_UNSIGNED_SHORT_5_6_5, bitmap, null);
            gl.glTexParameterx(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER,
                    GL10.GL_LINEAR);
            gl.glTexParameterx(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER,
                    GL10.GL_LINEAR);
            gl.glTexParameterx(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S,
                    GL10.GL_CLAMP_TO_EDGE);
            gl.glTexParameterx(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T,
                    GL10.GL_CLAMP_TO_EDGE);
        }

        // Setup GL state
        gl.glClearColor(1.0f, 1.0f, 1.0f, 0.0f);
        gl.glDisable(GL10.GL_DITHER);
        gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_FASTEST);
        gl.glEnable(GL10.GL_CULL_FACE);
        gl.glShadeModel(GL10.GL_SMOOTH);
        gl.glEnable(GL10.GL_DEPTH_TEST);

        initializeLights(gl);
    }
View Full Code Here

    /**
     * @see net.rim.device.api.opengles.GLField#render(GL)
     */
    public void render(final GL renderer) {
        final GL11 gl = (GL11) renderer;

        gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);

        // Set up the perspective projection
        gl.glMatrixMode(GL10.GL_PROJECTION);
        gl.glLoadIdentity();
        GLUtils.gluPerspective(gl, 45.0f, _aspect, 0.15f, 1000.0f);

        // Set up the local modelview transform and render it
        gl.glMatrixMode(GL10.GL_MODELVIEW);

        gl.glLoadMatrixf(_transform.getArray(), 0);
        _cube.enableVertexAttrib();
        _cube.enableNormalAttrib();
        _cube.enableTexcoordAttrib();
        _cube.render(gl);
    }
View Full Code Here

    /**
     * @see net.rim.device.api.opengles.GLField#render(GL)
     */
    protected void render(final GL g) {
        final GL11 gl = (GL11) g;

        if (_sizeChanged) {
            sizeChanged(gl, getWidth(), getHeight());
            _sizeChanged = false;
        }

        gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);

        // Transform the cube
        gl.glMatrixMode(GL10.GL_MODELVIEW);
        gl.glLoadIdentity();
        gl.glTranslatef(0, 0, -3.5f);
        gl.glRotatef(_rotation.getFloat(), 1.0f, 1.0f, 0.0f);

        // Enable position, normal and texture coordinates
        _cube.enableVertexAttrib();
        _cube.enableTexcoordAttrib();
        _cube.enableNormalAttrib();
View Full Code Here

TOP

Related Classes of javax.microedition.khronos.opengles.GL11

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.