Java Code Examples for android.opengl.GLES11#glDisableClientState()

The following examples show how to use android.opengl.GLES11#glDisableClientState() . 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: Disk.java    From Alite with GNU General Public License v3.0 6 votes vote down vote up
public void render() {
	GLES11.glNormalPointer(GLES11.GL_FLOAT, 0, normalBuffer);
	GLES11.glVertexPointer(3, GLES11.GL_FLOAT, 0, vertexBuffer);
	if (textureFilename != null) {
		GLES11.glTexCoordPointer(2, GLES11.GL_FLOAT, 0, texCoordBuffer);
		alite.getTextureManager().setTexture(textureFilename);
	} else {
		GLES11.glDisable(GLES11.GL_LIGHTING);
		GLES11.glDisableClientState(GLES11.GL_TEXTURE_COORD_ARRAY);			
	}
	GLES11.glDrawArrays(glDrawMode, 0, numberOfVertices);
	if (textureFilename == null) {
		GLES11.glEnableClientState(GLES11.GL_TEXTURE_COORD_ARRAY);
		GLES11.glEnable(GLES11.GL_LIGHTING);
	}
}
 
Example 2
Source File: AndroidPixmap.java    From Alite with GNU General Public License v3.0 6 votes vote down vote up
public void render() {			
	GLES11.glEnable(GLES11.GL_TEXTURE_2D);
	if (!textureManager.checkTexture(fileName)) {
		textureManager.addTexture(fileName, bitmap);
	}
	GLES11.glEnableClientState(GLES11.GL_VERTEX_ARRAY);
	GLES11.glEnableClientState(GLES11.GL_TEXTURE_COORD_ARRAY);
	GLES11.glVertexPointer(2, GLES11.GL_FLOAT, 0, vertexBuffer);
	GLES11.glTexCoordPointer(2, GLES11.GL_FLOAT, 0, texCoordBuffer);
	GLES11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
	GLES11.glEnable(GLES11.GL_BLEND);
	GLES11.glBlendFunc(GLES11.GL_SRC_ALPHA, GLES11.GL_ONE_MINUS_SRC_ALPHA);
	textureManager.setTexture(fileName);
	GLES11.glDrawArrays(GLES11.GL_TRIANGLE_STRIP, 0, 4);
	GLES11.glDisable(GLES11.GL_BLEND);
	GLES11.glDisable(GLES11.GL_TEXTURE_2D);
	textureManager.setTexture(null);
	GLES11.glDisableClientState(GLES11.GL_VERTEX_ARRAY);
	GLES11.glDisableClientState(GLES11.GL_TEXTURE_COORD_ARRAY);		
}
 
Example 3
Source File: Sphere.java    From Alite with GNU General Public License v3.0 6 votes vote down vote up
public void render() {
	if (hasNormals) {
		GLES11.glEnableClientState(GLES11.GL_NORMAL_ARRAY);
		GLES11.glNormalPointer(GLES11.GL_FLOAT, 0, normalBuffer);
	} else {
		GLES11.glDisableClientState(GLES11.GL_NORMAL_ARRAY);
	}
	GLES11.glVertexPointer(3, GLES11.GL_FLOAT, 0, vertexBuffer);
	if (textureFilename != null) {
		GLES11.glTexCoordPointer(2, GLES11.GL_FLOAT, 0, texCoordBuffer);
	} else {
		GLES11.glDisableClientState(GLES11.GL_TEXTURE_COORD_ARRAY);
		GLES11.glDisable(GLES11.GL_LIGHTING);
		GLES11.glColor4f(r, g, b, a);
	}
	alite.getTextureManager().setTexture(textureFilename);
	GLES11.glDrawArrays(glDrawMode, 0, numberOfVertices);
	if (!hasNormals) {
		GLES11.glEnableClientState(GLES11.GL_NORMAL_ARRAY);
	}
	if (textureFilename == null) {
		GLES11.glEnableClientState(GLES11.GL_TEXTURE_COORD_ARRAY);
		GLES11.glEnable(GLES11.GL_LIGHTING);
		GLES11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);			
	}
}
 
