In my world Layer I have a method that draws directly using openGl
// Tell OpenGL this is the texture we're using
GL::bindTexture2D(_subterraneanTexture->getName());
// wrap in both the S and T directions (that's X and Y for the rest of us!)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
// Enable the arrays
GL::enableVertexAttribs(GL::VERTEX_ATTRIB_FLAG_POSITION | GL::VERTEX_ATTRIB_FLAG_TEX_COORDS);
_glProgram->use();
_glProgram->setUniformsForBuiltins();
// Give OpenGl our array of points that we want to fill
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, sizeof(cocos2d::Point), _subterraneanFloorTextureTrianglePoints);
// Give OpenGl the array of points in the texture we want to use to fill the above array of points
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, sizeof(cocos2d::Point), _subterraneanFloorTexturePoints);
// Tell OpenGl to draw the arrays we gave it
glDrawArrays(GL_TRIANGLE_STRIP, 0, _numberOfFloorSubterraneanTextureTrianglePoints);
@Maxxx
I guess it could be caused by sending a wrong transform to shader
could you please try this code instead of your code:
GL::bindTexture2D(_subterraneanTexture->getName());
// wrap in both the S and T directions (that's X and Y for the rest of us!)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
// Enable the arrays
GL::enableVertexAttribs(GL::VERTEX_ATTRIB_FLAG_POSITION | GL::VERTEX_ATTRIB_FLAG_TEX_COORDS);
_glProgram->use();
//_glProgram->setUniformsForBuiltins();
//change to this
_glProgram->setUniformsForBuiltins(_modelViewTransform);