Java 类org.lwjgl.opengl.ARBVertexShader 实例源码

项目:NeoTextureEdit2    文件:OpenGLTextureRenderCanvas.java   
/**
 * Loads a vertex and fragment shader pair, compiles them and links them to a ProgramObjectARB
 * @param name
 * @return the program object ID
 */
public int getShaderProgram(ByteBuffer vcode, ByteBuffer fcode) {
    int progID = -1;

    int vid = ARBShaderObjects.glCreateShaderObjectARB(ARBVertexShader.GL_VERTEX_SHADER_ARB);
    int fid = ARBShaderObjects.glCreateShaderObjectARB(ARBFragmentShader.GL_FRAGMENT_SHADER_ARB);

    ARBShaderObjects.glShaderSourceARB(vid, vcode);
    ARBShaderObjects.glCompileShaderARB(vid);
    printLogInfo(vid, "Compile Vertex Shader");

    ARBShaderObjects.glShaderSourceARB(fid, fcode);
    ARBShaderObjects.glCompileShaderARB(fid);
    printLogInfo(fid, "Compile Fragment Shader");

    progID = ARBShaderObjects.glCreateProgramObjectARB();
    ARBShaderObjects.glAttachObjectARB(progID, vid);
    ARBShaderObjects.glAttachObjectARB(progID, fid);

    ARBShaderObjects.glLinkProgramARB(progID);
    printLogInfo(progID, "Link");
    ARBShaderObjects.glValidateProgramARB(progID);
    printLogInfo(progID, "Validate");

    return progID;
}
项目:debug    文件:DebugIT.java   
@Test
public void testNoVertexAttribPointerInOtherVAOViaExtension() {
    window = glfwCreateWindow(800, 600, "", 0L, 0L);
    glfwMakeContextCurrent(window);
    createCapabilities();
    ARBVertexShader.glEnableVertexAttribArrayARB(0);
    int vao = ARBVertexArrayObject.glGenVertexArrays();
    ARBVertexArrayObject.glBindVertexArray(vao);
    glDrawArrays(GL_POINTS, 0, 1); // <--- MUST NOT THROW
    ARBVertexArrayObject.glDeleteVertexArrays(new int[] { vao });
}
项目:4Space-5    文件:ShaderProgram.java   
public void glVertexAttributeMat4(int loc, Matrix4f matrix)
{
    ARBVertexShader.glVertexAttrib4fARB(loc  , matrix.m00, matrix.m01, matrix.m02, matrix.m03);
    ARBVertexShader.glVertexAttrib4fARB(loc+1, matrix.m10, matrix.m11, matrix.m12, matrix.m13);
    ARBVertexShader.glVertexAttrib4fARB(loc+2, matrix.m20, matrix.m21, matrix.m22, matrix.m23);
    ARBVertexShader.glVertexAttrib4fARB(loc+3, matrix.m30, matrix.m31, matrix.m32, matrix.m33);
}
项目:DynamicSurroundings    文件:ShaderProgram.java   
protected void initialize(final String vertexSrc, final String fragmentSrc) throws ShaderException {

        int vertShader = 0;
        int fragShader = 0;

        vertShader = createShader(vertexSrc, ARBVertexShader.GL_VERTEX_SHADER_ARB);
        fragShader = createShader(fragmentSrc, ARBFragmentShader.GL_FRAGMENT_SHADER_ARB);

        if (vertShader == 0 || fragShader == 0)
            throw new ShaderException(this.name, "Unable to intialize shader!");

        this.programId = ARBShaderObjects.glCreateProgramObjectARB();

        if (this.programId != 0) {
            ARBShaderObjects.glAttachObjectARB(this.programId, vertShader);
            ARBShaderObjects.glAttachObjectARB(this.programId, fragShader);

            ARBShaderObjects.glLinkProgramARB(this.programId);
            if (ARBShaderObjects.glGetObjectParameteriARB(this.programId,
                    ARBShaderObjects.GL_OBJECT_LINK_STATUS_ARB) == GL11.GL_FALSE) {
                throw new ShaderException(this.name, getLogInfo(this.programId));
            }

            ARBShaderObjects.glValidateProgramARB(this.programId);
            if (ARBShaderObjects.glGetObjectParameteriARB(this.programId,
                    ARBShaderObjects.GL_OBJECT_VALIDATE_STATUS_ARB) == GL11.GL_FALSE) {
                throw new ShaderException(this.name, getLogInfo(this.programId));
            }
        }
    }
