天天看點

mesa(OpenGL)安裝環境:

Mesa是一個類OpenGL(http://www.opengl.org)的開源實作

環境:

centos 7

安裝方法1:

步驟

問題及解決:

在“./configure“時報告以下錯誤:

Requested ‘libdrm_intel >= 2.4.61’ but version of libdrm_intel is 2.4.60

解決方法:安裝libdrm更高版本,找到這個程式的pc檔案,在控制台添加其路徑:

export PKG_CONFIG_PATH=/usr/lib/pkgconfig

安裝方法2:

yum install mesa*

yum install glut

安裝測試:

檢視是否支援3D渲染:

glxinfo |grep rendering

檢視glx的安裝資訊:

glxinfo |grep “OpenGL vendor”

glxinfo |grep “OpenGL version”

/*
 *  As a first example of using OpenGL in C, this program draws the
 *  classic red/green/blue triangle.  It uses the default OpenGL
 *  coordinate system, in which x, y, and z are limited to the range
 *  - to , and the positive z-axis points into the screen.  Note
 *  that this coordinate system is hardly ever used in practice.
 *
 *  When compiling this program, you must link it to the OpenGL library
 *  and to the glut library. For example, in Linux using the gcc compiler,
 *  it can be compiled with the command:
 *
 *          gcc -o first-triangle first-triangle.c -lGL -lglut
 */

#include <GL/gl.h>
#include <GL/glut.h>   // freeglut.h might be a better alternative, if available.


void display() {  // Display function will draw the image.

    glClearColor( , , ,  );  // (In fact, this is the default.)
    glClear( GL_COLOR_BUFFER_BIT );

    glBegin(GL_TRIANGLES);
    glColor3f( , ,  ); // red
    glVertex2f( -, - );
    glColor3f( , ,  ); // green
    glVertex2f( , - );
    glColor3f( , ,  ); // blue
    glVertex2f( ,  );
    glEnd();

    glutSwapBuffers(); // Required to copy color buffer onto the screen.

}


int main( int argc, char** argv ) {  // Initialize GLUT and

    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_SINGLE);    // Use single color buffer and no depth buffer.
    glutInitWindowSize(,);         // Size of display area, in pixels.
    glutInitWindowPosition(,);     // Location of window in screen coordinates.
    glutCreateWindow("GL RGB Triangle Setup Test"); // Parameter is window title.
    glutDisplayFunc(display);            // Called when the window needs to be redrawn.

    glutMainLoop(); // Run the event loop!  This function does not return.
                    // Program ends when user closes the window.
    return ;

}

           

繼續閱讀