Java Code Examples for javax.microedition.khronos.opengles.GL10#glTexCoordPointer()

The following examples show how to use javax.microedition.khronos.opengles.GL10#glTexCoordPointer() . 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: GLBitmap.java    From TikTok with Apache License 2.0 6 votes vote down vote up
public void draw(GL10 gl) {
    // bind the previously generated texture
    gl.glBindTexture(GL10.GL_TEXTURE_2D, textures[0]);

    // Point to our buffers
    gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
    gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);

    // Set the face rotation
    gl.glFrontFace(GL10.GL_CW);

    // Point to our vertex buffer
    gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuffer);
    gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, textureBuffer);

    // Draw the vertices as triangle strip
    gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, vertices.length / 3);

    // Disable the client state before leaving
    gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
    gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
}
 
Example 2
Source File: Grid.java    From codeexamples-android with Eclipse Public License 1.0 6 votes vote down vote up
public void draw(GL10 gl, boolean useTexture) {
    gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
    gl.glVertexPointer(3, GL10.GL_FLOAT, 0, mVertexBuffer);

    if (useTexture) {
        gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
        gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, mTexCoordBuffer);
        gl.glEnable(GL10.GL_TEXTURE_2D);
    } else {
        gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
        gl.glDisable(GL10.GL_TEXTURE_2D);
    }

    gl.glDrawElements(GL10.GL_TRIANGLES, mIndexCount,
            GL10.GL_UNSIGNED_SHORT, mIndexBuffer);
    gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
}
 
Example 3
Source File: PLHotspot.java    From PanoramaGL with Apache License 2.0 5 votes vote down vote up
/**render methods*/

@Override
protected void internalRender(GL10 gl, PLIRenderer renderer)
{
	this.calculateCoords(gl);
	
	List<PLITexture> textures = this.getTextures();
	int textureId = (textures.size() > 0 ? textures.get(0).getTextureId(gl) : 0);
	if(textureId == 0 || mVertexsBuffer == null || mTextureCoordsBuffer == null)
		return;
	
	gl.glEnable(GL10.GL_TEXTURE_2D);
	
	PLIView view = renderer.getInternalView();
	gl.glColor4f(1.0f, 1.0f, 1.0f, (view != null && view.isValidForTransition()) || this.getTouchStatus() == PLSceneElementTouchStatus.PLSceneElementTouchStatusOut ? this.getAlpha() : mOverAlpha);
	
	gl.glVertexPointer(3, GL10.GL_FLOAT, 0, mVertexsBuffer);
	gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, mTextureCoordsBuffer);
	gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
	gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
	
	gl.glEnable(GL10.GL_CULL_FACE);
	gl.glCullFace(GL10.GL_FRONT);
	gl.glShadeModel(GL10.GL_SMOOTH);
	
	gl.glBindTexture(GL10.GL_TEXTURE_2D, textureId);
	
	gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, 4);
	
	gl.glDisable(GL10.GL_TEXTURE_2D);
	gl.glDisable(GL10.GL_BLEND);
	gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
	gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
}
 
Example 4
Source File: PLHotspot.java    From panoramagl with Apache License 2.0 5 votes vote down vote up
/**
 * render methods
 */

@Override
protected void internalRender(GL10 gl, PLIRenderer renderer) {
    this.calculateCoords(gl);

    List<PLITexture> textures = this.getTextures();
    int textureId = (textures.size() > 0 ? textures.get(0).getTextureId(gl) : 0);
    if (textureId == 0 || mVertexsBuffer == null || mTextureCoordsBuffer == null)
        return;

    gl.glEnable(GL10.GL_TEXTURE_2D);

    PLIView view = renderer.getInternalView();
    gl.glColor4f(1.0f, 1.0f, 1.0f, (view != null && view.isValidForTransition()) || this.getTouchStatus() == PLSceneElementTouchStatus.PLSceneElementTouchStatusOut ? this.getAlpha() : mOverAlpha);

    gl.glVertexPointer(3, GL10.GL_FLOAT, 0, mVertexsBuffer);
    gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, mTextureCoordsBuffer);
    gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
    gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);

    gl.glEnable(GL10.GL_CULL_FACE);
    gl.glCullFace(GL10.GL_FRONT);
    gl.glShadeModel(GL10.GL_SMOOTH);

    gl.glBindTexture(GL10.GL_TEXTURE_2D, textureId);

    gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, 4);

    gl.glDisable(GL10.GL_TEXTURE_2D);
    gl.glDisable(GL10.GL_BLEND);
    gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
    gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
}
 
