Citro3D - Loading png into C3D_Tex

Discussion in '3DS - Homebrew Development and Emulators' started by PrintHello, Jul 23, 2017.

  1. PrintHello
    OP

    PrintHello Member

    Newcomer
    37
    15
    Feb 10, 2016
    Solved! See below for details

    I'm trying to write a simple GPU-based text renderer that will load a png file on the SD card into a C3D_Tex and display it on the screen.

    I've tried using libpng from the precompiled portlibs, and a png loader PicoPNG but both of them produce a texture like this:

    [​IMG]

    Code

    Both the Tex and the png have the same dimensions (128x128). I've used the png to bin converter tool and loaded the bin as the texture and that still shows up this garbled mess. Strangely the kitten.bin from the examples does load properly so I have no clue what it would be, probably something simple :sleep:.

    I've had a look at sfillib and it seems to do what I want but according to the github page it is deprecated.

    Any help is appreciated

    Cheers
     
    Last edited by PrintHello, Jul 23, 2017
  2. bee395

    bee395 Newbie

    Newcomer
    2
    1
    Jun 26, 2016
    Netherlands
    When I replace the kitten.bin with the logo.bin (from the Cirto3d test project) I get a good looking image. But when when I convert the logo64.png to a bin format, which should be the same, I get the same garbled mess. So I think it's something to do with the file format.
    You can maybe fix it with C3D_SafeDisplayTransfer but I'm not really sure.

    It's maybe easier to look at the gpusprites example, since they use a pngconverter so you don't have to worry about different bin formats.

    https://github.com/devkitPro/3ds-examples/blob/master/graphics/gpu/gpusprites/source/main.c#L182
     
    PrintHello likes this.
  3. PrintHello
    OP

    PrintHello Member

    Newcomer
    37
    15
    Feb 10, 2016
    upload_2017-7-23_21-1-12.png
    It's upside down and flipped horizontally but that did it :lol: Thanks!
    Here's the code for anyone else who comes across the thread (I made a new array to store the rgba to tiled format texture, and coped the rest from the link)
    Code
     
    jockep and bee395 like this.