在全屏模式下尝试切换到另一个应用程序时,GLFW崩溃了吗?

我正在运行Windows 10,并且在visual Studio 2019中有一个c ++ openGl项目。问题出在应用程序本身的窗口。如果我将应用程序设置为通过GLFW(无论是否带窗口)在全屏模式下运行,则无法按alt-tab或windows或其他任何按钮来进入另一个应用程序。如果我确实按下这些键之一,整个事情就会崩溃。

崩溃是什么样的:

在全屏模式下尝试切换到另一个应用程序时,GLFW崩溃了吗?

注意控制台中的奇怪错误,它似乎是任意的。 我尝试重新安装GLFW,将应用程序构建为独立的exe,将全屏模式更改为窗口模式,并查看控制台错误(我不知道它的相关性)。这是窗口创建代码:

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

// glfw window creation
GLFWmonitor* monitor = glfwGetPrimaryMonitor();

const GLFWvidmode* mode = glfwGetVideoMode(monitor);
glfwWindowHint(GLFW_RED_BITS,mode->redBits);
glfwWindowHint(GLFW_GREEN_BITS,mode->greenBits);
glfwWindowHint(GLFW_BLUE_BITS,mode->blueBits);
glfwWindowHint(GLFW_REFRESH_RATE,mode->refreshRate);

int screen_width = mode->width,screen_height = mode->height;

GLFWwindow* window = glfwCreateWindow(screen_width,screen_height,"Machine Dreams",monitor,NULL);
if (window == NULL) {
    std::cout << "Failed to create GLFW window" << std::endl;
    glfwTerminate();
    return -1;
}
glfwMakeContextCurrent(window);
glfwsetframebufferSizeCallback(window,framebuffer_size_callback);
glfwSetKeyCallback(window,key_callback);
glfwSetCursorPosCallback(window,mouse_callback);
glfwSetScrollCallback(window,scroll_callback);
glfwSetInputMode(window,GLFW_CURSOR,GLFW_CURSOR_DISABLED);
glfwSwapInterval(0); // disables v-sync

也许为我指出了glfw的替代品或其他东西。 这是完整的代码,其中删去了一些冗长的部分:

