PDA

View Full Version : help plz



chign
04-03-2010, 09:38 AM
hello.. i have written the code below for the display func..

void display()
{
char x[6][14]={ {'1','1','3','4','-','1','3','1','1','1','1','1','1','1'},
{'1','1','1','4','-','1','3','1','1','1','1','1','1','1'},
{'1','1','3','4','-','1','3','1','1','1','1','1','1','1'},
{'1','1','3','1','-','4','3','1','2','1','1','1','1','1'},
{'1','1','3','3','-','4','3','1','1','1','1','1','1','1'},
{'1','1','3','1','-','1','3','1','2','1','1','1','1','1'}
};
int i,j;
GLsizei temp1=0,temp2=0,cnt1,cnt2;
glClearColor(1,1,1,0);
glClear(GL_COLOR_BUFFER_BIT);
cnt1=(2*xwmax/AR_GRAM);
cnt2=(2*ywmax/AR_STIL);
//προσπελα&# 963;η του πινακα
for (i=0;i<AR_GRAM;i++) {
for (j=0;j<AR_STIL;j++) {
if (x[i][j]='*') {
glColor3f(1,0,0);
glBegin(GL_POLYGON);
glVertex2i(temp1,temp2+cnt2);
glVertex2i(temp1,temp2);
glVertex2i(temp1,temp1+cnt1);
glVertex2i(temp1+cnt1,temp2+cnt2);
glEnd();
}
else if (x[i][j]='2'){
glColor3f(0,1,0);
glBegin(GL_POLYGON);
glVertex2i(temp1,temp2+cnt2);
glVertex2i(temp1,temp2);
glVertex2i(temp1,temp1+cnt1);
glVertex2i(temp1+cnt1,temp2+cnt2);
glEnd();
}
temp1=temp1+cnt1;
temp2=temp2+cnt2;
}
}
}
the problem is that the result is the same, independent of the array.. i cannot find the problem though..
any ideas..?
thanks..

ZbuffeR
04-03-2010, 11:04 AM
= is an affectation, not a boolean test.
try == instead.

chign
04-03-2010, 11:49 AM
thanks..
i 've changed it and now the programm runs but i do not see anything in the window.. i mean i just see the frame of the window, not even a blank window,only the frame.. is it because my programma takes so much time to run?? or sth else??

ZbuffeR
04-03-2010, 02:16 PM
You should :
- learn more about C:
If all terms are integer, C division gives an integer result too, which is often annoying, that may be your case here :
2*xwmax/AR_GRAM
try instead with :
2.0*xwmax/AR_GRAM

- start from a working "Your First Polygon" tutorial, then adapt it little by little to your needs. That will avoid you struggling with finding correct projection coordinates.
http://nehe.gamedev.net/lesson.asp?index=01