Example 4
Source File: TargetBox.java    From Alite with GNU General Public License v3.0 6 votes vote down vote up
public void render() {
	alite.getTextureManager().setTexture(null);
	GLES11.glDisable(GLES11.GL_CULL_FACE);
	GLES11.glDisableClientState(GLES11.GL_TEXTURE_COORD_ARRAY);
	GLES11.glEnableClientState(GLES11.GL_VERTEX_ARRAY);
	GLES11.glVertexPointer(3, GLES11.GL_FLOAT, 0, lineBuffer);		
	GLES11.glColor4f(r, g, b, a);
	GLES11.glDisable(GLES11.GL_LIGHTING);
	GLES11.glLineWidth(5);
	GLES11.glDrawArrays(GLES11.GL_LINES, 0, 24);
	GLES11.glLineWidth(1);
	GLES11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
	GLES11.glEnable(GLES11.GL_LIGHTING);
	GLES11.glEnableClientState(GLES11.GL_TEXTURE_COORD_ARRAY);
	GLES11.glEnable(GLES11.GL_CULL_FACE);
}
 
Example 5
Source File: Skysphere.java    From Alite with GNU General Public License v3.0 6 votes vote down vote up
public void render() {
	GLES11.glDisableClientState(GLES11.GL_NORMAL_ARRAY);
	GLES11.glEnableClientState(GLES11.GL_VERTEX_ARRAY);
	GLES11.glEnableClientState(GLES11.GL_TEXTURE_COORD_ARRAY);
	GLES11.glDisable(GLES11.GL_CULL_FACE);
	
	GLES11.glVertexPointer(3, GLES11.GL_FLOAT, 0, vertexBuffer);
	GLES11.glTexCoordPointer(2, GLES11.GL_FLOAT, 0, texCoordBuffer);
	
	GLES11.glDisable(GLES11.GL_LIGHTING);
	GLES11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
	alite.getTextureManager().setTexture(textureFilename);
	GLES11.glDrawArrays(glDrawMode, 0, numberOfVertices);
	GLES11.glEnable(GLES11.GL_LIGHTING);
	
	GLES11.glEnable(GLES11.GL_CULL_FACE);
	GLES11.glDisableClientState(GLES11.GL_TEXTURE_COORD_ARRAY);
	GLES11.glDisableClientState(GLES11.GL_VERTEX_ARRAY);
	GLES11.glBindTexture(GLES11.GL_TEXTURE_2D, 0);
}
 
Example 6
Source File: Box.java    From Alite with GNU General Public License v3.0 5 votes vote down vote up
public void render() {
	alite.getTextureManager().setTexture(null);
	GLES11.glDisableClientState(GLES11.GL_TEXTURE_COORD_ARRAY);
	GLES11.glEnableClientState(GLES11.GL_VERTEX_ARRAY);
	GLES11.glVertexPointer(3, GLES11.GL_FLOAT, 0, vertexBuffer);		
	GLES11.glColor4f(r, g, b, a);
	GLES11.glDisable(GLES11.GL_LIGHTING);
	GLES11.glDrawArrays(GLES11.GL_TRIANGLES, 0, 36);
	GLES11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
	GLES11.glEnable(GLES11.GL_LIGHTING);
	GLES11.glEnableClientState(GLES11.GL_TEXTURE_COORD_ARRAY);
}
 
Example 7
Source File: GLES11DrawContext.java    From settlers-remake with MIT License 5 votes vote down vote up
public void drawTrianglesWithTextureColored(TextureHandle textureid, GeometryHandle vertexHandle, GeometryHandle colorHandle, int offset, int lines, int width, int stride, float x, float y) {
	bindTexture(textureid);
	int starti = offset < 0 ? (int)Math.ceil(-offset/(float)stride) : 0;

	if(lsz != -1) GLES11.glPopMatrix();
	GLES11.glPushMatrix();
	GLES11.glTranslatef(x, y, -.1f);
	GLES11.glScalef(1, 1, 0);
	GLES11.glMultMatrixf(heightMatrix, 0);

	if(!tex_coord_on) {
		GLES11.glEnableClientState(GLES11.GL_TEXTURE_COORD_ARRAY);
		tex_coord_on = true;
	}

	bindGeometry(vertexHandle);
	GLES11.glVertexPointer(3, GLES11.GL_FLOAT, 5 * 4, 0);
	GLES11.glTexCoordPointer(2, GLES11.GL_FLOAT, 5 * 4, 3 * 4);

	bindGeometry(colorHandle);
	GLES11.glColorPointer(4, GLES11.GL_UNSIGNED_BYTE, 0, 0);

	GLES11.glEnableClientState(GLES11.GL_COLOR_ARRAY);
	for (int i = starti; i != lines; i++) {
		GLES11.glDrawArrays(GLES11.GL_TRIANGLES, (offset + stride * i) * 3, width * 3);
	}
	GLES11.glDisableClientState(GLES11.GL_COLOR_ARRAY);

	GLES11.glPopMatrix();
	lsz = -1;
}
 
