@Przemyslaw_Trzaska wrote:
I’m trying to display pixels in Checkerboard pattern black and white. I understand that I need to find the end of the row and make offset 1 or 0 for each iteration. So that each time when the first loop ends the second starts with a white pixel or black pixel.
In my case pixels are in the same formation.ofApp.h
ofTexture tex;
unsigned char pixels[200 * 200];
int OffSetX;
int OffSetY;
ofApp.cpp
[b]
void ofApp::setup(){
// fill the pixels array with white pixels
int size = sizeof(pixels) / sizeof(unsigned char);
//int row = (200 * 200) / 2;for (int i = 0; i < size; i ++) { OffSetX = i + 1; for (int j = 0; j < size; j++) { OffSetY= (j + OffSetX)%2; if ((OffSetY+OffSetX) % 2 == 0) { pixels[j] = 255; }else{ pixels[j] = 0; } } } tex.loadData(pixels, 200, 200, GL_LUMINANCE);
}
[/b]
void ofApp::draw(){
tex.draw(20, 20, 800, 800);
}
Posts: 1
Participants: 1