Added SetFPS() and SetWindowVSync()
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -538,6 +538,9 @@ case FN_SetWindowAlwaysOnTop: //Sub Procedure
|
||||
case FN_SetMouseRelative: //Sub Procedure
|
||||
rc_setMouseRelative( SETMOUSERELATIVE_FLAG );
|
||||
break;
|
||||
case FN_SetWindowVSync: //Sub Procedure
|
||||
rc_setWindowVSync( SETWINDOWVSYNC_FLAG );
|
||||
break;
|
||||
case FN_FlashWindow: //Number Function
|
||||
rc_push_num(rc_flashWindow( FLASHWINDOW_FLAG ));
|
||||
break;
|
||||
@@ -547,6 +550,9 @@ case FN_WindowIsGrabbed: //Number Function
|
||||
case FN_PreUpdate: //Sub Procedure
|
||||
rc_preUpdate( );
|
||||
break;
|
||||
case FN_SetFPS: //Sub Procedure
|
||||
rc_setFPS( SETFPS_FPS_VAL );
|
||||
break;
|
||||
case FN_OpenCanvas: //Number Function
|
||||
rc_push_num(rc_canvasOpen( OPENCANVAS_W, OPENCANVAS_H, OPENCANVAS_VIEWPORT_X, OPENCANVAS_VIEWPORT_Y, OPENCANVAS_VIEWPORT_W, OPENCANVAS_VIEWPORT_H, OPENCANVAS_MODE ));
|
||||
break;
|
||||
|
||||
@@ -314,14 +314,14 @@ bool rc_windowOpenEx(std::string title, int x, int y, int w, int h, uint32_t win
|
||||
irr_creation_params.AntiAlias = AntiAlias;
|
||||
irr_creation_params.OGLES2ShaderPath = ".shaders/";
|
||||
|
||||
rc_window_vsync = vsync;
|
||||
rc_window_setfps = vsync;
|
||||
|
||||
if(vsync)
|
||||
{
|
||||
SDL_DisplayMode dm;
|
||||
SDL_GetDesktopDisplayMode(0, &dm);
|
||||
rc_vsync_refresh_rate = dm.refresh_rate;
|
||||
rc_vsync_timer = SDL_GetTicks();
|
||||
rc_setfps_refresh_rate = dm.refresh_rate;
|
||||
rc_setfps_timer = SDL_GetTicks();
|
||||
}
|
||||
|
||||
device = createDeviceEx(irr_creation_params);
|
||||
@@ -2131,7 +2131,25 @@ void rc_setMouseRelative(bool flag)
|
||||
|
||||
void rc_setWindowVSync(bool flag)
|
||||
{
|
||||
//TODO
|
||||
rc_window_setfps = true;
|
||||
SDL_DisplayMode dm;
|
||||
SDL_GetDesktopDisplayMode(0, &dm);
|
||||
rc_setfps_refresh_rate = dm.refresh_rate;
|
||||
rc_setfps_timer = SDL_GetTicks();
|
||||
}
|
||||
|
||||
void rc_setFPS(int fps)
|
||||
{
|
||||
if(fps < 0)
|
||||
{
|
||||
rc_window_setfps = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
rc_window_setfps = true;
|
||||
rc_setfps_refresh_rate = fps;
|
||||
rc_setfps_timer = SDL_GetTicks();
|
||||
}
|
||||
}
|
||||
|
||||
int rc_openURL(std::string url)
|
||||
|
||||
@@ -255,9 +255,9 @@ bool rc_mouse_zone_active = false;
|
||||
double rc_window_zone_scale_x = 1;
|
||||
double rc_window_zone_scale_y = 1;
|
||||
SDL_Rect rc_mouse_zone;
|
||||
bool rc_window_vsync = false;
|
||||
int rc_vsync_refresh_rate = 0;
|
||||
Uint32 rc_vsync_timer = 0;
|
||||
bool rc_window_setfps = false;
|
||||
int rc_setfps_refresh_rate = 0;
|
||||
Uint32 rc_setfps_timer = 0;
|
||||
|
||||
struct rc_scene_properties_obj
|
||||
{
|
||||
|
||||
@@ -79,11 +79,11 @@ void rc_preUpdate()
|
||||
|
||||
bool rc_update()
|
||||
{
|
||||
if(rc_window_vsync)
|
||||
if(rc_window_setfps)
|
||||
{
|
||||
int frame_delay = 1000/rc_vsync_refresh_rate;
|
||||
while( (SDL_GetTicks()-rc_vsync_timer) < frame_delay ){}
|
||||
rc_vsync_timer = SDL_GetTicks();
|
||||
int frame_delay = 1000/rc_setfps_refresh_rate;
|
||||
while( (SDL_GetTicks()-rc_setfps_timer) < frame_delay ){}
|
||||
rc_setfps_timer = SDL_GetTicks();
|
||||
}
|
||||
|
||||
if(!device->run())
|
||||
|
||||
Reference in New Issue
Block a user