aboutsummaryrefslogtreecommitdiffstats
path: root/src/classes/javax/media/opengl/sdk/glsl/CompileShaderNVidia.java
blob: c0c0d1c1ebd58da3069bd25a0091504b7f8b803d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package javax.media.opengl.sdk.glsl;

import javax.media.opengl.glsl.*;
import javax.media.opengl.*;

import java.io.*;

/** Precompiles a shader into NVidia binary format. Input is the
    resource name of the shader, such as
    "com/sun/opengl/impl/glsl/fixed/shader/a.fp".
    Output is "com/sun/opengl/impl/glsl/fixed/shader/bin/nvidia/a.bfp". */

public class CompileShaderNVidia extends CompileShader {
    private static final String NVAPSDK;

    static {
        String nvapSDKProp = System.getProperty("NVAPSDK");
        if (nvapSDKProp != null) {
            NVAPSDK = nvapSDKProp;
        } else {
            NVAPSDK = "C:\\nvap_sdk_0_3_x";
        }
    }

    public int getBinaryFormat() {
        return GLES2.GL_NVIDIA_PLATFORM_BINARY_NV;
    }

    public File getSDKCompilerDir() {
        File compilerDir = new File( NVAPSDK + File.separator + "tools" + File.separator );
        File compilerFile = new File( compilerDir, getVertexShaderCompiler());
        if(!compilerFile.exists()) {
            compilerDir = new File( NVAPSDK );
            compilerFile = new File( compilerDir, getVertexShaderCompiler());
        }
        if(!compilerFile.exists()) {
            throw new GLException("Can't find compiler: "+getVertexShaderCompiler() + " in : " +
                                  NVAPSDK+", "+NVAPSDK + File.separator + "tools");
        }
        return compilerDir;
    }

    public String getVertexShaderCompiler() {
        return "glslv.bat";
    }

    public String getFragmentShaderCompiler() {
        return "glslf.bat";
    }

    public static void main(String[] args) {
        new CompileShaderNVidia().run(args);
    }
}