List of usage examples for org.lwjgl.opengl ARBVertexShader glGetAttribLocationARB
@NativeType("GLint") public static int glGetAttribLocationARB(@NativeType("GLhandleARB") int programObj, @NativeType("GLchar const *") CharSequence name)
From source file:com.a2client.corex.ShaderAttrib.java
License:Open Source License
public void init(int ShaderID, String name, Const.SHADER_ATTRIB_TYPE attrib_type, boolean norm) { // ARBShaderObjects.glUseProgramObjectARB(ShaderID); this.Name = name; this.ID = ARBVertexShader.glGetAttribLocationARB(ShaderID, name); this.Type = attrib_type; int type_ord = attrib_type.ordinal(); this.Size = type_ord % 4 + 1; this.Norm = norm; switch (this.Type) { case atVec1b: this.DType = GL11.GL_UNSIGNED_BYTE; break;// w w w. j a va 2 s . c o m case atVec2b: this.DType = GL11.GL_UNSIGNED_BYTE; break; case atVec3b: this.DType = GL11.GL_UNSIGNED_BYTE; break; case atVec4b: this.DType = GL11.GL_UNSIGNED_BYTE; break; case atVec1s: this.DType = GL11.GL_SHORT; break; case atVec2s: this.DType = GL11.GL_SHORT; break; case atVec3s: this.DType = GL11.GL_SHORT; break; case atVec4s: this.DType = GL11.GL_SHORT; case atVec1f: this.DType = GL11.GL_FLOAT; break; case atVec2f: this.DType = GL11.GL_FLOAT; break; case atVec3f: this.DType = GL11.GL_FLOAT; break; case atVec4f: this.DType = GL11.GL_FLOAT; break; } }
From source file:com.ardor3d.scene.state.lwjgl.shader.LwjglShaderUtil.java
License:Open Source License
/** * Update variableID for attribute shadervariable if needed. * //from w ww.j a v a 2 s . c o m * @param variable * shadervaribale to update ID on * @param programID * shader program context ID */ public static void updateAttributeLocation(final ShaderVariable variable, final int programID) { if (variable.variableID == -1) { final ByteBuffer nameBuf = BufferUtils.createByteBuffer(variable.name.getBytes().length + 1); nameBuf.clear(); nameBuf.put(variable.name.getBytes()); nameBuf.rewind(); variable.variableID = ARBVertexShader.glGetAttribLocationARB(programID, nameBuf); if (variable.variableID == -1 && !variable.errorLogged) { logger.severe("Shader attribute [" + variable.name + "] could not be located in shader"); variable.errorLogged = true; } } }
From source file:taiga.code.opengl.shaders.ShaderProgram.java
License:Open Source License
/** * Returns the index for a given attribute in this {@link ShaderProgram}. * Th program must be loaded before this method is called. * // ww w.j a v a 2 s .c om * @param name The name of the attribute to look up. * @return The index of the attribute , or -1 if there was a problem. */ public Location getAttributeLocation(String name) { Location output = new Location(name, false); output.index = ARBVertexShader.glGetAttribLocationARB(shaderprog, name); locations.put(name, output); return output; }
From source file:taiga.code.opengl.shaders.ShaderProgram.java
License:Open Source License
@Override public void load() { try {/*from w ww .ja v a 2 s .com*/ shaderprog = ARBShaderObjects.glCreateProgramObjectARB(); if (!fragsrc.isEmpty()) { String[] src = new String[fragsrc.size()]; fragsrc.toArray(src); attachShader(shaderprog, ARBFragmentShader.GL_FRAGMENT_SHADER_ARB, src); } if (!vertsrc.isEmpty()) { String[] src = new String[vertsrc.size()]; vertsrc.toArray(src); attachShader(shaderprog, ARBVertexShader.GL_VERTEX_SHADER_ARB, src); } if (!geomsrc.isEmpty()) { String[] src = new String[geomsrc.size()]; geomsrc.toArray(src); attachShader(shaderprog, ARBGeometryShader4.GL_GEOMETRY_SHADER_ARB, src); } ARBShaderObjects.glLinkProgramARB(shaderprog); if (ARBShaderObjects.glGetObjectParameteriARB(shaderprog, ARBShaderObjects.GL_OBJECT_LINK_STATUS_ARB) == GL11.GL_FALSE) { throw new RuntimeException(getLog(shaderprog)); } ARBShaderObjects.glValidateProgramARB(shaderprog); if (ARBShaderObjects.glGetObjectParameteriARB(shaderprog, ARBShaderObjects.GL_OBJECT_VALIDATE_STATUS_ARB) == GL11.GL_FALSE) { throw new RuntimeException(getLog(shaderprog)); } } catch (RuntimeException ex) { ARBShaderObjects.glDeleteObjectARB(shaderprog); throw ex; } for (Location loc : locations.values()) { if (loc.uniform) loc.index = ARBShaderObjects.glGetUniformLocationARB(shaderprog, loc.name); else loc.index = ARBVertexShader.glGetAttribLocationARB(shaderprog, loc.name); } }