Visual Studio 2017 OpenGL启动速度非常慢

时间:2017-09-25 01:02:49

标签: c++ visual-studio opengl visual-studio-2017

我刚接触学习OpenGL实际上我刚刚开始关注一个名为" learningopengl"的资源,该资源教授如何设置GLFW和GLAD以在Visual Studio 2017上使用OpenGL。但是,我已经注意到,即使只是一个非常基本的程序,只能构建一个空白窗口,可以调整大小(沿着学习材料),它需要视觉工作室一致40秒左右来实际加载程序。它一旦运行就会运行良好,只需要很长时间就可以打开。

我知道这不应该花这么长时间,因为通过我的搜索并查看人们使用这些相同的库/包括他们在那里运行的示例程序时他们立即加载的视频。

我希望我能找出原因。作为参考,我正在运行的示例代码如下所示。

#include <glad/glad.h>
#include <GLFW\glfw3.h>

#include <iostream>

void framebuffer_size_callback(GLFWwindow* window, int width, int height);

int main() {

    // glfw: initialize and configure
    // -----------------------------
    glfwInit();
    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
    glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);

    // glfw window creation
    // --------------------
    GLFWwindow* window = glfwCreateWindow(800, 600, "LearnOpenGL", NULL, NULL);
    if (window == NULL) {
        std::cout << "Failed to create GLFW window" << std::endl;
        glfwTerminate();
        return -1;
    }
    glfwMakeContextCurrent(window);
    glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);

    // glad: load all openGL function pointers
    // ---------------------------------------
    if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) {
        std::cout << "Failed to initialize GLAD" << std::endl;
        return -1;
    }

    // render loop
    // -----------
    while (!glfwWindowShouldClose(window)) {
        // glfw: swap buffers and poll IO events (keys pressed/released, mouse moved etc
        // -----------------------------------------------------------------------------
        glfwSwapBuffers(window);
        glfwPollEvents();
    }

    // glfw: terminate, clearing all perviously allocated glfw recourses
    // -----------------------------------------------------------------
    glfwTerminate();
    return 0;

}

// glfw: whenever the window size is changed (by OS or user resize) this callback function executes
// ------------------------------------------------------------------------------------------------
void framebuffer_size_callback(GLFWwindow* window, int width, int height) {
    // make sure the viewport matches the new window dimensions; note that width and
    // height will be significantly larger then specified on retina displays.
    glViewport(0, 0, width, height);
}

只是一个最终的澄清,我不是说任何一种帧速率都很慢,我的意思是从我告诉visual studio运行项目(Ctrl + f5或运行调试器)到我能看到的时间实际的OpenGL窗口我尝试制作大约需要40秒或更长时间。

此外,当我运行代码时,cmd提示符在其后面运行,我也想知道为什么会发生这种情况,如果有办法阻止它或者由于设置而发生。

0 个答案:

没有答案
相关问题