[cocos2d-x] Added ETC1 support, thanks @halx99. Closes #989

This commit is contained in:
badlogic 2017-09-25 11:44:28 +02:00
parent a8f50bdecc
commit c1538b113b
3 changed files with 972 additions and 943 deletions

View File

@ -62,6 +62,7 @@
* Added support for clipping.
* SkeletonRenderer now combines the displayed color of the Node (cascaded from all parents) with the skeleton color for tinting.
* Added support for vertex effects. See `RaptorExample.cpp`.
* Added ETC1 support, thanks @halx99!
### Cocos2d-Objc
* Fixed renderer to work with 3.6 changes

View File

@ -71,6 +71,34 @@ void SkeletonRenderer::initialize () {
setGLProgramState(GLProgramState::getOrCreateWithGLProgramName(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP));
}
void SkeletonRenderer::setupGLProgramState () {
Texture2D *texture = nullptr;
for (int i = 0, n = _skeleton->slotsCount; i < n; i++) {
spSlot* slot = _skeleton->drawOrder[i];
if (!slot->attachment) continue;
switch (slot->attachment->type) {
case SP_ATTACHMENT_REGION: {
spRegionAttachment* attachment = (spRegionAttachment*)slot->attachment;
texture = static_cast<AttachmentVertices*>(attachment->rendererObject)->_texture;
break;
}
case SP_ATTACHMENT_MESH: {
spMeshAttachment* attachment = (spMeshAttachment*)slot->attachment;
texture = static_cast<AttachmentVertices*>(attachment->rendererObject)->_texture;
break;
}
default:
continue;
}
if (texture != nullptr) {
break;
}
}
setGLProgramState(GLProgramState::getOrCreateWithGLProgramName(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP, texture));
}
void SkeletonRenderer::setSkeletonData (spSkeletonData *skeletonData, bool ownsSkeletonData) {
_skeleton = spSkeleton_create(skeletonData);
_ownsSkeletonData = ownsSkeletonData;

View File

@ -124,7 +124,7 @@ CC_CONSTRUCTOR_ACCESS:
void initWithBinaryFile (const std::string& skeletonDataFile, const std::string& atlasFile, float scale = 1);
virtual void initialize ();
void setupGLProgramState();
protected:
void setSkeletonData (spSkeletonData* skeletonData, bool ownsSkeletonData);
virtual AttachmentVertices* getAttachmentVertices (spRegionAttachment* attachment) const;