List of usage examples for org.lwjgl.opengl GL11 glPixelTransferf
public static native void glPixelTransferf(@NativeType("GLenum") int pname, @NativeType("GLfloat") float param);
From source file:game.engine.frame.handlers.FlashMessageHandler.java
License:Open Source License
@Override public void draw() { prepareOpenGlState();// w w w . j ava2 s . c om int height = Display.getHeight(); final long now = System.currentTimeMillis(); int i = 0; glBindTexture(GL_TEXTURE_2D, 0); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); GL11.glPixelTransferf(GL11.GL_RED_SCALE, 0.0f); GL11.glPixelTransferf(GL11.GL_GREEN_SCALE, 0.0f); GL11.glPixelTransferf(GL11.GL_BLUE_SCALE, 0.0f); GL11.glPixelTransferf(GL11.GL_RED_BIAS, 1.0f); GL11.glPixelTransferf(GL11.GL_GREEN_BIAS, 1.0f); GL11.glPixelTransferf(GL11.GL_BLUE_BIAS, 1.0f); GL11.glPixelTransferf(GL11.GL_ALPHA_BIAS, 0.0f); for (final Entry entry : queue) { // fading doesn't work yet final long age = (now - entry.publishTime); float brightness; if (age < displayTime) { brightness = 1.0f; } else { brightness = 1.0f - ((age - displayTime) / (float) fadeTime); } GL11.glPixelTransferf(GL11.GL_ALPHA_SCALE, brightness); glWindowPos2i(leftOffset, height - topOffset - i * (2 * font.getCharacterHeight() + 4)); font.drawText(entry.message, 2, Font.ALIGN_LEFT, Font.ALIGN_TOP); i++; } GL11.glPixelTransferf(GL11.GL_RED_SCALE, 1.0f); GL11.glPixelTransferf(GL11.GL_GREEN_SCALE, 1.0f); GL11.glPixelTransferf(GL11.GL_BLUE_SCALE, 1.0f); GL11.glPixelTransferf(GL11.GL_ALPHA_SCALE, 1.0f); GL11.glPixelTransferf(GL11.GL_RED_BIAS, 0.0f); GL11.glPixelTransferf(GL11.GL_GREEN_BIAS, 0.0f); GL11.glPixelTransferf(GL11.GL_BLUE_BIAS, 0.0f); GL11.glPixelTransferf(GL11.GL_ALPHA_BIAS, 0.0f); }
From source file:game.engine.frame.handlers.FpsPanel.java
License:Open Source License
@Override public void draw() { // update FPS countedFrames++;/* ww w . j a va2 s . c o m*/ long now = System.currentTimeMillis(); if ((now - lastSamplingTime) >= 1000) { fps = countedFrames; countedFrames = 0; lastSamplingTime = now; } // draw the FPS panel String fpsText = Float.toString(fps); glBindTexture(GL_TEXTURE_2D, 0); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glWindowPos2i(Display.getWidth(), Display.getHeight()); GL11.glPixelTransferf(GL11.GL_RED_BIAS, 1.0f); GL11.glPixelTransferf(GL11.GL_GREEN_BIAS, 1.0f); GL11.glPixelTransferf(GL11.GL_BLUE_BIAS, 1.0f); font.drawText(fpsText, 2, Font.ALIGN_RIGHT, Font.ALIGN_TOP); GL11.glPixelTransferf(GL11.GL_RED_BIAS, 0.0f); GL11.glPixelTransferf(GL11.GL_GREEN_BIAS, 0.0f); GL11.glPixelTransferf(GL11.GL_BLUE_BIAS, 0.0f); }
From source file:jpcsp.graphics.RE.RenderingEngineLwjgl.java
License:Open Source License
@Override public void setPixelTransfer(int parameter, float value) { GL11.glPixelTransferf(pixelTransferToGL[parameter], value); }
From source file:name.martingeisse.miner.ingame.CubeWorldHandler.java
License:Open Source License
/** * @param glWorkerLoop the OpenGL worker loop *///from www . j ava 2s . com public void draw(final GlWorkerLoop glWorkerLoop) { // determine player's position as integers final int playerX = (int) (Math.floor(player.getPosition().getX())); final int playerY = (int) (Math.floor(player.getPosition().getY())); final int playerZ = (int) (Math.floor(player.getPosition().getZ())); // set the GL worker loop for the section renderer ((DefaultSectionRenderer) workingSet.getEngineParameters().getSectionRenderer()) .setGlWorkerLoop(glWorkerLoop); // run preparation code in the OpenGL worker thread glWorkerLoop.schedule(new GlWorkUnit() { @Override public void execute() { // profiling ProfilingHelper.start(); // set up projection matrix glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(60, aspectRatio, 0.1f, 10000.0f); // set up modelview matrix glMatrixMode(GL_MODELVIEW); glLoadIdentity(); // model transformation (direct) glRotatef((float) player.getOrientation().getVerticalAngle(), -1, 0, 0); // view transformation (reversed) glRotatef((float) player.getOrientation().getHorizontalAngle(), 0, -1, 0); // ... glTranslated(-player.getPosition().getX(), -player.getPosition().getY(), -player.getPosition().getZ()); // ... // clear the screen glDepthMask(true); glClearColor(0.5f, 0.5f, 1.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // some more preparation glDepthFunc(GL_LESS); glEnable(GL_DEPTH_TEST); ((DefaultSectionRenderer) workingSet.getEngineParameters().getSectionRenderer()) .setWireframe(wireframe); ((DefaultSectionRenderer) workingSet.getEngineParameters().getSectionRenderer()) .setTexturing(IngameHandler.enableTexturing); ((DefaultSectionRenderer) workingSet.getEngineParameters().getSectionRenderer()) .setTextureCoordinateGeneration(IngameHandler.enableTexGen); // scale by the inverse detail factor for drawing the cubes, but prepare for scaling back glPushMatrix(); float inverseFactor = 1.0f / StackdConstants.GEOMETRY_DETAIL_FACTOR; glScalef(inverseFactor, inverseFactor, inverseFactor); } }); // actually draw the world TODO pass the GL worker workingSet.draw(new FrameRenderParameters(playerX, playerY, playerZ)); // post-draw code, again in the GL worker thread glWorkerLoop.schedule(new GlWorkUnit() { @Override public void execute() { // scale back for the remaining operations glPopMatrix(); // Measure visible distance in the center of the crosshair, with only the world visible (no HUD or similar). // Only call if needed, this stalls the rendering pipeline --> 2x frame rate possible! if (captureRayActionSupport) { rayActionSupport.capture(); } else { rayActionSupport.release(); } // draw the sky glDisable(GL_TEXTURE_GEN_S); glDisable(GL_TEXTURE_GEN_T); glDisable(GL_TEXTURE_GEN_Q); glDisable(GL_TEXTURE_GEN_R); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_TEXTURE_2D); resources.getClouds().glBindTexture(); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); final float tex = 10.0f; glColor3f(1.0f, 1.0f, 1.0f); glBegin(GL_QUADS); glTexCoord2f(0, 0); glVertex3i(-100000, 1000, -100000); glTexCoord2f(tex, 0); glVertex3i(+100000, 1000, -100000); glTexCoord2f(tex, tex); glVertex3i(+100000, 1000, +100000); glTexCoord2f(0, tex); glVertex3i(-100000, 1000, +100000); glEnd(); glDisable(GL_BLEND); // draw the grid if (grid) { glDisable(GL_TEXTURE_2D); glColor3f(1.0f, 1.0f, 1.0f); final int sectionX = playerX >> MinerCommonConstants.CLUSTER_SIZE.getShiftBits(); final int sectionY = playerY >> MinerCommonConstants.CLUSTER_SIZE.getShiftBits(); final int sectionZ = playerZ >> MinerCommonConstants.CLUSTER_SIZE.getShiftBits(); final int distance = 48; glLineWidth(2.0f); glBegin(GL_LINES); for (int u = -3; u <= 4; u++) { for (int v = -3; v <= 4; v++) { for (final AxisAlignedDirection direction : AxisAlignedDirection.values()) { if (direction.isNegative()) { continue; } final int x = MinerCommonConstants.CLUSTER_SIZE.getSize() * (sectionX + direction.selectByAxis(0, u, v)); final int dx = direction.selectByAxis(distance, 0, 0); final int y = MinerCommonConstants.CLUSTER_SIZE.getSize() * (sectionY + direction.selectByAxis(v, 0, u)); final int dy = direction.selectByAxis(0, distance, 0); final int z = MinerCommonConstants.CLUSTER_SIZE.getSize() * (sectionZ + direction.selectByAxis(u, v, 0)); final int dz = direction.selectByAxis(0, 0, distance); glVertex3f(x + dx, y + dy, z + dz); glVertex3f(x - dx, y - dy, z - dz); } } } glEnd(); } // draw player proxies (i.e. other players) glBindTexture(GL_TEXTURE_2D, 0); glEnable(GL_BLEND); glMatrixMode(GL_MODELVIEW); for (final PlayerProxy playerProxy : playerProxies) { if (playerProxy.getId() != IngameHandler.protocolClient.getSessionId()) { otherPlayerVisualTemplate.renderEmbedded(playerProxy); } } glDisable(GL_BLEND); // draw the crosshair glLineWidth(1.0f); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glDisable(GL_DEPTH_TEST); glDisable(GL_TEXTURE_2D); glColor3f(1.0f, 1.0f, 1.0f); glBegin(GL_LINES); glVertex2f(-0.1f, 0.0f); glVertex2f(+0.1f, 0.0f); glVertex2f(0.0f, -0.1f); glVertex2f(0.0f, +0.1f); glEnd(); // draw the HUD glBindTexture(GL_TEXTURE_2D, 0); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glWindowPos2i(screenWidth, screenHeight - 30); GL11.glPixelTransferf(GL11.GL_RED_BIAS, 1.0f); GL11.glPixelTransferf(GL11.GL_GREEN_BIAS, 1.0f); GL11.glPixelTransferf(GL11.GL_BLUE_BIAS, 1.0f); resources.getFont().drawText("coins: " + IngameHandler.protocolClient.getCoins(), 2, Font.ALIGN_RIGHT, Font.ALIGN_TOP); GL11.glPixelTransferf(GL11.GL_RED_BIAS, 0.0f); GL11.glPixelTransferf(GL11.GL_GREEN_BIAS, 0.0f); GL11.glPixelTransferf(GL11.GL_BLUE_BIAS, 0.0f); // profiling ProfilingHelper.checkRelevant("draw", 50); } }); }
From source file:name.martingeisse.stackd.client.gui.element.TextLine.java
License:Open Source License
@Override public void handleEvent(final GuiEvent event) { if (event == GuiEvent.DRAW) { final Font effectiveFont = getEffectiveFont(); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_BLEND);/*from w ww . j av a2s . co m*/ GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glPixelTransferf(GL11.GL_RED_SCALE, 0.0f); GL11.glPixelTransferf(GL11.GL_GREEN_SCALE, 0.0f); GL11.glPixelTransferf(GL11.GL_BLUE_SCALE, 0.0f); GL11.glPixelTransferf(GL11.GL_ALPHA_SCALE, 1.0f); GL11.glPixelTransferf(GL11.GL_RED_BIAS, color.getRed() / 255.0f); GL11.glPixelTransferf(GL11.GL_GREEN_BIAS, color.getGreen() / 255.0f); GL11.glPixelTransferf(GL11.GL_BLUE_BIAS, color.getBlue() / 255.0f); GL11.glPixelTransferf(GL11.GL_ALPHA_BIAS, 0.0f); // TODO scale font so text doesn't become smaller with higher resolution Gui gui = getGui(); int x = gui.unitsToPixelsInt(getAbsoluteX()); int y = getGui().getHeightPixels() - gui.unitsToPixelsInt(getAbsoluteY()); glWindowPos2i(x, y); effectiveFont.drawText(text, 1.0f, Font.ALIGN_LEFT, Font.ALIGN_TOP); } }
From source file:name.martingeisse.stackd.client.gui.element.TextParagraph.java
License:Open Source License
@Override public void handleEvent(final GuiEvent event) { if (event == GuiEvent.DRAW) { final Font effectiveFont = getEffectiveFont(); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_BLEND);/*from ww w. ja va2 s . c om*/ GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glPixelTransferf(GL11.GL_RED_SCALE, 0.0f); GL11.glPixelTransferf(GL11.GL_GREEN_SCALE, 0.0f); GL11.glPixelTransferf(GL11.GL_BLUE_SCALE, 0.0f); GL11.glPixelTransferf(GL11.GL_ALPHA_SCALE, 1.0f); GL11.glPixelTransferf(GL11.GL_RED_BIAS, color.getRed() / 255.0f); GL11.glPixelTransferf(GL11.GL_GREEN_BIAS, color.getGreen() / 255.0f); GL11.glPixelTransferf(GL11.GL_BLUE_BIAS, color.getBlue() / 255.0f); GL11.glPixelTransferf(GL11.GL_ALPHA_BIAS, 0.0f); // TODO scale font so text doesn't become smaller with higher resolution final Gui gui = getGui(); final int x = gui.unitsToPixelsInt(getAbsoluteX()); final int y = getGui().getHeightPixels() - gui.unitsToPixelsInt(getAbsoluteY()); final int lineHeight = effectiveFont.getCharacterHeight(); int i = 0; for (String line : lines) { glWindowPos2i(x, y - i * lineHeight); effectiveFont.drawText(line, 1.0f, Font.ALIGN_LEFT, Font.ALIGN_TOP); i++; } } }
From source file:net.neilcsmith.praxis.video.opengl.internal.GLRenderer.java
License:Apache License
void syncPixelBufferToTexture(IntBuffer buffer, Texture texture, boolean alpha, int x, int y, int width, int height) { texture.bind();/*from w w w . jav a 2 s. c o m*/ if (!alpha) { GL11.glPixelTransferf(GL11.GL_ALPHA_BIAS, 1); } GL11.glTexSubImage2D(GL11.GL_TEXTURE_2D, 0, x, y, width, height, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, buffer); if (!alpha) { GL11.glPixelTransferf(GL11.GL_ALPHA_BIAS, 0); } }
From source file:tk.ivybits.engine.gl.GL.java
License:Open Source License
public static void glPixelTransferf(int a, float b) { GL11.glPixelTransferf(a, b); }