opengl - 在本地搭建API的文档说明网站

发布于:2025-05-29 ⋅ 阅读:(18) ⋅ 点赞:(0)

opengl - 在本地搭建API的文档说明网站

概述

使用opengl的API时,一般都会用第三方的API载入库(e.g. glew), 这些库都是动态载入API. 只有API原型,没有文档说明

#define glCompileShader GLEW_GET_FUN(__glewCompileShader)
// ...
#ifndef GLEW_GET_FUN
#define GLEW_GET_FUN(x) x
#endif
// ...
GLEW_FUN_EXPORT PFNGLCOMPILESHADERPROC __glewCompileShader;
// ...
typedef void (GLAPIENTRY * PFNGLCOMPILESHADERPROC) (GLuint shader);

看资料,可以在 https://docs.gl/ 查看opengl API的文档说明。不过因为网络通讯质量的原因,速度有点慢。
有时,也不想联网去看API说明。

后来在opengl官方库找到了API文档网站的git库(https://github.com/KhronosGroup/OpenGL-Refpages.git)

这个官方库有对应的网站(应该是在 https://www.khronos.org/ 上面), 如果网络通讯质量不好,还访问不到。

想用官方库在本地搭建OpenGL-Refpages,试了一下ok.
这样在本地看opengl的API官方文档,就可以离线看了。

笔记

迁出工程(https://github.com/KhronosGroup/OpenGL-Refpages.git)到本地D:\3rd\game_prj\KhronosGroup\OpenGL-Refpages
库中有官方编译好的html, 位置 >> D:\3rd\game_prj\KhronosGroup\OpenGL-Refpages\gl4\html
结合在根目录和gl4/html中都发现了index.php, 可知,这是用php启动的网站。
这么看,只需要打好php环境,将网站目录指到工程根目录即可。

安装php环境

查了一下,用 xampp 比较方便。
用360的软件管家安装xampp,默认就安装到C:\xampp.
我的C盘现在换了一个2T的SSD, 软件都安装到C盘,不用改。

配置php环境

配置文件 = C:\xampp\apache\conf\httpd.conf
修改点如下:

修改网站目录

#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
# 将连在一起的这2行的内容,都修改为本地网站目录 D:/3rd/game_prj/KhronosGroup/OpenGL-Refpages
# 目录分隔符号为'/', 不是‘\’
DocumentRoot "D:/3rd/game_prj/KhronosGroup/OpenGL-Refpages"
<Directory "D:/3rd/game_prj/KhronosGroup/OpenGL-Refpages">

修改端口号

因为默认端口是80, 容易端口冲突,改为一个独特的端口号

#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the <VirtualHost>
# directive.
#
# Change this to Listen on specific IP addresses as shown below to 
# prevent Apache from glomming onto all bound IP addresses.
#
#Listen 12.34.56.78:80
# 改为8086好了
Listen 8086

启动网站服务

启动 XAMPP Control Panel
启动apache服务
在这里插入图片描述
可以看到本地网站端口为8086, 说明修改的配置没错,且启动成功。
在chrome中输入网址 localhost:8086, 就启动了opengl 的API说明的本地网站。
在这里插入图片描述
如果看桌面版的opengl API说明,就选opengl4.5的链接。
在这里插入图片描述
在页面左上角有字幕选择,以要查看的API开头字母为索引,点击一下,就跳过去了。
假设我要查 glCompileShader, 那就选择’c’, 不是g…
如果API不是以gl开头,就选开头字母。
如果API是以gl开头,就选gl之后的那个字母。
在这里插入图片描述

备注

在本地看文档,速度嗖嗖的。

直接在网页中搜索API名称就行

网页看起来像静态网页。
在工程中拷贝要查的API名称,在本地API文档说明网页中CTRL + F,CTRL +V, 就直接能找到API, 比官方提供的字母搜索好。
在这里插入图片描述

END


网站公告

今日签到

点亮在社区的每一天
去签到