mercredi 25 novembre 2020

grid not showing at all when I try to on it

I am trying to make an option pop-up menu to be able to choose if I want the grid on or off as an option to add to the game I am trying to make. I have been able to display the pop-up menu which has two options called "grid on" and "grid off", however when I click on it, the grid doesn't show at all for me which I am struggling to do.

void myGrid(GLint i) {
glEnable(GL_LINE_STIPPLE); //Activates the line-style feature

glLineStipple(1, 0xAAAA);  // Plots a dashed polyline

glColor3f(0.8, 0.8, 0.8);

glBegin(GL_LINES);
for (i = 2; i <= 9; i++)
{
    glVertex3f(i * 0.1 * w, 0.0, 0.0);
    glVertex3f(i * 0.1 * w, 0.9 * h, 0.0);
}

for (i = 1; i <= 9; i++)
{
    glVertex3f(0.1 * w, i * 0.1 * h, 0.0);
    glVertex3f(w, i * 0.1 * h, 0.0);
}
glEnd();
glDisable(GL_LINE_STIPPLE);
}

int main(int argc, char* argv[])//standard c entry signature
{
//cout << "Player Controls:\n Up Key - move forward\n Down Key - move backward\n Left/Right key - move left or right\n R/r - rotate";
/* window management code ... */
/* initialises GLUT and processes any command line arguments */
glutInit(&argc, argv);
/* use double-buffered window and RGBA colour model */
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA);
/* window width = 400 pixels, height = 400 pixels */
glutInitWindowSize(500, 500);
/* window upper left corner at (100, 100) */
glutInitWindowPosition(100, 100);
/* creates an OpenGL window and set its title bar*/
glutCreateWindow("Coursework 1");
init();

glutDisplayFunc(display);

//glutKeyboardFunc(keyboard);
//glutSpecialFunc(specialKeys);
//  glutSpecialUpFunc(keyGoneUp);

glutReshapeFunc(reshape);

//Create a grid turning it on and off
glutCreateMenu(myGrid);

glutAddMenuEntry("Grid on", 1);
glutAddMenuEntry("Grid off", 2);
glutAttachMenu(GLUT_RIGHT_BUTTON);
//  SetupRC();
glutIdleFunc(IdleFunc);
glutMainLoop();

return 0;
}

Aucun commentaire:

Enregistrer un commentaire