tests/cuda3.2/tests/oceanFFT/oceanFFT.cpp
GLuint loadGLSLProgram(const char *vertFileName, const char *fragFileName)
{
    GLint linked;
    GLuint program;

    program = glCreateProgram();
    if (!attachShader(program, GL_VERTEX_SHADER, vertFileName)) {
        glDeleteProgram(program);
        fprintf(stderr, "Couldn't attach vertex shader from file %s\n", vertFileName);
        return 0;
    }

    if (!attachShader(program, GL_FRAGMENT_SHADER, fragFileName)) {
        glDeleteProgram(program);
        fprintf(stderr, "Couldn't attach fragment shader from file %s\n", fragFileName);
        return 0;
    }

    glLinkProgram(program);
    glGetProgramiv(program, GL_LINK_STATUS, &linked);
    if (!linked) {
        glDeleteProgram(program);
        char temp[256];
        glGetProgramInfoLog(program, 256, 0, temp);
        fprintf(stderr, "Failed to link program: %s\n", temp);
        return 0;
    }

    return program;
}
// Create shader program from vertex shader and fragment shader files
Create shader program from vertex shader and fragment shader files
Create shader program from vertex shader and fragment shader files
GLuint loadGLSLProgram(const char *vertFileName, const char *fragFileName)
{
    GLint linked;
    GLuint program;
    program = glCreateProgram();
    if (!attachShader(program, GL_VERTEX_SHADER, vertFileName)) {
        glDeleteProgram(program);
        fprintf(stderr, "Couldn't attach vertex shader from file %s\n", vertFileName);
        return 0;
    }
    if (!attachShader(program, GL_FRAGMENT_SHADER, fragFileName)) {
        glDeleteProgram(program);
        fprintf(stderr, "Couldn't attach fragment shader from file %s\n", fragFileName);
        return 0;
    }
    glLinkProgram(program);
    glGetProgramiv(program, GL_LINK_STATUS, &linked);
    if (!linked) {
        glDeleteProgram(program);
        char temp[256];
        glGetProgramInfoLog(program, 256, 0, temp);
        fprintf(stderr, "Failed to link program: %s\n", temp);
        return 0;
    }
    return program;
}
GLuint loadGLSLProgram ( const char * vertFileName , const char * fragFileName ) { GLint linked ; GLuint program ; program = glCreateProgram ( ) ; if ( ! attachShader ( program , GL_VERTEX_SHADER , vertFileName ) ) { glDeleteProgram ( program ) ; fprintf ( stderr , " \n " , vertFileName ) ; return 0 ; } if ( ! attachShader ( program , GL_FRAGMENT_SHADER , fragFileName ) ) { glDeleteProgram ( program ) ; fprintf ( stderr , " \n " , fragFileName ) ; return 0 ; } glLinkProgram ( program ) ; glGetProgramiv ( program , GL_LINK_STATUS , & linked ) ; if ( ! linked ) { glDeleteProgram ( program ) ; char temp [ 256 ] ; glGetProgramInfoLog ( program , 256 , 0 , temp ) ; fprintf ( stderr , " \n " , temp ) ; return 0 ; } return program ; }
Create shader program from vertex shader and fragment shader files
Create shader program from vertex shader and fragment shader files