Jump to content
  • Advertisement

Archived

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

neonoblivion

glBegin problem

This topic is 5853 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
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.

Share this post


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

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!