OpenGL 使用GLFW创建全屏窗口

GLFW库里面的glfwCreateWindow()函数是用来创建窗口的函数。

这样函数的原型是:

GLFWwindow* glfwCreateWindow(int width, int height, const char * title, GLFWmonitor * monitor, GLFWwindow * share);

介绍glfwCreateWindow()函数的使用方法

程序

    bool isFullScreen = true;
GLFWmonitor* pMonitor = isFullScreen ? glfwGetPrimaryMonitor() : NULL;
GLFWwindow* window = glfwCreateWindow(WIDTH, HEIGHT, "Holographic projection", pMonitor, NULL);
//GLFWwindow* window = glfwCreateWindow(WIDTH, HEIGHT, "Holographic projection", nullptr, nullptr);
    // Define the viewport dimensions
//glViewport(0, 0, WIDTH, HEIGHT);
glViewport(0, 0, Screen_Width, Screen_Height);

OpenGL GLFW 指定屏幕 全屏显示

程序

     bool isFullScreen = true;
int monitorCount;
//GLFWmonitor* pMonitor = isFullScreen ? glfwGetPrimaryMonitor() : NULL;
GLFWmonitor** pMonitor = isFullScreen ? glfwGetMonitors(&monitorCount) : NULL; std::cout << "Screen number is " << monitorCount << std::endl;
//GLFWmonitor** pM = pMonitor;
int holographic_screen = -1;
for(int i=0; i<monitorCount; i++){
int screen_x, screen_y;
const GLFWvidmode * mode = glfwGetVideoMode(pMonitor[i]);
screen_x = mode->width;
screen_y = mode->height;
std::cout << "Screen size is X = " << screen_x << ", Y = " << screen_y << std::endl;
if(screen_x==1920 && screen_y==1080){
holographic_screen = i;
}
}
std::cout << holographic_screen << std::endl; GLFWwindow* window = glfwCreateWindow(screenWidth, screenWidth, "Holographic projection", pMonitor[holographic_screen], NULL);
    // Define the viewport dimensions
//glViewport(0, 0, WIDTH, HEIGHT);
glViewport(0, 0, Screen_Width, Screen_Height);

参考网站:

http://wiki.jikexueyuan.com/project/modern-opengl-tutorial/tutorial44.html

http://www.glfw.org/docs/latest/group__monitor.html

http://gamedev.stackexchange.com/questions/60244/how-to-find-monitor-resolution-with-glfw3

http://geistyp.weebly.com/tech-life/080-glfw

最新文章

  1. thinkphp
  2. 13,SFDC 管理员篇 - 移动客户端
  3. sql 如果关联表 没有值 设置 默认值
  4. 【poj1160】 Post Office
  5. iOS之 PJSIP静态库编译(二)
  6. CCF真题之日期计算
  7. Python基础教程之List对象 转
  8. Centos后台运行jar
  9. Django架设blog步骤(转)
  10. 微软Visual Studio二十周年:VS2017于3月7日发布
  11. maven项目转成web项目没有生成WebContent目录
  12. 痞子衡嵌入式:蓝牙芯片厂商三强(Qualcomm&amp;CSR, TI, Nordic)产品一览
  13. Centos7配置静态IP后无法ping通外部网络的问题(无法上网)
  14. ubuntu系统安装微信小程序开发工具
  15. Fiddler怎样抓取手机的包
  16. maven自动部署项目以及常见问题解决
  17. 深入理解java虚拟机---3垃圾回收机制GC
  18. 既使用maven又使用lib下的Jar包
  19. Sql求和异常——对象不能从 DBNull 转换为其他类型
  20. Hbase Rowkey设计

热门文章

  1. 用 Java 技术创建 RESTful Web 服务
  2. ubuntu16.04 docker安装
  3. 【leetcode刷题笔记】Distinct Subsequences
  4. Spring中如何动态注入Bean实例教程
  5. Source not found The source attachment does not contain the source for the file MethodBeforeAdvice.class
  6. webpack 教程资源目录
  7. cscope usage
  8. hdu 1003 Max Sum(基础dp)
  9. Python基础-redis模块使用
  10. JSP页面跳转