Advertisement
Guest User

Untitled

a guest
Dec 4th, 2012
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. diff --git a/gfx/gl.c b/gfx/gl.c
  2. index bccfd63..1a30613 100644
  3. --- a/gfx/gl.c
  4. +++ b/gfx/gl.c
  5. @@ -997,13 +997,16 @@ static inline void gl_copy_frame(gl_t *gl, const void *frame, unsigned width, un
  6. }
  7. else // Slower path.
  8. {
  9. + uint8_t *fbuf = malloc(width * height * 2); // Allocate buffer once and reuse it
  10. const uint8_t *src = (const uint8_t*)frame;
  11. for (unsigned h = 0; h < height; h++, src += pitch)
  12. - {
  13. - glTexSubImage2D(GL_TEXTURE_2D,
  14. - 0, 0, h, width, 1, gl->texture_type,
  15. - gl->texture_fmt, src);
  16. - }
  17. + memcpy(&fbuf[h * (width * 2)], src, width * 2);
  18. +
  19. + glTexSubImage2D(GL_TEXTURE_2D,
  20. + 0, 0, 0, width, height, gl->texture_type,
  21. + gl->texture_fmt, fbuf);
  22. +
  23. + free(fbuf);
  24. }
  25. }
  26. #else
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement