PDA

View Full Version : Creating grid and nodes



philm0
04-06-2016, 05:38 PM
Hello everyone,

I have been attempting to create an infinite grid space for my program. It is a FEM simulation program.

For a grid, yes, I can simply create a for loop and call glVertex2f. But what if I would like to create an infinite grid space. I could create a for loop that goes up to 1 mil but that would take forever. Could I dynamically create the grid as the user "moves" through the space?

Also, I will be coding in openGL 2.1 for a widespread device support.

philm0
04-06-2016, 07:17 PM
Hello everyone,

I have been attempting to create an infinite grid space for my program. It is a FEM simulation program.

For a grid, yes, I can simply create a for loop and call glVertex2f. But what if I would like to create an infinite grid space. I could create a for loop that goes up to 1 mil but that would take forever. Could I dynamically create the grid as the user "moves" through the space?

Also, I will be coding in openGL 2.1 for a widespread device support.

Ok, so I was thinking about for a little bit and so far I have come up with everytime I translate my view, I will just redraw the entire screen to give the appearance of an infinite grid.

Thoughts on this idea?

philm0
04-08-2016, 08:12 AM
Ok, so I have been thinking about this for a little while and I came up with some code which nothing happens. To me, it should be working. This is what I thought. Is there a better way of doing this?



void geometryEditorCanvas::drawGrid()
{
// Clears the color buffer
glClear(GL_COLOR_BUFFER_BIT);

//Reset to modelview matrix
glMatrixMode(GL_MODELVIEW);
glPopMatrix();

for(double i = 0; i < factor; i++)
{
for(double j = 0; j < factor; j++)
{
glBegin(GL_POINTS);
glVertex2d(j * coordinateFactorWidth, i * coordinateFactorHeight);
glEnd();
}
}
}


Please, any help would be appreciated