javax.microedition.khronos.opengles.GL11 Java Examples

The following examples show how to use javax.microedition.khronos.opengles.GL11. 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: BouncyCubeRenderer.java    From opengl with Apache License 2.0 6 votes vote down vote up
public void onSurfaceCreated(GL10 gl, EGLConfig config) 
{

    gl.glDisable(GL11.GL_DITHER);

    gl.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT,
             GL11.GL_FASTEST);

    if (mTranslucentBackground) 
    {
         gl.glClearColor(1,0,0,0);
    } 
    else 
    {
         gl.glClearColor(1,1,1,1);
    }
    
    gl.glEnable(GL11.GL_CULL_FACE);
    gl.glShadeModel(GL11.GL_SMOOTH);
    gl.glEnable(GL11.GL_DEPTH_TEST);
}
 
Example #2
Source File: CubeMapActivity.java    From codeexamples-android with Eclipse Public License 1.0 6 votes vote down vote up
public void createBufferObjects(GL gl) {
    checkGLError(gl);
    // Generate a the vertex and element buffer IDs
    int[] vboIds = new int[2];
    GL11 gl11 = (GL11) gl;
    gl11.glGenBuffers(2, vboIds, 0);
    mVertexBufferObjectId = vboIds[0];
    mElementBufferObjectId = vboIds[1];

    // Upload the vertex data
    gl11.glBindBuffer(GL11.GL_ARRAY_BUFFER, mVertexBufferObjectId);
    mVertexByteBuffer.position(0);
    gl11.glBufferData(GL11.GL_ARRAY_BUFFER, mVertexByteBuffer.capacity(), mVertexByteBuffer, GL11.GL_STATIC_DRAW);

    gl11.glBindBuffer(GL11.GL_ELEMENT_ARRAY_BUFFER, mElementBufferObjectId);
    mIndexBuffer.position(0);
    gl11.glBufferData(GL11.GL_ELEMENT_ARRAY_BUFFER, mIndexBuffer.capacity() * CHAR_SIZE, mIndexBuffer, GL11.GL_STATIC_DRAW);

    // We don't need the in-memory data any more
    mVertexBuffer = null;
    mVertexByteBuffer = null;
    mIndexBuffer = null;
    checkGLError(gl);
}
 
Example #3
Source File: GLWrapper.java    From panoramagl with Apache License 2.0 6 votes vote down vote up
/**
 * init methods
 */

public GLWrapper(GL gl, GLSurfaceView glSurfaceView) {
    mGL = (GL10) gl;
    if (gl instanceof GL10Ext) {
        mGL10Ext = (GL10Ext) gl;
    }
    if (gl instanceof GL11) {
        mGL11 = (GL11) gl;
    }
    if (gl instanceof GL11Ext) {
        mGL11Ext = (GL11Ext) gl;
    }
    if (gl instanceof GL11ExtensionPack) {
        mGL11ExtPack = (GL11ExtensionPack) gl;
    }
    mGLSurfaceView = glSurfaceView;
}
 