Example 8
Source File: GLES11DrawContext.java    From settlers-remake with MIT License 5 votes vote down vote up
protected void specifyFormat(EGeometryFormatType format) {
	if (format.getTexCoordPos() == -1) {
		if(tex_coord_on) GLES11.glDisableClientState(GLES11.GL_TEXTURE_COORD_ARRAY);
		GLES11.glVertexPointer(2, GLES11.GL_FLOAT, 0, 0);
	} else {
		if(!tex_coord_on) GLES11.glEnableClientState(GLES11.GL_TEXTURE_COORD_ARRAY);
		int stride = format.getBytesPerVertexSize();
		GLES11.glVertexPointer(2, GLES11.GL_FLOAT, stride, 0);
		GLES11.glTexCoordPointer(2, GLES11.GL_FLOAT, stride, format.getTexCoordPos());
	}

	tex_coord_on = format.getTexCoordPos() != -1;
}
 
Example 9
Source File: GLES11DrawContext.java    From settlers-remake with MIT License 5 votes vote down vote up
public void draw2D(GeometryHandle geometry, TextureHandle texture, int primitive, int offset, int vertices, float x, float y, float z, float sx, float sy, float sz, AbstractColor color, float intensity) {
	if(lx != x || ly != y || lz != z || lsx != sx || lsy != sy || lsz != sz) {
		if(lsz != -1) GLES11.glPopMatrix();
		GLES11.glPushMatrix();
		if(x != 0 || y != 0 || z != 0) GLES11.glTranslatef(x, y, z);
		if(sx != 1 || sy != 1 || sz != 1) GLES11.glScalef(sx, sy, sz);
		lx = x; lsx = sx;
		ly = y; lsy = sy;
		lz = z; lsz = sz;
	}

	if(color != null) {
		float r = color.red*intensity;
		float g = color.green*intensity;
		float b = color.blue*intensity;
		float a = color.alpha;
		if(lr != r || lg != g || lb != b || la != a) GLES11.glColor4f(lr=r, lg=g, lb=b, la=a);
	} else {
		if(lr != lg || lr != lb || lr != intensity || la != 1) GLES11.glColor4f(intensity, intensity, intensity, 1);
		lr = lg = lb = intensity;
		la = 1;
	}

	bindTexture(texture);
	bindGeometry(geometry);
	EGeometryFormatType format = geometry.getFormat();

	if(format.getTexCoordPos() == -1) GLES11.glDisableClientState(GLES11.GL_TEXTURE_COORD_ARRAY);

	specifyFormat(format);
	GLES11.glDrawArrays(primitive, offset * vertices, vertices);

	if(format.getTexCoordPos() == -1) GLES11.glEnableClientState(GLES11.GL_TEXTURE_COORD_ARRAY);
}
 
Example 10
Source File: Sprite.java    From Alite with GNU General Public License v3.0 5 votes vote down vote up
protected void cleanUp() {
	GLES11.glDisable(GLES11.GL_BLEND);
	GLES11.glEnable(GLES11.GL_CULL_FACE);
	GLES11.glEnable(GLES11.GL_LIGHTING);

	GLES11.glDisableClientState(GLES11.GL_TEXTURE_COORD_ARRAY);
	GLES11.glDisableClientState(GLES11.GL_VERTEX_ARRAY);
	GLES11.glBindTexture(GLES11.GL_TEXTURE_2D, 0);
}
 
Example 11
Source File: AndroidPixmap.java    From Alite with GNU General Public License v3.0 5 votes vote down vote up
public void render(int x, int y) {
	if (x != lastX || y != lastY) {
		vertexBuffer.clear();
		vertexBuffer.put(x);
		vertexBuffer.put(y);
		vertexBuffer.put(x);
		vertexBuffer.put(y + height - 1);
		vertexBuffer.put(x + width - 1);
		vertexBuffer.put(y);
		vertexBuffer.put(x + width - 1);
		vertexBuffer.put(y + height - 1);
		vertexBuffer.position(0);
		lastX = x;
		lastY = y;
	}
	GLES11.glEnable(GLES11.GL_TEXTURE_2D);
	if (!textureManager.checkTexture(fileName)) {
		if (bitmap != null && !bitmap.isRecycled()) {
			textureManager.addTexture(fileName, bitmap);
		}
	}
	GLES11.glEnableClientState(GLES11.GL_VERTEX_ARRAY);
	GLES11.glEnableClientState(GLES11.GL_TEXTURE_COORD_ARRAY);
	GLES11.glVertexPointer(2, GLES11.GL_FLOAT, 0, vertexBuffer);
	GLES11.glTexCoordPointer(2, GLES11.GL_FLOAT, 0, texCoordBuffer);
	GLES11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
	GLES11.glEnable(GLES11.GL_BLEND);
	GLES11.glBlendFunc(GLES11.GL_SRC_ALPHA, GLES11.GL_ONE_MINUS_SRC_ALPHA);
	textureManager.setTexture(fileName);
	GLES11.glDrawArrays(GLES11.GL_TRIANGLE_STRIP, 0, 4);
	GLES11.glDisable(GLES11.GL_BLEND);
	textureManager.setTexture(null);
	GLES11.glDisable(GLES11.GL_TEXTURE_2D);
	GLES11.glDisableClientState(GLES11.GL_VERTEX_ARRAY);
	GLES11.glDisableClientState(GLES11.GL_TEXTURE_COORD_ARRAY);
}
 
Example 12
Source File: StarDust.java    From Alite with GNU General Public License v3.0 5 votes vote down vote up
void render() {		
       GLES11.glEnable(GLES11.GL_FOG);
	GLES11.glDisable(GLES11.GL_CULL_FACE);
       GLES11.glDisable(GLES11.GL_LIGHTING);
	GLES11.glDisableClientState(GLES11.GL_NORMAL_ARRAY);
	GLES11.glEnableClientState(GLES11.GL_VERTEX_ARRAY);
	GLES11.glDisableClientState(GLES11.GL_TEXTURE_COORD_ARRAY);
	GLES11.glDisableClientState(GLES11.GL_COLOR_ARRAY);
	GLES11.glEnableClientState(GLES11.GL_POINT_SIZE_ARRAY_OES);		
	GLES11.glVertexPointer(3, GLES11.GL_FLOAT, 0, dustParticles);
	GLES11.glPointSizePointerOES(GLES11.GL_FLOAT, 0, particleSizes);
	GLES11.glColor4f(0.7f, 0.7f, 1.0f, 0.8f);
	alite.getTextureManager().setTexture("textures/glow_mask.png");
       GLES11.glEnable(GLES11.GL_POINT_SPRITE_OES);
       GLES11.glTexEnvf(GLES11.GL_POINT_SPRITE_OES, GLES11.GL_COORD_REPLACE_OES, GLES11.GL_TRUE);
       GLES11.glEnable(GLES11.GL_BLEND);
       GLES11.glBlendFunc(GLES11.GL_ONE, GLES11.GL_ONE);
       GLES11.glHint(GLES11.GL_POINT_SMOOTH_HINT, GLES11.GL_NICEST);
	GLES11.glDisable(GLES11.GL_DEPTH_TEST);
	GLES11.glDrawArrays(GLES11.GL_POINTS, 0, particleCount);
	GLES11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
	GLES11.glPointSize(1.0f);
	GLES11.glDisableClientState(GLES11.GL_POINT_SIZE_ARRAY_OES);
	GLES11.glDisableClientState(GLES11.GL_COLOR_ARRAY);
	GLES11.glEnableClientState(GLES11.GL_NORMAL_ARRAY);
	GLES11.glEnableClientState(GLES11.GL_TEXTURE_COORD_ARRAY);
	GLES11.glEnable(GLES11.GL_LIGHTING);
	GLES11.glEnable(GLES11.GL_CULL_FACE);
	GLES11.glDisable(GLES11.GL_BLEND);
	GLES11.glDisable(GLES11.GL_FOG);
}
 
