Updating render target size bug

Posted By: alibaba

Updating render target size bug - 04/12/20 15:44

Hey guys, I'm trying to update a panel which receives it's image from a view. When I change the resolution with "h" and then update the sizes with "j" it works until I have a resolution of 1270x720. Why does that happen? Am I missing something here? Please try this code with a level of your choice and tell me if you get the same result.

EDIT: Funny thing is, if I press "h" five times to reach the 1280x720 immediately and update only then, it works!

Code

int ab_x[5]={800,1024,1024,1152,1280};
int ab_y[5]={600,768,600,864,720};

PANEL* bgP;
VIEW* bgV;
int num = 0;
void on_h_event()
{
	wait(2);
	num = cycle(num+1, 0 ,5);
	video_set(ab_x[num],ab_y[num],0,2);
}

void on_j_event()
{
	safe_remove(bgV.bmap);
	bgV.bmap = bmap_createblack(screen_size.x,screen_size.y,24);
	bgP.bmap = bgV.bmap;
	
	bgV.size_x = screen_size.x;
	bgV.size_y = screen_size.y;
	bgP.size_x = screen_size.x;
	bgP.size_y = screen_size.y;
}

void main()
{
	wait(1);
	level_load("test2.wmb");
	wait(3);
	bgV = view_create(10);
	bgV.bmap = bmap_createblack(screen_size.x,screen_size.y,24);
	set(bgV,SHOW);
	
	bgP = pan_create("",0);
	bgP.bmap = bgV.bmap;
	set(bgP,SHOW|TRANSLUCENT|LIGHT);
	vec_set(bgP.blue,vector(120,120,120));
	bgP.alpha = 50;
}

Posted By: txesmi

Re: Updating render target size bug - 04/12/20 16:28

Hi,
I don't konw what can be causing the crash, but a tip could solve the issue: If you create the render target at its maximum size at the very beginning, you don't need to delete and recreate it on resolution changes, you only need to set the sizes of the panel and the view. These sizes need to be set at the beginning too, so the view only uses the area determined by its size. Also, set the zbuffer to the maximum.

Salud!
Posted By: Evo

Re: Updating render target size bug - 04/12/20 16:46

Code
video_window(vector(1,1,0),vector(ab_x[num],ab_y[num],0),112,"Window");

Code
//Press key_h to change sizes
int ab_x[5]={800,1024,1024,1152,1280};
int ab_y[5]={600,768,600,864,720};

PANEL* bgP;
VIEW* bgV;

void update_bmap()
{
	safe_remove(bgV.bmap);
	bgV.bmap = bmap_createblack(screen_size.x,screen_size.y,24);
	bgP.bmap = bgV.bmap;
	
	bgV.size_x = screen_size.x;
	bgV.size_y = screen_size.y;
	bgP.size_x = screen_size.x;
	bgP.size_y = screen_size.y;
}

int num = 0;
void on_h_event()
{
	wait(2);
	num = cycle(num+1, 0 ,5);
	video_set(ab_x[num],ab_y[num],0,2);
	video_window(vector(1,1,0),vector(ab_x[num],ab_y[num],0),112,"Window");
	update_bmap();
}

void main()
{
	wait(1);
	level_load("testbed.wmb");
	wait(3);
	bgV = view_create(10);
	bgV.bmap = bmap_createblack(screen_size.x,screen_size.y,24);
	set(bgV,SHOW);
	
	bgP = pan_create("",0);
	bgP.bmap = bgV.bmap;
	set(bgP,SHOW|TRANSLUCENT|LIGHT);
	vec_set(bgP.blue,vector(200,200,255));
	bgP.alpha = 100;
}
Posted By: alibaba

Re: Updating render target size bug - 04/12/20 17:47

Thanks txesmi, it works if I set the size at the beginning and just change the sizes, but I still wonder though, why removing and recreating doesn't work..

@EVO This approach is not viable, because it will just resize the engine window, but won't change the resolution. Thanks for your input though! (Y) Nevermind, I wasn't paying attention... Your approach totally works! Thanks! But still.. why doesn't it work separately? If I call both functions separately, I won't work again...
Posted By: Evo

Re: Updating render target size bug - 04/12/20 17:54

No problem.

* video_set : Changes the resolution.
* video_window : only changes the window size and keeps the same resolution.

* window size shouldn't be smaller than the resolution.
© 2024 lite-C Forums