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

The following examples show how to use android.opengl.GLES11#glTranslatef() . 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: HyperspaceRenderer.java    From Alite with GNU General Public License v3.0 6 votes vote down vote up
public void performPresent(float deltaTime) {
       GLES11.glPointSize(2.0f);                
    GLES11.glBlendFunc(GLES11.GL_SRC_ALPHA, GLES11.GL_ONE_MINUS_SRC_ALPHA);
       GLES11.glDisable(GLES11.GL_BLEND);

   	GLES11.glDisable(GLES11.GL_LIGHTING);
	GLES11.glMatrixMode(GLES11.GL_TEXTURE);
   	GLES11.glTranslatef(0.0007f, -0.015f, 0.0f);
   	GLES11.glMatrixMode(GLES11.GL_MODELVIEW);
	GLES11.glPushMatrix();
	GLES11.glMultMatrixf(cylinder.getMatrix(), 0);
	GLES11.glColor4f(red, green, blue, 1.0f);		
	cylinder.render();
	GLES11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
	GLES11.glPopMatrix();
	GLES11.glPointSize(1.0f);
}
 
Example 2
Source File: HyperspaceScreen.java    From Alite with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void performPresent(float deltaTime) {
	if (isDisposed) {
		return;
	}
	GLES11.glDisable(GLES11.GL_CULL_FACE);
       GLES11.glClear(GLES11.GL_COLOR_BUFFER_BIT | GLES11.GL_DEPTH_BUFFER_BIT);
       
       counter += 0.72f;
       if (counter > 360) {
       	counter = 0;
       }
       switch (increase) {
       	case 0: red += 0.002f; if (red > 1.0f) red = 1.0f; break;
       	case 1: green += 0.002f; if (green > 1.0f) green = 1.0f; break;
       	case 2: blue += 0.002f; if (blue > 1.0f) blue = 1.0f; break;
       }
       GLES11.glLoadIdentity();
       lookAt(-3.5f, 0, 0,
       	   -3.5f, 1.0f, 0,
       	   (float) Math.sin(Math.toRadians(counter)), 0.0f, (float) Math.cos(Math.toRadians(counter)));
       
       GLES11.glRotatef(counter * 2, 0.0f, 0.0f, 1.0f);
   	GLES11.glVertexPointer(3, GLES11.GL_FLOAT, 0, vertexBuffer);
   	GLES11.glTexCoordPointer(2, GLES11.GL_FLOAT, 0, textureBuffer); 
   	
   	GLES11.glMatrixMode(GLES11.GL_TEXTURE);
   	GLES11.glTranslatef(0.0f, -0.015f, 0.0f);
   	GLES11.glMatrixMode(GLES11.GL_MODELVIEW);

   	GLES11.glColor4f(red, green, blue, 1.0f);
   	GLES11.glDrawArrays(GLES11.GL_TRIANGLE_STRIP, 0, totalIndices);
   	GLES11.glEnable(GLES11.GL_CULL_FACE);
   	GLES11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
}
 
Example 3
Source File: AutomaticLaunchScreen.java    From Alite with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void performPresent(float deltaTime) {
	if (isDisposed) {
		return;
	}
	GLES11.glDisable(GLES11.GL_CULL_FACE);
       GLES11.glClear(GLES11.GL_COLOR_BUFFER_BIT | GLES11.GL_DEPTH_BUFFER_BIT);
       
       counter += 0.72f;
       if (counter > 360) {
       	counter = 0;
       }
       switch (increase) {
       	case 0: red += 0.002f; if (red > 1.0f) red = 1.0f; break;
       	case 1: green += 0.002f; if (green > 1.0f) green = 1.0f; break;
       	case 2: blue += 0.002f; if (blue > 1.0f) blue = 1.0f; break;
       }
       GLES11.glLoadIdentity();
       lookAt(-3.5f, 0, 0,
       	   -3.5f, 1.0f, 0,
       	   (float) Math.sin(Math.toRadians(counter)), 0.0f, (float) Math.cos(Math.toRadians(counter)));
       
       GLES11.glRotatef(counter * 2, 0.0f, 0.0f, 1.0f);
   	GLES11.glVertexPointer(3, GLES11.GL_FLOAT, 0, vertexBuffer);
   	GLES11.glTexCoordPointer(2, GLES11.GL_FLOAT, 0, textureBuffer); 
   	
   	GLES11.glMatrixMode(GLES11.GL_TEXTURE);
   	GLES11.glTranslatef(0.0f, -0.015f, 0.0f);
   	GLES11.glMatrixMode(GLES11.GL_MODELVIEW);

   	GLES11.glColor4f(red, green, blue, 1.0f);
   	GLES11.glDrawArrays(GLES11.GL_TRIANGLE_STRIP, 0, totalIndices);
   	GLES11.glEnable(GLES11.GL_CULL_FACE);
   	GLES11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
}
 
Example 4
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 5
Source File: GLES11DrawContext.java    From settlers-remake with MIT License 5 votes vote down vote up
public void setGlobalAttributes(float x, float y, float z, float sx, float sy, float sz) {
	// reset matrix stack
	if(lsz != -1) GLES11.glPopMatrix();
	lsz = -1;

	GLES11.glLoadIdentity();
	GLES11.glTranslatef(x, y, z);
	GLES11.glScalef(sx, sy, sz);
}
 
Example 6
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;
}