glBegin problem

Started by
2 comments, last by neonoblivion 21 years, 10 months ago
I''m trying to use a map structure to keep track of my polygons for my scene. This is my loop I dont care about the logic yet, but it gives me an illegal action and fries.
  
//definitions

typedef struct ver{
float x,y,z,u,v;
} ver;

typedef struct poly{
	int numver;
	ver vers[10];
	int tex;
} poly;




typedef struct tile{
	int numpolys;
	poly polys[10];
} tile;




tile tiles[20];

int maph=50,mapw=50;


int map[50][50]={0};





///loop


for(int y;y<maph;y++){
		for(int x=0;x<mapw;x++){
			for(int index=0;index<tiles[map[y][x]].numpolys;index++){
				glBindTexture(GL_TEXTURE_2D,
					texture[tiles[map[y][x]].polys[index].tex]);
		
				glBegin(GL_POLYGON);
					for(int index2;index2<tiles[map[y][x]].polys[index2].numver;index2++){
						
						glTexCoord2f(tiles[map[y][x]].polys[index].vers[index2].u,
									 tiles[map[y][x]].polys[index].vers[index2].v);
						
						glVertex3f(tiles[map[y][x]].polys[index].vers[index2].x,
								   tiles[map[y][x]].polys[index].vers[index2].y,
					               tiles[map[y][x]].polys[index].vers[index2].z);
					}
				glEnd();	
			}
		}
	
	}


  
thanks in advance, Klaus
Advertisement
Where does it give ''illegal action''? Does it compile/link with no errors? Do you initialize all the data correctly?

You might want to check that you actually initialize map[][] to all 0''s if that''s what you mean because

map[50][50] = {0 };

won''t necessarily initialize the entire map to 0, do something like

memset(map,0,sizeof(int)*50*50);

or use some loops.

You really need to specify the problem more before you get meaningful answers.
move your glBegin(GL_POLYGON) into your for loop like this

for(loop)
{
glBegin(GL_POLYGON);
Draw Object-----
glEnd();
}

[edited by - Advinus on June 14, 2002 1:50:26 PM]
> for(int index2;index2
is the error an access violation?
then try:
for(int index2 = 0;index2

This topic is closed to new replies.

Advertisement