本文整理汇总了C++中SurfacePtr::get方法的典型用法代码示例。如果您正苦于以下问题:C++ SurfacePtr::get方法的具体用法?C++ SurfacePtr::get怎么用?C++ SurfacePtr::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SurfacePtr
的用法示例。
在下文中一共展示了SurfacePtr::get方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
void
DrawingContext::draw_surface(SurfacePtr surface, const Vector& position,
float angle, const Color& color, const Blend& blend,
int layer)
{
assert(surface != 0);
DrawingRequest* request = new(obst) DrawingRequest();
request->target = target;
request->type = SURFACE;
request->pos = transform.apply(position);
if(request->pos.x >= SCREEN_WIDTH || request->pos.y >= SCREEN_HEIGHT
|| request->pos.x + surface->get_width() < 0
|| request->pos.y + surface->get_height() < 0)
return;
request->layer = layer;
request->drawing_effect = transform.drawing_effect;
request->alpha = transform.alpha;
request->angle = angle;
request->color = color;
request->blend = blend;
SurfaceRequest* surfacerequest = new(obst) SurfaceRequest();
surfacerequest->surface = surface.get();
request->request_data = surfacerequest;
requests->push_back(request);
}
示例2: RenderText
void TtFontAsset::RenderText( SurfacePtr dest, int& x, int& y, const char* text, const pei::Color& color /*= pei::XColor(255,255,255)*/ )
{
// assert ( pFont );
if (!m_TtFont || dest.get() == NULL ) {
return;
}
#ifdef _HAS_SDL_TTF_
SDL_Surface *text_surface = NULL;
// this is a hack! We swap r & g and correct the color format manually
// SDL_ttf renders ARGB, but we need ABGR (or LE RGBA) to match RGBA texture format - performace reasons!
SDL_Color c = { color.b, color.g, color.r, color.a };
if ( (text_surface = TTF_RenderText_Blended( (TTF_Font*)m_TtFont->GetFontHandle(), text, c )) != NULL )
{
// swap r&g in the format description
text_surface->format->Rmask = 0x000000ff; text_surface->format->Rshift = 0;
text_surface->format->Bmask = 0x00ff0000; text_surface->format->Bshift = 16;
pei::SurfacePtr txt( new pei::SDL::SurfaceWrapper(text_surface));
pei::Blitter blitter(pei::PixOpPtr(new PixOpAlphaBlitSrcAlpha(txt->GetFormat(),dest->GetFormat()) ) );
blitter.Blit( txt, dest, x, y, txt->GetWidth(), txt->GetHeight(), 0, 0 );
int tw, th;
TTF_SizeText( (TTF_Font*)m_TtFont->GetFontHandle(), text, &tw, &th);
Uint32 font_height = TTF_FontHeight((TTF_Font*)m_TtFont->GetFontHandle()); // - a - 2*d;
y += font_height;
x += tw;
}
#endif
}