Fixed fullscreen rendering and mouse scaling

This commit is contained in:
n00b
2024-12-09 11:51:50 -05:00
parent 80c97f0a93
commit 31872c955c
4 changed files with 90 additions and 81 deletions

View File

@@ -1,71 +1,72 @@
N main w 12
N main h 13
N main canvas2 14
N main canvas1 15
N main yellow 16
N main darkyellow 17
N main magenta 18
N main cyan 19
N main red 20
N main grey 21
N main blue 22
N main darkblue 23
N main orange 24
N main black 25
N main green 26
N main white 27
N main sprite_canvas 28
N main tile 29
N main gz_img 30
N main rc_img 31
N main rc 32
N main gz 33
N main gz_x 34
N main gz_y 35
N main rc_x 36
N main rc_y 37
N main x 38
N main y 39
N main lforce 40
N main info_canvas 15
N main canvas1 16
N main yellow 17
N main darkyellow 18
N main magenta 19
N main cyan 20
N main red 21
N main grey 22
N main blue 23
N main darkblue 24
N main orange 25
N main black 26
N main green 27
N main white 28
N main sprite_canvas 29
N main tile 30
N main gz_img 31
N main rc_img 32
N main rc 33
N main gz 34
N main gz_x 35
N main gz_y 36
N main rc_x 37
N main rc_y 38
N main x 39
N main y 40
N main lforce 41
S main fnt$ 3
N main hud_font 41
N main hud_font 42
AS main hud_txt$ 4
N main t_img 42
N main t_img2 43
N main.#FOR:0 i 44
N main mesh1 45
N main actor1 46
N main actor1_texture 47
N main c 48
N main mat 49
N main a_mat 50
N main level 51
N main actor2 52
N main ax 53
N main ay 54
N main az 55
N main init 56
N main i 57
N main vx 58
N main vy 59
N main vz 60
N main mass 61
N main anim 62
N main num_loops 63
N main off_x 64
N main off_y 65
N main test_mode 66
N main.#WHILE:0.#SELECT:0->CASE:0.#IF:7 crx 67
N main.#WHILE:0.#SELECT:0->CASE:0.#IF:7 cry 68
N main.#WHILE:0.#SELECT:0->CASE:0.#IF:7 crz 69
N main.#WHILE:0.#SELECT:0->CASE:0.#ELSE:7->CONDITION:0 crx 70
N main.#WHILE:0.#SELECT:0->CASE:0.#ELSE:7->CONDITION:0 cry 71
N main.#WHILE:0.#SELECT:0->CASE:0.#ELSE:7->CONDITION:0 crz 72
N main.#WHILE:0.#SELECT:0->CASE:0.#IF:9 crx 73
N main.#WHILE:0.#SELECT:0->CASE:0.#IF:9 cry 74
N main.#WHILE:0.#SELECT:0->CASE:0.#IF:9 crz 75
N main.#WHILE:0.#SELECT:0->CASE:0.#ELSE:9->CONDITION:0 crx 76
N main.#WHILE:0.#SELECT:0->CASE:0.#ELSE:9->CONDITION:0 cry 77
N main.#WHILE:0.#SELECT:0->CASE:0.#ELSE:9->CONDITION:0 crz 78
N main.#WHILE:0.#IF:15 cno_x 79
N main.#WHILE:0.#IF:15 cno_y 80
N main t_img 43
N main t_img2 44
N main.#FOR:0 i 45
N main mesh1 46
N main actor1 47
N main actor1_texture 48
N main c 49
N main mat 50
N main a_mat 51
N main level 52
N main actor2 53
N main ax 54
N main ay 55
N main az 56
N main init 57
N main i 58
N main vx 59
N main vy 60
N main vz 61
N main mass 62
N main anim 63
N main num_loops 64
N main off_x 65
N main off_y 66
N main test_mode 67
N main.#WHILE:0.#SELECT:0->CASE:0.#IF:7 crx 68
N main.#WHILE:0.#SELECT:0->CASE:0.#IF:7 cry 69
N main.#WHILE:0.#SELECT:0->CASE:0.#IF:7 crz 70
N main.#WHILE:0.#SELECT:0->CASE:0.#ELSE:7->CONDITION:0 crx 71
N main.#WHILE:0.#SELECT:0->CASE:0.#ELSE:7->CONDITION:0 cry 72
N main.#WHILE:0.#SELECT:0->CASE:0.#ELSE:7->CONDITION:0 crz 73
N main.#WHILE:0.#SELECT:0->CASE:0.#IF:9 crx 74
N main.#WHILE:0.#SELECT:0->CASE:0.#IF:9 cry 75
N main.#WHILE:0.#SELECT:0->CASE:0.#IF:9 crz 76
N main.#WHILE:0.#SELECT:0->CASE:0.#ELSE:9->CONDITION:0 crx 77
N main.#WHILE:0.#SELECT:0->CASE:0.#ELSE:9->CONDITION:0 cry 78
N main.#WHILE:0.#SELECT:0->CASE:0.#ELSE:9->CONDITION:0 crz 79
N main.#WHILE:0.#IF:15 cno_x 80
N main.#WHILE:0.#IF:15 cno_y 81

View File

