Merge branch 'develop' into newRenderer

This commit is contained in:
Nite Luo 2013-11-13 10:27:30 -08:00
commit d5f651deee
13 changed files with 207 additions and 195 deletions

View File

@ -597,6 +597,7 @@ Developers:
bmanGH
Use gl caching functions in TexturePVR::createGLTexture()
Configuration of VAO in runtime
metadao
make create_project.py more pythonic and fix some typoes

View File

@ -14,13 +14,14 @@ cocos2d-x-3.0alpha1 @??? 2013
[FIX] When parsing XML using TinyXML, the data size has to be specified.
[FIX] Parameter type: const char* -> const string&
[FIX] Armature: many bug fixed, add more samples, add function to skip some frames when playing animation
[FIX] Configuration of VAO in runtime
[FIX] Webp Test Crashes.
[NEW] Arm64 support.
[NEW] Added Mouse Support For Desktop Platforms.
[NEW] Point: Adds ANCHOR_XXX constants like ANCHOR_MIDDLE, ANCHOR_TOP_RIGHT, etc.
[NEW] Sprite: Override setScale(float scaleX, float scaleY)
[NEW] External: added | operator for Control::EventType
[NEW] Android & iOS screen size change support
[FIX] Webp Test Crashes.
[Android]
[FIX] Added EGL_RENDERABLE_TYPE to OpenGL attributes
[FIX] Fixed application will crash when pause and resume.

View File

@ -259,7 +259,11 @@ bool Configuration::supportsDiscardFramebuffer() const
bool Configuration::supportsShareableVAO() const
{
return _supportsShareableVAO;
#if CC_TEXTURE_ATLAS_USE_VAO
return _supportsShareableVAO;
#else
return false;
#endif
}
//

View File

@ -25,6 +25,7 @@
#include "CCGL.h"
#include "CCNotificationCenter.h"
#include "CCEventType.h"
#include "CCConfiguration.h"
NS_CC_BEGIN
@ -114,11 +115,12 @@ DrawNode::~DrawNode()
glDeleteBuffers(1, &_vbo);
_vbo = 0;
#if CC_TEXTURE_ATLAS_USE_VAO
glDeleteVertexArrays(1, &_vao);
GL::bindVAO(0);
_vao = 0;
#endif
if (Configuration::getInstance()->supportsShareableVAO())
{
glDeleteVertexArrays(1, &_vao);
GL::bindVAO(0);
_vao = 0;
}
#if CC_ENABLE_CACHE_TEXTURE_DATA
NotificationCenter::getInstance()->removeObserver(this, EVNET_COME_TO_FOREGROUND);
@ -159,10 +161,11 @@ bool DrawNode::init()
ensureCapacity(512);
#if CC_TEXTURE_ATLAS_USE_VAO
glGenVertexArrays(1, &_vao);
GL::bindVAO(_vao);
#endif
if (Configuration::getInstance()->supportsShareableVAO())
{
glGenVertexArrays(1, &_vao);
GL::bindVAO(_vao);
}
glGenBuffers(1, &_vbo);
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
@ -179,9 +182,10 @@ bool DrawNode::init()
glBindBuffer(GL_ARRAY_BUFFER, 0);
#if CC_TEXTURE_ATLAS_USE_VAO
GL::bindVAO(0);
#endif
if (Configuration::getInstance()->supportsShareableVAO())
{
GL::bindVAO(0);
}
CHECK_GL_ERROR_DEBUG();
@ -206,21 +210,24 @@ void DrawNode::render()
glBufferData(GL_ARRAY_BUFFER, sizeof(V2F_C4B_T2F)*_bufferCapacity, _buffer, GL_STREAM_DRAW);
_dirty = false;
}
#if CC_TEXTURE_ATLAS_USE_VAO
GL::bindVAO(_vao);
#else
GL::enableVertexAttribs(GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX);
if (Configuration::getInstance()->supportsShareableVAO())
{
GL::bindVAO(_vao);
}
else
{
GL::enableVertexAttribs(GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX);
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
// vertex
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, vertices));
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
// vertex
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, vertices));
// color
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, colors));
// color
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, colors));
// texcood
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, texCoords));
#endif
// texcood
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, texCoords));
}
glDrawArrays(GL_TRIANGLES, 0, _bufferCount);
glBindBuffer(GL_ARRAY_BUFFER, 0);

