issue #1555:build ok on android

This commit is contained in:
minggo 2012-11-16 14:23:14 +08:00
parent cb2bc37513
commit a4a53df159
13 changed files with 71 additions and 26 deletions

View File

@ -8,7 +8,6 @@ LOCAL_MODULE_FILENAME := libcocos2d
LOCAL_SRC_FILES := \ LOCAL_SRC_FILES := \
CCConfiguration.cpp \ CCConfiguration.cpp \
CCDrawingPrimitives.cpp \
CCScheduler.cpp \ CCScheduler.cpp \
CCCamera.cpp \ CCCamera.cpp \
actions/CCAction.cpp \ actions/CCAction.cpp \
@ -38,6 +37,8 @@ cocoa/CCZone.cpp \
cocoa/CCArray.cpp \ cocoa/CCArray.cpp \
cocos2d.cpp \ cocos2d.cpp \
CCDirector.cpp \ CCDirector.cpp \
draw_nodes/CCDrawingPrimitives.cpp \
draw_nodes/CCDrawNode.cpp \
effects/CCGrabber.cpp \ effects/CCGrabber.cpp \
effects/CCGrid.cpp \ effects/CCGrid.cpp \
kazmath/src/aabb.c \ kazmath/src/aabb.c \
@ -65,6 +66,7 @@ layers_scenes_transitions_nodes/CCTransition.cpp \
layers_scenes_transitions_nodes/CCTransitionProgress.cpp \ layers_scenes_transitions_nodes/CCTransitionProgress.cpp \
menu_nodes/CCMenu.cpp \ menu_nodes/CCMenu.cpp \
menu_nodes/CCMenuItem.cpp \ menu_nodes/CCMenuItem.cpp \
misc_nodes/CCClippingNode.cpp \
misc_nodes/CCMotionStreak.cpp \ misc_nodes/CCMotionStreak.cpp \
misc_nodes/CCProgressTimer.cpp \ misc_nodes/CCProgressTimer.cpp \
misc_nodes/CCRenderTexture.cpp \ misc_nodes/CCRenderTexture.cpp \
@ -72,6 +74,8 @@ particle_nodes/CCParticleExamples.cpp \
particle_nodes/CCParticleSystem.cpp \ particle_nodes/CCParticleSystem.cpp \
particle_nodes/CCParticleBatchNode.cpp \ particle_nodes/CCParticleBatchNode.cpp \
particle_nodes/CCParticleSystemQuad.cpp \ particle_nodes/CCParticleSystemQuad.cpp \
physics_nodes/CCPhysicsDebugNode.cpp \
physics_nodes/CCPhysicsSprite.cpp \
platform/CCSAXParser.cpp \ platform/CCSAXParser.cpp \
platform/CCThread.cpp \ platform/CCThread.cpp \
platform/platform.cpp \ platform/platform.cpp \

View File

@ -27,7 +27,7 @@ THE SOFTWARE.
#include "cocoa/CCString.h" #include "cocoa/CCString.h"
#include "CCGL.h" #include "CCGL.h"
#include "CCDrawingPrimitives.h" #include "draw_nodes/CCDrawingPrimitives.h"
#include "CCDirector.h" #include "CCDirector.h"
#include "kazmath/GL/matrix.h" #include "kazmath/GL/matrix.h"

View File

