Creating a grid

Hi, I am doing a student project and I am doing a little “game” in Visual Studio with C++. I would like to create a grid surface up and down a spaceship. I tried the code below and it works.


void Grid::render() {
	glPushMatrix();
	glBegin(GL_LINES);
	glColor3f(1.0f, 1.0f, 1.0f);
	glTranslatef(100.0f, 100.0f, 100.0f);
	for (int i = -size; i <= size; i++)
	{
		glVertex3f((float)i, 0, (float)-size);
		glVertex3f((float)i, 0, (float)size);

		glVertex3f((float)-size, 0, (float)i);
		glVertex3f((float)size, 0, (float)i);
	}
	glEnd();
	glPopMatrix();
}

I would like to move the grid. Modify the grid position, but I don’t know how. What instruction should I use and how? I tried to upload a picture in case I haven’t explained myself properly, but for some reason I can’t do it. I expect I have explained correctly.

Thanks in advance!

glTranslatef is not legal between glBegin and glEnd calls. Please see the documentation:

Errors
GL_INVALID_OPERATION is generated if glTranslate is executed between the execution of glBegin and the corresponding execution of glEnd.
Fix that and you will find that, using old-style OpenGL as you are, glTranslatef is one appropriate way of moving the grid.

Okey, I solved the problem. Thank you!