Пример #1
0
void render()
{
    oRenderer->clear({0, 0, 0, 1});

    oPrimitiveBatch->begin(OPrimitivePointList);

    if (ORandBool()) oPrimitiveBatch->draw(Vector2(10, 25), Color(0, 1, 0, 1)); // 50%
    if (ORandBool(.25f)) oPrimitiveBatch->draw(Vector2(20, 25), Color(0, 1, 0, 1)); // 25%

    for (int i = 0; i < 100; ++i)
    {
        oPrimitiveBatch->draw(Vector2(ORandInt(10) * 10, 5), Color(1, 1, 0, 1));
        oPrimitiveBatch->draw(Vector2(ORandInt(5, 10) * 10, 10), Color(1, 1, 0, 1));
        oPrimitiveBatch->draw(Vector2(ORandInt(100), 15), Color(0, 1, 1, 1));
        oPrimitiveBatch->draw(Vector2(ORandInt(50, 100), 20), Color(0, 1, 1, 1));
        oPrimitiveBatch->draw(ORandVector2(Vector2(25, 25)) + Vector2(0, 30), Color(1, 0, 1, 1));
        oPrimitiveBatch->draw(ORandVector2(Vector2(10, 10), Vector2(25, 25)) + Vector2(30, 30), Color(1, 0, 1, 1));
        oPrimitiveBatch->draw(onut::randCircle(Vector2(50, 100), 25), Color(1, 1, 1, 1));
        oPrimitiveBatch->draw(onut::randCircleEdge(Vector2(150, 100), 25), Color(1, 1, 1, 1));
    }

    oPrimitiveBatch->end();

    oSpriteBatch->begin();

    oSpriteBatch->drawRect(nullptr, Rect(0, 150, 20, 12), ORandColor());
    oSpriteBatch->drawRect(nullptr, Rect(21, 150, 20, 12), ORandColor(.5f));
    oSpriteBatch->drawRect(nullptr, Rect(42, 150, 20, 12), ORandColor(Color(1, 0, 1)));
    oSpriteBatch->drawRect(nullptr, Rect(63, 150, 20, 12), ORandColor(Color(0, 1, 0), Color(1, 0, 0)));
    oSpriteBatch->drawRect(nullptr, Rect(63, 150, 20, 12), ORandColor(Color(0, 1, 0), Color(1, 0, 0)));

    onut::Palette palette = {
        OColorHex(43A08E),
        OColorHex(B3E0CB),
        OColorHex(EE5351),
        OColorHex(D19A8E),
        OColorHex(DBC9A3)
    };
    float x = 0;
    for (auto c : palette)
    {
        oSpriteBatch->drawRect(nullptr, Rect(x, 170, 20, 12), c);
        x += 21;
    }
    oSpriteBatch->drawRect(nullptr, Rect(0, 183, 20, 12), ORandColor(palette));
    oSpriteBatch->drawRect(nullptr, Rect(21, 183, 20, 12), ORandColor(palette, .5f));

    oSpriteBatch->end();
}
Пример #2
0
void render()
{
    // Clear
    oRenderer->clear(OColorHex(0));

    oSpriteBatch->begin();
    oSpriteBatch->drawRect(pVideoTexture, ORectFit(ORectFullScreen, pVideoTexture->getSize()));
    oSpriteBatch->end();
}
Пример #3
0
void render()
{
    // Clear
    oRenderer->clear(OColorHex(1d232d));

    // Draw stuff to our render target
    oRenderer->renderStates.renderTarget.push(pRenderTarget);
    oRenderer->renderStates.viewport.push({0, 0, pRenderTarget->getSize().x, pRenderTarget->getSize().y});
    oSpriteBatch->begin();
    oSpriteBatch->drawRect(pTextureFromFile, {0, 0, 128, 128});
    oSpriteBatch->drawRect(pTextureFromFile, {128, 0, 128, 128});
    oSpriteBatch->drawRect(pTextureFromFile, {0, 128, 128, 128});
    oSpriteBatch->drawRect(pTextureFromFile, {128, 128, 128, 128});
    oSpriteBatch->end();
    oRenderer->renderStates.viewport.pop();
    oRenderer->renderStates.renderTarget.pop();

    // Update our dynamic texture
    auto animValue = dynamicAnim.get();
    for (auto j = 0; j < 128; ++j)
    {
        for (auto i = 0; i < 128; ++i)
        {
            auto k = (j * 128 + i) * 4;
            dynamicData[k + 0] = j * 2 - animValue;
            dynamicData[k + 1] = j * 2 + animValue;
            dynamicData[k + 2] = j * 2;
            dynamicData[k + 3] = 255;
        }
    }
    pDynamic->setData(dynamicData);

    // Draw out resulted textures
    auto pFont = OGetFont("font.fnt");
    oSpriteBatch->begin(Matrix::CreateTranslation(80, 212, 0));
    oSpriteBatch->changeFiltering(OFilterNearest);

    oSpriteBatch->drawRect(pTextureFromFile, {0, 0, 128, 128});
    oSpriteBatch->drawRect(pTextureFromFileData, {128, 0, 128, 128});
    oSpriteBatch->drawRect(pTextureFromData, {256, 0, 128, 128});
    oSpriteBatch->drawRect(pRenderTarget, {384, 0, 128, 128});
    oSpriteBatch->drawRect(pDynamic, {512, 0, 128, 128});
    
    pFont->draw("From File", {64, 140}, OCenter);
    pFont->draw("From File Data", {64 + 128, 140}, OCenter);
    pFont->draw("From Data", {64 + 256, 140}, OCenter);
    pFont->draw("Render Target", {64 + 384, 140}, OCenter);
    pFont->draw("Dynamic", {64 + 512, 140}, OCenter);
    
    oSpriteBatch->end();
}
Пример #4
0
void render()
{
    // Clear
    oRenderer->clear(OColorHex(1d232d));

    // Draw Info
    auto pFont = OGetFont("font.fnt");

    oSpriteBatch->begin();

    pFont->draw("Original: ", {10, 10});
    pFont->draw(originalText, {200, 10}, OTopLeft, Color(.7f, 1.f));

    pFont->draw("Simple Hash: ", {10, 30});
    pFont->draw(std::to_string(hash), {200, 30}, OTopLeft, Color(.7f, 1.f));

    pFont->draw("Sha1: ", {10, 50});
    pFont->draw(sha1, {200, 50}, OTopLeft, Color(.7f, 1.f));

    pFont->draw("Shitty email validation: ", {10, 70});
    Vector2 pos(200, 70);
    for (auto& email : emails)
    {
        if (email.second)
        {
            pFont->draw(email.first, pos, OTopLeft, Color(0, 1, 0, 1.f));
        }
        else
        {
            pFont->draw(email.first, pos, OTopLeft, Color(1, 0, 0, 1.f));
        }
        pos.y += 12;
    }

    oSpriteBatch->end();
}
Пример #5
0
void render()
{
    // Clear
    oRenderer->clear(OColorHex(1d232d));
}
Пример #6
0
void render()
{
    auto pNutTexture = OGetTexture("onutLogo.png");
    auto pFrameTexture = OGetTexture("frameSmall.png");
    auto pChainTexture = OGetTexture("chain.png");

    // Clear
    oRenderer->clear(OColorHex(1d232d));

    // Begin a batch
    oSpriteBatch->begin(batchTransform);

    // Opaque
    oSpriteBatch->drawRect(nullptr, Rect(0, 0, 64, 64));
    oSpriteBatch->drawRect(nullptr, Rect(64, 0, 64, 64), Color(1, 0, 0, 1)); // Red
    oSpriteBatch->drawInclinedRect(nullptr, Rect(192, 0, 64, 64), -.5f); // Inclined

    // Textured
    oSpriteBatch->drawRect(pNutTexture, Rect(0, 64, 64, 64));
    oSpriteBatch->drawRect(pNutTexture, Rect(64, 64, 64, 64), Color(1, 0, 0, 1)); // Tinted

    // Per vertex coloring
    oSpriteBatch->drawRectWithColors(nullptr, Rect(0, 128, 64, 64), {Color(1, 0, 0, 1), Color(1, 1, 0, 1), Color(0, 1, 0, 1), Color(0, 0, 1, 1)});

    // Custom UVs
    oSpriteBatch->drawRectWithUVs(pNutTexture, Rect(64, 128, 64, 64), Vector4(0, 0, .5f, .5f));

    // Split the texture in 4 corner (Good for corsairs)
    oSpriteBatch->draw4Corner(pNutTexture, Rect(128, 64, 160, 160));

    // Scale 9, 9 Patch, 9 slice (whatever you guys call it)
    oSpriteBatch->drawRectScaled9(pFrameTexture, Rect(0, 256, 160, 160), Vector4(48, 48, 48, 48));
    oSpriteBatch->drawRectScaled9(pFrameTexture, Rect(160, 256, 256, 160), Vector4(48, 48, 48, 48));
    oSpriteBatch->drawRectScaled9RepeatCenters(pFrameTexture, Rect(416, 256, 256, 160), Vector4(48, 48, 48, 48));

    // Sprites
    oSpriteBatch->drawSprite(pNutTexture, Vector2(64, 480));
    oSpriteBatch->drawSprite(pNutTexture, Vector2(192, 480), Color::White, g_spriteAngle);
    oSpriteBatch->drawSprite(pNutTexture, Vector2(320, 440), Color::White, g_spriteAngle, .5f);
    oSpriteBatch->drawSprite(nullptr, Vector2(320, 500), Color::White, g_spriteAngle, 32.f);

    // With a custom matrix
    Matrix customTransform = Matrix::Identity;
    customTransform *= Matrix::CreateRotationZ(OConvertToRadians(g_spriteAngle));
    customTransform *= Matrix::CreateScale(4.f, 0.5f, 1.f);
    customTransform *= Matrix::CreateTranslation(520, 120, 0);
    oSpriteBatch->drawSprite(pNutTexture, customTransform, Color::White);

    // Lines
    oSpriteBatch->drawBeam(pChainTexture, Vector2(448, 480), Vector2(648, 440), 32.0f, Color::White);
    oSpriteBatch->drawBeam(pChainTexture, Vector2(448, 520), Vector2(648, 480), 32.0f, Color::White, g_spriteAngle * .1f);

    // Blend modes
    oRenderer->renderStates.blendMode = OBlendAdd;
    oSpriteBatch->drawSprite(pNutTexture, Vector2(400, 50), Color::White, 0, .25f);
    oRenderer->renderStates.blendMode = OBlendAlpha;
    oSpriteBatch->drawSprite(pNutTexture, Vector2(450, 50), Color::White, 0, .25f);
    oRenderer->renderStates.blendMode = OBlendForceWrite;
    oSpriteBatch->drawSprite(pNutTexture, Vector2(500, 50), Color::White, 0, .25f);
    oRenderer->renderStates.blendMode = OBlendMultiply;
    oSpriteBatch->drawSprite(pNutTexture, Vector2(550, 50), Color::White, 0, .25f);
    oRenderer->renderStates.blendMode = OBlendOpaque;
    oSpriteBatch->drawSprite(pNutTexture, Vector2(600, 50), Color::White, 0, .25f);
    oRenderer->renderStates.blendMode = OBlendPreMultiplied;
    oSpriteBatch->drawSprite(pNutTexture, Vector2(650, 50), Color::White, 0, .25f);

    // Origin
    oSpriteBatch->drawSprite(pNutTexture, Vector2(400, 200), Color::White, 0, .25f, Vector2(0, 0));
    oSpriteBatch->drawCross(Vector2(400, 200), 10.f, Color(1, 1, 0, 1));
    oSpriteBatch->drawSprite(pNutTexture, Vector2(500, 200), Color::White, 0, .25f, Vector2(.5f, .5f));
    oSpriteBatch->drawCross(Vector2(500, 200), 10.f, Color(1, 1, 0, 1));
    oSpriteBatch->drawSprite(pNutTexture, Vector2(600, 200), Color::White, 0, .25f, Vector2(1, 1));
    oSpriteBatch->drawCross(Vector2(600, 200), 10.f, Color(1, 1, 0, 1));

    // Filtering
    oRenderer->renderStates.sampleFiltering = OFilterNearest;
    oSpriteBatch->drawSprite(pNutTexture, Vector2(725, 100), Color::White, 0.f, 1.5f);
    oRenderer->renderStates.sampleFiltering = OFilterLinear;
    oSpriteBatch->drawSprite(pNutTexture, Vector2(725, 300), Color::White, 0.f, 1.5f);

    // End and flush the batch
    oSpriteBatch->end();
}
Пример #7
0
#include "DocumentView.h"
#include "viewStyles.h"

