本文整理汇总了C++中Canvas函数的典型用法代码示例。如果您正苦于以下问题:C++ Canvas函数的具体用法?C++ Canvas怎么用?C++ Canvas使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Canvas函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: OvalToPoint
/* ARGSUSED */
static double
OvalToPoint(
Tk_Canvas canvas, /* Canvas containing item. */
Tk_Item *itemPtr, /* Item to check against point. */
double *pointPtr) /* Pointer to x and y coordinates. */
{
RectOvalItem *ovalPtr = (RectOvalItem *) itemPtr;
double width;
int filled;
Tk_State state = itemPtr->state;
if (state == TK_STATE_NULL) {
state = Canvas(canvas)->canvas_state;
}
width = (double) ovalPtr->outline.width;
if (Canvas(canvas)->currentItemPtr == itemPtr) {
if (ovalPtr->outline.activeWidth>width) {
width = (double) ovalPtr->outline.activeWidth;
}
} else if (state == TK_STATE_DISABLED) {
if (ovalPtr->outline.disabledWidth>0) {
width = (double) ovalPtr->outline.disabledWidth;
}
}
filled = ovalPtr->fillGC != None;
if (ovalPtr->outline.gc == None) {
width = 0.0;
filled = 1;
}
return TkOvalToPoint(ovalPtr->bbox, width, filled, pointPtr);
}
开发者ID:AlexShiLucky,项目名称:bitkeeper,代码行数:35,代码来源:tkRectOval.c
示例2: RectToArea
/* ARGSUSED */
static int
RectToArea(
Tk_Canvas canvas, /* Canvas containing item. */
Tk_Item *itemPtr, /* Item to check against rectangle. */
double *areaPtr) /* Pointer to array of four coordinates (x1,
* y1, x2, y2) describing rectangular area. */
{
RectOvalItem *rectPtr = (RectOvalItem *) itemPtr;
double halfWidth;
double width;
Tk_State state = itemPtr->state;
if (state == TK_STATE_NULL) {
state = Canvas(canvas)->canvas_state;
}
width = rectPtr->outline.width;
if (Canvas(canvas)->currentItemPtr == itemPtr) {
if (rectPtr->outline.activeWidth > width) {
width = rectPtr->outline.activeWidth;
}
} else if (state == TK_STATE_DISABLED) {
if (rectPtr->outline.disabledWidth > 0) {
width = rectPtr->outline.disabledWidth;
}
}
halfWidth = width/2.0;
if (rectPtr->outline.gc == None) {
halfWidth = 0.0;
}
if ((areaPtr[2] <= (rectPtr->bbox[0] - halfWidth))
|| (areaPtr[0] >= (rectPtr->bbox[2] + halfWidth))
|| (areaPtr[3] <= (rectPtr->bbox[1] - halfWidth))
|| (areaPtr[1] >= (rectPtr->bbox[3] + halfWidth))) {
return -1;
}
if ((rectPtr->fillGC == None) && (rectPtr->outline.gc != None)
&& (areaPtr[0] >= (rectPtr->bbox[0] + halfWidth))
&& (areaPtr[1] >= (rectPtr->bbox[1] + halfWidth))
&& (areaPtr[2] <= (rectPtr->bbox[2] - halfWidth))
&& (areaPtr[3] <= (rectPtr->bbox[3] - halfWidth))) {
return -1;
}
if ((areaPtr[0] <= (rectPtr->bbox[0] - halfWidth))
&& (areaPtr[1] <= (rectPtr->bbox[1] - halfWidth))
&& (areaPtr[2] >= (rectPtr->bbox[2] + halfWidth))
&& (areaPtr[3] >= (rectPtr->bbox[3] + halfWidth))) {
return 1;
}
return 0;
}
开发者ID:AlexShiLucky,项目名称:bitkeeper,代码行数:54,代码来源:tkRectOval.c
示例3: Canvas
void DebugRenderer::renderBlobs(unsigned char* image, Blobber* blobber, int width, int height) {
Canvas canvas = Canvas();
canvas.data = image;
canvas.width = width;
canvas.height = height;
for (int i = 0; i < blobber->getColorCount(); i++) {
Blobber::Color* color = blobber->getColor(i);
if (color == NULL) {
continue;
}
if (
strcmp(color->name, "ball") != 0
&& strcmp(color->name, "yellow-goal") != 0
&& strcmp(color->name, "blue-goal") != 0
) {
continue;
}
Blobber::Blob* blob = blobber->getBlobs(color->name);
while (blob != NULL) {
canvas.drawBoxCentered(
(int)blob->centerX, (int)blob->centerY,
blob->x2 - blob->x1, blob->y2 - blob->y1,
color->color.red, color->color.green, color->color.blue
);
blob = blob->next;
}
}
}
开发者ID:Sean3Don,项目名称:soccervision,代码行数:35,代码来源:DebugRenderer.cpp
示例4: DisplayWindow
FullScreen::FullScreen()
{
#ifdef WIN32
clan::D3DTarget::set_current();
#else
clan::OpenGLTarget::set_current();
#endif
DisplayWindowDescription window_description;
window_description.set_title("ClanLib FullScreen Example");
window_description.set_size(Size(700, 600), true);
window_description.set_allow_resize(true);
window = DisplayWindow(window_description);
sc.connect(window.sig_window_close(), clan::bind_member(this, &FullScreen::on_window_close));
sc.connect(window.get_keyboard().sig_key_down(), clan::bind_member(this, &FullScreen::on_input_down));
canvas = Canvas(window);
spr_logo = Sprite(canvas, "../Basic2D/Resources/logo.png");
spr_background = Sprite(canvas, "../../Display/Path/Resources/lobby_background2.png");
font = clan::Font("tahoma", 24);
game_time.reset();
}
开发者ID:doughdemon,项目名称:ClanLib,代码行数:25,代码来源:fullscreen.cpp
示例5: TextToPoint
static double
TextToPoint(
Tk_Canvas canvas, /* Canvas containing itemPtr. */
Tk_Item *itemPtr, /* Item to check against point. */
double *pointPtr) /* Pointer to x and y coordinates. */
{
TextItem *textPtr;
Tk_State state = itemPtr->state;
double value, px, py;
if (state == TK_STATE_NULL) {
state = Canvas(canvas)->canvas_state;
}
textPtr = (TextItem *) itemPtr;
px = pointPtr[0] - textPtr->drawOrigin[0];
py = pointPtr[1] - textPtr->drawOrigin[1];
value = (double) Tk_DistanceToTextLayout(textPtr->textLayout,
(int) (px*textPtr->cosine - py*textPtr->sine),
(int) (py*textPtr->cosine + px*textPtr->sine));
if ((state == TK_STATE_HIDDEN) || (textPtr->color == NULL) ||
(textPtr->text == NULL) || (*textPtr->text == 0)) {
value = 1.0e36;
}
return value;
}
开发者ID:tcltk,项目名称:tk,代码行数:26,代码来源:tkCanvText.c
示例6: SCOPED_DRAW_EVENT
void FRCPassPostProcessVisualizeLPV::Process(FRenderingCompositePassContext& Context)
{
SCOPED_DRAW_EVENT(Context.RHICmdList, VisualizeLPV);
const FSceneView& View = Context.View;
const FSceneViewFamily& ViewFamily = *(View.Family);
// const FSceneRenderTargetItem& DestRenderTarget = PassOutputs[0].RequestSurface(Context);
const TRefCountPtr<IPooledRenderTarget> RenderTarget = GetInput(ePId_Input0)->GetOutput()->PooledRenderTarget;
const FSceneRenderTargetItem& DestRenderTarget = RenderTarget->GetRenderTargetItem();
// Set the view family's render target/viewport.
SetRenderTarget(Context.RHICmdList, DestRenderTarget.TargetableTexture, FTextureRHIRef());
{
FRenderTargetTemp TempRenderTarget(View, (const FTexture2DRHIRef&)DestRenderTarget.TargetableTexture);
FCanvas Canvas(&TempRenderTarget, NULL, ViewFamily.CurrentRealTime, ViewFamily.CurrentWorldTime, ViewFamily.DeltaWorldTime, View.GetFeatureLevel());
float X = 30;
float Y = 28;
const float YStep = 14;
const float ColumnWidth = 250;
Canvas.DrawShadowedString( X, Y += YStep, TEXT("VisualizeLightPropagationVolume"), GetStatsFont(), FLinearColor(0.2f, 0.2f, 1));
Y += YStep;
const FLightPropagationVolumeSettings& Dest = View.FinalPostProcessSettings.BlendableManager.GetSingleFinalDataConst<FLightPropagationVolumeSettings>();
#define ENTRY(name)\
Canvas.DrawShadowedString( X, Y += YStep, TEXT(#name) TEXT(":"), GetStatsFont(), FLinearColor(1, 1, 1));\
Canvas.DrawShadowedString( X + ColumnWidth, Y, *FString::Printf(TEXT("%g"), Dest.name), GetStatsFont(), FLinearColor(1, 1, 1));
ENTRY(LPVIntensity)
ENTRY(LPVVplInjectionBias)
ENTRY(LPVSize)
ENTRY(LPVSecondaryOcclusionIntensity)
ENTRY(LPVSecondaryBounceIntensity)
ENTRY(LPVGeometryVolumeBias)
ENTRY(LPVEmissiveInjectionIntensity)
ENTRY(LPVDirectionalOcclusionIntensity)
ENTRY(LPVDirectionalOcclusionRadius)
ENTRY(LPVDiffuseOcclusionExponent)
ENTRY(LPVSpecularOcclusionExponent)
ENTRY(LPVDiffuseOcclusionIntensity)
ENTRY(LPVSpecularOcclusionIntensity)
#undef ENTRY
Canvas.Flush_RenderThread(Context.RHICmdList);
}
Context.RHICmdList.CopyToResolveTarget(DestRenderTarget.TargetableTexture, DestRenderTarget.ShaderResourceTexture, false, FResolveParams());
// to satify following passws
FRenderingCompositeOutput* Output = GetOutput(ePId_Output0);
Output->PooledRenderTarget = RenderTarget;
}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:58,代码来源:PostProcessLpvIndirect.cpp
示例7: create_window
bool FullScreen::update()
{
const float virtual_screen_width = 800.0f;
const float virtual_screen_height = 600.0f;
game_time.update();
// Check for fullscreen switch
if (fullscreen_requested != is_fullscreen)
{
is_fullscreen = fullscreen_requested;
create_window();
}
if (window.get_gc() != canvas.get_gc())
{
canvas = Canvas(window); // Always get the graphic context, the window may have been recreated
}
canvas.clear(Colorf(0.0f,0.0f,0.2f));
int font_size = 28;
font_size *= canvas.get_width() / virtual_screen_width;
font.set_height(font_size);
canvas.set_transform(Mat4f::identity());
if (is_fullscreen)
{
font.draw_text(canvas, 16, font_size, "Full Screen Mode. Press 'F' to switch to resizable window.");
}
else
{
font.draw_text(canvas, 16, font_size, "Resizable Window. Press 'F' to switch to full screen mode.");
}
// Scale the drawing to the screen to a virtual screen size
Mat4f matrix = Mat4f::scale( (float) canvas.get_width() / virtual_screen_width, (float) canvas.get_height() /virtual_screen_height, 1.0f);
canvas.set_transform(matrix);
spr_logo.draw(canvas, virtual_screen_width-spr_logo.get_width(), virtual_screen_height-spr_logo.get_height());
spr_background.set_scale(0.5f, 0.5f);
spr_background.draw(canvas, 100, 100);
// Show a few alpha-blending moving rectangles that moves in circles
float x = cos(sin_count)*120.0f;
float y = sin(sin_count)*120.0f;
sin_count += 2.0f * game_time.get_time_elapsed();
canvas.fill_rect(Rectf( 320.0f + x -30.0f, 300.0f + y -30.0f, Sizef(60.0f, 60.0f)), Colorf(0.0f, 1.0f, 0.0, 0.5f));
x = cos(sin_count+3.14159f)*120.0f;
y = sin(sin_count+3.14159f)*120.0f;
canvas.fill_rect(Rectf( 320.0f + x -30.0f, 300 + y -30.0f, Sizef(60.0f, 60.0f)), Colorf(1.0f, 1.0f, 0.0, 0.5f));
window.flip(1);
return !quit;
}
开发者ID:ARMCoderCHS,项目名称:ClanLib,代码行数:56,代码来源:fullscreen.cpp
示例8: DisplayImage
static void
DisplayImage(
Tk_Canvas canvas, /* Canvas that contains item. */
Tk_Item *itemPtr, /* Item to be displayed. */
Display *display, /* Display on which to draw item. */
Drawable drawable, /* Pixmap or window in which to draw item. */
int x, int y, int width, int height)
/* Describes region of canvas that must be
* redisplayed (not used). */
{
ImageItem *imgPtr = (ImageItem *) itemPtr;
short drawableX, drawableY;
Tk_Image image;
Tk_State state = itemPtr->state;
if (state == TK_STATE_NULL) {
state = Canvas(canvas)->canvas_state;
}
image = imgPtr->image;
if (Canvas(canvas)->currentItemPtr == itemPtr) {
if (imgPtr->activeImage != NULL) {
image = imgPtr->activeImage;
}
} else if (state == TK_STATE_DISABLED) {
if (imgPtr->disabledImage != NULL) {
image = imgPtr->disabledImage;
}
}
if (image == NULL) {
return;
}
/*
* Translate the coordinates to those of the image, then redisplay it.
*/
Tk_CanvasDrawableCoords(canvas, (double) x, (double) y,
&drawableX, &drawableY);
Tk_RedrawImage(image, x - imgPtr->header.x1, y - imgPtr->header.y1,
width, height, drawable, drawableX, drawableY);
}
开发者ID:FreddieAkeroyd,项目名称:TkTclTix,代码行数:43,代码来源:tkCanvImg.c
示例9: return
RenderTechnique::PassElm RenderTechnique::addPass( NameID& name, unsigned int texCount, Effect* effect, int width, int height, bool flipH, bool flipV, bool renderToCanvas )
{
for( PassElm p = m_passes.FirstPointer(); !p.IsEmpty(); p.Next() )
if( p() && name == p()->name )
return( PassElm() );
if( static_cast<int>(texCount) > Global::use().engine->getTextureUnitsCount() )
return( PassElm() );
Engine::WindowRect wr;
Global::use().engine->getWindowRect( wr );
if( width <= 0 )
width = wr.width;
if( height <= 0 )
height = wr.height;
Pass* p = new Pass( name );
PassElm pass = m_passes.AddPointer( p );
if( pass.IsEmpty() )
{
DELETE_OBJECT( p );
return( PassElm() );
}
p->inputTextures.Reserve( texCount );
p->inputTexturesMine.Reserve( texCount );
for( unsigned int i = 0; i < p->inputTextures.Size(); i++ )
{
p->inputTextures[ i ] = 0;
p->inputTexturesMine[ i ] = false;
}
p->outputMaterial = xnew Material();
p->outputMaterial->setEffect( effect );
p->outputScene = xnew SpriteBatch( 1 );
p->outputScene->setCamera( xnew Camera2D( 0.0f, 0.0f, static_cast<float>(width), static_cast<float>(height), 0.0f ) );
p->outputQuad = xnew SpriteBatch::Sprite();
p->outputQuad->setMaterial( p->outputMaterial );
p->outputQuad->setWidth( static_cast<float>(width) );
p->outputQuad->setHeight( static_cast<float>(height) );
if( flipH )
p->outputQuad->flip( SpriteBatch::Sprite::ftHorizontal );
if( flipV )
p->outputQuad->flip( SpriteBatch::Sprite::ftVertical );
p->outputScene->attach( p->outputQuad );
if( renderToCanvas )
{
p->outputCanvas = xnew Canvas( width, height );
p->outputScene->setCanvas( p->outputCanvas );
p->outputCanvas->setClearOnActivate( true );
}
return( pass );
}
开发者ID:PsichiX,项目名称:XenonCore2,代码行数:48,代码来源:RenderTechnique.cpp
示例10: window_view
WindowView_Impl::WindowView_Impl(WindowView *view, const DisplayWindowDescription &desc) : window_view(view), window(desc)
{
canvas = Canvas(window);
slots.connect(window.sig_lost_focus(), clan::bind_member(this, &WindowView_Impl::on_lost_focus));
slots.connect(window.sig_got_focus(), clan::bind_member(this, &WindowView_Impl::on_got_focus));
slots.connect(window.sig_resize(), clan::bind_member(this, &WindowView_Impl::on_resize));
slots.connect(window.sig_paint(), clan::bind_member(this, &WindowView_Impl::on_paint));
slots.connect(window.sig_window_close(), clan::bind_member(this, &WindowView_Impl::on_window_close));
slots.connect(window.get_ic().get_keyboard().sig_key_down(), clan::bind_member(this, &WindowView_Impl::on_key_down));
slots.connect(window.get_ic().get_keyboard().sig_key_up(), clan::bind_member(this, &WindowView_Impl::on_key_up));
slots.connect(window.get_ic().get_mouse().sig_key_down(), clan::bind_member(this, &WindowView_Impl::on_mouse_down));
slots.connect(window.get_ic().get_mouse().sig_key_dblclk(), clan::bind_member(this, &WindowView_Impl::on_mouse_dblclk));
slots.connect(window.get_ic().get_mouse().sig_key_up(), clan::bind_member(this, &WindowView_Impl::on_mouse_up));
slots.connect(window.get_ic().get_mouse().sig_pointer_move(), clan::bind_member(this, &WindowView_Impl::on_mouse_move));
}
开发者ID:ARMCoderCHS,项目名称:ClanLib,代码行数:16,代码来源:window_view_impl.cpp
示例11: DisplayWindow
HSV::HSV()
{
clan::OpenGLTarget::set_current();
window = DisplayWindow("ClanLib HSV Sprite", 1024, 768);
sc.connect(window.sig_window_close(), clan::bind_member(this, &HSV::on_close));
sc.connect(window.get_keyboard().sig_key_up(), clan::bind_member(this, &HSV::on_input_up));
canvas = Canvas(window);
font = clan::Font("Tahoma", 11);
sprite_batcher = std::make_shared<HSVSpriteBatch>(canvas);
car1 = std::make_shared<HSVSprite>(canvas, sprite_batcher.get(), "Resources/spaceshoot_body_moving1.png");
car2 = std::make_shared<HSVSprite>(canvas, sprite_batcher.get(), "Resources/ferrari_maranello.png");
last_fps_update = System::get_time();
last_time = last_fps_update;
}
开发者ID:ArtHome12,项目名称:ClanLib,代码行数:18,代码来源:hsv.cpp
示例12: DisplayWindow
void FullScreen::create_window()
{
DisplayWindowDescription window_description;
window_description.set_title("ClanLib FullScreen Example");
window_description.set_size(Size(700, 600), true);
if (is_fullscreen)
{
window_description.set_fullscreen(true);
window_description.show_caption(false);
}
else
{
window_description.set_allow_resize(true);
}
window = DisplayWindow(window_description);
sc.connect(window.sig_window_close(), clan::bind_member(this, &FullScreen::on_window_close));
sc.connect(window.get_ic().get_keyboard().sig_key_down(), clan::bind_member(this, &FullScreen::on_input_down));
canvas = Canvas(window);
}
开发者ID:ARMCoderCHS,项目名称:ClanLib,代码行数:22,代码来源:fullscreen.cpp
示例13: TextToArea
static int
TextToArea(
Tk_Canvas canvas, /* Canvas containing itemPtr. */
Tk_Item *itemPtr, /* Item to check against rectangle. */
double *rectPtr) /* Pointer to array of four coordinates
* (x1,y1,x2,y2) describing rectangular
* area. */
{
TextItem *textPtr;
Tk_State state = itemPtr->state;
if (state == TK_STATE_NULL) {
state = Canvas(canvas)->canvas_state;
}
textPtr = (TextItem *) itemPtr;
return TkIntersectAngledTextLayout(textPtr->textLayout,
(int) ((rectPtr[0] + 0.5) - textPtr->drawOrigin[0]),
(int) ((rectPtr[1] + 0.5) - textPtr->drawOrigin[1]),
(int) (rectPtr[2] - rectPtr[0] + 0.5),
(int) (rectPtr[3] - rectPtr[1] + 0.5),
textPtr->angle);
}
开发者ID:tcltk,项目名称:tk,代码行数:23,代码来源:tkCanvText.c
示例14: CenterButtonImage
//---------------------------------------------------------------------------
void __fastcall CenterButtonImage(TButton * Button)
{
UncenterButtonImage(Button);
// with themes disabled, the text seems to be drawn over the icon,
// so that the padding spaces hide away most of the icon
if (UseThemes())
{
Button->ImageAlignment = iaCenter;
int ImageWidth = Button->Images->Width;
std::unique_ptr<TControlCanvas> Canvas(new TControlCanvas());
Canvas->Control = Button;
UnicodeString Caption = Button->Caption;
UnicodeString Padding;
while (Canvas->TextWidth(Padding) < ImageWidth)
{
Padding += L" ";
}
Caption = Padding + Caption;
Button->Caption = Caption;
int CaptionWidth = Canvas->TextWidth(Caption);
// The margins seem to extend the area over which the image is centered,
// so we have to set it to a double of desired padding.
// Note that (CaptionWidth / 2) - (ImageWidth / 2)
// is approximatelly same as half of caption width before padding.
Button->ImageMargins->Left = - 2 * ((CaptionWidth / 2) - (ImageWidth / 2) + ScaleByTextHeight(Button, 2));
}
else
{
// at least do not draw it so near to the edge
Button->ImageMargins->Left = 1;
}
}
开发者ID:mpmartin8080,项目名称:winscp,代码行数:37,代码来源:WinInterface.cpp
示例15: Canvas
Canvas
TopCanvas::Lock()
{
return Canvas(buffer);
}
开发者ID:jaaaaf,项目名称:LK8000,代码行数:5,代码来源:TopCanvas.cpp
示例16: SCOPED_DRAW_EVENT
void FRCPassPostProcessVisualizeShadingModels::Process(FRenderingCompositePassContext& Context)
{
SCOPED_DRAW_EVENT(Context.RHICmdList, PostProcessVisualizeShadingModels);
const FPooledRenderTargetDesc* InputDesc = GetInputDesc(ePId_Input0);
const FSceneView& View = Context.View;
const FViewInfo& ViewInfo = Context.View;
const FSceneViewFamily& ViewFamily = *(View.Family);
FIntRect SrcRect = View.ViewRect;
FIntRect DestRect = View.ViewRect;
FIntPoint SrcSize = InputDesc->Extent;
const FSceneRenderTargetItem& DestRenderTarget = PassOutputs[0].RequestSurface(Context);
// Set the view family's render target/viewport.
SetRenderTarget(Context.RHICmdList, DestRenderTarget.TargetableTexture, FTextureRHIRef());
Context.SetViewportAndCallRHI(DestRect);
// set the state
Context.RHICmdList.SetBlendState(TStaticBlendState<>::GetRHI());
Context.RHICmdList.SetRasterizerState(TStaticRasterizerState<>::GetRHI());
Context.RHICmdList.SetDepthStencilState(TStaticDepthStencilState<false, CF_Always>::GetRHI());
TShaderMapRef<FPostProcessVS> VertexShader(Context.GetShaderMap());
TShaderMapRef<FPostProcessVisualizeShadingModelsPS> PixelShader(Context.GetShaderMap());
static FGlobalBoundShaderState BoundShaderState;
SetGlobalBoundShaderState(Context.RHICmdList, Context.GetFeatureLevel(), BoundShaderState, GFilterVertexDeclaration.VertexDeclarationRHI, *VertexShader, *PixelShader);
PixelShader->SetPS(Context, ((FViewInfo&)View).ShadingModelMaskInView);
// Draw a quad mapping scene color to the view's render target
DrawRectangle(
Context.RHICmdList,
DestRect.Min.X, DestRect.Min.Y,
DestRect.Width(), DestRect.Height(),
SrcRect.Min.X, SrcRect.Min.Y,
SrcRect.Width(), SrcRect.Height(),
DestRect.Size(),
SrcSize,
*VertexShader,
EDRF_UseTriangleOptimization);
FRenderTargetTemp TempRenderTarget(View, (const FTexture2DRHIRef&)DestRenderTarget.TargetableTexture);
FCanvas Canvas(&TempRenderTarget, NULL, 0, 0, 0, Context.GetFeatureLevel());
float X = 30;
float Y = 28;
const float YStep = 14;
const float ColumnWidth = 250;
FString Line;
Canvas.DrawShadowedString( X, Y += YStep, TEXT("Visualize ShadingModels (mostly to track down bugs)"), GetStatsFont(), FLinearColor(1, 1, 1));
Y = 160 - YStep - 4;
uint32 Value = ((FViewInfo&)View).ShadingModelMaskInView;
Line = FString::Printf(TEXT("View.ShadingModelMaskInView = 0x%x"), Value);
Canvas.DrawShadowedString( X, Y, *Line, GetStatsFont(), FLinearColor(0.5f, 0.5f, 0.5f));
Y += YStep;
UEnum* Enum = FindObject<UEnum>(NULL, TEXT("Engine.EMaterialShadingModel"));
check(Enum);
Y += 5;
for(uint32 i = 0; i < MSM_MAX; ++i)
{
FString Name = Enum->GetEnumName(i);
Line = FString::Printf(TEXT("%d. %s"), i, *Name);
bool bThere = (Value & (1 << i)) != 0;
Canvas.DrawShadowedString(X + 30, Y, *Line, GetStatsFont(), bThere ? FLinearColor(1, 1, 1) : FLinearColor(0, 0, 0) );
Y += 20;
}
Line = FString::Printf(TEXT("(On CPU, based on what gets rendered)"));
Canvas.DrawShadowedString( X, Y, *Line, GetStatsFont(), FLinearColor(0.5f, 0.5f, 0.5f)); Y += YStep;
Canvas.Flush_RenderThread(Context.RHICmdList);
Context.RHICmdList.CopyToResolveTarget(DestRenderTarget.TargetableTexture, DestRenderTarget.ShaderResourceTexture, false, FResolveParams());
// AdjustGBufferRefCount(1) call is done in constructor
FSceneRenderTargets::Get(Context.RHICmdList).AdjustGBufferRefCount(Context.RHICmdList, -1);
}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:91,代码来源:VisualizeShadingModels.cpp
示例17: SCOPED_DRAW_EVENT
//.........这里部分代码省略.........
// Draw a quad mapping scene color to the view's render target
DrawRectangle(
0, 0,
DestRect.Width(), DestRect.Height(),
SrcRect.Min.X, SrcRect.Min.Y,
SrcRect.Width(), SrcRect.Height(),
DestRect.Size(),
SrcSize,
EDRF_UseTriangleOptimization);
// Now draw the requested tiles into the grid
TShaderMapRef<FPostProcessVS> VertexShader(GetGlobalShaderMap());
TShaderMapRef<FPostProcessVisualizeBufferPS<true> > PixelShader(GetGlobalShaderMap());
RHISetBlendState(TStaticBlendState<CW_RGB, BO_Add, BF_SourceAlpha, BF_InverseSourceAlpha>::GetRHI());
static FGlobalBoundShaderState BoundShaderState;
SetGlobalBoundShaderState(BoundShaderState, GFilterVertexDeclaration.VertexDeclarationRHI, *VertexShader, *PixelShader);
PixelShader->SetPS(Context);
// Track the name and position of each tile we draw so we can write text labels over them
struct LabelRecord
{
FString Label;
int32 LocationX;
int32 LocationY;
};
TArray<LabelRecord> Labels;
const int32 MaxTilesX = 4;
const int32 MaxTilesY = 4;
const int32 TileWidth = DestRect.Width() / MaxTilesX;
const int32 TileHeight = DestRect.Height() / MaxTilesY;
int32 CurrentTileIndex = 0;
for (TArray<TileData>::TConstIterator It = Tiles.CreateConstIterator(); It; ++It, ++CurrentTileIndex)
{
FRenderingCompositeOutputRef Tile = It->Source;
if (Tile.IsValid())
{
FTextureRHIRef Texture = Tile.GetOutput()->PooledRenderTarget->GetRenderTargetItem().TargetableTexture;
int32 TileX = CurrentTileIndex % MaxTilesX;
int32 TileY = CurrentTileIndex / MaxTilesX;
PixelShader->SetSourceTexture(Texture);
DrawRectangle(
TileX * TileWidth, TileY * TileHeight,
TileWidth, TileHeight,
SrcRect.Min.X, SrcRect.Min.Y,
SrcRect.Width(), SrcRect.Height(),
DestRect.Size(),
SrcSize,
EDRF_Default);
Labels.Add(LabelRecord());
Labels.Last().Label = It->Name;
Labels.Last().LocationX = 8 + TileX * TileWidth;
Labels.Last().LocationY = (TileY + 1) * TileHeight - 19;
}
}
// Draw tile labels
// this is a helper class for FCanvas to be able to get screen size
class FRenderTargetTemp : public FRenderTarget
{
public:
const FSceneView& View;
const FTexture2DRHIRef Texture;
FRenderTargetTemp(const FSceneView& InView, const FTexture2DRHIRef InTexture)
: View(InView), Texture(InTexture)
{
}
virtual FIntPoint GetSizeXY() const
{
return View.ViewRect.Size();
};
virtual const FTexture2DRHIRef& GetRenderTargetTexture() const
{
return Texture;
}
} TempRenderTarget(View, (const FTexture2DRHIRef&)DestRenderTarget.TargetableTexture);
FCanvas Canvas(&TempRenderTarget, NULL, ViewFamily.CurrentRealTime, ViewFamily.CurrentWorldTime, ViewFamily.DeltaWorldTime);
FLinearColor LabelColor(1, 1, 0);
for (auto It = Labels.CreateConstIterator(); It; ++It)
{
Canvas.DrawShadowedString(It->LocationX, It->LocationY, *It->Label, GetStatsFont(), LabelColor);
}
Canvas.Flush();
RHICopyToResolveTarget(DestRenderTarget.TargetableTexture, DestRenderTarget.ShaderResourceTexture, false, FResolveParams());
}
开发者ID:Tigrouzen,项目名称:UnrealEngine-4,代码行数:101,代码来源:PostProcessVisualizeBuffer.cpp
示例18: window
// The start of the Application
int App::start(const std::vector<std::string> &args)
{
quit = false;
clan::SlotContainer cc;
DisplayWindowDescription win_desc;
win_desc.set_allow_resize(true);
win_desc.set_title("Font Example Application");
win_desc.set_size(Size( 1000, 700 ), false);
DisplayWindow window(win_desc);
cc.connect(window.sig_window_close(), std::function<void()>(this, &App::on_window_close));
cc.connect(window.get_ic().get_keyboard().sig_key_up(), std::function<void(const clan::InputEvent&)>(this, &App::on_input_up));
resources = clan::XMLResourceManager::create(clan::XMLResourceDocument("Resources/resources.xml"));
std::string theme;
if (FileHelp::file_exists("../../../Resources/GUIThemeAero/theme.css"))
theme = "../../../Resources/GUIThemeAero";
else if (FileHelp::file_exists("../../../Resources/GUIThemeBasic/theme.css"))
theme = "../../../Resources/GUIThemeBasic";
else
throw Exception("No themes found");
gui_manager = GUIWindowManagerTexture(window);
GUIManager gui(gui_manager, theme);
canvas = Canvas(window);
GUITopLevelDescription gui_desc;
gui_desc.set_title("Options");
gui_desc.set_position(Rect(10, 10, 250, 400), false);
GUIComponent gui_window(&gui, gui_desc, "window");
int offset_x = 10;
int offset_y = 8;
int width = 200;
int height = 20;
const int gap = 26;
PushButton button_class_system(&gui_window);
button_class_system.set_geometry(Rect(offset_x, offset_y, offset_x + width, offset_y + height));
button_class_system.func_clicked() = bind_member(this, &App::on_button_clicked_class_system);
button_class_system.set_text("Class: System");
offset_y += gap;
PushButton button_class_sprite(&gui_window);
button_class_sprite.set_geometry(Rect(offset_x, offset_y, offset_x + width, offset_y + height));
button_class_sprite.func_clicked() = bind_member(this, &App::on_button_clicked_class_sprite);
button_class_sprite.set_text("Class: Sprite");
offset_y += gap;
PushButton button_typeface_tahoma(&gui_window);
button_typeface_tahoma_ptr = &button_typeface_tahoma;
button_typeface_tahoma.set_geometry(Rect(offset_x, offset_y, offset_x + width, offset_y + height));
button_typeface_tahoma.func_clicked() = bind_member(this, &App::on_button_clicked_typeface_tahoma);
button_typeface_tahoma.set_text("Typeface: Tahoma");
offset_y += gap;
PushButton button_typeface_sans(&gui_window);
button_typeface_sans_ptr = &button_typeface_sans;
button_typeface_sans.set_geometry(Rect(offset_x, offset_y, offset_x + width, offset_y + height));
button_typeface_sans.func_clicked() = bind_member(this, &App::on_button_clicked_typeface_sans);
button_typeface_sans.set_text("Typeface: Microsoft Sans Serif");
offset_y += gap;
PushButton button_typeface_bitstream(&gui_window);
button_typeface_bitstream_ptr = &button_typeface_bitstream;
button_typeface_bitstream.set_geometry(Rect(offset_x, offset_y, offset_x + width, offset_y + height));
button_typeface_bitstream.func_clicked() = bind_member(this, &App::on_button_clicked_typeface_bitstream);
button_typeface_bitstream.set_text("Typeface: Bitstream Vera Sans");
offset_y += gap;
CheckBox checkbox1(&gui_window);
checkbox1.set_geometry(Rect(offset_x, offset_y, offset_x + 80, offset_y + height));
checkbox1.func_state_changed() = bind_member(this, &App::on_checkbox_state_underline);
checkbox1.set_text("Underline");
CheckBox checkbox2(&gui_window);
checkbox2.set_geometry(Rect(offset_x+100, offset_y, offset_x + 180, offset_y + height));
checkbox2.func_state_changed() = bind_member(this, &App::on_checkbox_state_strikeout);
checkbox2.set_text("Strikeout");
offset_y += gap;
CheckBox checkbox3(&gui_window);
checkbox3.set_geometry(Rect(offset_x, offset_y, offset_x + 80, offset_y + height));
checkbox3.func_state_changed() = bind_member(this, &App::on_checkbox_state_italic);
checkbox3.set_text("Italic");
CheckBox checkbox4(&gui_window);
checkbox4.set_checked(true);
checkbox4.set_geometry(Rect(offset_x+100, offset_y, offset_x + 180, offset_y + height));
checkbox4.func_state_changed() = bind_member(this, &App::on_checkbox_state_antialias);
checkbox4.set_text("Anti Alias");
offset_y += gap;
CheckBox checkbox5(&gui_window);
checkbox5.set_checked(true);
checkbox5.set_geometry(Rect(offset_x, offset_y, offset_x + 120, offset_y + height));
//.........这里部分代码省略.........
开发者ID:punkkeks,项目名称:ClanLib,代码行数:101,代码来源:font.cpp
示例19: flogger
Win32_App::Win32_App()
{
SourceDLLName = "Game.dll";
//GameCode = Win32_LoadGameCode(SourceDLLName);
#ifdef _DEBUG
// Дебажная консоль
FileLogger flogger("debug.log");
log_event("SYSTEM", "Logger initialized");
#endif
try
{
// We support all display targets, in order listed here
#ifdef WIN32
D3DTarget::enable();
#endif
OpenGLTarget::enable();
}
catch (Exception exception)
{
// Create a console window for text-output if not available
ConsoleWindow console("Console", 80, 160);
Console::write_line("Exception caught: " + exception.get_message_and_stack_trace());
console.display_close_message();
quit = true;
}
// TODO: сохранять настройки графики
fullscreen = 0;
// TODO: Масштабировать окно
InitScreenSize = Sizef(1024.0f, 768.0f);
ScreenSize = InitScreenSize;
DisplayWindowDescription window_description;
window_description.set_title("Robot Game");
window_description.set_size(ScreenSize, true);
window_description.set_allow_resize(true);
//window_description.set_type(WindowType::tool);
window = DisplayWindow(window_description);
canvas = Canvas(window);
// Подключим коллбэки на слоты пользовательского ввода
keyboard = window.get_ic().get_keyboard();
sc.connect(window.sig_window_close(), bind_member(this, &Win32_App::Win32_OnWindowClose));
sc.connect(window.get_ic().get_keyboard().sig_key_up(), bind_member(this, &Win32_App::Win32_OnKeyUp));
sc.connect(window.get_ic().get_keyboard().sig_key_down(), bind_member(this, &Win32_App::Win32_OnKeyDown));
sc.connect(window.get_ic().get_mouse().sig_key_down(), bind_member(this, &Win32_App::Win32_OnMouseDown));
// Sound
SoundOutput sound_output(48000);
/*
SoundBuffer sbuffer("cheer1.ogg");
sbuffer.play();
*/
// Game memory
LPVOID BaseAddress = 0;
GameMemory.PermanentStorageSize = Megabytes(256);
GameMemory.TransientStorageSize = Megabytes(256);
size_t TotalStorageSize = (size_t)(GameMemory.PermanentStorageSize + GameMemory.TransientStorageSize);
GameMemory.PermanentStorage = VirtualAlloc(BaseAddress, TotalStorageSize, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
GameMemory.TransientStorage = ((uint8*)GameMemory.PermanentStorage + GameMemory.PermanentStorageSize);
// Game state
GameState = (game_state*)GameMemory.PermanentStorage;
*GameState = {};
GameState->ScreenSize = ScreenSize;
// Resources
//OpenGLTarget::set_current();
GameState->game_resources = clan::XMLResourceManager::create(clan::XMLResourceDocument("sprites.xml"));
GameState->LoadGameSpriteFromImage = &LoadGameSpriteFromImage;
GameState->LoadGameSpriteFromResource = &LoadGameSpriteFromResource;
GameState->AddGameSpriteFrameFromImage = &AddGameSpriteFrameFromImage;
// Main display buffers
//GameState->MainDisplayBuffer = PixelBuffer(1024, 768, TextureFormat::tf_rgba8, GameMemory.TransientStorage);
// Win32 Timings
CanSleepSafe = (timeBeginPeriod(1) == TIMERR_NOERROR);
QueryPerformanceFrequency(&PerfCounterFrequencyQ);
PerfCounterFrequency = PerfCounterFrequencyQ.QuadPart;
QueryPerformanceCounter(&LastCounter);
LastCycleCount = __rdtsc();
game_time.reset();
//console.display_close_message();
//timeEndPeriod(1);
}
开发者ID:MeiHouwang,项目名称:RoboGame,代码行数:98,代码来源:Win32_app.cpp
示例20: SCOPED_DRAW_EVENT
void FRCPassPostProcessTestImage::Process(FRenderingCompositePassContext& Context)
{
SCOPED_DRAW_EVENT(Context.RHICmdList, TestImage, DEC_SCENE_ITEMS);
const FSceneView& View = Context.View;
const FSceneViewFamily& ViewFamily = *(View.Family);
FIntRect SrcRect = View.ViewRect;
FIntRect DestRect = View.ViewRect;
const FSceneRenderTargetItem& DestRenderTarget = PassOutputs[0].RequestSurface(Context);
// Set the view family's render target/viewport.
SetRenderTarget(Context.RHICmdList, DestRenderTarget.TargetableTexture, FTextureRHIRef());
Context.SetViewportAndCallRHI(DestRect);
// set the state
Context.RHICmdList.SetBlendState(TStaticBlendState<>::GetRHI());
Context.RHICmdList.SetRasterizerState(TStaticRasterizerState<>::GetRHI());
Context.RHICmdList.SetDepthStencilState(TStaticDepthStencilState<false, CF_Always>::GetRHI());
TShaderMapRef<FPostProcessVS> VertexShader(Context.GetShaderMap());
TShaderMapRef<FPostProcessTestImagePS> PixelShader(Context.GetShaderMap());
static FGlobalBoundShaderState BoundShaderState;
SetGlobalBoundShaderState(Context.RHICmdList, Context.GetFeatureLevel(), BoundShaderState, GFilterVertexDeclaration.VertexDeclarationRHI, *VertexShader, *PixelShader);
PixelShader->SetPS(Context);
// Draw a quad mapping scene color to the view's render target
DrawRectangle(
Context.RHICmdList,
0, 0,
DestRect.Width(), DestRect.Height(),
SrcRect.Min.X, SrcRect.Min.Y,
SrcRect.Width(), SrcRect.Height(),
DestRect.Size(),
GSceneRenderTargets.GetBufferSizeXY(),
*VertexShader,
EDRF_UseTriangleOptimization);
{
// this is a helper class for FCanvas to be able to get screen size
class FRenderTargetTemp : public FRenderTarget
{
public:
const FSceneView& View;
const FTexture2DRHIRef Texture;
FRenderTargetTemp(const FSceneView& InView, const FTexture2DRHIRef InTexture)
: View(InView), Texture(InTexture)
{
}
virtual FIntPoint GetSizeXY() const
{
return View.ViewRect.Size();
};
virtual const FTexture2DRHIRef& GetRenderTargetTexture() const
{
return Texture;
}
} TempRenderTarget(View, (const FTexture2DRHIRef&)DestRenderTarget.TargetableTexture);
FCanvas Canvas(&TempRenderTarget, NULL, ViewFamily.CurrentRealTime, ViewFamily.CurrentWorldTime, ViewFamily.DeltaWorldTime, Context.GetFeatureLevel());
float X = 30;
float Y = 8;
const float YStep = 14;
const float ColumnWidth = 250;
FString Line;
Line = FString::Printf(TEXT("Top bars:"));
Canvas.DrawShadowedString( X, Y += YStep, *Line, GetStatsFont(), FLinearColor(1, 1, 1));
Line = FString::Printf(TEXT(" Moving bars using FrameTime"));
Canvas.DrawShadowedString( X, Y += YStep, *Line, GetStatsFont(), FLinearColor(1, 1, 1));
Line = FString::Printf(TEXT(" Black and white raster, Pixel sized, Watch for Moire pattern"));
Canvas.DrawShadowedString( X, Y += YStep, *Line, GetStatsFont(), FLinearColor(1, 1, 1));
Line = FString::Printf(TEXT(" Black and white raster, 2x2 block sized"));
Canvas.DrawShadowedString( X, Y += YStep, *Line, GetStatsFont(), FLinearColor(1, 1, 1));
Line = FString::Printf(TEXT("Bottom bars:"));
Canvas.DrawShadowedString( X, Y += YStep, *Line, GetStatsFont(), FLinearColor(1, 1, 1));
Line = FString::Printf(TEXT(" 8 bars near white, 4 right bars should appear as one (HDTV)"));
Canvas.DrawShadowedString( X, Y += YStep, *Line, GetStatsFont(), FLinearColor(1, 1, 1));
Line = FString::Printf(TEXT(" 8 bars near black, 4 left bars should appear as one (HDTV)"));
Canvas.DrawShadowedString( X, Y += YStep, *Line, GetStatsFont(), FLinearColor(1, 1, 1));
Line = FString::Printf(TEXT(" Linear Greyscale in sRGB from 0 to 255"));
Canvas.DrawShadowedString( X, Y += YStep, *Line, GetStatsFont(), FLinearColor(1, 1, 1));
Line = FString::Printf(TEXT("Color bars:"));
Canvas.DrawShadowedString( X, Y += YStep, *Line, GetStatsFont
|
请发表评论