本文整理汇总了C++中TextureAtlas类的典型用法代码示例。如果您正苦于以下问题:C++ TextureAtlas类的具体用法?C++ TextureAtlas怎么用?C++ TextureAtlas使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TextureAtlas类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: TextureAtlas
void TextureAtlasHandler::LoadAtlasFromFile(const String& Name, const String& Group)
{
/// @todo Update after we have refactored the resource system if needed.
Resource::DataStreamPtr AtlasStream = Resource::ResourceManager::GetSingletonPtr()->OpenAssetStream(Name,Group);
AtlasStream->SetStreamPosition(0);
XML::Document AtlasDoc;
AtlasDoc.Load( *AtlasStream.Get() );
XML::Node RootNode = AtlasDoc.GetChild("Atlases");
if( !RootNode.Empty() )
{
for( XML::NodeIterator AtlasIt = RootNode.begin() ; AtlasIt != RootNode.end() ; ++AtlasIt )
{
// Parse the Atlas
TextureAtlas* NewAtlas = new TextureAtlas( (*AtlasIt) );
// Verify we don't already have one of the same name
AtlasIterator AtIt = this->Atlases.find( NewAtlas->GetName() );
if( AtIt != Atlases.end() )
{
MEZZ_EXCEPTION(ExceptionBase::II_DUPLICATE_IDENTITY_EXCEPTION,"Texture Atlas with the name \"" + NewAtlas->GetName() + "\" already exists.");
}
// Add the unique Atlas
this->Atlases[NewAtlas->GetName()] = NewAtlas;
}
}else{
MEZZ_EXCEPTION(ExceptionBase::INVALID_STATE_EXCEPTION,"Mezzanine Texture Atlas file \"" + Name + "\"does not contain expected \"Atlases\" root node. File is not valid and cannot be parsed.");
}
}
开发者ID:,项目名称:,代码行数:28,代码来源:
示例2: runtime_error
TextureAtlasAnimation::TextureAtlasAnimation(TextureAtlas &atlas, const string &path, float fps, bool looping, bool reverse)
:
atlas(atlas),
fps(fps),
looping(looping)
{
if (reverse)
{
auto tmp = atlas.getAnimationSprites(path);
for (int i = tmp.size() - 1; i >= 0; i--)
{
sprites.push_back(tmp[i]);
}
}
else
{
sprites = atlas.getAnimationSprites(path);
}
if (sprites.empty())
{
throw runtime_error("INVALID ANIMATION");
}
}
开发者ID:SlateScience,项目名称:new-chronotext-toolkit,代码行数:25,代码来源:TextureAtlasAnimation.cpp
示例3: TextureAtlas
TextureAtlas* SDL::loadAtlas( string imagefile, string datafile )
{
TextureAtlas * ta = new TextureAtlas();
ta->tex = loadTexture( imagefile );
ta->loadData( datafile );
texAtlases[ imagefile ] = ta;
return ta;
}
开发者ID:AutonomicStudios,项目名称:SideScroller,代码行数:8,代码来源:SDLO.cpp
示例4: new
TextureAtlas * TextureAtlas::createWithTexture(Texture2D *texture, ssize_t capacity)
{
TextureAtlas * textureAtlas = new (std::nothrow) TextureAtlas();
if (textureAtlas && textureAtlas->initWithTexture(texture, capacity))
{
textureAtlas->autorelease();
return textureAtlas;
}
CC_SAFE_DELETE(textureAtlas);
return nullptr;
}
开发者ID:akinlin,项目名称:PowerOfTheMind,代码行数:11,代码来源:CCTextureAtlas.cpp
示例5: TextureAtlas
TextureAtlas * TextureAtlas::createWithTexture(Texture2D *texture, int capacity)
{
TextureAtlas * textureAtlas = new TextureAtlas();
if (textureAtlas && textureAtlas->initWithTexture(texture, capacity))
{
textureAtlas->autorelease();
return textureAtlas;
}
CC_SAFE_DELETE(textureAtlas);
return NULL;
}
开发者ID:ADoby,项目名称:Project_Space_Pirate,代码行数:11,代码来源:CCTextureAtlas.cpp
示例6: _AtlasPage_createTexture
void _AtlasPage_createTexture (AtlasPage* self, const char* path) {
Texture2D* texture = Director::getInstance()->getTextureCache()->addImage(path);
TextureAtlas* textureAtlas = TextureAtlas::createWithTexture(texture, 4);
textureAtlas->retain();
self->rendererObject = textureAtlas;
// Using getContentSize to make it supports the strategy of loading resources in cocos2d-x.
// self->width = texture->getPixelsWide();
// self->height = texture->getPixelsHigh();
self->width = texture->getContentSize().width;
self->height = texture->getContentSize().height;
}
开发者ID:CryQ,项目名称:coclua,代码行数:11,代码来源:spine-cocos2dx.cpp
示例7: TextureAtlas
std::shared_ptr<TextureAtlas> Project::loadTextureAtlas(std::string filename) {
std::string texture = filename.substr(0, filename.size()-4) + ".png";
auto iter = textureAtlasRef.find(filename);
if (iter != textureAtlasRef.end()){
if (!iter->second.expired()){
return iter->second.lock();
}
}
TextureAtlas* textureAtlas = new TextureAtlas();
textureAtlas->load(filename, texture);
auto ref = std::shared_ptr<TextureAtlas>{textureAtlas};
textureAtlasRef[filename] = weak_ptr<TextureAtlas>{ref};
return ref;
}
开发者ID:buffer8848,项目名称:kick,代码行数:15,代码来源:project.cpp
示例8: CC_NODE_DRAW_SETUP
void CCSkeleton::draw () {
CC_NODE_DRAW_SETUP();
GL::blendFunc(blendFunc.src, blendFunc.dst);
Color3B color = getColor();
skeleton->r = color.r / (float)255;
skeleton->g = color.g / (float)255;
skeleton->b = color.b / (float)255;
skeleton->a = getOpacity() / (float)255;
if (premultipliedAlpha) {
skeleton->r *= skeleton->a;
skeleton->g *= skeleton->a;
skeleton->b *= skeleton->a;
}
TextureAtlas* textureAtlas = 0;
V3F_C4B_T2F_Quad quad;
quad.tl.vertices.z = 0;
quad.tr.vertices.z = 0;
quad.bl.vertices.z = 0;
quad.br.vertices.z = 0;
for (int i = 0, n = skeleton->slotCount; i < n; i++) {
Slot* slot = skeleton->slots[i];
if (!slot->attachment || slot->attachment->type != ATTACHMENT_REGION) continue;
RegionAttachment* attachment = (RegionAttachment*)slot->attachment;
TextureAtlas* regionTextureAtlas = getTextureAtlas(attachment);
if (regionTextureAtlas != textureAtlas) {
if (textureAtlas) {
textureAtlas->drawQuads();
textureAtlas->removeAllQuads();
}
}
textureAtlas = regionTextureAtlas;
if (textureAtlas->getCapacity() == textureAtlas->getTotalQuads() &&
!textureAtlas->resizeCapacity(textureAtlas->getCapacity() * 2)) return;
RegionAttachment_updateQuad(attachment, slot, &quad, premultipliedAlpha);
textureAtlas->updateQuad(&quad, textureAtlas->getTotalQuads());
}
if (textureAtlas) {
textureAtlas->drawQuads();
textureAtlas->removeAllQuads();
}
if (debugSlots) {
// Slots.
DrawPrimitives::setDrawColor4B(0, 0, 255, 255);
glLineWidth(1);
Point points[4];
V3F_C4B_T2F_Quad quad;
for (int i = 0, n = skeleton->slotCount; i < n; i++) {
Slot* slot = skeleton->slots[i];
if (!slot->attachment || slot->attachment->type != ATTACHMENT_REGION) continue;
RegionAttachment* attachment = (RegionAttachment*)slot->attachment;
RegionAttachment_updateQuad(attachment, slot, &quad);
points[0] = Point(quad.bl.vertices.x, quad.bl.vertices.y);
points[1] = Point(quad.br.vertices.x, quad.br.vertices.y);
points[2] = Point(quad.tr.vertices.x, quad.tr.vertices.y);
points[3] = Point(quad.tl.vertices.x, quad.tl.vertices.y);
DrawPrimitives::drawPoly(points, 4, true);
}
}
if (debugBones) {
// Bone lengths.
glLineWidth(2);
DrawPrimitives::setDrawColor4B(255, 0, 0, 255);
for (int i = 0, n = skeleton->boneCount; i < n; i++) {
Bone *bone = skeleton->bones[i];
float x = bone->data->length * bone->m00 + bone->worldX;
float y = bone->data->length * bone->m10 + bone->worldY;
DrawPrimitives::drawLine(Point(bone->worldX, bone->worldY), Point(x, y));
}
// Bone origins.
DrawPrimitives::setPointSize(4);
DrawPrimitives::setDrawColor4B(0, 0, 255, 255); // Root bone is blue.
for (int i = 0, n = skeleton->boneCount; i < n; i++) {
Bone *bone = skeleton->bones[i];
DrawPrimitives::drawPoint(Point(bone->worldX, bone->worldY));
if (i == 0) DrawPrimitives::setDrawColor4B(0, 255, 0, 255);
}
}
}
开发者ID:0x0c,项目名称:cocos2d-x,代码行数:81,代码来源:CCSkeleton.cpp
示例9: SetGraphic
void Part::Load(FileNode *fileNode)
{
//Entity::Load(fileNode);
fileNode->Read("id", id);
fileNode->Read("name", name);
sprite = NULL;
SetGraphic(NULL);
TextureAtlas *textureAtlas = puppet->GetTextureAtlas();
if (textureAtlas)
{
TextureAtlasEntry *textureAtlasEntry = NULL;
fileNode->Read("atlasEntry", atlasEntry);
if (atlasEntry != "")
{
textureAtlasEntry = textureAtlas->GetEntryByName(atlasEntry);
if (textureAtlasEntry)
{
sprite = new Sprite(textureAtlas->GetImageName());
SetGraphic(sprite);
sprite->textureOffset = textureAtlasEntry->GetTextureOffset();
sprite->textureScale = textureAtlasEntry->GetTextureScale();
printf("textureOffset: (%f, %f) textureScale: (%f, %f)\n", sprite->textureOffset.x, sprite->textureOffset.y, sprite->textureScale.x, sprite->textureScale.y);
sprite->width = textureAtlasEntry->GetWidth();
sprite->height = textureAtlasEntry->GetHeight();
}
}
}
if (sprite == NULL)
{
std::string image;
fileNode->Read("image", image);
sprite = new Sprite(image);
SetGraphic(sprite);
}
if (sprite != NULL)
{
int width=-1, height=-1;
fileNode->Read("width", width);
fileNode->Read("height", height);
if (width != -1)
{
sprite->width = width;
}
if (height != -1)
{
sprite->height = height;
}
fileNode->Read("offset", sprite->position);
}
int layer = 0;
fileNode->Read("layer", layer);
SetLayer(layer);
// if (sprite)
// {
// std::string atlas;
// fileNode->Read("atlas", atlas);
// if (atlas != "")
// {
// int x, y, width, height, maxWidth=-1, maxHeight=-1;
// std::istringstream is(atlas);
// is >> x >> y >> width >> height >> maxWidth >> maxHeight;
//
// if (maxWidth == -1)
// maxWidth = width;
// if (maxHeight == -1)
// maxHeight = height;
//
// sprite->textureOffset = Vector2(x/float(maxWidth), y/float(maxHeight));
// sprite->textureScale = Vector2(width/float(maxWidth), height/float(maxHeight));
//
// sprite->width = width;
// sprite->height = height;
// }
// }
}
开发者ID:soundofjw,项目名称:Monocle-Engine,代码行数:86,代码来源:Puppet.cpp
示例10: getGLProgram
void Skeleton::onDraw(const Mat4 &transform, uint32_t flags)
{
getGLProgram()->use();
getGLProgram()->setUniformsForBuiltins(transform);
GL::blendFunc(blendFunc.src, blendFunc.dst);
Color3B color = getColor();
skeleton->r = color.r / (float)255;
skeleton->g = color.g / (float)255;
skeleton->b = color.b / (float)255;
skeleton->a = getOpacity() / (float)255;
if (premultipliedAlpha) {
skeleton->r *= skeleton->a;
skeleton->g *= skeleton->a;
skeleton->b *= skeleton->a;
}
int additive = 0;
TextureAtlas* textureAtlas = 0;
V3F_C4B_T2F_Quad quad;
quad.tl.vertices.z = 0;
quad.tr.vertices.z = 0;
quad.bl.vertices.z = 0;
quad.br.vertices.z = 0;
for (int i = 0, n = skeleton->slotCount; i < n; i++) {
spSlot* slot = skeleton->drawOrder[i];
if (!slot->attachment || slot->attachment->type != ATTACHMENT_REGION) continue;
spRegionAttachment* attachment = (spRegionAttachment*)slot->attachment;
TextureAtlas* regionTextureAtlas = getTextureAtlas(attachment);
if (slot->data->additiveBlending != additive) {
if (textureAtlas) {
textureAtlas->drawQuads();
textureAtlas->removeAllQuads();
}
additive = !additive;
GL::blendFunc(blendFunc.src, additive ? GL_ONE : blendFunc.dst);
} else if (regionTextureAtlas != textureAtlas && textureAtlas) {
textureAtlas->drawQuads();
textureAtlas->removeAllQuads();
}
textureAtlas = regionTextureAtlas;
setFittedBlendingFunc(textureAtlas);
ssize_t quadCount = textureAtlas->getTotalQuads();
if (textureAtlas->getCapacity() == quadCount) {
textureAtlas->drawQuads();
textureAtlas->removeAllQuads();
if (!textureAtlas->resizeCapacity(textureAtlas->getCapacity() * 2)) return;
}
spRegionAttachment_updateQuad(attachment, slot, &quad, premultipliedAlpha);
textureAtlas->updateQuad(&quad, quadCount);
}
if (textureAtlas) {
textureAtlas->drawQuads();
textureAtlas->removeAllQuads();
}
if(debugBones || debugSlots) {
Director* director = Director::getInstance();
CCASSERT(nullptr != director, "Director is null when seting matrix stack");
director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, transform);
if (debugSlots) {
// Slots.
DrawPrimitives::setDrawColor4B(0, 0, 255, 255);
glLineWidth(1);
Vec2 points[4];
V3F_C4B_T2F_Quad tmpQuad;
for (int i = 0, n = skeleton->slotCount; i < n; i++) {
spSlot* slot = skeleton->drawOrder[i];
if (!slot->attachment || slot->attachment->type != ATTACHMENT_REGION) continue;
spRegionAttachment* attachment = (spRegionAttachment*)slot->attachment;
spRegionAttachment_updateQuad(attachment, slot, &tmpQuad);
points[0] = Vec2(tmpQuad.bl.vertices.x, tmpQuad.bl.vertices.y);
points[1] = Vec2(tmpQuad.br.vertices.x, tmpQuad.br.vertices.y);
points[2] = Vec2(tmpQuad.tr.vertices.x, tmpQuad.tr.vertices.y);
points[3] = Vec2(tmpQuad.tl.vertices.x, tmpQuad.tl.vertices.y);
DrawPrimitives::drawPoly(points, 4, true);
}
}
if (debugBones) {
// Bone lengths.
glLineWidth(2);
DrawPrimitives::setDrawColor4B(255, 0, 0, 255);
for (int i = 0, n = skeleton->boneCount; i < n; i++) {
spBone *bone = skeleton->bones[i];
float x = bone->data->length * bone->m00 + bone->worldX;
float y = bone->data->length * bone->m10 + bone->worldY;
DrawPrimitives::drawLine(Vec2(bone->worldX, bone->worldY), Vec2(x, y));
}
// Bone origins.
DrawPrimitives::setPointSize(4);
DrawPrimitives::setDrawColor4B(0, 0, 255, 255); // Root bone is blue.
for (int i = 0, n = skeleton->boneCount; i < n; i++) {
spBone *bone = skeleton->bones[i];
DrawPrimitives::drawPoint(Vec2(bone->worldX, bone->worldY));
if (i == 0) DrawPrimitives::setDrawColor4B(0, 255, 0, 255);
//.........这里部分代码省略.........
开发者ID:0xiaohui00,项目名称:Cocos2dx-Wechat,代码行数:101,代码来源:CCSkeleton.cpp
示例11: SpriteBatch
SpriteBatch::SpriteBatch(TextureAtlas& atlas) :
SpriteBatch(atlas.getTexture())
{
_atlas = &atlas;
}
开发者ID:gwthomas,项目名称:sol-framework,代码行数:5,代码来源:SolSpriteBatch.cpp
示例12: CC_NODE_DRAW_SETUP
void Skeleton::onDraw ()
{
CC_NODE_DRAW_SETUP();
GL::blendFunc(blendFunc.src, blendFunc.dst);
Color3B color = getColor();
skeleton->r = color.r / (float)255;
skeleton->g = color.g / (float)255;
skeleton->b = color.b / (float)255;
skeleton->a = getOpacity() / (float)255;
if (premultipliedAlpha) {
skeleton->r *= skeleton->a;
skeleton->g *= skeleton->a;
skeleton->b *= skeleton->a;
}
int additive = 0;
TextureAtlas* textureAtlas = 0;
V3F_C4B_T2F_Quad quad;
quad.tl.vertices.z = 0;
quad.tr.vertices.z = 0;
quad.bl.vertices.z = 0;
quad.br.vertices.z = 0;
for (int i = 0, n = skeleton->slotCount; i < n; i++) {
spSlot* slot = skeleton->drawOrder[i];
if (!slot->attachment || slot->attachment->type != ATTACHMENT_REGION) continue;
spRegionAttachment* attachment = (spRegionAttachment*)slot->attachment;
TextureAtlas* regionTextureAtlas = getTextureAtlas(attachment);
if (slot->data->additiveBlending != additive) {
if (textureAtlas) {
textureAtlas->drawQuads();
textureAtlas->removeAllQuads();
}
additive = !additive;
GL::blendFunc(blendFunc.src, additive ? GL_ONE : blendFunc.dst);
} else if (regionTextureAtlas != textureAtlas && textureAtlas) {
textureAtlas->drawQuads();
textureAtlas->removeAllQuads();
}
textureAtlas = regionTextureAtlas;
setFittedBlendingFunc(textureAtlas);
ssize_t quadCount = textureAtlas->getTotalQuads();
if (textureAtlas->getCapacity() == quadCount) {
textureAtlas->drawQuads();
textureAtlas->removeAllQuads();
if (!textureAtlas->resizeCapacity(textureAtlas->getCapacity() * 2)) return;
}
spRegionAttachment_updateQuad(attachment, slot, &quad, premultipliedAlpha);
textureAtlas->updateQuad(&quad, quadCount);
}
if (textureAtlas) {
textureAtlas->drawQuads();
textureAtlas->removeAllQuads();
}
if(debugBones || debugSlots) {
kmGLPushMatrix();
kmGLLoadMatrix(&_modelViewTransform);
if (debugSlots) {
// Slots.
DrawPrimitives::setDrawColor4B(0, 0, 255, 255);
glLineWidth(1);
Point points[4];
V3F_C4B_T2F_Quad tmpQuad;
for (int i = 0, n = skeleton->slotCount; i < n; i++) {
spSlot* slot = skeleton->drawOrder[i];
if (!slot->attachment || slot->attachment->type != ATTACHMENT_REGION) continue;
spRegionAttachment* attachment = (spRegionAttachment*)slot->attachment;
spRegionAttachment_updateQuad(attachment, slot, &tmpQuad);
points[0] = Point(tmpQuad.bl.vertices.x, tmpQuad.bl.vertices.y);
points[1] = Point(tmpQuad.br.vertices.x, tmpQuad.br.vertices.y);
points[2] = Point(tmpQuad.tr.vertices.x, tmpQuad.tr.vertices.y);
points[3] = Point(tmpQuad.tl.vertices.x, tmpQuad.tl.vertices.y);
DrawPrimitives::drawPoly(points, 4, true);
}
}
if (debugBones) {
// Bone lengths.
glLineWidth(2);
DrawPrimitives::setDrawColor4B(255, 0, 0, 255);
for (int i = 0, n = skeleton->boneCount; i < n; i++) {
spBone *bone = skeleton->bones[i];
float x = bone->data->length * bone->m00 + bone->worldX;
float y = bone->data->length * bone->m10 + bone->worldY;
DrawPrimitives::drawLine(Point(bone->worldX, bone->worldY), Point(x, y));
}
// Bone origins.
DrawPrimitives::setPointSize(4);
DrawPrimitives::setDrawColor4B(0, 0, 255, 255); // Root bone is blue.
for (int i = 0, n = skeleton->boneCount; i < n; i++) {
spBone *bone = skeleton->bones[i];
DrawPrimitives::drawPoint(Point(bone->worldX, bone->worldY));
if (i == 0) DrawPrimitives::setDrawColor4B(0, 255, 0, 255);
}
}
//.........这里部分代码省略.........
开发者ID:BellyWong,项目名称:EarthWarrior3D,代码行数:101,代码来源:CCSkeleton.cpp
注:本文中的TextureAtlas类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论