9. Remake the old “wheel” for 2D
attribute vec2 aPos;
void main()
{
gl_Position = vec4( aPos.x/HALF_WIDTH - 1.0,
1.0 - aPos.y/HALF_HEIGHT,
0.0,
1.0);
}
10. • Multiply ops: 16
• Add ops: 12
• Total: 28
• Multiply ops: 2
• Add ops: 2
• Total: 4
old “wheel”
28 VS 4
new “wheel”
11.
12. ETC texture
• Ericsson Texture Compression (ETC)
• 6x compression 0f 24-bit RGB data
• No support images with Alpha component
Source: http://en.wikipedia.org/wiki/Ericsson_Texture_Compression
46. Our old “wheel”
• Encode binary content to string (Base64)
• Use HTTP GET method
• Decode url string to binary
47. Our new “wheel”
• No encode
• Use HTTP POST method
- With “Content-Type: application/octet-stream”
- Maybe with "Content-Encoding: gzip“
- And "Content-MD5: …"
• No decode
48. HttpURLConnection http_conn = (HttpURLConnection)url.openConnection();
http_conn.setRequestMethod(”POST”);
http_conn.setDoOutput(true);
byte[] final_content = GZIP(_binary_data);
http_conn.setRequestProperty("Content-Type", "application/octet-stream");
http_conn.setRequestProperty("Content-Encoding", "gzip");
http_conn.setRequestProperty("Content-MD5", MD5(final_content));
http_conn.setFixedLengthStreamingMode(final_content.length);
//send the POST content
OutputStream out = http_conn.getOutputStream();
out.write(final_content);
out.close();
60. Even when it doesn’t get a better result, it always helps you gain more exp.
My exp
Editor's Notes
Vertex Shader - OpenGL ES graphics code for rendering the vertices of a shape.Fragment Shader - OpenGL ES code for rendering the face of a shape with colors or textures.Program - An OpenGL ES object that contains the shaders you want to use for drawing one or more shapes.
What’s ETC ?Why should we use ETC texture ?But ETC don’t support alpha channel !!!
Q&A
Load texturefor (inti = 0 ; i < n ; ++i) { glActiveTexture(GL_TEXTURE0 + i); glBindTexture(GL_TEXTURE_2D, texture_ids[i]); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexImage2D(GL_TEXTURE_2D, ...); }Use texturefor (i = 0 ; i < n; ++i) { ... glUniform1i(texture_location, i); ... glDrawElements(...); }