@@ -1784,14 +1784,14 @@ int rc_mouseX()
{
int x, y;
SDL_GetMouseState(&x, &y);
return x;
return (int)( (double)x * rc_window_mouse_scale_x );
}
int rc_mouseY()
{
int x, y;
SDL_GetMouseState(&x, &y);
return y;
return (int)( (double)y * rc_window_mouse_scale_y );
}
void rc_getMouse(double* x, double* y, double* mb1, double* mb2, double* mb3)
@@ -1803,8 +1803,8 @@ void rc_getMouse(double* x, double* y, double* mb1, double* mb2, double* mb3)
*mb2 = (current_button_state & SDL_BUTTON(SDL_BUTTON_MIDDLE))!=0;
*mb3 = (current_button_state & SDL_BUTTON(SDL_BUTTON_RIGHT))!=0;
*x = ix;
*y = iy;
*x = (double)ix * rc_window_mouse_scale_x;
*y = (double)iy * rc_window_mouse_scale_x;
}
int rc_mouseWheelX()
@@ -1913,21 +1913,21 @@ int rc_windowIsGrabbed()
void rc_warpMouse(int x, int y)
{
SDL_WarpMouseInWindow(rc_window, x, y);
SDL_WarpMouseInWindow(rc_window, (int)( (double)x*rc_window_mouse_scale_x ), (int)( (double)y*rc_window_mouse_scale_y ));
}
void rc_warpMouseGlobal(int x, int y)
{
SDL_WarpMouseGlobal(x, y);
SDL_WarpMouseGlobal((int)( (double)x*rc_window_mouse_scale_x ), (int)( (double)y*rc_window_mouse_scale_y ) );
}
void rc_setMouseZone(int x, int y, int w, int h)
{
SDL_Rect r;
r.x = x;
r.y = y;
r.w = w;
r.h = h;
r.x = (int)( (double)x * rc_window_mouse_scale_x );
r.y = (int)( (double)y * rc_window_mouse_scale_y );
r.w = (int)( (double)w * rc_window_mouse_scale_x );
r.h = (int)( (double)h * rc_window_mouse_scale_y );
SDL_SetWindowMouseRect(rc_window, &r);
}
@@ -3160,7 +3160,7 @@ bool rc_update()
return false;
int win_w = 0, win_h = 0;
int w_scale = 1, h_scale = 1;
double w_scale = 1, h_scale = 1;
if(rc_window)
{
@@ -3168,6 +3168,12 @@ bool rc_update()
//std::cout << "size = " << win_w << ", " << win_h << std::endl;
}
w_scale = ( (double)win_w / (double)rc_window_size.Width );
h_scale = ( (double)win_h / (double)rc_window_size.Height );
rc_window_mouse_scale_x = ( (double)rc_window_size.Width / (double)win_w );
rc_window_mouse_scale_y = ( (double)rc_window_size.Height / (double)win_h );
SEvent irrevent;
SDL_Event SDL_event;
bool Close = false;
@@ -3649,7 +3655,7 @@ bool rc_update()
//debug
irr::core::rect<s32> src( irr::core::vector2d<s32>(0,0), rc_canvas[0].texture->getSize() );
irr::core::rect<s32> dest( irr::core::vector2d<s32>(0,0), irr::core::dimension2d<s32>(win_w, win_h) );
irr::core::rect<s32> dest( irr::core::vector2d<s32>(0,0), irr::core::dimension2d<s32>(win_w*w_scale, win_h*h_scale) );
irr::video::SColor color(0);
VideoDriver->draw2DImage(rc_canvas[0].texture, dest, src);
//draw2DImage2(VideoDriver, rc_canvas[0].texture, src, dest, irr::core::position2d<irr::s32>(0, 0), 0, false, color, screenSize);

View File

@@ -247,6 +247,8 @@ irr::video::IVideoDriver * VideoDriver;
irr::scene::ISceneManager *SceneManager;
SDL_Window* rc_window;
irr::core::dimension2d<u32> rc_window_size;
double rc_window_mouse_scale_x = 1;
double rc_window_mouse_scale_y = 1;
struct rc_scene_properties_obj
{

View File

@@ -32,7 +32,7 @@
<irrtheora.h>
"rc_func130_cases.h"
1733754077 /home/n00b/Projects/RCBASIC4/rcbasic_runtime/rc_os_defines.h
1733761759 /home/n00b/Projects/RCBASIC4/rcbasic_runtime/rc_os_defines.h
<TargetConditionals.h>
1733590876 /home/n00b/Projects/RCBASIC4/rcbasic_runtime/rc_defines.h
@@ -1247,7 +1247,7 @@
1727545973 /home/n00b/Projects/RCBASIC4/rcbasic_runtime/RealisticWater.h
<irrlicht.h>
1733755753 /home/n00b/Projects/RCBASIC4/rcbasic_runtime/rc_gfx.h
1733763017 /home/n00b/Projects/RCBASIC4/rcbasic_runtime/rc_gfx.h
"SDL.h"
<SDL2/SDL.h>
<irrlicht.h>
@@ -1271,7 +1271,7 @@
"rc_joints.h"
<irrtheora.h>
1733754167 /home/n00b/Projects/RCBASIC4/rcbasic_runtime/rc_gfx_core.h
1733762830 /home/n00b/Projects/RCBASIC4/rcbasic_runtime/rc_gfx_core.h
"SDL.h"
"btBulletDynamicsCommon.h"
"BulletSoftBody/btSoftRigidDynamicsWorld.h"