当前位置: 首页>>代码示例>>C++>>正文


C++ Rect2D::y0方法代码示例

本文整理汇总了C++中Rect2D::y0方法的典型用法代码示例。如果您正苦于以下问题:C++ Rect2D::y0方法的具体用法?C++ Rect2D::y0怎么用?C++ Rect2D::y0使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Rect2D的用法示例。


在下文中一共展示了Rect2D::y0方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: drawPopup

Rect2D App::drawPopup(const char* title) {
    int w = renderDevice->width();
    int h = renderDevice->height();

    // Drop shadow
    renderDevice->pushState();
        renderDevice->setBlendFunc(RenderDevice::BLEND_SRC_ALPHA, RenderDevice::BLEND_ONE_MINUS_SRC_ALPHA);
        Rect2D rect = Rect2D::xywh(w/2 - 20, h/2 - 20, w/2, h/2);
        Draw::rect2D(rect + Vector2(5, 5), renderDevice, Color4(0, 0, 0, 0.15f));
    renderDevice->popState();

    // White box
    Draw::rect2D(rect, renderDevice, Color3::white());
    Draw::rect2DBorder(rect, renderDevice, Color3::black());

    // The close box
    Draw::rect2DBorder(Rect2D::xywh(rect.x1() - 16, rect.y0(), 16, 16), renderDevice, Color3::black());
    renderDevice->setColor(Color3::black());
    renderDevice->beginPrimitive(PrimitiveType::LINES);
        renderDevice->sendVertex(Vector2(rect.x1() - 14, rect.y0() + 2));
        renderDevice->sendVertex(Vector2(rect.x1() - 2, rect.y0() + 14));   
        renderDevice->sendVertex(Vector2(rect.x1() - 2, rect.y0() + 2));
        renderDevice->sendVertex(Vector2(rect.x1() - 14, rect.y0() + 14));   
    renderDevice->endPrimitive();

    float s = w * 0.013;
    titleFont->draw2D(renderDevice, title, Vector2(rect.x0() + 4, rect.y0()), s * 1.5, Color3::black(), Color4::clear(), GFont::XALIGN_LEFT, GFont::YALIGN_TOP);

    return rect;
}
开发者ID:luaman,项目名称:g3d-cvs,代码行数:30,代码来源:main.cpp

示例2: setDimensions

void SDLWindow::setDimensions(const Rect2D& dims) {
    #ifdef G3D_WIN32
        int W = screenWidth();
        int H = screenHeight();

        int x = iClamp((int)dims.x0(), 0, W);
        int y = iClamp((int)dims.y0(), 0, H);
        int w = iClamp((int)dims.width(), 1, W);
        int h = iClamp((int)dims.height(), 1, H);

        SetWindowPos(_Win32HWND, NULL, x, y, w, h, SWP_NOZORDER);
        // Do not update settings-- wait for an event to notify us
    #endif

	#ifdef G3D_LINUX
		//TODO: Linux
	#endif 

    // TODO: OS X
}
开发者ID:luaman,项目名称:g3d-cpp,代码行数:20,代码来源:SDLWindow.cpp

示例3: convertFromUnitToNormal

Vector3 Camera::convertFromUnitToNormal(const Vector3& in, const Rect2D& viewport) const{
    return (in + Vector3(1.0f, 1.0f, 1.0f)) * 0.5f * Vector3(viewport.width(), viewport.height(), 1.0f) + 
            Vector3(viewport.x0(), viewport.y0(), 0.0f);
}
开发者ID:jackpoz,项目名称:G3D-backup,代码行数:4,代码来源:Camera.cpp

示例4: onGraphics


//.........这里部分代码省略.........
        drawBar(rd, featureRating, p);

        // Designed to put NV40 at 50
        performanceRating = log(rd->stats().frameRate) * 15.0f;

        p.y += s * 4;
        performanceButton =
            Rect2D::xywh(p,
                         titleFont->draw2D(rd, "Speed", p - Vector2(w * 0.0075f, 0), s * 2, Color3::white() * 0.4f));

        {
            float spd = iRound(performanceRating * 10) / 10.0f;
            p.y += reportFont->draw2D(rd, format("%5.1f", spd), Vector2(x0 - s*2, p.y), s*2, Color3::red() * 0.5).y;
        }
        drawBar(rd, (int)min(performanceRating, 100.0f), p);

        p.y += s * 4;
        titleFont->draw2D(rd, "Quality", p - Vector2(w * 0.0075f, 0), s * 2, Color3::white() * 0.4f);
        p.y += reportFont->draw2D(rd, quality(bugCount), Vector2(x0, p.y), s*2, Color3::red() * 0.5f).y;
        drawBar(rd, iClamp(100 - bugCount * 10, 0, 100), p);

