mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-17 12:31:41 +08:00
Cocos2d-x and SFML now respect the atlas filter and wrap settings.
This commit is contained in:
parent
4064f0b7bc
commit
b41af15f0c
@ -34,9 +34,37 @@
|
||||
|
||||
USING_NS_CC;
|
||||
|
||||
GLuint wrap (spAtlasWrap wrap) {
|
||||
return wrap == SP_ATLAS_CLAMPTOEDGE ? GL_CLAMP_TO_EDGE : GL_REPEAT;
|
||||
}
|
||||
|
||||
GLuint filter (spAtlasFilter filter) {
|
||||
switch (filter) {
|
||||
case SP_ATLAS_NEAREST:
|
||||
return GL_NEAREST;
|
||||
case SP_ATLAS_LINEAR:
|
||||
return GL_LINEAR;
|
||||
case SP_ATLAS_MIPMAP:
|
||||
return GL_LINEAR_MIPMAP_LINEAR;
|
||||
case SP_ATLAS_MIPMAP_NEAREST_NEAREST:
|
||||
return GL_NEAREST_MIPMAP_NEAREST;
|
||||
case SP_ATLAS_MIPMAP_LINEAR_NEAREST:
|
||||
return GL_LINEAR_MIPMAP_NEAREST;
|
||||
case SP_ATLAS_MIPMAP_NEAREST_LINEAR:
|
||||
return GL_NEAREST_MIPMAP_LINEAR;
|
||||
case SP_ATLAS_MIPMAP_LINEAR_LINEAR:
|
||||
return GL_LINEAR_MIPMAP_LINEAR;
|
||||
}
|
||||
return GL_LINEAR;
|
||||
}
|
||||
|
||||
void _spAtlasPage_createTexture (spAtlasPage* self, const char* path) {
|
||||
CCTexture2D* texture = CCTextureCache::sharedTextureCache()->addImage(path);
|
||||
texture->retain();
|
||||
|
||||
ccTexParams textureParams = {filter(self->minFilter), filter(self->magFilter), wrap(self->uWrap), wrap(self->vWrap)};
|
||||
texture->setTexParameters(&textureParams);
|
||||
|
||||
self->rendererObject = texture;
|
||||
self->width = texture->getPixelsWide();
|
||||
self->height = texture->getPixelsHigh();
|
||||
|
||||
@ -34,9 +34,37 @@
|
||||
|
||||
USING_NS_CC;
|
||||
|
||||
GLuint wrap (spAtlasWrap wrap) {
|
||||
return wrap == SP_ATLAS_CLAMPTOEDGE ? GL_CLAMP_TO_EDGE : GL_REPEAT;
|
||||
}
|
||||
|
||||
GLuint filter (spAtlasFilter filter) {
|
||||
switch (filter) {
|
||||
case SP_ATLAS_NEAREST:
|
||||
return GL_NEAREST;
|
||||
case SP_ATLAS_LINEAR:
|
||||
return GL_LINEAR;
|
||||
case SP_ATLAS_MIPMAP:
|
||||
return GL_LINEAR_MIPMAP_LINEAR;
|
||||
case SP_ATLAS_MIPMAP_NEAREST_NEAREST:
|
||||
return GL_NEAREST_MIPMAP_NEAREST;
|
||||
case SP_ATLAS_MIPMAP_LINEAR_NEAREST:
|
||||
return GL_LINEAR_MIPMAP_NEAREST;
|
||||
case SP_ATLAS_MIPMAP_NEAREST_LINEAR:
|
||||
return GL_NEAREST_MIPMAP_LINEAR;
|
||||
case SP_ATLAS_MIPMAP_LINEAR_LINEAR:
|
||||
return GL_LINEAR_MIPMAP_LINEAR;
|
||||
}
|
||||
return GL_LINEAR;
|
||||
}
|
||||
|
||||
void _spAtlasPage_createTexture (spAtlasPage* self, const char* path) {
|
||||
Texture2D* texture = Director::getInstance()->getTextureCache()->addImage(path);
|
||||
texture->retain();
|
||||
|
||||
Texture2D::TexParams textureParams = {filter(self->minFilter), filter(self->magFilter), wrap(self->uWrap), wrap(self->vWrap)};
|
||||
texture->setTexParameters(&textureParams);
|
||||
|
||||
self->rendererObject = texture;
|
||||
self->width = texture->getPixelsWide();
|
||||
self->height = texture->getPixelsHigh();
|
||||
|
||||
@ -40,7 +40,10 @@ using namespace sf;
|
||||
void _AtlasPage_createTexture (AtlasPage* self, const char* path){
|
||||
Texture* texture = new Texture();
|
||||
if (!texture->loadFromFile(path)) return;
|
||||
texture->setSmooth(true);
|
||||
|
||||
if (self->magFilter == SP_ATLAS_LINEAR) texture->setSmooth(true);
|
||||
if (self->uWrap == SP_ATLAS_REPEAT && self->vWrap == SP_ATLAS_REPEAT) texture->setRepeated(true);
|
||||
|
||||
self->rendererObject = texture;
|
||||
Vector2u size = texture->getSize();
|
||||
self->width = size.x;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user