Example 13
Source File: EngineExhaust.java    From Alite with GNU General Public License v3.0 5 votes vote down vote up
public void render() {
	GLES11.glDepthFunc(GLES11.GL_LESS);
	GLES11.glDepthMask(false);
	GLES11.glEnable(GLES11.GL_BLEND);
	GLES11.glDisable(GLES11.GL_CULL_FACE);
	GLES11.glDisableClientState(GLES11.GL_TEXTURE_COORD_ARRAY);
	GLES11.glEnableClientState(GLES11.GL_COLOR_ARRAY);
	GLES11.glDisable(GLES11.GL_LIGHTING);
	GLES11.glBlendFunc(GLES11.GL_SRC_ALPHA, GLES11.GL_ONE);		
	MathHelper.copyMatrix(getMatrix(), saveMatrix);
	for (int i = 0; i < 2; i++) {
		GLES11.glPushMatrix();
		GLES11.glMultMatrixf(getMatrix(), 0);
	
		GLES11.glVertexPointer(3, GLES11.GL_FLOAT, 0, diskBuffer);
		GLES11.glColorPointer(4, GLES11.GL_FLOAT, 0, colorBuffer1);
		GLES11.glDrawArrays(GLES11.GL_TRIANGLE_FAN, 0, 10);
	
		GLES11.glVertexPointer(3, GLES11.GL_FLOAT, 0, cylinderBuffer);
		GLES11.glColorPointer(4, GLES11.GL_FLOAT, 0, colorBuffer2);
		GLES11.glDrawArrays(GLES11.GL_TRIANGLE_STRIP, 0, 18);
	
		GLES11.glPopMatrix();
		scale(0.4f, 0.4f, 1.2f);
	}
	MathHelper.copyMatrix(saveMatrix, currentMatrix);
	extractVectors();
	GLES11.glEnable(GLES11.GL_CULL_FACE);
	GLES11.glEnable(GLES11.GL_LIGHTING);
	GLES11.glEnableClientState(GLES11.GL_TEXTURE_COORD_ARRAY);
	GLES11.glDisableClientState(GLES11.GL_COLOR_ARRAY);
	GLES11.glDepthFunc(GLES11.GL_LESS);
	GLES11.glDepthMask(true);
	GLES11.glDisable(GLES11.GL_BLEND);
}
 
Example 14
Source File: Billboard.java    From Alite with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void render() {		
	GLES11.glDisableClientState(GLES11.GL_NORMAL_ARRAY);
	GLES11.glVertexPointer(2, GLES11.GL_FLOAT, 0, vertexBuffer);
	GLES11.glTexCoordPointer(2, GLES11.GL_FLOAT, 0, texCoordBuffer);
	GLES11.glDisable(GLES11.GL_LIGHTING);
	GLES11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
	alite.getTextureManager().setTexture(textureFilename);
	GLES11.glDrawArrays(GLES11.GL_TRIANGLE_STRIP, 0, 4);
	GLES11.glEnableClientState(GLES11.GL_NORMAL_ARRAY);
	GLES11.glEnable(GLES11.GL_LIGHTING);		
}
 
Example 15
Source File: AliteHud.java    From Alite with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void render() {
	
	setUp();
	GLES11.glColor4f(Settings.alpha, Settings.alpha, Settings.alpha, Settings.alpha);
	GLES11.glDrawArrays(GLES11.GL_TRIANGLE_STRIP, 0, 4);

	computeLaser();
	if (currentLaserIndex >= 0) {
		laser.simpleRender();
	}
	if (!witchSpace) {
		compass.render();
	}

	infoGauges.render();
	GLES11.glColor4f(Settings.alpha, Settings.alpha, Settings.alpha, Settings.alpha);
	aliteText.justRender();
	if (safeZone) {
		safeIcon.justRender();
	}
	if (System.currentTimeMillis() < ecmActive) {
		ecmIcon.justRender();
	}
	
	if (Settings.controlMode == ShipControl.CONTROL_PAD && controlPad != null) {
		controlPad.render();
	} else if ((Settings.controlMode == ShipControl.CURSOR_BLOCK || Settings.controlMode == ShipControl.CURSOR_SPLIT_BLOCK) && controlKeys != null) {
		controlKeys.render();
	}
	
	GLES11.glBlendFunc(GLES11.GL_ONE, GLES11.GL_ONE);
	switch (viewDirection) {
		case 0: frontViewport.justRender(); break;
		case 1: rightViewport.justRender(); break;
		case 2: rearViewport.justRender();  break;
		case 3: leftViewport.justRender();  break;
	}
	
	GLES11.glDisableClientState(GLES11.GL_TEXTURE_COORD_ARRAY);
	GLES11.glBindTexture(GLES11.GL_TEXTURE_2D, 0);			
	renderLollipops();
	if (zoomFactor > 1.5f && zoomFactor < 3.0f) {
		GLES11.glColor4f(0.94f * Settings.alpha, 0.94f * Settings.alpha, 0.0f, 0.6f * Settings.alpha);
		alite.getFont().drawText("x2", RADAR_X1 + 20, RADAR_Y1 + 20, false, 1.0f);			
	} else if (zoomFactor > 3.0f) {
		GLES11.glColor4f(0.94f * Settings.alpha, 0.94f * Settings.alpha, 0.0f, 0.6f * Settings.alpha);
		alite.getFont().drawText("x4", RADAR_X1 + 20, RADAR_Y1 + 20, false, 1.0f);				
	}
	GLES11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
	GLES11.glDisable(GLES11.GL_BLEND);
	GLES11.glEnable(GLES11.GL_CULL_FACE);
	GLES11.glEnable(GLES11.GL_LIGHTING);

	GLES11.glDisableClientState(GLES11.GL_VERTEX_ARRAY);
	cleanUp();
	
}
 