#       undef PRINT


        p.y = h - 50;
#       define PRINT(str) p.y += reportFont->draw2D(rd, str, p, 8, Color3::black()).y;

        PRINT("These ratings are based on the performance of G3D apps.");
        PRINT("They may not be representative of overall 3D performance.");
        PRINT("Speed is based on both processor and graphics card. Upgrading");
        PRINT("your graphics driver may improve Quality and Features.");
#       undef  PRINT
#       undef LABEL

        switch (popup) {
        case NONE:
            break;

        case PERFORMANCE:
            {
                //  Draw the popup box
                Rect2D box = drawPopup("Performance Details");
                p.x = box.x0() + 10;
                p.y = box.y0() + 30;

                Vector2 spacing(box.width() / 6.5, 0);

                std::string str;

                float factor = 3 * vertexPerformance.numTris / 1e6;

#               define PRINT(cap, val)   \
                    reportFont->draw2D(rd, cap, p, s, Color3::black());\
                    reportFont->draw2D(rd, (vertexPerformance.val[0] > 0) ? \
                        format("%5.1f", vertexPerformance.val[0]) : \
                        std::string("X"), p + spacing * 3, s, Color3::red() * 0.5, Color4::clear(), GFont::XALIGN_RIGHT);\
                    reportFont->draw2D(rd, (vertexPerformance.val[0] > 0) ? \
                        format("%5.1f", factor * vertexPerformance.val[0]) : \
                        std::string("X"), p + spacing * 4, s, Color3::red() * 0.5, Color4::clear(), GFont::XALIGN_RIGHT);\
                    reportFont->draw2D(rd, (vertexPerformance.val[1] > 0) ? \
                        format("%5.1f", vertexPerformance.val[1]) : \
                        std::string("X"), p + spacing * 5, s, Color3::red() * 0.5, Color4::clear(), GFont::XALIGN_RIGHT);\
                    p.y += reportFont->draw2D(rd, (vertexPerformance.val[1] > 0) ? \
                        format("%5.1f", factor * vertexPerformance.val[1]) : \
                        std::string("X"), p + spacing * 6, s, Color3::red() * 0.5, Color4::clear(), GFont::XALIGN_RIGHT).y;

                reportFont->draw2D(rd, "Incoherent", p + spacing * 3.5, s, Color3::black(), Color4::clear(), GFont::XALIGN_RIGHT);
                p.y += reportFont->draw2D(rd, "Coherent", p + spacing * 5.5, s, Color3::black(), Color4::clear(), GFont::XALIGN_RIGHT).y;

                reportFont->draw2D(rd, "FPS*", p + spacing * 3, s, Color3::black(), Color4::clear(), GFont::XALIGN_RIGHT);
                reportFont->draw2D(rd, "MVerts/s", p + spacing * 4, s, Color3::black(), Color4::clear(), GFont::XALIGN_RIGHT);
                reportFont->draw2D(rd, "FPS*", p + spacing * 5, s, Color3::black(), Color4::clear(), GFont::XALIGN_RIGHT).y;
                p.y += reportFont->draw2D(rd, "MVerts/s", p + spacing * 6, s, Color3::black(), Color4::clear(), GFont::XALIGN_RIGHT).y;
                
                PRINT("glBegin/glEnd", beginEndFPS);
                PRINT("glDrawElements", drawElementsRAMFPS); 
                PRINT("  + VBO", drawElementsVBOFPS);
                PRINT("  + uint16", drawElementsVBO16FPS);
                PRINT("  + gl interleave", drawElementsVBOIFPS);
                PRINT("  + manual interleave", drawElementsVBOIMFPS);
                PRINT("  (without shading)", drawElementsVBOPeakFPS);

                reportFont->draw2D(rd, "glDrawArrays", p, s, Color3::black());
                reportFont->draw2D(rd, (vertexPerformance.drawArraysVBOPeakFPS > 0) ? \
                    format("%5.1f", vertexPerformance.drawArraysVBOPeakFPS) : \
                    std::string("X"), p + spacing * 5, s, Color3::red() * 0.5, Color4::clear(), GFont::XALIGN_RIGHT);\
                p.y += reportFont->draw2D(rd, (vertexPerformance.drawArraysVBOPeakFPS > 0) ? \
                    format("%5.1f", factor * vertexPerformance.drawArraysVBOPeakFPS) : \
                    std::string("X"), p + spacing * 6, s, Color3::red() * 0.5, Color4::clear(), GFont::XALIGN_RIGHT).y;

#               undef PRINT

                p.y += s;
                p.y += reportFont->draw2D(rd, format("* FPS at %d k polys/frame.", 
                    iRound(vertexPerformance.numTris / 1000.0)), p + Vector2(20, 0), s, Color3::black()).y;
            }
        }

    rd->pop2D();
}
开发者ID:luaman,项目名称:g3d-cvs,代码行数:101,代码来源:main.cpp

