zoukankan      html  css  js  c++  java
  • 获取显示屏的个数和分辨率 --- 通过使用OpenGL的GLFW库

    获取显示屏的个数和分辨率 — 通过使用OpenGL的GLFW库

    程序

    #include <iostream>
    
    // GLFW
    #include <GLFW/glfw3.h>
    
    int main()
    {
        // Init GLFW
        glfwInit();
        // Set all the required options for GLFW
        glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
        glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
        glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
        glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);
    
        int monitorCount;
        //GLFWmonitor* pMonitor = glfwGetPrimaryMonitor();
        GLFWmonitor** pMonitor =  glfwGetMonitors(&monitorCount);
    
        std::cout << "Now, Screen number is " << monitorCount << std::endl;
        for(int i=0; i<monitorCount; i++){
            int screen_x, screen_y;
            const GLFWvidmode * mode = glfwGetVideoMode(pMonitor[i]);
            std::cout << "Screen size is X = " << mode->width << ", Y = " << mode->height << std::endl;
        }
    
        //waiting
        getchar();
    
        // Terminate GLFW, clearing any resources allocated by GLFW.
        glfwTerminate();
        return 0;
    }

    运行程序

    Now, Screen number is 2
    Screen size is X = 1920, Y = 1080
    Screen size is X = 1280, Y = 1024

    参考网站:
    http://gamedev.stackexchange.com/questions/60244/how-to-find-monitor-resolution-with-glfw3
    http://geistyp.weebly.com/tech-life/080-glfw

  • 相关阅读:
    jsp4个作用域
    jsp9个内置对象
    jsp指令
    jsp注释
    jsp原理
    java面试
    代理
    泛型
    exception
    基础
  • 原文地址:https://www.cnblogs.com/aobosir/p/5928652.html
Copyright © 2011-2022 走看看