Пример #1
0
Graphic_Util::Graphic_Util() {
	std::cout << "GRAPHIC UTIL" << std::endl;
	//Init SDL Opengl COntext at startup
	
	init_sdl();
	build_shader();
}
Пример #2
0
int LogoRenderer::build_program(GenericShaderContext *gs) {
    GLuint v_shader, f_shader;

    if (!((v_shader = build_shader(v_shader_source, GL_VERTEX_SHADER)) &&
                (f_shader = build_shader(f_shader_source, GL_FRAGMENT_SHADER)))) {
        //av_log(NULL, AV_LOG_ERROR, "build_shader error\n");
        return -1;
    }

    gs->program = glCreateProgram();
    glAttachShader(gs->program, v_shader);
    glAttachShader(gs->program, f_shader);
    glLinkProgram(gs->program);

    GLint status;
    glGetProgramiv(gs->program, GL_LINK_STATUS, &status);
    return status == GL_TRUE ? 0 : -1;
}
Пример #3
0
int GLWidget::build_program(GenericShaderContext *gs, const QString& fragSource) 
{
    GLuint v_shader, f_shader;
    v_shader = build_shader(v_shader_source, GL_VERTEX_SHADER);
    //f_shader = build_shader(f_shader_source, GL_FRAGMENT_SHADER);
    f_shader = build_shader(fragSource.toLocal8Bit().constData(), GL_FRAGMENT_SHADER);
    if (!(v_shader && f_shader )) {
        qDebug()<<"GLWidget::build_shader error";
        return -1;
    }

    gs->program = glCreateProgram();
    qDebug()<<"GLWidget::build_program gs->program: "<<gs->program;
    glAttachShader(gs->program, v_shader);
    glAttachShader(gs->program, f_shader);
    glLinkProgram(gs->program);

    GLint status;
    glGetProgramiv(gs->program, GL_LINK_STATUS, &status);
    return status == GL_TRUE ? 0 : -1;
}
Пример #4
0
// ---------------------------------------------------------- build_program ---
GLuint build_program( const char * vertex_source,
                      const char * fragment_source )
{
    GLuint vertex_shader   = build_shader( vertex_source, GL_VERTEX_SHADER);
    GLuint fragment_shader = build_shader( fragment_source, GL_FRAGMENT_SHADER);
    
    GLuint handle = glCreateProgram( );
    glAttachShader( handle, vertex_shader);
    glAttachShader( handle, fragment_shader);
    glLinkProgram( handle);
    
    GLint link_status;
    glGetProgramiv( handle, GL_LINK_STATUS, &link_status );
    if (link_status == GL_FALSE)
    {
        GLchar messages[256];
        glGetProgramInfoLog( handle, sizeof(messages), 0, &messages[0] );
        fprintf( stderr, "%s\n", messages );
        exit(1);
    }
    
    return handle;
}