OpenGL-我应该存储属性/统一位置吗? [英] OpenGL - Should I store Attribute/Uniform locations?

查看:106
本文介绍了OpenGL-我应该存储属性/统一位置吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

glGetUniformLocationglGetAttribLocation是否很费时间?

哪种方法更好?

  1. 每次需要时都呼叫glGetAttribLocationglGetUniformLocation吗?
  2. 将位置存储在变量中,并在需要时使用它们吗?
  1. Call glGetAttribLocation or glGetUniformLocation every time I need it ?
  2. 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