PIGLIT_GL_TEST_CONFIG_END bool compile_simple_program(const char* vs_text, const char* fs_text) { GLuint vs; GLuint fs; GLuint prog; bool status; prog = glCreateProgram(); vs = piglit_compile_shader_text_nothrow(GL_VERTEX_SHADER, vs_text); fs = piglit_compile_shader_text_nothrow(GL_FRAGMENT_SHADER, fs_text); if (!vs || !fs) return false; glAttachShader(prog, vs); glAttachShader(prog, fs); glLinkProgram(prog); status = piglit_link_check_status(prog); glDeleteProgram(prog); return status; }
/** * Generate a full program pipeline using the shader code provided in * the \a sources array. */ static GLuint generate_program_v(const struct grid_info grid, const char **sources) { const unsigned basic_stages = (GL_FRAGMENT_SHADER_BIT | GL_VERTEX_SHADER_BIT); const unsigned tess_stages = (GL_TESS_CONTROL_SHADER_BIT | GL_TESS_EVALUATION_SHADER_BIT); const unsigned graphic_stages = (basic_stages | tess_stages | GL_GEOMETRY_SHADER_BIT); const unsigned stages = (grid.stages | /* Make a full pipeline if a tesselation shader was * requested. */ (grid.stages & tess_stages ? graphic_stages : 0) | /* Make sure there is always a vertex and fragment * shader if we're doing graphics. */ (grid.stages & graphic_stages ? basic_stages : 0)); GLuint prog = glCreateProgram(); const struct image_stage_info *stage; for (stage = known_image_stages(); stage->stage; ++stage) { if (stages & stage->bit) { char *source = generate_stage_source( grid, stage->stage, sources[get_stage_idx(stage)]); GLuint shader = piglit_compile_shader_text_nothrow( stage->stage, source); free(source); if (!shader) { glDeleteProgram(prog); return 0; } glAttachShader(prog, shader); glDeleteShader(shader); } } glBindAttribLocation(prog, PIGLIT_ATTRIB_POS, "piglit_vertex"); glBindAttribLocation(prog, PIGLIT_ATTRIB_TEX, "piglit_texcoord"); glLinkProgram(prog); if (!piglit_link_check_status(prog)) { glDeleteProgram(prog); return 0; } return prog; }