zoukankan      html  css  js  c++  java
  • QT_OPENGL-------- 1. WINDOW

    opengl学习第一步,首先来实现一个显示窗口。

    1.首先要下载配置glfw,我在前面的文章中也提到过,具体作用可以另行百度。配置出现无法引用可参考ubuntu 使用glfw.h 出现函数无法调用

    2.构建qt空项目,新建-》Non-Qt Project-》Plain C++ Application-》工程名-》下一步。(创建一个只有一个main.cpp 和.pro文件)

    3.在.pro文件中添加glfw的动态链接

    LIBS+=-L/usr/local/lib -lglfw3 -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor -lGL -lpthread -ldl

    4.添加如下代码到main.cpp中

    #include <GLFW/glfw3.h>
    
    int main(void)
    {
        GLFWwindow* window;
    
        /* Initialize the library */
        if (!glfwInit())
            return -1;
    
        /* Create a windowed mode window and its OpenGL context */
        window = glfwCreateWindow(480, 320, "Hello World", NULL, NULL);
        if (!window)
        {
            glfwTerminate();
            return -1;
        }
    
        /* Make the window's context current */
        glfwMakeContextCurrent(window);
    
        /* Loop until the user closes the window */
        while (!glfwWindowShouldClose(window))
        {
            /* Draw a triangle */
            glBegin(GL_TRIANGLES);
    
            glColor3f(1.0, 0.0, 0.0);    // Red
            glVertex3f(0.0, 1.0, 0.0);
    
            glColor3f(0.0, 1.0, 0.0);    // Green
            glVertex3f(-1.0, -1.0, 0.0);
    
            glColor3f(0.0, 0.0, 1.0);    // Blue
            glVertex3f(1.0, -1.0, 0.0);
    
            glEnd();
    
            /* Swap front and back buffers */
            glfwSwapBuffers(window);
    
            /* Poll for and process events */
            glfwPollEvents();
        }
    
        glfwTerminate();
        return 0;
    }

    最后的效果:

  • 相关阅读:
    储存过程与触发器
    session 和 cookie
    (四)Jira工作流状态的属性
    (三)Jira scriptrunner插件
    (二)JIRA安装
    vs2015 调试无法访问网站的问题
    设计模式
    依赖倒置、反射、泛型、委托、AOP
    C# .NET
    持续集成
  • 原文地址:https://www.cnblogs.com/fuhang/p/10002016.html
Copyright © 2011-2022 走看看