Ok, here is some of the code that should illustrate what I am doing. Essentially, the two lists are made in a class that only holds data (called DataBank) and is able to return the data when requested.
This method works exactly as it should and is used to draw an X or an O in the view (Tic Tac Toe, if I haven't yet mentioned it):
-(void)drawRect

NSRect)rect
{
glClear(GL_COLOR_BUFFER_BIT);
[self defaultPerspective];
if (![DataBank isWinner])
{
if ([DataBank isPlayer])
{
[self drawX];
glFlush();
return;
}
//if the code has executed this far, it must be an "O"
[self drawO];
}
else
{
//insert code here to handle drawing the isWinner Banner
}
glFlush();
}
and the following code does not work. It is too draw a grid of X's and O's in the view as well as the bars that make up the grid (the bars draw, the pieces do not even though the data is working properly and a debug shows that everything happens as it should):
- (void)drawRect

NSRect)rect
{
int x, y/*used for stepping through Array*/;
//glClear(GL_COLOR_BUFFER_BIT); The next line is a little more powerful
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
[self defaultPerspective];
//right here enter the code for the brackets that make up the board
[self drawBoard];
for(x=0; x <3; x++)
//the game board array will be improved from Tic Tac 2D in the way that it will now be an array of integers to make things a little easier to look at
{
for(y=0;y<3;y++)
{
//code to draw each piece
[self defaultPerspective];
glTranslatef(-0.7f+(x*0.7f), -0.7f+(y*0.7f),0.0f);
switch ((int)[DataBank pieceAt:x with:y])
{
case 1:
{
//piece is X
[self drawX];
}
case 2:
{
//piece is O
[self drawO];
}
default:{} //the piece is blank so just exit
}
}
}
if([DataBank isWinner])
{
//insert code here to overlay the transparent Victory banner
}
glFlush();
}
The drawX and drawO methods are implemented in exactly the same way in both classes:
- (void)drawX
//used to draw X at default location
{
glCallList([DataBank getXList]);
}
- (void)drawO
//used to draw O at default location
{
glCallList([DataBank getOList]);
}
[DataBank getOList] and [DataBank getXList] return types GLuint.
I will post the entire source on my web site some time tonight for people to poke at:
www.indigox.dyndns.org
Thanks for any suggestions,
Jeff.