'''c++
#include <glad/glad.h>
#include <GLFW/glfw3.h>
//#define STB_IMAGE_IMPLEMENTATION
//#include "stb_image.h"

#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtx/euler_angles.hpp>
#include <glm/gtc/type_ptr.hpp>

#include <iostream>
#include <random>

using namespace glm;
#include <assimp/Importer.hpp>
#include <assimp/scene.h>
#include <assimp/postprocess.h>
#include <iostream>
#include "shader.h"
#include "camera.h"
//#include "model.h"
#include "FBO.h"

float deltaTime = 0.0f;
float lastFrame = 0.0f;

unsigned int frameCount = 0;
bool zooming = false;
//int total_pixel_count;
int pixel_count;
float watch;

Camera camera(vec3(0.0f,2.0f,7.0f),2560,1440);
void framebuffer_size_callback(GLFWwindow* window,int width,int height);
void keyboard_callback(GLFWwindow* window);
void mouse_callback(GLFWwindow* window,double xpos,double ypos);
void key_callback(GLFWwindow* window,int key,int scancode,int action,int mods);
void scroll_callback(GLFWwindow* window,double xoffset,double yoffset);


int main() {
    // glfw: initialize and configure
    glfwInit();
    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR,4.5);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR,4.5);
    glfwWindowHint(GLFW_OPENGL_PROFILE,GLFW_OPENGL_CORE_PROFILE);

    // glfw window creation
    GLFWmonitor* monitor = glfwGetPrimaryMonitor();

    const GLFWvidmode* mode = glfwGetVideoMode(monitor);
    glfwWindowHint(GLFW_RED_BITS,mode->redBits);
    glfwWindowHint(GLFW_GREEN_BITS,mode->greenBits);
    glfwWindowHint(GLFW_BLUE_BITS,mode->blueBits);
    glfwWindowHint(GLFW_REFRESH_RATE,mode->refreshRate);

    int screen_width = mode->width,screen_height = mode->height;




    GLFWwindow* window = glfwCreateWindow(screen_width,NULL);
    if (window == NULL) {
        std::cout << "Failed to create GLFW window" << std::endl;
        glfwTerminate();
        return -1;
    }
    //glfwsetwindowpos(window,2560/2.f- screen_width/2.f,1440/2.f - screen_height / 2.f);
    glfwMakeContextCurrent(window);
    glfwsetframebufferSizeCallback(window,framebuffer_size_callback);
    glfwSetKeyCallback(window,key_callback);
    glfwSetCursorPosCallback(window,mouse_callback);
    glfwSetScrollCallback(window,scroll_callback);
    glfwSetInputMode(window,GLFW_CURSOR_DISABLED);
    glfwSwapInterval(0); // disables v-sync
    //stbi_set_flip_vertically_on_load(true);

    //glfwSetWindowMonitor(window,mode->width,mode->height,mode->refreshRate);

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

    //Camera camera = Camera(vec3(0.0f,0.0f,20.0f),screen_width,screen_height);

    //cout << rot[0].x << "," << rot[1].x << "," << rot[2].x << endl;
    //cout << rot[0].y << "," << rot[1].y << "," << rot[2].y << endl;
    //cout << rot[0].z << "," << rot[1].z << "," << rot[2].z << endl;
    //cout << rot[0].w << "," << rot[1].w << "," << rot[2].w << "," << rot[3].w << endl;

    //define model
    float cubeVertices[] = {
        // Back face
        -0.5f,-0.5f,// Bottom-left
         0.5f,0.5f,1.0f,// top-right
         0.5f,// bottom-right         
         0.5f,// top-right
        -0.5f,// bottom-left
        -0.5f,// top-left
        // Front face
        -0.5f,// bottom-left
         0.5f,// bottom-right
         0.5f,// top-left
        -0.5f,// bottom-left
        // Left face
        -0.5f,// bottom-right
        -0.5f,// top-right
        // Right face
         0.5f,// top-left
         0.5f,// top-right         
         0.5f,// bottom-left     
        // Bottom face
        -0.5f,// top-right
        // Top face
        -0.5f,// top-right     
         0.5f,0.0f  // bottom-left        
    };

    vec3 pointLightPositions[] = {
        vec3(0.0f,1.1f),};

    // positions
    vec3 pos1(-1.0,1.0,0.0);
    vec3 pos2(-1.0,-1.0,0.0);
    vec3 pos3(1.0,0.0);
    vec3 pos4(1.0,0.0);
    // texture coordinates
    vec2 uv1(0.0,1.0);
    vec2 uv2(0.0,0.0);
    vec2 uv3(1.0,0.0);
    vec2 uv4(1.0,1.0);
    // normal vector
    vec3 nm(0.0,0.0,1.0);

    vec3 edge1 = pos2 - pos1;
    vec3 edge2 = pos3 - pos1;
    vec2 deltaUV1 = uv2 - uv1;
    vec2 deltaUV2 = uv3 - uv1;

    vec3 tangent1,tangent2;
    float f = 1.0f / (deltaUV1.x * deltaUV2.y - deltaUV2.x * deltaUV1.y);
    tangent1 = normalize(f * (deltaUV2.y * edge1 - deltaUV1.y * edge2));
    f = 1.0f / (deltaUV1.x * deltaUV2.y - deltaUV2.x * deltaUV1.y);
    tangent2 = normalize(f * (deltaUV2.y * edge1 - deltaUV1.y * edge2));

    float quadVerts[] = {
        // positions            // normal         // uv// tangent
        pos1.x,pos1.y,pos1.z,nm.x,nm.y,nm.z,uv1.x,uv1.y,tangent1.x,tangent1.y,tangent1.z,pos2.x,pos2.y,pos2.z,uv2.x,uv2.y,pos3.x,pos3.y,pos3.z,uv3.x,uv3.y,pos1.x,tangent2.x,tangent2.y,tangent2.z,pos4.x,pos4.y,pos4.z,uv4.x,uv4.y,tangent2.z
    };

    unsigned int cubeVAO,cubeVBO;
    glGenVertexArrays(1,&cubeVAO);
    glGenBuffers(1,&cubeVBO);

    glBindVertexArray(cubeVAO);

    glBindBuffer(GL_ARRAY_BUFFER,cubeVBO);
    glBufferData(GL_ARRAY_BUFFER,sizeof(cubeVertices),cubeVertices,GL_STATIC_DRAW);

    glVertexAttribPointer(0,3,GL_FLOAT,GL_FALSE,5 * sizeof(float),(void*)0);
    glEnableVertexAttribArray(0);

    glBindBuffer(GL_ARRAY_BUFFER,0);
    glBindVertexArray(0);

    unsigned int quadVAO,quadVBO;
    glGenVertexArrays(1,&quadVAO);
    glGenBuffers(1,&quadVBO);

    glBindVertexArray(quadVAO);

    glBindBuffer(GL_ARRAY_BUFFER,quadVBO);
    glBufferData(GL_ARRAY_BUFFER,sizeof(quadVerts),quadVerts,GL_STATIC_DRAW);
    glEnableVertexAttribArray(0);
    glVertexAttribPointer(0,11 * sizeof(float),(void*)0);
    glEnableVertexAttribArray(1);
    glVertexAttribPointer(1,(void*)(3 * sizeof(float)));
    glEnableVertexAttribArray(2);
    glVertexAttribPointer(2,2,(void*)(6 * sizeof(float)));
    glEnableVertexAttribArray(3);
    glVertexAttribPointer(3,(void*)(8 * sizeof(float)));

    glBindBuffer(GL_ARRAY_BUFFER,0);
    glBindVertexArray(0);

    unsigned int matricesUBO;
    glGenBuffers(1,&matricesUBO);
    glBindBuffer(GL_UNIFORM_BUFFER,matricesUBO);
    glBufferData(GL_UNIFORM_BUFFER,2 * sizeof(mat4),NULL,GL_STATIC_DRAW);
    glBindBuffer(GL_UNIFORM_BUFFER,0);
    glBindBufferBase(GL_UNIFORM_BUFFER,matricesUBO);

    //unsigned int parametersUBO;
    //glGenBuffers(1,&parametersUBO);
    //glBindBuffer(GL_UNIFORM_BUFFER,parametersUBO);
    //glBufferData(GL_UNIFORM_BUFFER,21 * sizeof(float),GL_STATIC_DRAW);
    //glBindBuffer(GL_UNIFORM_BUFFER,0);
    //glBindBufferBase(GL_UNIFORM_BUFFER,1,parametersUBO);

    uint endpoints[15000000 / 64];
    for (int i = 0; i < 15000000 / 64; i++) {
        endpoints[i] = 0;
    }

    GLuint ssbo;
    glGenBuffers(1,&ssbo);
    glBindBuffer(GL_SHADER_STORAGE_BUFFER,ssbo);


    //glBufferData(GL_SHADER_STORAGE_BUFFER,4 * pixelCount,nullptr,GL_DYNAMIC_COPY);
    //glClearBufferData(GL_SHADER_STORAGE_BUFFER,GL_R8,GL_RED,GL_UNSIGNED_INT,nullptr);

    glBufferData(GL_SHADER_STORAGE_BUFFER,15000000 / 64 * 4,GL_DYNAMIC_COPY);
    glBindBufferBase(GL_SHADER_STORAGE_BUFFER,ssbo);

    //GLint data;
    //glGetBufferParameteriv(GL_SHADER_STORAGE_BUFFER,GL_BUFFER_SIZE,&data);
    //cout << data << endl;
    glBindBuffer(GL_SHADER_STORAGE_BUFFER,0); // unbind



    //glBufferData(GL_SHADER_STORAGE_BUFFER,sizeof(endpoints),&endpoints,GL_DYNAMIC_DRAW);
    //glBindBufferBase(GL_SHADER_STORAGE_BUFFER,ssbo);
    //glBindBuffer(GL_SHADER_STORAGE_BUFFER,0); // unbind

    frameBufferObject hdrFBO = frameBufferObject(screen_width,screen_height);
    hdrFBO.attachColourBuffers(0,GL_RGBA16F,0);
    hdrFBO.attachColourBuffers(0,1);
    hdrFBO.attachRenderBuffer(0);
    hdrFBO.check();



    frameBufferObject gbuffer = frameBufferObject(screen_width,screen_height);
    gbuffer.attachColourBuffers(0,0); //gNormal
    gbuffer.attachColourBuffers(0,GL_RGBA8,1); //gAlbedo_shadow
    gbuffer.attachColourBuffers(0,2); //gMetal_Rough_AO
    gbuffer.attachColourBuffers(0,GL_RGBA32F,3); //gDepth //pixel xy,depth

    gbuffer.check();
    unsigned int attachments2[4] = { GL_COLOR_ATTACHMENT0,GL_COLOR_ATTACHMENT1,GL_COLOR_ATTACHMENT2,GL_COLOR_ATTACHMENT3 };
    glDrawBuffers(4,attachments2);

    vector<GLubyte> emptyData(screen_width * screen_height * 4.f,0); //0-255

    GLuint gNormal_2;
    glGenTextures(1,&gNormal_2);
    glBindTexture(GL_TEXTURE_2D,gNormal_2);
    glTexImage2D(GL_TEXTURE_2D,GL_RGBA,GL_UNSIGNED_BYTE,&emptyData[0]);
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);

    //GLuint gNormal_bank;
    //glGenTextures(1,&gNormal_bank);
    //glBindTexture(GL_TEXTURE_2D,gNormal_bank);
    //glTexImage2D(GL_TEXTURE_2D,&emptyData[0]);
    //glTexParameteri(GL_TEXTURE_2D,GL_CLAMP_TO_EDGE);
    //glTexParameteri(GL_TEXTURE_2D,GL_LINEAR);
    //glTexParameteri(GL_TEXTURE_2D,GL_LINEAR);


    GLuint gAlbedo_shadow_2;
    glGenTextures(1,&gAlbedo_shadow_2);
    glBindTexture(GL_TEXTURE_2D,gAlbedo_shadow_2);
    glTexImage2D(GL_TEXTURE_2D,GL_LINEAR);

    //GLuint gAlbedo_shadow_bank;
    //glGenTextures(1,&gAlbedo_shadow_bank);
    //glBindTexture(GL_TEXTURE_2D,gAlbedo_shadow_bank);
    //glTexImage2D(GL_TEXTURE_2D,GL_LINEAR);


    GLuint gMetal_Rough_AO_2;
    glGenTextures(1,&gMetal_Rough_AO_2);
    glBindTexture(GL_TEXTURE_2D,gMetal_Rough_AO_2);
    glTexImage2D(GL_TEXTURE_2D,GL_LINEAR);

    //GLuint gMetal_Rough_AO_bank;
    //glGenTextures(1,&gMetal_Rough_AO_bank);
    //glBindTexture(GL_TEXTURE_2D,gMetal_Rough_AO_bank);
    //glTexImage2D(GL_TEXTURE_2D,GL_LINEAR);


    GLuint gDepth_2;
    glGenTextures(1,&gDepth_2);
    glBindTexture(GL_TEXTURE_2D,gDepth_2);
    glTexImage2D(GL_TEXTURE_2D,GL_LINEAR);

    //GLuint gPosition_bank;
    //glGenTextures(1,&gPosition_bank);
    //glBindTexture(GL_TEXTURE_2D,gPosition_bank);
    //glTexImage2D(GL_TEXTURE_2D,GL_LINEAR); 


    vector<GLubyte> clearColor(4,0); //it seems as though if a channel is not cleared it is set to 100%

    //glClearTexImage(gNormal_bank,&clearColor[0]);
    //glClearTexImage(gAlbedo_shadow_bank,&clearColor[0]);
    //glClearTexImage(gMetal_Rough_AO_bank,&clearColor[0]);
    //glClearTexImage(gPosition_bank,&clearColor[0]);

    //glClearTexImage(gNormal_2,&clearColor[0]);
    //glClearTexImage(gAlbedo_shadow_2,&clearColor[0]);
    //glClearTexImage(gMetal_Rough_AO_2,&clearColor[0]);
    //glClearTexImage(gDepth_2,&clearColor[0]);


    frameBufferObject res1FBO = frameBufferObject(screen_width,screen_height);
    res1FBO.attachColourBuffers(0,0);
    frameBufferObject res2FBO = frameBufferObject(screen_width / 2.0f,screen_height / 2.0f);
    res2FBO.attachColourBuffers(0,0);
    frameBufferObject res4FBO = frameBufferObject(screen_width / 4.0f,screen_height / 4.0f);
    res4FBO.attachColourBuffers(0,0);
    frameBufferObject res8FBO = frameBufferObject(screen_width / 8.0f,screen_height / 8.0f);
    res8FBO.attachColourBuffers(0,GL_RGB32F,0);
    frameBufferObject res16FBO = frameBufferObject(screen_width / 16.0f,screen_height / 16.0f);
    res16FBO.attachColourBuffers(0,0);
    //res16FBO.setfilter(0,GL_NEAREST);

    frameBufferObject res1FBO_2 = frameBufferObject(screen_width,screen_height);
    res1FBO_2.attachColourBuffers(0,0);
    frameBufferObject res2FBO_2 = frameBufferObject(screen_width / 2.0f,screen_height / 2.0f);
    res2FBO_2.attachColourBuffers(0,0);
    frameBufferObject res4FBO_2 = frameBufferObject(screen_width / 4.0f,screen_height / 4.0f);
    res4FBO_2.attachColourBuffers(0,GL_RGB16F,0);
    frameBufferObject res8FBO_2 = frameBufferObject(screen_width / 8.0f,screen_height / 8.0f);
    res8FBO_2.attachColourBuffers(0,0);
    frameBufferObject res16FBO_2 = frameBufferObject(screen_width / 16.0f,screen_height / 16.0f);
    res16FBO_2.attachColourBuffers(0,0);

    frameBufferObject res1FBO_3 = frameBufferObject(screen_width,screen_height);
    res1FBO_3.attachColourBuffers(0,0);

    //frameBufferObject res4FBO_3 = frameBufferObject(screen_width / 4.0f,screen_height / 4.0f);
    //res4FBO_3.attachColourBuffers(0,0);

    Shader coneMarchShader  ("lighting.vert","coneMarch.frag"  );
    Shader passThroughShader("screen.vert","passthrough.frag");
    Shader giShader         ("lighting.vert","gi.frag"         );
    Shader lightingShader   ("lighting.vert","lighting.frag"   );
    Shader vectorShader     ("lighting.vert","vector.frag"     );
    Shader dof2Shader       ("screen.vert","dof2.frag"       );
    Shader dofShader        ("screen.vert","dof.frag"        );
    Shader mblurShader      ("screen.vert","mblur.frag"      );
    Shader maccelShader     ("screen.vert","maccel.frag"     );
    Shader chromaShader     ("screen.vert","chroma.frag"     );
    Shader blurShader       ("screen.vert","blur.frag"       );
    Shader screenShader     ("screen.vert","screen.frag"     );

    compShader reprojectionCompShader("reproject.comp");
    compShader sortCompShader        ("sort.comp"     );
    compShader storageCompShader     ("storage.comp"  );
    compShader processCompShader     ("process.comp"  );

    coneMarchShader.use();
    coneMarchShader.setInt("prevTex",0);

    passThroughShader.use();
    passThroughShader.setInt("gNormal_2",0);
    passThroughShader.setInt("gAlbedo_shadow_2",1);
    passThroughShader.setInt("gMetal_Rough_AO_2",2);
    passThroughShader.setInt("gDepth_2",3);

    processCompShader.use();
    processCompShader.setVec3("dirLight.direction",lightDir);
    processCompShader.setVec3("dirLight.color",lightColor);

    lightingShader.use();
    lightingShader.setVec3("dirLight.direction",lightDir);
    lightingShader.setVec3("dirLight.color",lightColor);
    lightingShader.setInt("gNormal",0);
    lightingShader.setInt("gAlbedo_shadow",1);
    lightingShader.setInt("gMetal_Rough_AO",2);
    lightingShader.setInt("gDepth",3);
    lightingShader.setInt("res8FBO",4);

    dofShader.use();
    dofShader.setInt("tex1",0);
    //dofShader.setInt("tex2",1);
    dofShader.setInt("vector",1);

    maccelShader.use();
    maccelShader.setInt("tex",0);
    maccelShader.setInt("vector",1);

    mblurShader.use();
    mblurShader.setInt("tex",0);
    mblurShader.setInt("accelTex",1);
    mblurShader.setInt("vector",2);

    screenShader.use();
    screenShader.setInt("screenTexture",0);
    screenShader.setInt("bloomBlur4",1);
    screenShader.setInt("bloomBlur8",2);
    screenShader.setInt("bloomBlur16",3);

    glEnable(GL_CULL_FACE); 


    mat4 view = camera.getViewMatrix();
    float fov = atan(1.f / camera.fl);
    mat4 projection = perspective(fov,(float)screen_width / (float)screen_height,0.01f,1000.0f);

    while (!glfwWindowShouldClose(window)) {
        float currentFrame = glfwGetTime();
        deltaTime = currentFrame - lastFrame;
        lastFrame = currentFrame;
        frameCount++;
        //cout << "Delta Time: " << deltaTime*1000 << "ms" << endl;
        //cout << "-------------------------" << endl;

        glfwGetWindowSize(window,&screen_width,&screen_height);

        // input
        keyboard_callback(window);

        if (zooming) {
            float d = DE(camera.position,iterOffset + 10.f);
            //camera.zoomPower = log2f(1.f / (d + 1e-30));
            //camera.zoom = exp2f(-camera.zoomPower); //reciprocal
            camera.zoom = d;
        }

        s += sV * deltaTime;
        sV *= pow(.5f,deltaTime*6);

        vec3 prev_viewPos = camera.position;
        mat4 prev_view = view;
        mat4 prev_projection = projection;

        camera.refresh(deltaTime);
        view = camera.getViewMatrix();
        float viewfacing = glm::max(dot((vec3)camera.velocity,vec3(vec4(0,-1,0) * view)) / camera.fl,0.f);
        float fov = atan(1.f/camera.fl + pow(viewfacing * 10.,.9)*.1);
        projection = perspective(fov,1000.0f);
        glBindBuffer(GL_UNIFORM_BUFFER,matricesUBO);
        glBufferSubdata(GL_UNIFORM_BUFFER,sizeof(mat4),value_ptr(view));
        glBufferSubdata(GL_UNIFORM_BUFFER,value_ptr(projection));
        glBindBuffer(GL_UNIFORM_BUFFER,0);

        //camera.planeInFocus +=  (marchSurface(camera.position,vec3(vec4(0.f,0.f,-1.f,0.f) * view)) - camera.planeInFocus) / glm::max(camera.planeInFocus / 10.f,1.f);
        //camera.planeInFocus += (marchSurface(camera.position,0.f) * view)) - camera.planeInFocus) ;
        camera.planeInFocus = mix(marchSurface(camera.position,0) * view)),camera.planeInFocus,.9);
        //camera.planeInFocus = marchSurface(camera.position,0) * view));

        //glBindBuffer(GL_UNIFORM_BUFFER,parametersUBO);
        //glBufferSubdata(GL_UNIFORM_BUFFER,3 * sizeof(vec4),value_ptr(mat4(rot3D)));
        //glBufferSubdata(GL_UNIFORM_BUFFER,sizeof(vec4),value_ptr(juliaC));
        //glBufferSubdata(GL_UNIFORM_BUFFER,8 * sizeof(vec2),sizeof(vec2),value_ptr(FoldValues));
        //glBufferSubdata(GL_UNIFORM_BUFFER,9 * sizeof(vec2),sizeof(float),&scale_vary);
        //glBufferSubdata(GL_UNIFORM_BUFFER,19 * sizeof(float),&s);
        //glBufferSubdata(GL_UNIFORM_BUFFER,20 * sizeof(float),&sqrtMinR);
        //glBindBuffer(GL_UNIFORM_BUFFER,0);

        // rendering code normally goes here

    glfwTerminate();
    return 3;
}

void framebuffer_size_callback(GLFWwindow* window,int height) {
    glViewport(0,width,height);
}

void keyboard_callback(GLFWwindow* window) {
    if (glfwGetKey(window,GLFW_KEY_ESCAPE) == GLFW_PRESS)
        glfwSetWindowShouldClose(window,true);
        //glfwTerminate();

    if (glfwGetKey(window,GLFW_KEY_R) == GLFW_PRESS) {
        float speed = length(camera.velocity) + .001;
        camera.velocity *= glm::max(speed - deltaTime,0.f) / speed;

        camera.rollV = sign(camera.rollV) * glm::max(abs(camera.rollV) - deltaTime * 3.f,0.f);
        //user.QVw,user.QVx,user.QVy,user.QVz = slerp(1,user.QVw,user.QVz,0.95)
    }

    vec3 dir = vec3(0);
    if (glfwGetKey(window,GLFW_KEY_W) == GLFW_PRESS)
        dir.z -= 1;
    if (glfwGetKey(window,GLFW_KEY_S) == GLFW_PRESS)
        dir.z += 1;
    if (glfwGetKey(window,GLFW_KEY_A) == GLFW_PRESS)
        dir.x -= 1;
    if (glfwGetKey(window,GLFW_KEY_D) == GLFW_PRESS)
        dir.x += 1;
    if (glfwGetKey(window,GLFW_KEY_SPACE) == GLFW_PRESS)
        dir.y += 1;
    if (glfwGetKey(window,GLFW_KEY_LEFT_CONTROL) == GLFW_PRESS)
        dir.y -= 1;
    float len = length(dir);
    if (len != 0)   dir = dir / len;
    camera.processKeyboard(dir,deltaTime);

    float r = 0;
    if (glfwGetKey(window,GLFW_KEY_Q) == GLFW_PRESS)
        r--;

    if (glfwGetKey(window,GLFW_KEY_E) == GLFW_PRESS)
        r++;

    if (r!=0) camera.rollV += r * deltaTime * 15.f;
    else camera.rollV = sign(camera.rollV) * glm::max(abs(camera.rollV) - deltaTime * 5.f,0.f) * pow(.1f,deltaTime * 4.f);

    if (glfwGetKey(window,GLFW_KEY_T) == GLFW_PRESS) {
        //rot3D = mat3(camera.getViewMatrix());
        float tht = camera.position.x * 0.31415;
        rot2D = mat2(cos(tht),sin(tht),-sin(tht),cos(tht));
    }

    if (glfwGetKey(window,GLFW_KEY_P) == GLFW_PRESS)
        juliaC = vec3(camera.position*0.1);

    camera.smooth = GL_FALSE;
    if (glfwGetKey(window,GLFW_KEY_LEFT_SHIFT) == GLFW_PRESS)
        camera.smooth = GL_TRUE;

}

void key_callback(GLFWwindow* window,int mods) {
    if (key == GLFW_KEY_Z && action == GLFW_PRESS) {
        zooming = !zooming;
    } else if (key == GLFW_KEY_Y && action == GLFW_PRESS) {
        frameCount = 0;
    }
}

void scroll_callback(GLFWwindow* window,double yoffset) {
    if (glfwGetKey(window,GLFW_KEY_LEFT_SHIFT) == GLFW_PRESS) sV += yoffset * 10.* deltaTime;
    else camera.flV = yoffset*1000.*deltaTime;
}

void mouse_callback(GLFWwindow* window,double ypos) {
    camera.processMouseMovement(xpos,ypos,deltaTime);
}

''' 这是帧缓冲区大小的回调:

void framebuffer_size_callback(GLFWwindow* window,int height) {
glViewport(0,height);
}
study222 回答:在全屏模式下尝试切换到另一个应用程序时,GLFW崩溃了吗?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3069075.html

大家都在问