OpenGL and atlas
Posted
by
user30088
on Game Development
See other posts from Game Development
or by user30088
Published on 2014-04-02T13:57:34Z
Indexed on
2014/06/01
22:01 UTC
Read the original article
Hit count: 504
I'm trying to draw element from a texture atlas with OpenGL ES 2.
Currently, I'm drawing my elements using something like that in the shader: uniform mat4 uCamera;
uniform mat4 uModel;
attribute vec4 aPosition;
attribute vec4 aColor;
attribute vec2 aTextCoord;
uniform vec2 offset;
uniform vec2 scale;
varying lowp vec4 vColor;
varying lowp vec2 vUV;
void main()
{
vUV = offset + aTextCoord * scale;
gl_Position = (uCamera * uModel) * aPosition;
vColor = aColor;
}
For each elements to draw I send his offset and scale to the shader. The problem with this method: I can't rotate the element but it's not a problem for now.
I would like to know, what is better for performance:
- Send uniforms like that for each element on every frames
- Update quad geometry (uvs) for each element
Thanks!
© Game Development or respective owner