我正在尝试绘制图片中的内容。所以我可以绘制随机彩色方块,但是我无法让for循环在图像中绘制方块。
代码:
for (int i =0; i < image.width; i = i+5) {
for (int j = 0; j < image.height; j = j+5) {
//will this for loop give me what's in the image?
//want to incorporate the code below in here. Modifications?
glPushMatrix();
glTranslatef(i, j, 0);
glColor3ub( rand()%255, rand()%255, rand()%255 );
glBegin(GL_QUADS);
glVertex2i(0,0);
glVertex2i(1,0);
glVertex2i(1,1);
glVertex2i(0,1);
glEnd();
glPopMatrix();
}
}
答案 0 :(得分:3)
您甚至没有在循环体中使用i
和j
。尝试用xpos
和ypos
替换那些(无论那些是什么)。