A bit of a long question but id be greatful if someone could point me in the right direction.
I have the following code which produces a 64x64 checkerboard grid:
#include <stdlib.h>
#include <GL/glut.h>
#define checkImageWidth 512 //64
#define checkImageHeight 512 //64
GLubyte checkImage[checkImageHeight][checkImageWidth][3];
void makeCheckImage(void)
{
int i,j,c;
for (i = 0; i< checkImageHeight; i++) {
for (j = 0; j< checkImageWidth; j++) {
c = ((((i&0x8)==0)^((j&0x8))==0))*255;
checkImage[i][j][0] = (GLubyte) c;
checkImage[i][j][1] = (GLubyte) c;
checkImage[i][j][2] = (GLubyte) c;
}
}
}
void myinit(void)
{
glClearColor(0.0, 0.0, 0.0, 0.0) ;
glShadeModel(GL_FLAT) ;
makeCheckImage();
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
}
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glutSwapBuffers() ;
glRasterPos2i(-1,-1);
glDrawPixels(checkImageWidth, checkImageHeight, GL_RGB,
GL_UNSIGNED_BYTE, checkImage);
glFlush();
}
int main (int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB );
glutInitWindowSize(513, 513);
glutCreateWindow(“Checkerboard”);
myinit();
glutDisplayFunc(display);
glutMainLoop();
}
My question is, how do i single out one of these squares and assign it a specific colour? What method would do this? I have been trying colorTables but haven’t got it to work yet.
To make it clear why i want individual squares highlighted is because i am trying to model Salmon migration down a river and each square is going to represent a certain number of salmon which will ‘swim’ down the river. For this reason this square that has been assigned a certain color needs to know where the next square is so it can ‘swim’ into it.
Any general comments or specfic answers welcome;
thankyou