Removes CCVertexAttribBind

This commit is contained in:
Ricardo Quesada 2014-05-08 14:01:26 -07:00
parent 9ea4aa1e16
commit 453b670ad2
3 changed files with 0 additions and 244 deletions

View File

@ -1610,10 +1610,6 @@
500DC9BD19106E89007B91BF /* CCProfiling.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 500DC9BA19106E89007B91BF /* CCProfiling.cpp */; };
500DC9BE19106E89007B91BF /* CCProfiling.h in Headers */ = {isa = PBXBuildFile; fileRef = 500DC9BB19106E89007B91BF /* CCProfiling.h */; };
500DC9BF19106E89007B91BF /* CCProfiling.h in Headers */ = {isa = PBXBuildFile; fileRef = 500DC9BB19106E89007B91BF /* CCProfiling.h */; };
500DC9E5191BF301007B91BF /* CCVertexAttribBind.h in Headers */ = {isa = PBXBuildFile; fileRef = 500DC9E1191BF301007B91BF /* CCVertexAttribBind.h */; };
500DC9E6191BF301007B91BF /* CCVertexAttribBind.h in Headers */ = {isa = PBXBuildFile; fileRef = 500DC9E1191BF301007B91BF /* CCVertexAttribBind.h */; };
500DC9E7191BF301007B91BF /* CCVertexAttribBind.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 500DC9E2191BF301007B91BF /* CCVertexAttribBind.cpp */; };
500DC9E8191BF301007B91BF /* CCVertexAttribBind.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 500DC9E2191BF301007B91BF /* CCVertexAttribBind.cpp */; };
500DC9E9191BF301007B91BF /* CCGLProgramState.h in Headers */ = {isa = PBXBuildFile; fileRef = 500DC9E3191BF301007B91BF /* CCGLProgramState.h */; };
500DC9EA191BF301007B91BF /* CCGLProgramState.h in Headers */ = {isa = PBXBuildFile; fileRef = 500DC9E3191BF301007B91BF /* CCGLProgramState.h */; };
500DC9EB191BF301007B91BF /* CCGLProgramState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 500DC9E4191BF301007B91BF /* CCGLProgramState.cpp */; };
@ -2700,8 +2696,6 @@
500DC9B519106E6D007B91BF /* TransformUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TransformUtils.h; sourceTree = "<group>"; };
500DC9BA19106E89007B91BF /* CCProfiling.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CCProfiling.cpp; path = ../base/CCProfiling.cpp; sourceTree = "<group>"; };
500DC9BB19106E89007B91BF /* CCProfiling.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CCProfiling.h; path = ../base/CCProfiling.h; sourceTree = "<group>"; };
500DC9E1191BF301007B91BF /* CCVertexAttribBind.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCVertexAttribBind.h; sourceTree = "<group>"; };
500DC9E2191BF301007B91BF /* CCVertexAttribBind.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCVertexAttribBind.cpp; sourceTree = "<group>"; };
500DC9E3191BF301007B91BF /* CCGLProgramState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCGLProgramState.h; sourceTree = "<group>"; };
500DC9E4191BF301007B91BF /* CCGLProgramState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCGLProgramState.cpp; sourceTree = "<group>"; };
50272538190BF1B900AAF4ED /* cocos2d.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = cocos2d.h; path = ../cocos/cocos2d.h; sourceTree = "<group>"; };
@ -3258,8 +3252,6 @@
1A570238180BCC580088DEC7 /* shaders */ = {
isa = PBXGroup;
children = (
500DC9E1191BF301007B91BF /* CCVertexAttribBind.h */,
500DC9E2191BF301007B91BF /* CCVertexAttribBind.cpp */,
500DC9E3191BF301007B91BF /* CCGLProgramState.h */,
500DC9E4191BF301007B91BF /* CCGLProgramState.cpp */,
1A57052F180BD9500088DEC7 /* CCGLProgram.cpp */,
@ -5042,7 +5034,6 @@
1A57022F180BCC1A0088DEC7 /* CCParticleSystemQuad.h in Headers */,
500DC96A19106300007B91BF /* CCEventListenerCustom.h in Headers */,
B2AF2F9718EBAEAE00C5807C /* MathUtil.h in Headers */,
500DC9E5191BF301007B91BF /* CCVertexAttribBind.h in Headers */,
1A570236180BCC4D0088DEC7 /* CCScriptSupport.h in Headers */,
1A57024D180BCC6F0088DEC7 /* ccShader_Position_uColor_frag.h in Headers */,
1A57024F180BCC6F0088DEC7 /* ccShader_Position_uColor_vert.h in Headers */,
@ -5653,7 +5644,6 @@
1AD71EAC180E26E600808F54 /* Attachment.h in Headers */,
500DC94719106300007B91BF /* CCDataVisitor.h in Headers */,
2905FA4918CF08D100240AA3 /* UIButton.h in Headers */,
500DC9E6191BF301007B91BF /* CCVertexAttribBind.h in Headers */,
500DC96719106300007B91BF /* CCEventListenerAcceleration.h in Headers */,
1AD71EB0180E26E600808F54 /* AttachmentLoader.h in Headers */,
1AD71EB4180E26E600808F54 /* Bone.h in Headers */,
@ -6216,7 +6206,6 @@
1A570225180BCC1A0088DEC7 /* CCParticleExamples.cpp in Sources */,
1A570229180BCC1A0088DEC7 /* CCParticleSystem.cpp in Sources */,
1A57022D180BCC1A0088DEC7 /* CCParticleSystemQuad.cpp in Sources */,
500DC9E7191BF301007B91BF /* CCVertexAttribBind.cpp in Sources */,
500DC9B01910633C007B91BF /* CCTouch.cpp in Sources */,
50FCEB9B18C72017004AD434 /* ImageViewReader.cpp in Sources */,
500DC9AA19106300007B91BF /* ZipUtils.cpp in Sources */,
@ -6774,7 +6763,6 @@
1AAF5854180E40B9000584C8 /* LocalStorageAndroid.cpp in Sources */,
1A9DCA24180E6955007A3AD4 /* ccFPSImages.c in Sources */,
1A9DCA28180E6955007A3AD4 /* CCGLBufferedNode.cpp in Sources */,
500DC9E8191BF301007B91BF /* CCVertexAttribBind.cpp in Sources */,
50FCEBA018C72017004AD434 /* LayoutReader.cpp in Sources */,
50E6D33518E174130051CA34 /* UIHBox.cpp in Sources */,
500DC98F19106300007B91BF /* CCRef.cpp in Sources */,

View File

@ -1,140 +0,0 @@
/****************************************************************************
Copyright 2014 Chukong Technologies Inc.
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,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN false EVENT SHALL THE
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.
****************************************************************************/
#include "base/CCDirector.h"
#include "2d/CCVertexAttribBind.h"
#include "2d/ccGLStateCache.h"
#include "base/ccMacros.h"
#include "2d/platform/CCFileUtils.h"
#include "2d/uthash.h"
#include "deprecated/CCString.h"
NS_CC_BEGIN
VertexAttribType::VertexAttribType(): _type(GL_FLOAT), _size(0), _location(-1), _offset(0)
{
}
VertexAttribType::VertexAttribType(GLenum type, int size): _type(type), _size(size), _location(-1), _offset(0)
{
switch (type) {
case GL_FLOAT_VEC2:
_type = GL_FLOAT;
_size = 2;
break;
case GL_FLOAT_VEC3:
_type = GL_FLOAT;
_size = 3;
break;
case GL_FLOAT_VEC4:
_type = GL_FLOAT;
_size = 4;
break;
default:
break;
}
}
int VertexAttribType::getByteSize()
{
int byteSize = 0;
switch (_type) {
case GL_BYTE:
case GL_UNSIGNED_BYTE:
byteSize = _size;
break;
case GL_SHORT:
case GL_UNSIGNED_SHORT:
byteSize = _size * sizeof(GLshort);
break;
case GL_FLOAT:
byteSize = _size * sizeof(GLfloat);
break;
default:
CCASSERT(0,"type error");
break;
}
return byteSize;
}
VertexAttribBind::VertexAttribBind(const VertexAttribType* elem, int count)
{
setVertexAttribElems(elem, count);
}
VertexAttribBind::VertexAttribBind(const std::vector<VertexAttribType>& elems)
{
setVertexAttribElems(&elems[0], elems.size());
}
VertexAttribBind::VertexAttribBind(const std::vector<VertexAttrib*>& attribs)
{
std::vector<VertexAttribType> elems;
for (auto it = attribs.begin(); it != attribs.end(); it++) {
VertexAttribType type((*it)->type, (*it)->size);
type._location = (*it)->index;
elems.push_back(type);
}
setVertexAttribElems(&elems[0], elems.size());
}
VertexAttribBind::~VertexAttribBind()
{
delete[] _vertexAttribs;
}
void VertexAttribBind::bindAttribute(int index, int attribLocation)
{
//make sure index and attribute location are validate
_vertexAttribs[index]._location = attribLocation;
}
//bind attributes pointer
void VertexAttribBind::bindAttributePtr(void* vertexPointer)
{
for (auto i = 0; i < _vertexAtttribCount; i++) {
auto elem = _vertexAttribs[i];
if (elem._location != -1)
{
glEnableVertexAttribArray(elem._location);
void* pointer = vertexPointer ? (void*)(((unsigned char*)vertexPointer) + elem._offset) : (void*)elem._offset;
glVertexAttribPointer(elem._location, elem._size, elem._type, GL_FALSE, _stride, pointer);
}
}
}
void VertexAttribBind::setVertexAttribElems(const VertexAttribType* elem, int count)
{
_vertexAtttribCount = count;
_vertexAttribs = new VertexAttribType[count];
_stride = 0;
for (auto i = 0; i < count; i++) {
_vertexAttribs[i] = elem[i];
_vertexAttribs[i]._offset = _stride;
_stride += _vertexAttribs[i].getByteSize();
}
}
NS_CC_END

View File

@ -1,92 +0,0 @@
/****************************************************************************
Copyright 2014 Chukong Technologies Inc.
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,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN false EVENT SHALL THE
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.
****************************************************************************/
#ifndef __CCVRETEXATTRIBBIND_H__
#define __CCVRETEXATTRIBBIND_H__
#include "base/ccMacros.h"
#include "base/CCRef.h"
#include "CCGL.h"
#include "math/CCMath.h"
#include "2d/CCGLProgram.h"
#include <set>
NS_CC_BEGIN
USING_NS_CC_MATH;
////vertex attribute/////
class VertexAttribType
{
friend class VertexAttribBind;
friend class GLProgram;
public:
VertexAttribType();
VertexAttribType(GLenum type, int size);
int getByteSize();
protected:
GLenum _type;
int _size;
int _location;
int _offset;
};
////vertex attributes bind
class VertexAttribBind
{
public:
VertexAttribBind(const VertexAttribType* elem, int count);
VertexAttribBind(const std::vector<VertexAttribType>& elems);
VertexAttribBind(const std::vector<VertexAttrib*>& attribs);
virtual ~VertexAttribBind();
/**
* bind vertex attributes.
*
* @param index Position in _vertexAttribs
* @param attribLocation location in shader. It can be queried from GLProgram, eg. program->getAttribLocation("a_position")
*/
void bindAttribute(int index, int attribLocation);
/**bind attributes pointer**/
void bindAttributePtr(void* vertexPointer = nullptr);
protected:
void setVertexAttribElems(const VertexAttribType* elem, int count);
VertexAttribType* _vertexAttribs;
int _vertexAtttribCount;
int _stride;
};
NS_CC_END
#endif /* __CCVRETEXATTRIBBIND_H__ */