Example 16
Source File: Cylinder.java    From Alite with GNU General Public License v3.0 4 votes vote down vote up
public void render() {
	GLES11.glDisable(GLES11.GL_CULL_FACE);

	if (hasTop) {
		GLES11.glDisableClientState(GLES11.GL_TEXTURE_COORD_ARRAY);
		GLES11.glEnableClientState(GLES11.GL_NORMAL_ARRAY);
		GLES11.glEnable(GLES11.GL_BLEND);
		GLES11.glBlendFunc(GLES11.GL_ONE, GLES11.GL_ONE);		
		GLES11.glColor4f(r, g, b, a);
		GLES11.glVertexPointer(3, GLES11.GL_FLOAT, 0, diskBuffer1);
		GLES11.glNormalPointer(GLES11.GL_FLOAT, 0, normalBuffer[0]);		
		GLES11.glDrawArrays(GLES11.GL_TRIANGLE_FAN, 0, segments + 2);
	}
					
	GLES11.glNormalPointer(GLES11.GL_FLOAT, 0, normalBuffer[1]);		
	GLES11.glVertexPointer(3, GLES11.GL_FLOAT, 0, cylinderBuffer);		
	if (textureFilename != null) {
		GLES11.glEnable(GLES11.GL_LIGHTING);
		GLES11.glEnableClientState(GLES11.GL_TEXTURE_COORD_ARRAY);
		GLES11.glTexCoordPointer(2, GLES11.GL_FLOAT, 0, texCoordBuffer);
		alite.getTextureManager().setTexture(textureFilename);
	} else {
		GLES11.glDisable(GLES11.GL_LIGHTING);
		GLES11.glDisableClientState(GLES11.GL_TEXTURE_COORD_ARRAY);			
	}
       GLES11.glTexEnvf(GLES11.GL_TEXTURE_ENV, GLES11.GL_TEXTURE_ENV_MODE, GLES11.GL_MODULATE);        
    GLES11.glBlendFunc(GLES11.GL_SRC_ALPHA, GLES11.GL_ONE_MINUS_SRC_ALPHA);
       GLES11.glDisable(GLES11.GL_BLEND);
	GLES11.glColor4f(r, g, b, a);
	GLES11.glDrawArrays(GLES11.GL_TRIANGLE_STRIP, 0, segments * 2 + 2);
	
	if (hasBottom) {
		GLES11.glDisable(GLES11.GL_LIGHTING);
		GLES11.glDisableClientState(GLES11.GL_TEXTURE_COORD_ARRAY);
		GLES11.glEnableClientState(GLES11.GL_NORMAL_ARRAY);
		GLES11.glEnable(GLES11.GL_BLEND);
		GLES11.glBlendFunc(GLES11.GL_ONE, GLES11.GL_ONE);		
		GLES11.glColor4f(r, g, b, a);
		GLES11.glVertexPointer(3, GLES11.GL_FLOAT, 0, diskBuffer2);
		GLES11.glNormalPointer(GLES11.GL_FLOAT, 0, normalBuffer[2]);		
		GLES11.glDrawArrays(GLES11.GL_TRIANGLE_FAN, 0, segments + 2);
	}
	
	GLES11.glColor4f(1, 1, 1, 1);
	GLES11.glEnableClientState(GLES11.GL_TEXTURE_COORD_ARRAY);
	GLES11.glEnable(GLES11.GL_LIGHTING);
}
 
