获取显示屏的个数和分辨率 — 通过使用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

获取显示屏的个数和分辨率 --- 通过使用OpenGL的GLFW库的更多相关文章

  1. js 获取对象属性个数

    js 获取对象属性个数 方法一: var attributeCount = function(obj) { var count = 0; for(var i in obj) { if(obj.hasO ...

  2. C#基础知识回顾--C#遍历enum类型、获取enum项个数

    C#遍历enum类型 对于enum类型: 使用foreach遍历enum类型的元素并填充combox foreach ( HatchStyle hs1 in Enum.GetValues(typeof ...

  3. javascript 获取函数形参个数

    分享下javascript获取函数形参个数的方法. /** * 获取函数的形参个数 * @param {Function} func [要获取的函数] * @return {*} [形参的数组或und ...

  4. Linux上获取CPU Core个数的实现

    Linux上获取CPU Core个数的实现 可以通过多种手段取得CPU Core的个数,如: 1) 调用系统提供的函数get_nprocs(),可以在头文件sys/sysinfo.h中发现它 2) 借 ...

  5. React-Native 之 GD (十二)海淘半小时热门 及 获取最新数据个数功能 (角标)

    1.海淘半小时热门   基本功能和首页相似 GDHt.js /** * 海淘折扣 */ import React, { Component } from 'react'; import { Style ...

  6. JS获取checkbox的个数

    本文算是转载自网络,当时用了他的函数,现在想总结一下,但忘了原文地址了 ================================================================ ...

  7. VC获取并修改计算机屏幕分辨率

    //获取分辨率 int m_nWindwMetricsX   =   ::GetSystemMetrics(SM_CXSCREEN);     int m_nWindwMetricsY   =   : ...

  8. jQuery获取子元素个数的方法

    //获取id=div1下的子元素的个数 $('#id').children().length; //获取id=div1下的p元素个数 $('#id').children('p').length;

  9. JS获取浏览器高宽度,屏幕分辨率和一些定位空隙等

    IE中: document.body.clientWidth ==> BODY对象宽度 document.body.clientHeight ==> BODY对象高度 document.d ...

随机推荐

  1. 搭建SSM项目时报错(org.springframework.jdbc.CannotGetJdbcConnectionException)

    严重: Servlet.service() for servlet [SpringMVC] in context with path [/ssm] threw exception [Request p ...

  2. 【LeetCode】【动态规划】Generate Parentheses(括号匹配问题)

    描述 Given n pairs of parentheses, write a function to generate all combinations of well-formed parent ...

  3. Data Structure Linked List: Reverse a Linked List in groups of given size

    http://www.geeksforgeeks.org/reverse-a-list-in-groups-of-given-size/ #include <iostream> #incl ...

  4. H5 input默认数字键盘,显示为密码格式

    <P> <span class="yzname w25">银行密码</span> <input class="j_passwor ...

  5. 【leetcode刷题笔记】Binary Tree Level Order Traversal(JAVA)

    Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, ...

  6. Finding Similar Items 文本相似度计算的算法——机器学习、词向量空间cosine、NLTK、diff、Levenshtein距离

    http://infolab.stanford.edu/~ullman/mmds/ch3.pdf 汇总于此 还有这本书 http://www-nlp.stanford.edu/IR-book/ 里面有 ...

  7. Raft 为什么是更易理解的分布式一致性算法——(1)Leader在时,由Leader向Follower同步日志 (2)Leader挂掉了,选一个新Leader,Leader选举算法。

    转自:http://www.cnblogs.com/mindwind/p/5231986.html Raft 协议的易理解性描述 虽然 Raft 的论文比 Paxos 简单版论文还容易读了,但论文依然 ...

  8. Quality

  9. python基础-条件语句if

    if语句: if 判断条件: 执行语句 else: 执行语句 flag = Falsename = 'huipaodexiong'if name == 'python':    flag = True ...

  10. javaScript-进阶篇(一)

    1.变量 1.必须以字母.下划线或美元符号开头,后面可以跟字母.下划线.美元符号和数字. 2.变量名区分大小写,如:A与a是两个不同变量. 3.不允许使用JavaScript关键字和保留字做变量名. ...