mirror of https://github.com/axmolengine/axmol.git
fix crash on windows
This commit is contained in:
parent
5459149279
commit
79eee9b145
|
@ -185,7 +185,7 @@ void DrawNode::ensureCapacityGLPoint(int count)
|
|||
if(_bufferCountGLPoint + count > _bufferCapacityGLPoint)
|
||||
{
|
||||
_bufferCapacityGLPoint += MAX(_bufferCapacityGLPoint, count);
|
||||
_bufferGLPoint = (V2F_C4B_PF*)realloc(_bufferGLPoint, _bufferCapacityGLPoint*sizeof(V2F_C4B_PF));
|
||||
_bufferGLPoint = (V2F_C4B_T2F*)realloc(_bufferGLPoint, _bufferCapacityGLPoint*sizeof(V2F_C4B_T2F));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -254,15 +254,13 @@ bool DrawNode::init()
|
|||
glGenBuffers(1, &_vboGLPoint);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _vboGLPoint);
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(V2F_C4B_T2F)*_bufferCapacityGLPoint, _bufferGLPoint, GL_STREAM_DRAW);
|
||||
GL::enableVertexAttribs(GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX);
|
||||
// vertex
|
||||
glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_POSITION);
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_PF), (GLvoid *)offsetof(V2F_C4B_PF, vertices));
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, vertices));
|
||||
// color
|
||||
glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_COLOR);
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(V2F_C4B_PF), (GLvoid *)offsetof(V2F_C4B_PF, colors));
|
||||
// pointsize
|
||||
glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_POINTSIZE);
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POINTSIZE, 1, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_PF), (GLvoid *)offsetof(V2F_C4B_PF, pointSize));
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, colors));
|
||||
// Texture coord as pointsize
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORD, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, texCoords));
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
if (Configuration::getInstance()->supportsShareableVAO())
|
||||
|
@ -389,14 +387,14 @@ void DrawNode::onDrawGLLine(const Mat4 &transform, uint32_t flags)
|
|||
|
||||
void DrawNode::onDrawGLPoint(const Mat4 &transform, uint32_t flags)
|
||||
{
|
||||
auto glProgram = GLProgramCache::getInstance()->getGLProgram(GLProgram::SHADER_NAME_POSITION_COLOR_POINTSIZE);
|
||||
auto glProgram = GLProgramCache::getInstance()->getGLProgram(GLProgram::SHADER_NAME_POSITION_COLOR_TEXASPOINTSIZE);
|
||||
glProgram->use();
|
||||
glProgram->setUniformsForBuiltins(transform);
|
||||
|
||||
if (_dirtyGLPoint)
|
||||
{
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _vboGLPoint);
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(V2F_C4B_PF)*_bufferCapacityGLPoint, _bufferGLPoint, GL_STREAM_DRAW);
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(V2F_C4B_T2F)*_bufferCapacityGLPoint, _bufferGLPoint, GL_STREAM_DRAW);
|
||||
|
||||
_dirtyGLPoint = false;
|
||||
}
|
||||
|
@ -408,10 +406,10 @@ void DrawNode::onDrawGLPoint(const Mat4 &transform, uint32_t flags)
|
|||
else
|
||||
{
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _vboGLPoint);
|
||||
GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION | GL::VERTEX_ATTRIB_FLAG_COLOR);
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_PF), (GLvoid *)offsetof(V2F_C4B_PF, vertices));
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(V2F_C4B_PF), (GLvoid *)offsetof(V2F_C4B_PF, colors));
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POINTSIZE, 1, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_PF), (GLvoid *)offsetof(V2F_C4B_PF, pointSize));
|
||||
GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX);
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, vertices));
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, colors));
|
||||
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORD, 1, GL_FLOAT, GL_FALSE, sizeof(V2F_C4B_T2F), (GLvoid *)offsetof(V2F_C4B_T2F, texCoords));
|
||||
}
|
||||
|
||||
glDrawArrays(GL_POINTS, 0, _bufferCountGLPoint);
|
||||
|
@ -425,8 +423,8 @@ void DrawNode::drawPoint(const Vec2& position, const float pointSize, const Colo
|
|||
{
|
||||
ensureCapacityGLPoint(1);
|
||||
|
||||
V2F_C4B_PF *point = (V2F_C4B_PF*)(_bufferGLPoint + _bufferCountGLPoint);
|
||||
V2F_C4B_PF a = {position, Color4B(color), pointSize};
|
||||
V2F_C4B_T2F *point = (V2F_C4B_T2F*)(_bufferGLPoint + _bufferCountGLPoint);
|
||||
V2F_C4B_T2F a = {position, Color4B(color), Tex2F(pointSize,0)};
|
||||
*point = a;
|
||||
|
||||
_bufferCountGLPoint += 1;
|
||||
|
@ -442,11 +440,11 @@ void DrawNode::drawPoints(const Vec2 *position, unsigned int numberOfPoints, con
|
|||
{
|
||||
ensureCapacityGLPoint(numberOfPoints);
|
||||
|
||||
V2F_C4B_PF *point = (V2F_C4B_PF*)(_bufferGLPoint + _bufferCountGLPoint);
|
||||
V2F_C4B_T2F *point = (V2F_C4B_T2F*)(_bufferGLPoint + _bufferCountGLPoint);
|
||||
|
||||
for(unsigned int i=0; i < numberOfPoints; i++,point++)
|
||||
{
|
||||
V2F_C4B_PF a = {position[i], Color4B(color), pointSize};
|
||||
V2F_C4B_T2F a = {position[i], Color4B(color), Tex2F(pointSize,0)};
|
||||
*point = a;
|
||||
}
|
||||
|
||||
|
|
|
@ -154,7 +154,7 @@ protected:
|
|||
|
||||
int _bufferCapacityGLPoint;
|
||||
GLsizei _bufferCountGLPoint;
|
||||
V2F_C4B_PF *_bufferGLPoint;
|
||||
V2F_C4B_T2F *_bufferGLPoint;
|
||||
Color4F _pointColor;
|
||||
int _pointSize;
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ const char* GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP = "ShaderPositi
|
|||
const char* GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST = "ShaderPositionTextureColorAlphaTest";
|
||||
const char* GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST_NO_MV = "ShaderPositionTextureColorAlphaTest_NoMV";
|
||||
const char* GLProgram::SHADER_NAME_POSITION_COLOR = "ShaderPositionColor";
|
||||
const char* GLProgram::SHADER_NAME_POSITION_COLOR_POINTSIZE = "ShaderPositionColorPointsize";
|
||||
const char* GLProgram::SHADER_NAME_POSITION_COLOR_TEXASPOINTSIZE = "ShaderPositionColorTexAsPointsize";
|
||||
const char* GLProgram::SHADER_NAME_POSITION_COLOR_NO_MVP = "ShaderPositionColor_noMVP";
|
||||
const char* GLProgram::SHADER_NAME_POSITION_TEXTURE = "ShaderPositionTexture";
|
||||
const char* GLProgram::SHADER_NAME_POSITION_TEXTURE_U_COLOR = "ShaderPositionTexture_uColor";
|
||||
|
@ -90,7 +90,6 @@ const char* GLProgram::UNIFORM_NAME_ALPHA_TEST_VALUE = "CC_alpha_value";
|
|||
// Attribute names
|
||||
const char* GLProgram::ATTRIBUTE_NAME_COLOR = "a_color";
|
||||
const char* GLProgram::ATTRIBUTE_NAME_POSITION = "a_position";
|
||||
const char* GLProgram::ATTRIBUTE_NAME_POINTSIZE = "a_pointSize";
|
||||
const char* GLProgram::ATTRIBUTE_NAME_TEX_COORD = "a_texCoord";
|
||||
const char* GLProgram::ATTRIBUTE_NAME_TEX_COORD1 = "a_texCoord1";
|
||||
const char* GLProgram::ATTRIBUTE_NAME_TEX_COORD2 = "a_texCoord2";
|
||||
|
@ -278,7 +277,6 @@ void GLProgram::bindPredefinedVertexAttribs()
|
|||
} attribute_locations[] =
|
||||
{
|
||||
{GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION},
|
||||
{GLProgram::ATTRIBUTE_NAME_POINTSIZE, GLProgram::VERTEX_ATTRIB_POINTSIZE},
|
||||
{GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::VERTEX_ATTRIB_COLOR},
|
||||
{GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORD},
|
||||
{GLProgram::ATTRIBUTE_NAME_TEX_COORD1, GLProgram::VERTEX_ATTRIB_TEX_COORD1},
|
||||
|
|
|
@ -89,7 +89,6 @@ public:
|
|||
VERTEX_ATTRIB_NORMAL,
|
||||
VERTEX_ATTRIB_BLEND_WEIGHT,
|
||||
VERTEX_ATTRIB_BLEND_INDEX,
|
||||
VERTEX_ATTRIB_POINTSIZE,
|
||||
VERTEX_ATTRIB_MAX,
|
||||
|
||||
// backward compatibility
|
||||
|
@ -120,7 +119,7 @@ public:
|
|||
static const char* SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST;
|
||||
static const char* SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST_NO_MV;
|
||||
static const char* SHADER_NAME_POSITION_COLOR;
|
||||
static const char* SHADER_NAME_POSITION_COLOR_POINTSIZE;
|
||||
static const char* SHADER_NAME_POSITION_COLOR_TEXASPOINTSIZE;
|
||||
static const char* SHADER_NAME_POSITION_COLOR_NO_MVP;
|
||||
static const char* SHADER_NAME_POSITION_TEXTURE;
|
||||
static const char* SHADER_NAME_POSITION_TEXTURE_U_COLOR;
|
||||
|
@ -161,7 +160,6 @@ public:
|
|||
// Attribute names
|
||||
static const char* ATTRIBUTE_NAME_COLOR;
|
||||
static const char* ATTRIBUTE_NAME_POSITION;
|
||||
static const char* ATTRIBUTE_NAME_POINTSIZE;
|
||||
static const char* ATTRIBUTE_NAME_TEX_COORD;
|
||||
static const char* ATTRIBUTE_NAME_TEX_COORD1;
|
||||
static const char* ATTRIBUTE_NAME_TEX_COORD2;
|
||||
|
|
|
@ -40,7 +40,7 @@ enum {
|
|||
kShaderType_PositionTextureColorAlphaTest,
|
||||
kShaderType_PositionTextureColorAlphaTestNoMV,
|
||||
kShaderType_PositionColor,
|
||||
kShaderType_PositionColorPointsize,
|
||||
kShaderType_PositionColorTextureAsPointsize,
|
||||
kShaderType_PositionColor_noMVP,
|
||||
kShaderType_PositionTexture,
|
||||
kShaderType_PositionTexture_uColor,
|
||||
|
@ -142,8 +142,8 @@ void GLProgramCache::loadDefaultGLPrograms()
|
|||
|
||||
// Position, Color, PointSize shader
|
||||
p = new (std::nothrow) GLProgram();
|
||||
loadDefaultGLProgram(p, kShaderType_PositionColorPointsize);
|
||||
_programs.insert( std::make_pair(GLProgram::SHADER_NAME_POSITION_COLOR_POINTSIZE, p) );
|
||||
loadDefaultGLProgram(p, kShaderType_PositionColorTextureAsPointsize);
|
||||
_programs.insert( std::make_pair(GLProgram::SHADER_NAME_POSITION_COLOR_TEXASPOINTSIZE, p) );
|
||||
|
||||
//
|
||||
// Position, Color shader no MVP
|
||||
|
@ -261,9 +261,9 @@ void GLProgramCache::reloadDefaultGLPrograms()
|
|||
loadDefaultGLProgram(p, kShaderType_PositionColor);
|
||||
|
||||
// Position, Color, PointSize shader
|
||||
p = getGLProgram(GLProgram::SHADER_NAME_POSITION_COLOR_POINTSIZE);
|
||||
p = getGLProgram(GLProgram::SHADER_NAME_POSITION_COLOR_TEXASPOINTSIZE);
|
||||
p->reset();
|
||||
loadDefaultGLProgram(p, kShaderType_PositionColorPointsize);
|
||||
loadDefaultGLProgram(p, kShaderType_PositionColorTextureAsPointsize);
|
||||
|
||||
//
|
||||
// Position, Color shader no MVP
|
||||
|
@ -368,8 +368,8 @@ void GLProgramCache::loadDefaultGLProgram(GLProgram *p, int type)
|
|||
case kShaderType_PositionColor:
|
||||
p->initWithByteArrays(ccPositionColor_vert ,ccPositionColor_frag);
|
||||
break;
|
||||
case kShaderType_PositionColorPointsize:
|
||||
p->initWithByteArrays(ccPositionColorPointsize_vert ,ccPositionColor_frag);
|
||||
case kShaderType_PositionColorTextureAsPointsize:
|
||||
p->initWithByteArrays(ccPositionColorTextureAsPointsize_vert ,ccPositionColor_frag);
|
||||
break;
|
||||
case kShaderType_PositionColor_noMVP:
|
||||
p->initWithByteArrays(ccPositionTextureColor_noMVP_vert ,ccPositionColor_frag);
|
||||
|
|
|
@ -22,11 +22,12 @@
|
|||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
const char* ccPositionColorPointsize_vert = STRINGIFY(
|
||||
const char* ccPositionColorTextureAsPointsize_vert = STRINGIFY(
|
||||
|
||||
attribute vec4 a_position;
|
||||
attribute vec4 a_color;
|
||||
attribute float a_pointSize;
|
||||
|
||||
attribute vec2 a_texCoord;
|
||||
|
||||
\n#ifdef GL_ES\n
|
||||
varying lowp vec4 v_fragmentColor;
|
||||
|
@ -37,7 +38,7 @@ varying vec4 v_fragmentColor;
|
|||
void main()
|
||||
{
|
||||
gl_Position = CC_MVPMatrix * a_position;
|
||||
gl_PointSize = a_pointSize;
|
||||
gl_PointSize = a_texCoord.x;
|
||||
v_fragmentColor = a_color;
|
||||
}
|
||||
);
|
|
@ -43,7 +43,7 @@ NS_CC_BEGIN
|
|||
#include "ccShader_PositionColor.vert"
|
||||
|
||||
//
|
||||
#include "ccShader_PositionColorPointsize.vert"
|
||||
#include "ccShader_PositionColorTextureAsPointsize.vert"
|
||||
|
||||
//
|
||||
#include "ccShader_PositionTexture.frag"
|
||||
|
|
|
@ -42,7 +42,7 @@ extern CC_DLL const GLchar * ccPosition_uColor_vert;
|
|||
extern CC_DLL const GLchar * ccPositionColor_frag;
|
||||
extern CC_DLL const GLchar * ccPositionColor_vert;
|
||||
|
||||
extern CC_DLL const GLchar * ccPositionColorPointsize_vert;
|
||||
extern CC_DLL const GLchar * ccPositionColorTextureAsPointsize_vert;
|
||||
|
||||
extern CC_DLL const GLchar * ccPositionTexture_frag;
|
||||
extern CC_DLL const GLchar * ccPositionTexture_vert;
|
||||
|
|
Loading…
Reference in New Issue