OpenGL-我应该存储属性/统一位置吗? [英] OpenGL - Should I store Attribute/Uniform locations?
问题描述
glGetUniformLocation
和glGetAttribLocation
是否很费时间?
哪种方法更好?
- 每次需要时都呼叫
glGetAttribLocation
或glGetUniformLocation
吗? - 将位置存储在变量中,并在需要时使用它们吗?
- Call
glGetAttribLocation
orglGetUniformLocation
every time I need it ? - Store locations in varables and use them when needed ?
推荐答案
无论在Android还是iPhone上,对于opengl表面,您都可以使用以下方法: onSurfaceCreated和onSurfaceChanged , 养成在这两种方法中获取制服和属性的习惯.
Whether on Android or iPhone, for an opengl surface you will have methods like: onSurfaceCreated and onSurfaceChanged, get into the habit of fetching uniforms and attributes here in these 2 methods.
提高渲染速度的唯一方法(当代码跨越1000行代码时,它将很快成为您的优先事项)是仅在onDrawFrame方法中包含 gluseprogram,glbindbuffer,纹理绑定和其他绑定,始终在onSurfaceCreated和onSurfaceChanged内部缓存变量
The only way you can make rendering faster (which will soon become your priority when your code crosses 1000 lines of code) is by only having gluseprogram, glbindbuffer, texture binds and other binds inside onDrawFrame method, always cache variables inside onSurfaceCreated and onSurfaceChanged
这篇关于OpenGL-我应该存储属性/统一位置吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!