English Amiga Board


Go Back   English Amiga Board > Coders > Coders. System

 
 
Thread Tools
Old 17 December 2021, 14:49   #1
mateusz_s
Registered User
 
Join Date: Jan 2020
Location: Poland
Posts: 181
AllocScreenBuffer() - doesn't want to allocate bitmap.

I am making a triple buffering using ChangeScreenBuffer() function.

It looks like AllocScreenBuffer() doesn't want to allocate bitmap for it when the parameter is 0.

The code below doesnt work as it should. I can fill only first buffor that is linked to screen bitmap, and the other two buffers are blank, and I can't fill them. Like the bitmaps werent allocated, but the pointers are not NULL; So the result is that only one frame is filled with rendered content and two frames are blank. So the screen flickers.

Code:
        // INIT

	// create two message ports
	struct MsgPort* APP_port_disp = CreateMsgPort();
	struct MsgPort* APP_port_safe = CreateMsgPort();
	
	// declare Screen Buffer structure
	struct ScreenBuffer* APP_screen_buffer[3];

	// first buffer - the bitmap won't be allocated - it will use screens bitmap
	APP_screen_buffer[0] = AllocScreenBuffer(APP_screen, NULL, SB_SCREEN_BITMAP);

	// second and third buffer - the bitmaps will be allocated
	APP_screen_buffer[1] = AllocScreenBuffer(APP_screen, NULL, 0);
	APP_screen_buffer[2] = AllocScreenBuffer(APP_screen, NULL, 0);

	// link with message ports
	for (int i = 0; i < 3; i++)
	{
		APP_screen_buffer[i]->sb_DBufInfo->dbi_DispMessage.mn_ReplyPort = APP_port_disp;
       	APP_screen_buffer[i]->sb_DBufInfo->dbi_SafeMessage.mn_ReplyPort = APP_port_safe;
	}
	
	// init buffer switcher
	int APP_current_frame_buffer = 1;
	int APP_next_frame_buffer = 2;


        // LOOP

        while (APP_main_loop)
        {
	....

      ChangeScreenBuffer(APP_screen, APP_screen_buffer[APP_current_frame_buffer]);

      // lock bitmap adress and put it in my engine buffer: EM_prefs.output_buffer_32
      APTR handle = LockBitMapTags(APP_screen_buffer[APP_next_frame_buffer]->sb_BitMap, LBMI_BASEADDRESS (ULONG)&EM_prefs.output_buffer_32, TAG_DONE);
	
        // render frame in engine				         
       EM_Update_And_Render(&APP_main_loop);
       UnLockBitMap(handle);

	// increment APP_current_frame_buffer
	APP_current_frame_buffer++;
	if (APP_current_frame_buffer > 2) APP_current_frame_buffer = 0;

	// increment APP_next_frame_buffer
	APP_next_frame_buffer++;
	if (APP_next_frame_buffer > 2) APP_next_frame_buffer = 0;
}

Then I allocated BitMaps manually and linked them to screen buffers. And everything works..
I just added this in INIT part. Free bitmaps that should be allocated by AllocScrennBuffer, and alloca my own botmaps:

Code:
FreeBitMap(APP_screen_buffer[1]->sb_BitMap);
FreeBitMap(APP_screen_buffer[2]->sb_BitMap);

struct BitMap* bm1 = AllocBitMap(320,200,32,BMF_DISPLAYABLE , &APP_screen->BitMap );
APP_screen_buffer[1]->sb_BitMap = bm1;

struct BitMap* bm2 = AllocBitMap(320,200,32,BMF_DISPLAYABLE , &APP_screen->BitMap );
APP_screen_buffer[2]->sb_BitMap = bm2;


Am I doing something wrong? or this is an API bug?
Thanks!
mateusz_s is offline  
Old 18 December 2021, 18:24   #2
Thomas Richter
Registered User
 
Join Date: Jan 2019
Location: Germany
Posts: 3,215
Maybe the following example from the P96 test corpus helps.
Attached Files
File Type: zip DoubleBuffer.zip (4.8 KB, 67 views)
Thomas Richter is offline  
Old 18 December 2021, 20:33   #3
mateusz_s
Registered User
 
Join Date: Jan 2020
Location: Poland
Posts: 181
Quote:
Originally Posted by Thomas Richter View Post
Maybe the following example from the P96 test corpus helps.
Thank You Thomas, that a really big exmaple, I must analyze it carefully..
mateusz_s is offline  
Old 18 December 2021, 20:47   #4
mateusz_s
Registered User
 
Join Date: Jan 2020
Location: Poland
Posts: 181
Quote:
Originally Posted by Thomas Richter View Post
Maybe the following example from the P96 test corpus helps.
ps. Should I see something on the screen? I just see empty Intuition Screen..

ohh, ok. Q,S,R on keyboard
mateusz_s is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
WHDLOAD: Can't allocate Expmem (SKIDMARKS) Nostromo support.Games 11 09 February 2023 21:52
Allocate/deallocate memory? idrougge Coders. Blitz Basic 7 03 February 2017 10:21
68030 write-allocate mode TheDarkCoder Coders. General 9 20 August 2011 17:25
SWOS 96/97 - cannot allocate ShadowRam gingerbeardman project.WHDLoad 37 11 February 2011 17:49
Could not allocate 'shadow ram'? NovaCoder project.WHDLoad 4 28 August 2008 01:09

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 11:28.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.12858 seconds with 16 queries