Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Direct Pixel Manipulation (looking for an example of TLN_GetBitmapPtr)
#3
Thanks, marc, it worked (well, at least it didn't segfaulted...),

However, I tried to use TLN_SetPaletteColor, and the background is still black. My doubt here is that if I can draw something in runtime in the bitmap layer, or I actually need to use a tileset so I can manipulate that with the bitmap layer I've created.

My current code:

Code:
#include <stdio.h>
#include <stdlib.h>
#include "Tilengine.h"

int main (int argc, char* argv[])
{
    TLN_Init(400, 240, 1, 0, 0);
    TLN_CreateWindow(NULL, CWF_VSYNC);

    TLN_Bitmap bitmap = TLN_CreateBitmap(400, 240, 8);
    TLN_Palette palette = TLN_CreatePalette(256);
    TLN_SetBitmapPalette(bitmap, palette);
    TLN_SetLayerBitmap(0, bitmap);
    TLN_SetLayerPalette(0, palette);

    for (int i = 0; i < 256; i++)
        TLN_SetPaletteColor(palette, i, 0, 36, 96);

    int frame = 0;
    int color = 0;
    while(TLN_ProcessWindow())
    {
        TLN_DrawFrame(frame);

        TLN_SetPaletteColor(palette, color, color, color, color);
        if (color < 256)
            color++;
        else color = 0;

        frame++;
    }

    TLN_DeleteBitmap(bitmap);
    // TLN_DeletePalette(palette);
    TLN_DeleteWindow();
    TLN_Deinit();
    return 0;
}
Reply


Messages In This Thread
RE: Direct Pixel Manipulation (looking for an example of TLN_GetBitmapPtr) - by alanhdiniz - 08-27-2019, 09:48 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)