List of usage examples for org.lwjgl.opengl GL11 GL_BYTE
int GL_BYTE
To view the source code for org.lwjgl.opengl GL11 GL_BYTE.
Click Source Link
From source file:com.ardor3d.scene.state.lwjgl.shader.LwjglShaderUtil.java
License:Open Source License
private static void updateShaderAttribute(final ShaderVariablePointerByte variable, final ShaderObjectsStateRecord record, final boolean useVBO) { enableVertexAttribute(variable, record); if (useVBO) { final RenderContext context = ContextManager.getCurrentContext(); final int vboId = LwjglRenderer.setupVBO(variable.data, context); LwjglRendererUtil.setBoundVBO(context.getRendererRecord(), vboId); ARBVertexProgram.glVertexAttribPointerARB(variable.variableID, variable.size, variable.unsigned ? GL11.GL_UNSIGNED_BYTE : GL11.GL_BYTE, variable.normalized, variable.stride, 0);/*from www . j a va 2s.c o m*/ } else { variable.data.getBuffer().rewind(); ARBVertexProgram.glVertexAttribPointerARB(variable.variableID, variable.size, variable.unsigned, variable.normalized, variable.stride, variable.data.getBuffer()); } }
From source file:com.ardor3d.scene.state.lwjgl.util.LwjglTextureUtil.java
License:Open Source License
public static int getGLPixelDataType(final PixelDataType type) { switch (type) { case Byte: return GL11.GL_BYTE; case Float: return GL11.GL_FLOAT; case HalfFloat: return ARBHalfFloatPixel.GL_HALF_FLOAT_ARB; case Short: return GL11.GL_SHORT; case UnsignedShort: return GL11.GL_UNSIGNED_SHORT; case Int:/*from w w w . j a v a2 s . c om*/ return GL11.GL_INT; case UnsignedInt: return GL11.GL_UNSIGNED_INT; case UnsignedByte: return GL11.GL_UNSIGNED_BYTE; case UnsignedByte_3_3_2: return GL12.GL_UNSIGNED_BYTE_3_3_2; case UnsignedByte_2_3_3_Rev: return GL12.GL_UNSIGNED_BYTE_2_3_3_REV; case UnsignedShort_5_6_5: return GL12.GL_UNSIGNED_SHORT_5_6_5; case UnsignedShort_5_6_5_Rev: return GL12.GL_UNSIGNED_SHORT_5_6_5_REV; case UnsignedShort_4_4_4_4: return GL12.GL_UNSIGNED_SHORT_4_4_4_4; case UnsignedShort_4_4_4_4_Rev: return GL12.GL_UNSIGNED_SHORT_4_4_4_4_REV; case UnsignedShort_5_5_5_1: return GL12.GL_UNSIGNED_SHORT_5_5_5_1; case UnsignedShort_1_5_5_5_Rev: return GL12.GL_UNSIGNED_SHORT_1_5_5_5_REV; case UnsignedInt_8_8_8_8: return GL12.GL_UNSIGNED_INT_8_8_8_8; case UnsignedInt_8_8_8_8_Rev: return GL12.GL_UNSIGNED_INT_8_8_8_8_REV; case UnsignedInt_10_10_10_2: return GL12.GL_UNSIGNED_INT_10_10_10_2; case UnsignedInt_2_10_10_10_Rev: return GL12.GL_UNSIGNED_INT_2_10_10_10_REV; default: throw new Error("Unhandled type: " + type); } }
From source file:com.badlogic.gdx.backends.lwjgl.LwjglGL10.java
License:Apache License
public final void glNormalPointer(int type, int stride, Buffer pointer) { if (pointer instanceof FloatBuffer && type == GL11.GL_FLOAT) GL11.glNormalPointer(stride, (FloatBuffer) pointer); else if (pointer instanceof ByteBuffer && type == GL11.GL_FLOAT) GL11.glNormalPointer(stride, ((ByteBuffer) pointer).asFloatBuffer()); else if (pointer instanceof ByteBuffer && type == GL11.GL_BYTE) GL11.glNormalPointer(stride, (ByteBuffer) pointer); else// w w w . j a v a2 s . co m throw new GdxRuntimeException("Can't use " + pointer.getClass().getName() + " with this method. GL10.GL_SHORT not supported. Use FloatBuffer instead. Blame LWJGL"); }
From source file:com.foudroyantfactotum.mod.fousarchive.midi.generation.MidiTexture.java
License:Open Source License
@Override public void loadTexture(IResourceManager resourceManager) throws IOException { final int xSize = getSmallTextureSize(); final int ySize = 88; byte[] res = null; try (final InputStream io = resourceManager.getResource(rl).getInputStream()) { res = getMidiTrack(io, xSize, ySize); } catch (InvalidMidiDataException e) { e.printStackTrace();//from w ww . jav a 2 s . c o m } if (res != null) { this.deleteGlTexture(); GlStateManager.bindTexture(this.getGlTextureId()); final ByteBuffer bb = (ByteBuffer) BufferUtils.createByteBuffer(res.length).put(res).flip(); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MAX_LEVEL, 0); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MIN_LOD, 0.0f); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MAX_LOD, 0.0f); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL14.GL_TEXTURE_LOD_BIAS, 0.0f); GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGB, xSize, ySize, 0, GL11.GL_RGB, GL11.GL_BYTE, bb); } }
From source file:fr.ign.cogit.geoxygene.appli.gl.RasterImage.java
License:Open Source License
/** * read a raster Image/*from w w w . j av a 2s .c o m*/ * * @param image * @param symbolizer */ public void readImage(GridCoverage2D image, RasterSymbolizer symbolizer) { System.out.println("READING THE RASTER"); // To avoid multiple read if ((isRead == false) || (symbolizer.getChannelSelection() != null)) // &&(imageFilename // != // null)) { // Declaration and initialization // Set width, height, nbBands and compute size width = image.getRenderedImage().getWidth(); height = image.getRenderedImage().getHeight(); nbBands = image.getNumSampleDimensions(); // size of the input image !! size = width * height * nbBands; // Determine data type of image imageDataType = image.getSampleDimension(0).getSampleDimensionType().name(); // Channel Selection // TODO : VALIDATION of channel selection from symbolizer selectBands(image, symbolizer); // Determine the format format = generateFormatFromNbBandSelected(); // Determine the data type GLinternalDataType = generateGLinternalDataTypeFromImageDataType(); // Automatically detect the best GLinternalFormat GLinternalFormat = generateOptimalGLinternalFormat(); // Buffer allocation and acquisition // INFO : bufferImage.order(ByteOrder.nativeOrder()); // to adjust // the ByteBuffer instance's endianness to match the current // platform. if ((GLinternalDataType == GL11.GL_BYTE) || (GLinternalDataType == GL11.GL_UNSIGNED_BYTE)) { byte[] byteData = ((DataBufferByte) image.getRenderedImage().getData().getDataBuffer()).getData(); bufferImage = ByteBuffer.allocateDirect(byteData.length); bufferImage.order(ByteOrder.nativeOrder()); bufferImage.put(ByteBuffer.wrap(byteData)); } else if ((GLinternalDataType == GL11.GL_SHORT) || (GLinternalDataType == GL11.GL_UNSIGNED_SHORT)) { short[] shortData = ((DataBufferShort) image.getRenderedImage().getData().getDataBuffer()) .getData(); bufferImage = ByteBuffer.allocateDirect(shortData.length * 2); bufferImage.order(ByteOrder.nativeOrder()); bufferImage.asShortBuffer().put(ShortBuffer.wrap(shortData)); } else if ((GLinternalDataType == GL11.GL_INT) || (GLinternalDataType == GL11.GL_UNSIGNED_INT)) { int[] intData = ((DataBufferInt) image.getRenderedImage().getData().getDataBuffer()).getData(); bufferImage = ByteBuffer.allocateDirect(intData.length * 4); bufferImage.order(ByteOrder.nativeOrder()); bufferImage.asIntBuffer().put(IntBuffer.wrap(intData)); } else if (GLinternalDataType == GL11.GL_FLOAT) { float[] floatData = ((DataBufferFloat) image.getRenderedImage().getData().getDataBuffer()) .getData(); bufferImage = ByteBuffer.allocateDirect(floatData.length * 4); bufferImage.order(ByteOrder.nativeOrder()); bufferImage.asFloatBuffer().put(FloatBuffer.wrap(floatData)); } else if (GLinternalDataType == GL11.GL_DOUBLE) { double[] doubleData = ((DataBufferDouble) image.getRenderedImage().getData().getDataBuffer()) .getData(); bufferImage = ByteBuffer.allocateDirect(doubleData.length * 8); bufferImage.order(ByteOrder.nativeOrder()); bufferImage.asDoubleBuffer().put(DoubleBuffer.wrap(doubleData)); } else { System.err.println("This type of data : " + GLinternalDataType + "is not recognized."); } // Rewind the buffer, not very with our way-to-put but why not bufferImage.rewind(); // Now, bufferImage is ok, reading is complete isRead = true; // TEMP ?? animation animate = symbolizer.getAnimate(); } }
From source file:fr.ign.cogit.geoxygene.appli.gl.RasterImage.java
License:Open Source License
private int generateGLinternalDataTypeFromImageDataType() { if (imageDataType == "REAL_32BITS") { return GL11.GL_FLOAT; } else if (imageDataType == "REAL_64BITS") { return GL11.GL_DOUBLE; } else if (imageDataType == "SIGNED_8BITS") { return GL11.GL_BYTE; } else if (imageDataType == "SIGNED_16BITS") { return GL11.GL_SHORT; } else if (imageDataType == "SIGNED_32BITS") { return GL11.GL_INT; } else if (imageDataType == "UNSIGNED_1BIT") { System.err.println("This type of data : " + imageDataType + "is not implemented."); return -1; /* not done */ } else if (imageDataType == "UNSIGNED_2BITS") { System.err.println("This type of data : " + imageDataType + "is not implemented."); return -1; /* not done */ } else if (imageDataType == "UNSIGNED_4BITS") { System.err.println("This type of data : " + imageDataType + "is not implemented."); return -1; /* not done */ } else if (imageDataType == "UNSIGNED_8BITS") { return GL11.GL_UNSIGNED_BYTE; } else if (imageDataType == "UNSIGNED_16BITS") { return GL11.GL_UNSIGNED_SHORT; } else if (imageDataType == "UNSIGNED_32BITS") { return GL11.GL_UNSIGNED_INT; } else {/* w w w .j a v a 2 s .c o m*/ System.err.println("This type of data : " + imageDataType + "is not recognized."); return -1; } }
From source file:fr.ign.cogit.geoxygene.appli.gl.RasterImage.java
License:Open Source License
private int generateOptimalGLinternalFormat() { if (defColormap) { // With a colormap, we must keep pixel information in the shader, // only solution, give float to shader if (nbBandsSelected == 1) return GL30.GL_R32F; else if (nbBandsSelected == 2) return GL30.GL_RG32F; else if (nbBandsSelected == 3) return GL30.GL_RGB32F; else// w w w.j av a 2 s . c om return GL30.GL_RGBA32F; } else if (GLinternalDataType == GL11.GL_BYTE) { if (nbBandsSelected == 1) return GL30.GL_R8; else if (nbBandsSelected == 2) return GL30.GL_RG8; else if (nbBandsSelected == 3) return GL11.GL_RGB8; else return GL11.GL_RGBA8; } else if (GLinternalDataType == GL11.GL_SHORT) { if (nbBandsSelected == 1) return GL30.GL_R16; else if (nbBandsSelected == 2) return GL30.GL_RG16; else if (nbBandsSelected == 3) return GL11.GL_RGB16; else return GL11.GL_RGBA16; } else if (GLinternalDataType == GL11.GL_INT) { if (nbBandsSelected == 1) return GL30.GL_R32I; else if (nbBandsSelected == 2) return GL30.GL_RG32I; else if (nbBandsSelected == 3) return GL30.GL_RGB32I; else return GL30.GL_RGBA32I; } else if (GLinternalDataType == GL11.GL_FLOAT) { if (nbBandsSelected == 1) return GL30.GL_R32F; else if (nbBandsSelected == 2) return GL30.GL_RG32F; else if (nbBandsSelected == 3) return GL30.GL_RGB32F; else return GL30.GL_RGBA32F; } else if (GLinternalDataType == GL11.GL_DOUBLE) { // TODO : check that if (nbBandsSelected == 1) return GL30.GL_R32F; else if (nbBandsSelected == 2) return GL30.GL_RG32F; else if (nbBandsSelected == 3) return GL30.GL_RGB32F; else return GL30.GL_RGBA32F; } else if (GLinternalDataType == GL11.GL_UNSIGNED_BYTE) { // TODO check that too if (nbBandsSelected == 1) return GL30.GL_R8; else if (nbBandsSelected == 2) return GL30.GL_RG8; else if (nbBandsSelected == 3) return GL11.GL_RGB8; else return GL11.GL_RGBA8; } else if (GLinternalDataType == GL11.GL_UNSIGNED_SHORT) { if (nbBandsSelected == 1) return GL30.GL_R16; else if (nbBandsSelected == 2) return GL30.GL_RG16; else if (nbBandsSelected == 3) return GL11.GL_RGB16; else return GL11.GL_RGBA16; } else if (GLinternalDataType == GL11.GL_UNSIGNED_INT) { if (nbBandsSelected == 1) return GL30.GL_R32UI; else if (nbBandsSelected == 2) return GL30.GL_RG32UI; else if (nbBandsSelected == 3) return GL30.GL_RGB32UI; else return GL30.GL_RGBA32UI; } else { System.err.println("generateOptimalGLinternalFormat() failed to find the correct format"); return -1; // nothing to do here with that } }
From source file:loon.core.graphics.opengl.LWjglGL10.java
License:Apache License
public final void glNormalPointer(int type, int stride, Buffer pointer) { if (pointer instanceof FloatBuffer && type == GL11.GL_FLOAT) { GL11.glNormalPointer(stride, (FloatBuffer) pointer); } else if (pointer instanceof ByteBuffer && type == GL11.GL_FLOAT) { GL11.glNormalPointer(stride, ((ByteBuffer) pointer).asFloatBuffer()); } else if (pointer instanceof ByteBuffer && type == GL11.GL_BYTE) { GL11.glNormalPointer(stride, (ByteBuffer) pointer); } else {/*from ww w .j ava 2s . c om*/ throw new RuntimeException("Can't use " + pointer.getClass().getName() + " with this method. GL10.GL_SHORT not supported. Use FloatBuffer instead. Blame LWJGL"); } }
From source file:net.minecraft.src.PaintWorld.java
License:Open Source License
public void getTextureForFace(int face) { PaintFace pface = renderBlock.paintedFaces[face]; if (textureBuffer == null) { textureBuffer = ByteBuffer.allocateDirect(ARRAY_SIZE); textureBuffer.order(ByteOrder.nativeOrder()); }/* w w w . ja v a 2 s . com*/ if (textureId <= 0) { textureId = GL11.glGenTextures(); GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureId); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); } GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureId); textureBuffer.clear(); textureBuffer.put(pface.points); textureBuffer.flip(); GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, ROW, ROW, 0, GL11.GL_RGBA, GL11.GL_BYTE, textureBuffer); }
From source file:org.spout.engine.renderer.vertexbuffer.VertexBufferImplByte.java
License:Open Source License
public void bind() { if (vboId == -1) throw new IllegalStateException("Cannot bind a vertex buffer without data!"); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vboId); GL20.glVertexAttribPointer(getLayout(), getElements(), GL11.GL_BYTE, false, 0, 0); }