Jump to content

3D Sprite Text Not Working


Go to solution Solved by Josh,

Recommended Posts

  • reepblue changed the title to 3D Sprite Text Not Working
  • 2 weeks later...
  • Solution
Posted

The problem is you are supplying TEXT_LEFT | TEXT_TOP as the size argument.

It looks like the documentation is already correct, so I think there is no bug: https://www.leadwerks.com/learn/CreateSprite?lang=lua

Corrected Lua code:

font = LoadFont("Fonts/arial.ttf", 24)  sprite = CreateSprite(program.world, font, "Hello", 24, TEXT_LEFT | TEXT_TOP)  o = CreateGameObject(sprite)

Here is a test program that shows it working.

#include "Leadwerks.h"

using namespace Leadwerks;

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

    //Create a window
    auto window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, 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);
    
    //Create sprite
    auto font = LoadFont("Fonts/arial.ttf");
    auto sprite = CreateSprite(world, font, "Test this out!", 24);
    
    //Main loop
    while (window->Closed() == false and window->KeyHit(KEY_ESCAPE) == false)
    {
        world->Update();
        world->Render(framebuffer);
    }
    return 0;
}

 

  • Like 1

Let's build cool stuff and have fun. :)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...