获取显示屏的个数和分辨率 — 通过使用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. iOS JSON 和 Mode l转换

    MJExtension  是我们项目开发常用的一个第三方框架  很好用. https://github.com/CoderMJLee/MJExtension 映射 json  value key  直 ...

  2. mysql innobackupex备份实施

    最近用innobackup进行备份测试,我们只备份一个innodb类型的库,数据大小大概50多G,用innobackupex大概用了5个多小时,但是mysqldump只用了大约2个小时,这让我很费解, ...

  3. P4773 红鲤鱼与绿鲤鱼

    P4773 红鲤鱼与绿鲤鱼 暑假比赛的一个水题 总情况数:\(\dfrac{(a+b)!}{a!b!}\) 就是\(a+b\)条鲤鱼中选\(a\) or \(b\)的情况 反正我们会用完鲤鱼,则红鲤鱼 ...

  4. P3506 [POI2010]MOT-Monotonicity 2

    题目 P3506 [POI2010]MOT-Monotonicity 2 第一次切掉没题解的题\(qwq\) 做法 首先确定\(a_i\)的位置后显然就能确定\(a_{i+1}\)的位置,建一棵权值线 ...

  5. perl常用字符串函数

    1.$position = index(string,substring,skipchars): 该函数返回子串substring在字符串string中的位置,如果不存在,则返回-1:参数skipch ...

  6. JAVA NIO之浅谈内存映射文件原理与DirectMemory

    JAVA类库中的NIO包相对于IO 包来说有一个新功能是内存映射文件,日常编程中并不是经常用到,但是在处理大文件时是比较理想的提高效率的手段.本文我主要想结合操作系统中(OS)相关方面的知识介绍一下原 ...

  7. Android 基础-3.0 数据存储方式

    Android几种数据存储方式 文件存储 SharedPreference存储 Json解析 SQLite数据库存储 文件存储 文件存储是Android中最基本的一种存储方式,和Java中实现I/O的 ...

  8. Python基础-修改excel中内容

    from xlutils.copy import copy import xlrd import os #1.打一要修改的excel #2.再打开另一个excel #3.把第一个excel里面修改东西 ...

  9. codeforces 631B B. Print Check

    B. Print Check time limit per test 1 second memory limit per test 256 megabytes input standard input ...

  10. HDU3579Hello Kiki(中国剩余定理)(不互质的情况)

    One day I was shopping in the supermarket. There was a cashier counting coins seriously when a littl ...