Using compositing to blit directly to window bitmap, requires double click to show the images?

15 posts / 0 new
Last post
AmigaBlitter
AmigaBlitter's picture
Offline
Last seen: 6 years 9 months ago
Joined: 2012-02-18 19:55
Using compositing to blit directly to window bitmap, requires double click to show the images?

Hello,
As in the subject, i use compositetag to blit on a window.
The problem is that i can't see the images, until i double click on the window.

I forgot something?

Thank you

thomas
thomas's picture
Offline
Last seen: 3 months 1 week ago
Joined: 2011-05-16 14:23
A normal window does not have

A normal window does not have a bitmap. If your window has one, you'll probably use the WA_SuperBitmap or WFLG_SUPER_BITMAP refreshing method. If you do, you have to call CopySBitMap after each change of the super bitmap.
http://wiki.amigaos.net/index.php/Intuition_Windows#Graphics_and_Layers_Functions_for_SuperBitMap_Windows

AmigaBlitter
AmigaBlitter's picture
Offline
Last seen: 6 years 9 months ago
Joined: 2012-02-18 19:55
this is the code: Object

this is the code:

  1. Object *winobj;
  2.  
  3. if ((winobj = IIntuition->NewObject (WindowClass,NULL,
  4. WA_PubScreen, scr,
  5. WA_IDCMP, IDCMP_VANILLAKEY | IDCMP_INTUITICKS,
  6. WA_Width, scr->Width * 6/ 10,
  7. WA_Height, scr->Height * 6 / 10,
  8. WINDOW_NewMenu,newmenu,
  9. WINDOW_BackFillName, "Sys:Prefs/Presets/Patterns/Chalk/ChalkBlue.brush",
  10. WINDOW_Position, WPOS_TOPLEFT,
  11. WINDOW_ParentGroup, IIntuition->NewObject (LayoutClass,NULL,
  12. LAYOUT_Orientation, LAYOUT_ORIENT_VERT,
  13. LAYOUT_SpaceOuter, TRUE,
  14. TAG_END),
  15. TAG_END)))
  16.  
  17. {
  18.  
  19. return (winobj);

and...

  1. IGraphics->CompositeTags(COMPOSITE_Src_Over_Dest, boing_bm, imageWindow->WLayer->BitMap,
  2. COMPTAG_SrcWidth, boing_width,
  3. COMPTAG_SrcHeight, boing_height,
  4. COMPTAG_OffsetX, boing_x,
  5. COMPTAG_OffsetY, boing_y,
  6. COMPTAG_Flags, COMPFLAG_IgnoreDestAlpha,
  7. TAG_END);
thomas
thomas's picture
Offline
Last seen: 3 months 1 week ago
Joined: 2011-05-16 14:23
You must not blit into this

You must not blit into this bitmap. It does not belong to your window.

AmigaBlitter
AmigaBlitter's picture
Offline
Last seen: 6 years 9 months ago
Joined: 2012-02-18 19:55
Why does not belong to my

Why does not belong to my window?

And why if i double click on the window the image blitted appear?

thomas
thomas's picture
Offline
Last seen: 3 months 1 week ago
Joined: 2011-05-16 14:23
Why does not belong to my

Why does not belong to my window?

All windows on a screen share the same bitmap. There is only one bitmap for all windows. If you blit into this bitmap you overwrite other windows (unless your window is the frontmost).

"Windows" don't exist in this level. Windows are made by Layers. And Layers only exist for RastPorts, not for Bitmaps.

If you need a bitmap as output for a graphics function, you have to allocate your own.

And why if i double click on the window the image blitted appear?

I don't know. Perhaps the window opened by window.class internally is a superbitmap window. I suppose that you have the ClickToFront commodity or similar running and the double click causes WindowToFront() to be called. This copies the super bitmap connected to the window into the screen's bitmap.

AmigaBlitter
AmigaBlitter's picture
Offline
Last seen: 6 years 9 months ago
Joined: 2012-02-18 19:55
I should investigate in

I should investigate in this.

In fact i have four windows opened, but i do blit only in two window, each with a different image.
The image blitted appear if i double click on the respective window. Doesn't seems shared to me, cause for every window where i blit, i use the same offset starting at 0,0, but there are not overwritten window or part of it.

Btw, i just discovered this:

if blit in this way: IGraphics->CompositeTags(COMPOSITE_Src_Over_Dest, boing_bm, imageWindow->RPort->BitMap,

instead of: IGraphics->CompositeTags(COMPOSITE_Src_Over_Dest, boing_bm, imageWindow->WLayer->BitMap,

the situation change to contrary, as follow:

the image is blittet on the window and appear without any double click but, if i double click on the window, the image seems to go "behind" the window's backfill. Correction. The image go to the customScreen that hosts the windows.

thomas
thomas's picture
Offline
Last seen: 3 months 1 week ago
Joined: 2011-05-16 14:23
You are making bad software,

You are making bad software, you know.

You got an example how to do it right in this post: http://www.os4coding.net/forum/load-display-32-bit-alpha-png#comment-1793

This is the only legal way to do it.

If you do it differently, you create a hack which might work by accident but might break in the future or on another machine.

Trial-and-error is not the right way to learn. Read the docs and follow the rules. Please.

Hans
Hans's picture
Offline
Last seen: 3 months 3 weeks ago
Joined: 2010-12-09 22:04
Re: Using compositing to blit directly to window bitmap,...

@thomas

All windows on a screen share the same bitmap. There is only one bitmap for all windows. If you blit into this bitmap you overwrite other windows (unless your window is the frontmost).

That isn't true any more. When compositing is enabled on a screen, each window implicitly has an off-screen bitmap. This is why it's behaving the way that AmigaBlitter describes. His render operation doesn't trigger a screen refresh, but double-clicking does.

Trial-and-error is not the right way to learn. Read the docs and follow the rules. Please.

A lot of the documentation is old and out of date, and there are lots of horrible examples floating aroung. Wading through that isn't easy, so please be a bit more understanding.

I'm probably partially to blame because I told AmigaBlitter to stop using BltBitMapTags() for alpha blits (it's NOT HW accelerated, and CompositeTags() is the right tool for the job).

@AmigaBlitter

Look into using the super-bitmap refresh method.

EDIT: Alternatively, look into using ILayers->DoHookClipRects(); with a hook containing your compositing code. That way you can use CompositeTags() on the rast-port.

Hans

Join the Kea Campus - upgrade your skills; support my work; enjoy the Amiga corner.
https://keasigmadelta.com/ - see more of my work

AmigaBlitter
AmigaBlitter's picture
Offline
Last seen: 6 years 9 months ago
Joined: 2012-02-18 19:55
His render operation doesn't

His render operation doesn't trigger a screen refresh, but double-clicking does.

It's seems that the triggered operation by double clicking on the window is:

IIntuition->WindowToFront(window);

If i do this the image blitted via compositing appears, and it's blazing fast.

I haven't found any example to use ILayers->DoHookClipRects().

Hans
Hans's picture
Offline
Last seen: 3 months 3 weeks ago
Joined: 2010-12-09 22:04
Re: Using compositing to blit directly to window bitmap,...

It's seems that the triggered operation by double clicking on the window is:

IIntuition->WindowToFront(window);

If i do this the image blitted via compositing appears, and it's blazing fast.


This isn't the right way to do things though. It's exploiting a side-effect, and I doubt that it works when compositing is disabled in GUI prefs. Plus, calling WindowToFront() all the time brings your window to the front. If the user is busy with something else, then that will be very annoying.

I haven't found any example to use ILayers->DoHookClipRects().

Currently, I lack the time to create an example myself. Try to figure it out from the autodocs. Here are a few tips:
- Your hook function should set COMPTAG_DestX/DestY/DestWidth/DestHeight for each call based on the rectangle that it is passed by DoHookClipRects. The other tags depend on what render operation you want to do
- Use the window's rastport (the one that salass00 used with BltBitMapTags() in his example code)

Hans

Join the Kea Campus - upgrade your skills; support my work; enjoy the Amiga corner.
https://keasigmadelta.com/ - see more of my work

AmigaBlitter
AmigaBlitter's picture
Offline
Last seen: 6 years 9 months ago
Joined: 2012-02-18 19:55
Thank you This isn't the

Thank you

This isn't the right way to do things though.

Yes, i undestand. As thomas and you pointed out this is not the right way.
Just to satisfy my curiosity, I used the function that I assumed was implicit in the double click, that is, WindowToFront.

salass00
salass00's picture
Offline
Last seen: 6 months 2 weeks ago
Joined: 2011-02-03 11:27
See boing3 example

See boing3 example here:
https://dl.dropboxusercontent.com/u/26599983/boing.lha

AmigaBlitter
AmigaBlitter's picture
Offline
Last seen: 6 years 9 months ago
Joined: 2012-02-18 19:55
many thanks. I will try this

many thanks.

I will try this afternoon

AmigaBlitter
AmigaBlitter's picture
Offline
Last seen: 6 years 9 months ago
Joined: 2012-02-18 19:55
The DoHookClipRects code

The DoHookClipRects code works very well.
Just a little slower.

Log in or register to post comments