获取显示屏的个数和分辨率 --- 通过使用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 ...
随机推荐
- ELKK 日志处理
http://blog.csdn.net/u010022051/article/details/54342357 在ELKK的架构中,各个框架的角色分工如下: ElasticSearch1.7.2:数 ...
- H5 input默认数字键盘,显示为密码格式
<P> <span class="yzname w25">银行密码</span> <input class="j_passwor ...
- (转)Windows下面安装和配置MySQL(5.6.20)
原文地址:http://www.cnblogs.com/qiyebao/p/3887055.html 1.首先到http://dev.mysql.com/ 上下载windows版mysql5.6免安装 ...
- castle windsor学习-----Registering components one-by-one 注册类型
1.在容器中注册一个类型 container.Register( Component.For<IMyService>() .ImplementedBy<MyServiceImpl&g ...
- maven命令创建项目
1)创建一个Project mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArti ...
- centos5.5源更新方法(网易163源 很快的源)
http://blog.chinaunix.net/uid-24993824-id-189965.html 1.首先,打开终端,获取root权限 2.关闭fastestmirror插件 ...
- matlab查找最临近搜索knnsearch
Idx = knnsearch(X,Y) finds the nearest neighbor in X for each query point in Y and returns the indic ...
- java:类集操作总结
java:类集操作总结 1.List接口允许有重复的元素,Set接口中不允许有重复的元素 2.ArrayList,和Vector的区别 3.set依靠equals和hashCode区分 4.TreeS ...
- 高并发下用pdo,文件排它锁,redis三种方法对比
<?php header('content-type:text/html;charset=utf-8'); // //无控制 // $DB_DSN = ' ...
- C 字节对齐.我的算法学习之路
C/C++基础笔试题1.0(字节对齐) http://blog.csdn.net/dengyaolongacmblog/article/details/37559687 我的算法学习之路 http:/ ...