@arturB, post #30
struct TagItem m_windowTags[] =
{
{WA_CustomScreen, 0},
{WA_Left, 0},
{WA_Top, 0},
{WA_InnerWidth, 0},
{WA_InnerHeight, 0},
{WA_Activate, TRUE},
{WA_GimmeZeroZero, TRUE},
{WA_Borderless, TRUE},
{WA_Backdrop, TRUE},
{WA_NoCareRefresh, TRUE},
{WA_IDCMP, IDCMP_CLOSEWINDOW|IDCMP_RAWKEY|IDCMP_MOUSEBUTTONS},
{WA_Flags, WFLG_SUPER_BITMAP},
{TAG_END, TAG_END},
};
// przed otwarciem okna ustawiałem tagi (g_nWinWidth = screen Width, g_nWinHeight = screen height)
// g_pScreen to adres ekranu
setWindowTag(WA_CustomScreen, (ULONG)g_pScreen);
setWindowTag(WA_InnerWidth, g_nWinWidth);
setWindowTag(WA_InnerHeight, g_nWinHeight);@asman, post #32
@arturB, post #34
@arturB, post #34
@asman, post #38
@arturB, post #39
Dokladnie. Ma chodzic na wszystkim wiec tylko system. Z moich eksperymentow wynika ze RethinkDisplay(); ktory mam w aga/ecs po zmianie ekranow, nie wystepowal u mnie w trg. Po podstawieniu dziala myszka prawidlowo... ale fps drop tez jest. Wynika zatem ze screenToFront robi w rtg cos co m.in RethinkDisplay();
@arturB, post #39
// DEKLARUJEMY - For double buffering.
static struct ScreenBuffer* system__buffer[] = { NULL, NULL };
static struct MsgPort* system__display_port = NULL;
static UBYTE system__safetochange;system__buffer[0] = AllocScreenBuffer(system__screen, 0, SB_SCREEN_BITMAP);
if (system__buffer[0]) system_console__write("[OK]");
else
{
system_console__write("[FAILED]");
system_console__write("\n\t\t### Critical error!");
system_console__write("\n\t\t### Can't allocate screen buffers.");
Delay(200);
return 0;
}
system__buffer[1] = AllocScreenBuffer(system__screen, NULL, 0);
if (system__buffer[1]) system_console__write(" [OK]");
else
{
system_console__write(" [FAILED]");
system_console__write("\n\t\t### Critical error!");
system_console__write("\n\t\t### Can't allocate screen buffers.");
Delay(200);
return 0;
}
// Manual allocating second buffer because its not working (bug ?)...
struct BitMap* tmp_bitmap = AllocBitMap(ENGINE_IO__SCREEN_WIDTH, ENGINE_IO__SCREEN_HEIGHT, 8, BMF_CLEAR | BMF_DISPLAYABLE, system__screen->RastPort.BitMap );
if (tmp_bitmap == NULL)
{
system_console__write(" [FAILED]");
system_console__write("\n\t\t### Critical error!");
system_console__write("\n\t\t### Can't allocate screen buffers.");
Delay(200);
return 0;
}
FreeBitMap(system__buffer[1]->sb_BitMap);
system__buffer[1]->sb_BitMap = tmp_bitmap;
system__safetochange = 1;
system__display_port = CreateMsgPort();
system__buffer[0]->sb_DBufInfo->dbi_DispMessage.mn_ReplyPort = system__display_port;
system__buffer[1]->sb_DBufInfo->dbi_DispMessage.mn_ReplyPort = system__display_port;
// Attach buffer 1 to the screen.
ChangeScreenBuffer(system__screen, system__buffer[1]);// Put screen to front. ScreenToFront(system__screen);
// przed pętlą:
LONG current_buffer = 0;
// pętla
while (ENGINE_io__global.is_loop)
{
[...]
// Mój ENGINE rysuje co ma rysować do lokalizacji pod wskaźnikiem: unsigned char *ENGINE_io__global.output_buffer;
// W przypadku trybu RTG - nie alokuje tu żadnej pamięci - jest po prostu wskaźnik.
// Przed kolejną klatką pobieram do tego wskaźnika - adres bitmapy bufora będącego aktualnie "z tyłu":
APTR handle = LockBitMapTags(system__buffer[current_buffer]->sb_BitMap, LBMI_BASEADDRESS, (ULONG)&ENGINE_io__global.output_buffer, TAG_DONE);
UnLockBitMap(handle);
// ENGINE rysuje swoje do bitmapy systemowej bedącej "z tyłu", niewidocznej teraz..
ENGINE__run();
// Teraz podminiamy bufory:
if (!system__safetochange)
{
while (!GetMsg(system__display_port)) WaitPort(system__display_port);
system__safetochange = TRUE;
}
if (ChangeScreenBuffer(system__screen, system__buffer[current_buffer]))
{
system__safetochange = FALSE;
}
current_buffer ^= 1;
WaitTOF();
[...]
}@arturB, post #30
@mateusz_s, post #44
system__safetodraw = 1; system__safe_port = CreateMsgPort(); system__buffer[0]->sb_DBufInfo->dbi_SafeMessage.mn_ReplyPort = system__safe_port; system__buffer[1]->sb_DBufInfo->dbi_SafeMessage.mn_ReplyPort = system__safe_port;
if (!system__safetodraw)
{
while (!GetMsg(system__safe_port)) WaitPort(system__safe_port);
system__safetodraw = TRUE;
}
/* Tutaj można bezpiecznie rysować */if (ChangeScreenBuffer(system__screen, system__buffer[current_buffer]))
{
system__safetochange = FALSE;
}
current_buffer ^= 1;while (!ChangeScreenBuffer(system__screen, system__buffer[current_buffer]))
{
WaitTOF();
}
system__safetodraw = FALSE;
system__safetochange = FALSE;
current_buffer ^= 1;@Hexmage960, post #46
@arturB, post #22
@Hexmage960, post #47
@arturB, post #49
@BULI, post #53
@arturB, post #55