|
|
@@ -19,28 +19,31 @@
|
|
|
|
|
|
// Default sprite vertex shader
|
|
|
#define SPRITE_VSH \
|
|
|
- "uniform mat4 sb_projection_matrix;" \
|
|
|
- "attribute vec3 a_position;" \
|
|
|
- "attribute vec2 a_texcoord;" \
|
|
|
- "attribute vec4 a_color;" \
|
|
|
- "varying vec2 vtexcoord;" \
|
|
|
- "varying vec4 vcolor;" \
|
|
|
- "void main()" \
|
|
|
- "{" \
|
|
|
- "gl_Position = sb_projection_matrix * vec4(a_position, 1);" \
|
|
|
- "vtexcoord = a_texcoord;" \
|
|
|
- "vcolor = a_color;" \
|
|
|
- "}"
|
|
|
+ "uniform mat4 u_projectionMatrix;\n" \
|
|
|
+ "attribute vec3 a_position;\n" \
|
|
|
+ "attribute vec2 a_texcoord;\n" \
|
|
|
+ "attribute vec4 a_color;\n" \
|
|
|
+ "varying vec2 v_texcoord;\n" \
|
|
|
+ "varying vec4 v_color;\n" \
|
|
|
+ "void main()\n" \
|
|
|
+ "{\n" \
|
|
|
+ "gl_Position = u_projectionMatrix * vec4(a_position, 1);\n" \
|
|
|
+ "v_texcoord = a_texcoord;\n" \
|
|
|
+ "v_color = a_color;\n" \
|
|
|
+ "}\n"
|
|
|
|
|
|
// Default sprite fragment shader
|
|
|
#define SPRITE_FSH \
|
|
|
- "varying vec2 vtexcoord;" \
|
|
|
- "varying vec4 vcolor;" \
|
|
|
- "uniform sampler2D texture;" \
|
|
|
- "void main()" \
|
|
|
- "{" \
|
|
|
- "gl_FragColor = vcolor * texture2D(texture, vtexcoord);" \
|
|
|
- "}"
|
|
|
+ "#ifdef OPENGL_ES\n" \
|
|
|
+ "precision highp float;\n" \
|
|
|
+ "#endif\n" \
|
|
|
+ "varying vec2 v_texcoord;\n" \
|
|
|
+ "varying vec4 v_color;\n" \
|
|
|
+ "uniform sampler2D u_texture;\n" \
|
|
|
+ "void main()\n" \
|
|
|
+ "{\n" \
|
|
|
+ "gl_FragColor = v_color * texture2D(u_texture, v_texcoord);\n" \
|
|
|
+ "}\n"
|
|
|
|
|
|
namespace gameplay
|
|
|
{
|
|
|
@@ -146,8 +149,8 @@ SpriteBatch* SpriteBatch::create(Texture* texture, Effect* effect, unsigned int
|
|
|
batch->_textureHeightRatio = 1.0f / (float)texture->getHeight();
|
|
|
batch->resizeBatch(initialCapacity > 0 ? initialCapacity : SPRITE_BATCH_DEFAULT_SIZE);
|
|
|
|
|
|
- // If there is a uniform named 'sb_projection_matrix', store it so that we can set our projection matrix to it
|
|
|
- batch->_projectionUniform = effect->getUniform("sb_projection_matrix");
|
|
|
+ // If there is a uniform named 'u_projectionMatrix', store it so that we can set our projection matrix to it
|
|
|
+ batch->_projectionUniform = effect->getUniform("u_projectionMatrix");
|
|
|
if (batch->_projectionUniform)
|
|
|
{
|
|
|
batch->_projectionMatrix = new Matrix();
|