示例5: onEvent

bool GuiScrollBar::onEvent(const GEvent& event) {
    if (! m_visible) {
        return false;
    }
    float m = maxValue();
        Rect2D topB;
        Rect2D bottomB; 
        Rect2D barBounds;
        Rect2D thumbBounds;

        getAllBounds(topB, bottomB, barBounds, thumbBounds);
    if (event.type == GEventType::MOUSE_BUTTON_DOWN) {
       
        const Vector2& mouse = Vector2(event.button.x, event.button.y);
      
        if(bottomB.contains(mouse)) {
            *m_value = min<float>( m * m_extent, *m_value + m_extent * BUTTON_PRESS_SCROLL);
            m_state = ARROW_DOWN_SCROLLING;
            GEvent response;

            response.gui.type = GEventType::GUI_CHANGE;
            response.gui.control = m_eventSource;
            m_gui->fireEvent(response);

            fireEvent(GEventType::GUI_ACTION);
            return true;

        } else if (topB.contains(mouse)) {

            *m_value = max<float>( 0.0f, *m_value - m_extent*BUTTON_PRESS_SCROLL);

            m_state = ARROW_UP_SCROLLING;

            GEvent response;
            response.gui.type = GEventType::GUI_CHANGE;
            response.gui.control = m_eventSource;
            m_gui->fireEvent(response);

            fireEvent(GEventType::GUI_ACTION);
            return true;

        } else if (thumbBounds.contains(mouse)) {
            m_state = IN_DRAG;
            m_dragStart = mouse;
            m_dragStartValue = floatValue();
            
            GEvent response;
            response.gui.type = GEventType::GUI_DOWN;
            response.gui.control = m_eventSource;
            m_gui->fireEvent(response);

            response.gui.type = GEventType::GUI_CHANGE;
            response.gui.control = m_eventSource;
            m_gui->fireEvent(response);

            return true;

        } else if (barBounds.contains(mouse)) {
            // Jump to this position
            float p;
            if(m_vertical) {
                p =  ( mouse.y - (float)barBounds.y0() ) / ((float)barBounds.height()/(m + 1)) - .5f;
            } else {
                p = ( mouse.x - (float)barBounds.x0() ) / ((float)barBounds.width()/(m + 1)) - .5f;
            }
            p = max<float>(0, p);
            p = min<float>(p, m);
            setFloatValue(p);

            m_state = NONE;

            GEvent response;
            response.gui.type = GEventType::GUI_CHANGE;
            response.gui.control = m_eventSource;
            m_gui->fireEvent(response);

            fireEvent(GEventType::GUI_ACTION);
            return true;
        }

        return false;

    } else if (event.type == GEventType::MOUSE_BUTTON_UP) {

        m_state = NONE;

        fireEvent(GEventType::GUI_ACTION);
        if (m_state == IN_DRAG) {
            // End the drag

            fireEvent(GEventType::GUI_DOWN);
            fireEvent(GEventType::GUI_ACTION);

            return true;
        }

    } else if (event.type == GEventType::MOUSE_MOTION) {

        // We'll only receive these events if we have the keyFocus, but we can't
        // help receiving the key focus if the user clicked on the control!
//.........这里部分代码省略.........
开发者ID:elfprince13,项目名称:G3D10,代码行数:101,代码来源:GuiScrollBar.cpp

示例6: setDimensions

void wxGWindow::setDimensions (const Rect2D &dims) {
    window->SetSize(dims.x0(), dims.y0(), dims.width(), dims.height());
}
开发者ID:luaman,项目名称:g3d-cpp,代码行数:3,代码来源:wxGWindow.cpp


注:本文中的Rect2D::y0方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。