How to edit a GLKTexture or another OpenGL ES texture pixel-by-pixel

I am trying to implement my own methods for 3D to 2D projection, and I would like to draw on a pixel-by-pixel basis using OpenGL ES. I have started this by creating a simple ViewController that loads a texture and displays it to the screen, just to see if it would work:

https://gist.github.com/doctordoder/9595277

And I noticed that I could change the textureInfo property at any point and the view would respond accordingly. This is nice, but I don’t want to display an image, I want to do some behind-the-scenes math, and be able to just change the texture pixel-by-pixel. I was thinking something like this should be possible:

    for (int i = 0; i < textureInfo.width; i++)
    {
    	for (int j = 0; j < textureInfo.height; j++)
    	{
    		textureInfo.pixels[i][j] = GLKVector3Make(drand48(),
    												  drand48(),
    												  drand48());
    	}
    }

But I don’t see any such property of the textureInfo.

My question is how do I draw pixel by pixel to a texture in OpenGL ES? Or is there a better way to do this?

Both GLES2/3 have a programmable graphics pipeline which include fragment shaders. Fragment shaders allow you to run a kernel that can include a large range of mathematical operations on a per-pixel bases that run on the GPU.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.