Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>One way that springs to mind is to draw the pixels of your frame into a texture and then render that texture using OpenGL.</p> <p>I wrote a blog post a while back on how to go about this, primarily for old-skool pixel-based video games, but it also applies for your situation. The post is <a href="http://quirkygba.blogspot.com/2010/10/android-native-coding-in-c.html" rel="noreferrer">Android Native Coding in C</a>, and I set up a <a href="https://github.com/richq/glbuffer" rel="noreferrer">github repository with an example</a>. Using this technique I have been able to get 60 FPS, even on first generation hardware.</p> <p><strong>EDIT</strong> regarding glTexImage2D vs glTexSubImage2D for this approach.</p> <p>Calling glTexImage2D will allocate video memory for your texture and copy the pixels you pass it into that memory (if you don't pass NULL). Calling glTexSubImage2D will update the pixels you specify in an already-allocated texture.</p> <p>If you update <em>all</em> of the texture then there's little difference calling one or the other, in fact glTexImage2D is usually faster. But if you only update part of the texture glTexSubImage2D wins out on speed.</p> <p>You have to use power-of-2 texture sizes, so in covering the screen on hi-res devices requires a 1024x512 texture, and a 512x512 texture on medium resolutions. The texture is larger than the screen area (hi-res is 800x400-ish), which means you only need to update part of it, so glTexSubImage2D is the way to go.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. COThanks for your response! Ya know it's funny I came accross your blog a while back and I used that as a base for my app haha. I haven't been able to find it again until now so thank you for letting me know! Right now I finally got something to appear on the screen but the pixels seem to be totally messed up. I am not sure if I am creating my rectangular texture correctly or if it is a problem converting to the correct RGB pixel format in FFmpeg. I wish there were more OpenGL ES documentation as it is pretty easy to do this with quads in OpenGL. Any tips?
      singulars
    2. COYou can use a quad with a texture on it. Just use `glOrthof` and set your vertex and texture coordinates, all as you would in regular OpenGL. Messed up pixels is a vague description: are they completely indecipherable? Too green or too red? Maybe they're sheared to the left? My advice: get the code working on the PC using the subset of OpenGL that overlaps with GLES, then compile the exact same code to Android. It's what I usually do.
      singulars
    3. COOk thank you for the information. Sorry what I meant by messed up pixels are that yea they are indecipherable. In FFmpeg you have to use a function sws_scale to transform the pixel format to RGG, but as for the OpenGL side I am still learning how to use it and I'm not quite sure if I converted to the right pixel format or if I set up my rectangular vertices and texture coordinates correctly. Also since I am looping through each frame should be be using glTexSubImage2d() or continue using glTexImage2d() to replace the current texture with my new texture data from the new frame?
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload