public static String getGlDetails() { String vendor = GLES11.glGetString(GLES11.GL_VENDOR); String renderer = GLES11.glGetString(GLES11.GL_RENDERER); String version = GLES11.glGetString(GLES11.GL_VERSION); String extensions = GLES11.glGetString(GLES11.GL_EXTENSIONS); StringBuffer result = new StringBuffer(); result.append("OpenGL Vendor: " + vendor + "\n"); result.append("OpenGL Renderer: " + renderer + "\n"); result.append("OpenGL Version: " + version + "\n"); if (extensions != null) { result.append("Extensions:\n"); for (String e: extensions.split(" ")) { result.append(" " + e + "\n"); } } else { result.append("No Extensions.\n"); } return result.toString(); }
public boolean performIntergalacticJump() { InGameManager.safeZoneViolated = false; if (player.getActiveMissions().size() == 0) { player.increaseIntergalacticJumpCounter(); if (player.getIntergalacticJumpCounter() == 1) { // Mimic Amiga behavior: Mission starts after 1 intergal hyperjump // and 63 other jumps (intergal or intragal). player.resetJumpCounter(); } } int nextGal = generator.getCurrentGalaxy() + 1; if (nextGal > 8 || nextGal < 1) { nextGal = 1; } generator.buildGalaxy(nextGal); player.setCurrentSystem(generator.getSystem(player.getCurrentSystem().getIndex())); player.setHyperspaceSystem(player.getCurrentSystem()); player.getCobra().removeEquipment(EquipmentStore.galacticHyperdrive); setIntergalActive(false); setScreen(new FlightScreen(this, false)); GLES11.glMatrixMode(GLES11.GL_TEXTURE); GLES11.glLoadIdentity(); navigationBar.setActiveIndex(2); return true; }
@Override public void drawText(String text, int x, int y, long color, GLText font) { if (font == null) { return; } float alpha = (float) ((((long) color) & (long) 0xFF000000) >> 24) / 255.0f; float red = ((color & 0x00FF0000) >> 16) / 255.0f; float green = ((color & 0x0000FF00) >> 8) / 255.0f; float blue = (color & 0x000000FF) / 255.0f; GLES11.glEnable(GLES11.GL_BLEND); GLES11.glBlendFunc(GLES11.GL_ONE, GLES11.GL_ONE); font.begin(red, green, blue, alpha); y -= (int) (font.getSize()); font.draw(text, transX(x), transY(y)); font.end(); GLES11.glDisable(GLES11.GL_BLEND); textureManager.setTexture(null); }
@Override public void present(float deltaTime) { if (isGl) { Rect visibleArea = ((AndroidGraphics) game.getGraphics()).getVisibleArea(); renderGlPart(deltaTime, visibleArea); setUpForDisplay(visibleArea); } if (currentLine != null) { currentLine.prePresent(deltaTime); } doPresent(deltaTime); GLES11.glBlendFunc(GLES11.GL_ONE, GLES11.GL_ONE_MINUS_SRC_ALPHA); GLES11.glEnable(GLES11.GL_BLEND); if (!hideCloseButton) { closeButton.render(alite.getGraphics()); } GLES11.glDisable(GLES11.GL_BLEND); if (currentLine != null) { currentLine.postPresent(deltaTime); } }
public void displayShip() { Rect visibleArea = ((AndroidGraphics) game.getGraphics()).getVisibleArea(); initDisplay(visibleArea); if (SHOW_DOCKING && coriolis != null) { GLES11.glPushMatrix(); GLES11.glMultMatrixf(coriolis.getMatrix(), 0); coriolis.render(); GLES11.glPopMatrix(); } GLES11.glPushMatrix(); GLES11.glMultMatrixf(currentShip.getMatrix(), 0); ((Geometry) currentShip).render(); GLES11.glPopMatrix(); endDisplay(visibleArea); }
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(); } } }
public void initializeGl(Rect visibleArea) { float ratio = (float) windowWidth / (float) windowHeight; GlUtils.setViewport(visibleArea); GLES11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); GLES11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); GLES11.glPointSize(2.0f); 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.glMatrixMode(GLES11.GL_PROJECTION); GLES11.glLoadIdentity(); GlUtils.gluPerspective(game, 120f, ratio, 0.01f, 100f); GLES11.glMatrixMode(GLES11.GL_MODELVIEW); GLES11.glLoadIdentity(); GLES11.glEnableClientState(GLES11.GL_VERTEX_ARRAY); GLES11.glEnableClientState(GLES11.GL_TEXTURE_COORD_ARRAY); GLES11.glEnable(GLES11.GL_TEXTURE_2D); GLES11.glEnable(GLES11.GL_DEPTH_TEST); ((Alite) game).getTextureManager().setTexture(textureFilename); GLES11.glDisable(GLES11.GL_LIGHTING); }
@Override public void drawDashedCircle(int cx, int cy, int r, long color, int segments) { if (segments > 64) { segments = 64; } cx = transX(cx); cy = transY(cy); r = (int) (r * scaleFactor); circleBuffer.clear(); float step = 360.0f / segments; for (float i = 0; i < 360.0f; i += step) { float ang = (float) Math.toRadians(i); circleBuffer.put((float) (cx + Math.cos(ang) * r)); circleBuffer.put((float) (cy + Math.sin(ang) * r)); } circleBuffer.position(0); setGlColor(color); GLES11.glVertexPointer(2, GLES11.GL_FLOAT, 0, circleBuffer); GLES11.glDrawArrays(GLES11.GL_LINES, 0, segments); }
@Override public void drawCircle(int cx, int cy, int r, long color, int segments) { if (segments > 64) { segments = 64; } cx = transX(cx); cy = transY(cy); r = (int) (r * scaleFactor); circleBuffer.clear(); float step = 360.0f / segments; for (float i = 0; i < 360.0f; i += step) { float ang = (float) Math.toRadians(i); circleBuffer.put((float) (cx + Math.cos(ang) * r)); circleBuffer.put((float) (cy + Math.sin(ang) * r)); } circleBuffer.position(0); setGlColor(color); GLES11.glVertexPointer(2, GLES11.GL_FLOAT, 0, circleBuffer); GLES11.glDrawArrays(GLES11.GL_LINE_LOOP, 0, segments); }
@Override public void fillRect(int x, int y, int width, int height, long color) { 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; } setGlColor(color); 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); GLES11.glVertexPointer(2, GLES11.GL_FLOAT, 0, rectBuffer); GLES11.glDrawArrays(GLES11.GL_TRIANGLE_FAN, 0, 4); }
public Disk(final Alite alite, final float innerRadius, final float outerRadius, final float beginAngle, final float endAngle, final float beginAngleOuter, final float endAngleOuter, final int sections, final String textureFilename) { numberOfVertices = 2 * (sections + 1); this.alite = alite; this.innerRadius = innerRadius; this.outerRadius = outerRadius; this.beginAngle = beginAngle; this.endAngle = endAngle; this.beginAngleOuter = beginAngleOuter; this.endAngleOuter = endAngleOuter; this.sections = sections; vertexBuffer = GlUtils.allocateFloatBuffer(4 * 3 * numberOfVertices); texCoordBuffer = GlUtils.allocateFloatBuffer(4 * 2 * numberOfVertices); normalBuffer = GlUtils.allocateFloatBuffer(4 * 3 * numberOfVertices); allNormals = new float[3 * numberOfVertices]; plotDiskPoints(innerRadius, outerRadius, (float) Math.toRadians(beginAngle), (float) Math.toRadians(endAngle), (float) Math.toRadians(beginAngleOuter), (float) Math.toRadians(endAngleOuter), sections); this.textureFilename = textureFilename; if (textureFilename != null) { alite.getTextureManager().addTexture(textureFilename); } glDrawMode = GLES11.GL_TRIANGLE_STRIP; }
@Override protected void init() { GLES11.glLightfv(GLES11.GL_LIGHT3, GLES11.GL_AMBIENT, lightAmbient, 0); GLES11.glLightfv(GLES11.GL_LIGHT3, GLES11.GL_DIFFUSE, lightAmbient, 0); GLES11.glLightfv(GLES11.GL_LIGHT3, GLES11.GL_SPECULAR, lightSpecular, 0); GLES11.glLightfv(GLES11.GL_LIGHT3, GLES11.GL_POSITION, lightPosition, 0); GLES11.glLightf(GLES11.GL_LIGHT3, GLES11.GL_SPOT_CUTOFF, 35.0f); GLES11.glLightf(GLES11.GL_LIGHT3, GLES11.GL_SPOT_EXPONENT, 100.0f); vertexBuffer = createFaces(VERTEX_DATA, NORMAL_DATA, 1, 0, 8, 2, 0, 1, 3, 1, 9, 4, 2, 1, 4, 1, 3, 4, 7, 6, 5, 0, 2, 5, 2, 6, 6, 2, 4, 7, 5, 6, 8, 0, 11, 8, 11, 5, 8, 5, 7, 8, 7, 4, 8, 4, 3, 8, 3, 10, 9, 1, 8, 9, 8, 10, 9, 10, 3, 11, 0, 5); texCoordBuffer = GlUtils.toFloatBufferPositionZero(TEXTURE_COORDINATE_DATA); alite.getTextureManager().addTexture(textureFilename); if (Settings.engineExhaust) { addExhaust(new EngineExhaust(this, 13, 13, 300, -50, 0, 0)); addExhaust(new EngineExhaust(this, 13, 13, 300, 50, 0, 0)); addExhaust(new EngineExhaust(this, 5, 5, 180, -115, 0, 0, 1.0f, 0.5f, 0.0f, 0.7f)); addExhaust(new EngineExhaust(this, 5, 5, 180, 115, 0, 0, 1.0f, 0.5f, 0.0f, 0.7f)); } initTargetBox(); }
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]); } } }
public synchronized void freeAllTextures() { Iterator <String> iterator = Collections.synchronizedSet(textures.keySet()).iterator(); ArrayList <String> toBeRemoved = new ArrayList<String>(); while (iterator.hasNext()) { String fileName = iterator.next(); Texture texture = textures.get(fileName); if (texture != null) { GLES11.glDeleteTextures(1, texture.index, 0); texturePool.free(texture); toBeRemoved.add(fileName); } } for (String s: toBeRemoved) { textures.put(s, null); } sprites.clear(); }
@Override public void fillCircle(int cx, int cy, int r, long color, int segments) { if (segments > 64) { segments = 64; } cx = transX(cx); cy = transY(cy); r = (int) (r * scaleFactor); circleBuffer.clear(); float step = 360.0f / segments; for (float i = 0; i < 360.0f; i += step) { float ang = (float) Math.toRadians(i); circleBuffer.put((float) (cx + Math.cos(ang) * r)); circleBuffer.put((float) (cy + Math.sin(ang) * r)); } circleBuffer.position(0); setGlColor(color); GLES11.glVertexPointer(2, GLES11.GL_FLOAT, 0, circleBuffer); GLES11.glDrawArrays(GLES11.GL_TRIANGLE_FAN, 0, segments); }
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); } }
private void performViewTransformation(float deltaTime) { // Kudos to Quelo!! // Thanks for getting me started on OpenGL -- from simply // looking at this method, one cannot immediately grasp the // complexities of the ideas behind it. // And without Quelo, I certainly would not have understood! GLES11.glMatrixMode(GLES11.GL_MODELVIEW); GLES11.glLoadIdentity(); GLES11.glLightfv(GLES11.GL_LIGHT1, GLES11.GL_POSITION, lightPosition, 0); if (!paused) { ship.applyDeltaRotation((float) Math.toDegrees(deltaYawRollPitch.z * deltaTime), (float) Math.toDegrees(deltaYawRollPitch.x * deltaTime), (float) Math.toDegrees(deltaYawRollPitch.y * deltaTime)); } ship.orthoNormalize(); Matrix.invertM(viewMatrix, 0, ship.getMatrix(), 0); GLES11.glLoadMatrixf(viewMatrix, 0); }
private void renderHud() { if (hud == null) { return; } GLES11.glMatrixMode(GLES11.GL_PROJECTION); GLES11.glPushMatrix(); GLES11.glLoadIdentity(); Rect visibleArea = ((AndroidGraphics) alite.getGraphics()).getVisibleArea(); GlUtils.ortho(alite, visibleArea); GLES11.glMatrixMode(GLES11.GL_MODELVIEW); GLES11.glLoadIdentity(); if (playerControl) { alite.getCobra().setRotation(deltaYawRollPitch.z, deltaYawRollPitch.y); } alite.getCobra().setSpeed(ship.getSpeed()); hud.render(); hud.clear(); }
public void renderScroller(final float deltaTime) { GLES11.glColor4f(0.0f, 0.0f, 0.0f, 1.0f); GLES11.glClear(GLES11.GL_COLOR_BUFFER_BIT); GLES11.glMatrixMode(GLES11.GL_PROJECTION); GLES11.glPushMatrix(); GLES11.glLoadIdentity(); Rect visibleArea = ((AndroidGraphics) alite.getGraphics()).getVisibleArea(); GlUtils.ortho(alite, visibleArea); GLES11.glMatrixMode(GLES11.GL_MODELVIEW); GLES11.glLoadIdentity(); GLES11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); message.render(alite); if (scrollingText != null) { scrollingText.render(deltaTime); } GLES11.glMatrixMode(GLES11.GL_PROJECTION); GLES11.glPopMatrix(); GLES11.glMatrixMode(GLES11.GL_MODELVIEW); }
private void init() { inGame.setPlayerControl(false); inGame.setViewport(0); inGame.getShip().setSpeed(0); inGame.getShip().getForwardVector().copy(movementVector); startTime = System.nanoTime(); Alite.get().getTextureManager().addTexture(textureFilename); cylinder = new CylinderSpaceObject(Alite.get(), "HyperspaceTunnel", 12500.0f, 100.0f, 16, false, false, textureFilename); red = 0.2f + (float) Math.random() * 0.5f; green = 0.2f + (float) Math.random() * 0.5f; blue = 0.2f + (float) Math.random() * 0.5f; SoundManager.stop(Assets.hyperspace); SoundManager.play(Assets.hyperspace); progress = 0.0f; cylinder.setMatrix(inGame.getShip().getMatrix()); cylinder.setColor(red, green, blue, 1.0f); cylinder.setSpeed(-400.0f); cylinder.moveForward(17.0f, movementVector); GLES11.glTexEnvf(GLES11.GL_TEXTURE_ENV, GLES11.GL_TEXTURE_ENV_MODE, GLES11.GL_MODULATE); movementVector.negate(); }
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); }
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); } }
@Override public void onActivation() { AliteLog.d("Ship Intro Screen", "On Activation. glError: " + GLES11.glGetError()); Rect visibleArea = ((AndroidGraphics) game.getGraphics()).getVisibleArea(); windowWidth = visibleArea.width(); windowHeight = visibleArea.height(); initializeGl(visibleArea); AliteLog.d("Ship Intro Screen", "On Activation. After init. glError: " + GLES11.glGetError()); AliteHud.ct = new DefaultCoordinateTransformer((Alite) game); allObjects.clear(); SpaceObject cobra = new CargoCanister((Alite) game); cobra.setPosition(0.0f, 0.0f, START_Z); inGame.getShip().setPosition(0.0f, 0.0f, 0.0f); allObjects.add(cobra); startTime = System.nanoTime(); screenStartTime = startTime; displayMode = DisplayMode.ZOOM_IN; AliteLog.d("Ship Intro Screen", "On Activation done. glError: " + GLES11.glGetError()); }
@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); } }
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); }
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); }
public static Bitmap createBitmapFromGLSurface(int x, int y, int w, int h, int glHeight) throws OutOfMemoryError { int bitmapBuffer[] = new int[w * h]; int bitmapSource[] = new int[w * h]; IntBuffer intBuffer = IntBuffer.wrap(bitmapBuffer); intBuffer.position(0); try { GLES11.glReadPixels(x, glHeight - h - y, w, h, GL10.GL_RGBA, GL10.GL_UNSIGNED_BYTE, intBuffer); int offset1, offset2; for (int i = 0; i < h; i++) { offset1 = i * w; offset2 = (h - i - 1) * w; for (int j = 0; j < w; j++) { int texturePixel = bitmapBuffer[offset1 + j]; int blue = (texturePixel >> 16) & 0xff; int red = (texturePixel << 16) & 0x00ff0000; int pixel = (texturePixel & 0xff00ff00) | red | blue; bitmapSource[offset2 + j] = pixel; } } } catch (GLException e) { return null; } return Bitmap.createBitmap(bitmapSource, w, h, Bitmap.Config.ARGB_8888); }
public static void debugGlVendorData() { String vendor = GLES11.glGetString(GLES11.GL_VENDOR); String renderer = GLES11.glGetString(GLES11.GL_RENDERER); String version = GLES11.glGetString(GLES11.GL_VERSION); String extensions = GLES11.glGetString(GLES11.GL_EXTENSIONS); d("GL Vendor Data", "Vendor: " + vendor); d("GL Vendor Data", "Renderer: " + renderer); d("GL Vendor Data", "Version: " + version); if (extensions != null) { for (String e: extensions.split(" ")) { d("GL Vendor Data", "Extension: " + e); } } }
public boolean performHyperspaceJump() { InGameManager.safeZoneViolated = false; if (player.getActiveMissions().size() == 0) { player.increaseJumpCounter(); } boolean willEnterWitchSpace = player.getRating().ordinal() > Rating.POOR.ordinal() && Math.random() <= 0.02; for (Mission mission: player.getActiveMissions()) { willEnterWitchSpace |= mission.willEnterWitchSpace(); } if (player.getCobra().getPitch() <= -2.0f && player.getCobra().getRoll() <= -2.0f) { willEnterWitchSpace = true; } int distance = player.getCurrentSystem() == null ? computeDistance(player.getPosition(), player.getHyperspaceSystem()) : player.getCurrentSystem().computeDistance(player.getHyperspaceSystem()); if (willEnterWitchSpace) { distance >>= 1; int x = player.getCurrentSystem() == null ? player.getPosition().x : player.getCurrentSystem().getX(); int y = player.getCurrentSystem() == null ? player.getPosition().y : player.getCurrentSystem().getY(); int dx = player.getHyperspaceSystem().getX() - x; int dy = player.getHyperspaceSystem().getY() - y; int nx = x + (dx >> 1); int ny = y + (dy >> 1); player.setPosition(nx, ny); player.setCurrentSystem(null); } else { player.setCurrentSystem(player.getHyperspaceSystem()); } player.getCobra().setFuel(player.getCobra().getFuel() - distance); FlightScreen fs = new FlightScreen(this, false); if (willEnterWitchSpace) { fs.enterWitchSpace(); } setScreen(fs); GLES11.glMatrixMode(GLES11.GL_TEXTURE); GLES11.glLoadIdentity(); navigationBar.setActiveIndex(2); player.setLegalValue(player.getLegalValue() >> 1); return true; }
protected void renderText() { if (currentLine != null) { currentY = currentLine.getY(); currentHeight = currentLine.getHeight(); if (currentHeight != 0 && textData != null && textData.length > 0) { currentHeight = textData[textData.length - 1].y + 30 - currentY; if (currentY + currentHeight > 1080) { AliteLog.e("Overfull VBox", "Attention: Overfull VBox for " + currentLine.getText() + " => " + (currentY + currentHeight)); } currentLine.setHeight(currentHeight); } currentX = currentLine.getX(); currentWidth = currentLine.getWidth(); } if (currentLine == null || currentLine.getText().isEmpty()) { return; } Graphics g = alite.getGraphics(); GLES11.glBlendFunc(GLES11.GL_ONE, GLES11.GL_ONE_MINUS_SRC_ALPHA); GLES11.glEnable(GLES11.GL_BLEND); if (currentX != -1 && currentY != -1) { g.gradientRect(currentX, currentY, currentWidth, currentHeight, true, true, AliteColors.get().tutorialBubbleDark(), AliteColors.get().tutorialBubbleLight()); } GLES11.glDisable(GLES11.GL_BLEND); if (currentX != -1 && currentY != -1) { g.rec3d(currentX, currentY, currentWidth, currentHeight, 4, AliteColors.get().tutorialBubbleLight(), AliteColors.get().tutorialBubbleDark()); } if (currentLine != null && textData != null) { displayText(g, textData); } }
@Override public void postNavigationRender(float deltaTime) { if (currentLine != null) { GLES11.glBlendFunc(GLES11.GL_ONE, GLES11.GL_ONE_MINUS_SRC_ALPHA); GLES11.glEnable(GLES11.GL_BLEND); currentLine.renderHighlights(deltaTime); GLES11.glDisable(GLES11.GL_BLEND); } }
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); }
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(cougar.getMatrix(), 0); cougar.render(); GLES11.glPopMatrix(); GLES11.glDisable(GLES11.GL_DEPTH_TEST); GLES11.glDisable(GLES11.GL_TEXTURE_2D); setUpForDisplay(visibleArea); }
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); }
private void initDisplay(final Rect visibleArea) { 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, 900000.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.glPushMatrix(); GLES11.glMultMatrixf(skysphere.getMatrix(), 0); skysphere.render(); GLES11.glPopMatrix(); 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.glDisable(GLES11.GL_BLEND); }
public void presentTradeGoods(float deltaTime) { Graphics g = game.getGraphics(); for (int y = 0; y < ROWS; y++) { for (int x = 0; x < COLUMNS; x++) { if (tradeButton[x][y] == null) { continue; } if (selection == tradeButton[x][y]) { if (Settings.animationsEnabled) { computeCurrentFrame(); } //tradeButton[x][y].setBorderColors(AliteColors.get().selectedColoredFrameLight(), AliteColors.get().selectedColoredFrameDark()); tradeButton[x][y].render(g, currentFrame); GLES11.glEnable(GLES11.GL_BLEND); GLES11.glBlendFunc(GLES11.GL_ONE, GLES11.GL_ONE); GLES11.glEnableClientState(GLES11.GL_VERTEX_ARRAY); g.fillRect(tradeButton[x][y].getX(), tradeButton[x][y].getY(), tradeButton[x][y].getWidth(), tradeButton[x][y].getHeight(), AliteColors.get().highlightColor()); GLES11.glDisable(GLES11.GL_BLEND); if (errorText == null) { presentSelection(y, x); } } else { //tradeButton[x][y].setBorderColors(AliteColors.get().coloredFrameLight(), AliteColors.get().coloredFrameDark()); tradeButton[x][y].render(g); } String price = getCost(y, x); int halfWidth = g.getTextWidth(price, Assets.regularFont) >> 1; g.drawText(price, x * GAP_X + X_OFFSET + (SIZE >> 1) - halfWidth, y * GAP_Y + Y_OFFSET + SIZE + 35, AliteColors.get().price(), Assets.regularFont); drawAdditionalTradeGoodInformation(y, x, deltaTime); } } if (errorText != null) { game.getGraphics().drawText(errorText, X_OFFSET, 1050, AliteColors.get().message(), Assets.regularFont); } if (cashLeft != null) { g.drawText(cashLeft, X_OFFSET, 1050, AliteColors.get().message(), Assets.regularFont); } }
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); }
@Override public void setClip(int x1, int y1, int x2, int y2) { if (x1 == -1 && y1 == -1 && x2 == -1 && y2 == -1) { GLES11.glDisable(GLES11.GL_SCISSOR_TEST); return; } x1 = x1 == -1 ? Math.max(visibleArea.left - 1, 0) : transX(x1); y1 = y1 == -1 ? Math.max(visibleArea.top - 1, 0) : transY(y1); x2 = x2 == -1 ? Math.min(visibleArea.right + 1, visibleArea.width()) : transX(x2); y2 = y2 == -1 ? Math.min(visibleArea.bottom + 1, visibleArea.height()) : transY(y2); GLES11.glEnable(GLES11.GL_SCISSOR_TEST); GLES11.glScissor(x1, y1, x2 - x1 + 1, y2 - y1 + 1); }
public void renderYesNoButtons() { GLES11.glColor4f(Settings.alpha, Settings.alpha, Settings.alpha, Settings.alpha); yesButton.render(); noButton.render(); if (yesTouched) { overlay.setPosition(yesButton.getPosition()); overlay.render(); } if (noTouched) { overlay.setPosition(noButton.getPosition()); overlay.render(); } GLES11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); }