NVIDIA Jetson Xavier - Using OpenGL
(Redirected from Xavier/GPU/Sotware Support/OPENGL)
OpenGL is an API for rendering 2D and 3D vector graphics. The API is typically used to interact with a graphics processing unit (GPU), to achieve hardware-accelerated rendering.
Hello World
1. Create a file main.cpp and paste the code.
#include <GL/glut.h>
void displayMe(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_POLYGON);
glVertex3f(0.0, 0.0, 0.0);
glVertex3f(0.5, 0.0, 0.0);
glVertex3f(0.5, 0.5, 0.0);
glVertex3f(0.0, 0.5, 0.0);
glEnd();
glFlush();
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE);
glutInitWindowSize(300, 300);
glutInitWindowPosition(100, 100);
glutCreateWindow("Hello world :D");
glutDisplayFunc(displayMe);
glutMainLoop();
return 0;
}
2. In the command line go to the path where is the file and run the next command.
g++ main.cpp -o HelloWorld -lGL -lGLU -lglut
3. Run the binary
./HelloWorld
4. Resulting screen
