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

The following examples show how to use android.opengl.GLES11#glBindTexture() . 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: TextureManager.java    From Alite with GNU General Public License v3.0 6 votes vote down vote up
public void setTexture(String fileName) {
	if (fileName == null) {
		GLES11.glBindTexture(GLES11.GL_TEXTURE_2D, 0);			
		return;
	}
	Texture texture = textures.get(fileName);
	if (texture == null || !texture.isValid()) {		
		addTexture(fileName);
		texture = textures.get(fileName);
	}
	if (texture != null) {
		if (!texture.isValid()) {
			texture.index[0] = addTexture(fileName);
		}
		
		if (texture.index[0] != 0) {
			GLES11.glBindTexture(GLES11.GL_TEXTURE_2D, texture.index[0]);
		} 
	} 
}
 
Example 2
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 3
Source File: AliteScreen.java    From Alite with GNU General Public License v3.0 5 votes vote down vote up
protected final void setUpForDisplay(Rect visibleArea) {		
	GLES11.glDisable(GLES11.GL_CULL_FACE);
	GLES11.glDisable(GLES11.GL_LIGHTING);
	GLES11.glBindTexture(GLES11.GL_TEXTURE_2D, 0);
	GLES11.glDisable(GLES11.GL_TEXTURE_2D);

	GLES11.glMatrixMode(GLES11.GL_PROJECTION);
	GLES11.glLoadIdentity();
	GlUtils.ortho(game, visibleArea);

	GLES11.glMatrixMode(GLES11.GL_MODELVIEW);
	GLES11.glLoadIdentity();

	GLES11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);	
}
 
Example 4
Source File: TextureManager.java    From Alite with GNU General Public License v3.0 5 votes vote down vote up
public void freeTexture(String fileName) {
	Texture texture = textures.get(fileName);
	if (texture != null && texture.isValid()) {			
		GLES11.glBindTexture(GLES11.GL_TEXTURE_2D, 0);
		GLES11.glDeleteTextures(1, texture.index, 0);			
		GLES11.glFinish();
		textures.put(fileName, null);
		bitmaps.remove(fileName);
		texturePool.free(texture);
	}
}
 
Example 5
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 6
Source File: GLText.java    From Alite with GNU General Public License v3.0 5 votes vote down vote up
public void begin(float red, float green, float blue, float alpha) {
	GLES11.glColor4f(red, green, blue, alpha); // Set Color+Alpha
	GLES11.glEnable(GLES11.GL_TEXTURE_2D);
	GLES11.glBindTexture(GLES11.GL_TEXTURE_2D, textureId); // Bind the
															// Texture
	batch.beginBatch(); // Begin Batch
}
 
Example 7
Source File: GLES11DrawContext.java    From settlers-remake with MIT License 5 votes vote down vote up
protected void bindTexture(TextureHandle texture) {
	if (texture != lastTexture) {
		int id = 0;
		if (texture != null) {
			id = texture.getInternalId();
		}
		GLES11.glBindTexture(GLES11.GL_TEXTURE_2D, id);
		lastTexture = texture;
	}
}
 
Example 8
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 9
Source File: TextureManager.java    From Alite with GNU General Public License v3.0 4 votes vote down vote up
private final void loadTexture(Bitmap bitmap, int index) {				
	GLES11.glBindTexture(GLES11.GL_TEXTURE_2D, index);
	GLES11.glTexParameterf(GLES11.GL_TEXTURE_2D, GLES11.GL_TEXTURE_MAG_FILTER, GLES11.GL_LINEAR);
	GLES11.glTexParameterf(GLES11.GL_TEXTURE_2D, GLES11.GL_TEXTURE_MIN_FILTER, GLES11.GL_LINEAR);
	GLUtils.texImage2D(GLES11.GL_TEXTURE_2D, 0, bitmap, 0);
}
 
Example 10
Source File: AboutScreen.java    From Alite with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void performPresent(float deltaTime) {
	if (isDisposed) {
		return;
	}
	GLES11.glClear(GLES11.GL_COLOR_BUFFER_BIT | GLES11.GL_DEPTH_BUFFER_BIT);
       GLES11.glClearDepthf(1.0f);

       GLES11.glMatrixMode(GLES11.GL_MODELVIEW);
       GLES11.glLoadIdentity();                    

       GLES11.glEnable(GLES11.GL_TEXTURE_2D);
	GLES11.glMatrixMode(GLES11.GL_PROJECTION);
	GLES11.glPushMatrix();		
	GLES11.glLoadIdentity();
	Rect visibleArea = ((AndroidGraphics) ((Alite) game).getGraphics()).getVisibleArea();
	GlUtils.ortho(game, visibleArea);		
	
	GLES11.glMatrixMode(GLES11.GL_MODELVIEW);
	GLES11.glLoadIdentity();
	GLES11.glDisable(GLES11.GL_DEPTH_TEST);		
	GLES11.glColor4f(globalAlpha, globalAlpha, globalAlpha, globalAlpha);
	background.render();
       GLES11.glColor4f(globalAlpha * alpha, globalAlpha * alpha, globalAlpha * alpha, globalAlpha * alpha);
       aliteLogo.render();
       if (y < 1200) {
       	int i = 0;
       	for (TextData text: texts) {
       		i++;
       		if (y + text.y > -120) {
           		if (y + text.y > 1080) {
           			break;
           		}
           		setGlColor(text.color);
           		font.drawText(text.text, text.x, y + text.y, true, text.scale);
           		if (y + text.y < 525 && i == texts.size() - 1) {
           			end = true;
           		}
       		}
       	}
       }
       GLES11.glColor4f(globalAlpha, globalAlpha, globalAlpha, globalAlpha);
       ((Alite) game).getFont().drawText("Alite Version " + Alite.VERSION_STRING, 0, 1030, false, 1.0f);
	GLES11.glDisable(GLES11.GL_CULL_FACE);
	GLES11.glMatrixMode(GLES11.GL_PROJECTION);
	GLES11.glPopMatrix();
	GLES11.glMatrixMode(GLES11.GL_MODELVIEW);
	GLES11.glEnable(GLES11.GL_DEPTH_TEST);
	
       GLES11.glDisable(GLES11.GL_TEXTURE_2D);
	GLES11.glBindTexture(GLES11.GL_TEXTURE_2D, 0);
}
 
Example 11
Source File: SpriteBatch.java    From Alite with GNU General Public License v3.0 4 votes vote down vote up
public void beginBatch(int textureId)  {
 GLES11.glBindTexture(GLES11.GL_TEXTURE_2D, textureId); // Bind Texture
   numSprites = 0;                                 // Empty Sprite Counter
   bufferIndex = 0;                                // Reset Buffer Index (Empty)
}