2011-03-30 15:00:13 +08:00
|
|
|
/****************************************************************************
|
2012-06-14 15:13:16 +08:00
|
|
|
Copyright (c) 2010-2012 cocos2d-x.org
|
2012-03-14 16:10:01 +08:00
|
|
|
Copyright (c) 2011 ForzeField Studios S.L.
|
2011-03-30 15:00:13 +08:00
|
|
|
|
|
|
|
http://www.cocos2d-x.org
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
2012-03-14 16:10:01 +08:00
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN false EVENT SHALL THE
|
2011-03-30 15:00:13 +08:00
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
2012-04-19 14:35:52 +08:00
|
|
|
#include "CCMotionStreak.h"
|
2012-06-19 16:20:46 +08:00
|
|
|
#include "textures/CCTextureCache.h"
|
|
|
|
#include "shaders/ccGLStateCache.h"
|
|
|
|
#include "shaders/CCGLProgram.h"
|
|
|
|
#include "shaders/CCShaderCache.h"
|
2012-04-19 14:35:52 +08:00
|
|
|
#include "ccMacros.h"
|
|
|
|
|
|
|
|
#include "support/CCVertex.h"
|
2012-06-19 16:20:46 +08:00
|
|
|
#include "support/CCPointExtension.h"
|
2011-03-30 15:00:13 +08:00
|
|
|
|
2012-03-14 14:55:17 +08:00
|
|
|
NS_CC_BEGIN
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
MotionStreak::MotionStreak()
|
2013-06-15 14:03:30 +08:00
|
|
|
: _fastMode(false)
|
|
|
|
, _startingPositionInitialized(false)
|
|
|
|
, _texture(NULL)
|
2013-06-20 14:13:12 +08:00
|
|
|
, _positionR(PointZero)
|
2013-06-15 14:03:30 +08:00
|
|
|
, _stroke(0.0f)
|
|
|
|
, _fadeDelta(0.0f)
|
|
|
|
, _minSeg(0.0f)
|
|
|
|
, _maxPoints(0)
|
|
|
|
, _nuPoints(0)
|
|
|
|
, _previousNuPoints(0)
|
|
|
|
, _pointVertexes(NULL)
|
|
|
|
, _pointState(NULL)
|
|
|
|
, _vertices(NULL)
|
|
|
|
, _colorPointer(NULL)
|
|
|
|
, _texCoords(NULL)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_blendFunc.src = GL_SRC_ALPHA;
|
|
|
|
_blendFunc.dst = GL_ONE_MINUS_SRC_ALPHA;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
MotionStreak::~MotionStreak()
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
CC_SAFE_RELEASE(_texture);
|
|
|
|
CC_SAFE_FREE(_pointState);
|
|
|
|
CC_SAFE_FREE(_pointVertexes);
|
|
|
|
CC_SAFE_FREE(_vertices);
|
|
|
|
CC_SAFE_FREE(_colorPointer);
|
|
|
|
CC_SAFE_FREE(_texCoords);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-07-05 16:49:22 +08:00
|
|
|
MotionStreak* MotionStreak::create(float fade, float minSeg, float stroke, const Color3B& color, const char* path)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-20 14:13:12 +08:00
|
|
|
MotionStreak *pRet = new MotionStreak();
|
2012-04-19 14:35:52 +08:00
|
|
|
if (pRet && pRet->initWithFade(fade, minSeg, stroke, color, path))
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
CC_SAFE_DELETE(pRet);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2013-07-05 16:49:22 +08:00
|
|
|
MotionStreak* MotionStreak::create(float fade, float minSeg, float stroke, const Color3B& color, Texture2D* texture)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-20 14:13:12 +08:00
|
|
|
MotionStreak *pRet = new MotionStreak();
|
2012-04-19 14:35:52 +08:00
|
|
|
if (pRet && pRet->initWithFade(fade, minSeg, stroke, color, texture))
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
CC_SAFE_DELETE(pRet);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2013-07-05 16:49:22 +08:00
|
|
|
bool MotionStreak::initWithFade(float fade, float minSeg, float stroke, const Color3B& color, const char* path)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
CCAssert(path != NULL, "Invalid filename");
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
Texture2D *texture = TextureCache::sharedTextureCache()->addImage(path);
|
2012-04-19 14:35:52 +08:00
|
|
|
return initWithFade(fade, minSeg, stroke, color, texture);
|
|
|
|
}
|
|
|
|
|
2013-07-05 16:49:22 +08:00
|
|
|
bool MotionStreak::initWithFade(float fade, float minSeg, float stroke, const Color3B& color, Texture2D* texture)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-20 14:13:12 +08:00
|
|
|
Node::setPosition(PointZero);
|
|
|
|
setAnchorPoint(PointZero);
|
2012-06-15 15:10:40 +08:00
|
|
|
ignoreAnchorPointForPosition(true);
|
2013-06-15 14:03:30 +08:00
|
|
|
_startingPositionInitialized = false;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
_positionR = PointZero;
|
2013-06-15 14:03:30 +08:00
|
|
|
_fastMode = true;
|
|
|
|
_minSeg = (minSeg == -1.0f) ? stroke/5.0f : minSeg;
|
|
|
|
_minSeg *= _minSeg;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_stroke = stroke;
|
|
|
|
_fadeDelta = 1.0f/fade;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_maxPoints = (int)(fade*60.0f)+2;
|
|
|
|
_nuPoints = 0;
|
|
|
|
_pointState = (float *)malloc(sizeof(float) * _maxPoints);
|
2013-06-20 14:13:12 +08:00
|
|
|
_pointVertexes = (Point*)malloc(sizeof(Point) * _maxPoints);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-07-05 16:49:22 +08:00
|
|
|
_vertices = (Vertex2F*)malloc(sizeof(Vertex2F) * _maxPoints * 2);
|
|
|
|
_texCoords = (Tex2F*)malloc(sizeof(Tex2F) * _maxPoints * 2);
|
2013-06-15 14:03:30 +08:00
|
|
|
_colorPointer = (GLubyte*)malloc(sizeof(GLubyte) * _maxPoints * 2 * 4);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// Set blend mode
|
2013-06-15 14:03:30 +08:00
|
|
|
_blendFunc.src = GL_SRC_ALPHA;
|
|
|
|
_blendFunc.dst = GL_ONE_MINUS_SRC_ALPHA;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// shader program
|
2013-06-20 14:13:12 +08:00
|
|
|
setShaderProgram(ShaderCache::sharedShaderCache()->programForKey(kShader_PositionTextureColor));
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
setTexture(texture);
|
|
|
|
setColor(color);
|
|
|
|
scheduleUpdate();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
void MotionStreak::setPosition(const Point& position)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_startingPositionInitialized = true;
|
|
|
|
_positionR = position;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-07-05 16:49:22 +08:00
|
|
|
void MotionStreak::tintWithColor(const Color3B& colors)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
setColor(colors);
|
|
|
|
|
|
|
|
// Fast assignation
|
2013-06-15 14:03:30 +08:00
|
|
|
for(unsigned int i = 0; i<_nuPoints*2; i++)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-07-05 16:49:22 +08:00
|
|
|
*((Color3B*) (_colorPointer+i*4)) = colors;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
Texture2D* MotionStreak::getTexture(void)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
return _texture;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
void MotionStreak::setTexture(Texture2D *texture)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
if (_texture != texture)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
CC_SAFE_RETAIN(texture);
|
2013-06-15 14:03:30 +08:00
|
|
|
CC_SAFE_RELEASE(_texture);
|
|
|
|
_texture = texture;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-05 16:49:22 +08:00
|
|
|
void MotionStreak::setBlendFunc(const BlendFunc &blendFunc)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_blendFunc = blendFunc;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-07-05 16:49:22 +08:00
|
|
|
const BlendFunc& MotionStreak::getBlendFunc(void) const
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
return _blendFunc;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
void MotionStreak::setOpacity(GLubyte opacity)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
CCAssert(false, "Set opacity no supported");
|
|
|
|
}
|
|
|
|
|
2013-07-04 12:50:17 +08:00
|
|
|
GLubyte MotionStreak::getOpacity(void) const
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
CCAssert(false, "Opacity no supported");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
void MotionStreak::setOpacityModifyRGB(bool bValue)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
CC_UNUSED_PARAM(bValue);
|
|
|
|
}
|
|
|
|
|
2013-07-04 12:50:17 +08:00
|
|
|
bool MotionStreak::isOpacityModifyRGB(void) const
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
void MotionStreak::update(float delta)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
if (!_startingPositionInitialized)
|
2012-06-08 14:11:48 +08:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
delta *= _fadeDelta;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
unsigned int newIdx, newIdx2, i, i2;
|
|
|
|
unsigned int mov = 0;
|
|
|
|
|
|
|
|
// Update current points
|
2013-06-15 14:03:30 +08:00
|
|
|
for(i = 0; i<_nuPoints; i++)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_pointState[i]-=delta;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
if(_pointState[i] <= 0)
|
2012-04-19 14:35:52 +08:00
|
|
|
mov++;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
newIdx = i-mov;
|
|
|
|
|
|
|
|
if(mov>0)
|
|
|
|
{
|
|
|
|
// Move data
|
2013-06-15 14:03:30 +08:00
|
|
|
_pointState[newIdx] = _pointState[i];
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// Move point
|
2013-06-15 14:03:30 +08:00
|
|
|
_pointVertexes[newIdx] = _pointVertexes[i];
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// Move vertices
|
|
|
|
i2 = i*2;
|
|
|
|
newIdx2 = newIdx*2;
|
2013-06-15 14:03:30 +08:00
|
|
|
_vertices[newIdx2] = _vertices[i2];
|
|
|
|
_vertices[newIdx2+1] = _vertices[i2+1];
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// Move color
|
|
|
|
i2 *= 4;
|
|
|
|
newIdx2 *= 4;
|
2013-06-15 14:03:30 +08:00
|
|
|
_colorPointer[newIdx2+0] = _colorPointer[i2+0];
|
|
|
|
_colorPointer[newIdx2+1] = _colorPointer[i2+1];
|
|
|
|
_colorPointer[newIdx2+2] = _colorPointer[i2+2];
|
|
|
|
_colorPointer[newIdx2+4] = _colorPointer[i2+4];
|
|
|
|
_colorPointer[newIdx2+5] = _colorPointer[i2+5];
|
|
|
|
_colorPointer[newIdx2+6] = _colorPointer[i2+6];
|
2012-04-19 14:35:52 +08:00
|
|
|
}else
|
|
|
|
newIdx2 = newIdx*8;
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
const GLubyte op = (GLubyte)(_pointState[newIdx] * 255.0f);
|
|
|
|
_colorPointer[newIdx2+3] = op;
|
|
|
|
_colorPointer[newIdx2+7] = op;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
}
|
2013-06-15 14:03:30 +08:00
|
|
|
_nuPoints-=mov;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// Append new point
|
|
|
|
bool appendNewPoint = true;
|
2013-06-15 14:03:30 +08:00
|
|
|
if(_nuPoints >= _maxPoints)
|
2012-06-08 14:11:48 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
appendNewPoint = false;
|
2012-06-08 14:11:48 +08:00
|
|
|
}
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
else if(_nuPoints>0)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
bool a1 = ccpDistanceSQ(_pointVertexes[_nuPoints-1], _positionR) < _minSeg;
|
|
|
|
bool a2 = (_nuPoints == 1) ? false : (ccpDistanceSQ(_pointVertexes[_nuPoints-2], _positionR) < (_minSeg * 2.0f));
|
2012-04-19 14:35:52 +08:00
|
|
|
if(a1 || a2)
|
2012-06-08 14:11:48 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
appendNewPoint = false;
|
2012-06-08 14:11:48 +08:00
|
|
|
}
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if(appendNewPoint)
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_pointVertexes[_nuPoints] = _positionR;
|
|
|
|
_pointState[_nuPoints] = 1.0f;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2012-09-17 15:02:24 +08:00
|
|
|
// Color assignment
|
2013-06-15 14:03:30 +08:00
|
|
|
const unsigned int offset = _nuPoints*8;
|
2013-07-05 16:49:22 +08:00
|
|
|
*((Color3B*)(_colorPointer + offset)) = _displayedColor;
|
|
|
|
*((Color3B*)(_colorPointer + offset+4)) = _displayedColor;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// Opacity
|
2013-06-15 14:03:30 +08:00
|
|
|
_colorPointer[offset+3] = 255;
|
|
|
|
_colorPointer[offset+7] = 255;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// Generate polygon
|
2013-06-15 14:03:30 +08:00
|
|
|
if(_nuPoints > 0 && _fastMode )
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
if(_nuPoints > 1)
|
2012-06-08 14:11:48 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
ccVertexLineToPolygon(_pointVertexes, _stroke, _vertices, _nuPoints, 1);
|
2012-06-08 14:11:48 +08:00
|
|
|
}
|
2012-04-19 14:35:52 +08:00
|
|
|
else
|
2012-06-08 14:11:48 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
ccVertexLineToPolygon(_pointVertexes, _stroke, _vertices, 0, 2);
|
2012-06-08 14:11:48 +08:00
|
|
|
}
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_nuPoints ++;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
if( ! _fastMode )
|
2012-06-08 14:11:48 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
ccVertexLineToPolygon(_pointVertexes, _stroke, _vertices, 0, _nuPoints);
|
2012-06-08 14:11:48 +08:00
|
|
|
}
|
|
|
|
|
2012-06-14 05:26:28 +08:00
|
|
|
// Updated Tex Coords only if they are different than previous step
|
2013-06-15 14:03:30 +08:00
|
|
|
if( _nuPoints && _previousNuPoints != _nuPoints ) {
|
|
|
|
float texDelta = 1.0f / _nuPoints;
|
|
|
|
for( i=0; i < _nuPoints; i++ ) {
|
2013-07-05 16:49:22 +08:00
|
|
|
_texCoords[i*2] = Tex2F(0, texDelta*i);
|
|
|
|
_texCoords[i*2+1] = Tex2F(1, texDelta*i);
|
2012-06-14 05:26:28 +08:00
|
|
|
}
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_previousNuPoints = _nuPoints;
|
2012-06-08 14:11:48 +08:00
|
|
|
}
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
void MotionStreak::reset()
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_nuPoints = 0;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
void MotionStreak::draw()
|
2012-03-14 16:10:01 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
if(_nuPoints <= 1)
|
2012-04-19 14:35:52 +08:00
|
|
|
return;
|
|
|
|
|
|
|
|
CC_NODE_DRAW_SETUP();
|
|
|
|
|
2013-06-20 14:13:12 +08:00
|
|
|
ccGLEnableVertexAttribs(kVertexAttribFlag_PosColorTex );
|
2013-06-15 14:03:30 +08:00
|
|
|
ccGLBlendFunc( _blendFunc.src, _blendFunc.dst );
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
ccGLBindTexture2D( _texture->getName() );
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-04-09 10:09:38 +08:00
|
|
|
#ifdef EMSCRIPTEN
|
2013-04-09 12:08:34 +08:00
|
|
|
// Size calculations from ::initWithFade
|
2013-07-05 16:49:22 +08:00
|
|
|
setGLBufferData(_vertices, (sizeof(Vertex2F) * _maxPoints * 2), 0);
|
2013-06-20 14:13:12 +08:00
|
|
|
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, 0);
|
2013-04-09 10:09:38 +08:00
|
|
|
|
2013-07-05 16:49:22 +08:00
|
|
|
setGLBufferData(_texCoords, (sizeof(Tex2F) * _maxPoints * 2), 1);
|
2013-06-20 14:13:12 +08:00
|
|
|
glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, 0, 0);
|
2013-04-09 10:09:38 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
setGLBufferData(_colorPointer, (sizeof(GLubyte) * _maxPoints * 2 * 4), 2);
|
2013-06-20 14:13:12 +08:00
|
|
|
glVertexAttribPointer(kVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, 0, 0);
|
2013-04-09 10:09:38 +08:00
|
|
|
#else
|
2013-06-20 14:13:12 +08:00
|
|
|
glVertexAttribPointer(kVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, _vertices);
|
|
|
|
glVertexAttribPointer(kVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, 0, _texCoords);
|
|
|
|
glVertexAttribPointer(kVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, 0, _colorPointer);
|
2013-04-09 10:09:38 +08:00
|
|
|
#endif // EMSCRIPTEN
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, (GLsizei)_nuPoints*2);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
CC_INCREMENT_GL_DRAWS(1);
|
2012-03-14 16:10:01 +08:00
|
|
|
}
|
2010-08-19 10:14:54 +08:00
|
|
|
|
2012-03-14 14:55:17 +08:00
|
|
|
NS_CC_END
|
2010-08-19 10:14:54 +08:00
|
|
|
|