Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The program crashes after launch. EXC_BAD_ACCESS error!!! #1

Closed
zilongshanren opened this issue Jan 20, 2014 · 4 comments
Closed

The program crashes after launch. EXC_BAD_ACCESS error!!! #1

zilongshanren opened this issue Jan 20, 2014 · 4 comments

Comments

@zilongshanren
Copy link

My cocos2d-x version is v2.2 and I followed your instructions step by step.
It's easy to get all stuff build and run. But after launching, it crashes.

Here is the crash code line:

CCTextureAtlas.cpp line 636.

glDrawElements(GL_TRIANGLES, (GLsizei) n_6, GL_UNSIGNED_SHORT, (GLvoid_) (start_6_sizeof(m_pIndices[0])) );

The Xcode gives me EXC_BAD_ACCESS at the above line.

It seems the memory of n data was unintentional freed before this code line was executed.

@wantnon2
Copy link
Collaborator

i just checked my cocos2d-x 2.2. i found i had made several bug fix to it.
here is the code around your crash location in my cocos2d-x 2.2, see if there are any difference:

//i do not know when the line below is missing, but other cocos2d-x 2.2 seem has this line [yang chao]
ccGLBindVAO(m_uVAOname);//add [yang chao]

#if CC_REBIND_INDICES_BUFFER
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_pBuffersVBO[1]);
#endif

#if CC_TEXTURE_ATLAS_USE_TRIANGLE_STRIP
glDrawElements(GL_TRIANGLE_STRIP, (GLsizei) n_6, GL_UNSIGNED_SHORT, (GLvoid_) (start_6_sizeof(m_pIndices[0])) );
#else
glDrawElements(GL_TRIANGLES, (GLsizei) n_6, GL_UNSIGNED_SHORT, (GLvoid_) (start_6_sizeof(m_pIndices[0])) );
#endif // CC_TEXTURE_ATLAS_USE_TRIANGLE_STRIP

#if CC_REBIND_INDICES_BUFFER
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
#endif

//to avoid glDrawElements crash, here need to unbind VAO. [yang chao]
//see:https://groups.google.com/forum/#!topic/cocos2d-js-devel/2JTlQdKD3BU
ccGLBindVAO(0);//ccGLBindVAO is a wrap of glBindVertexArray

// glBindVertexArray(0);

#else // ! CC_TEXTURE_ATLAS_USE_VAO

@zilongshanren
Copy link
Author

Cool!
It works like a charm:)
Thanks.

@wantnon2
Copy link
Collaborator

glad to hear that:)

@6311879
Copy link

6311879 commented Jan 22, 2014

working nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants