64位ubuntu下用code::blocks IDE配置opengl开发环境

http://jingyan.baidu.com/article/c74d60007d104f0f6b595d6d.html

样例程序:

#include <GL/glut.h>

#include <stdlib.h>

void init();

void display();

int main(int argc, char* argv[])

{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);
    glutInitWindowPosition(0, 0);
    glutInitWindowSize(300, 300);
    glutCreateWindow("OpenGL 3D View");
    init();
    glutDisplayFunc(display);
    glutMainLoop();
    return 0;
}

void init()
{
    glClearColor(0.0, 0.0, 0.0, 0.0);
    glMatrixMode(GL_PROJECTION);
    glOrtho(-5, 5, -5, 5, 5, 15);
    glMatrixMode(GL_MODELVIEW);
    gluLookAt(0, 0, 10, 0, 0, 0, 0, 1, 0);
}

void display()
{
    glClear(GL_COLOR_BUFFER_BIT);
    glColor3f(1.0, 0, 0);
    glutWireTeapot(3);
    glFlush();
}

效果:

注:项目开发

开发的时候,新建GLUT工程,在main.cpp里面编写代码即可
新建后,自带有一个openGL的例子

原文地址:https://www.cnblogs.com/moonlightpoet/p/5659255.html