Floating point texture issue

Here is how I use and upload the texture to OpenGL.
http://pastebin.com/GGjNGhhq


val colData = Array.tabulate(rows, cols)((i, j) => {
      //val depth = fbm(i, j)
      //val c = getSubSpriteData(depth)._3
      val tc = if (((i&8)==0)^((j&8)==0)) List(1.0f, 1.0f, 1.0f)  else List(0.0f, 0.0f, 0.0f)
      tc
}).flatMap(arr => arr.flatMap(l => l)).array

tileColours = new DataGL(colData, rows, cols, 3, 2)

Distortion:
http://postimg.org/image/46lthwo3z/

This does not occur if I throw my data into an image and then upload it.

Now, if I save this result as an image and upload that to my GPU it works perfectly. However I would rather directly upload data to the GPU than encode it into an image and upload that.

The shader simply does a UV mapping like so:


vec2 getUV() {
    vec2 uv = gl_FragCoord.xy/viewport;
    uv.y = 1. - uv.y;
    return uv;
}

vec3 col = texture2D(subspriteColours, getUV()).rgb;

I should add that I am not using PO2 dimensions, which strangely enough work without issue. The data stored is a dimension of (120, 45), however I can save the non-po2 data as a non-po2 image and load that perfectly. The issue is purely when uploading the above data (or any, but this example shows the problem perfectly), I have tried other RGB modes as well, but the issue persists, which leads me to believe a possible driver issue.

I have come back to the problem and it was trivial, and yet silly. I needed to transpose the data I uploaded. OpenGL textures are uploaded in column order, and not row order. If your data is in row order then simply transpose it.

The solution was obvious after I noticed certain patterns, then I though there might be some funny rotation issues. Uploaded a 3x3 texture and compared it to the image I was generating and noticed it immediately.


val colourData = Array.tabulate(rows, cols)((i, j) => {
      val depth = fbm(i, j)
      val c = getSubSpriteData(depth)._3
      imgColData.setRGB(i, j, new Color(c(0), c(1), c(2)).getRGB)
      List(c(0), c(1), c(2), 0.0f)
    }).transpose.flatten.flatten.array