Jump to content

Sprite pixel offset


Josh
 Share

Go to solution Solved by Josh,

Recommended Posts

 

OK:

#include "UltraEngine.h"

using namespace UltraEngine;

int main(int argc, const char* argv[])
{
    //Get the displays
    auto displays = GetDisplays();

    //Create a window
    auto window = CreateWindow("Ultra Engine", 0, 0, 640, 480, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR);

    //Create framebuffer
    auto framebuffer = CreateFramebuffer(window);

    //Create world
    auto world = CreateWorld();

    //Create camera
    auto camera = CreateCamera(world, PROJECTION_ORTHOGRAPHIC);
    camera->SetClearColor(0.125);
    camera->SetPosition(float(framebuffer->size.x) * 0.5f, float(framebuffer->size.y) * 0.5f, 0.0f);

    //Background
    auto sprite = CreateSprite(world, 100, 100);
    sprite->SetColor(0, 0, 1);
    sprite->SetPosition(10, framebuffer->size.y - sprite->size.y - 10);

    //Border
    auto sprite2 = CreateSprite(world, sprite->size.x - 2, sprite->size.y - 2, true);
    sprite2->SetPosition(sprite->position.x + 1.0f, sprite->position.y + 1.0f, -0.1f);

    //Main loop
    while (window->Closed() == false and window->KeyHit(KEY_ESCAPE) == false)
    {
        world->Update();
        world->Render(framebuffer);
    }
    return 0;
}

BUG:

#include "UltraEngine.h"

using namespace UltraEngine;

int main(int argc, const char* argv[])
{
    //Get the displays
    auto displays = GetDisplays();

    //Create a window
    auto window = CreateWindow("Ultra Engine", 0, 0, 640, 480, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR);

    //Create framebuffer
    auto framebuffer = CreateFramebuffer(window);

    //Create world
    auto world = CreateWorld();

    //Create camera
    auto camera = CreateCamera(world, PROJECTION_ORTHOGRAPHIC);
    camera->SetClearColor(0.125);
    camera->SetPosition(float(framebuffer->size.x) * 0.5f, float(framebuffer->size.y) * 0.5f, 0.0f);

    //Background
    auto sprite = CreateSprite(world, 100, 100, false, 5);
    sprite->SetColor(0, 0, 1);
    sprite->SetPosition(10, framebuffer->size.y - sprite->size.y - 10);

    //Border
    auto sprite2 = CreateSprite(world, sprite->size.x - 2, sprite->size.y - 2, true);
    sprite2->SetPosition(sprite->position.x + 1.0f, sprite->position.y + 1.0f, -0.1f);

    //Main loop
    while (window->Closed() == false and window->KeyHit(KEY_ESCAPE) == false)
    {
        world->Update();
        world->Render(framebuffer);
    }
    return 0;
}

BUG:

#include "UltraEngine.h"

using namespace UltraEngine;

int main(int argc, const char* argv[])
{
    //Get the displays
    auto displays = GetDisplays();

    //Create a window
    auto window = CreateWindow("Ultra Engine", 0, 0, 640, 480, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR);

    //Create framebuffer
    auto framebuffer = CreateFramebuffer(window);

    //Create world
    auto world = CreateWorld();

    //Create camera
    auto camera = CreateCamera(world, PROJECTION_ORTHOGRAPHIC);
    camera->SetClearColor(0.125);
    camera->SetPosition(float(framebuffer->size.x) * 0.5f, float(framebuffer->size.y) * 0.5f, 0.0f);

    //Background
    auto sprite = CreateSprite(world, 100, 100, false, 0);
    sprite->SetColor(0, 0, 1);
    sprite->SetPosition(10, framebuffer->size.y - sprite->size.y - 10);

    //Border
    auto sprite2 = CreateSprite(world, sprite->size.x - 2, sprite->size.y - 2, true, 5);
    sprite2->SetPosition(sprite->position.x + 1.0f, sprite->position.y + 1.0f, -0.1f);

    //Main loop
    while (window->Closed() == false and window->KeyHit(KEY_ESCAPE) == false)
    {
        world->Update();
        world->Render(framebuffer);
    }
    return 0;
}

 

 

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

  • Solution

I think I am going to try eliminating the radius parameter. I don't think this will ever work correctly, and even if it did it would still be extremely aliased. rasterizing an image for each rounded widget block could look a lot better.

  • Like 1

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

  • Josh locked this topic
Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...