Example 17
Source File: Vertices.java    From Alite with GNU General Public License v3.0 4 votes vote down vote up
public void drawFull(int primitiveType, int offset, int numVertices) {
	GLES11.glEnableClientState(GLES11.GL_VERTEX_ARRAY); // Enable Position
														// in Vertices
	vertices.position(0); // Set Vertex Buffer to Position
	GLES11.glVertexPointer(positionCnt, GLES11.GL_FLOAT, vertexSize,
			vertices); // Set Vertex Pointer

	if (hasColor) { // IF Vertices Have Color
		GLES11.glEnableClientState(GLES11.GL_COLOR_ARRAY); // Enable Color
															// in Vertices
		vertices.position(positionCnt); // Set Vertex Buffer to Color
		GLES11.glColorPointer(COLOR_CNT, GLES11.GL_FLOAT, vertexSize,
				vertices); // Set Color Pointer
	}

	if (hasTexCoords) { // IF Vertices Have Texture Coords
		GLES11.glEnableClientState(GLES11.GL_TEXTURE_COORD_ARRAY); // Enable
																	// Texture
																	// Coords
																	// in
																	// Vertices
		vertices.position(positionCnt + (hasColor ? COLOR_CNT : 0)); // Set
																		// Vertex
																		// Buffer
																		// to
																		// Texture
																		// Coords
																		// (NOTE:
																		// position
																		// based
																		// on
																		// whether
																		// color
																		// is
																		// also
																		// specified)
		GLES11.glTexCoordPointer(TEXCOORD_CNT, GLES11.GL_FLOAT, vertexSize,
				vertices); // Set Texture Coords Pointer
	}

	if (indices != null) { // IF Indices Exist
		indices.position(offset); // Set Index Buffer to Specified Offset
		GLES11.glDrawElements(primitiveType, numVertices,
				GLES11.GL_UNSIGNED_SHORT, indices); // Draw Indexed
	} else { // ELSE No Indices Exist
		GLES11.glDrawArrays(primitiveType, offset, numVertices); // Draw
																	// Direct
																	// (Array)
	}

	if (hasTexCoords) // IF Vertices Have Texture Coords
		GLES11.glDisableClientState(GLES11.GL_TEXTURE_COORD_ARRAY); // Clear
																	// Texture
																	// Coords
																	// State

	if (hasColor) // IF Vertices Have Color
		GLES11.glDisableClientState(GLES11.GL_COLOR_ARRAY); // Clear Color
															// State

	GLES11.glDisableClientState(GLES11.GL_VERTEX_ARRAY); // Clear Vertex
															// Array State
}
 
Example 18
Source File: AndroidGraphics.java    From Alite with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void gradientRect(int x, int y, int width, int height, boolean horizontal, boolean vertical, long color1, long color2) {
	int x2 = transX(x + width - 1);
	int ty2 = transY(y + height - 1);
	x = transX(x);
	y = transY(y);
	int ty = y < 0 ? 0 : y;
	if (ty2 < 0) {
		return;
	}
	
	float alpha1 = (float) ((int) ((color1 & 0xFF000000l) >> 24)) / 255.0f;
	float red1   = ((color1 & 0x00FF0000) >> 16) / 255.0f;
	float green1 = ((color1 & 0x0000FF00) >>  8) / 255.0f;
	float blue1  =  (color1 & 0x000000FF)        / 255.0f;
	float alpha2 = (float) ((int) ((color2 & 0xFF000000l) >> 24)) / 255.0f;
	float red2   = ((color2 & 0x00FF0000) >> 16) / 255.0f;
	float green2 = ((color2 & 0x0000FF00) >>  8) / 255.0f;
	float blue2  =  (color2 & 0x000000FF)        / 255.0f;

	GLES11.glEnableClientState(GLES11.GL_VERTEX_ARRAY);
	GLES11.glEnableClientState(GLES11.GL_COLOR_ARRAY);
	rectBuffer.clear();
	rectBuffer.put(x);
	rectBuffer.put(ty);
	rectBuffer.put(x2);
	rectBuffer.put(ty);
	rectBuffer.put(x2);
	rectBuffer.put(ty2);
	rectBuffer.put(x);
	rectBuffer.put(ty2);
	rectBuffer.position(0);
	colorBuffer.clear();
	colorBuffer.put(red1); colorBuffer.put(green1); colorBuffer.put(blue1); colorBuffer.put(alpha1);
	colorBuffer.put(horizontal ? red2 : red1); colorBuffer.put(horizontal ? green2 : green1); colorBuffer.put(horizontal ? blue2 : blue1); colorBuffer.put(horizontal ? alpha2 : alpha1);
	colorBuffer.put(red2); colorBuffer.put(green2); colorBuffer.put(blue2); colorBuffer.put(alpha2);
	colorBuffer.put(vertical ? red2 : red1); colorBuffer.put(vertical ? green2 : green1); colorBuffer.put(vertical ? blue2 : blue1); colorBuffer.put(vertical ? alpha2 : alpha1);
	colorBuffer.position(0);
	GLES11.glColorPointer(4, GLES11.GL_FLOAT, 0, colorBuffer);
	GLES11.glVertexPointer(2, GLES11.GL_FLOAT, 0, rectBuffer);
	GLES11.glDrawArrays(GLES11.GL_TRIANGLE_FAN, 0, 4);
	GLES11.glDisableClientState(GLES11.GL_COLOR_ARRAY);
}
 