Example #4
Source File: GLES11Canvas.java    From PhotoMovie with Apache License 2.0 6 votes vote down vote up
@Override
public void setTextureParameters(BasicTexture texture) {
    int width = texture.getWidth();
    int height = texture.getHeight();
    // Define a vertically flipped crop rectangle for OES_draw_texture.
    // The four values in sCropRect are: left, bottom, width, and
    // height. Negative value of width or height means flip.
    sCropRect[0] = 0;
    sCropRect[1] = height;
    sCropRect[2] = width;
    sCropRect[3] = -height;

    // Set texture parameters.
    int target = texture.getTarget();
    mGL.glBindTexture(target, texture.getId());
    mGL.glTexParameterfv(target, GL11Ext.GL_TEXTURE_CROP_RECT_OES, sCropRect, 0);
    mGL.glTexParameteri(target, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP_TO_EDGE);
    mGL.glTexParameteri(target, GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP_TO_EDGE);
    mGL.glTexParameterf(target, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
    mGL.glTexParameterf(target, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
}
 
Example #5
Source File: MatrixPaletteRenderer.java    From codeexamples-android with Eclipse Public License 1.0 6 votes vote down vote up
public void draw(GL10 gl) {
    GL11 gl11 = (GL11) gl;
    GL11Ext gl11Ext = (GL11Ext) gl;

    gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);

    gl11.glBindBuffer(GL11.GL_ARRAY_BUFFER, mVertexBufferObjectId);
    gl11.glVertexPointer(3, GL10.GL_FLOAT, VERTEX_SIZE, 0);
    gl11.glTexCoordPointer(2, GL10.GL_FLOAT, VERTEX_SIZE, VERTEX_TEXTURE_BUFFER_INDEX_OFFSET * FLOAT_SIZE);

    gl.glEnableClientState(GL11Ext.GL_MATRIX_INDEX_ARRAY_OES);
    gl.glEnableClientState(GL11Ext.GL_WEIGHT_ARRAY_OES);

    gl11Ext.glWeightPointerOES(2, GL10.GL_FLOAT, VERTEX_SIZE, VERTEX_WEIGHT_BUFFER_INDEX_OFFSET  * FLOAT_SIZE);
    gl11Ext.glMatrixIndexPointerOES(2, GL10.GL_UNSIGNED_BYTE, VERTEX_SIZE, VERTEX_PALETTE_INDEX_OFFSET );

    gl11.glBindBuffer(GL11.GL_ELEMENT_ARRAY_BUFFER, mElementBufferObjectId);
    gl11.glDrawElements(GL10.GL_TRIANGLES, mIndexCount, GL10.GL_UNSIGNED_SHORT, 0);
    gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
    gl.glDisableClientState(GL11Ext.GL_MATRIX_INDEX_ARRAY_OES);
    gl.glDisableClientState(GL11Ext.GL_WEIGHT_ARRAY_OES);
    gl11.glBindBuffer(GL11.GL_ARRAY_BUFFER, 0);
    gl11.glBindBuffer(GL11.GL_ELEMENT_ARRAY_BUFFER, 0);
}
 
Example #6
Source File: GLCanvasImpl.java    From document-viewer with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void setSize(final int width, final int height) {
    mScreenWidth = width;
    mScreenHeight = height;
    mAlpha = 1.0f;

    final GL11 gl = mGL;
    gl.glViewport(0, 0, width, height);
    gl.glMatrixMode(GL10.GL_PROJECTION);
    gl.glLoadIdentity();
    GLU.gluOrtho2D(gl, 0, width, 0, height);

    gl.glMatrixMode(GL10.GL_MODELVIEW);
    gl.glLoadIdentity();

    final float matrix[] = mMatrixValues;
    Matrix.setIdentityM(matrix, 0);
    // to match the graphic coordinate system in android, we flip it vertically.
    Matrix.translateM(matrix, 0, 0, height, 0);
    Matrix.scaleM(matrix, 0, 1, -1, 1);
}
 
Example #7
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 #8
Source File: GLCanvasImpl.java    From document-viewer with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void drawRect(final RectF r, final Paint paint) {
    final GL11 gl = mGL;

    mGLState.setColorMode(paint.getColor(), mAlpha);
    mGLState.setLineWidth(paint.getStrokeWidth());

    saveTransform();
    translate(r.left, r.top);
    scale(r.width(), r.height(), 1);

    gl.glLoadMatrixf(mMatrixValues, 0);
    gl.glDrawArrays(GL10.GL_LINE_LOOP, OFFSET_DRAW_RECT, 4);

    restoreTransform();
}
 
Example #9
Source File: PLSceneBase.java    From PanoramaGL with Apache License 2.0 6 votes vote down vote up
/**matrix methods*/

protected void updateMatrixes(GL10 gl)
{
	if(PLOpenGLSupport.isHigherThanOpenGL1(gl))
	{
		GL11 gl11 = (GL11)gl;
		gl11.glGetFloatv(GL11.GL_PROJECTION_MATRIX, mProjectionMatrix, 0);
		gl11.glGetFloatv(GL11.GL_MODELVIEW_MATRIX, mModelMatrix, 0);
	}
	else
	{
		mMatrixGrabber.getCurrentProjection(gl);
		mMatrixGrabber.getCurrentModelView(gl);
	}
}
 
Example #10
Source File: GLWrapper.java    From PanoramaGL with Apache License 2.0 6 votes vote down vote up
/**init methods*/

public GLWrapper(GL gl, GLSurfaceView glSurfaceView)
{
	mGL = (GL10)gl;
	if(gl instanceof GL10Ext)
	{
           mGL10Ext = (GL10Ext)gl;
       }
       if(gl instanceof GL11)
       {
           mGL11 = (GL11)gl;
       }
       if(gl instanceof GL11Ext)
       {
           mGL11Ext = (GL11Ext)gl;
       }
       if(gl instanceof GL11ExtensionPack)
       {
       	mGL11ExtPack = (GL11ExtensionPack)gl;
       }
       mGLSurfaceView = glSurfaceView;
}
 
Example #11
Source File: GraphicsHelper.java    From BobEngine with GNU Lesser General Public License v2.1 6 votes vote down vote up
public void loadAllGraphics(GL10 gl) {
	int sampleSize = 1;
	boolean success = false;
	do {
		try {
			for (int g = 0; g < graphics.length; g++) {
				if (graphics[g] != null) {
					loadGraphic((GL11) gl, g, sampleSize);
				}
			}

			success = true;
		} catch (OutOfMemoryError e) {  // Not enough memory to load all the graphics. BobEngine will try down sampling them.
			sampleSize++;
			Log.e("BobEngine", "Not enough memory. Retrying in sample size " + Integer.toString(sampleSize));
			success = false;
		}
	} while (!success);  // Try again

	gl.glFinish();
}
 
Example #12
Source File: GLRootView.java    From document-viewer with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Called when the context is created, possibly after automatic destruction.
 */
// This is a GLSurfaceView.Renderer callback
@Override
public void onSurfaceCreated(final GL10 gl1, final EGLConfig config) {
    final GL11 gl = (GL11) gl1;
    if (mGL != null) {
        // The GL Object has changed
        LCTX.i("GLObject has changed from " + mGL + " to " + gl);
    }
    mRenderLock.lock();
    try {
        mGL = gl;
        mCanvas = new GLCanvasImpl(gl);
        BasicTexture.invalidateAllTextures();
    } finally {
        mRenderLock.unlock();
    }

    setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
}
 
Example #13
Source File: GLCanvasImpl.java    From document-viewer with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void drawLine(final float x1, final float y1, final float x2, final float y2, final Paint paint) {
    final GL11 gl = mGL;

    mGLState.setColorMode(paint.getColor(), mAlpha);
    mGLState.setLineWidth(paint.getStrokeWidth());

    saveTransform();
    translate(x1, y1);
    scale(x2 - x1, y2 - y1, 1);

    gl.glLoadMatrixf(mMatrixValues, 0);
    gl.glDrawArrays(GL10.GL_LINE_STRIP, OFFSET_DRAW_LINE, 2);

    restoreTransform();
}
 
Example #14
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 #15
Source File: GLES11Canvas.java    From PhotoMovie with Apache License 2.0 6 votes vote down vote up
@Override
public void drawRect(float x, float y, float width, float height, GLPaint paint) {
    GL11 gl = mGL;

    mGLState.setColorMode(paint.getColor(), mAlpha);
    mGLState.setLineWidth(paint.getLineWidth());

    saveTransform();
    translate(x, y);
    scale(width, height, 1);

    gl.glLoadMatrixf(mMatrixValues, 0);
    gl.glDrawArrays(GL11.GL_LINE_LOOP, OFFSET_DRAW_RECT, 4);

    restoreTransform();
    mCountDrawLine++;
}
 
Example #16
Source File: GLES11Canvas.java    From PhotoMovie with Apache License 2.0 6 votes vote down vote up
@Override
public void drawLine(float x1, float y1, float x2, float y2, GLPaint paint) {
    GL11 gl = mGL;

    mGLState.setColorMode(paint.getColor(), mAlpha);
    mGLState.setLineWidth(paint.getLineWidth());

    saveTransform();
    translate(x1, y1);
    scale(x2 - x1, y2 - y1, 1);

    gl.glLoadMatrixf(mMatrixValues, 0);
    gl.glDrawArrays(GL11.GL_LINE_STRIP, OFFSET_DRAW_LINE, 2);

    restoreTransform();
    mCountDrawLine++;
}
 
Example #17
Source File: Square.java    From opengl with Apache License 2.0 6 votes vote down vote up
public void draw(GL10 gl) {  
	//tell openGL how the vertices are ordering their faces
	//this is both for efficiently so openGL can ignore the "backside" and not attempt to draw it.
	gl.glFrontFace(GL11.GL_CCW);  //counter clockwise, so any counter triangles are ignored.
	//send the buffers to the renderer
	//specific the number of elements per vertex, which there are 2.
	gl.glVertexPointer(2, GL11.GL_FLOAT, 0, mFVertexBuffer); //8
	//color buffer is added, with the size of the 4 elements
	gl.glColorPointer(4, GL11.GL_UNSIGNED_BYTE, 0, mColorBuffer); //9
	
	//finally draw the element, we the connectivity array, using triangles
	//could also be triangle lists, points or lines
	gl.glDrawElements(GL11.GL_TRIANGLES, 6, GL11.GL_UNSIGNED_BYTE, mIndexBuffer);
	
	//return the openGL back to the default value.
	gl.glFrontFace(GL11.GL_CCW); //11
}
 
Example #18
Source File: ImageUtils.java    From monolog-android with MIT License 5 votes vote down vote up
public static int getBitmapMaxWidthAndMaxHeight() {
    int[] maxSizeArray = new int[1];
    GLES10.glGetIntegerv(GL10.GL_MAX_TEXTURE_SIZE, maxSizeArray, 0);

    if (maxSizeArray[0] == 0) {
        GLES10.glGetIntegerv(GL11.GL_MAX_TEXTURE_SIZE, maxSizeArray, 0);
    }
    // return maxSizeArray[0];
    return 2048;
}
 
Example #19
Source File: RawTexture.java    From Trebuchet with GNU General Public License v3.0 5 votes vote down vote up
protected void prepare(GLCanvas canvas) {
    GLId glId = canvas.getGLId();
    mId = glId.generateTexture();
    canvas.initializeTextureSize(this, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE);
    canvas.setTextureParameters(this);
    mState = STATE_LOADED;
    setAssociatedCanvas(canvas);
}
 
Example #20
Source File: EGLManager.java    From ZGDanmaku with Apache License 2.0 5 votes vote down vote up
/**
 * get GL11 object
 * @return
 */
public GL11 getGL11() {
    if (gl11 == null) {
        throw new UnsupportedOperationException("OpenGL ES 1.1 only");
    }
    return gl11;
}
 
Example #21
Source File: Utility.java    From iBeebo with GNU General Public License v3.0 5 votes vote down vote up
public static int getMaxLeftWidthOrHeightImageViewCanRead(int heightOrWidth) {
    // 1pixel==4bytes
    // http://stackoverflow.com/questions/13536042/android-bitmap-allocating-16-bytes-per-pixel
    // http://stackoverflow.com/questions/15313807/android-maximum-allowed-width-height-of-bitmap
    int[] maxSizeArray = new int[1];
    GLES10.glGetIntegerv(GL10.GL_MAX_TEXTURE_SIZE, maxSizeArray, 0);

    if (maxSizeArray[0] == 0) {
        GLES10.glGetIntegerv(GL11.GL_MAX_TEXTURE_SIZE, maxSizeArray, 0);
    }
    int maxHeight = maxSizeArray[0];
    int maxWidth = maxSizeArray[0];

    return (maxHeight * maxWidth) / heightOrWidth;
}
 
Example #22
Source File: RawTexture.java    From TurboLauncher with Apache License 2.0 5 votes vote down vote up
protected void prepare(GLCanvas canvas) {
    GLId glId = canvas.getGLId();
    mId = glId.generateTexture();
    canvas.initializeTextureSize(this, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE);
    canvas.setTextureParameters(this);
    mState = STATE_LOADED;
    setAssociatedCanvas(canvas);
}
 
Example #23
Source File: GLCanvasImpl.java    From document-viewer with GNU General Public License v3.0 5 votes vote down vote up
public void fillRect(final RectF r, final int color) {
    mGLState.setColorMode(color, mAlpha);

    final GL11 gl = mGL;

    saveTransform();
    translate(r.left, r.top);
    scale(r.width(), r.height(), 1);

    gl.glLoadMatrixf(mMatrixValues, 0);
    gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, OFFSET_FILL_RECT, 4);

    restoreTransform();
}
 
