我的OpenGL学习进阶之旅OpenGL ES 着色语言的IDE插件(Android Studio和Visutal Studio)以及常见GLSL文件扩展名介绍
Posted 欧阳鹏
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了我的OpenGL学习进阶之旅OpenGL ES 着色语言的IDE插件(Android Studio和Visutal Studio)以及常见GLSL文件扩展名介绍相关的知识,希望对你有一定的参考价值。
通过前面的博客:
我们学习了OpenGL ES 着色语言 GLSL的基本理论知识,接下来我们实际去开发 GLSL 的时候,会发现有IDE 不支持关键字高亮 ,对开发GLSL来说很不友好。
没有插件的情况
- Visual Studio 没有任何高亮
- android Studio 没有任何高亮
这样去编写 GLSL 的时候,很不友好,很容易出错。 有什么办法让他们高亮呢?
二、Visutal Studio的GLSL插件
2.1 GLSL language integration 官网查询信息
2.2 安装插件
- 打开Visual Studio 2019,选择“扩展”–>“管理扩展”
- 在左侧选项卡中选择“联机”,并搜索“shader”,安装“GLSL language integration”
- 下载中
-
安装成功后,底部将显示如图黄色提示,此时关闭Visual Studio 2019,点击【关闭】按钮,然后关闭所有Visual Studio 2019窗口
-
关闭所有Visual Studio 2019窗口,稍等片刻后,将弹出“VSIX Installer”插件安装程序,点击“Modify”按钮
-
安装中
安装完成,点击【Close】按钮
-
完成安装后,打开Visual Studio 2019,并选择“工具”–>“选项”
-
从左侧选项卡找到“GLSL language integration”,此时可以为指定类型文件编辑自定义的扩展名,注意多个扩展名之间用英文分号分隔
2.3 效果展示
- 插件安装好之后,打开GLSL文件的效果如下:
三、Android Studio的GLSL插件
3.1 GLSL Support 插件介绍
3.2 安装 GLSL Support
-
Ctrl+Alt+S进入Setting
-
打开 Settings --> Plugins
-
搜索GLSL
-
安装GLSL插件
-
重启Android Studio
3.3 效果展示
因为我已经安装过了,安装后的样子如下图所示:
- 控制GLSL的高亮颜色 Editor - -> Color Scheme - -> GLSL
- 控制GLSL的代码样式 Editor - -> Code Style - -> GLSL
我们来看看安装了GLSL Support 插件后,打开GLSL文件的效果,如下所示:
四、GLSL文件的文件扩展名
在 OpenGL / OpenGL ES Reference Compiler 一文中有如下介绍
Any GLSL errors in shader.frag will be printed out. Be sure that your shader includes the appropriate #version statement; the default is #version 100, i.e., the shading language supported in OpenGL ES 2.0. The stage is indicated by the file’s extension:
- .vert - a vertex shader
- .tesc - a tessellation control shader
- .tese - a tessellation evaluation shader
- .geom - a geometry shader
- .frag - a fragment shader
- .comp - a compute shader
There is also a non-shader file extension:
- .conf - a configuration file of implementation-dependent limits
在Visual Studio 2019中可以有如下文件扩展名:
但是我一般在开发的时候用的扩展名是如下三个:
- .glsl
Auto detect shader type file extension
- .frag
Fragment shader type file extension
- .vert
Vertex shader type file extension
以上是关于我的OpenGL学习进阶之旅OpenGL ES 着色语言的IDE插件(Android Studio和Visutal Studio)以及常见GLSL文件扩展名介绍的主要内容,如果未能解决你的问题,请参考以下文章