static const Color g_panelBGColor = OColorHex(2d2d30);
static const Color g_outlineColor = Color::Lerp(OColorHex(ff9933), g_panelBGColor, .75f);
static const Color g_panelTitleBGColor = OColorHex(3f3f46);
static const Color g_fontColor = OColorHex(f1f1f1);
static const Color g_sizeHandleColor = OColorHex(999999);
static const Color g_btnStatesColors[4][2] = {
    {OColorHex(333337), OColorHex(3e3e42)},
    {OColorHex(999999), OColorHex(3e3e42)},
    {OColorHex(1c97ea), OColorHex(3e3e42)},
    {OColorHex(007acc), OColorHex(333337)}
};

static onut::BMFont* g_pFont;

extern DocumentView* g_pDocument;
extern onut::UIControl* g_pUIScreen;
extern onut::UIContext* g_pUIContext;

void createViewUIStyles(onut::UIContext* pContext)
{
    g_pFont = OGetBMFont("segeo12.fnt");

    pContext->onClipping = [](bool enabled, const onut::sUIRect& rect)
    {
        OSB->end();

        auto regionRect = onut::UI2Onut(g_pUIScreen->getChild("pnlRegion")->getWorldRect(*g_pUIContext));
        auto orect = onut::UI2Onut(rect);