hello,
in my demo lib project, i am using a function within the main scene to apply an effector to the entire screen (specifically, the EFF_VBLUR and EFF_HBLUR effects). it works when opengl is disabled, but it doesn't when opengl is enabled
i'd really like to use opengl because it speeds up the rendering on my system, so i would like to know if and how an effector can be applied in opengl
i have a feeling the set_gl_callback function is what i'm looking for, but i don't know how to use it yet
pretty please? thank you!
apply effector when using demo lib opengl?
- AutumnCheney
- Posts: 507
- Joined: Sun Dec 29, 2019 8:16 am
- Location: tahlequah, ok, usa
- Contact:
- NightRadio
- Site Admin
- Posts: 3955
- Joined: Fri Jan 23, 2004 12:28 am
- Location: Ekaterinburg. Russia
- Contact:
Re: apply effector when using demo lib opengl?
Unfortunately the effector() can't work with OpenGL screen directly, but the following trick can be used:
But the effector() remains on the CPU side anyway, so it will work as slowly as in non-OpenGL mode.
Code: Select all
$prev_screen = get_screen()
if temp_img <= 0 { temp_img = new( WINDOW_XSIZE, WINDOW_YSIZE, PIXEL ) } else { resize( temp_img, WINDOW_XSIZE, WINDOW_YSIZE ) }
copy( temp_img, $prev_screen ) //Copy pixels from the OpenGL screen to the temp_img
set_screen( temp_img ) //Switch to the temp_img (soft render)
effector( EFF_HBLUR, 64, WHITE, -WINDOW_XSIZE/4, -WINDOW_YSIZE/4, WINDOW_XSIZE/2, WINDOW_YSIZE/2 ) //Apply the effector
set_screen( $prev_screen ) //Switch back to the OpenGL screen
update_gl_data( temp_img ) //Update temp_img - copy modified pixels to GPU memory
pixi( temp_img ) //Show temp_img
- AutumnCheney
- Posts: 507
- Joined: Sun Dec 29, 2019 8:16 am
- Location: tahlequah, ok, usa
- Contact:
Re: apply effector when using demo lib opengl?
thank you! i modified this to use the demo_xsize and demo_ysize variables (it misbehaves if i use the window variables)NightRadio wrote: ↑Tue Jan 10, 2023 4:26 pm Unfortunately the effector() can't work with OpenGL screen directly, but the following trick can be used:
But the effector() remains on the CPU side anyway, so it will work as slowly as in non-OpenGL mode.Code: Select all
$prev_screen = get_screen() if temp_img <= 0 { temp_img = new( WINDOW_XSIZE, WINDOW_YSIZE, PIXEL ) } else { resize( temp_img, WINDOW_XSIZE, WINDOW_YSIZE ) } copy( temp_img, $prev_screen ) //Copy pixels from the OpenGL screen to the temp_img set_screen( temp_img ) //Switch to the temp_img (soft render) effector( EFF_HBLUR, 64, WHITE, -WINDOW_XSIZE/4, -WINDOW_YSIZE/4, WINDOW_XSIZE/2, WINDOW_YSIZE/2 ) //Apply the effector set_screen( $prev_screen ) //Switch back to the OpenGL screen update_gl_data( temp_img ) //Update temp_img - copy modified pixels to GPU memory pixi( temp_img ) //Show temp_img
and i don't mind the effector not being any faster, it's controlled by the demo time and goes away after a certain amount of time