Example #24
Source File: GLCanvasImpl.java    From document-viewer with GNU General Public License v3.0 5 votes vote down vote up
private void textureRect(final float x, final float y, final float width, final float height) {
    final GL11 gl = mGL;

    saveTransform();
    translate(x, y);
    scale(width, height, 1);
    gl.glColor4f(1, 1, 1, 1);
    gl.glLoadMatrixf(mMatrixValues, 0);
    gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, OFFSET_FILL_RECT, 4);

    restoreTransform();
}
 
Example #25
Source File: GLCanvasImpl.java    From document-viewer with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void drawPoly(final int color, final PointF... path) {
    mGLState.setColorMode(color, mAlpha);
    mGLState.setLineWidth(1.5f);
    final GL11 gl = mGL;

    final int bytes = 2 * path.length * Float.SIZE;
    final FloatBuffer xyBuffer = allocateDirectNativeOrderBuffer(bytes).asFloatBuffer();
    for (int i = 0; i < path.length; i++) {
        xyBuffer.put(path[i].x / mScreenWidth);
        xyBuffer.put(path[i].y / mScreenHeight);
    }
    xyBuffer.position(0);

    saveTransform();
    translate(0, 0);
    scale(mScreenWidth, mScreenHeight, 1);
    gl.glLoadMatrixf(mMatrixValues, 0);

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

    gl.glBindBuffer(GL11.GL_ARRAY_BUFFER, name[0]);
    gl.glBufferData(GL11.GL_ARRAY_BUFFER, bytes, xyBuffer, GL11.GL_DYNAMIC_DRAW);
    gl.glVertexPointer(2, GL10.GL_FLOAT, 0, 0);
    gl.glDrawArrays(GL10.GL_LINE_LOOP, 0, path.length);

    restoreTransform();

    gl.glBindBuffer(GL11.GL_ARRAY_BUFFER, mBoxCoords);
    gl.glVertexPointer(2, GL10.GL_FLOAT, 0, 0);
    gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, 0);
}
 
