Java Code Examples for android.opengl.GLES11#glColor4f()
The following examples show how to use
android.opengl.GLES11#glColor4f() .
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: ControlledShipIntroScreen.java From Alite with GNU General Public License v3.0 | 6 votes |
@Override public void performPresent(float deltaTime) { inGame.render(deltaTime, allObjects); if (!allObjects.isEmpty()) { GLES11.glMatrixMode(GLES11.GL_PROJECTION); GLES11.glPushMatrix(); GLES11.glLoadIdentity(); Rect visibleArea = ((AndroidGraphics) game.getGraphics()).getVisibleArea(); GlUtils.ortho(game, visibleArea); GLES11.glMatrixMode(GLES11.GL_MODELVIEW); GLES11.glLoadIdentity(); GLES11.glColor4f(0.937f, 0.396f, 0.0f, 1.0f); GLES11.glMatrixMode(GLES11.GL_PROJECTION); GLES11.glPopMatrix(); GLES11.glMatrixMode(GLES11.GL_MODELVIEW); } }
Example 2
Source File: InfoGaugeRenderer.java From Alite with GNU General Public License v3.0 | 6 votes |
public void renderMissiles() { int installedMissiles = alite.getCobra().getMissiles(); GLES11.glColor4f(Settings.alpha, Settings.alpha, Settings.alpha, 0.2f * Settings.alpha); missile.justRender(); for (int i = 0; i < 4; i++) { if (i < installedMissiles) { if (i == installedMissiles - 1 && alite.getCobra().isMissileLocked()) { lockedSlot.setPosition(ct.getTextureCoordX(165 + i * 80), ct.getTextureCoordY(990), ct.getTextureCoordX(165 + i * 80 + 80), ct.getTextureCoordY(1027)); lockedSlot.justRender(); } else if (i == installedMissiles - 1 && alite.getCobra().isMissileTargetting()) { targettingSlot.setPosition(ct.getTextureCoordX(165 + i * 80), ct.getTextureCoordY(990), ct.getTextureCoordX(165 + i * 80 + 80), ct.getTextureCoordY(1027)); targettingSlot.justRender(); } else { filledSlot.setPosition(ct.getTextureCoordX(165 + i * 80), ct.getTextureCoordY(990), ct.getTextureCoordX(165 + i * 80 + 80), ct.getTextureCoordY(1027)); filledSlot.justRender(); } } else { emptySlot.setPosition(ct.getTextureCoordX(165 + i * 80), ct.getTextureCoordY(990), ct.getTextureCoordX(165 + i * 80 + 80), ct.getTextureCoordY(1027)); emptySlot.justRender(); } } }
Example 3
Source File: Skysphere.java From Alite with GNU General Public License v3.0 | 6 votes |
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 4
Source File: OnScreenDebug.java From Alite with GNU General Public License v3.0 | 5 votes |
public static final void debugDocking(final Alite alite, final GraphicObject ship, final List <DepthBucket> sortedObjectsToDraw) { for (DepthBucket depthBucket: sortedObjectsToDraw) { for (AliteObject object: depthBucket.sortedObjects) { if (object instanceof SpaceObject && ((SpaceObject) object).getType() == ObjectType.SpaceStation) { float distanceSq = ObjectUtils.computeDistanceSq(object, ship); if (distanceSq < 64000000) { displayDockingAlignment(alite, ship, (SpaceObject) object, distanceSq); } return; } } } GLES11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); }
Example 5
Source File: AndroidPixmap.java From Alite with GNU General Public License v3.0 | 5 votes |
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 6
Source File: AboutScreen.java From Alite with GNU General Public License v3.0 | 5 votes |
private void setGlColor(long color) { int alpha = (int) ((color & 0xFF000000l) >> 24); int red = (int) (color & 0x00FF0000) >> 16; int green = (int) (color & 0x0000FF00) >> 8; int blue = (int) (color & 0x000000FF); GLES11.glColor4f(red / 255.0f * globalAlpha, green / 255.0f * globalAlpha, blue / 255.0f * globalAlpha, alpha / 255.0f * globalAlpha); }
Example 7
Source File: OnScreenMessage.java From Alite with GNU General Public License v3.0 | 5 votes |
void render(Alite alite) { long time = System.nanoTime(); DelayedText toBeRemoved = null; for (DelayedText dt: delayedTexts) { if (time >= dt.time) { this.text = dt.text; scale = 1.0f; activate(time, dt.duration); toBeRemoved = dt; } } if (toBeRemoved != null) { delayedTexts.remove(toBeRemoved); } if (!isActive()) { if (lastRepetitionInactive <= 0 && repetitionText != null) { lastRepetitionInactive = System.nanoTime(); repetitionTime = lastRepetitionInactive + repetitionInterval; } if (repetitionText != null && System.nanoTime() >= repetitionTime && repetitionTime > 0) { if (repetitionTimes > 0) { repetitionTimes--; } else if (repetitionTimes == 0) { clearRepetition(); repetitionTimes = -1; return; } text = repetitionText; activate(System.nanoTime(), repetitionDuration); } return; } lastRepetitionInactive = 0; GLES11.glColor4f(color.x, color.y, color.z, 0.6f); alite.getFont().drawText(text, 960, 650, true, scale); GLES11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); }
Example 8
Source File: Box.java From Alite with GNU General Public License v3.0 | 5 votes |
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 9
Source File: AutomaticLaunchScreen.java From Alite with GNU General Public License v3.0 | 5 votes |
@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 10
Source File: CursorKeys.java From Alite with GNU General Public License v3.0 | 5 votes |
void render() { float a = Settings.alpha * Settings.controlAlpha; GLES11.glColor4f(a, a, a, a); for (int i = 0; i < 4; i++) { cursorKeys[downPointer[i] > 0 ? i + 4 : i].justRender(); } GLES11.glColor4f(Settings.alpha, Settings.alpha, Settings.alpha, Settings.alpha); }
Example 11
Source File: DockingBay.java From Alite with GNU General Public License v3.0 | 5 votes |
void render() { boolean enabled = GLES11.glIsEnabled(GLES11.GL_CULL_FACE); if (enabled) { GLES11.glDisable(GLES11.GL_CULL_FACE); } alite.getTextureManager().setTexture(textureFilename); GLES11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); GLES11.glVertexPointer(3, GLES11.GL_FLOAT, 0, vertexBuffer); GLES11.glNormalPointer(GLES11.GL_FLOAT, 0, normalBuffer); GLES11.glTexCoordPointer(2, GLES11.GL_FLOAT, 0, texCoordBuffer); GLES11.glDrawArrays(GLES11.GL_TRIANGLES, 0, numberOfVertices); if (enabled) { GLES11.glEnable(GLES11.GL_CULL_FACE); } }
Example 12
Source File: PlanetScreen.java From Alite with GNU General Public License v3.0 | 5 votes |
public void afterDisplay() { Rect visibleArea = ((AndroidGraphics) game.getGraphics()).getVisibleArea(); float aspectRatio = (float) visibleArea.width() / (float) visibleArea.height(); GLES11.glEnable(GLES11.GL_TEXTURE_2D); GLES11.glEnable(GLES11.GL_CULL_FACE); GLES11.glMatrixMode(GLES11.GL_PROJECTION); GLES11.glLoadIdentity(); GlUtils.gluPerspective(game, 45.0f, aspectRatio, 20000.0f, 1000000.0f); GLES11.glMatrixMode(GLES11.GL_MODELVIEW); GLES11.glLoadIdentity(); GLES11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); GLES11.glEnableClientState(GLES11.GL_NORMAL_ARRAY); GLES11.glEnableClientState(GLES11.GL_VERTEX_ARRAY); GLES11.glEnableClientState(GLES11.GL_TEXTURE_COORD_ARRAY); GLES11.glEnable(GLES11.GL_DEPTH_TEST); GLES11.glDepthFunc(GLES11.GL_LESS); GLES11.glClear(GLES11.GL_DEPTH_BUFFER_BIT); GLES11.glPushMatrix(); GLES11.glMultMatrixf(planet.getMatrix(), 0); planet.render(); GLES11.glPopMatrix(); GLES11.glDisable(GLES11.GL_DEPTH_TEST); GLES11.glDisable(GLES11.GL_TEXTURE_2D); setUpForDisplay(visibleArea); }
Example 13
Source File: AliteScreen.java From Alite with GNU General Public License v3.0 | 5 votes |
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 14
Source File: ConstrictorScreen.java From Alite with GNU General Public License v3.0 | 5 votes |
public void displayShip() { Rect visibleArea = ((AndroidGraphics) game.getGraphics()).getVisibleArea(); float aspectRatio = (float) visibleArea.width() / (float) visibleArea.height(); GLES11.glEnable(GLES11.GL_TEXTURE_2D); GLES11.glEnable(GLES11.GL_CULL_FACE); GLES11.glMatrixMode(GLES11.GL_PROJECTION); GLES11.glLoadIdentity(); GlUtils.gluPerspective(game, 45.0f, aspectRatio, 1.0f, 100000.0f); GLES11.glMatrixMode(GLES11.GL_MODELVIEW); GLES11.glLoadIdentity(); GLES11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); GLES11.glEnableClientState(GLES11.GL_NORMAL_ARRAY); GLES11.glEnableClientState(GLES11.GL_VERTEX_ARRAY); GLES11.glEnableClientState(GLES11.GL_TEXTURE_COORD_ARRAY); GLES11.glEnable(GLES11.GL_DEPTH_TEST); GLES11.glDepthFunc(GLES11.GL_LESS); GLES11.glClear(GLES11.GL_DEPTH_BUFFER_BIT); GLES11.glPushMatrix(); GLES11.glMultMatrixf(constrictor.getMatrix(), 0); constrictor.render(); GLES11.glPopMatrix(); GLES11.glDisable(GLES11.GL_DEPTH_TEST); GLES11.glDisable(GLES11.GL_TEXTURE_2D); setUpForDisplay(visibleArea); }
Example 15
Source File: AliteHud.java From Alite with GNU General Public License v3.0 | 4 votes |
private void renderLollipops() { float x1, y1, y2; for (int i = 0; i < MAXIMUM_OBJECTS; i++) { if (enabled[i] && (!enemy[i] || enemiesVisible)) { x1 = objects[i][0] / (110.0f / zoomFactor) + RADAR_X1 + 402; y1 = objects[i][2] / (294.0f / zoomFactor) + RADAR_Y1 + 146; y2 = y1 - objects[i][1] / (294.0f / zoomFactor); float distance = objects[i][0] * objects[i][0] + objects[i][1] * objects[i][1] + objects[i][2] * objects[i][2]; if (distance > 44100.0f / zoomFactor * 44100.0f / zoomFactor) { // Don't show objects farther away than 44,100m continue; } lollipopBar.put(ct.getTextureCoordX(x1 - 13.0f)); lollipopBar.put(ct.getTextureCoordY(y2)); lollipopBar.put(ct.getTextureCoordX(x1 - 13.0f)); lollipopBar.put(ct.getTextureCoordY(y2 + 15.0f)); lollipopBar.put(ct.getTextureCoordX(x1 + 12.0f)); lollipopBar.put(ct.getTextureCoordY(y2)); lollipopBar.put(ct.getTextureCoordX(x1 + 12.0f)); lollipopBar.put(ct.getTextureCoordY(y2 + 15.0f)); lollipopBar.position(0); GLES11.glColor4f(objectColors[i][0] * Settings.alpha, objectColors[i][1] * Settings.alpha, objectColors[i][2] * Settings.alpha, Settings.alpha); GLES11.glVertexPointer(2, GLES11.GL_FLOAT, 0, lollipopBar); GLES11.glDrawArrays(GLES11.GL_TRIANGLE_STRIP, 0, 4); if (Math.abs(y2 - y1) > 15.0f) { lollipopStem.put(ct.getTextureCoordX(x1 - 13.0f)); lollipopStem.put(y1 < y2 ? ct.getTextureCoordY(y1 + 15.0f) : ct.getTextureCoordY(y1)); lollipopStem.put(ct.getTextureCoordX(x1 - 13.0f)); lollipopStem.put(y1 < y2 ? ct.getTextureCoordY(y2) : ct.getTextureCoordY(y2 + 15.0f)); lollipopStem.put(ct.getTextureCoordX(x1 - 3)); lollipopStem.put(y1 < y2 ? ct.getTextureCoordY(y1 + 15.0f) : ct.getTextureCoordY(y1)); lollipopStem.put(ct.getTextureCoordX(x1 - 3)); lollipopStem.put(y1 < y2 ? ct.getTextureCoordY(y2) : ct.getTextureCoordY(y2 + 15.0f)); lollipopStem.position(0); GLES11.glVertexPointer(2, GLES11.GL_FLOAT, 0, lollipopStem); GLES11.glDrawArrays(GLES11.GL_TRIANGLE_STRIP, 0, 4); } } } }
Example 16
Source File: InfoGaugeRenderer.java From Alite with GNU General Public License v3.0 | 4 votes |
public void render() { int sy = 700; float dataValue = GAUGE_LENGTH; for (int i = 0, n = uiTexts.length; i < n; i++) { Sprite s = uiTexts[i]; s.justRender(); gaugeOverlay.setPosition(ct.getTextureCoordX(i < 6 ? 150 : 1420), ct.getTextureCoordY(sy), ct.getTextureCoordX((i < 6 ? 150 : 1420) + 350), ct.getTextureCoordY(sy + 36)); GLES11.glColor4f(Settings.alpha, Settings.alpha, Settings.alpha, 0.2f * Settings.alpha); gaugeOverlay.justRender(); dataValue = computeDataValueAndSetColor(i, Settings.alpha); if (i == 7) { renderRoll(sy); } else if (i == 8) { renderPitch(sy); } else { if (dataValue > 0) { dataValue++; } if (i >= 6) { dataValue++; } gaugeContent.setPosition(ct.getTextureCoordX(i < 6 ? 149 : 1419), ct.getTextureCoordY(sy), ct.getTextureCoordX((i < 6 ? 149 : 1419) + dataValue), ct.getTextureCoordY(sy + 36)); } gaugeContent.justRender(); GLES11.glColor4f(Settings.alpha, Settings.alpha, Settings.alpha, Settings.alpha); sy += 40; if (i == 1 || i == 8) { sy += 25; } if (i == 5) { sy = 700; } } renderMissiles(); }
Example 17
Source File: OnScreenDebug.java From Alite with GNU General Public License v3.0 | 4 votes |
public static final void debugFPS(Alite alite) { GLES11.glColor4f(0.9f, 0.7f, 0.0f, 1.0f); alite.getFont().drawText(String.format("FPS: %3.1f", AndroidGame.fps), 400, 10, false, 1.0f); GLES11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); }
Example 18
Source File: ControlPad.java From Alite with GNU General Public License v3.0 | 4 votes |
void render() { float a = Settings.alpha * Settings.controlAlpha; GLES11.glColor4f(a, a, a, a); controlPad[activeIndex].justRender(); GLES11.glColor4f(Settings.alpha, Settings.alpha, Settings.alpha, Settings.alpha); }
Example 19
Source File: AboutScreen.java From Alite with GNU General Public License v3.0 | 4 votes |
@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 20
Source File: GLText.java From Alite with GNU General Public License v3.0 | 4 votes |
public void end() { batch.endBatch(); // End Batch GLES11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); // Restore Default Color/Alpha GLES11.glDisable(GLES11.GL_TEXTURE_2D); }