View File

@ -57,7 +57,7 @@ public:
CUSTOM
};
typedef int ListenerID;
typedef std::size_t ListenerID;
protected:
/** Constructor */

View File

@ -37,6 +37,7 @@ THE SOFTWARE.
#include "TransformUtils.h"
#include "CCNotificationCenter.h"
#include "CCEventType.h"
#include "CCConfiguration.h"
// extern
#include "kazmath/GL/matrix.h"
@ -57,11 +58,14 @@ bool ParticleSystemQuad::initWithTotalParticles(unsigned int numberOfParticles)
}
initIndices();
#if CC_TEXTURE_ATLAS_USE_VAO
setupVBOandVAO();
#else
setupVBO();
#endif
if (Configuration::getInstance()->supportsShareableVAO())
{
setupVBOandVAO();
}
else
{
setupVBO();
}
setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR));
@ -81,9 +85,7 @@ bool ParticleSystemQuad::initWithTotalParticles(unsigned int numberOfParticles)
ParticleSystemQuad::ParticleSystemQuad()
:_quads(NULL)
,_indices(NULL)
#if CC_TEXTURE_ATLAS_USE_VAO
,_VAOname(0)
#endif
{
memset(_buffersVBO, 0, sizeof(_buffersVBO));
}
@ -95,10 +97,11 @@ ParticleSystemQuad::~ParticleSystemQuad()
CC_SAFE_FREE(_quads);
CC_SAFE_FREE(_indices);
glDeleteBuffers(2, &_buffersVBO[0]);
#if CC_TEXTURE_ATLAS_USE_VAO
glDeleteVertexArrays(1, &_VAOname);
GL::bindVAO(0);
#endif
if (Configuration::getInstance()->supportsShareableVAO())
{
glDeleteVertexArrays(1, &_VAOname);
GL::bindVAO(0);
}
}
#if CC_ENABLE_CACHE_TEXTURE_DATA
@ -355,47 +358,48 @@ void ParticleSystemQuad::draw()
CCASSERT( _particleIdx == _particleCount, "Abnormal error in particle quad");
#if CC_TEXTURE_ATLAS_USE_VAO
//
// Using VBO and VAO
//
GL::bindVAO(_VAOname);
if (Configuration::getInstance()->supportsShareableVAO())
{
//
// Using VBO and VAO
//
GL::bindVAO(_VAOname);
#if CC_REBIND_INDICES_BUFFER
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]);
#endif
glDrawElements(GL_TRIANGLES, (GLsizei) _particleIdx*6, GL_UNSIGNED_SHORT, 0);
glDrawElements(GL_TRIANGLES, (GLsizei) _particleIdx*6, GL_UNSIGNED_SHORT, 0);
#if CC_REBIND_INDICES_BUFFER
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
#endif
}
else
{
//
// Using VBO without VAO
//
#else
//
// Using VBO without VAO
//
#define kQuadSize sizeof(_quads[0].bl)
#define kQuadSize sizeof(_quads[0].bl)
GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX );
GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX );
glBindBuffer(GL_ARRAY_BUFFER, _buffersVBO[0]);
// vertices
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, vertices));
// colors
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, colors));
// tex coords
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, texCoords));
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]);
glBindBuffer(GL_ARRAY_BUFFER, _buffersVBO[0]);
// vertices
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, vertices));
// colors
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, colors));
// tex coords
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof( V3F_C4B_T2F, texCoords));
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]);
glDrawElements(GL_TRIANGLES, (GLsizei) _particleIdx*6, GL_UNSIGNED_SHORT, 0);
glDrawElements(GL_TRIANGLES, (GLsizei) _particleIdx*6, GL_UNSIGNED_SHORT, 0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
#endif
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
}
CC_INCREMENT_GL_DRAWS(1);
CHECK_GL_ERROR_DEBUG();
@ -454,11 +458,14 @@ void ParticleSystemQuad::setTotalParticles(int tp)
}
initIndices();
#if CC_TEXTURE_ATLAS_USE_VAO
setupVBOandVAO();
#else
setupVBO();
#endif
if (Configuration::getInstance()->supportsShareableVAO())
{
setupVBOandVAO();
}
else
{
setupVBO();
}
}
else
{
@ -468,7 +475,6 @@ void ParticleSystemQuad::setTotalParticles(int tp)
resetSystem();
}
#if CC_TEXTURE_ATLAS_USE_VAO
void ParticleSystemQuad::setupVBOandVAO()
{
// clean VAO
@ -508,7 +514,6 @@ void ParticleSystemQuad::setupVBOandVAO()
CHECK_GL_ERROR_DEBUG();
}
#else
void ParticleSystemQuad::setupVBO()
{
@ -527,15 +532,16 @@ void ParticleSystemQuad::setupVBO()
CHECK_GL_ERROR_DEBUG();
}
#endif
void ParticleSystemQuad::listenBackToForeground(Object *obj)
{
#if CC_TEXTURE_ATLAS_USE_VAO
if (Configuration::getInstance()->supportsShareableVAO())
{
setupVBOandVAO();
#else
}
else
{
setupVBO();
#endif
}
}
bool ParticleSystemQuad::allocMemory()
@ -578,11 +584,14 @@ void ParticleSystemQuad::setBatchNode(ParticleBatchNode * batchNode)
allocMemory();
initIndices();
setTexture(oldBatch->getTexture());
#if CC_TEXTURE_ATLAS_USE_VAO
setupVBOandVAO();
#else
setupVBO();
#endif
if (Configuration::getInstance()->supportsShareableVAO())
{
setupVBOandVAO();
}
else
{
setupVBO();
}
}
// OLD: was it self render ? cleanup
else if( !oldBatch )
@ -597,11 +606,12 @@ void ParticleSystemQuad::setBatchNode(ParticleBatchNode * batchNode)
glDeleteBuffers(2, &_buffersVBO[0]);
memset(_buffersVBO, 0, sizeof(_buffersVBO));
#if CC_TEXTURE_ATLAS_USE_VAO
glDeleteVertexArrays(1, &_VAOname);
GL::bindVAO(0);
_VAOname = 0;
#endif
if (Configuration::getInstance()->supportsShareableVAO())
{
glDeleteVertexArrays(1, &_VAOname);
GL::bindVAO(0);
_VAOname = 0;
}
}
}
}