Example #26
Source File: Cube.java    From opengl with Apache License 2.0 5 votes vote down vote up
public void draw(GL10 gl)
{
    gl.glVertexPointer(3, GL11.GL_FLOAT, 0, mFVertexBuffer);
    gl.glColorPointer(4, GL11.GL_UNSIGNED_BYTE, 0, mColorBuffer);
    
	gl.glDrawElements( gl.GL_TRIANGLE_FAN, 6 * 3, gl.GL_UNSIGNED_BYTE, mTfan1);
	gl.glDrawElements( gl.GL_TRIANGLE_FAN, 6 * 3, gl.GL_UNSIGNED_BYTE, mTfan2);
}
 
Example #27
Source File: GLClipHelper.java    From document-viewer with GNU General Public License v3.0 5 votes vote down vote up
void drawClipRegions(final GL11 gl) {
    gl.glClear(GL10.GL_STENCIL_BUFFER_BIT);

    gl.glColorMask(false, false, false, false);
    gl.glStencilFunc(GL10.GL_ALWAYS, 1, ~0);
    gl.glStencilOp(GL10.GL_INCR, GL10.GL_INCR, GL10.GL_INCR);

    for (int i = 0; i < count; i++) {
        regions[i].draw(canvas);
    }

    gl.glColorMask(true, true, true, true);
    gl.glStencilFunc(GL10.GL_EQUAL, count, ~0);
    gl.glStencilOp(GL10.GL_KEEP, GL10.GL_KEEP, GL10.GL_KEEP);
}
 
