1
votes

Shaders compile status is always 0, including zero errors. If i purposefully break the shader it properly shows the errors and even fails to link, however when the shader (I believe) is a correct and working shader it's compile status is still zero, (GL_FALSE) but the program links correctly. when the failed to compile shader is used in a program nothing renders.

code used to check shaders:

private static void checkShader(int handle,String path) {
    int status = glGetProgrami(handle,GL_COMPILE_STATUS);
    boolean compiled = status==GL_TRUE;
    if (compiled) return; // Shader compiled and everything is fine~
    String error = glGetShaderInfoLog(handle);
    System.err.println("==== SHADER FAILED TO COMPILE ====");
    System.err.println(path);
    System.err.println(error);
    System.err.println("==== ======================== ====");
}

code used to read shaders:

private static String getShaderData(String path) throws IOException {
    InputStream inputStream = ShaderManager.class.getResourceAsStream(path);
    if (inputStream == null) throw new BadShaderException("Could not find shader: "+path);
    Scanner scanner = new Scanner(inputStream);
    StringBuilder builder = new StringBuilder();
    while (scanner.hasNextLine())
        builder.append(scanner.nextLine()).append('\n');
    scanner.close();
    return builder.toString();
}

loading vertex shaders (same for fragment and geometry shader, but container class changed)

public static VertexShader loadVertexShader(String path) {
    String source;
    try {
        source = getShaderData(path);
    } catch (Exception e) {
        throw new BadShaderException("Failed to load data for shader: "+path);
    }
    int handle = glCreateShader(GL_VERTEX_SHADER);
    glShaderSource(handle,source);
    glCompileShader(handle);
    checkShader(handle,path);
    return new VertexShader(handle,path);
}

shader I'm trying to use

#version 330 core
layout(location = 0) in vec3 vpm;
uniform mat4 depthMatrix;

void main(){
 gl_Position =  depthMatrix * vec4(vpm,1);
}

and a shader I've found while searching for a "passthrough" shader to test

#version 330 core
// Input vertex data, different for all executions of this shader.
layout(location = 0) in vec3 vertexPosition_modelspace;

// Output data ; will be interpolated for each fragment.
out vec2 UV;

void main(){
    gl_Position =  vec4(vertexPosition_modelspace,1);
    UV = (vertexPosition_modelspace.xy+vec2(1,1))/2.0;
}

I'm using lwjgl 3.1.4,

OpenGL version is (4.6.0 NVIDIA 388.13)

OpenGL Vendor is (NVIDIA Corporation)

OpenGL Renderer is (GeForce GTX 1060 6GB/PCIe/SSE2)

EDIT: I was using glGetProgrami instead of glGetShaderi

1
I wish there were a way to "watch" certain questions. I use LWJGL sometimes and I'd like to see what the solution is also.markspace
@markspace you can at least mark it as a "favorite" (the star under the vote buttons) so it appears in your profile under favorite questions.Jim Garrison

1 Answers

2
votes

I was using glGetProgrami instead of glGetShaderi when checking whether my shaders compiled correctly. I was unaware of the latter method and thought the prior was used for both.