List of usage examples for org.lwjgl.opengl GL20 glGetProgrami
@NativeType("void") public static int glGetProgrami(@NativeType("GLuint") int program, @NativeType("GLenum") int pname)
From source file:me.thehutch.fusion.engine.render.opengl.gl20.OpenGL20Program.java
License:Open Source License
@Override public void link() { ensureCreated("Program must be created to link."); // Link the program GL20.glLinkProgram(id);//ww w . jav a 2 s. c o m // Check program link success if (GL20.glGetProgrami(id, GL_LINK_STATUS) == GL_FALSE) { final int logLength = GL20.glGetProgrami(id, GL_INFO_LOG_LENGTH); throw new IllegalStateException( "Program could not be linked\n" + GL20.glGetProgramInfoLog(id, logLength)); } // Check for errors RenderUtil.checkGLError(); // Validate the program GL20.glValidateProgram(id); // Check program validation success if (GL20.glGetProgrami(id, GL_VALIDATE_STATUS) == GL_FALSE) { final int logLength = GL20.glGetProgrami(id, GL_INFO_LOG_LENGTH); System.err.println("Program validation failed:\n" + GL20.glGetProgramInfoLog(id, logLength)); } // Check for errors RenderUtil.checkGLError(); /* * Load the program uniforms */ // Get the maximum uniform name length final int maxNameLength = GL20.glGetProgrami(id, GL_ACTIVE_UNIFORM_MAX_LENGTH); // Create a buffer to store the name of the uniform final ByteBuffer nameBuffer = BufferUtils.createByteBuffer(maxNameLength); // Create a buffer to store the length of the uniform name final IntBuffer lengthBuffer = BufferUtils.createIntBuffer(1); // Create a buffer to store the uniform size final IntBuffer sizeBuffer = BufferUtils.createIntBuffer(1); // Create a buffer to stroe the uniform type final IntBuffer typeBuffer = BufferUtils.createIntBuffer(1); // Create a byte array to store the name in final byte[] nameBytes = new byte[maxNameLength]; int textureUnit = 0; final int uniformCount = GL20.glGetProgrami(id, GL_ACTIVE_UNIFORMS); for (int i = 0; i < uniformCount; ++i) { // Retrieve the attributes of the uniform (length, size, type and name) GL20.glGetActiveUniform(id, i, lengthBuffer, sizeBuffer, typeBuffer, nameBuffer); // Get the length of the uniform name final int length = lengthBuffer.get(); // Get the name from the buffer and put it in the byte[] nameBuffer.get(nameBytes, 0, length); final String name = new String(nameBytes, 0, length); // Convert the name buffer to a String this.uniforms.put(name, GL20.glGetUniformLocation(id, name)); // Check if the uniform is a texture/sampler switch (typeBuffer.get()) { case GL_SAMPLER_2D: case GL_SAMPLER_CUBE: this.textures.put(textureUnit++, name); break; default: break; } // Clear the buffers lengthBuffer.clear(); sizeBuffer.clear(); typeBuffer.clear(); nameBuffer.clear(); } // Check for errors RenderUtil.checkGLError(); }
From source file:net.smert.frameworkgl.opengl.helpers.ShaderHelper.java
License:Apache License
public boolean getLinkStatus(int programID) { return GL20.glGetProgrami(programID, GL20.GL_LINK_STATUS) != GL11.GL_FALSE; }
From source file:net.smert.frameworkgl.opengl.helpers.ShaderHelper.java
License:Apache License
public boolean getValidateStatus(int programID) { return GL20.glGetProgrami(programID, GL20.GL_VALIDATE_STATUS) != GL11.GL_FALSE; }
From source file:opengl.test.object.object.java
protected final void link() { GL20.glLinkProgram(programID);/* w w w.j av a 2 s. co m*/ if (GL20.glGetProgrami(programID, GL20.GL_LINK_STATUS) != GL11.GL_TRUE) { throw new RuntimeException("Khong the link program"); } }
From source file:opengl.test.object.tree.testobject.leaf.java
private void link() { GL20.glLinkProgram(programID);/*from w w w . jav a2s .c o m*/ if (GL20.glGetProgrami(programID, GL20.GL_LINK_STATUS) != GL11.GL_TRUE) { throw new RuntimeException("Khong the link program"); } }
From source file:org.jogamp.glg2d.impl.shader.AbstractShaderPipeline.java
License:Apache License
protected void checkProgramThrowException(int programId, int statusFlag) { int result = GL20.glGetProgrami(programId, statusFlag); if (result == GL11.GL_TRUE) { return;//from w w w .ja va 2s . c o m } int loglen = GL20.glGetShaderi(programId, GL20.GL_INFO_LOG_LENGTH); String error = GL20.glGetShaderInfoLog(programId, loglen); throw new ShaderException(error); }
From source file:org.spout.renderer.lwjgl.gl20.GL20Program.java
License:Open Source License
@Override public void link() { checkCreated();//from w w w.jav a2 s.c o m // Add the attribute layouts to the program state final TObjectIntIterator<String> iterator = attributeLayouts.iterator(); while (iterator.hasNext()) { iterator.advance(); // Bind the index to the name GL20.glBindAttribLocation(id, iterator.value(), iterator.key()); } // Link program GL20.glLinkProgram(id); // Check program link status if (GL20.glGetProgrami(id, GL20.GL_LINK_STATUS) == GL11.GL_FALSE) { throw new IllegalStateException("Program could not be linked\n" + GL20.glGetProgramInfoLog(id, 1000)); } if (CausticUtil.isDebugEnabled()) { // Validate program GL20.glValidateProgram(id); // Check program validation status if (GL20.glGetProgrami(id, GL20.GL_VALIDATE_STATUS) == GL11.GL_FALSE) { final Logger logger = CausticUtil.getCausticLogger(); logger.log(Level.WARNING, "Program validation failed. This doesn''t mean it won''t work, so you maybe able to ignore it\n{0}", GL20.glGetProgramInfoLog(id, 1000)); } } // Load uniforms uniforms.clear(); final int uniformCount = GL20.glGetProgrami(id, GL20.GL_ACTIVE_UNIFORMS); for (int i = 0; i < uniformCount; i++) { final ByteBuffer nameBuffer = CausticUtil.createByteBuffer(256); GL20.glGetActiveUniform(id, i, CausticUtil.createIntBuffer(1), CausticUtil.createIntBuffer(1), CausticUtil.createIntBuffer(1), nameBuffer); nameBuffer.rewind(); final byte[] nameBytes = new byte[256]; nameBuffer.get(nameBytes); // Simplify array names final String name = new String(nameBytes).trim().replaceFirst("\\[\\d+\\]", ""); uniforms.put(name, GL20.glGetUniformLocation(id, name)); } // Check for errors LWJGLUtil.checkForGLError(); }
From source file:ovh.tgrhavoc.gameengine.core.Shader.java
License:Open Source License
public void compileShader() { GL20.glLinkProgram(pointer);/*from w w w .ja v a 2 s.c o m*/ if (GL20.glGetProgrami(pointer, GL20.GL_LINK_STATUS) == 0) { System.err.println(GL20.glGetShaderInfoLog(pointer, 1024)); System.exit(-1); } GL20.glValidateProgram(pointer); if (GL20.glGetProgrami(pointer, GL20.GL_VALIDATE_STATUS) == 0) { System.err.println(GL20.glGetShaderInfoLog(pointer, 1024)); System.exit(-1); } }
From source file:processing.lwjgl.PGL.java
License:Open Source License
public String getProgramInfoLog(int prog) { int len = GL20.glGetProgrami(prog, GL20.GL_INFO_LOG_LENGTH); return GL20.glGetProgramInfoLog(prog, len); }
From source file:processing.lwjgl.PLWJGL.java
License:Open Source License
public String getProgramInfoLog(int program) { int len = GL20.glGetProgrami(program, GL20.GL_INFO_LOG_LENGTH); return GL20.glGetProgramInfoLog(program, len); }