View File

@ -135,20 +135,15 @@ public:
virtual void setTotalParticles(int tp) override;
private:
#if CC_TEXTURE_ATLAS_USE_VAO
void setupVBOandVAO();
#else
void setupVBO();
#endif
bool allocMemory();
protected:
V3F_C4B_T2F_Quad *_quads; // quads to be rendered
GLushort *_indices; // indices
#if CC_TEXTURE_ATLAS_USE_VAO
GLuint _VAOname;
#endif
GLuint _buffersVBO[2]; //0: vertex 1: indices
};

View File

@ -34,6 +34,7 @@ THE SOFTWARE.
#include "CCEventType.h"
#include "CCDirector.h"
#include "CCGL.h"
#include "CCConfiguration.h"
// support
#include "CCTexture2D.h"
#include "CCString.h"
@ -61,10 +62,11 @@ TextureAtlas::~TextureAtlas()
glDeleteBuffers(2, _buffersVBO);
#if CC_TEXTURE_ATLAS_USE_VAO
glDeleteVertexArrays(1, &_VAOname);
GL::bindVAO(0);
#endif
if (Configuration::getInstance()->supportsShareableVAO())
{
glDeleteVertexArrays(1, &_VAOname);
GL::bindVAO(0);
}
CC_SAFE_RELEASE(_texture);
#if CC_ENABLE_CACHE_TEXTURE_DATA
@ -191,11 +193,14 @@ bool TextureAtlas::initWithTexture(Texture2D *texture, long capacity)
this->setupIndices();
#if CC_TEXTURE_ATLAS_USE_VAO
setupVBOandVAO();
#else
setupVBO();
#endif
if (Configuration::getInstance()->supportsShareableVAO())
{
setupVBOandVAO();
}
else
{
setupVBO();
}
_dirty = true;
@ -204,11 +209,14 @@ bool TextureAtlas::initWithTexture(Texture2D *texture, long capacity)
void TextureAtlas::listenBackToForeground(Object *obj)
{
#if CC_TEXTURE_ATLAS_USE_VAO
setupVBOandVAO();
#else
setupVBO();
#endif
if (Configuration::getInstance()->supportsShareableVAO())
{
setupVBOandVAO();
}
else
{
setupVBO();
}
// set _dirty to true to force it rebinding buffer
_dirty = true;
@ -249,7 +257,6 @@ void TextureAtlas::setupIndices()
//TextureAtlas - VAO / VBO specific
#if CC_TEXTURE_ATLAS_USE_VAO
void TextureAtlas::setupVBOandVAO()
{
glGenVertexArrays(1, &_VAOname);
@ -284,14 +291,13 @@ void TextureAtlas::setupVBOandVAO()
CHECK_GL_ERROR_DEBUG();
}
#else // CC_TEXTURE_ATLAS_USE_VAO
void TextureAtlas::setupVBO()
{
glGenBuffers(2, &_buffersVBO[0]);
mapBuffers();
}
#endif // ! // CC_TEXTURE_ATLAS_USE_VAO
void TextureAtlas::mapBuffers()
{
@ -604,90 +610,89 @@ void TextureAtlas::drawNumberOfQuads(long numberOfQuads, long start)
GL::bindTexture2D(_texture->getName());
#if CC_TEXTURE_ATLAS_USE_VAO
//
// Using VBO and VAO
//
// XXX: update is done in draw... perhaps it should be done in a timer
if (_dirty)
if (Configuration::getInstance()->supportsShareableVAO())
{
glBindBuffer(GL_ARRAY_BUFFER, _buffersVBO[0]);
// option 1: subdata
//glBufferSubData(GL_ARRAY_BUFFER, sizeof(_quads[0])*start, sizeof(_quads[0]) * n , &_quads[start] );
// option 2: data
// glBufferData(GL_ARRAY_BUFFER, sizeof(quads_[0]) * (n-start), &quads_[start], GL_DYNAMIC_DRAW);
// option 3: orphaning + glMapBuffer
glBufferData(GL_ARRAY_BUFFER, sizeof(_quads[0]) * (numberOfQuads-start), NULL, GL_DYNAMIC_DRAW);
void *buf = glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
memcpy(buf, _quads, sizeof(_quads[0])* (numberOfQuads-start));
glUnmapBuffer(GL_ARRAY_BUFFER);
glBindBuffer(GL_ARRAY_BUFFER, 0);
//
// Using VBO and VAO
//
_dirty = false;
}
// XXX: update is done in draw... perhaps it should be done in a timer
if (_dirty)
{
glBindBuffer(GL_ARRAY_BUFFER, _buffersVBO[0]);
// option 1: subdata
//glBufferSubData(GL_ARRAY_BUFFER, sizeof(_quads[0])*start, sizeof(_quads[0]) * n , &_quads[start] );
// option 2: data
// glBufferData(GL_ARRAY_BUFFER, sizeof(quads_[0]) * (n-start), &quads_[start], GL_DYNAMIC_DRAW);
// option 3: orphaning + glMapBuffer
glBufferData(GL_ARRAY_BUFFER, sizeof(_quads[0]) * (numberOfQuads-start), NULL, GL_DYNAMIC_DRAW);
void *buf = glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
memcpy(buf, _quads, sizeof(_quads[0])* (numberOfQuads-start));
glUnmapBuffer(GL_ARRAY_BUFFER);
glBindBuffer(GL_ARRAY_BUFFER, 0);
GL::bindVAO(_VAOname);
_dirty = false;
}
GL::bindVAO(_VAOname);
#if CC_REBIND_INDICES_BUFFER
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]);
#endif
#if CC_TEXTURE_ATLAS_USE_TRIANGLE_STRIP
glDrawElements(GL_TRIANGLE_STRIP, (GLsizei) numberOfQuads*6, GL_UNSIGNED_SHORT, (GLvoid*) (start*6*sizeof(_indices[0])) );
glDrawElements(GL_TRIANGLE_STRIP, (GLsizei) numberOfQuads*6, GL_UNSIGNED_SHORT, (GLvoid*) (start*6*sizeof(_indices[0])) );
#else
glDrawElements(GL_TRIANGLES, (GLsizei) numberOfQuads*6, GL_UNSIGNED_SHORT, (GLvoid*) (start*6*sizeof(_indices[0])) );
glDrawElements(GL_TRIANGLES, (GLsizei) numberOfQuads*6, GL_UNSIGNED_SHORT, (GLvoid*) (start*6*sizeof(_indices[0])) );
#endif // CC_TEXTURE_ATLAS_USE_TRIANGLE_STRIP
#if CC_REBIND_INDICES_BUFFER
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
#endif
// glBindVertexArray(0);
#else // ! CC_TEXTURE_ATLAS_USE_VAO
//
// Using VBO without VAO
//
}
else
{
//
// Using VBO without VAO
//
#define kQuadSize sizeof(_quads[0].bl)
glBindBuffer(GL_ARRAY_BUFFER, _buffersVBO[0]);
glBindBuffer(GL_ARRAY_BUFFER, _buffersVBO[0]);
// XXX: update is done in draw... perhaps it should be done in a timer
if (_dirty)
{
glBufferSubData(GL_ARRAY_BUFFER, sizeof(_quads[0])*start, sizeof(_quads[0]) * numberOfQuads , &_quads[start] );
_dirty = false;
}
// XXX: update is done in draw... perhaps it should be done in a timer
if (_dirty)
{
glBufferSubData(GL_ARRAY_BUFFER, sizeof(_quads[0])*start, sizeof(_quads[0]) * numberOfQuads , &_quads[start] );
_dirty = false;
}
GL::enableVertexAttribs(GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX);
GL::enableVertexAttribs(GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX);
// vertices
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof(V3F_C4B_T2F, vertices));
// vertices
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof(V3F_C4B_T2F, vertices));
// colors
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (GLvoid*) offsetof(V3F_C4B_T2F, colors));
// colors
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (GLvoid*) offsetof(V3F_C4B_T2F, colors));
// tex coords
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof(V3F_C4B_T2F, texCoords));
// tex coords
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, kQuadSize, (GLvoid*) offsetof(V3F_C4B_T2F, texCoords));
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _buffersVBO[1]);
#if CC_TEXTURE_ATLAS_USE_TRIANGLE_STRIP
glDrawElements(GL_TRIANGLE_STRIP, (GLsizei)numberOfQuads*6, GL_UNSIGNED_SHORT, (GLvoid*) (start*6*sizeof(_indices[0])));
glDrawElements(GL_TRIANGLE_STRIP, (GLsizei)numberOfQuads*6, GL_UNSIGNED_SHORT, (GLvoid*) (start*6*sizeof(_indices[0])));
#else
glDrawElements(GL_TRIANGLES, (GLsizei)numberOfQuads*6, GL_UNSIGNED_SHORT, (GLvoid*) (start*6*sizeof(_indices[0])));
glDrawElements(GL_TRIANGLES, (GLsizei)numberOfQuads*6, GL_UNSIGNED_SHORT, (GLvoid*) (start*6*sizeof(_indices[0])));
#endif // CC_TEXTURE_ATLAS_USE_TRIANGLE_STRIP
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
#endif // CC_TEXTURE_ATLAS_USE_VAO
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
}
CC_INCREMENT_GL_DRAWS(1);
CHECK_GL_ERROR_DEBUG();