Example 5
Source File: TexCubeSmallGLUT.java    From opengl with Apache License 2.0 5 votes vote down vote up
void draw(GL10 gl) {
if (texEnabled) {
    gl.glEnable(GL10.GL_TEXTURE_2D);
    gl.glBindTexture(GL10.GL_TEXTURE_2D, mTextureID);
    gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
    gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, mCoordBuffer);
}

super.draw(gl);

if (texEnabled) {
    gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
    gl.glDisable(GL10.GL_TEXTURE_2D);
}
   }
 
Example 6
Source File: TexCubeSmallGLUT.java    From opengl with Apache License 2.0 5 votes vote down vote up
void draw(GL10 gl) {
if (texEnabled) {
    gl.glEnable(GL10.GL_TEXTURE_2D);
    gl.glBindTexture(GL10.GL_TEXTURE_2D, mTextureID);
    gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
    gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, mCoordBuffer);
}

super.draw(gl);

if (texEnabled) {
    gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
    gl.glDisable(GL10.GL_TEXTURE_2D);
}
   }
 
Example 7
Source File: ShadeRenderer.java    From BobEngine with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void render(GL10 gl, int layer) {
    if (alpha[layer] > 0.0001f) {
        float x = 0;
        float y = 0;
        float width = getRoom().getViewWidth();
        float height = getRoom().getViewHeight();

        x += getRoom().getCameraLeftEdge() * getRoom().getGridUnitX();
        y += getRoom().getCameraBottomEdge() * getRoom().getGridUnitY();

        vertices[0] = x;             // Bottom Left X
        vertices[1] = y;             // Bottom Left Y
        vertices[2] = vertices[0];   // Top Left X (Same as Bottom X)
        vertices[3] = y + height;    // Top Left Y
        vertices[4] = x + width;     // Bottom Right X
        vertices[5] = vertices[1];   // Bottom Right Y (Same as Left Y)
        vertices[6] = vertices[4];   // Top Right X (Same as Bottom X)
        vertices[7] = vertices[3];   // Top Right Y (Same as Left Y)

        vertexBuffer.clear();
        vertexBuffer.put(vertices);

        vertexBuffer.position(0);
        textureBuffer.position(0);
        indexBuffer.position(0);

        gl.glBindTexture(GL11.GL_TEXTURE_2D, 0);
        gl.glColor4f(red[layer] * alpha[layer], green[layer] * alpha[layer], blue[layer] * alpha[layer], alpha[layer]);

        // Point to our vertex and texture buffers
        gl.glVertexPointer(2, GL10.GL_FLOAT, 0, vertexBuffer);
        gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, textureBuffer);

        // Draw the vertices as triangles
        gl.glDrawElements(GL10.GL_TRIANGLES, INDICES.length, GL10.GL_UNSIGNED_SHORT, indexBuffer);
    }
}
 
Example 8
Source File: TGAGLSurfaceView.java    From TGAReader with MIT License 5 votes vote down vote up
@Override
public void onDrawFrame(GL10 gl) {
	gl.glClearColor(0.5f, 0.5f, 0.5f, 1);
	gl.glClear(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT);
	
	gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
	gl.glVertexPointer(3, GL10.GL_FLOAT, 0, positionBuffer);

	gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
	gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, texcoordBuffer);
	
	gl.glEnable(GL_CULL_FACE);
	gl.glCullFace(GL_BACK);
	
	gl.glMatrixMode(GL10.GL_MODELVIEW);
	gl.glLoadIdentity();
	GLU.gluLookAt(gl, 3, 3, 3, 0, 0, 0, 0, 1, 0);
	
	// draw front and back
	draw(gl, tgaTextures[0]);
	
	// draw left and right
	gl.glPushMatrix();
	gl.glRotatef(90, 0, 1, 0);
	draw(gl, tgaTextures[1]);
	gl.glPopMatrix();
	
	// draw top and bottom
	gl.glPushMatrix();
	gl.glRotatef(-90, 1, 0, 0);
	draw(gl, tgaTextures[2]);
	gl.glPopMatrix();
}
 
