polygon is not drawn

SGDK only sub forum

Moderator: Stef

cero
Very interested
Posts: 338
Joined: Mon Nov 30, 2015 1:55 pm

Re: polygon is not drawn

Post by cero » Fri Jul 15, 2022 2:43 pm

You didn't allocate it, and wrote to random memory. You really need to review your C basics.

alko
Very interested
Posts: 172
Joined: Thu Aug 07, 2014 9:31 am
Location: Russian Federation

Re: polygon is not drawn

Post by alko » Fri Jul 15, 2022 6:57 pm

:oops:

Code: Select all

 line = MEM_alloc( sizeof(Line));
Image

alko
Very interested
Posts: 172
Joined: Thu Aug 07, 2014 9:31 am
Location: Russian Federation

Re: polygon is not drawn

Post by alko » Fri Jul 15, 2022 9:26 pm

Also I want to place sprite behind two layers.

1.) how to set offset address of sprite after:

Code: Select all

 u16 ind = BMP_FB1ENDTILEINDEX    ;
 ind += cabin.tileset->numTile;
 

2.) how to set attributes priority?

Image
Image

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: polygon is not drawn

Post by Stef » Tue Jul 19, 2022 10:00 am

alko wrote:
Fri Jul 15, 2022 6:57 pm
:oops:

Code: Select all

 line = MEM_alloc( sizeof(Line));
No, it's really overkill and you may not release it properly later.
Just use static structure for that:

Code: Select all

 Line line;
line.pt1.x =0;
line.pt1.y =0;
line.pt2.x =100;
line.pt2.y =100;
line.col=10;

BMP_drawLine(&line);

alko
Very interested
Posts: 172
Joined: Thu Aug 07, 2014 9:31 am
Location: Russian Federation

Re: polygon is not drawn

Post by alko » Thu Aug 11, 2022 9:22 pm

I placed a sprite and artifacts appeared

Code: Select all

 BMP_init(TRUE, BG_B, PAL1, TRUE);
    BMP_setBufferCopy(TRUE);
    SYS_enableInts();
   u16 ind = BMP_FB1ENDTILEINDEX    ; //TILE_USERINDEX;
VDP_setPalette(PAL0, cabin.palette->data);
VDP_drawImageEx(BG_A, &cabin, TILE_ATTR_FULL(PAL0, TRUE, FALSE, FALSE, ind),0, 0, FALSE, TRUE);
ind += cabin.tileset->numTile;

SPR_init();

VDP_setPalette(PAL2, earth.palette->data);
sprites[0] = SPR_addSprite( &earth ,160, 100, TILE_ATTR(PAL2, FALSE, FALSE, FALSE));
SPR_setVRAMTileIndex(sprites[0],ind);

SPR_update();
SYS_doVBlankProcess();

Image
Image

Post Reply