项目:DynamicSurroundings    文件:ShaderUtils.java   
public static int createProgram(@Nullable final ResourceLocation vert, @Nullable final ResourceLocation frag) {
    int vertId = 0, fragId = 0, program;
    if (vert != null)
        vertId = createShader(vert, ARBVertexShader.GL_VERTEX_SHADER_ARB);
    if (frag != null)
        fragId = createShader(frag, ARBFragmentShader.GL_FRAGMENT_SHADER_ARB);

    program = OpenGlHelper.glCreateProgram();
    if (program == 0)
        return 0;

    if (vert != null)
        OpenGlHelper.glAttachShader(program, vertId);
    if (frag != null)
        OpenGlHelper.glAttachShader(program, fragId);

    OpenGlHelper.glLinkProgram(program);
    if (OpenGlHelper.glGetProgrami(program, ARBShaderObjects.GL_OBJECT_LINK_STATUS_ARB) == GL11.GL_FALSE) {
        LibLog.log().error(getLogInfoProgram(program), null);
        return 0;
    }

    GL20.glValidateProgram(program);
    if (OpenGlHelper.glGetProgrami(program, ARBShaderObjects.GL_OBJECT_VALIDATE_STATUS_ARB) == GL11.GL_FALSE) {
        LibLog.log().error(getLogInfoProgram(program), null);
        return 0;
    }

    OpenGlHelper.glDeleteShader(vertId);
    OpenGlHelper.glDeleteShader(fragId);

    OpenGlHelper.glUseProgram(0);

    return program;
}
项目:AdventureBackpack2    文件:ShaderProgram.java   
public void glVertexAttributeMat4(int loc, Matrix4f matrix)
{
    ARBVertexShader.glVertexAttrib4fARB(loc, matrix.m00, matrix.m01, matrix.m02, matrix.m03);
    ARBVertexShader.glVertexAttrib4fARB(loc + 1, matrix.m10, matrix.m11, matrix.m12, matrix.m13);
    ARBVertexShader.glVertexAttrib4fARB(loc + 2, matrix.m20, matrix.m21, matrix.m22, matrix.m23);
    ARBVertexShader.glVertexAttrib4fARB(loc + 3, matrix.m30, matrix.m31, matrix.m32, matrix.m33);
}
项目:GPVM    文件:ShaderProgram.java   
/**
 * Returns the index for a given attribute in this {@link ShaderProgram}.
 * Th program must be loaded before this method is called.
 * 
 * @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;
}
项目:Beeg-StaKe    文件:Shader.java   
public Shader(String fragmentShader, String vertexShader) {
    this.fragmentShader = fragmentShader;
    this.vertexShader = vertexShader;
    this.vertexShaderId = loadShader(ARBVertexShader.GL_VERTEX_SHADER_ARB,
            vertexShader);
    this.fragmentShaderId = loadShader(
            ARBFragmentShader.GL_FRAGMENT_SHADER_ARB, fragmentShader);
    this.programId = ARBShaderObjects.glCreateProgramObjectARB();
    ARBShaderObjects.glAttachObjectARB(this.programId, this.vertexShaderId);
    ARBShaderObjects.glAttachObjectARB(this.programId,
            this.fragmentShaderId);
    ARBShaderObjects.glLinkProgramARB(this.programId);
    ARBShaderObjects.glValidateProgramARB(this.programId);
}
项目:RefinedRelocation    文件:ShaderProgram.java   
public void glVertexAttributeMat4(int loc, Matrix4f matrix)
{
    ARBVertexShader.glVertexAttrib4fARB(loc  , matrix.m00, matrix.m01, matrix.m02, matrix.m03);
    ARBVertexShader.glVertexAttrib4fARB(loc+1, matrix.m10, matrix.m11, matrix.m12, matrix.m13);
    ARBVertexShader.glVertexAttrib4fARB(loc+2, matrix.m20, matrix.m21, matrix.m22, matrix.m23);
    ARBVertexShader.glVertexAttrib4fARB(loc+3, matrix.m30, matrix.m31, matrix.m32, matrix.m33);
}
项目:DecompiledMinecraft    文件:OpenGlHelper.java   
public static int glGetAttribLocation(int p_153164_0_, CharSequence p_153164_1_)
{
    return arbShaders ? ARBVertexShader.glGetAttribLocationARB(p_153164_0_, p_153164_1_) : GL20.glGetAttribLocation(p_153164_0_, p_153164_1_);
}
项目:BaseClient    文件:OpenGlHelper.java   
public static int glGetAttribLocation(int p_153164_0_, CharSequence p_153164_1_)
{
    return arbShaders ? ARBVertexShader.glGetAttribLocationARB(p_153164_0_, p_153164_1_) : GL20.glGetAttribLocation(p_153164_0_, p_153164_1_);
}
项目:BaseClient    文件:OpenGlHelper.java   
public static int glGetAttribLocation(int p_153164_0_, CharSequence p_153164_1_)
{
    return arbShaders ? ARBVertexShader.glGetAttribLocationARB(p_153164_0_, p_153164_1_) : GL20.glGetAttribLocation(p_153164_0_, p_153164_1_);
}
项目:Backmemed    文件:OpenGlHelper.java   
public static int glGetAttribLocation(int program, CharSequence name)
{
    return arbShaders ? ARBVertexShader.glGetAttribLocationARB(program, name) : GL20.glGetAttribLocation(program, name);
}
项目:CustomWorldGen    文件:OpenGlHelper.java   
public static int glGetAttribLocation(int program, CharSequence name)
{
    return arbShaders ? ARBVertexShader.glGetAttribLocationARB(program, name) : GL20.glGetAttribLocation(program, name);
}
项目:4Space-5    文件:ShaderProgram.java   
public int getAttribLoc(String name)
{
    return ARBVertexShader.glGetAttribLocationARB(programID, name);
}
项目:AdventureBackpack2    文件:ShaderProgram.java   
public int getAttribLoc(String name)
{
    return ARBVertexShader.glGetAttribLocationARB(programID, name);
}
项目:ExpandedRailsMod    文件:OpenGlHelper.java   
public static int glGetAttribLocation(int program, CharSequence name)
{
    return arbShaders ? ARBVertexShader.glGetAttribLocationARB(program, name) : GL20.glGetAttribLocation(program, name);
}
项目:example-jovr-lwjgl3-rift    文件:ShaderProgram120.java   
public void init() {
    // vertex shader
    final int vertShader = ARBShaderObjects.glCreateShaderObjectARB(ARBVertexShader.GL_VERTEX_SHADER_ARB);
    if (vertShader == GL_FALSE) {
        throw new RuntimeException("failed to create vert shader");
    }
    final String vertexCode = ""
            + "#version 120                                                 \n"
            + "                                                             \n" 
            + "                                                             \n" 
            + "void main() {                                                \n" 
            //+ "    gl_Position = gl_Vertex;                                 \n"
            + "    gl_Position = vec4(gl_Vertex.xyz * 0.5, gl_Vertex.w);    \n"
            + "}                                                            \n";
    ARBShaderObjects.glShaderSourceARB(vertShader, vertexCode);
    ARBShaderObjects.glCompileShaderARB(vertShader);
    if (GL20.glGetShaderi(vertShader, GL20.GL_COMPILE_STATUS) == GL_FALSE) {
        System.out.println(GL20.glGetShaderInfoLog(vertShader));
        throw new RuntimeException("vert comp failed");
    }

    // fragment shader
    final int fragShader = ARBShaderObjects.glCreateShaderObjectARB(ARBFragmentShader.GL_FRAGMENT_SHADER_ARB);
    if (fragShader == GL_FALSE) {
        throw new RuntimeException("failed to create frag shader");
    }
    final String fragCode = ""
            + "#version 120                                     \n"
            + "                                                 \n" 
            + "void main() {                                    \n" 
            + "    gl_FragColor = vec4(1.0, 1.0, 0.4, 1.0);     \n"
            + "}                                                \n";
    ARBShaderObjects.glShaderSourceARB(fragShader, fragCode);
    ARBShaderObjects.glCompileShaderARB(fragShader);
    if (GL20.glGetShaderi(fragShader, GL20.GL_COMPILE_STATUS) == GL_FALSE) {
        System.out.println(GL20.glGetShaderInfoLog(fragShader));
        throw new RuntimeException("frag comp failed");
    }

    // program
    program = ARBShaderObjects.glCreateProgramObjectARB();
    if (program == GL_FALSE) {
        throw new RuntimeException("failed to create shader program");
    }
    ARBShaderObjects.glAttachObjectARB(program, vertShader);
    ARBShaderObjects.glAttachObjectARB(program, fragShader);
    ARBShaderObjects.glLinkProgramARB(program);                     //is there a way to check this result?
    ARBShaderObjects.glValidateProgramARB(program);                 //is there a way to check this result?

    glClearColor(.42f, .67f, .87f, 1f);
}
项目:Cauldron    文件:OpenGlHelper.java   
public static int func_153164_b(int p_153164_0_, CharSequence p_153164_1_)
{
    return field_153214_y ? ARBVertexShader.glGetAttribLocationARB(p_153164_0_, p_153164_1_) : GL20.glGetAttribLocation(p_153164_0_, p_153164_1_);
}
项目:Cauldron    文件:OpenGlHelper.java   
public static int func_153164_b(int p_153164_0_, CharSequence p_153164_1_)
{
    return field_153214_y ? ARBVertexShader.glGetAttribLocationARB(p_153164_0_, p_153164_1_) : GL20.glGetAttribLocation(p_153164_0_, p_153164_1_);
}
项目:PenguinMenaceEngine    文件:Shader.java   
/**
 * Create a shader with the given id and shader strings.
 *
 * @param vsh The vertex shader. (as a string)
 * @param fsh The fragment shader. (as a string)
 */
