BRT Community

Please login or register.

Login with username, password and session length
Advanced search  

News:

Welcome to the Bridgetek Community!

Please read our Welcome Note

Technical Support enquires
please contact the team
@ Bridgetek Support

Please refer to our website for detailed information on all our products - Bridgetek - Bridging Technology

Author Topic: Proper way to set up and display multiple bitmaps in one DL  (Read 103 times)

rmand

  • Newbie
  • *
  • Posts: 4
    • View Profile


I'm able to display display multiple image/bitmaps as long as each image is set up with HANDLE, SOURCE, etc immediately prior to display.

If I try to set up multiple bitmaps parameters in advance, and then add a bitmap using VERTEX2F, I get a corrupted screen/display.

Below is an example of what does NOT work:

Note, the image data is already loaded into RAM and imageTable array contains valid bitmap attributes.


Code: [Select]
char handles[] = { 8,9 };
uint32_t addresses[] = { ramBitmapAddress1,ramBitmapAddress2};


       int count = 1; // if count == sizeof(handles) the display gets corrupted

for (int i = 0; i < sizeof(handles); i++) { 
App_WrCoCmd_Buffer(phost, BITMAP_HANDLE(handles[i]));
App_WrCoCmd_Buffer(phost, BITMAP_SOURCE(addresses[i]);
App_WrCoCmd_Buffer(phost, BITMAP_LAYOUT(L1, imageTable[i]->Stride, imageTable[i]->Height));
App_WrCoCmd_Buffer(phost, BITMAP_SIZE(NEAREST, BORDER, BORDER, imageTable[i]->Width, imageTable[i]->Height));
}

//Place the image
App_WrCoCmd_Buffer(phost, BEGIN(BITMAPS)); // start drawing bitmaps
App_WrCoCmd_Buffer(phost, COLOR_RGB(0,255,0));
App_WrCoCmd_Buffer(phost, VERTEX2F(685 * 16, 380 * 16, 8, 0));
App_WrCoCmd_Buffer(phost, END());



What is the correct way of doing this?  It seems inefficient to have to set up the bitmap attributes every time it's being used.
Logged

BRT Community

  • Administrator
  • Hero Member
  • *****
  • Posts: 586
    • View Profile
Re: Proper way to set up and display multiple bitmaps in one DL
« Reply #1 on: July 18, 2022, 03:49:57 PM »

Hello,

It is worth considering the CMD_SETBITMAP as this makes it easier to set up your bitmaps and is easier to use than the individual commands.

You can use a SetBitmap command just before the vertex

   BEGIN(BITMAPS);
   CMD_SETBITMAP(0, L2, 300, 225);
   VERTEX2F(0,0);
   CMD_SETBITMAP(40000, L2, 300, 225);
   VERTEX2F(100*16,100*16);

You can also set the bitmaps up in a display list beforehand and you can then use them later on. for this you can create a display list with DLSTART at the start and DISPLAY  SWAP at the end.
{
        CMD_DLSTART();
   CLEAR_COLOR_RGB(0, 0, 0);
   CLEAR(1,1,1);

   BITMAP_HANDLE(0);
   CMD_SETBITMAP(0, L2, 300, 225);
   BITMAP_HANDLE(1);
   CMD_SETBITMAP(40000, L2, 300, 225);

   DISPLAY();
   CMD_SWAP();
}

// in the new screen where you want to use them:
   BEGIN(BITMAPS);
   VERTEX2II(0,0,0,0); // handle 0
   VERTEX2II(100,100,1,0); // handle 1

Best Regards, BRT Community
« Last Edit: July 18, 2022, 04:18:54 PM by BRT Community »
Logged

Kaetemi

  • Newbie
  • *
  • Posts: 29
    • View Profile
Re: Proper way to set up and display multiple bitmaps in one DL
« Reply #2 on: July 19, 2022, 07:19:43 PM »

Below is an example of what does NOT work:

You're missing `BITMAP_HANDLE` before the `VERTEX2F` call. The display list is a state machine, so the draw depends on the state that's set. The handle is used to point to one of 32 bitmap states, which persist across frames. And don't forget `DISPLAY` at the end to end the display list, as it may contain garbage.

Also, you may be missing `BITMAP_SIZE_H` and `BITMAP_LAYOUT_H` calls, their previous state may contain garbage as well.

I recommend using the `EVE_CoDl_` convenience calls from HAL, such as `EVE_CoDl_bitmapLayout`, instead of App_WrCoCmd_Buffer etc, as they simplify compatibility and reduce mistakes. (e.g. `EVE_CoDl_vertex2f_4` includes logic to automatically switch vertex format if your coordinates are out of range, and `EVE_CoDl_vertexFormat` deduplicates redundant state change calls.)
Logged

rmand

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Proper way to set up and display multiple bitmaps in one DL
« Reply #3 on: August 16, 2022, 05:53:52 PM »

Thank you for your help!
Looks like there were two issues.

1) The examples and programming guide makes heavy use of direct to DL commands.  So I was setting the handle in the DL but the bitmap info in the CO CMD queue.
2) DISPLAY() at the of the DL was required otherwise the bitmaps would get chopped or shrunk depending on the garbage passed the end of the list in DL RAM.

Logged