本文整理汇总了C++中spNativeTexture类的典型用法代码示例。如果您正苦于以下问题:C++ spNativeTexture类的具体用法?C++ spNativeTexture怎么用?C++ spNativeTexture使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了spNativeTexture类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void Mem2Native::push(spMemoryTexture src, spNativeTexture dest)
{
src->addRef();
dest->addRef();
_messages.send(0, src.get(), dest.get());
//_messages.post(0, src.get(), dest.get());
}
示例2: operator
bool operator()(const spNativeTexture& t1, const spNativeTexture& t2) const
{
if (t1->getFormat() < _tf)
return true;
if (t1->getWidth() < _w)
return true;
return t1->getHeight() < _h;
}
示例3: RectF
AnimationFrame::AnimationFrame(spNativeTexture t)
{
_row = _column = 0;
_resAnim = 0;
_diffuse.base = t;
_diffuse.premultiplied = true;
_srcRect = RectF(0, 0, 1, 1);
_destRect = RectF(0, 0, (float)t->getWidth(), (float)t->getHeight());
_frameSize = Vector2((float)t->getWidth(), (float)t->getHeight());
}
示例4: isGood
bool RenderTargetsManager::isGood(const spNativeTexture& t, int w, int h, TextureFormat tf) const
{
if (!t)
return false;
if (!t->getHandle())
return false;
if (t->getFormat() == tf &&
t->getWidth() >= w && t->getHeight() >= h &&
t->getWidth() <= (w + ALIGN_SIZE) && t->getHeight() <= (h + ALIGN_SIZE))
return true;
return false;
}
示例5: setTexture
void STDRenderer::setTexture(spNativeTexture base, spNativeTexture alpha, bool basePremultiplied)
{
if (base == 0 || base->getHandle() == 0)
base = white;
unsigned int shaderFlags = _shaderFlags;
if (basePremultiplied)
shaderFlags &= ~UberShaderProgram::ALPHA_PREMULTIPLY;
else
shaderFlags |= UberShaderProgram::ALPHA_PREMULTIPLY;
if (alpha)
shaderFlags |= UberShaderProgram::SEPARATE_ALPHA;
else
shaderFlags &= ~UberShaderProgram::SEPARATE_ALPHA;
//##ifdef OX_DEBUG
#if 0
if (_base != base) { OX_ASSERT(_alpha != alpha); }
else { OX_ASSERT(_alpha == alpha); }
#endif //OX_DEBUG
//no reason to check changed alpha because it is in pair with base
if (_base != base || /*_alpha != alpha || */_shaderFlags != shaderFlags)
{
drawBatch();
}
_shaderFlags = shaderFlags;
_base = base;
_alpha = alpha;
}
示例6: pass
void pass(spNativeTexture srcTexture, const Rect& srcRect, spNativeTexture destTexture, const Rect& destRect, const Color& color)
{
IVideoDriver* driver = IVideoDriver::instance;
const VertexDeclarationGL* decl = static_cast<const VertexDeclarationGL*>(driver->getVertexDeclaration(vertexPCT2::FORMAT));
driver->setRenderTarget(destTexture);
driver->clear(0);
driver->setViewport(destRect);
driver->setTexture(0, srcTexture);
vertexPCT2 v[4];
RectF dst = srcRect.cast<RectF>() / Vector2((float)srcTexture->getWidth(), (float)srcTexture->getHeight());
fillQuadT(v,
dst,
RectF(-1, -1, 2, 2),
AffineTransform::getIdentity(), color.rgba());
driver->draw(IVideoDriver::PT_TRIANGLE_STRIP, decl, v, sizeof(v));
driver->setTexture(0, 0);
}
示例7: oxglActiveTexture
void VideoDriverGLES20::setTexture(int sampler, spNativeTexture t)
{
oxglActiveTexture(GL_TEXTURE0 + sampler);
if (t)
glBindTexture(GL_TEXTURE_2D, (GLuint)((size_t)t->getHandle()));
else
glBindTexture(GL_TEXTURE_2D, 0);
CHECKGL();
}
示例8: v
MaskedRenderer::MaskedRenderer(spNativeTexture mask, const RectF &srcRect, const RectF &destRect, const transform &t, bool channelR) :_mask(mask)
{
_clipUV = ClipUV(
t.transform(destRect.getLeftTop()),
t.transform(destRect.getRightTop()),
t.transform(destRect.getLeftBottom()),
srcRect.getLeftTop(),
srcRect.getRightTop(),
srcRect.getLeftBottom());
_clipMask = srcRect;
Vector2 v(1.0f / mask->getWidth(), 1.0f / mask->getHeight());
_clipMask.expand(v, v);
_shaderFlags |= UberShaderProgram::MASK;
if (channelR)
_shaderFlags |= UberShaderProgram::MASK_R_CHANNEL;
}
示例9: setRenderTarget
void VideoDriverGL::setRenderTarget(spNativeTexture rt)
{
if (!rt)
{
glBindFramebuffer(GL_FRAMEBUFFER, 0);
return;
}
NativeTextureGLES *gl = safeCast<NativeTextureGLES*>(rt.get());
glBindFramebuffer(GL_FRAMEBUFFER, gl->getFboID());
}
示例10: cmp
static bool cmp(const spNativeTexture& t2, const spNativeTexture& t1)
{
if (t1->getFormat() > t2->getFormat())
return true;
if (t1->getWidth() > t2->getWidth())
return true;
return t1->getHeight() > t2->getHeight();
}
示例11: init
void ResAnim::init(spNativeTexture texture, const Point& originalSize, int columns, int rows, float scaleFactor)
{
_scaleFactor = scaleFactor;
if (!texture)
return;
int frame_width = originalSize.x / columns;
int frame_height = originalSize.y / rows;
animationFrames frames;
int frames_count = rows * columns;
frames.reserve(frames_count);
Vector2 frameSize((float)frame_width, (float)frame_height);
for (int y = 0; y < rows; ++y)
{
for (int x = 0; x < columns; ++x)
{
Rect src;
src.pos = Point(x * frame_width, y * frame_height);
src.size = Point(frame_width, frame_height);
float iw = 1.0f / texture->getWidth();
float ih = 1.0f / texture->getHeight();
RectF srcRect(src.pos.x * iw, src.pos.y * ih, src.size.x * iw, src.size.y * ih);
RectF destRect(Vector2(0, 0), frameSize * scaleFactor);
AnimationFrame frame;
Diffuse df;
df.base = texture;
frame.init(this, df, srcRect, destRect, destRect.size);
frames.push_back(frame);
}
}
init(frames, columns, scaleFactor);
}
示例12: setRenderTarget
void VideoDriverGL::setRenderTarget(spNativeTexture rt)
{
if (!rt)
{
glBindFramebuffer(GL_FRAMEBUFFER, _prevFBO);
CHECKGL();
return;
}
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &_prevFBO);
NativeTextureGLES *gl = safeCast<NativeTextureGLES*>(rt.get());
glBindFramebuffer(GL_FRAMEBUFFER, gl->getFboID());
CHECKGL();
}
示例13: TextureLine
TextureLine(spNativeTexture t)
{
setVerticalMode(Box9Sprite::TILING_FULL);
setHorizontalMode(Box9Sprite::TILING_FULL);
Sprite::setResAnim(DebugActor::resSystem->getResAnim("checker"));
AnimationFrame f;
Vector2 s = fitSize(itemSize, Vector2((float)t->getWidth(), (float)t->getHeight()));
setSize(s);
Diffuse df;
df.base = t;
f.init(0, df, RectF(0, 0, 1.0f, 1.0f), RectF(0, 0, s.x, s.y), s);
spSprite image = initActor(new Sprite,
arg_blend = blend_disabled,
arg_resAnim = f);
addChild(image);
spColorRectSprite rect = initActor(new ColorRectSprite,
arg_color = Color(Color::White, 255),
arg_attachTo = this);
rect->addTween(Sprite::TweenColor(Color(Color::White, 0)), 4000, -1, true);
char path[255];
path::normalize(t->getName().c_str(), path);
char txt[255];
safe_sprintf(txt, "%s\n<div c=\"FF0000\">%s</div>-<div c=\"0000ff\">%dx%d</div>\nid: %d",
path,
textureFormat2String(t->getFormat()),
t->getWidth(), t->getHeight(), t->getObjectID());
spTextField text = initActor(new TextField,
arg_color = Color::Black,
arg_w = (float)itemSize.x,
arg_vAlign = TextStyle::VALIGN_TOP,
arg_hAlign = TextStyle::HALIGN_LEFT,
arg_multiline = true,
arg_attachTo = rect,
arg_htmlText = txt
);
text->setBreakLongWords(true);
rect->setSize(text->getTextRect().size.cast<Vector2>() + Vector2(2, 2));
rect->setY((itemSize.y - rect->getHeight()) / 2.0f);
}
示例14: load_texture_internal
void load_texture_internal(const std::string &file, spNativeTexture nt, LoadResourcesContext *load_context)
{
ImageData im;
spMemoryTexture mt = new MemoryTexture;
LOGD("loading atlas: %s", file.c_str());
file::buffer bf;
file::read(file.c_str(), bf);
LOGD("atlas file loaded: %s", file.c_str());
mt->init(bf, Renderer::getPremultipliedAlphaRender(), nt->getFormat());
//mt->init(2048, 2048, TF_R8G8B8A8);
im = mt->lock();
LOGD("atlas size: %d %d", im.w, im.h);
//Object::dumpCreatedObjects();
load_context->createTexture(mt, nt);
}
示例15: load_texture_internal
void load_texture_internal(const std::string& file, spNativeTexture nt, bool linearFilter, bool clamp2edge, LoadResourcesContext* load_context)
{
ImageData im;
spMemoryTexture mt = new MemoryTexture;
LOGD("loading atlas: %s", file.c_str());
file::buffer bf;
file::read(file.c_str(), bf);
LOGD("atlas file loaded: %s", file.c_str());
mt->init(bf, true, nt->getFormat());
im = mt->lock();
LOGD("atlas size: %d %d", im.w, im.h);
CreateTextureTask opt;
opt.src = mt;
opt.dest = nt;
opt.linearFilter = linearFilter;
opt.clamp2edge = clamp2edge;
load_context->createTexture(opt);
}