Example #28
Source File: Cube.java    From opengl with Apache License 2.0 5 votes vote down vote up
public void draw(GL10 gl)
{
    gl.glVertexPointer(3, GL11.GL_FLOAT, 0, mFVertexBuffer);
    gl.glColorPointer(4, GL11.GL_UNSIGNED_BYTE, 0, mColorBuffer);
    
	gl.glDrawElements( GL11.GL_TRIANGLE_FAN, 6 * 3, GL11.GL_UNSIGNED_BYTE, mTfan1);
	gl.glDrawElements( GL11.GL_TRIANGLE_FAN, 6 * 3, GL11.GL_UNSIGNED_BYTE, mTfan2);
}
 
Example #29
Source File: GLCanvasImpl.java    From document-viewer with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void fillRect(final float x, final float y, final float width, final float height, final int color) {
    mGLState.setColorMode(color, mAlpha);
    final GL11 gl = mGL;

    saveTransform();
    translate(x, y);
    scale(width, height, 1);

    gl.glLoadMatrixf(mMatrixValues, 0);
    gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, OFFSET_FILL_RECT, 4);

    restoreTransform();
}
 
Example #30
Source File: Cube.java    From opengl with Apache License 2.0 5 votes vote down vote up
public void draw(GL10 gl)
{
    gl.glVertexPointer(3, GL11.GL_FLOAT, 0, mFVertexBuffer);
    gl.glColorPointer(4, GL11.GL_UNSIGNED_BYTE, 0, mColorBuffer);
    
	gl.glDrawElements( GL11.GL_TRIANGLE_FAN, 6 * 3, GL11.GL_UNSIGNED_BYTE, mTfan1);
	gl.glDrawElements( GL11.GL_TRIANGLE_FAN, 6 * 3, GL11.GL_UNSIGNED_BYTE, mTfan2);
}