List of usage examples for com.badlogic.gdx Gdx gl30
GL30 gl30
To view the source code for com.badlogic.gdx Gdx gl30.
Click Source Link
From source file:com.cyphercove.doublehelix.points.BillboardDecalBatch.java
License:Apache License
public void initialize(int size) { vertices = new float[size * BillboardDecal.VERTEX_SIZE]; Mesh.VertexDataType vertexDataType = Mesh.VertexDataType.VertexArray; if (Gdx.gl30 != null) { vertexDataType = Mesh.VertexDataType.VertexBufferObjectWithVAO; }//from ww w . j a v a 2 s .c om mesh = new Mesh(vertexDataType, false, size, 0, new VertexAttribute(VertexAttributes.Usage.Position, 3, ShaderProgram.POSITION_ATTRIBUTE), new VertexAttribute(VertexAttributes.Usage.ColorPacked, 4, ShaderProgram.COLOR_ATTRIBUTE), new VertexAttribute(VertexAttributes.Usage.Generic, 1, SIZE_ATTRIBUTE), new VertexAttribute(VertexAttributes.Usage.Generic, 1, ROTATION_ATTRIBUTE)); }
From source file:com.esotericsoftware.spine.utils.TwoColorPolygonBatch.java
License:Open Source License
public TwoColorPolygonBatch(int maxVertices, int maxTriangles) { // 32767 is max vertex index. if (maxVertices > 32767) throw new IllegalArgumentException("Can't have more than 32767 vertices per batch: " + maxTriangles); Mesh.VertexDataType vertexDataType = Mesh.VertexDataType.VertexArray; if (Gdx.gl30 != null) vertexDataType = VertexDataType.VertexBufferObjectWithVAO; mesh = new Mesh(vertexDataType, false, maxVertices, maxTriangles * 3, // new VertexAttribute(Usage.Position, 2, "a_position"), // new VertexAttribute(Usage.ColorPacked, 4, "a_light"), // new VertexAttribute(Usage.ColorPacked, 4, "a_dark"), // Dark alpha is unused, but colors are packed as 4 byte floats. new VertexAttribute(Usage.TextureCoordinates, 2, "a_texCoord0")); vertices = new float[maxVertices * 6]; triangles = new short[maxTriangles * 3]; defaultShader = createDefaultShader(); shader = defaultShader;/*w ww . j a v a 2s . c om*/ projectionMatrix.setToOrtho2D(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); }
From source file:de.fatox.meta.graphics.buffer.MultisampleFBO.java
License:Apache License
/** Convenience method to return the first Texture attachment present in the fbo **/ public Texture getColorBufferTexture() { if (nonMultisampledFbo == null) { // TODO fix return null; }//from w w w . j av a 2 s.c o m Gdx.gl30.glBindFramebuffer(GL30.GL_READ_FRAMEBUFFER, framebufferHandle); Gdx.gl30.glBindFramebuffer(GL30.GL_DRAW_FRAMEBUFFER, nonMultisampledFbo.getFramebufferHandle()); Gdx.gl30.glBlitFramebuffer(0, 0, getWidth(), getHeight(), 0, 0, getWidth(), getHeight(), GL30.GL_COLOR_BUFFER_BIT, GL30.GL_NEAREST); Gdx.gl30.glBindFramebuffer(GL30.GL_DRAW_FRAMEBUFFER, 0); Gdx.gl30.glBindFramebuffer(GL30.GL_READ_FRAMEBUFFER, 0); FrameBuffer.unbind(); return nonMultisampledFbo.getColorBufferTexture(); }
From source file:de.fatox.meta.graphics.buffer.MultisampleFBO.java
License:Apache License
/** Return the Texture attachments attached to the fbo **/ public Array<Texture> getTextureAttachments() { checkError(Gdx.gl.glGetError());//from w ww . ja v a2 s. c o m FrameBuffer.unbind(); Gdx.gl30.glBindFramebuffer(GL30.GL_READ_FRAMEBUFFER, framebufferHandle); Gdx.gl30.glBindFramebuffer(GL30.GL_DRAW_FRAMEBUFFER, nonMultisampledFbo.getFramebufferHandle()); IntBuffer intBuffer = BufferUtils.newIntBuffer(1); for (int i = 0; i < textureAttachments; i++) { if (i == textureAttachments - 1 && textureAttachments > 1) { Gdx.gl30.glReadBuffer(GL30.GL_NONE); intBuffer.put(GL30.GL_NONE); checkError(Gdx.gl.glGetError()); } else { Gdx.gl30.glReadBuffer(GL30.GL_COLOR_ATTACHMENT0 + i); intBuffer.put(GL30.GL_COLOR_ATTACHMENT0 + i); } intBuffer.rewind(); Gdx.gl30.glDrawBuffers(1, intBuffer); if (i == textureAttachments - 1 && textureAttachments > 1) { Gdx.gl30.glBlitFramebuffer(0, 0, getWidth(), getHeight(), 0, 0, getWidth(), getHeight(), GL30.GL_DEPTH_BUFFER_BIT, GL30.GL_NEAREST); } else { Gdx.gl30.glBlitFramebuffer(0, 0, getWidth(), getHeight(), 0, 0, getWidth(), getHeight(), GL30.GL_COLOR_BUFFER_BIT, GL30.GL_NEAREST); } } FrameBuffer.unbind(); return nonMultisampledFbo.getTextureAttachments(); }
From source file:de.fatox.meta.graphics.buffer.MultisampleFBO.java
License:Apache License
protected void build() { GL20 gl = Gdx.gl20;//from www . j av a 2 s . c o m checkValidBuilder(); // iOS uses a different framebuffer handle! (not necessarily 0) if (!defaultFramebufferHandleInitialized) { defaultFramebufferHandleInitialized = true; if (Gdx.app.getType() == ApplicationType.iOS) { IntBuffer intbuf = ByteBuffer.allocateDirect(16 * Integer.SIZE / 8).order(ByteOrder.nativeOrder()) .asIntBuffer(); gl.glGetIntegerv(GL20.GL_FRAMEBUFFER_BINDING, intbuf); defaultFramebufferHandle = intbuf.get(0); } else { defaultFramebufferHandle = 0; } } framebufferHandle = gl.glGenFramebuffer(); gl.glBindFramebuffer(GL20.GL_FRAMEBUFFER, framebufferHandle); GLFrameBuffer.FrameBufferBuilder imBuilder = new GLFrameBuffer.FrameBufferBuilder(getWidth(), getHeight()); int width = bufferBuilder.width; int height = bufferBuilder.height; if (bufferBuilder.hasDepthRenderBuffer) { depthbufferHandle = gl.glGenRenderbuffer(); gl.glBindRenderbuffer(GL20.GL_RENDERBUFFER, depthbufferHandle); Gdx.gl30.glRenderbufferStorageMultisample(GL20.GL_RENDERBUFFER, 4, bufferBuilder.depthRenderBufferSpec.internalFormat, width, height); } if (bufferBuilder.hasStencilRenderBuffer) { stencilbufferHandle = gl.glGenRenderbuffer(); gl.glBindRenderbuffer(GL20.GL_RENDERBUFFER, stencilbufferHandle); Gdx.gl30.glRenderbufferStorageMultisample(GL20.GL_RENDERBUFFER, 4, bufferBuilder.stencilRenderBufferSpec.internalFormat, width, height); } if (bufferBuilder.hasPackedStencilDepthRenderBuffer) { depthStencilPackedBufferHandle = gl.glGenRenderbuffer(); gl.glBindRenderbuffer(GL20.GL_RENDERBUFFER, depthStencilPackedBufferHandle); Gdx.gl30.glRenderbufferStorageMultisample(GL20.GL_RENDERBUFFER, 4, bufferBuilder.packedStencilDepthRenderBufferSpec.internalFormat, width, height); } isMRT = bufferBuilder.textureAttachmentSpecs.size > 1; isMRT = true; int colorTextureCounter = 0; if (isMRT) { for (FrameBufferTextureAttachmentSpec attachmentSpec : bufferBuilder.textureAttachmentSpecs) { int texture = createTexture(attachmentSpec); textureAttachments++; if (attachmentSpec.isColorTexture()) { gl.glFramebufferTexture2D(GL20.GL_FRAMEBUFFER, GL30.GL_COLOR_ATTACHMENT0 + colorTextureCounter, GL32.GL_TEXTURE_2D_MULTISAMPLE, texture, 0); imBuilder.addColorTextureAttachment(GL30.GL_RGBA8, GL30.GL_RGBA, GL30.GL_UNSIGNED_BYTE); colorTextureCounter++; } else if (attachmentSpec.isDepth) { gl.glFramebufferTexture2D(GL20.GL_FRAMEBUFFER, GL20.GL_DEPTH_ATTACHMENT, GL30.GL_TEXTURE_2D, texture, 0); imBuilder.addDepthTextureAttachment(GL30.GL_DEPTH_COMPONENT32F, GL30.GL_FLOAT); } else if (attachmentSpec.isStencil) { gl.glFramebufferTexture2D(GL20.GL_FRAMEBUFFER, GL20.GL_STENCIL_ATTACHMENT, gl.GL_TEXTURE_2D, texture, 0); } } } else { int texture = createTexture(bufferBuilder.textureAttachmentSpecs.first()); textureAttachments = 1; imBuilder.addColorTextureAttachment(GL30.GL_RGBA8, GL30.GL_RGBA, GL30.GL_UNSIGNED_BYTE); gl.glBindTexture(GL32.GL_TEXTURE_2D_MULTISAMPLE, texture); Gdx.gl30.glFramebufferTexture2D(GL20.GL_FRAMEBUFFER, GL20.GL_COLOR_ATTACHMENT0, GL32.GL_TEXTURE_2D_MULTISAMPLE, texture, 0); } if (isMRT) { IntBuffer buffer = BufferUtils.newIntBuffer(colorTextureCounter); for (int i = 0; i < colorTextureCounter; i++) { buffer.put(GL30.GL_COLOR_ATTACHMENT0 + i); } buffer.position(0); Gdx.gl30.glDrawBuffers(colorTextureCounter, buffer); } if (bufferBuilder.hasDepthRenderBuffer) { gl.glFramebufferRenderbuffer(GL20.GL_FRAMEBUFFER, GL20.GL_DEPTH_ATTACHMENT, GL20.GL_RENDERBUFFER, depthbufferHandle); } if (bufferBuilder.hasStencilRenderBuffer) { gl.glFramebufferRenderbuffer(GL20.GL_FRAMEBUFFER, GL20.GL_STENCIL_ATTACHMENT, GL20.GL_RENDERBUFFER, stencilbufferHandle); } if (bufferBuilder.hasPackedStencilDepthRenderBuffer) { gl.glFramebufferRenderbuffer(GL20.GL_FRAMEBUFFER, GL30.GL_DEPTH_STENCIL_ATTACHMENT, GL20.GL_RENDERBUFFER, depthStencilPackedBufferHandle); } gl.glBindRenderbuffer(GL20.GL_RENDERBUFFER, 0); gl.glBindTexture(GL32.GL_TEXTURE_2D_MULTISAMPLE, 0); assertShit(); gl.glBindFramebuffer(GL20.GL_FRAMEBUFFER, defaultFramebufferHandle); addManagedFrameBuffer(Gdx.app, this); nonMultisampledFbo = imBuilder.build(); }
From source file:org.ams.prettypaint.PrettyPolygonBatch.java
License:Open Source License
/** * For every frame: call one of the begin methods, then pass this batch to a {@link PrettyPolygon}s draw method. After you have done * that with all your Polygons you call {@link #end()}; *///from w ww.j a v a 2 s . c o m public PrettyPolygonBatch() { debugRenderer = new DebugRenderer() { @Override void draw(ShapeRenderer shapeRenderer) { drawFrustum(shapeRenderer, debugColors.first().color); } @Override void update() { super.update(); boolean enabled = drawFrustum; boolean change = enabled != this.enabled; if (!change) return; this.enabled = enabled; debugColors.clear(); if (drawFrustum) { debugColors.add(new DebugColor(Color.CYAN, "Frustum")); } if (!enabled) { debugRendererArray.removeValue(this, true); } } }; shaderProgram = new ShaderProgram(Shader.vertexShader, Shader.fragmentShader); if (!shaderProgram.isCompiled()) Gdx.app.log("PrettyPolygonBatch", "PrettyPolygonBatch shader-program not compiled!"); Mesh.VertexDataType vertexDataType = Mesh.VertexDataType.VertexBufferObject; if (Gdx.gl30 != null) { vertexDataType = Mesh.VertexDataType.VertexBufferObjectWithVAO; } mesh = new Mesh(vertexDataType, true, maxData, 0, Shader.Attribute.position.vertexAttribute, // position of vertex Shader.Attribute.colorOrJustOpacity.vertexAttribute, // are packed into one float Shader.Attribute.positionInRegion.vertexAttribute, // texture translation, alpha values Shader.Attribute.regionPositionOrBoldness.vertexAttribute, // bottom left of textureRegionName in texture, alpha values Shader.Attribute.regionSizeAndShaderChooser.vertexAttribute // size of textureRegionName(region must be square), alpha value. (<-0.5 when outline) ); }