本文整理汇总了C++中piglit_build_simple_program函数的典型用法代码示例。如果您正苦于以下问题:C++ piglit_build_simple_program函数的具体用法?C++ piglit_build_simple_program怎么用?C++ piglit_build_simple_program使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了piglit_build_simple_program函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: piglit_init
void
piglit_init(int argc, char **argv)
{
piglit_require_extension("GL_EXT_texture_norm16");
prog = piglit_build_simple_program(vs_source, fs_source);
if (piglit_is_extension_supported("GL_OES_texture_buffer"))
buf_prog = piglit_build_simple_program(vs_source,
fs_buf_source);
}
示例2: piglit_init
void
piglit_init(int argc, char **argv)
{
GLuint prog = piglit_build_simple_program(
"#version 140\n"
"const vec2 verts[4] = vec2[](\n"
" vec2(-1, 1),\n"
" vec2(-1,-1),\n"
" vec2( 1,-1),\n"
" vec2( 1, 1)\n"
");\n"
"void main() {\n"
" gl_Position = vec4(verts[gl_VertexID], 0, 1);\n"
"}\n",
"#version 140\n"
"void main() {\n"
" gl_FragColor = vec4(1,0,0,1);\n"
"}\n");
GLuint vao;
glUseProgram(prog);
glGenVertexArrays(1, &vao);
glBindVertexArray(vao);
}
示例3: piglit_init
void
piglit_init(int argc, char **argv)
{
GLuint Texture;
piglit_require_extension("GL_ARB_texture_float");
piglit_require_extension("GL_ARB_fragment_shader");
HaveRG = piglit_is_extension_supported("GL_ARB_texture_rg");
Program = piglit_build_simple_program(NULL, FragShaderText);
glUseProgram(Program);
BiasUniform = glGetUniformLocation(Program, "bias");
ScaleUniform = glGetUniformLocation(Program, "scale");
TexUniform = glGetUniformLocation(Program, "tex");
glUniform1f(BiasUniform, Bias);
glUniform1f(ScaleUniform, Scale);
glUniform1i(TexUniform, 0); /* tex unit zero */
(void) check_error(__FILE__, __LINE__);
glGenTextures(1, &Texture);
glBindTexture(GL_TEXTURE_2D, Texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
}
示例4: piglit_init
void
piglit_init(int argc, char **argv)
{
GLuint buf;
GLint vertex;
piglit_require_gl_version(20);
prog = piglit_build_simple_program(vs, fs);
if (!prog) {
printf("Failed to compile/link program\n");
piglit_report_result(PIGLIT_FAIL);
}
glUseProgram(prog);
attr = glGetAttribLocation(prog, "attr");
vertex = glGetAttribLocation(prog, "vertex");
glGenBuffers(1, &buf);
glBindBuffer(GL_ARRAY_BUFFER, buf);
glBufferData(GL_ARRAY_BUFFER, sizeof(verts), verts, GL_STATIC_DRAW);
glVertexAttribPointer(vertex,
2, GL_FLOAT, GL_FALSE, 0, 0);
glEnableVertexAttribArray(vertex);
}
示例5: piglit_init
void
piglit_init(int argc, char **argv)
{
piglit_require_GLSL();
piglit_require_extension("GL_ARB_instanced_arrays");
Program = piglit_build_simple_program(VertShaderText, FragShaderText);
glUseProgram(Program);
PosAttrib = glGetAttribLocation(Program, "Pos");
ColorAttrib = glGetAttribLocation(Program, "Color");
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum(-5, 5, -5, 5, 10, 20);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0, 0, -11.0);
glScalef(0.5, 0.5, 1.0);
if ((argc >= 2) && (strcmp(argv[1], "vbo") == 0)) {
use_vbo = GL_TRUE;
}
}
示例6: piglit_init
void
piglit_init(int argc, char **argv)
{
enum piglit_result result;
GLuint render_program;
int i;
float green[4] = { 0.0, 1.0, 0.0, 1.0 };
cs_ids_common_init();
cs_ids_set_local_id_test();
cs_ids_set_local_size(4, 4, 4);
cs_ids_set_global_size(4, 4, 4);
render_program =
piglit_build_simple_program(passthrough_vs_src,
green_fs_src);
glClearColor(0.0, 0.0, 0.0, 0.0);
for (i = 0; i < 2; i++) {
result = cs_ids_run_test();
if (result != PIGLIT_PASS)
piglit_report_result(result);
glUseProgram(render_program);
glClear(GL_COLOR_BUFFER_BIT);
piglit_draw_rect(-1, -1, 2, 2);
result = piglit_probe_rect_rgba(0, 0, piglit_width,
piglit_height, green)
? PIGLIT_PASS : PIGLIT_FAIL;
}
cs_ids_common_destroy();
piglit_report_result(result);
}
示例7: create_program
static void
create_program(struct program *program, const char *type)
{
char *fs_source, *vs_source;
GLuint prog;
char *threshold;
if (strcmp(type, "") == 0)
threshold = "vec4(0.02)";
else
threshold = "ivec4(1)";
if (test_vs) {
asprintf(&vs_source, vs_vert_source, type, type, type, type,
threshold);
fs_source = fs_vert_source;
} else {
vs_source = vs_frag_source;
asprintf(&fs_source, fs_frag_source, type, type, type, type,
threshold);
}
prog = piglit_build_simple_program(vs_source, fs_source);
program->prog = prog;
program->pos_location = glGetUniformLocation(prog, "pos");
program->expected_location = glGetUniformLocation(prog,
"expected");
vertex_location = glGetAttribLocation(prog, "vertex");
assert(vertex_location == 0);
}
示例8: piglit_init
void
piglit_init(int argc, char **argv)
{
GLuint vertIndex;
#ifdef PIGLIT_USE_OPENGL
piglit_require_extension("GL_ARB_base_instance");
#else
piglit_require_extension("GL_EXT_base_instance");
#endif
prog = piglit_build_simple_program(vstext, fstext);
glUseProgram(prog);
glGenBuffers(1, &vertBuff);
glBindBuffer(GL_ARRAY_BUFFER, vertBuff);
glBufferData(GL_ARRAY_BUFFER, vertSize, vertices, GL_STATIC_DRAW);
glGenBuffers(1, &indexBuf);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuf);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, indSize,
indices, GL_STATIC_DRAW);
glGenVertexArrays(1, &vao);
glBindVertexArray(vao);
vertIndex = glGetAttribLocation(prog, "vertex");
glBindBuffer(GL_ARRAY_BUFFER, vertBuff);
glEnableVertexAttribArray(vertIndex);
glVertexAttribPointer(vertIndex, 3, GL_FLOAT, GL_FALSE, 0, 0);
}
示例9: make_program
static GLuint
make_program(void)
{
const char *snippet = sample_function->snippet;
int glsl_version = sample_function->glsl_version;
int snippet_length = strlen(snippet);
int snippet_pos = strstr(fragment_source, "SNIPPET") - fragment_source;
GLuint program;
char source[1000], *p = source;
if (glsl_version > 0) {
p += sprintf(p, "#version %i\n", glsl_version);
piglit_require_GLSL_version(glsl_version);
}
if (sample_function->extension) {
p += sprintf(p,
"#extension %s : require\n",
sample_function->extension);
piglit_require_extension(sample_function->extension);
}
memcpy(p, fragment_source, snippet_pos);
p += snippet_pos;
memcpy(p, snippet, snippet_length);
p += snippet_length;
memcpy(p,
fragment_source + snippet_pos + 7,
sizeof fragment_source - snippet_pos - 7);
program = piglit_build_simple_program(vertex_source, source);
return program;
}
示例10: setup_shaders
static void
setup_shaders(void)
{
static const char *vsSrc =
"#version 150\n"
"in vec4 Attr0;"
"in vec4 Attr1;"
"smooth out vec4 fs_color0;"
"void main(void) {"
" gl_Position = Attr0;"
" fs_color0 = Attr1;"
"}";
static const char *fsSrc =
"#version 150\n"
"smooth in vec4 fs_color0;"
"out vec4 fragColor0;"
"void main(void) {"
" vec2 psCoords = gl_PointCoord;"
" fragColor0 = fs_color0;"
"}";
prog = piglit_build_simple_program(vsSrc, fsSrc);
glBindFragDataLocation(prog, 0, "fragColor0");
glLinkProgram(prog);
glUseProgram(prog);
}
示例11: piglit_init
void
piglit_init(int argc, char **argv)
{
int maxloc;
GLuint prog;
char *f_sha;
piglit_require_extension("GL_ARB_explicit_uniform_location");
glGetIntegerv(GL_MAX_UNIFORM_LOCATIONS, &maxloc);
if (!piglit_check_gl_error(GL_NO_ERROR))
piglit_report_result(PIGLIT_FAIL);
/* test GL_MAX_UNIFORM_LOCATIONS - 1, 0, and a loc in between (1) */
if (asprintf(&f_sha, fs_template, maxloc - 1, 0, 1) == -1)
piglit_report_result(PIGLIT_FAIL);
prog = piglit_build_simple_program(vs_text, f_sha);
free(f_sha);
if (glGetUniformLocation(prog, "r") != maxloc - 1)
piglit_report_result(PIGLIT_FAIL);
if (glGetUniformLocation(prog, "g") != 0)
piglit_report_result(PIGLIT_FAIL);
if (glGetUniformLocation(prog, "b") != 1)
piglit_report_result(PIGLIT_FAIL);
glDeleteProgram(prog);
piglit_report_result(PIGLIT_PASS);
}
示例12: piglit_init
void
piglit_init(int argc, char **argv)
{
GLuint prog;
char *vs_text;
if (strcmp(argv[1], "drawid") == 0) {
(void)!asprintf(&vs_text, vs_template,
"ref.x == gl_DrawIDARB");
} else if (strcmp(argv[1], "vertexid") == 0) {
(void)!asprintf(&vs_text, vs_template,
"ref.x == gl_DrawIDARB && ref.y == gl_VertexID");
} else {
printf("Unknown subtest: %s\n", argv[1]);
piglit_report_result(PIGLIT_FAIL);
}
piglit_require_GLSL_version(130);
piglit_require_extension("GL_ARB_shader_draw_parameters");
piglit_require_extension("GL_ARB_base_instance");
prog = piglit_build_simple_program(vs_text, fs_text);
glUseProgram(prog);
}
示例13: piglit_init
void
piglit_init(int argc, char **argv)
{
GLuint prog, i;
piglit_require_extension("GL_ARB_explicit_attrib_location");
piglit_require_extension("GL_ARB_explicit_uniform_location");
prog = piglit_build_simple_program(vs_text, fs_text);
/* verify that locations are sequential */
for (i = 0; i < 16; i++) {
char *element;
if (asprintf(&element, "a[%d]", i) == -1)
piglit_report_result(PIGLIT_FAIL);
if (glGetUniformLocation(prog, element) != 3 + i)
piglit_report_result(PIGLIT_FAIL);
free(element);
}
glDeleteProgram(prog);
piglit_report_result(PIGLIT_PASS);
}
示例14: piglit_init
void
piglit_init(int argc, char *argv[])
{
GLuint prog, array, buf;
glGenVertexArrays(1, &array);
glBindVertexArray(array);
glGenBuffers(1, &buf);
glBindBuffer(GL_ARRAY_BUFFER, buf);
prog = piglit_build_simple_program(vs_src, fs_src);
glVertexAttribPointer(0, /* index */
4, /* size */
GL_FLOAT, /* type */
GL_FALSE, /* normalized */
0, /* stride */
NULL /* pointer */);
glEnableVertexAttribArray(0);
#ifndef DISPLAY
glEnable(GL_RASTERIZER_DISCARD);
#endif
do_query_init(queries, ARRAY_SIZE(queries));
if (!piglit_link_check_status(prog)) {
glDeleteProgram(prog);
piglit_report_result(PIGLIT_FAIL);
}
glUseProgram(prog);
}
示例15: piglit_init
void
piglit_init(int argc, char **argv)
{
char *vsCode;
char *fsCode;
piglit_require_extension("GL_ARB_texture_storage");
piglit_require_extension("GL_ARB_texture_view");
piglit_require_extension("GL_EXT_texture_array");
/* setup shaders and program object for 2DArray rendering */
asprintf(&vsCode,
"void main()\n"
"{\n"
" gl_Position = gl_Vertex;\n"
" gl_TexCoord[0] = gl_MultiTexCoord0;\n"
"}\n");
asprintf(&fsCode,
"#extension GL_EXT_texture_array : enable\n"
"uniform sampler2DArray tex;\n"
"void main()\n"
"{\n"
" vec4 color = texture2DArray(tex, gl_TexCoord[0].xyz);\n"
" gl_FragColor = vec4(color.xyz, 1.0);\n"
"}\n");
prog2Darray = piglit_build_simple_program(vsCode, fsCode);
free(fsCode);
free(vsCode);
tex_loc_2Darray = glGetUniformLocation(prog2Darray, "tex");
}