Open two windows in blitz3D

Blitz3D Forums/Blitz3D Programming/Open two windows in blitz3D

dogzer(Posted 2009) [#1]
This may sound CRAZY but, is there any way to make blitz3d open two windows at the same time? Giving you the posibility to render in either of those windows? I'd make things much more awesome, wouldn't it?


Beaker(Posted 2009) [#2]
Not sure why you would want to, but I can think of a couple of ways that might work. One is to open two blitz apps and let them talk to each other using the localhost network. Another way is to convert blitz3dsdk so that you can run it from Blitz3d (might not work).


dogzer(Posted 2009) [#3]
Well, i thought it'd be nice to, say you're making a terrain editor, you could have two windows, the terrain viewer, and a smaller window with all the parameters. Just thought it'd be cool =/


Warner(Posted 2009) [#4]
I don't think it would be easy to open 2 direct3d windows, since direct3d wasn't designed to do that. But you should be able to open another window with scrollbars/buttons/textedit etc. Maybe look at WinBlitz3D.


Charrua(Posted 2009) [#5]
one of my first questions was if blitz support multiple monitors and the answer i received from blitz support was no. But i used two or more windows the way Beaker say, actually i was using a serial port not the lan, but the idea is the same.

Juan


Warner(Posted 2009) [#6]
I think that blitz support ment dx7 does not support dual-fullscreen applications. Two windowed applications should work, although I can imagine it would not run really fast.


Charrua(Posted 2009) [#7]
i used 3 windows the first comunicates wiht the second via serial port @19200 and the second wiht the third via udp. The firs simulates a harwarware i was developping and the other 2 sould run in 2 separate machines but for testing i implement all 3 in the same computer.
not very fast, but one simulates some kind of automated input, the second was in that renders and updategames happens and the last one was for show a gui to control/view and to modify some aspects of the main program on the fly.
Juan


PowerPC603(Posted 2009) [#8]
You could use 2 separate viewports and 2 camera's.
Attach everything that you want to see in the first viewport to a pivot and the rest (the stuff you wanna see in the second viewport) to another pivot.

First hide the second pivot and render the first viewport.
Then show the second pivot and hide the first one and render again, now to the second viewport.

Everything will be in one window, but you'll have 2 separate windows inside the main window.

Isn't this what you want, or something close to it?


Rroff(Posted 2009) [#9]
The method mentioned above of using blitz3dsdk for one instance should work in theory... tho you'd lose some of the functionality in that instance.


dogzer(Posted 2009) [#10]
Is there a way to lower the cpu usage of one of the instances? (from within blitz3d code)


skidracer(Posted 2009) [#11]
I just did some tests with the following
Graphics3D 640,480,0,2
While Not KeyHit(1)
For i=1 To 1000
Color Rnd(255),Rnd(255),Rnd(255)
Rect Rnd(640),Rnd(480),Rnd(640),Rnd(480),True
Next
Delay 5
Flip
Wend

made an exe on the desktop and ran two instances.

Without the Delay, they didn't share too nice, with the delay things looked a bit better. If Blitz3D gave you the ability to access the DC of the back buffer you could simply run the second app with a blank display and use a system Blit to copy unflipped renderworlds from the primary app into second window.


Zethrax(Posted 2009) [#12]
I generally find a Delay( 20 ) will get you down to zero cpu usage showing in the Windows Task Manager when no intensive updates are being processed. As far as I'm aware, 20 milliseconds is the default time-slice for threading.


Warner(Posted 2009) [#13]
Instead of using Delay, you could maybe also use something along the lines of this:
Repeat
   now = MilliSecs()
Until Abs(now - old) > 42
old = now



Rroff(Posted 2009) [#14]
Its generally a good idea - even if your not using tweening - to divide your code up into 2 parts - one lot only ticks over at says 30Hz where all the main processing takes place - the other which is just the rendering is called every frame without a delay.

If needs be you can render into an imagebuffer in the processing part and render that imagebuffer in the rendering part.


Kryzon(Posted 2009) [#15]
Warner, isn't using a Delay() better than locking the CPU at 100% for 42 milliseconds?


Zethrax(Posted 2009) [#16]
Yes. Using a Delay will free up the CPU for the delay period. Using a busy loop will cause Blitz to hog the CPU for the period the loop is active.

It's best to test your suggestions first, Warner, to ensure that they have merit.


Warner(Posted 2009) [#17]
Well, since delay was mentioned allready, I thought it could be sort of an 'extra' suggestion. But okay, maybe the following might work better. I did not test it at all.
Repeat
   now = MilliSecs()
   Delay 1
Until Abs(now - old) > 42
old = now



Rroff(Posted 2009) [#18]
IIRC there can be ~15ms skew on the timer on most windows systems so that method would potentially run into odd timeslices... so you might as well just use delay 30, etc.