@ -23,6 +23,7 @@
#include "CCDrawNode.h" #include "CCDrawNode.h"
#include "support/CCPointExtension.h" #include "support/CCPointExtension.h"
#include "shaders/CCShaderCache.h" #include "shaders/CCShaderCache.h"
#include "CCGL.h"
NS_CC_BEGIN NS_CC_BEGIN
@ -110,8 +111,10 @@ CCDrawNode::~CCDrawNode()
glDeleteBuffers(1, &m_uVbo); glDeleteBuffers(1, &m_uVbo);
m_uVbo = 0; m_uVbo = 0;
#if CC_TEXTURE_ATLAS_USE_VAO
glDeleteVertexArrays(1, &m_uVao); glDeleteVertexArrays(1, &m_uVao);
m_uVao = 0; m_uVao = 0;
#endif
} }
CCDrawNode* CCDrawNode::create() CCDrawNode* CCDrawNode::create()
@ -146,8 +149,10 @@ bool CCDrawNode::init()
ensureCapacity(512); ensureCapacity(512);
#if CC_TEXTURE_ATLAS_USE_VAO
glGenVertexArrays(1, &m_uVao); glGenVertexArrays(1, &m_uVao);
ccGLBindVAO(m_uVao); ccGLBindVAO(m_uVao);
#endif
glGenBuffers(1, &m_uVbo); glGenBuffers(1, &m_uVbo);
glBindBuffer(GL_ARRAY_BUFFER, m_uVbo); glBindBuffer(GL_ARRAY_BUFFER, m_uVbo);
@ -163,7 +168,10 @@ bool CCDrawNode::init()
glVertexAttribPointer(kCCVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, sizeof(ccV2F_C4B_T2F), (GLvoid *)offsetof(ccV2F_C4B_T2F, texCoords)); glVertexAttribPointer(kCCVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, sizeof(ccV2F_C4B_T2F), (GLvoid *)offsetof(ccV2F_C4B_T2F, texCoords));
glBindBuffer(GL_ARRAY_BUFFER, 0); glBindBuffer(GL_ARRAY_BUFFER, 0);
#if CC_TEXTURE_ATLAS_USE_VAO
ccGLBindVAO(0); ccGLBindVAO(0);
#endif
CHECK_GL_ERROR_DEBUG(); CHECK_GL_ERROR_DEBUG();
@ -174,16 +182,34 @@ bool CCDrawNode::init()
void CCDrawNode::render() void CCDrawNode::render()
{ {
glBindBuffer(GL_ARRAY_BUFFER, m_uVbo);
if (m_bDirty) if (m_bDirty)
{ {
glBindBuffer(GL_ARRAY_BUFFER, m_uVbo);
glBufferData(GL_ARRAY_BUFFER, sizeof(ccV2F_C4B_T2F)*m_uBufferCapacity, m_pBuffer, GL_STREAM_DRAW); glBufferData(GL_ARRAY_BUFFER, sizeof(ccV2F_C4B_T2F)*m_uBufferCapacity, m_pBuffer, GL_STREAM_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
m_bDirty = false; m_bDirty = false;
} }
#if CC_TEXTURE_ATLAS_USE_VAO
ccGLBindVAO(m_uVao); ccGLBindVAO(m_uVao);
#else
ccGLEnableVertexAttribs(kCCVertexAttribFlag_PosColorTex);
// vertex
int diff = offsetof(ccV2F_C4B_T2F, vertices);
glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, sizeof(ccV2F_C4B_T2F), (GLvoid *)(m_pBuffer+diff));
// color
diff = offsetof(ccV2F_C4B_T2F, colors);
glVertexAttribPointer(kCCVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_FALSE, sizeof(ccV2F_C4B_T2F), (GLvoid *)(m_pBuffer+diff));
// texcood
diff = offsetof(ccV2F_C4B_T2F, texCoords);
glVertexAttribPointer(kCCVertexAttrib_Color, 2, GL_FLOAT, GL_FALSE, sizeof(ccV2F_C4B_T2F), (GLvoid *)(m_pBuffer+diff));
#endif
glDrawArrays(GL_TRIANGLES, 0, m_nBufferCount); glDrawArrays(GL_TRIANGLES, 0, m_nBufferCount);
glBindBuffer(GL_ARRAY_BUFFER, 0);
CC_INCREMENT_GL_DRAWS(1); CC_INCREMENT_GL_DRAWS(1);
CHECK_GL_ERROR_DEBUG(); CHECK_GL_ERROR_DEBUG();

View File

@ -26,7 +26,7 @@ THE SOFTWARE.
#include "CCLabelAtlas.h" #include "CCLabelAtlas.h"
#include "textures/CCTextureAtlas.h" #include "textures/CCTextureAtlas.h"
#include "support/CCPointExtension.h" #include "support/CCPointExtension.h"
#include "CCDrawingPrimitives.h" #include "draw_nodes/CCDrawingPrimitives.h"
#include "ccConfig.h" #include "ccConfig.h"
#include "shaders/CCShaderCache.h" #include "shaders/CCShaderCache.h"
#include "shaders/CCGLProgram.h" #include "shaders/CCGLProgram.h"

View File

@ -35,7 +35,7 @@ http://www.angelcode.com/products/bmfont/ (Free, Windows only)
#include "platform/platform.h" #include "platform/platform.h"
#include "cocoa/CCDictionary.h" #include "cocoa/CCDictionary.h"
#include "CCConfiguration.h" #include "CCConfiguration.h"
#include "CCDrawingPrimitives.h" #include "draw_nodes/CCDrawingPrimitives.h"
#include "sprite_nodes/CCSprite.h" #include "sprite_nodes/CCSprite.h"
#include "support/CCPointExtension.h" #include "support/CCPointExtension.h"
#include "platform/CCFileUtils.h" #include "platform/CCFileUtils.h"

View File

@ -26,7 +26,7 @@
*/ */
#include "CCClippingNode.h" #include "CCClippingNode.h"
#import "kazmath/GL/matrix.h" #include "kazmath/GL/matrix.h"
#include "shaders/CCGLProgram.h" #include "shaders/CCGLProgram.h"
#include "shaders/CCShaderCache.h" #include "shaders/CCShaderCache.h"
#include "CCDirector.h" #include "CCDirector.h"

View File

@ -32,7 +32,7 @@ THE SOFTWARE.
#include "shaders/ccGLStateCache.h" #include "shaders/ccGLStateCache.h"
#include "CCDirector.h" #include "CCDirector.h"
#include "support/TransformUtils.h" #include "support/TransformUtils.h"
#include "CCDrawingPrimitives.h" #include "draw_nodes/CCDrawingPrimitives.h"
// extern // extern
#include "kazmath/GL/matrix.h" #include "kazmath/GL/matrix.h"

View File

@ -36,10 +36,13 @@ THE SOFTWARE.
#if CC_TEXTURE_ATLAS_USE_VAO #if CC_TEXTURE_ATLAS_USE_VAO
#include <EGL/egl.h>
PFNGLGENVERTEXARRAYSOESPROC glGenVertexArraysOESEXT = 0; // <EGL/egl.h> exists since android 2.3
PFNGLBINDVERTEXARRAYOESPROC glBindVertexArrayOESEXT = 0; #include <EGL/egl.h>
PFNGLDELETEVERTEXARRAYSOESPROC glDeleteVertexArraysOESEXT = 0; PFNGLGENVERTEXARRAYSOESPROC glGenVertexArraysOESEXT = 0;
PFNGLBINDVERTEXARRAYOESPROC glBindVertexArrayOESEXT = 0;
PFNGLDELETEVERTEXARRAYSOESPROC glDeleteVertexArraysOESEXT = 0;
#endif #endif
void initExtensions() { void initExtensions() {

View File

@ -25,11 +25,15 @@ THE SOFTWARE.
#ifndef __CCGL_H__ #ifndef __CCGL_H__
#define __CCGL_H__ #define __CCGL_H__
#define glClearDepth glClearDepthf #define glClearDepth glClearDepthf
#define glDeleteVertexArrays glDeleteVertexArraysOES #define glDeleteVertexArrays glDeleteVertexArraysOES
#define glGenVertexArrays glGenVertexArraysOES #define glGenVertexArrays glGenVertexArraysOES
#define glBindVertexArray glBindVertexArrayOES #define glBindVertexArray glBindVertexArrayOES
#define CC_GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8_OES #define glMapBuffer glMapBufferOES
#define glUnmapBuffer glUnmapBufferOES
#define GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8_OES
#define GL_WRITE_ONLY GL_WRITE_ONLY_OES
// GL_GLEXT_PROTOTYPES isn't defined in glplatform.h on android ndk r7 // GL_GLEXT_PROTOTYPES isn't defined in glplatform.h on android ndk r7
// we manually define it here // we manually define it here
@ -43,6 +47,10 @@ THE SOFTWARE.
#include <GLES2/gl2ext.h> #include <GLES2/gl2ext.h>
// gl2.h doesn't define GLchar on Android // gl2.h doesn't define GLchar on Android
typedef char GLchar; typedef char GLchar;
// android defines GL_BGRA_EXT but not GL_BRGA
#ifndef GL_BGRA
#define GL_BGRA 0x80E1
#endif
//declare here while define in CCEGLView_android.cpp //declare here while define in CCEGLView_android.cpp
extern PFNGLGENVERTEXARRAYSOESPROC glGenVertexArraysOESEXT; extern PFNGLGENVERTEXARRAYSOESPROC glGenVertexArraysOESEXT;

View File

@ -179,6 +179,8 @@ void ccGLDeleteTextureN(GLuint textureUnit, GLuint textureId)
void ccGLBindVAO(GLuint vaoId) void ccGLBindVAO(GLuint vaoId)
{ {
#if CC_TEXTURE_ATLAS_USE_VAO
#if CC_ENABLE_GL_STATE_CACHE #if CC_ENABLE_GL_STATE_CACHE
if (s_uVAO != vaoId) if (s_uVAO != vaoId)
{ {
@ -187,6 +189,8 @@ void ccGLBindVAO(GLuint vaoId)
} }
#else #else
glBindVertexArray(vaoId); glBindVertexArray(vaoId);
#endif // CC_ENABLE_GL_STATE_CACHE
#endif #endif
} }

View File

@ -32,13 +32,12 @@ THE SOFTWARE.
#include "CCSpriteFrame.h" #include "CCSpriteFrame.h"
#include "CCSpriteFrameCache.h" #include "CCSpriteFrameCache.h"
#include "textures/CCTextureCache.h" #include "textures/CCTextureCache.h"
#include "CCDrawingPrimitives.h" #include "draw_nodes/CCDrawingPrimitives.h"
#include "shaders/CCShaderCache.h" #include "shaders/CCShaderCache.h"
#include "shaders/ccGLStateCache.h" #include "shaders/ccGLStateCache.h"
#include "shaders/CCGLProgram.h" #include "shaders/CCGLProgram.h"
#include "CCDirector.h" #include "CCDirector.h"
#include "support/CCPointExtension.h" #include "support/CCPointExtension.h"
#include "CCDrawingPrimitives.h"
#include "cocoa/CCGeometry.h" #include "cocoa/CCGeometry.h"
#include "textures/CCTexture2D.h" #include "textures/CCTexture2D.h"
#include "cocoa/CCAffineTransform.h" #include "cocoa/CCAffineTransform.h"

View File

@ -28,7 +28,7 @@ THE SOFTWARE.
#include "ccConfig.h" #include "ccConfig.h"
#include "CCSprite.h" #include "CCSprite.h"
#include "effects/CCGrid.h" #include "effects/CCGrid.h"
#include "CCDrawingPrimitives.h" #include "draw_nodes/CCDrawingPrimitives.h"
#include "textures/CCTextureCache.h" #include "textures/CCTextureCache.h"
#include "support/CCPointExtension.h" #include "support/CCPointExtension.h"
#include "shaders/CCShaderCache.h" #include "shaders/CCShaderCache.h"

View File

@ -900,11 +900,12 @@ void VolatileTexture::reloadAllTextures()
case kString: case kString:
{ {
vt->texture->initWithString(vt->m_strText.c_str(), vt->texture->initWithString(vt->m_strText.c_str(),
vt->m_size, vt->m_strFontName.c_str(),
vt->m_alignment, vt->m_fFontSize,
vt->m_vAlignment, vt->m_size,
vt->m_strFontName.c_str(), vt->m_alignment,
vt->m_fFontSize); vt->m_vAlignment
);
} }
break; break;
case kImage: case kImage: