Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I show how to display an image as a texture in OpenGL ES 2.0 on the iPhone in <a href="http://www.sunsetlakesoftware.com/sites/default/files/ColorTracking.zip" rel="nofollow">this example</a>, where the image is a frame of video from the camera, and <a href="http://www.sunsetlakesoftware.com/sites/default/files/CubeExample.zip" rel="nofollow">this example</a>, where I pull in a PVR-compressed texture as an image. The former example is described in the writeup <a href="http://www.sunsetlakesoftware.com/2010/10/22/gpu-accelerated-video-processing-mac-and-ios" rel="nofollow">here</a>.</p> <p>I describe how the vertex and fragment shaders work, along with all the supporting code for them, in the video for the OpenGL ES 2.0 class which is part of my freely available iOS development course <a href="http://deimos.apple.com/WebObjects/Core.woa/Browse/matcmadison.edu.3989485784.04638434143" rel="nofollow">on iTunes U</a>. Additionally, I highly recommend you read Jeff LaMarche's <a href="http://iphonedevelopment.blogspot.com/search/label/Book%20project" rel="nofollow">series of posted chapters</a> from his unpublished OpenGL ES 2.0 book.</p> <p>In short, once you have the texture loaded in, you'll need to attach it as a uniform to your shader program using code like the following:</p> <pre><code>glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, myTexture); glUniform1i(myTextureUniform, 0); </code></pre> <p>Within your fragment shader, you'll need to define the texture uniform:</p> <pre><code>uniform sampler2D myTexture; </code></pre> <p>and then sample the color from the texture at the appropriate point:</p> <pre><code>gl_FragColor = texture2D(myTexture, textureCoordinate); </code></pre> <p>Again, I go into this in more detail within my class, and you can use these examples as starting points to work from.</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.
 

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