|
Post by peter717 on May 13, 2023 15:27:00 GMT -6
Hi there
I'm not sure this is a bug, but to me it seems so. It concerns a 'bug' for the current Windows version of RCBasic (RCBasic 3.20 revision 2). The 'bug' occur in both the 32-bit and 64-bit version of RCBasic. (The Win version I use is Windows 10 64-bit.) But just maybe I'm doing something wrong?
When a generated EXE (which was made though the 'Tools -> Distribute' feature in the editor of RCBasic) is closed, it disappears from the taskbar but seems to be still active when Windows taskmanager is checked! When another instance of that same EXE is started and closed again, a second instance of the same EXE appears in Windows taskmanager and also stays there. If a third time that EXE is opened and then closed, a third process of that same app/EXE stays active in Windows taskmanager and so on. CPU load also increases a bit when a lot of such instances are opened and take resources on the computer. I can close all those EXE's manually in Windows taskmanager and no error message or whatever appears and CPU load lowers again a bit. This 'bug' appears on various example projects that are included in the RCBasic package (like for example just to name one, the vector demo in subdir GFX of the examples). Also both on the 32-bit and 64-bit version. I even then replaced the SDL2 DLL library files with another version to try, but the 'bug' remains so that it is probably(?) caused by RCBasic itself. The various projects I've tried, seems not having anything in their Basic code (on first sight because RCBasic is rather new to me) that keeps them running when closed.
Anyone any idea? Bug or not? What can be done to prevent this behaviour? Maybe adding some extra code in the BAS file that closes the so called process handle of the app? Can RCBasic do such thing as a workaround perhaps? But better would be that the process is removed automatically when closed.
|
|
|
Post by n00b on May 13, 2023 16:01:46 GMT -6
Its not a bug in RCBasic but those programs. A couple years back I added functions to detect if the minimize, maximize, or close events on a window was triggered. This also involved changing default behaviours for windows so the entire program does not end when a window closes. It only triggers a window close event.
In your main loop, try this (if your window is not 0 then just use your window #):
While WindowExists(0)
|
|
|
Post by peter717 on May 14, 2023 17:18:39 GMT -6
Wow, thanks man. That's very clear. Sorry, my mistake then.
A good point I see now to start and build further on when wanting to make a program that must close it process together with its GUI, seems to be the following code that is given in the documentation of RCBasic: my_window_mode = WindowMode(1,0,0,0,0) WindowOpen ( 0, "My App", WINDOWPOS_CENTERED, WINDOWPOS_CENTERED, 640, 480, my_window_mode, 1 )
While WindowExists( 0 ) Update() Wend
That works like a charm when running its generated EXE in Windows. The process closes nicely together with the GUI.
But... unfotunately. When for example tried to modify the project called 'vector demo' (in subdir GFX of the examples), the process stayed active when the GUI was closed or in other cases RCBAsic returned the message that it 'could not load rcbasic program'. That was the case wherever this line was inserted:
While WindowExists( 0 ) Any idea where to slide this line in the following program below? Tried already places thought that were good, such as at the end of the main loop just before the lines with the codes 'update()' and 'wend'. But no success.
'-3d Drawing demo-based on sdlBasic Demo- RC Basic version - Rodney Cunningham aka n00b
LoadFont(0,"KosugiMaru-Regular.ttf",16)
dim xobs dim yobs dim zobs dim xtgt dim ytgt dim ztgt dim qdst dim zoom radiano=57.2957792
wdwd=1 xedge=512 yedge=384
my_window_mode = WindowMode(1,0,0,0,0) WindowOpen(0, "3D Vector", 20, 20, xedge, yedge, my_window_mode, 1) CanvasOpen(0, xedge, yedge, 0, 0, xedge, yedge, 0) Canvas(0) SetColor(rgb(32, 32,128)) ClearCanvas() expctw=640 expctf=xedge/expctw
function absv(n) if n<0 then return n*(-1) end if return n end function
function eucl(x1,y1,z1) x1=abs(x1) y1=abs(y1) z1=abs(z1) return sqrt((x1^2)+(y1^2)+(z1^2)) end function
function pitag(x2,y2) x2=abs(x2) y2=abs(y2) if ((x2^2)+(y2^2))<>0 then return sqrt((x2^2)+(y2^2)) else return 0 end if end function
function angulo(xe,ye) tmprq=0 if xe<=0 and ye<=0 then tmprq=3 end if if xe<=0 and ye>=0 then tmprq=4 end if if xe>=0 and ye>=0 then tmprq=1 end if if xe>=0 and ye<=0 then tmprq=2 end if quadt=tmprq dptg=pitag(xe,ye) dim v if dptg<>0 then v=asin(abs(xe)/dptg) else v=0 end if tmpr=v*57.2957792 tmpr2=tmpr if quadt=2 then tmpr2=180-tmpr end if if quadt=3 then tmpr2=180+tmpr end if if quadt=4 then tmpr2=360-tmpr end if return tmpr2 end function
function xfrom3d(x1,y1,z1) xdn=x1-xobs ydn=y1-yobs zdn=z1-zobs xvn=xtgt-xobs yvn=ytgt-yobs zvn=ztgt-zobs rdnang=angulo(xdn,ydn) rdndist=pitag(xdn,ydn) rvnang=angulo(xvn,yvn) rvndist=pitag(xvn,yvn) rdnang=rdnang-rvnang rvnang=0 xdn=sin(rdnang/radiano)*rdndist ydn=cos(rdnang/radiano)*rdndist xvn=0 yvn=rvndist rdnang=angulo(zdn,ydn) rdndist=pitag(zdn,ydn) rvnang=angulo(zvn,yvn) rvndist=pitag(zvn,yvn) rdnang=rdnang-rvnang rvnang=0 zdn=sin(rdnang/radiano)*rdndist ydn=cos(rdnang/radiano)*rdndist xproj=(xedge/2)+(zoom*((qdst*xdn)/ydn)) yproj=(yedge/2)+(zoom*((qdst*zdn)/ydn)) return xproj end function
function yfrom3d(x1,y1,z1) xdn=x1-xobs ydn=y1-yobs zdn=z1-zobs xvn=xtgt-xobs yvn=ytgt-yobs zvn=ztgt-zobs rdnang=angulo(xdn,ydn) rdndist=pitag(xdn,ydn) rvnang=angulo(xvn,yvn) rvndist=pitag(xvn,yvn) rdnang=rdnang-rvnang rvnang=0 xdn=sin(rdnang/radiano)*rdndist ydn=cos(rdnang/radiano)*rdndist xvn=0 yvn=rvndist rdnang=angulo(zdn,ydn) rdndist=pitag(zdn,ydn) rvnang=angulo(zvn,yvn) rvndist=pitag(zvn,yvn) rdnang=rdnang-rvnang rvnang=0 zdn=sin(rdnang/radiano)*rdndist ydn=cos(rdnang/radiano)*rdndist xproj=(xedge/2)+(zoom*((qdst*xdn)/ydn)) yproj=(yedge/2)+(zoom*((qdst*zdn)/ydn)) return yproj end function
Sub Rect3d_xy(xc1,yc1,xc2,yc2,zc1) x1=xfrom3d(xc1,yc1,zc1) y1=yfrom3d(xc1,yc1,zc1) x2=xfrom3d(xc2,yc1,zc1) y2=yfrom3d(xc2,yc1,zc1) x3=xfrom3d(xc2,yc2,zc1) y3=yfrom3d(xc2,yc2,zc1) x4=xfrom3d(xc1,yc2,zc1) y4=yfrom3d(xc1,yc2,zc1) line (x1,y1,x2,y2) line (x2,y2,x3,y3) line (x3,y3,x4,y4) line (x4,y4,x1,y1) End Sub
Window(0) xmouse = 0 ymouse = 0 t_delay = 10 t_mark = timer()
while true ClearCanvas() zoom=96*expctf mb = 0 xms = 0 yms = 0 getmouse(xms, yms, mb, mb, mb) if (xms<>-1) and (yms<>-1) then xmouse = xms ymouse = yms end if xm1= (xmouse-(xedge/2))* (-1*(1/expctf) ) ym1=(ymouse-(yedge/2))*(1/expctf) xobs=xm1 yobs=150 zobs=ym1 xtgt=0 ytgt=0 ztgt=0 qdst=10 for zz=-20 to 20 step 5 Rect3d_xy(-20,-20,20,20,zz) next update() wend
'end
|
|
|
Post by n00b on May 14, 2023 19:15:29 GMT -6
Try running this:
'-3d Drawing demo-based on sdlBasic Demo- RC Basic version - Rodney Cunningham aka n00b '- 3d Drawing demo - 040803 - sdlBasic version - Paulo Silva '- (3d algorythms based on Michel Rousselet codes for zx-spectrum ) '- bug: xobs position value looks reverted (=*-1) (needs a deep review) '- bugfix from Vroby: div0 error in angulo() function
LoadFont(0,"KosugiMaru-Regular.ttf",16)
dim xobs dim yobs dim zobs dim xtgt dim ytgt dim ztgt dim qdst dim zoom radiano=57.2957792
wdwd=1 xedge=512 yedge=384
WindowOpen(0, "3D Vector", 20, 20, xedge, yedge, WINDOW_VISIBLE, 1) CanvasOpen(0, xedge, yedge, 0, 0, xedge, yedge, 0) Canvas(0) SetColor(rgb(32, 32,128)) ClearCanvas() expctw=640 expctf=xedge/expctw
function absv(n) if n<0 then return n*(-1) end if return n end function
function eucl(x1,y1,z1) x1=abs(x1) y1=abs(y1) z1=abs(z1) return sqrt((x1^2)+(y1^2)+(z1^2)) end function
function pitag(x2,y2) x2=abs(x2) y2=abs(y2) if ((x2^2)+(y2^2))<>0 then return sqrt((x2^2)+(y2^2)) else return 0 end if end function
function angulo(xe,ye) tmprq=0 if xe<=0 and ye<=0 then tmprq=3 end if if xe<=0 and ye>=0 then tmprq=4 end if if xe>=0 and ye>=0 then tmprq=1 end if if xe>=0 and ye<=0 then tmprq=2 end if quadt=tmprq dptg=pitag(xe,ye) dim v if dptg<>0 then v=asin(abs(xe)/dptg) else v=0 end if tmpr=v*57.2957792 tmpr2=tmpr if quadt=2 then tmpr2=180-tmpr end if if quadt=3 then tmpr2=180+tmpr end if if quadt=4 then tmpr2=360-tmpr end if return tmpr2 end function
function xfrom3d(x1,y1,z1) xdn=x1-xobs ydn=y1-yobs zdn=z1-zobs xvn=xtgt-xobs yvn=ytgt-yobs zvn=ztgt-zobs rdnang=angulo(xdn,ydn) rdndist=pitag(xdn,ydn) rvnang=angulo(xvn,yvn) rvndist=pitag(xvn,yvn) rdnang=rdnang-rvnang rvnang=0 xdn=sin(rdnang/radiano)*rdndist ydn=cos(rdnang/radiano)*rdndist xvn=0 yvn=rvndist rdnang=angulo(zdn,ydn) rdndist=pitag(zdn,ydn) rvnang=angulo(zvn,yvn) rvndist=pitag(zvn,yvn) rdnang=rdnang-rvnang rvnang=0 zdn=sin(rdnang/radiano)*rdndist ydn=cos(rdnang/radiano)*rdndist xproj=(xedge/2)+(zoom*((qdst*xdn)/ydn)) yproj=(yedge/2)+(zoom*((qdst*zdn)/ydn)) return xproj end function
function yfrom3d(x1,y1,z1) xdn=x1-xobs ydn=y1-yobs zdn=z1-zobs xvn=xtgt-xobs yvn=ytgt-yobs zvn=ztgt-zobs rdnang=angulo(xdn,ydn) rdndist=pitag(xdn,ydn) rvnang=angulo(xvn,yvn) rvndist=pitag(xvn,yvn) rdnang=rdnang-rvnang rvnang=0 xdn=sin(rdnang/radiano)*rdndist ydn=cos(rdnang/radiano)*rdndist xvn=0 yvn=rvndist rdnang=angulo(zdn,ydn) rdndist=pitag(zdn,ydn) rvnang=angulo(zvn,yvn) rvndist=pitag(zvn,yvn) rdnang=rdnang-rvnang rvnang=0 zdn=sin(rdnang/radiano)*rdndist ydn=cos(rdnang/radiano)*rdndist xproj=(xedge/2)+(zoom*((qdst*xdn)/ydn)) yproj=(yedge/2)+(zoom*((qdst*zdn)/ydn)) return yproj end function
Sub Rect3d_xy(xc1,yc1,xc2,yc2,zc1) x1=xfrom3d(xc1,yc1,zc1) y1=yfrom3d(xc1,yc1,zc1) x2=xfrom3d(xc2,yc1,zc1) y2=yfrom3d(xc2,yc1,zc1) x3=xfrom3d(xc2,yc2,zc1) y3=yfrom3d(xc2,yc2,zc1) x4=xfrom3d(xc1,yc2,zc1) y4=yfrom3d(xc1,yc2,zc1) line (x1,y1,x2,y2) line (x2,y2,x3,y3) line (x3,y3,x4,y4) line (x4,y4,x1,y1) End Sub
Window(0) xmouse = 0 ymouse = 0 t_delay = 10 t_mark = timer()
while WindowExists(0) ClearCanvas() zoom=96*expctf mb = 0 xms = 0 yms = 0 getmouse(xms, yms, mb, mb, mb) if (xms<>-1) and (yms<>-1) then xmouse = xms ymouse = yms end if xm1= (xmouse-(xedge/2))* (-1*(1/expctf) ) ym1=(ymouse-(yedge/2))*(1/expctf) xobs=xm1 yobs=150 zobs=ym1 xtgt=0 ytgt=0 ztgt=0 qdst=10 for zz=-20 to 20 step 5 Rect3d_xy(-20,-20,20,20,zz) next update() wend
print "THE END"
|
|
|
Post by n00b on May 14, 2023 19:17:39 GMT -6
Also, I will update all the examples before next release. Some of them were written by other people on this forum and I have not personally looked at them in a very long time.
|
|
|
Post by peter717 on May 14, 2023 20:12:27 GMT -6
Good work! That worked. The process is now closed together with the GUI. Thanks. Time to find out myself where and why I went wrong...
|
|
|
Post by n00b on May 15, 2023 9:03:46 GMT -6
Awesome, glad it worked out for you.
|
|
|
Post by peter717 on May 15, 2023 18:23:39 GMT -6
Not really a bug or problem, but when in the Windows version of RCBasic an EXE file is generated (with the 'Tools -> Distribute' feature in the editor) in another directory then the directory where the main BAS file and project files are, the file 'main.cbc' is put in the project directory but not in the directory where the distribution files are put such as the EXE and necessery DLL files to run it. It would be nice that the file 'main.cbc' also would be placed wherever also the distribution was created. I know that this 'problem' is already known because there's a small text file in the directory where RCBasic keeps its interpreters for distribution.
The textfile itself says: --- 1. Rename your *.cbc file to main.cbc
2. Place main.cbc along with all your the files and folders for your project in dist_32\assets to distribute 32-bit binary or dist_64\assets to distribute 64-bit binary
DO NOT REMOVE OR RENAME THE "assets" FOLDER DO NOT REMOVE OR RENAME THE "assets\bin" FOLDER
3. You can rename launcher to whatever you want
4. Zip the folder up
5. From here you can distribute it how ever you want ---
Okay. That was probably somthing from the time that there wasn't a distribution feature in the editor and had to be made manually. But for Windows now all works fine when creating a distribution, except for the placement of 'main.cbc'. That still has to be copied manually from the 'original' project directory.
Another nice feature would be a kind of way to bind or embed this CBC file into the generated EXE file (interpreter EXE). In sdlBasic this function is available in its editor. And actually the only thing that it does overthere is to 'glue' the plain Basic code at the end of the interpreter binary and create a new EXE file as program. In one way or another the interpreter overthere 'detects' the Basic code in its EXE file and run it as a standalone program (with of course the necessary DLL files in the same directory or system directory). Woudn't it be nice for RCBasic too? But I think it is a bit more difficult in RCBasic to do? I tried as kind of experiment to glue the contents of the file 'main.cbc' to the end of the interpreter with a hex editor. In sdlBasic that can do the job, very easy and simple, but whith RCBasic it doesn't work. But maybe an idea to think about? (Sorry, this last one should probably in the 'feature request' thread...)
|
|
|
Post by n00b on May 15, 2023 18:38:01 GMT -6
The main.cbc file not being in the generated folder is actually a bug. It sometimes works and sometimes doesn't and I am not exactly sure why. That tool is mostly written in rcbasic itself so it should be fairly easy to fix.
Those notes you found were probably from before the distribute tool was made. Some of those files in the tools folder, I have not touched for several years.
And on your last question, rcbasic.exe looks for the code to run inside a *.cbc file. By default, if you don't pass a different *.cbc file to rcbasic.exe, it will load main.cbc if it exists. I can possibly look into making the cbc files embeddable but it probably won't be in the next couple of releases since 3.21 is a stability/optimization release and 3.22 will likely be the same.
Thanks for your feedback. All bug reports and feedback are much appreciated.
|
|
|
Post by peter717 on May 15, 2023 18:50:49 GMT -6
Most things I tried already in RCBasic work pretty well, at least in Windows. Keep up the good work! RCBasic seems already a good alternative to sdlBasic.
|
|