获取显示屏的个数和分辨率 --- 通过使用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
获取显示屏的个数和分辨率 --- 通过使用OpenGL的GLFW库的更多相关文章
- js 获取对象属性个数
js 获取对象属性个数 方法一: var attributeCount = function(obj) { var count = 0; for(var i in obj) { if(obj.hasO ...
- C#基础知识回顾--C#遍历enum类型、获取enum项个数
C#遍历enum类型 对于enum类型: 使用foreach遍历enum类型的元素并填充combox foreach ( HatchStyle hs1 in Enum.GetValues(typeof ...
- javascript 获取函数形参个数
分享下javascript获取函数形参个数的方法. /** * 获取函数的形参个数 * @param {Function} func [要获取的函数] * @return {*} [形参的数组或und ...
- Linux上获取CPU Core个数的实现
Linux上获取CPU Core个数的实现 可以通过多种手段取得CPU Core的个数,如: 1) 调用系统提供的函数get_nprocs(),可以在头文件sys/sysinfo.h中发现它 2) 借 ...
- React-Native 之 GD (十二)海淘半小时热门 及 获取最新数据个数功能 (角标)
1.海淘半小时热门 基本功能和首页相似 GDHt.js /** * 海淘折扣 */ import React, { Component } from 'react'; import { Style ...
- JS获取checkbox的个数
本文算是转载自网络,当时用了他的函数,现在想总结一下,但忘了原文地址了 ================================================================ ...
- VC获取并修改计算机屏幕分辨率
//获取分辨率 int m_nWindwMetricsX = ::GetSystemMetrics(SM_CXSCREEN); int m_nWindwMetricsY = : ...
- jQuery获取子元素个数的方法
//获取id=div1下的子元素的个数 $('#id').children().length; //获取id=div1下的p元素个数 $('#id').children('p').length;
- JS获取浏览器高宽度,屏幕分辨率和一些定位空隙等
IE中: document.body.clientWidth ==> BODY对象宽度 document.body.clientHeight ==> BODY对象高度 document.d ...
随机推荐
- Hadoop2.x + eclipse 插件配置
http://blog.csdn.net/u012874209/article/details/52105304 搭建集群那些就不用说了,主要有几个关键的地方需要注意(自己的Hadoop版本是2.5. ...
- [原创] Windows下Eclipse连接hadoop
1 下载hadoop-eclipse-plugin :我用的是hadoop-eclipse-plugin1.2.1 ,百度自行下载 2 配置插件:将下载的插件解压,把插件放到..\eclipse\pl ...
- 【leetcode刷题笔记】Linked List Cycle II
Given a linked list, return the node where the cycle begins. If there is no cycle, return null. Foll ...
- Linux iptables 从入门到放弃
iptables表(iptables)和链(chains) 描述完iptables术语后,相信大家对iptables的表和链有了初步的了解.默认情况下,Iptables根据功能和表的定义划分包含 ...
- Spring与web.xml
出处:http://blog.csdn.net/u010796790 在web.xml配置监听器 ContextLoaderListener (listener-class) ContextLoade ...
- HDU 1255 覆盖的面积 (线段树扫描线+面积交)
自己YY了一个的写法,不过时间复杂度太高了,网上的想法太6了 题意:给你一些矩阵,求出矩阵的面积并 首先按照x轴离散化线段到线段树上(因为是找连续区间,所以段建树更加好做). 然后我们可以想一下怎样 ...
- Linux课程---4、Linux目录结构及常用命令(目录结构)
Linux课程---4.Linux目录结构及常用命令(目录结构) 一.总结 一句话总结: 家目录:./root:root用户的家目录 能执行的程序:./bin:所有用户都能执行的程序:./sbin:只 ...
- iframe弹出层中关闭包含iframe的div(子页面调用父页面js函数)
父页面: <div id="win2" style=" width:300px; height:200px; border:1px solid red;" ...
- C++(九)— 虚函数、纯虚函数、虚析构函数
1.虚函数 原因:通过指针调用成员函数时,只能访问到基类的同名成员函数.在同名覆盖现象中,通过某个类的对象(指针及引用)调用同名函数,编译器会将该调用静态联编到该类的同名函数,也就是说,通过基类对象指 ...
- priority_queue用法(转载)
关于priority_queue 1,关于STL中的priority_queue:确定用top()查看顶部元素时,该元素是具有最高优先级的一个元素. 调用pop()删除之后,将促使下一个元素进入该位置 ...