Skip to content

Latest commit

 

History

History
79 lines (72 loc) · 5.73 KB

README.md

File metadata and controls

79 lines (72 loc) · 5.73 KB

Hello Every One

let's start with Cpp in Linux with Cmake and using Codelite text editer.

<title>Running OpenGL in Linux</title>

Running OpenGL in Linux

Step 1: Install the necessary packages

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

Step 2: Compile and Run the OpenGL Program

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

Additional Tips

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.

Example 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.