本文整理汇总了C++中Video::SetClipRect方法的典型用法代码示例。如果您正苦于以下问题:C++ Video::SetClipRect方法的具体用法?C++ Video::SetClipRect怎么用?C++ Video::SetClipRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Video
的用法示例。
在下文中一共展示了Video::SetClipRect方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawFog
// Draw fog on the small bitmap
void MapControl::DrawFog(unsigned short XWin, unsigned short YWin)
{
Video *video = core->GetVideoDriver();
Region old_clip;
video->GetClipRect(old_clip);
Region r( XWin + XPos, YWin + YPos, Width, Height );
video->SetClipRect(&r);
// FIXME: this is ugly, the knowledge of Map and ExploredMask
// sizes should be in Map.cpp
int w = MyMap->GetWidth() / 2;
int h = MyMap->GetHeight() / 2;
for (int y = 0; y < h; y++) {
for (int x = 0; x < w; x++) {
Point p( (short) (MAP_MULT * x), (short) (MAP_MULT * y) );
bool visible = MyMap->IsVisible( p, true );
if (! visible) {
Region rgn = Region ( MAP_TO_SCREENX(MAP_DIV * x), MAP_TO_SCREENY(MAP_DIV * y), MAP_DIV, MAP_DIV );
video->DrawRect( rgn, colors[black] );
}
}
}
video->SetClipRect(&old_clip);
}
示例2: DrawWindow
/** This function Draws the Window on the Output Screen */
void Window::DrawWindow()
{
Video* video = core->GetVideoDriver();
Region clip( XPos, YPos, Width, Height );
//Frame && Changed
if ( (Flags & (WF_FRAME|WF_CHANGED) )== (WF_FRAME|WF_CHANGED) ) {
Region screen( 0, 0, core->Width, core->Height );
video->SetClipRect( NULL );
//removed this?
Color black = { 0, 0, 0, 255 };
video->DrawRect( screen, black );
if (core->WindowFrames[0])
video->BlitSprite( core->WindowFrames[0], 0, 0, true );
if (core->WindowFrames[1])
video->BlitSprite( core->WindowFrames[1], core->Width - core->WindowFrames[1]->Width, 0, true );
if (core->WindowFrames[2])
video->BlitSprite( core->WindowFrames[2], (core->Width - core->WindowFrames[2]->Width) / 2, 0, true );
if (core->WindowFrames[3])
video->BlitSprite( core->WindowFrames[3], (core->Width - core->WindowFrames[3]->Width) / 2, core->Height - core->WindowFrames[3]->Height, true );
} else if (clip_regions.size()) {
// clip drawing (we only do Background right now) for InvalidateForControl
for (unsigned int i = 0; i < clip_regions.size(); i++) {
Region to_clip = clip_regions[i];
to_clip.x += XPos;
to_clip.y += YPos;
video->SetClipRect(&to_clip);
if (BackGround) {
video->BlitSprite( BackGround, XPos, YPos, true );
}
}
}
clip_regions.clear();
video->SetClipRect( &clip );
//Float || Changed
if (BackGround && (Flags & (WF_FLOAT|WF_CHANGED) ) ) {
video->BlitSprite( BackGround, XPos, YPos, true );
}
std::vector< Control*>::iterator m;
for (m = Controls.begin(); m != Controls.end(); ++m) {
( *m )->Draw( XPos, YPos );
}
if ( (Flags&WF_CHANGED) && (Visible == WINDOW_GRAYED) ) {
Color black = { 0, 0, 0, 128 };
video->DrawRect(clip, black);
}
video->SetClipRect( NULL );
Flags &= ~WF_CHANGED;
}
示例3: Draw
//.........这里部分代码省略.........
idx = strtoul( lines[i] + 3, &rest, 0 );
if (*rest != ',')
goto notmatched;
acolor = strtoul( rest + 1, &rest, 16 );
if (*rest != ',')
goto notmatched;
bcolor = strtoul( rest + 1, &rest, 16 );
if (*rest != ']')
goto notmatched;
tlen = (int)(strstr( rest + 1, "[/s]" ) - rest - 1);
if (tlen < 0)
goto notmatched;
len += tlen + 23;
Buffer = (char *) realloc( Buffer, len + 2 );
if (seltext == (int) i) {
sprintf( Buffer + lastlen, "[color=%6.6lX]%.*s[/color]",
acolor, tlen, rest + 1 );
} else {
sprintf( Buffer + lastlen, "[color=%6.6lX]%.*s[/color]",
bcolor, tlen, rest + 1 );
}
} else {
notmatched:
len += ( int ) strlen( lines[i] ) + 1;
Buffer = (char *) realloc( Buffer, len + 2 );
memcpy( &Buffer[lastlen], lines[i], len - lastlen );
}
lastlen = len;
if (i != linesize - 1) {
Buffer[lastlen - 1] = '\n';
Buffer[lastlen] = 0;
}
}
video->SetClipRect( &clip );
int pos;
if (startrow==CurLine) {
pos = CurPos;
} else {
pos = -1;
}
ftext->PrintFromLine( startrow, clip,
( unsigned char * ) Buffer, palette,
IE_FONT_ALIGN_LEFT, finit, Cursor, pos );
free( Buffer );
video->SetClipRect( NULL );
//streaming text
if (linesize>50) {
//the buffer is filled enough
return;
}
if (core->GetAudioDrv()->IsSpeaking() ) {
//the narrator is still talking
return;
}
if (RunEventHandler( TextAreaOutOfText )) {
return;
}
if (linesize==lines.size()) {
ResetEventHandler( TextAreaOutOfText );
return;
}
AppendText("\n",-1);
return;
}
示例4: Draw
/** Draws the Control on the Output Display */
void WorldMapControl::Draw(unsigned short XWin, unsigned short YWin)
{
WorldMap* worldmap = core->GetWorldMap();
if (!Width || !Height) {
return;
}
if(!Changed)
return;
Changed = false;
Video* video = core->GetVideoDriver();
Region r( XWin+XPos, YWin+YPos, Width, Height );
Region clipbackup;
video->GetClipRect(clipbackup);
video->SetClipRect(&r);
video->BlitSprite( worldmap->GetMapMOS(), MAP_TO_SCREENX(0), MAP_TO_SCREENY(0), true, &r );
unsigned int i;
unsigned int ec = worldmap->GetEntryCount();
for(i=0;i<ec;i++) {
WMPAreaEntry *m = worldmap->GetEntry(i);
if (! (m->GetAreaStatus() & WMP_ENTRY_VISIBLE)) continue;
int xOffs = MAP_TO_SCREENX(m->X);
int yOffs = MAP_TO_SCREENY(m->Y);
Sprite2D* icon = m->GetMapIcon(worldmap->bam);
if( icon ) {
if (m == Area) {
Palette *pal = icon->GetPalette();
icon->SetPalette(pal_selected);
video->BlitSprite( icon, xOffs, yOffs, true, &r );
icon->SetPalette(pal);
pal->Release();
} else {
video->BlitSprite( icon, xOffs, yOffs, true, &r );
}
video->FreeSprite( icon );
}
if (AnimPicture && !strnicmp(m->AreaResRef, currentArea, 8) ) {
video->BlitSprite( AnimPicture, xOffs, yOffs, true, &r );
}
}
// Draw WMP entry labels
if (ftext==NULL) {
video->SetClipRect(&clipbackup);
return;
}
for(i=0;i<ec;i++) {
WMPAreaEntry *m = worldmap->GetEntry(i);
if (! (m->GetAreaStatus() & WMP_ENTRY_VISIBLE)) continue;
Sprite2D *icon=m->GetMapIcon(worldmap->bam);
int h=0,w=0,xpos=0,ypos=0;
if (icon) {
h=icon->Height;
w=icon->Width;
xpos=icon->XPos;
ypos=icon->YPos;
video->FreeSprite( icon );
}
Region r2 = Region( MAP_TO_SCREENX(m->X-xpos), MAP_TO_SCREENY(m->Y-ypos), w, h );
if (!m->GetCaption())
continue;
int tw = ftext->CalcStringWidth( (unsigned char*)m->GetCaption() ) + 5;
int th = ftext->maxHeight;
Palette* text_pal = pal_normal;
if (Area == m) {
text_pal = pal_selected;
} else {
if (! (m->GetAreaStatus() & WMP_ENTRY_VISITED)) {
text_pal = pal_notvisited;
}
}
ftext->Print( Region( r2.x + (r2.w - tw)/2, r2.y + r2.h, tw, th ),
( const unsigned char * ) m->GetCaption(), text_pal, 0, true );
}
video->SetClipRect(&clipbackup);
}