View File

@ -219,17 +219,12 @@ private:
void setupIndices();
void mapBuffers();
#if CC_TEXTURE_ATLAS_USE_VAO
void setupVBOandVAO();
#else
void setupVBO();
#endif
protected:
GLushort* _indices;
#if CC_TEXTURE_ATLAS_USE_VAO
GLuint _VAOname;
#endif
GLuint _buffersVBO[2]; //0: vertex 1: indices
bool _dirty; //indicates whether or not the array buffer of the VBO needs to be updated
/** quantity of quads that are going to be drawn */

View File

@ -28,6 +28,7 @@ THE SOFTWARE.
#include "CCGLProgram.h"
#include "CCDirector.h"
#include "ccConfig.h"
#include "CCConfiguration.h"
// extern
#include "kazmath/GL/matrix.h"
@ -50,9 +51,7 @@ static GLuint s_uCurrentBoundTexture[kMaxActiveTexture] = {(GLuint)-1,(GLuin
static GLenum s_eBlendingSource = -1;
static GLenum s_eBlendingDest = -1;
static int s_eGLServerState = 0;
#if CC_TEXTURE_ATLAS_USE_VAO
static GLuint s_uVAO = 0;
#endif
#endif // CC_ENABLE_GL_STATE_CACHE
// GL State Cache functions
@ -78,9 +77,7 @@ void invalidateStateCache( void )
s_eBlendingSource = -1;
s_eBlendingDest = -1;
s_eGLServerState = 0;
#if CC_TEXTURE_ATLAS_USE_VAO
s_uVAO = 0;
#endif
#endif // CC_ENABLE_GL_STATE_CACHE
}
@ -187,19 +184,20 @@ void deleteTextureN(GLuint textureUnit, GLuint textureId)
void bindVAO(GLuint vaoId)
{
#if CC_TEXTURE_ATLAS_USE_VAO
if (Configuration::getInstance()->supportsShareableVAO())
{
#if CC_ENABLE_GL_STATE_CACHE
if (s_uVAO != vaoId)
{
s_uVAO = vaoId;
glBindVertexArray(vaoId);
}
if (s_uVAO != vaoId)
{
s_uVAO = vaoId;
glBindVertexArray(vaoId);
}
#else
glBindVertexArray(vaoId);
glBindVertexArray(vaoId);
#endif // CC_ENABLE_GL_STATE_CACHE
#endif
}
}
//#pragma mark - GL Vertex Attrib functions

View File

@ -33,23 +33,16 @@ THE SOFTWARE.
#include <android/log.h>
#if CC_TEXTURE_ATLAS_USE_VAO
// <EGL/egl.h> exists since android 2.3
#include <EGL/egl.h>
PFNGLGENVERTEXARRAYSOESPROC glGenVertexArraysOESEXT = 0;
PFNGLBINDVERTEXARRAYOESPROC glBindVertexArrayOESEXT = 0;
PFNGLDELETEVERTEXARRAYSOESPROC glDeleteVertexArraysOESEXT = 0;
#endif
void initExtensions() {
#if CC_TEXTURE_ATLAS_USE_VAO
glGenVertexArraysOESEXT = (PFNGLGENVERTEXARRAYSOESPROC)eglGetProcAddress("glGenVertexArraysOES");
glBindVertexArrayOESEXT = (PFNGLBINDVERTEXARRAYOESPROC)eglGetProcAddress("glBindVertexArrayOES");
glDeleteVertexArraysOESEXT = (PFNGLDELETEVERTEXARRAYSOESPROC)eglGetProcAddress("glDeleteVertexArraysOES");
#endif
}
NS_CC_BEGIN

View File

@ -237,8 +237,11 @@ static CCEAGLView *__view = 0;
context_ = [renderer_ context];
//discardFramebufferSupported_ = [[Configuration sharedConfiguration] supportsDiscardFramebuffer];
#if GL_EXT_discard_framebuffer == 1
discardFramebufferSupported_ = YES;
#else
discardFramebufferSupported_ = NO;
#endif
CHECK_GL_ERROR();
@ -288,7 +291,7 @@ static CCEAGLView *__view = 0;
glResolveMultisampleFramebufferAPPLE();
}
if( discardFramebufferSupported_)
if(discardFramebufferSupported_)
{
if (multiSampling_)
{

View File

@ -1 +1 @@
f86eb12e6d4835f93bd6f59d860970bcd2f74128
811c4efefbe80ac5bcc88d74e56cc093166dd64a