08-27-2019, 03:15 AM
(This post was last modified: 08-27-2019, 08:50 AM by alanhdiniz.)
Hey everyone,
I've just started to learn how to use Tilengine, and I was checking ou how to do direct pixel manipulation with the TLN_GetBitmapPtr function, but when changed the value of the pointer the program segfaulted (obviously). And since I could not find any examples of that function (well, not easily at least) I decided to ask some one over here to see if I can get some help.
This is my noob code:
Already thanking the support,
Alan.
I've just started to learn how to use Tilengine, and I was checking ou how to do direct pixel manipulation with the TLN_GetBitmapPtr function, but when changed the value of the pointer the program segfaulted (obviously). And since I could not find any examples of that function (well, not easily at least) I decided to ask some one over here to see if I can get some help.
This is my noob 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_SetBGColor(0, 36, 96);
TLN_CreateWindow(NULL, 0);
TLN_Bitmap bitmap = TLN_CreateBitmap(400, 240, 8);
TLN_SetLayerBitmap(0, bitmap);
int frame = 0;
while(TLN_ProcessWindow())
{
TLN_DrawFrame(frame);
for (int x = 0; x < 400; x++)
{
for (int y = 0; y < 240; y++)
{
uint8_t *pixel = TLN_GetBitmapPtr(bitmap, x, y);
*pixel = (uint8_t)0xff;
}
}
frame++;
}
TLN_DeleteBitmap(bitmap);
TLN_DeleteWindow();
TLN_Deinit();
return 0;
}
Already thanking the support,
Alan.