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?