List of usage examples for org.lwjgl.opengl GL11 glBindTexture
public static void glBindTexture(@NativeType("GLenum") int target, @NativeType("GLuint") int texture)
From source file:wrath.client.graphics.Texture.java
License:Open Source License
@Override public void reload() { this.texID = ClientUtils.getTexture(ClientUtils.loadImageFromFile(file)); GL11.glEnable(GL11.GL_TEXTURE_2D);//from ww w. j av a 2 s .c o m GL11.glBindTexture(GL11.GL_TEXTURE_2D, texID); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE); if (Game.getCurrentInstance().getConfig().getBoolean("TexureMipmapping", true)) GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D); if (Game.getCurrentInstance().getConfig().getBoolean("AntiAliasingTexture", true)) { if (Game.getCurrentInstance().getConfig().getBoolean("TexureMipmapping", true)) { GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR_MIPMAP_LINEAR); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); } else { GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST); } } Texture.unbindTextures(); Game.getCurrentInstance().getLogger() .println("Created texture ID '" + texID + "' from file '" + file.getName() + "'!"); }
From source file:wrath.client.graphics.Texture.java
License:Open Source License
/** * Sets all current OpenGL textures to point to nothing. * This should not be called by the developer as it is done automatically. *//*from www.j a va2s . co m*/ public static void unbindTextures() { GL11.glBindTexture(GL11.GL_TEXTURE_1D, 0); GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0); }
From source file:zildo.fwk.gfx.engine.SpriteEngine.java
License:Open Source License
public void render(boolean backGround) { // Display every sprites GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glEnable(GL11.GL_BLEND);/* w ww . j ava2 s. c o m*/ float[] color = ZUtils.getFloat(GL11.GL_CURRENT_COLOR, 4); Vector3f ambient = ClientEngineZildo.ortho.getAmbientColor(); if (ambient != null) { color[0] = ambient.x; color[1] = ambient.y; color[2] = ambient.z; } // Respect order from bankOrder boolean endSequence = false; int posBankOrder = 0; // Retrieve the sprite's order int[][] bankOrder = ClientEngineZildo.spriteDisplay.getBankOrder(); int phase = (backGround) ? 0 : 1; while (!endSequence) { int numBank = bankOrder[phase][posBankOrder * 4]; if (numBank == -1) { endSequence = true; } else { // Render the n sprites from this bank int nbQuads = bankOrder[phase][posBankOrder * 4 + 1]; int iCurrentFX = bankOrder[phase][posBankOrder * 4 + 2]; int alpha = bankOrder[phase][posBankOrder * 4 + 3]; EngineFX currentFX = EngineFX.values()[iCurrentFX]; int texId = textureTab[numBank]; GL11.glBindTexture(GL11.GL_TEXTURE_2D, texId); // Select the right pixel shader (if needed) if (pixelShaderSupported) { switch (currentFX) { case NO_EFFECT: ARBShaderObjects.glUseProgramObjectARB(0); break; case PERSO_HURT: // A sprite has been hurt ARBShaderObjects.glUseProgramObjectARB(ClientEngineZildo.pixelShaders.getPixelShader(1)); ClientEngineZildo.pixelShaders.setParameter(1, "randomColor", new Vector4f( (float) Math.random(), (float) Math.random(), (float) Math.random(), 1)); break; default: if (currentFX.needPixelShader()) { // This is a color replacement, so get the right ones Vector4f[] tabColors = ClientEngineZildo.pixelShaders .getConstantsForSpecialEffect(currentFX); // And enable the 'color replacement' pixel shader ARBShaderObjects .glUseProgramObjectARB(ClientEngineZildo.pixelShaders.getPixelShader(0)); ClientEngineZildo.pixelShaders.setParameter(0, "Color1", tabColors[2]); ClientEngineZildo.pixelShaders.setParameter(0, "Color2", tabColors[3]); ClientEngineZildo.pixelShaders.setParameter(0, "Color3", (Vector4f) new Vector4f(tabColors[0]).scale(color[0])); ClientEngineZildo.pixelShaders.setParameter(0, "Color4", (Vector4f) new Vector4f(tabColors[1]).scale(color[0])); } else { ARBShaderObjects.glUseProgramObjectARB(0); } } } switch (currentFX) { case SHINY: GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE); // _MINUS_SRC_ALPHA); GL11.glColor4f(1, (float) Math.random(), 0, (float) Math.random()); break; case QUAD: GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glColor4f(0.5f + 0.5f * (float) Math.random(), 0.5f * (float) Math.random(), 0, 1); break; case FOCUSED: GL11.glColor3f(1.0f, 1.0f, 1.0f); break; default: color[3] = alpha / 255.0f; ZUtils.setCurrentColor(color); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); } meshSprites[numBank].render(nbQuads); posBankOrder++; } } // Deactivate pixel shader if (pixelShaderSupported) { ARBShaderObjects.glUseProgramObjectARB(0); } GL11.glDisable(GL11.GL_BLEND); }
From source file:zildo.fwk.gfx.engine.TextureEngine.java
License:Open Source License
public void generateTexture() { // Create A IntBuffer For Image Address In Memory IntBuffer buf = ByteBuffer.allocateDirect(4).order(ByteOrder.nativeOrder()).asIntBuffer(); GL11.glGenTextures(buf); // Create Texture In OpenGL GL11.glBindTexture(GL11.GL_TEXTURE_2D, buf.get(0)); // Typical Texture Generation Using Data From The Image int wrapping = GL11.GL_REPEAT; // Wrap texture (useful for cloud) GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, wrapping); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, wrapping); int filtering = GL11.GL_NEAREST; // Linear Filtering GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, filtering); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, filtering); // Generate The Texture GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, textureFormat, 256, 256, 0, textureFormat, GL11.GL_UNSIGNED_BYTE, scratch);//from w ww . j a v a2 s . c om // Reset bytebuffer scratch scratch.clear(); // Store texture id textureTab[n_Texture] = buf.get(0); // Ready for next one n_Texture++; }
From source file:zildo.fwk.gfx.engine.TextureEngine.java
License:Open Source License
public void getTextureImage(int p_texId) { GL11.glBindTexture(GL11.GL_TEXTURE_2D, p_texId); GL11.glGetTexImage(GL11.GL_TEXTURE_2D, 0, textureFormat, GL11.GL_UNSIGNED_BYTE, scratch); }
From source file:zildo.fwk.gfx.engine.TileEngine.java
License:Open Source License
public void render(boolean backGround) { if (initialized) { Vector3f ambient = ClientEngineZildo.ortho.getAmbientColor(); if (ambient != null) { GL11.glColor3f(ambient.x, ambient.y, ambient.z); }//from w ww . j a v a2 s . com // Small optimization: do not draw invisible faces ! (counterclock // wise vertices) // pD3DDevice9.SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW); if (backGround) { // Display BACKGROUND GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glEnable(GL11.GL_BLEND); for (int i = 0; i < Constantes.NB_MOTIFBANK; i++) { if (meshBACK[i].getNPoints() > 0) { GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureTab[i]); meshBACK[i].render(); } } GL11.glDisable(GL11.GL_BLEND); } else { // Display FOREGROUND GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glEnable(GL11.GL_BLEND); for (int i = 0; i < Constantes.NB_MOTIFBANK; i++) { if (meshFORE[i].getNPoints() > 0) { GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureTab[i]); meshFORE[i].render(); } } GL11.glDisable(GL11.GL_BLEND); } // GL11.glColor3f(1f, 1f, 1f); } }
From source file:zildo.fwk.gfx.filter.BilinearFilter.java
License:Open Source License
@Override public boolean renderFilter() { fbo.endRendering();/*from www . ja va 2s . c o m*/ // Select right texture GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID); // Disable blend GL11.glDisable(GL11.GL_BLEND); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glPushMatrix(); GL11.glTranslatef(0, -sizeY, 1); GL11.glColor3f(1.0f, 1.0f, 1.0f); // Draw texture with depth super.render(); GL11.glPopMatrix(); GL11.glMatrixMode(GL11.GL_MODELVIEW); return true; }
From source file:zildo.fwk.gfx.filter.BlendFilter.java
License:Open Source License
@Override public boolean renderFilter() { int currentSquareSize = getCurrentSquareSize(); if (currentSquareSize == 1) { return true; }/*from ww w . j av a 2 s.c o m*/ fbo.endRendering(); // Get on top of screen and disable blending GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glPushMatrix(); GL11.glTranslatef(0, -sizeY, 0); GL11.glColor3f(1f, 1f, 1f); // Draw squares int nSquareX = Zildo.viewPortX / currentSquareSize; int nSquareY = Zildo.viewPortY / currentSquareSize; GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID); GL11.glBegin(GL11.GL_QUADS); for (int i = 0; i < nSquareY + 1; i++) { for (int j = 0; j < nSquareX + 1; j++) { ClientEngineZildo.ortho.boxTexturedOpti(j * currentSquareSize, i * currentSquareSize, currentSquareSize, currentSquareSize, (j * currentSquareSize) / (float) ScreenFilter.realX, (i * currentSquareSize) / (float) ScreenFilter.realY, 0, 0); } } GL11.glEnd(); GL11.glPopMatrix(); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glDisable(GL11.GL_BLEND); return true; }
From source file:zildo.fwk.gfx.filter.BlurFilter.java
License:Open Source License
@Override public boolean renderFilter() { boolean result = true; fbo.endRendering();/*from www. ja va 2 s.c o m*/ // Get on top of screen and disable blending GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity(); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glPushMatrix(); GL11.glTranslatef(0, -sizeY, 0); //GL11.glDisable(GL11.GL_BLEND); if (nImagesSaved < nImages) { // All images are not stored yet. So we just display the current one. nImagesSaved++; GL11.glBindTexture(GL11.GL_TEXTURE_2D, texBuffer[currentImage]); super.render(); result = false; } else { super.focusOnZildo(); // Draw each image, with intensified colors for (int i = 0; i < nImages; i++) { float coeff = startCoeff + i * (incCoeff / nImages); GL11.glColor4f(coeff, coeff, coeff, 1.0f); GL11.glBindTexture(GL11.GL_TEXTURE_2D, texBuffer[(i + currentImage + 1) % nImages]); super.render(); if (i == 0) { // Enable blend from second one GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE); //_MINUS_SRC_ALPHA); } } } GL11.glPopMatrix(); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glDisable(GL11.GL_BLEND); // Switch currentImage = (currentImage + 1) % nImages; return result; }
From source file:zildo.fwk.gfx.filter.CircleFilter.java
License:Open Source License
@Override public boolean renderFilter() { // Get on top of screen and disable blending GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity();//w ww .jav a 2 s .com GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glPushMatrix(); GL11.glTranslatef(0, -sizeY, 1); GL11.glColor3f(1f, 1f, 1f); GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID); GL11.glBegin(GL11.GL_QUADS); int radius = (int) (coeffLevel * (255 - getFadeLevel())); // + 20; int radiusSquare = (int) Math.pow(radius, 2); int col = 0; int sizeA = center.y - radius; int sizeB = Zildo.viewPortY - (center.y + radius); // 1) Draw the two areas outside the circle if (sizeA > 0) { ClientEngineZildo.ortho.boxOpti(0, 0, Zildo.viewPortX, sizeA, 2, null); } if (sizeB > 0) { ClientEngineZildo.ortho.boxOpti(0, center.y + radius, Zildo.viewPortX, sizeB, 2, null); } // 2) Draw the circle area int startI = Math.max(0, sizeA); int endI = Math.min(Zildo.viewPortY, center.y + radius); for (int i = startI; i < endI; i++) { int start = (int) Math.pow(i - center.y, 2); // Calculate DELTA and 2 roots x1 & x2 double delta = 4 * (radiusSquare - start); double squareRootDelta = Math.sqrt(delta); int x1 = (int) (center.x - squareRootDelta / 2); int x2 = (int) (center.x + squareRootDelta / 2); ClientEngineZildo.ortho.boxOpti(0, i, x1, 1, col, null); ClientEngineZildo.ortho.boxOpti(x2, i, Zildo.viewPortX - x2, 1, col, null); } GL11.glEnd(); GL11.glPopMatrix(); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glDisable(GL11.GL_BLEND); return true; }