List of usage examples for org.lwjgl.opengl GL11 glTexEnvf
public static native void glTexEnvf(@NativeType("GLenum") int target, @NativeType("GLenum") int pname, @NativeType("GLfloat") float param);
From source file:com.ardor3d.scene.state.lwjgl.LwjglTextureStateUtil.java
License:Open Source License
public static void applyCombineFactors(final Texture texture, final TextureUnitRecord unitRecord, final int unit, final TextureStateRecord record, final ContextCapabilities caps) { // check that this is a valid fixed function unit. glTexEnv is only // supported for unit < GL_MAX_TEXTURE_UNITS if (unit >= caps.getNumberOfFixedTextureUnits()) { return;//from www . ja va 2 s. c o m } // first thing's first... if we are doing dot3 and don't // support it, disable this texture. boolean checked = false; if (!caps.isEnvDot3TextureCombineSupported() && (texture.getCombineFuncRGB() == CombinerFunctionRGB.Dot3RGB || texture.getCombineFuncRGB() == CombinerFunctionRGB.Dot3RGBA)) { // disable disableTexturing(unitRecord, record, unit, caps); // No need to continue return; } // Okay, now let's set our scales if we need to: // First RGB Combine scale if (!unitRecord.isValid() || unitRecord.envRGBScale != texture.getCombineScaleRGB()) { if (!checked) { checkAndSetUnit(unit, record, caps); checked = true; } GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, ARBTextureEnvCombine.GL_RGB_SCALE_ARB, texture.getCombineScaleRGB().floatValue()); unitRecord.envRGBScale = texture.getCombineScaleRGB(); } // Then Alpha Combine scale if (!unitRecord.isValid() || unitRecord.envAlphaScale != texture.getCombineScaleAlpha()) { if (!checked) { checkAndSetUnit(unit, record, caps); checked = true; } GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_ALPHA_SCALE, texture.getCombineScaleAlpha().floatValue()); unitRecord.envAlphaScale = texture.getCombineScaleAlpha(); } // Time to set the RGB combines final CombinerFunctionRGB rgbCombineFunc = texture.getCombineFuncRGB(); if (!unitRecord.isValid() || unitRecord.rgbCombineFunc != rgbCombineFunc) { if (!checked) { checkAndSetUnit(unit, record, caps); checked = true; } GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, ARBTextureEnvCombine.GL_COMBINE_RGB_ARB, LwjglTextureUtil.getGLCombineFuncRGB(rgbCombineFunc)); unitRecord.rgbCombineFunc = rgbCombineFunc; } CombinerSource combSrcRGB = texture.getCombineSrc0RGB(); if (!unitRecord.isValid() || unitRecord.combSrcRGB0 != combSrcRGB) { if (!checked) { checkAndSetUnit(unit, record, caps); checked = true; } GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, ARBTextureEnvCombine.GL_SOURCE0_RGB_ARB, LwjglTextureUtil.getGLCombineSrc(combSrcRGB)); unitRecord.combSrcRGB0 = combSrcRGB; } CombinerOperandRGB combOpRGB = texture.getCombineOp0RGB(); if (!unitRecord.isValid() || unitRecord.combOpRGB0 != combOpRGB) { if (!checked) { checkAndSetUnit(unit, record, caps); checked = true; } GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, ARBTextureEnvCombine.GL_OPERAND0_RGB_ARB, LwjglTextureUtil.getGLCombineOpRGB(combOpRGB)); unitRecord.combOpRGB0 = combOpRGB; } // We only need to do Arg1 or Arg2 if we aren't in Replace mode if (rgbCombineFunc != CombinerFunctionRGB.Replace) { combSrcRGB = texture.getCombineSrc1RGB(); if (!unitRecord.isValid() || unitRecord.combSrcRGB1 != combSrcRGB) { if (!checked) { checkAndSetUnit(unit, record, caps); checked = true; } GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, ARBTextureEnvCombine.GL_SOURCE1_RGB_ARB, LwjglTextureUtil.getGLCombineSrc(combSrcRGB)); unitRecord.combSrcRGB1 = combSrcRGB; } combOpRGB = texture.getCombineOp1RGB(); if (!unitRecord.isValid() || unitRecord.combOpRGB1 != combOpRGB) { if (!checked) { checkAndSetUnit(unit, record, caps); checked = true; } GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, ARBTextureEnvCombine.GL_OPERAND1_RGB_ARB, LwjglTextureUtil.getGLCombineOpRGB(combOpRGB)); unitRecord.combOpRGB1 = combOpRGB; } // We only need to do Arg2 if we are in Interpolate mode if (rgbCombineFunc == CombinerFunctionRGB.Interpolate) { combSrcRGB = texture.getCombineSrc2RGB(); if (!unitRecord.isValid() || unitRecord.combSrcRGB2 != combSrcRGB) { if (!checked) { checkAndSetUnit(unit, record, caps); checked = true; } GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, ARBTextureEnvCombine.GL_SOURCE2_RGB_ARB, LwjglTextureUtil.getGLCombineSrc(combSrcRGB)); unitRecord.combSrcRGB2 = combSrcRGB; } combOpRGB = texture.getCombineOp2RGB(); if (!unitRecord.isValid() || unitRecord.combOpRGB2 != combOpRGB) { if (!checked) { checkAndSetUnit(unit, record, caps); checked = true; } GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, ARBTextureEnvCombine.GL_OPERAND2_RGB_ARB, LwjglTextureUtil.getGLCombineOpRGB(combOpRGB)); unitRecord.combOpRGB2 = combOpRGB; } } } // Now Alpha combines final CombinerFunctionAlpha alphaCombineFunc = texture.getCombineFuncAlpha(); if (!unitRecord.isValid() || unitRecord.alphaCombineFunc != alphaCombineFunc) { if (!checked) { checkAndSetUnit(unit, record, caps); checked = true; } GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, ARBTextureEnvCombine.GL_COMBINE_ALPHA_ARB, LwjglTextureUtil.getGLCombineFuncAlpha(alphaCombineFunc)); unitRecord.alphaCombineFunc = alphaCombineFunc; } CombinerSource combSrcAlpha = texture.getCombineSrc0Alpha(); if (!unitRecord.isValid() || unitRecord.combSrcAlpha0 != combSrcAlpha) { if (!checked) { checkAndSetUnit(unit, record, caps); checked = true; } GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, ARBTextureEnvCombine.GL_SOURCE0_ALPHA_ARB, LwjglTextureUtil.getGLCombineSrc(combSrcAlpha)); unitRecord.combSrcAlpha0 = combSrcAlpha; } CombinerOperandAlpha combOpAlpha = texture.getCombineOp0Alpha(); if (!unitRecord.isValid() || unitRecord.combOpAlpha0 != combOpAlpha) { if (!checked) { checkAndSetUnit(unit, record, caps); checked = true; } GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, ARBTextureEnvCombine.GL_OPERAND0_ALPHA_ARB, LwjglTextureUtil.getGLCombineOpAlpha(combOpAlpha)); unitRecord.combOpAlpha0 = combOpAlpha; } // We only need to do Arg1 or Arg2 if we aren't in Replace mode if (alphaCombineFunc != CombinerFunctionAlpha.Replace) { combSrcAlpha = texture.getCombineSrc1Alpha(); if (!unitRecord.isValid() || unitRecord.combSrcAlpha1 != combSrcAlpha) { if (!checked) { checkAndSetUnit(unit, record, caps); checked = true; } GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, ARBTextureEnvCombine.GL_SOURCE1_ALPHA_ARB, LwjglTextureUtil.getGLCombineSrc(combSrcAlpha)); unitRecord.combSrcAlpha1 = combSrcAlpha; } combOpAlpha = texture.getCombineOp1Alpha(); if (!unitRecord.isValid() || unitRecord.combOpAlpha1 != combOpAlpha) { if (!checked) { checkAndSetUnit(unit, record, caps); checked = true; } GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, ARBTextureEnvCombine.GL_OPERAND1_ALPHA_ARB, LwjglTextureUtil.getGLCombineOpAlpha(combOpAlpha)); unitRecord.combOpAlpha1 = combOpAlpha; } // We only need to do Arg2 if we are in Interpolate mode if (alphaCombineFunc == CombinerFunctionAlpha.Interpolate) { combSrcAlpha = texture.getCombineSrc2Alpha(); if (!unitRecord.isValid() || unitRecord.combSrcAlpha2 != combSrcAlpha) { if (!checked) { checkAndSetUnit(unit, record, caps); checked = true; } GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, ARBTextureEnvCombine.GL_SOURCE2_ALPHA_ARB, LwjglTextureUtil.getGLCombineSrc(combSrcAlpha)); unitRecord.combSrcAlpha2 = combSrcAlpha; } combOpAlpha = texture.getCombineOp2Alpha(); if (!unitRecord.isValid() || unitRecord.combOpAlpha2 != combOpAlpha) { if (!checked) { checkAndSetUnit(unit, record, caps); checked = true; } GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, ARBTextureEnvCombine.GL_OPERAND2_ALPHA_ARB, LwjglTextureUtil.getGLCombineOpAlpha(combOpAlpha)); unitRecord.combOpAlpha2 = combOpAlpha; } } } }
From source file:com.ardor3d.scene.state.lwjgl.LwjglTextureStateUtil.java
License:Open Source License
public static void applyLodBias(final Texture texture, final TextureUnitRecord unitRecord, final int unit, final TextureStateRecord record, final ContextCapabilities caps) { if (caps.isTextureLodBiasSupported()) { final float bias = texture.getLodBias() < caps.getMaxLodBias() ? texture.getLodBias() : caps.getMaxLodBias();// w ww . ja va2 s .co m if (!unitRecord.isValid() || unitRecord.lodBias != bias) { checkAndSetUnit(unit, record, caps); GL11.glTexEnvf(EXTTextureLODBias.GL_TEXTURE_FILTER_CONTROL_EXT, EXTTextureLODBias.GL_TEXTURE_LOD_BIAS_EXT, bias); unitRecord.lodBias = bias; } } }
From source file:com.badlogic.gdx.backends.lwjgl.LwjglGL10.java
License:Apache License
public final void glTexEnvf(int target, int pname, float param) { GL11.glTexEnvf(target, pname, param); }
From source file:com.damagedearth.Utilities.Components.TrueTypeFont.java
License:Open Source License
public static int loadImage(BufferedImage bufferedImage) { try {/*from w ww . ja v a 2s . c o m*/ short width = (short) bufferedImage.getWidth(); short height = (short) bufferedImage.getHeight(); //textureLoader.bpp = bufferedImage.getColorModel().hasAlpha() ? (byte)32 : (byte)24; int bpp = (byte) bufferedImage.getColorModel().getPixelSize(); ByteBuffer byteBuffer; DataBuffer db = bufferedImage.getData().getDataBuffer(); if (db instanceof DataBufferInt) { int intI[] = ((DataBufferInt) (bufferedImage.getData().getDataBuffer())).getData(); byte newI[] = new byte[intI.length * 4]; for (int i = 0; i < intI.length; i++) { byte b[] = intToByteArray(intI[i]); int newIndex = i * 4; newI[newIndex] = b[1]; newI[newIndex + 1] = b[2]; newI[newIndex + 2] = b[3]; newI[newIndex + 3] = b[0]; } byteBuffer = ByteBuffer.allocateDirect(width * height * (bpp / 8)).order(ByteOrder.nativeOrder()) .put(newI); } else { byteBuffer = ByteBuffer.allocateDirect(width * height * (bpp / 8)).order(ByteOrder.nativeOrder()) .put(((DataBufferByte) (bufferedImage.getData().getDataBuffer())).getData()); } byteBuffer.flip(); int internalFormat = GL11.GL_RGBA8, format = GL11.GL_RGBA; IntBuffer textureId = BufferUtils.createIntBuffer(1); ; GL11.glGenTextures(textureId); GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureId.get(0)); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP); 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_LINEAR); GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_MODULATE); GLU.gluBuild2DMipmaps(GL11.GL_TEXTURE_2D, internalFormat, width, height, format, GL11.GL_UNSIGNED_BYTE, byteBuffer); return textureId.get(0); } catch (Exception e) { e.printStackTrace(); System.exit(-1); } return -1; }
From source file:com.dyonovan.tcnodetracker.lib.truetyper.TrueTypeFont.java
License:Open Source License
public static int loadImage(BufferedImage bufferedImage) { try {// www. j a va 2 s.c o m short width = (short) bufferedImage.getWidth(); short height = (short) bufferedImage.getHeight(); //textureLoader.bpp = bufferedImage.getColorModel().hasAlpha() ? (byte)32 : (byte)24; int bpp = (byte) bufferedImage.getColorModel().getPixelSize(); ByteBuffer byteBuffer; DataBuffer db = bufferedImage.getData().getDataBuffer(); if (db instanceof DataBufferInt) { int intI[] = ((DataBufferInt) (bufferedImage.getData().getDataBuffer())).getData(); byte newI[] = new byte[intI.length * 4]; for (int i = 0; i < intI.length; i++) { byte b[] = intToByteArray(intI[i]); int newIndex = i * 4; newI[newIndex] = b[1]; newI[newIndex + 1] = b[2]; newI[newIndex + 2] = b[3]; newI[newIndex + 3] = b[0]; } byteBuffer = ByteBuffer.allocateDirect(width * height * (bpp / 8)).order(ByteOrder.nativeOrder()) .put(newI); } else { byteBuffer = ByteBuffer.allocateDirect(width * height * (bpp / 8)).order(ByteOrder.nativeOrder()) .put(((DataBufferByte) (bufferedImage.getData().getDataBuffer())).getData()); } byteBuffer.flip(); int internalFormat = GL11.GL_RGBA8, format = GL11.GL_RGBA; IntBuffer textureId = BufferUtils.createIntBuffer(1); ; GL11.glGenTextures(textureId); GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureId.get(0)); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST); //GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); //GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR_MIPMAP_NEAREST); //GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR_MIPMAP_LINEAR); //GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST_MIPMAP_LINEAR); //GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST_MIPMAP_NEAREST); GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_MODULATE); GLU.gluBuild2DMipmaps(GL11.GL_TEXTURE_2D, internalFormat, width, height, format, GL11.GL_UNSIGNED_BYTE, byteBuffer); return textureId.get(0); } catch (Exception e) { e.printStackTrace(); System.exit(-1); } return -1; }
From source file:com.golemgame.properties.fengGUI.AppearanceDisplayer.java
License:Open Source License
private void drawScaledTintedImage(Graphics g, IOpenGL gl, ITexture texture, ColorRGBA color, int x, int y, int width, int height) { x += g.getTranslation().getX();//from w ww . j a v a 2s . co m y += g.getTranslation().getY(); gl.enableTexture2D(true); { //gl.setTexEnvModeModulate(); } colorBuffer.clear(); colorBuffer.put(color.r).put(color.g).put(color.b).put(color.a); colorBuffer.rewind(); texture.bind(); GL11.glTexEnv(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_COLOR, colorBuffer); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);//inform gl that no mipmaps are being used. // GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID); GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_BLEND); // GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, // GL11.GL_TEXTURE_ENV_MODE, GL11.GL_DECAL); gl.startQuads(); float startY = 0.0f; // top float startX = 0.0f; // left float endY = 1.0f; // bottom float endX = 1.0f; // right int rWidth = width; int rHeight = height; // fit into clip - both the polygon to render (x,y,x+w,y+h) AND the // texture (0,0->1,1) Rectangle clipSpace = g.getClipSpace(); if (x < clipSpace.getX()) { rWidth -= clipSpace.getX() - x; startX = (float) (clipSpace.getX() - x) / (float) width; x = clipSpace.getX(); } if (x + rWidth > clipSpace.getX() + clipSpace.getWidth()) { rWidth = clipSpace.getX() + clipSpace.getWidth() - x; endX = (float) rWidth / (float) width; } if (y < clipSpace.getY()) { rHeight -= clipSpace.getY() - y; endY = (float) rHeight / (float) height; y = clipSpace.getY(); } if (y + rHeight > clipSpace.getY() + clipSpace.getHeight()) { rHeight = clipSpace.getY() + clipSpace.getHeight() - y; startY = (float) (height - rHeight) / (float) height; } gl.texCoord(startX, endY); gl.vertex(x, y); gl.texCoord(startX, startY); gl.vertex(x, rHeight + y); gl.texCoord(endX, startY); gl.vertex(rWidth + x, rHeight + y); gl.texCoord(endX, endY); gl.vertex(rWidth + x, y); gl.end(); gl.enableTexture2D(false); }
From source file:com.owens.oobjloader.lwjgl.TextureLoader.java
License:BSD License
public int convertToTexture(BufferedImage img) { int[] pixels = new int[img.getWidth() * img.getHeight()]; PixelGrabber grabber = new PixelGrabber(img, 0, 0, img.getWidth(), img.getHeight(), pixels, 0, img.getWidth());//from w ww .ja v a2s .co m try { grabber.grabPixels(); } catch (InterruptedException e) { log.log(SEVERE, "InterruptedException while trying to grab pixels, e=" + e); e.printStackTrace(); return -1; } int bufLen = 0; bufLen = pixels.length * 4; ByteBuffer oglPixelBuf = BufferUtils.createByteBuffer(bufLen); for (int y = img.getHeight() - 1; y >= 0; y--) { for (int x = 0; x < img.getWidth(); x++) { int pixel = pixels[y * img.getWidth() + x]; oglPixelBuf.put((byte) ((pixel >> 16) & 0xFF)); oglPixelBuf.put((byte) ((pixel >> 8) & 0xFF)); oglPixelBuf.put((byte) ((pixel >> 0) & 0xFF)); oglPixelBuf.put((byte) ((pixel >> 24) & 0xFF)); } } oglPixelBuf.flip(); ByteBuffer temp = ByteBuffer.allocateDirect(4); temp.order(ByteOrder.nativeOrder()); IntBuffer textBuf = temp.asIntBuffer(); GL11.glGenTextures(textBuf); int textureID = textBuf.get(0); GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); 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); GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_MODULATE); GL11.glTexImage2D(GL11.GL_TEXTURE_2D, TEXTURE_LEVEL, GL11.GL_RGBA8, img.getWidth(), img.getHeight(), 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, oglPixelBuf); return textureID; }
From source file:espresso3d.engine.renderer.E3DGeometryRenderer.java
License:Open Source License
/*********************************/ public void setupTextureUnits(int glTextureID, int detail0TextureID, int detail1TextureID) { ARBMultitexture.glActiveTextureARB(ARBMultitexture.GL_TEXTURE0_ARB); if (glTextureID != -1) { GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glBindTexture(GL11.GL_TEXTURE_2D, glTextureID); /* if(detail0TextureID != -1) {//from ww w. j a va 2 s. com GL11.glTexEnvf (GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, ARBTextureEnvCombine.GL_COMBINE_ARB); GL11.glTexEnvf (GL11.GL_TEXTURE_ENV, ARBTextureEnvCombine.GL_COMBINE_RGB_ARB, GL11.GL_REPLACE); } else {*/ GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_MODULATE); // } } else GL11.glDisable(GL11.GL_TEXTURE_2D); if (getEngine().getFeatureChecker().getArbMultitextureNumTexUnitsSupported() < 2) return; ARBMultitexture.glActiveTextureARB(ARBMultitexture.GL_TEXTURE1_ARB); if (detail0TextureID != -1) { GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glBindTexture(GL11.GL_TEXTURE_2D, detail0TextureID); GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, ARBTextureEnvCombine.GL_COMBINE_ARB); GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, ARBTextureEnvCombine.GL_COMBINE_RGB_ARB, GL11.GL_ADD); } else GL11.glDisable(GL11.GL_TEXTURE_2D); if (getEngine().getFeatureChecker().getArbMultitextureNumTexUnitsSupported() < 3) return; ARBMultitexture.glActiveTextureARB(ARBMultitexture.GL_TEXTURE2_ARB); if (detail1TextureID != -1) { GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glBindTexture(GL11.GL_TEXTURE_2D, detail1TextureID); GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, ARBTextureEnvCombine.GL_COMBINE_ARB); GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, ARBTextureEnvCombine.GL_COMBINE_RGB_ARB, GL11.GL_ADD); } else GL11.glDisable(GL11.GL_TEXTURE_2D); }
From source file:espresso3d.engine.renderer.particle.E3DParticleRendererARBPointSprite.java
License:Open Source License
private void setupPointSpriteParameters(double spriteSize) { particleDistanceScalarBuffer.clear(); // particleDistanceScalarBuffer.put(0.0f);//1.0f); particleDistanceScalarBuffer.put(0.0f);//1.0f); particleDistanceScalarBuffer.put(0.0f); particleDistanceScalarBuffer.put((float) (1.0 / (getEngine().getCurrentViewport().getWidth() * getEngine().getCurrentViewport().getHeight())));//0.1f); particleDistanceScalarBuffer.rewind(); ARBPointParameters.glPointParameterARB(ARBPointParameters.GL_POINT_DISTANCE_ATTENUATION_ARB, particleDistanceScalarBuffer); ARBPointParameters.glPointParameterfARB(ARBPointParameters.GL_POINT_SIZE_MIN_ARB, 1f);//(float)particle.getSize());//1f ); ARBPointParameters.glPointParameterfARB(ARBPointParameters.GL_POINT_SIZE_MAX_ARB, maxPointSpriteSize); ARBPointParameters.glPointParameterfARB(ARBPointParameters.GL_POINT_FADE_THRESHOLD_SIZE_ARB, 100f); /* GL14.glPointParameter(GL14.GL_POINT_DISTANCE_ATTENUATION, particleDistanceScalarBuffer); GL14.glPointParameterf( GL14.GL_POINT_SIZE_MIN, 1f);//(float)particle.getSize());//1f ); GL14.glPointParameterf( GL14.GL_POINT_SIZE_MAX, maxPointSpriteSize); GL14.glPointParameterf(GL14.GL_POINT_FADE_THRESHOLD_SIZE, 100f); *///from ww w.j a v a2 s. c o m GL14.glPointParameterf(GL20.GL_POINT_SPRITE_COORD_ORIGIN, GL20.GL_LOWER_LEFT); GL11.glTexEnvf(ARBPointSprite.GL_POINT_SPRITE_ARB, ARBPointSprite.GL_COORD_REPLACE_ARB, GL11.GL_TRUE); // GL11.glTexEnvf( GL20.GL_POINT_SPRITE, GL20.GL_COORD_REPLACE, GL11.GL_TRUE ); GL11.glPointSize((float) spriteSize); //POINT_SIZE_WORLD_COORD_SCALAR); }
From source file:fr.def.iss.vd2.lib_v3d.element.V3DSprite.java
License:Open Source License
@Override protected void doDisplay(V3DCamera camera) { if (!enableColor) { GL11.glPushAttrib(GL11.GL_CURRENT_BIT); GL11.glColor4f(1, 1, 1, opacity); }/*from w w w . ja va 2s . c om*/ GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_MODULATE); GL11.glAlphaFunc(GL11.GL_GREATER, 0.1f); GL11.glEnable(GL11.GL_ALPHA_TEST); if (disableRotation) { camera.disableRotation(); } float w = 0.5f * size.x * image.getWidth(); float h = 0.5f * size.y * image.getHeight(); GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture.getID()); GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(0.0f, 0.0f); GL11.glVertex3f(-w, -h, 0.0f); GL11.glTexCoord2f(1.0f, 0.0f); GL11.glVertex3f(w, -h, 0.0f); GL11.glTexCoord2f(1.0f, 1.0f); GL11.glVertex3f(w, h, 0.0f); GL11.glTexCoord2f(0.0f, 1.0f); GL11.glVertex3f(-w, h, 0.0f); GL11.glEnd(); if (disableRotation) { camera.enableRotation(); } GL11.glDisable(GL11.GL_ALPHA_TEST); GL11.glDisable(GL11.GL_TEXTURE_2D); if (!enableColor) { GL11.glPopAttrib(); } }