Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > glCallList problems

glCallList problems
Thread Tools
Dedicated MacNNer
Join Date: Jun 2000
Location: Dundas, Ontario, Canada
Status: Offline
Reply With Quote
Apr 2, 2001, 12:57 PM
 
Hello,

I have been having trouble using glCallList and I am unable to figure out what the logical cause of the problem might be. In one class I generate two Lists (it is a simple Tic Tac Toe so they are X and O). I then have two other classes (OpenGLViews - one for the game grid and another that displays the current player as either X or O) that try to call the list whenever they have to draw one of the shapes. Although I am calling the lists in exactly the same way, one of the views doesn't draw the shape while the other one does (the current player view does, the grid does not). Since I can see no difference in the way things are being handled yet I do see a difference in the outcome I was hoping that someone here might be able to help (I have worked at it for days and it won't work). Other information that might be of note is that in the view where it refuses to draw (the grid) I already have objects drawn (the grid itself) while the other (current player view) does not.
I am at a loss with this one so any ideas would be appreciated.
Jeff.
Spectral Class
"Shedding Light on Innovation"
     
Fresh-Faced Recruit
Join Date: Mar 2001
Location: baltimore, md 21202
Status: Offline
Reply With Quote
Apr 3, 2001, 04:41 PM
 
Hi,

It's hard to figure out your problem without seeing some code. Hmm.. are you re-drawing the view after you call the list??

David
dstys
     
Dedicated MacNNer
Join Date: Jun 2000
Location: Dundas, Ontario, Canada
Status: Offline
Reply With Quote
Apr 3, 2001, 07:39 PM
 
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.
Spectral Class
"Shedding Light on Innovation"
     
Dedicated MacNNer
Join Date: Jun 2000
Location: Dundas, Ontario, Canada
Status: Offline
Reply With Quote
Apr 3, 2001, 07:47 PM
 
ok, it is on my site for anyone interested right here:
www.indigox.dyndns.org/tictac3dsource/

(Damn UBB!)
Spectral Class
"Shedding Light on Innovation"
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 02:52 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2