List of usage examples for org.lwjgl.opengl GL20 glBindAttribLocation
public static void glBindAttribLocation(@NativeType("GLuint") int program, @NativeType("GLuint") int index, @NativeType("GLchar const *") CharSequence name)
From source file:ar.com.quark.backend.lwjgl.opengl.DesktopGLES20.java
License:Apache License
/** * {@inheritDoc}//from w w w.ja v a 2s. co m */ @Override public void glBindAttribLocation(int name, int id, String attribute) { GL20.glBindAttribLocation(name, id, attribute); }
From source file:br.com.perin.shaders.ShaderProgram.java
protected void bindAttribute(int attribute, String variable) { GL20.glBindAttribLocation(programId, attribute, variable); }
From source file:com.adavr.player.globjects.Program.java
License:Open Source License
public void bindAttribLocation(int index, CharSequence name) { GL20.glBindAttribLocation(id, index, name); }
From source file:com.badlogic.gdx.backends.jglfw.JglfwGL20.java
License:Apache License
public void glBindAttribLocation(int program, int index, String name) { GL20.glBindAttribLocation(program, index, name); }
From source file:com.flowpowered.caustic.lwjgl.gl20.GL20Program.java
License:MIT License
@Override public void link() { checkCreated();//from w ww . ja v a 2s . c om // 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); final int maxLength = GL20.glGetProgrami(id, GL20.GL_ACTIVE_UNIFORM_MAX_LENGTH); final IntBuffer lengthBuffer = CausticUtil.createIntBuffer(1); final IntBuffer ignored1 = CausticUtil.createIntBuffer(1); final IntBuffer ignored2 = CausticUtil.createIntBuffer(1); final ByteBuffer nameBuffer = CausticUtil.createByteBuffer(maxLength); final byte[] nameBytes = new byte[maxLength]; for (int i = 0; i < uniformCount; i++) { lengthBuffer.clear(); ignored1.clear(); ignored2.clear(); nameBuffer.clear(); GL20.glGetActiveUniform(id, i, lengthBuffer, ignored1, ignored2, nameBuffer); final int length = lengthBuffer.get(); nameBuffer.get(nameBytes, 0, length); // Simplify array names final String name = new String(nameBytes, 0, length).replaceFirst("\\[\\d+\\]", ""); uniforms.put(name, GL20.glGetUniformLocation(id, name)); uniformValues.put(name, UNSET); } // Check for errors LWJGLUtil.checkForGLError(); }
From source file:com.geekyaubergine.geekyjgameutil.shader.ShaderProgram.java
License:Open Source License
/** * Binds VAO attribute to variable in shader * @param attribute Attribute ID/*from www .j a v a 2 s .c om*/ * @param variableName Variable name in shader files */ public void bindAttribute(int attribute, String variableName) { Validate.notNull(variableName, "Variable name must not be null"); Validate.isTrue(variableName.length() > 0, "Variable name must contain at least one character"); GL20.glBindAttribLocation(programID, attribute, variableName); }
From source file:com.github.kajdreef.mazerunnermvn.MazeRunner.ShaderProgram.java
public void newShaderProgram(String vertexShaderLocation, String fragmentShaderLocation) { // Initialize the vertex Shader vertexId = compileShader(GL20.GL_VERTEX_SHADER, vertexShaderLocation); // Initialize the fragment shader fragmentId = compileShader(GL20.GL_FRAGMENT_SHADER, fragmentShaderLocation); programId = GL20.glCreateProgram();//from w ww .j a v a2s . c o m GL20.glAttachShader(programId, vertexId); GL20.glAttachShader(programId, fragmentId); // Position information will be attribute 0 GL20.glBindAttribLocation(programId, 0, "in_Position"); // Color information will be attribute 1 GL20.glBindAttribLocation(programId, 1, "in_Color"); // Texture information will be attribute 2 GL20.glBindAttribLocation(programId, 2, "in_TextureCoord"); GL20.glLinkProgram(programId); GL20.glValidateProgram(programId); // Get matrices uniform locations projectionMatrixLocation = GL20.glGetUniformLocation(programId, "projectionMatrix"); viewMatrixLocation = GL20.glGetUniformLocation(programId, "viewMatrix"); modelMatrixLocation = GL20.glGetUniformLocation(programId, "modelMatrix"); }
From source file:com.github.ryancwilliams.WJ3dPL.graphics.GLUtils.ShaderProgram.java
License:Apache License
/** * Creates a new shader program with the provided vertex and fragment * shader source code./*from w w w . j a v a2 s. c om*/ * The provided attributes are linked to this program. * @param vertexShaderSource the source code of the vertex shader. * @param fragmentShaderSource the source code of the fragment shader. * @param attributes The Vertex Attributes to bind to this shader program. * @throws LWJGLException If their is a issue compiling the shaders or * creating or binding the program. */ public ShaderProgram(String vertexShaderSource, String fragmentShaderSource, List<VertexAttribute> attributes) throws LWJGLException { //Check if any of the sourcecode paramaters are null if (fragmentShaderSource == null || fragmentShaderSource == null) { //If any of the sourcecode paramaters were null //throw a exception throw new IllegalArgumentException("Shader source may not be null"); } //Check if shaders are not supported if (!ShaderProgram.isSupported()) { //If shaders are not supported //throw a exception throw new LWJGLException("Shaders are not supported on this device"); } //Compile the shaders int vertexShader = ShaderProgram.compileShader(GL20.GL_VERTEX_SHADER, vertexShaderSource); int fragmentShader = ShaderProgram.compileShader(GL20.GL_FRAGMENT_SHADER, fragmentShaderSource); //Create the program this.program = GL20.glCreateProgram(); //Bind the attrib locations //Check if attributes were provided if (attributes != null) { //For each attribute for (VertexAttribute attribute : attributes) { //Check if the attribute is not null if (attribute != null) { //bind the attribute GL20.glBindAttribLocation(this.program, attribute.index, attribute.name); } } } //Attach the shaders GL20.glAttachShader(this.program, vertexShader); GL20.glAttachShader(this.program, fragmentShader); //Link the program GL20.glLinkProgram(this.program); //Get if the program link was good boolean programLink = GL20.glGetProgrami(this.program, GL20.GL_LINK_STATUS) == GL11.GL_TRUE; //Get the log String infoLog = GL20.glGetProgramInfoLog(this.program, GL20.glGetProgrami(this.program, GL20.GL_INFO_LOG_LENGTH)); //Log the log if a log is present if (infoLog != null && infoLog.trim().length() != 0) { Logger.getLogger(ShaderProgram.class.getName()).log(Level.FINEST, infoLog); } //Check if program link is bad if (programLink == false) { throw new LWJGLException("Failure in linking program. Error log:\n" + infoLog); } //detach and delete the shaders which are no longer needed GL20.glDetachShader(this.program, vertexShader); GL20.glDetachShader(this.program, fragmentShader); GL20.glDeleteShader(vertexShader); GL20.glDeleteShader(fragmentShader); }
From source file:com.grillecube.client.opengl.GLProgram.java
protected void bindAttribute(int attribute, String name) { GL20.glBindAttribLocation(this.progID, attribute, name); }
From source file:com.grillecube.engine.opengl.object.GLProgram.java
protected void bindAttribute(int attribute, String name) { GL20.glBindAttribLocation(this._programID, attribute, name); }