Example 19
Source File: LaserCylinder.java    From Alite with GNU General Public License v3.0 4 votes vote down vote up
public void render(Alite alite) {
	if (!visible) {
		return;
	}
	GLES11.glDepthFunc(GLES11.GL_LEQUAL);
	GLES11.glDepthMask(false);
	GLES11.glDisable(GLES11.GL_CULL_FACE);
	if (textureFilename != null) {
		GLES11.glEnableClientState(GLES11.GL_TEXTURE_COORD_ARRAY);
		GLES11.glEnable(GLES11.GL_LIGHTING);
		alite.getTextureManager().setTexture(textureFilename);
	} else {
		GLES11.glDisableClientState(GLES11.GL_TEXTURE_COORD_ARRAY);
		GLES11.glDisable(GLES11.GL_LIGHTING);
		alite.getTextureManager().setTexture(null);
	}			
	GLES11.glEnableClientState(GLES11.GL_NORMAL_ARRAY);
	
	GLES11.glEnable(GLES11.GL_BLEND);
	GLES11.glBlendFunc(GLES11.GL_ONE, GLES11.GL_ONE);
	GLES11.glColor4f(emission[0], emission[1], emission[2], emission[3]);
	for (int i = 0; i < 2; i++) {
		GLES11.glPushMatrix();
		GLES11.glMultMatrixf(getMatrix(), 0);
	
		GLES11.glVertexPointer(3, GLES11.GL_FLOAT, 0, diskBuffer1);
		GLES11.glNormalPointer(GLES11.GL_FLOAT, 0, normalBuffer[0]);
		if (textureFilename != null) {
			GLES11.glTexCoordPointer(2, GLES11.GL_FLOAT, 0, texCoordBuffer[0]);
		}
		GLES11.glDrawArrays(GLES11.GL_TRIANGLE_FAN, 0, 10);
				
		GLES11.glVertexPointer(3, GLES11.GL_FLOAT, 0, cylinderBuffer);
		GLES11.glNormalPointer(GLES11.GL_FLOAT, 0, normalBuffer[1]);
		if (textureFilename != null) {
			GLES11.glTexCoordPointer(2, GLES11.GL_FLOAT, 0, texCoordBuffer[1]);
		}
		GLES11.glDrawArrays(GLES11.GL_TRIANGLE_STRIP, 0, 18);
	
		GLES11.glVertexPointer(3, GLES11.GL_FLOAT, 0, diskBuffer2);
		GLES11.glNormalPointer(GLES11.GL_FLOAT, 0, normalBuffer[2]);
		if (textureFilename != null) {
			GLES11.glTexCoordPointer(2, GLES11.GL_FLOAT, 0, texCoordBuffer[2]);
		}
		GLES11.glDrawArrays(GLES11.GL_TRIANGLE_FAN, 0, 10);

		GLES11.glPopMatrix();
		MathHelper.copyMatrix(getMatrix(), saveMatrix);
		scale(0.7f, 0.7f, 0.7f);			
		GLES11.glColor4f(1.0f, 1.0f, 1.0f, 0.8f);
	}
	MathHelper.copyMatrix(saveMatrix, currentMatrix);
	extractVectors();
	GLES11.glEnable(GLES11.GL_CULL_FACE);
	GLES11.glEnable(GLES11.GL_LIGHTING);
	GLES11.glEnableClientState(GLES11.GL_TEXTURE_COORD_ARRAY);
	alite.getTextureManager().setTexture(null);
	GLES11.glDepthFunc(GLES11.GL_LESS);
	GLES11.glDepthMask(true);
	GLES11.glDisable(GLES11.GL_BLEND);
}