void MythRenderOpenGL2::DrawBitmapPriv(uint *textures, uint texture_count, const QRectF *src, const QRectF *dst, uint prog) { if (prog && !m_shader_objects.contains(prog)) prog = 0; if (prog == 0) prog = m_shaders[kShaderDefault]; uint first = textures[0]; EnableShaderObject(prog); SetShaderParams(prog, &m_projection[0][0], "u_projection"); SetShaderParams(prog, &m_transforms.top().m[0][0], "u_transform"); SetBlend(false); EnableTextures(first); uint active_tex = 0; for (uint i = 0; i < texture_count; i++) { if (m_textures.contains(textures[i])) { ActiveTexture(GL_TEXTURE0 + active_tex++); glBindTexture(m_textures[textures[i]].m_type, textures[i]); } } m_glBindBuffer(GL_ARRAY_BUFFER, m_textures[first].m_vbo); UpdateTextureVertices(first, src, dst); m_glBufferData(GL_ARRAY_BUFFER, kVertexSize, NULL, GL_STREAM_DRAW); void* target = m_glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY); if (target) memcpy(target, m_textures[first].m_vertex_data, kVertexSize); m_glUnmapBuffer(GL_ARRAY_BUFFER); m_glEnableVertexAttribArray(VERTEX_INDEX); m_glEnableVertexAttribArray(TEXTURE_INDEX); m_glVertexAttribPointer(VERTEX_INDEX, VERTEX_SIZE, GL_FLOAT, GL_FALSE, VERTEX_SIZE * sizeof(GLfloat), (const void *) kVertexOffset); m_glVertexAttrib4f(COLOR_INDEX, 1.0, 1.0, 1.0, 1.0); m_glVertexAttribPointer(TEXTURE_INDEX, TEXTURE_SIZE, GL_FLOAT, GL_FALSE, TEXTURE_SIZE * sizeof(GLfloat), (const void *) kTextureOffset); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); m_glDisableVertexAttribArray(TEXTURE_INDEX); m_glDisableVertexAttribArray(VERTEX_INDEX); m_glBindBuffer(GL_ARRAY_BUFFER, 0); }
void* UIOpenGLTextures::GetTextureBuffer(GLTexture *Texture) { if (!Texture) return NULL; glBindTexture(Texture->m_type, Texture->m_val); if (Texture->m_pbo) { m_glBindBuffer(GL_PIXEL_UNPACK_BUFFER, Texture->m_pbo); m_glBufferData(GL_PIXEL_UNPACK_BUFFER, Texture->m_dataSize, NULL, GL_STREAM_DRAW); return m_glMapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY); } return NULL; }
void MythRenderOpenGL2::DrawBitmapPriv(uint tex, const QRect *src, const QRect *dst, uint prog, int alpha, int red, int green, int blue) { if (prog && !m_shader_objects.contains(prog)) prog = 0; if (prog == 0) prog = m_shaders[kShaderDefault]; EnableShaderObject(prog); SetShaderParams(prog, &m_projection[0][0], "u_projection"); SetShaderParams(prog, &m_transforms.top().m[0][0], "u_transform"); SetBlend(true); EnableTextures(tex); glBindTexture(m_textures[tex].m_type, tex); m_glBindBuffer(GL_ARRAY_BUFFER, m_textures[tex].m_vbo); UpdateTextureVertices(tex, src, dst); m_glBufferData(GL_ARRAY_BUFFER, kVertexSize, NULL, GL_STREAM_DRAW); void* target = m_glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY); if (target) memcpy(target, m_textures[tex].m_vertex_data, kVertexSize); m_glUnmapBuffer(GL_ARRAY_BUFFER); m_glEnableVertexAttribArray(VERTEX_INDEX); m_glEnableVertexAttribArray(TEXTURE_INDEX); m_glVertexAttribPointer(VERTEX_INDEX, VERTEX_SIZE, GL_FLOAT, GL_FALSE, VERTEX_SIZE * sizeof(GLfloat), (const void *) kVertexOffset); m_glVertexAttrib4f(COLOR_INDEX, red / 255.0, green / 255.0, blue / 255.0, alpha / 255.0); m_glVertexAttribPointer(TEXTURE_INDEX, TEXTURE_SIZE, GL_FLOAT, GL_FALSE, TEXTURE_SIZE * sizeof(GLfloat), (const void *) kTextureOffset); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); m_glDisableVertexAttribArray(TEXTURE_INDEX); m_glDisableVertexAttribArray(VERTEX_INDEX); m_glBindBuffer(GL_ARRAY_BUFFER, 0); }