栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

OpenGL学习001-GLFW环境搭建

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

OpenGL学习001-GLFW环境搭建

      GLFW是一个专门针对OpenGL的C语言库,它提供了一些渲染物体所需的最低限度的接口。它允许用户创建OpenGL上下文,定义窗口参数以及处理用户输入,下面来记述下GLFW在Ubuntu环境下的构建。

1.源代码下载

     在ubuntu下创建glfw工作目录,然后下载glfw源代码

mkdir glfw
cd glfw
wget https://github.com/glfw/glfw/releases/download/3.3.4/glfw-3.3.4.zip
unzip glfw-3.3.4.zip
2. 检查依赖

    glfw构建时需要特定的依赖包,libx11-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev,使用dpkg命令检查上述包是否已经安装。

 2.1检查libx11-dev
ubuntu@ubuntu-VirtualBox:~/glfw$ dpkg -s libx11-dev
Package: libx11-dev
Status: install ok installed
Priority: optional
Section: libdevel
Installed-Size: 2528
Maintainer: Ubuntu Developers 
Architecture: amd64
Multi-Arch: same
Source: libx11
Version: 2:1.6.9-2ubuntu1.2
Replaces: x11proto-dev (<< 2019.2)
Depends: libx11-6 (= 2:1.6.9-2ubuntu1.2), libxau-dev (>= 1:1.0.0-1), libxdmcp-dev (>= 1:1.0.0-1), x11proto-dev (>= 2019.2-1), xtrans-dev, libxcb1-dev
Suggests: libx11-doc
Description: X11 client-side library (development headers)
 This package provides a client interface to the X Window System, otherwise
 known as 'Xlib'.  It provides a complete API for the basic functions of the
 window system.
 .
 This package contains the development headers for the library found in
 libx11-6. Non-developers likely have little use for this package.
 .
 More information about X.Org can be found at:
 
 .
 This module can be found at
 git://anongit.freedesktop.org/git/xorg/lib/libX11
Original-Maintainer: Debian X Strike Force 

Status: install ok installed  表明libx11-dev已经安装

2.2检查libxrandr-dev
ubuntu@ubuntu-VirtualBox:~/glfw$ dpkg -s libxrandr-dev
dpkg-query: package 'libxrandr-dev' is not installed and no information is available
Use dpkg --info (= dpkg-deb --info) to examine archive files.
ubuntu@ubuntu-VirtualBox:~/glfw$

 查询结果显示libxrandr-dev未安装,则将其安装。

ubuntu@ubuntu-VirtualBox:~/glfw$ sudo apt-get -y install libxrandr-dev

再次检查libxrandr-dev安装情况

ubuntu@ubuntu-VirtualBox:~/glfw$ dpkg -s libxrandr-dev
Package: libxrandr-dev
Status: install ok installed
Priority: optional
Section: libdevel
Installed-Size: 131
Maintainer: Ubuntu Developers 
Architecture: amd64
Multi-Arch: same
Source: libxrandr
Version: 2:1.5.2-0ubuntu1
Depends: libxrandr2 (= 2:1.5.2-0ubuntu1), libx11-dev, libxext-dev, x11proto-randr-dev (>= 1.4), libxrender-dev
Description: X11 RandR extension library (development headers)
 libXrandr provides an X Window System client interface to the RandR
 extension to the X protocol.
 .
 The RandR extension allows for run-time configuration of display attributes
 such as resolution, rotation, and reflection.
 .
 This package contains the development headers for the library found in
 libxrandr2.  Non-developers likely have little use for this package.
 .
 More information about X.Org can be found at:
 
 .
 This module can be found at
 git://anongit.freedesktop.org/git/xorg/lib/libXrandr
Original-Maintainer: Debian X Strike Force 
ubuntu@ubuntu-VirtualBox:~/glfw$

显示librandr-dev已安装

2.3 检查libxinerama-dev

     按照2.1 libx11-dev, 2.2libxrandr-dev操作步骤,未安装则安装,已安装则忽略。

2.4 检查libxcursor-dev

         按照2.1 libx11-dev, 2.2libxrandr-dev操作步骤,未安装则安装,已安装则忽略。

2.5 检查 libxi-dev

      按照2.1 libx11-dev, 2.2libxrandr-dev操作步骤,未安装则安装,已安装则忽略。

3 编译 & 安装

    

ubuntu@ubuntu-VirtualBox:~/glfw/glfw-3.3.4$ cd   #切入glfw源代码目录
ubuntu@ubuntu-VirtualBox:~$ cd glfw/glfw-3.3.4/
ubuntu@ubuntu-VirtualBox:~/glfw/glfw-3.3.4$ pwd
/home/ubuntu/glfw/glfw-3.3.4
ubuntu@ubuntu-VirtualBox:~/glfw/glfw-3.3.4$ mkdir build-dir  #创建编译目录
ubuntu@ubuntu-VirtualBox:~/glfw/glfw-3.3.4$ cd build-dir/
ubuntu@ubuntu-VirtualBox:~/glfw/glfw-3.3.4/build-dir$ cmake .. -DCMAKE_INSTALL_PREFIX=/home/ubuntu/glfw/Install -DCMAKE_BUILD_TYPE=RELEASE  #编译预处理
ubuntu@ubuntu-VirtualBox:~/glfw/glfw-3.3.4/build-dir$ make -j3 #编译
ubuntu@ubuntu-VirtualBox:~/glfw/glfw-3.3.4/build-dir$ make install  #安装


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/344439.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号