本文整理汇总了C++中Sizef函数的典型用法代码示例。如果您正苦于以下问题:C++ Sizef函数的具体用法?C++ Sizef怎么用?C++ Sizef使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Sizef函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: m_controls
ControllerHUD::ControllerHUD() :
m_controls()
{
const Sizef btn_size(16, 16);
const Vector pos(128, 64);
const Vector dpad_pos = pos + Vector(-64.0f, 0.0f);
m_controls[Control::LEFT] = Rectf::from_center(dpad_pos + Vector(-16.0f, 0.0f), btn_size);
m_controls[Control::RIGHT] = Rectf::from_center(dpad_pos + Vector(16.0f, 0.0f), btn_size);
m_controls[Control::UP] = Rectf::from_center(dpad_pos + Vector(0.0f, -16.0f), btn_size);
m_controls[Control::DOWN] = Rectf::from_center(dpad_pos + Vector(0.0f, 16.0f), btn_size);
const Vector peek_pos = pos + Vector(0.0f, -24.0f);
m_controls[Control::PEEK_LEFT] = Rectf::from_center(peek_pos + Vector(-16.0f, 0.0f), btn_size);
m_controls[Control::PEEK_RIGHT] = Rectf::from_center(peek_pos + Vector(16.0f, 0.0f), btn_size);
m_controls[Control::PEEK_UP] = Rectf::from_center(peek_pos + Vector(0.0f, -16.0f), btn_size);
m_controls[Control::PEEK_DOWN] = Rectf::from_center(peek_pos + Vector(0.0f, 16.0f), btn_size);
const Vector btn_pos = pos + Vector(64.0f, -8.0f);
m_controls[Control::ACTION] = Rectf::from_center(btn_pos + Vector(-20.0f, 0.0f), btn_size);
m_controls[Control::JUMP] = Rectf::from_center(btn_pos + Vector(0.0f, 20.0f), btn_size);
m_controls[Control::START] = Rectf::from_center(pos + Vector(16.0f, 24.0f), Sizef(16, 8));
m_controls[Control::ESCAPE] = Rectf::from_center(pos + Vector(-16.0f, 24.0f), Sizef(16, 8));
}
示例2: menu2rect
void
MenuManager::transition(Menu* from, Menu* to)
{
if (!from && !to)
{
return;
}
else
{
Rectf from_rect;
if (from)
{
from_rect = menu2rect(*from);
}
else
{
from_rect = Rectf(to->get_center_pos(), Sizef(0, 0));
}
Rectf to_rect;
if (to)
{
to_rect = menu2rect(*to);
}
else
{
to_rect = Rectf(from->get_center_pos(), Sizef(0, 0));
}
m_transition->start(from_rect, to_rect);
}
}
示例3: glClearColor
void
GeometryTest::draw()
{
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
Display::draw_line(line1, Color(0.0f, 1.0f, 0.0f));
Display::draw_line(line2, Color(0.0f, 1.0f, 0.0f));
Display::fill_rect(Rectf(cursor - Vector2f(2,2), Sizef(5,5)), Color(1.0f, 0.0f, 1.0f));
Display::fill_rect(Rectf(cursor2 - Vector2f(2,2), Sizef(5,5)), Color(1.0f, 1.0f, 0.0f));
Display::fill_rect(Rectf(collision_point - Vector2f(3,3), Sizef(7,7)), Color(1.0f, 1.0f, 1.0f));
// Try vector projection
Vector2f a(line1.p2 - line1.p1);
Vector2f b(line2.p2 - line2.p1);
Vector2f c(a.project(b));
Display::draw_line(line1.p1, line1.p1 + c, Color(1.0f, 1.0f, 1.0f, 0.5f));
int segments = std::max(0, int(cursor.y / 10));
Display::fill_arc(Vector2f(200, 200), 100.0f, cursor.x, cursor2.x, Color(1.0f, 1.0f, 1.0f, 0.5f), segments);
Display::draw_arc(Vector2f(200, 200), 100.0f, cursor.x, cursor2.x, Color(1.0f, 1.0f, 1.0f), segments);
Display::draw_circle(Vector2f(200, 200), 128.0f, Color(1.0f, 1.0f, 1.0f), segments);
}
示例4: 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;
}
示例5: Sizef
void
ItemHorizontalLine::draw(DrawingContext& context, const Vector& pos, int menu_width, bool active) {
// TODO
/* Draw a horizontal line with a little 3d effect */
context.color().draw_filled_rect(Rectf(Vector(pos.x, pos.y - 6.0f),
Sizef(static_cast<float>(menu_width), 4.0f)),
Color(0.6f, 0.7f, 1.0f, 1.0f), LAYER_GUI);
context.color().draw_filled_rect(Rectf(Vector(pos.x, pos.y - 6.0f),
Sizef(static_cast<float>(menu_width), 2.0f)),
Color(1.0f, 1.0f, 1.0f, 1.0f), LAYER_GUI);
}
示例6: reader
void FontProvider_Sprite::draw_text(Canvas &canvas, float xpos, float ypos, float scale_x, float scale_y, const std::string &text, const Colorf &color)
{
float f_spacelen = spacelen;
float ascent = font_metrics.get_ascent() * scale_x;
// Scan the string
UTF8_Reader reader(text.data(), text.length());
while(!reader.is_end())
{
unsigned int glyph = reader.get_char();
reader.next();
Font_Sprite_Glyph *gptr = get_glyph(glyph);
if (gptr)
{
spr_glyphs.set_frame(gptr->sprite_index);
Size frame_size = spr_glyphs.get_frame_size(gptr->sprite_index);
float dest_width = scale_x * frame_size.width;
float dest_height = scale_y * frame_size.height;
spr_glyphs.set_color(color);
spr_glyphs.draw(canvas, Rectf(xpos, ypos - ascent, Sizef(dest_width, dest_height)));
xpos += dest_width;
}
else
{
xpos += f_spacelen;
}
}
}
示例7: square_size
//------------------------------------------------------------------------------//
void InventoryItem::populateGeometryBuffer()
{
if (!isUserStringDefined("BlockImage"))
return;
const Image* img = PropertyHelper<Image*>::fromString(getUserString("BlockImage"));
if (!img)
return;
const Sizef square_size(squarePixelSize());
argb_t colour = 0xFF00FF00;
if (d_dragging && !currentDropTargetIsValid())
colour = 0xFFFF0000;
for (int y = 0; y < d_content.height(); ++y)
{
for (int x = 0; x < d_content.width(); ++x)
{
if (d_content.elementAtLocation(x, y))
{
img->render(d_geometryBuffers,
glm::vec2(x * square_size.d_width + 1, y * square_size.d_height + 1),
Sizef(square_size.d_width - 2, square_size.d_height - 2), 0, false,
ColourRect(colour));
}
}
}
}
示例8: Sizef
void
BicyclePlatform::draw(DrawingContext& context)
{
if (g_debug.show_collision_rects) {
context.color().draw_filled_rect(Rectf::from_center(m_center, Sizef(16, 16)), Color::MAGENTA, LAYER_OBJECTS);
}
}
示例9: reader
void Font_DrawFlat::draw_text(Canvas &canvas, const Pointf &position, const std::string &text, const Colorf &color, float line_spacing)
{
float offset_x = 0;
float offset_y = 0;
UTF8_Reader reader(text.data(), text.length());
RenderBatchTriangle *batcher = canvas.impl->batcher.get_triangle_batcher();
while (!reader.is_end())
{
unsigned int glyph = reader.get_char();
reader.next();
if (glyph == '\n')
{
offset_x = 0;
offset_y += line_spacing;
continue;
}
Font_TextureGlyph *gptr = glyph_cache->get_glyph(canvas, font_engine, glyph);
if (gptr)
{
if (!gptr->texture.is_null())
{
float xp = offset_x + position.x + gptr->offset.x;
float yp = offset_y + position.y + gptr->offset.y;
Rectf dest_size(xp, yp, Sizef(gptr->geometry.get_size()));
batcher->draw_image(canvas, gptr->geometry, dest_size, color, gptr->texture);
}
offset_x += gptr->metrics.advance.width;
offset_y += gptr->metrics.advance.height;
}
}
}
示例10: square_size
//------------------------------------------------------------------------------//
void InventoryReceiver::populateGeometryBuffer()
{
if (!isUserStringDefined("BlockImage"))
return;
const Image* img = PropertyHelper<Image*>::fromString(getUserString("BlockImage"));
if (!img)
return;
const Sizef square_size(squarePixelSize());
for (int y = 0; y < d_content.height(); ++y)
{
for (int x = 0; x < d_content.width(); ++x)
{
argb_t colour = 0xFFFFFFFF;
if (d_content.elementAtLocation(x, y))
colour = 0xFF0000FF;
img->render(*d_geometry,
Vector2f(x * square_size.d_width + 1, y * square_size.d_height + 1),
Sizef(square_size.d_width - 2, square_size.d_height - 2), 0,
ColourRect(colour));
}
}
}
示例11: glXDestroyPbuffer
//----------------------------------------------------------------------------//
void OpenGLGLXPBTextureTarget::initialisePBuffer()
{
int creation_attrs[] =
{
GLX_PBUFFER_WIDTH, d_area.getWidth(),
GLX_PBUFFER_HEIGHT, d_area.getHeight(),
GLX_LARGEST_PBUFFER, True,
GLX_PRESERVED_CONTENTS, True,
None
};
// release any existing pbuffer
if (d_pbuffer)
glXDestroyPbuffer(d_dpy, d_pbuffer);
d_pbuffer = glXCreatePbuffer(d_dpy, d_fbconfig, creation_attrs);
if (!d_pbuffer)
CEGUI_THROW(RendererException(
"pbuffer creation error: glXCreatePbuffer() failed"));
// get the real size of the buffer that was created
GLuint actual_width, actual_height;
glXQueryDrawable(d_dpy, d_pbuffer, GLX_WIDTH, &actual_width);
glXQueryDrawable(d_dpy, d_pbuffer, GLX_HEIGHT, &actual_height);
d_area.setSize(Sizef(actual_width, actual_height));
// ensure CEGUI::Texture is wrapping real GL texture and has correct size
d_CEGUITexture->setOpenGLTexture(d_texture, d_area.getSize());
}
示例12: Image
//----------------------------------------------------------------------------//
SVGImage::SVGImage(const XMLAttributes& attributes) :
Image(attributes.getValueAsString(ImageNameAttribute),
glm::vec2(static_cast<float>(attributes.getValueAsInteger(ImageXOffsetAttribute, 0)),
static_cast<float>(attributes.getValueAsInteger(ImageYOffsetAttribute, 0))),
Rectf(glm::vec2(static_cast<float>(attributes.getValueAsInteger(ImageXPosAttribute, 0)),
static_cast<float>(attributes.getValueAsInteger(ImageYPosAttribute, 0))),
Sizef(static_cast<float>(attributes.getValueAsInteger(ImageWidthAttribute, 0)),
static_cast<float>(attributes.getValueAsInteger(ImageHeightAttribute, 0)))),
PropertyHelper<AutoScaledMode>::fromString(attributes.getValueAsString(ImageAutoScaledAttribute)),
Sizef(static_cast<float>(attributes.getValueAsInteger(ImageNativeHorzResAttribute, 640)),
static_cast<float>(attributes.getValueAsInteger(ImageNativeVertResAttribute, 480)))),
d_svgData(&SVGDataManager::getSingleton().getSVGData(
attributes.getValueAsString(ImageSVGDataAttribute))),
d_useGeometryAntialiasing(true)
{
}
示例13: d_displayDPI
//----------------------------------------------------------------------------//
OpenGLRenderer::OpenGLRenderer(const TextureTargetType tt_type) :
d_displayDPI(96, 96),
d_initExtraStates(false),
d_activeBlendMode(BM_INVALID)
{
// get rough max texture size
GLint max_tex_size;
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max_tex_size);
d_maxTextureSize = max_tex_size;
// initialise display size
GLint vp[4];
glGetIntegerv(GL_VIEWPORT, vp);
d_displaySize = Sizef(static_cast<float>(vp[2]), static_cast<float>(vp[3]));
initialiseGLExtensions();
initialiseTextureTargetFactory(tt_type);
// we _really_ need separate rgb/alpha blend modes, if this support is not
// available, add a note to the renderer ID string so that this fact is
// logged.
if (!GLEW_VERSION_1_4 && !GLEW_EXT_blend_func_separate)
d_rendererID += " No glBlendFuncSeparate(EXT) support.";
d_defaultTarget = new OpenGLViewportTarget(*this);
}
示例14: init_area
//----------------------------------------------------------------------------//
void OgreTextureTarget::declareRenderSize(const Sizef& sz)
{
// exit if current size is enough
if ((d_area.getWidth() >= sz.d_width) && (d_area.getHeight() >=sz.d_height))
return;
Ogre::TexturePtr rttTex = Ogre::TextureManager::getSingleton().createManual(
OgreTexture::getUniqueName(),
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
Ogre::TEX_TYPE_2D, sz.d_width, sz.d_height, 1, 0, Ogre::PF_A8R8G8B8,
Ogre::TU_RENDERTARGET);
d_renderTarget = rttTex->getBuffer()->getRenderTarget();
Rectf init_area(
Vector2f(0, 0),
Sizef(d_renderTarget->getWidth(), d_renderTarget->getHeight())
);
setArea(init_area);
// delete viewport and reset ptr so a new one is generated. This is
// required because we have changed d_renderTarget so need a new VP also.
delete d_viewport;
d_viewport = 0;
// because Texture takes ownership, the act of setting the new ogre texture
// also ensures any previous ogre texture is released.
d_CEGUITexture->setOgreTexture(rttTex, true);
clear();
}
示例15: OpenGLTextureTarget
//----------------------------------------------------------------------------//
OpenGLWGLPBTextureTarget::OpenGLWGLPBTextureTarget(OpenGLRendererBase& owner) :
OpenGLTextureTarget(owner),
d_pixfmt(0),
d_pbuffer(0),
d_context(0),
d_hdc(0),
d_prevContext(0),
d_prevDC(0)
{
if (!WGLEW_ARB_pbuffer)
CEGUI_THROW(RendererException("WGL_ARB_pbuffer extension is needed to "
"use OpenGLWGLPBTextureTarget!"));
HDC hdc = wglGetCurrentDC();
uint fmtcnt;
wglChoosePixelFormatARB(hdc, pbAttrs, 0, 1, &d_pixfmt, &fmtcnt);
if (!fmtcnt)
CEGUI_THROW(RendererException(
"pbuff creation failure, no suitable pixel formats."));
initialiseTexture();
// set default size (and cause initialisation of the pbuffer)
declareRenderSize(Sizef(DEFAULT_SIZE, DEFAULT_SIZE));
}