Jump to content

Photo

Allegro bitmap warning


  • Please log in to reply
4 replies to this topic

#1 jsm116

jsm116

    Script kludger

  • Members
  • Location:The 301

Posted 29 September 2018 - 04:32 PM

I have several custom subscreens and other things that require the use of a bitmap. Everything's working fine in the game but I'm getting this warning in allegro:

Warning: Screen->DrawBitmap(2) contains invalid data or is not initialized.
[Note* Deferred drawing or layering order possibly not set right.]

Without revealing all of my code, is there some usual cause for this warning? Is it something I can safely ignore or will it cause problems down the line as the quest grows?



#2 ywkls

ywkls

    Master

  • Members

Posted 30 September 2018 - 01:04 AM

I have several custom subscreens and other things that require the use of a bitmap. Everything's working fine in the game but I'm getting this warning in allegro:

Warning: Screen->DrawBitmap(2) contains invalid data or is not initialized.
[Note* Deferred drawing or layering order possibly not set right.]

Without revealing all of my code, is there some usual cause for this warning? Is it something I can safely ignore or will it cause problems down the line as the quest grows?

I've had that warning show up too.

I'm not exactly sure of the cause, but it usually occurred whenever something was trying to draw outside the limits of the bitmap.

Since each bitmap is 512 x 512 and can't have negative  coordinates as the source for the drawing, that could conceivably cause this.

To pinpoint it more precisely, someone would probably have to take a look at your code.



#3 jsm116

jsm116

    Script kludger

  • Members
  • Location:The 301

Posted 30 September 2018 - 01:42 AM

This one goes in the d'oh files: I was drawing the bitmap elements to layer 7 but the bitmap itself was being drawn on layer 6. When I pointed Screen->DrawBitmap() to layer 7 the warning went away.



#4 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 01 October 2018 - 03:30 AM

This one goes in the d'oh files: I was drawing the bitmap elements to layer 7 but the bitmap itself was being drawn on layer 6. When I pointed Screen->DrawBitmap() to layer 7 the warning went away.

 

Bitmaps don't have physical layers. In fact, there are no real layers in ZC. The layer system is just a way of sorting internal drawing orders, so, what might be happening, is that when you set up the bitmap and draw to it on layer 7, the actual draw isn't enqueued until after your layer 6 draws. 

 

You can just draw to layer 0 on your bitmaps, and then blit the bitmap to any layer of the screen. It doesn't matter that your bitmap draws at done on layer 0 in this case. What does matter, is how ZC enqueues all of your layer draws. Until you have drawn something to a bitmap, or set it up by calling SetRendertarget(), it doesn't exist as a valid pointer.

 

You can do this, to initialise all of your system bitmaps:
 

void InitBitmaps()
{
     for ( int q = RT_BITMAP1; q <= RT_BITMAP6; ++q )
    {
        Screen->SetRenderTarget(q);
        Screen->PutPixel(0,0,0,0,0,0,0,128);
   }
   Screen->SetRanderTarget(RT_SCREEN);
}

Call that in your init script, and our onContinue script, and you should never encounter this issue again; however, be aware that script draws happen in layer order.


I typically draw only to layer 0 on bitmaps anyway, and I manually set up by draw ordering. 



#5 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

  • Members
  • Real Name:Pillsbury
  • Location:Magical Land of Dough

Posted 01 October 2018 - 03:59 AM

It's been a while but you should only get this if you did something wrong, hence the error message that doesn't know what else to do.

Likely cause:
A)Draw to bitmap 0 as layer 5.
B)Draw bitmap 0 to layer 2.
C)Oops.

See what happened?
They follow the same layering rules as all other drawing commands. This could of been easily fixed when it was implemented, but then the whole concept of SetRenderTarget() to work with any other script drawing code would of not worked.


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users