NVIDIA Jetson Xavier - Using OpenGL

From RidgeRun Developer Connection
< Xavier‎ | Processors‎ | GPU
Jump to: navigation, search



Previous: Processors/GPU/CUDA Index Next: Interfaces



Nvidia-preferred-partner-badge-rgb-for-screen.png




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.

Contents

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

Error creating thumbnail: Unable to save thumbnail to destination
Hello World



Previous: Processors/GPU/CUDA Index Next: Interfaces