void draw_mbs() { H264Context *h = g_h; GPUH264Context * const g = &h->gpu; MpegEncContext * const s = &h->s; int pic_width = 16*s->mb_width, pic_height = 16*s->mb_height; glClearColor(0,0,0,0); glClear(GL_COLOR_BUFFER_BIT); GLuint refParam; int i; for(i = 0; i < 6; i++) { //g->shaders[i] = createGLSLProgram("shaders/base.vert", "shaders/fullpel.frag"); g->shaders[i] = createGLSLProgram(shaderfiles[i][0], shaderfiles[i][1]); refParam = glGetUniformLocation(g->shaders[i], "dpb"); setupUniformInt(g->shaders[i], pic_width, "tex_width"); setupUniformInt(g->shaders[i], pic_height, "tex_height"); glActiveTexture(GL_TEXTURE1); glBindTexture(tp_3d.texTarget, g->dpb_tex); glUniform1i(refParam, 1); checkGLErrors("Uniform setup"); glCallList(dispList); glFinish(); } }
/** * Initialize vertex array objects, vertex buffer objects, * clear color and depth clear value */ void init(void) { // Points of a triangle. GLfloat points[] = {-1.0f, -0.75f, 0.0f, 1.0f, 0.0f, 0.75f, 0.0f, 1.0f, 1.0f, -0.75f, 0.0f, 1.0f }; #ifndef __APPLE__ // GLEW has trouble supporting the core profile glewExperimental = GL_TRUE; glewInit(); if(!GLEW_ARB_vertex_array_object) { fprintf(stderr, "ARB_vertex_array_object not available.\n"); terminate(EXIT_FAILURE); } #endif _program = createGLSLProgram(_vertexSource, _fragmentSource); // Get the location of the "vertex" attribute in the shader program _vertexLocation = glGetAttribLocation(_program, "vertex"); // Generate a single handle for a vertex array object glGenVertexArrays(1, &_vao); // Generate a handle for a buffer object glGenBuffers(1, &_vertices); // Bind the vertex array object glBindVertexArray(_vao); // Make that vbo the current array buffer. Subsequent array buffer operations // will affect this vbo. glBindBuffer(GL_ARRAY_BUFFER, _vertices); // Set the data for the vbo. glBufferData(GL_ARRAY_BUFFER, // Target buffer object 3 * 4 * sizeof(GLfloat), // Size in bytes of the buffer (GLfloat*) points, // Pointer to the data GL_STATIC_DRAW); // Expected data usage pattern // Enable the vertex attribute array for the currently bound vertex array object glEnableVertexAttribArray(_vertexLocation); // Specify the location and data format of the array of generic vertex attributes glVertexAttribPointer(_vertexLocation, // Attribute location in the shader program 4, // Number of components per attribute GL_FLOAT, // Data type of attribute GL_FALSE, // GL_TRUE: values are normalized or // GL_FALSE: values are converted to fixed point 0, // Stride 0); // Offset into VBO for this data // Set the clear color glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // Set the depth clearing value glClearDepth(1.0f); glBindVertexArray(0); }