• 13
• 12
• 9
• 10
• 13

# Infinite graph made out of squares.

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

## Recommended Posts

Hi,

So I was wondering how you make an infinitely sized graph and each unit is a square (made with GL_QUADS). I have made a grid in OpenGL (using C++) and have came up with the following:
//Declare varaibles.//This is for rows.int row = 0;//Goes through array NOT for the drawing.int i;//This is for drawing. Because it can be reset with affecting the length of the loop.static int g;for (i = 0; i < 100; i++){	g++;	if (cellActivation == false)	{		glColor3f(1.0f, 1.0f, 1.0f);		glBegin(GL_QUADS);		glVertex3f(g, row, -10);		glVertex3f(g+1, row, -10);		glVertex3f(g+1, row-1, -10);		glVertex3f(g, row-1, -10);		glEnd();	}	else if (cellActivation == true)	{		glColor3f(0.2f, 0.3f, 1.0f);		glBegin(GL_QUADS);		glVertex3f(g, row, -10);		glVertex3f(g+1, row, -10);		glVertex3f(g+1, row-1, -10);		glVertex3f(g, row-1, -10);		glEnd();	}	if(g == 10)	{		row--;	        g = 0;	}}

But, this is not infinite. Is there a way to make it infinite (and I mean make it so it can expand at runtime)?

##### Share on other sites
As a dirty hack...I've not considered it too much. But could you double the size of the your array in each dimension when you reach a certain distance away from it, so it just keeps growing and growing?