Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>So... in the end I did what other people had to do and wrote my own version of GLKBaseEffect. </p> <p>It's fiddly but it's not THAT hard, took about a day. There are tutorials out there but none offered exactly what I needed. In the end I used the OGL default project as my starting point as that gave me the framework - compiling and running shaders and all that, even though it wasn't doing what I wanted. </p> <p>Here is the gist of what I did. It took a lot of iterations to get working...</p> <ol> <li>Remove all GLKBaseEffect from the default OGL project (one cube is drawn with GLKBaseEffect but the other is with shaders)</li> <li>Change projection Matrix to be GLKMatrix4MakeOrtho.</li> <li>Change vertices from Cube to 2D. Get it working.</li> <li>Add textures.</li> <li>Get it all working.</li> <li>Move all OGL code into an OpenGLHelper Class.</li> <li>Move code into my project and replace all GLKEffects with my new class</li> </ol> <p>The end result may not be the best code, but it works, and there are no leaks any more.</p> <p>Here are my shaders </p> <pre><code>// FRAGMENT SHADER ////////////// precision mediump float; varying lowp vec2 texCoordOut; uniform sampler2D textureUniform; uniform float alphaUniform; uniform lowp vec4 colorUniform; void main() { vec4 color = colorUniform * texture2D(textureUniform, texCoordOut); ; gl_FragColor = color; } // VERTEX SHADER //////////////////// attribute vec4 position; uniform mat4 projection; uniform mat4 modelView; attribute vec2 texCoordIn; varying vec2 texCoordOut; void main() { gl_Position = projection * modelView * position; texCoordOut = texCoordIn; } </code></pre> <p>I'd happily share the rest of the code but there's a bit much of it to put in here!</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. 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.
 

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