1. Install the OpenGL development package:
sudo apt-get install freeglut3-dev
or
// Similar changes can be applied to drawTriangle and drawRectangle>sudo yum install freeglut-devel
2. Install the GLUT library:
sudo apt-get install libglut-dev
or
sudo yum install glut
1. Compile the program:
g++ -o program program.cpp -lGL -lGLU -lglut
Replace program.cpp
with the name of your OpenGL program.
2. Run the program:
./program
Verify OpenGL installation:
glxinfo | grep OpenGL
This command will display information about your OpenGL installation.
Troubleshooting:
- If you encounter issues with OpenGL not being recognized, try reinstalling the necessary packages.
- If you encounter issues with the program not running, check for any syntax errors in your code.
#include
void display() {
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_TRIANGLES);
glVertex2f(-0.5, -0.5);
glVertex2f(0.5, -0.5);
glVertex2f(0, 0.5);
glEnd();
glutSwapBuffers();
}
int main(int argc, char** argv) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
glutInitWindowSize(640, 480);
glutCreateWindow("OpenGL Example");
glutDisplayFunc(display);
glutMainLoop();
return 0;
}
References
License
This README file is licensed under the MIT License.