【OpenGL/ES系列教程】 第四讲 glTexImage2D用法的区别
2016-03-24 11:09
2771 查看
GL和GLES标准的一些细微的区别常常令人抓狂,原本在PC上好好的,一移植就乱七八糟的,纹理作为标准里的重要部分非常值得探讨一下,glTexImage2D作为一个热门接口函数几乎会陪伴你一生,下面来分析一下。
作者在用GLES2.0绘制纹理时遇到如下的异常情况:
![](https://oscdn.geek-share.com/Uploads/Images/Content/202010/20/d8f7ca8736d909a09eb629f3fb6e4a4c)
修正之后正确效果如下:
![](http://img.blog.csdn.net/20160324104347353)
错误追踪后发现是glTexImage2D抛出GL_INVALIA_OPERATION的错误,随后作者紧急查阅了一下gles2.0/gl4.5的Spec,找到了问题发生的原因。
gles2.0的Spec:
void glTexImage2D(GLenum target,GLint level,GLint internalformat,GLsizei width,GLsizei height,GLint border,GLenum format,GLenum type,const GLvoid* data);
对于上面的若干参数,可能唯一理解有点障碍的就是internalformat和format,Spec给出的说明分别是
internalformat - 这个格式指的是内部GPU上的纹理数据格式
Specifies the internal format of the texture.
Must be one of the following symbolic constants:
format - 这个格式指的是传进来的data数据的格式,必须和internalformat匹 配,经测试发现必须和internalformat一样
Specifies the format of the texel data. Must match
The following symbolic values are accepted:
同时给出了更清晰的说明 -
两种format必须一致,在纹理处理过程中不支持不同格式的转换
No conversion between formats is supported during texture image processing.
but a GL implementation may choose to store the texture array at any internal resolution it chooses.
gl4.5的Spec:
internalformat和format和gles2.0含义一样,只是各种格式非常的多,还有compressed压缩格式
支持纹理处理过程中的不同格式转换,具体每种格式用法的细节读者自行查阅Spec
作者在用GLES2.0绘制纹理时遇到如下的异常情况:
修正之后正确效果如下:
错误追踪后发现是glTexImage2D抛出GL_INVALIA_OPERATION的错误,随后作者紧急查阅了一下gles2.0/gl4.5的Spec,找到了问题发生的原因。
gles2.0的Spec:
void glTexImage2D(GLenum target,GLint level,GLint internalformat,GLsizei width,GLsizei height,GLint border,GLenum format,GLenum type,const GLvoid* data);
对于上面的若干参数,可能唯一理解有点障碍的就是internalformat和format,Spec给出的说明分别是
internalformat - 这个格式指的是内部GPU上的纹理数据格式
Specifies the internal format of the texture.
Must be one of the following symbolic constants:
GL_ALPHA,
GL_LUMINANCE,
GL_LUMINANCE_ALPHA,
GL_RGB,
GL_RGBA
format - 这个格式指的是传进来的data数据的格式,必须和internalformat匹 配,经测试发现必须和internalformat一样
Specifies the format of the texel data. Must match
internalformat.
The following symbolic values are accepted:
GL_ALPHA,
GL_RGB,
GL_RGBA,
GL_LUMINANCE,and
GL_LUMINANCE_ALPHA
同时给出了更清晰的说明 -
两种format必须一致,在纹理处理过程中不支持不同格式的转换
Notes
internalformatmust match
format.
No conversion between formats is supported during texture image processing.
typemay be used as a hint to specify how much precision is desired,
but a GL implementation may choose to store the texture array at any internal resolution it chooses.
gl4.5的Spec:
internalformat和format和gles2.0含义一样,只是各种格式非常的多,还有compressed压缩格式
支持纹理处理过程中的不同格式转换,具体每种格式用法的细节读者自行查阅Spec
相关文章推荐
- dell optiplex台式机 安装win7 清楚分区的方法
- shell 脚本 修改系统时间
- Docker-4 Docker 相关概念
- 使用 ssh -R 穿透局域网访问内部服务器主机,反向代理 无人值守化
- 【读书笔记】Linux内核设计与实现(第五章)
- centos 防火墙 iptables 用shell代码来添加
- Linux(CentOS-7.0)下安装MySQL5.6.22
- centos7使用问题总结
- Linux 技巧:让进程在后台可靠运行的几种方法
- Linux IO模式
- apache的server-status如何分析的技术说明
- Linux文件权限查看及修改命令chmod
- 《LINUX内核设计与实现》读书笔记之第五章
- HYSBZ 1798(Ahoi2009) Seq 维护序列seq(区间更新+加法乘法混合操作)
- 屏蔽第三方网站中的百度广告和百度推荐
- linux下nginx默认使用www-data用户组
- Android项目架构
- The file “XXX” couldn’t be opened because you don’t have permission to view it.解决方法:
- 1号店交易系统架构如何向「高并发高可用」演进
- 年终福利,PHP7+Apache2.4+MySQL5.6 源码编译安装,环境配置,搭建你自己的LAMP环境