public Shader(final String vsh, final String fsh) {
    if (!Display.isCreated()) {
        throw new IllegalStateException("You need to initialize the display module first.");
    }
    try {
        if (vsh != null) {
            vsId = createShader(vsh, ARBVertexShader.GL_VERTEX_SHADER_ARB);
        }
        if (fsh != null) {
            fsId = createShader(fsh,
                    ARBFragmentShader.GL_FRAGMENT_SHADER_ARB);
        }
        program = ARBShaderObjects.glCreateProgramObjectARB();

        if (program <= 0) {
            throw new RuntimeException("Cannot create shader");
        }

        if (vsId != 0) {
            ARBShaderObjects.glAttachObjectARB(program, vsId);
        }
        if (fsId != 0) {
            ARBShaderObjects.glAttachObjectARB(program, fsId);
        }
        ARBShaderObjects.glLinkProgramARB(program);

        if (ARBShaderObjects.glGetObjectParameteriARB(program,
                ARBShaderObjects.GL_OBJECT_LINK_STATUS_ARB) == GL11.GL_FALSE) {
            throw new RuntimeException(getLogInfo(program));
        }

        ARBShaderObjects.glValidateProgramARB(program);
        if (ARBShaderObjects.glGetObjectParameteriARB(program,
                ARBShaderObjects.GL_OBJECT_VALIDATE_STATUS_ARB) == GL11.GL_FALSE) {
            throw new RuntimeException(getLogInfo(program));
        }
    } catch (RuntimeException e) {
        delete();
        throw e;
    }
}
项目:RefinedRelocation    文件:ShaderProgram.java   
public int getAttribLoc(String name)
{
    return ARBVertexShader.glGetAttribLocationARB(programID, name);
}
项目:OpenModsLib    文件:ShaderHelper.java   
@Override
public int glGetAttribLocation(int program, String attrib) {
    return ARBVertexShader.glGetAttribLocationARB(program, attrib);
}
项目:OpenModsLib    文件:ShaderHelper.java   
@Override
public void glEnableVertexAttribArray(int index) {
    ARBVertexShader.glEnableVertexAttribArrayARB(index);
}
项目:OpenModsLib    文件:ShaderHelper.java   
@Override
public void glDisableVertexAttribArray(int index) {
    ARBVertexShader.glDisableVertexAttribArrayARB(index);
}
项目:OpenModsLib    文件:ShaderHelper.java   
@Override
public void glVertexAttribPointer(int index, int size, int type, boolean normalized, int stride, long offset) {
    ARBVertexShader.glVertexAttribPointerARB(index, size, type, normalized, stride, offset);
}