本文整理汇总了C++中Evas_GL_API::glLinkProgram方法的典型用法代码示例。如果您正苦于以下问题:C++ Evas_GL_API::glLinkProgram方法的具体用法?C++ Evas_GL_API::glLinkProgram怎么用?C++ Evas_GL_API::glLinkProgram使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Evas_GL_API
的用法示例。
在下文中一共展示了Evas_GL_API::glLinkProgram方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
// Initialize the shader and program object
static int
init_shaders(GLData *gld)
{
Evas_GL_API *gl = gld->glapi;
GLbyte vShaderStr[] =
"attribute vec4 vPosition; \n"
"void main() \n"
"{ \n"
" gl_Position = vPosition; \n"
"} \n";
GLbyte fShaderStr[] =
"#ifdef GL_ES \n"
"precision mediump float; \n"
"#endif \n"
"void main() \n"
"{ \n"
" gl_FragColor = vec4 ( 1.0, 0.0, 0.0, 1.0 );\n"
"} \n";
GLint linked;
// Load the vertex/fragment shaders
gld->vtx_shader = load_shader(gld, GL_VERTEX_SHADER, (const char*)vShaderStr);
gld->fgmt_shader = load_shader(gld, GL_FRAGMENT_SHADER, (const char*)fShaderStr);
// Create the program object
gld->program = gl->glCreateProgram( );
if (0 == gld->program)
return 0;
gl->glAttachShader(gld->program, gld->vtx_shader);
gl->glAttachShader(gld->program, gld->fgmt_shader);
gl->glBindAttribLocation(gld->program, 0, "vPosition");
gl->glLinkProgram(gld->program);
gl->glGetProgramiv(gld->program, GL_LINK_STATUS, &linked);
if (!linked)
{
GLint info_len = 0;
gl->glGetProgramiv(gld->program, GL_INFO_LOG_LENGTH, &info_len);
if (1 < info_len)
{
char* info_log = malloc(sizeof(char) * info_len);
gl->glGetProgramInfoLog(gld->program, info_len, NULL, info_log);
_printf("Error linking program:\n%s\n", info_log);
free(info_log);
g_assert(FALSE);
}
gl->glDeleteProgram(gld->program);
return 0;
}
return 1;
}
示例2: printf
static void
gears_init(GLData *gld)
{
Evas_GL_API *gl = gld->glapi;
const char *p;
char msg[512];
gl->glEnable(GL_CULL_FACE);
gl->glEnable(GL_DEPTH_TEST);
p = vertex_shader;
gld->vtx_shader = gl->glCreateShader(GL_VERTEX_SHADER);
gl->glShaderSource(gld->vtx_shader, 1, &p, NULL);
gl->glCompileShader(gld->vtx_shader);
gl->glGetShaderInfoLog(gld->vtx_shader, sizeof msg, NULL, msg);
printf("vertex shader info: %s\n", msg);
p = fragment_shader;
gld->fgmt_shader = gl->glCreateShader(GL_FRAGMENT_SHADER);
gl->glShaderSource(gld->fgmt_shader, 1, &p, NULL);
gl->glCompileShader(gld->fgmt_shader);
gl->glGetShaderInfoLog(gld->fgmt_shader, sizeof msg, NULL, msg);
printf("fragment shader info: %s\n", msg);
gld->program = gl->glCreateProgram();
gl->glAttachShader(gld->program, gld->vtx_shader);
gl->glAttachShader(gld->program, gld->fgmt_shader);
gl->glBindAttribLocation(gld->program, 0, "position");
gl->glBindAttribLocation(gld->program, 1, "normal");
gl->glLinkProgram(gld->program);
gl->glGetProgramInfoLog(gld->program, sizeof msg, NULL, msg);
printf("info: %s\n", msg);
gl->glUseProgram(gld->program);
gld->proj_location = gl->glGetUniformLocation(gld->program, "proj");
gld->light_location = gl->glGetUniformLocation(gld->program, "light");
gld->color_location = gl->glGetUniformLocation(gld->program, "color");
/* make the gears */
gld->gear1 = make_gear(gld, 1.0, 4.0, 1.0, 20, 0.7);
gld->gear2 = make_gear(gld, 0.5, 2.0, 2.0, 10, 0.7);
gld->gear3 = make_gear(gld, 1.3, 2.0, 0.5, 10, 0.7);
}