| 369 | } |
| 370 | |
| 371 | static void DrawQuad(void) |
| 372 | { |
| 373 | const char *vssrc = |
| 374 | "varying mediump vec2 texCoord;\n" |
| 375 | "attribute vec2 inPosition;\n" |
| 376 | "void main() {\n" |
| 377 | " texCoord = vec2((inPosition.x+1.0)/2.0, (inPosition.y+1.0)/2.0);\n" |
| 378 | " gl_Position = vec4(inPosition.x, inPosition.y, 0.0, 1.0);\n" |
| 379 | "}\n"; |
| 380 | const char *fssrc = |
| 381 | "uniform sampler2D tex;\n" |
| 382 | "varying mediump vec2 texCoord;\n" |
| 383 | "void main() {\n" |
| 384 | " gl_FragColor = texture2D(tex, texCoord);\n" |
| 385 | "}\n"; |
| 386 | GLuint vs, fs, program; |
| 387 | GLuint positionIdx = 0; |
| 388 | GLfloat x1 = -1.0f, x2 = 1.0f, y1 = -1.0f, y2 = 1.0f; |
| 389 | GLfloat vertices[4][2]; |
| 390 | vertices[0][0] = x1; vertices[0][1] = y1; |
| 391 | vertices[1][0] = x2; vertices[1][1] = y1; |
| 392 | vertices[2][0] = x1; vertices[2][1] = y2; |
| 393 | vertices[3][0] = x2; vertices[3][1] = y2; |
| 394 | |
| 395 | vs = glCreateShader(GL_VERTEX_SHADER); |
| 396 | fs = glCreateShader(GL_FRAGMENT_SHADER); |
| 397 | |
| 398 | glShaderSource(vs, 1, &vssrc, NULL); |
| 399 | glShaderSource(fs, 1, &fssrc, NULL); |
| 400 | |
| 401 | glCompileShader(vs); |
| 402 | glCompileShader(fs); |
| 403 | |
| 404 | program = glCreateProgram(); |
| 405 | glAttachShader(program, vs); |
| 406 | glAttachShader(program, fs); |
| 407 | glLinkProgram(program); |
| 408 | glUseProgram(program); |
| 409 | |
| 410 | positionIdx = glGetAttribLocation(program, "inPosition"); |
| 411 | glEnableVertexAttribArray(positionIdx); |
| 412 | glVertexAttribPointer(positionIdx, 2, GL_FLOAT, GL_FALSE, 0, vertices); |
| 413 | glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); |
| 414 | |
| 415 | glUseProgram(0); |
| 416 | glDeleteProgram(program); |
| 417 | glDeleteShader(vs); |
| 418 | glDeleteShader(fs); |
| 419 | } |
| 420 | |
| 421 | void * CreateGLRenderbuffer( GLsizei width, GLsizei height, |
| 422 | GLenum attachment, |
no outgoing calls
no test coverage detected