Example 9
Source File: SpriteTextRenderer.java    From codeexamples-android with Eclipse Public License 1.0 5 votes vote down vote up
public void draw(GL10 gl) {
    gl.glFrontFace(GL10.GL_CCW);
    gl.glVertexPointer(3, GL10.GL_FLOAT, 0, mFVertexBuffer);
    gl.glEnable(GL10.GL_TEXTURE_2D);
    gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, mTexBuffer);
    gl.glDrawElements(GL10.GL_TRIANGLE_STRIP, VERTS,
            GL10.GL_UNSIGNED_SHORT, mIndexBuffer);
}
 
Example 10
Source File: TriangleRenderer.java    From codeexamples-android with Eclipse Public License 1.0 5 votes vote down vote up
public void draw(GL10 gl) {
    gl.glFrontFace(GL10.GL_CCW);
    gl.glVertexPointer(3, GL10.GL_FLOAT, 0, mFVertexBuffer);
    gl.glEnable(GL10.GL_TEXTURE_2D);
    gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, mTexBuffer);
    gl.glDrawElements(GL10.GL_TRIANGLE_STRIP, VERTS,
            GL10.GL_UNSIGNED_SHORT, mIndexBuffer);
}
 
Example 11
Source File: PLCubicPanorama.java    From PanoramaGL with Apache License 2.0 4 votes vote down vote up
/**render methods*/

@Override
protected void internalRender(GL10 gl, PLIRenderer renderer)
{
	gl.glEnable(GL10.GL_TEXTURE_2D);
	
	gl.glEnable(GL10.GL_CULL_FACE);
	gl.glCullFace(GL10.GL_FRONT);
	gl.glShadeModel(GL10.GL_SMOOTH);
	
	gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
	gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
	gl.glVertexPointer(3, GL10.GL_FLOAT, 0, sCubeBuffer);
	gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, sTextureCoordsBuffer);
	
	// Front Face
	if(this.bindTextureByIndex(gl, PLConstants.kCubeFrontFaceIndex))
	{
		gl.glNormal3f(0.0f, 0.0f, 1.0f);
		gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, 4);
	}
	
	// Back Face
	if(this.bindTextureByIndex(gl, PLConstants.kCubeBackFaceIndex))
	{
		gl.glNormal3f(0.0f, 0.0f, -1.0f);
		gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 4, 4);
	}
	
	// Left Face
	if(this.bindTextureByIndex(gl, PLConstants.kCubeLeftFaceIndex))
	{
		gl.glNormal3f(1.0f, 0.0f, 0.0f);
		gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 8, 4);
	}
	
	// Right Face
	if(this.bindTextureByIndex(gl, PLConstants.kCubeRightFaceIndex))
	{
		gl.glNormal3f(-1.0f, 0.0f, 0.0f);
		gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 12, 4);
	}
	
	// Up Face
	if(this.bindTextureByIndex(gl, PLConstants.kCubeUpFaceIndex))
	{
		gl.glNormal3f(0.0f, 1.0f, 0.0f);
		gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 16, 4);
	}
	
	// Down Face
	if(this.bindTextureByIndex(gl, PLConstants.kCubeDownFaceIndex))
	{
		gl.glNormal3f(0.0f, -1.0f, 0.0f);
		gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 20, 4);
	}
	
	gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
	gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY);	
	gl.glDisable(GL10.GL_CULL_FACE);
	gl.glDisable(GL10.GL_TEXTURE_2D);
}
 
Example 12
Source File: Page.java    From PlayLikeCurl with MIT License 4 votes vote down vote up
public void draw(GL10 gl,Context context) {

		if(needtextureupdate) {

			needtextureupdate=false;
			loadGLTexture(gl, context);
		}
		calculateVerticesCoords();


		gl.glBindTexture(GL10.GL_TEXTURE_2D, textures[0]);

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

		gl.glFrontFace(GL10.GL_CCW);

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

		gl.glDrawElements(GL10.GL_TRIANGLES, indices.length, GL10.GL_UNSIGNED_SHORT, indexBuffer);

		gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
		gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
	}
 
Example 13
Source File: PLCubicPanorama.java    From panoramagl with Apache License 2.0 4 votes vote down vote up
/**
 * render methods
 */

@Override
protected void internalRender(GL10 gl, PLIRenderer renderer) {
    gl.glEnable(GL10.GL_TEXTURE_2D);

    gl.glEnable(GL10.GL_CULL_FACE);
    gl.glCullFace(GL10.GL_FRONT);
    gl.glShadeModel(GL10.GL_SMOOTH);

    gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
    gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
    gl.glVertexPointer(3, GL10.GL_FLOAT, 0, sCubeBuffer);
    gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, sTextureCoordsBuffer);

    // Front Face
    if (this.bindTextureByIndex(gl, PLConstants.kCubeFrontFaceIndex)) {
        gl.glNormal3f(0.0f, 0.0f, 1.0f);
        gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, 4);
    }

    // Back Face
    if (this.bindTextureByIndex(gl, PLConstants.kCubeBackFaceIndex)) {
        gl.glNormal3f(0.0f, 0.0f, -1.0f);
        gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 4, 4);
    }

    // Left Face
    if (this.bindTextureByIndex(gl, PLConstants.kCubeLeftFaceIndex)) {
        gl.glNormal3f(1.0f, 0.0f, 0.0f);
        gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 8, 4);
    }

    // Right Face
    if (this.bindTextureByIndex(gl, PLConstants.kCubeRightFaceIndex)) {
        gl.glNormal3f(-1.0f, 0.0f, 0.0f);
        gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 12, 4);
    }

    // Up Face
    if (this.bindTextureByIndex(gl, PLConstants.kCubeUpFaceIndex)) {
        gl.glNormal3f(0.0f, 1.0f, 0.0f);
        gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 16, 4);
    }

    // Down Face
    if (this.bindTextureByIndex(gl, PLConstants.kCubeDownFaceIndex)) {
        gl.glNormal3f(0.0f, -1.0f, 0.0f);
        gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 20, 4);
    }

    gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
    gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
    gl.glDisable(GL10.GL_CULL_FACE);
    gl.glDisable(GL10.GL_TEXTURE_2D);
}
 
Example 14
Source File: QuadRenderSystem.java    From BobEngine with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * Render the quads in this system.
 *
 * @param gl OpenGL ES 1 object.
 * @param layer layer to render.
 */
public void render(GL10 gl, int layer) {
	boolean obFound = false;
	int gID;
	int numIndices = 0;    // The number of indices for all objects

	if (graphic == null) {
		gID = 0;
	} else {
		gID = graphic.id;
	}

	for (int i = 0; i < numQuads; i++) {
		Transformation t = quads.get(i).getTransformation();
		GraphicAreaTransformation g = quads.get(i).getGraphicAreaTransformation();

		if (t.getLayer() == layer && onScreen(t, getRoom()) && Transform.getRealVisibility(t)) {
			if (!obFound) {
				vertexBuffer.clear();
				textureBuffer.clear();

				vertexBuffer.position(0);
				textureBuffer.position(0);
				indexBuffer[layer].position(0);

				obFound = true;
			}

			vertexBuffer.put(getVertices(t));
			textureBuffer.put(getVertices(g));
			numIndices += INDICES;
		}
	}

	if (obFound) {
		if (numIndices != lastIndex[layer]) {
			if (numIndices > indices.length) {
				indices = new short[numIndices + 1];
			}

			for (int i = 0; i < numIndices; i += 6) {
				indices[i + 0] = (short) (((i / 6) * 4) + 0);
				indices[i + 1] = (short) (((i / 6) * 4) + 1);
				indices[i + 2] = (short) (((i / 6) * 4) + 2);
				indices[i + 3] = (short) (((i / 6) * 4) + 1);
				indices[i + 4] = (short) (((i / 6) * 4) + 2);
				indices[i + 5] = (short) (((i / 6) * 4) + 3);
			}

			indexBuffer[layer].clear();
			indexBuffer[layer].put(indices);
			lastIndex[layer] = numIndices;
		}

		vertexBuffer.position(0);
		textureBuffer.position(0);
		indexBuffer[layer].position(0);

		// Add color
		gl.glColor4f(red[layer] * alpha[layer], green[layer] * alpha[layer], blue[layer] * alpha[layer], alpha[layer]);

		// Bind the texture
		gl.glBindTexture(GL11.GL_TEXTURE_2D, gID);

		// Point to our vertex and texture buffers
		gl.glVertexPointer(2, GL10.GL_FLOAT, 0, vertexBuffer);
		gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, textureBuffer);

		// Draw the vertices as triangles
		gl.glDrawElements(GL10.GL_TRIANGLES, numIndices, GL10.GL_UNSIGNED_SHORT, indexBuffer[layer]);
	}
}