Archived

This topic is now archived and is closed to further replies.

neonoblivion

glBegin problem

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites