LB Booster
General >> General Board >> re: endless graphics draws and LBBooster
http://lbb.conforums.com/index.cgi?board=general&action=display&num=1441788259

re: endless graphics draws and LBBooster
Post by michael on Sep 9th, 2015, 08:44am

I just found this forum. Thanks for the information and the link Richard.
Re: re: endless graphics draws and LBBooster
Post by Richard Russell on Sep 9th, 2015, 10:33am

on Sep 9th, 2015, 08:44am, michael wrote:
Thanks for the information and the link Richard.

LB4's 'segmented' graphics are the cause of much grief. Whilst occasionally useful, far more commonly they result in unwanted side-effects such as windows that are not redrawn when uncovered (or restored from being minimized), or excessive memory usage. These effects are avoidable, but only at the expense of some complication and only if you are aware of there being a problem in the first place!

So it was an early design decision that LBB would use a more conventional double-buffered approach, whereby graphics are initially drawn onto an off-screen memory surface and then 'blitted' to the screen when required. Not only does this solve both problems, but it is an architecture that Windows is specifically designed to support (with API functions such as GetBoundsRect, InvalidateRect and BitBlt).

Despite this significantly different internal architecture, LBB is compatible with the vast majority of LB graphics programs. This is helped by the fact that FLUSH and REDRAW are implemented in LBB, albeit that they do something rather different from what they do in LB (see the LBB Help docs).

For those few graphics programs which are incompatible there are usually straightforward workarounds to allow them to run in LBB.

Richard.
Re: re: endless graphics draws and LBBooster
Post by michael on Sep 9th, 2015, 2:47pm

Liberty Basic did have options like the gx libraries and OpenGL resources. Of course I wanted to just focus on the base graphics for my experiments.
Finding the options out now makes it so I need to modify my simulated 3D image tools to gxGL so I can step out to the "blitter" as they worded it.

My question though is, are the gx libraries and the OpenGL resource 100% compatible with Liberty basic booster?
Oh, and (since I do see there is a mention of LBB enhancements) does LBB have a way of extracting the color value of a pixel with perhaps a one command request?


Re: re: endless graphics draws and LBBooster
Post by Richard Russell on Sep 9th, 2015, 3:20pm

on Sep 9th, 2015, 2:47pm, michael wrote:
My question though is, are the gx libraries and the OpenGL resource 100% compatible with Liberty basic booster?

I'm afraid I don't know what the 'gx libraries' are so I can't help you there, perhaps somebody else can. As far as OpenGL is concerned that is definitely compatible with LBB, as the author of Cabinet Planner can I think confirm!

Quote:
does LBB have a way of extracting the color value of a pixel with perhaps a one command request?

Nothing additional to what LB provides (i.e. calling the GetPixel API), no. Even if LBB were to provide such a function it would not necessarily be any faster, since it would need to call GetPixel internally and that's a fairly slow API.

Richard.
Re: re: endless graphics draws and LBBooster
Post by michael on Sep 9th, 2015, 3:26pm

One more question.. I was looking at your documentation on LBB and it mentioned it made everything in a stand alone program.
Does this mean the bmp images and the wave files ...ect are inserted into the executable ?!!! :O

Oh and here is a link to the gxGL library code
http://basic.wikispaces.com/gx+Graphics+Library


Re: re: endless graphics draws and LBBooster
Post by RobM on Sep 9th, 2015, 3:48pm

on Sep 9th, 2015, 3:20pm, Richard Russell wrote:
As far as OpenGL is concerned that is definitely compatible with LBB, as the author of Cabinet Planner can I think confirm!

Richard.


Yes it is, and with the added speed of LBB, 3d graphics render much more smoothly.
Re: re: endless graphics draws and LBBooster
Post by Richard Russell on Sep 9th, 2015, 5:20pm

on Sep 9th, 2015, 3:26pm, michael wrote:
Does this mean the bmp images and the wave files ...ect are inserted into the executable ?!!!

Yes, optionally. You can 'embed' such resource files in the EXE such that they are automatically extracted the first time it is run. Of course you can use a 'proper' installer like Inno Setup if you prefer, which will provide more sophisticated options, but when you just need to store some images and wave files etc. the simple LBB capability is useful.

One good use of this feature is to put a program on a website which the end user just has to click on and select 'Run'. Then the browser does all the work behind the scenes, without the user having to worry about manually downloading and installing etc. first.

Richard.
Re: re: endless graphics draws and LBBooster
Post by Richard Russell on Sep 10th, 2015, 08:50am

on Sep 9th, 2015, 3:26pm, michael wrote:
Oh and here is a link to the gxGL library code

I've tried the four demo programs listed at gxGraphicsLibraryHome and they seem to run perfectly in LBB. In fact LBB is well suited to a library such as this because I just needed to add the following line at the end of each of the demo programs:

Code:
'include gxGraphics.bas 

In LB, which has no include capability, I would have needed to copy the library code into each program.

Richard.

User Image
Re: re: endless graphics draws and LBBooster
Post by michael on Sep 10th, 2015, 09:05am

That's amazing!! And to think I tried to make a simulated DLL in LB.. Essentially, what you showed me would allow me to make modules for many things.
I would also suppose you would surprise me further and say that LBB could also be used to somehow make a DLL?


Re: re: endless graphics draws and LBBooster
Post by Richard Russell on Sep 10th, 2015, 9:17pm

on Sep 10th, 2015, 09:05am, michael wrote:
I would also suppose you would surprise me further and say that LBB could also be used to somehow make a DLL?

Actually it can't, or at least I've never worked out a way to do it (I'm not sure whether it's theoretically possible or not).

Richard.
Re: re: endless graphics draws and LBBooster
Post by michael on Sep 11th, 2015, 02:26am

I tried to make include work in LBB but the program doesn't recognize it. I put it at the end of my main program and then executed it.
Because of the missing program module (subroutines that are separated from the program and saved in a separate .bas file)
I looked at the links concerning it in LBB and I cant figure why it doesn't work.



And a little subject for your amusement:
Quote :"Spheres are really hard to make "
grin
http://canevian.conforums.com/index.cgi?board=Development&action=display&num=1441915542
Re: re: endless graphics draws and LBBooster
Post by Richard Russell on Sep 11th, 2015, 05:46am

on Sep 11th, 2015, 02:26am, michael wrote:
I cant figure why it doesn't work.

Most likely reasons:
  1. Not starting in the first column. Unlike a conventional comment, 'include must be at the very beginning of the line.

  2. No CRLF afterwards. If you are putting it at the very end of the program, make sure you have added a newline after the filename.
Richard.

Re: re: endless graphics draws and LBBooster
Post by michael on Sep 11th, 2015, 07:59am

Obviously I am doing something wrong.
lets say this is my main program.. I have include at the start of the program: (the program wont run if the sub is put there.)
Code:
'include mytools.bas
nomainwin
 open "The sphere subroutine !!Created by Michael Gallup (free for the public to use)" for graphics_nsb_fs as #1
 #1 "trapclose [quit]"
 #1 "fill black ; home ; down ; north"
'************H***V***S***R***G***B**Dimmer
call sphere 500,500,220,225,240,250,1
call sphere 50,50,25,225,240,250,9
call sphere 100,100,50,200,200,200,4
call sphere 200,200,100,140,200,200,2
wait
[quit]
close #1
end
 

and here is the program it would add to the above code.
I would have saved it as mytools.bas
do you know how it would be corrected?

Also the code bellow would need to be put at the base of the program.
Code:
sub sphere h,v,size,x,c,a,dimmer ' dimmer cannot be more than 24
#1 "place ";h;" ";v
for y=1 to size
#1 "down"
#1 "color ";x;" ";c;" ";a
#1 "size 2"
#1 "circle ";y
#1 "flush"
x=x-dimmer
c=c-dimmer
a=a-dimmer
if x<2 then x=2
if c<2 then c=2
if a<2 then a=2
next y
end sub
 

Re: re: endless graphics draws and LBBooster
Post by tsh73 on Sep 11th, 2015, 10:50am

'include
doesn't work as a first line.
It is documented in a help file:
Quote:
For maximum compatibility with Liberty BASIC Workshop the 'include directive is ignored when it is at the very beginning of the program. See this Wiki article for more information, and for details of how to integrate LBW with LBB.

Re: re: endless graphics draws and LBBooster
Post by Rod on Sep 11th, 2015, 5:06pm

The use of flush in the middle of the loop is not appropriate. If you ran this in LB with a size of 200 then every time the window was moved minimised or restored there would be 200 drawing actions. Perhaps not with LBB but certainly with LB.

Flush should be use sparingly and at the end of a looped or multiplexed drawing routine.
Re: re: endless graphics draws and LBBooster
Post by Richard Russell on Sep 11th, 2015, 5:24pm

on Sep 11th, 2015, 5:06pm, Rod wrote:
If you ran this in LB with a size of 200 then every time the window was moved minimised or restored there would be 200 drawing actions. Perhaps not with LBB but certainly with LB.

The effect won't be so serious in LBB, but it will certainly slow the program down so it's not a good idea. If you're writing a program to run only in LBB, I would recommend not using FLUSH (although it can still be useful when paired with REDRAW). If you want the code to run in both LB and LBB then use FLUSH but ensure it doesn't result in a memory leak (e.g. using CLS or DELSEGMENT to free the memory).

Richard.
Re: re: endless graphics draws and LBBooster
Post by michael on Sep 11th, 2015, 5:34pm

That's fine. It doesn't take me long to copy/paste my main program onto a template.
I will just make a Program generator to merge the files together quickly into a new program.
Because that's what I do best.

I am using LBB just for the fact that it makes stand alone executables and for the fact it allows continuous draws.
I could use the other resources like gxGL and OpenGL and some other method Richard used in old forum posts for 3D magic, but that's a bit over me since I have only been serious on LB since last January 2015..

Re: re: endless graphics draws and LBBooster
Post by Richard Russell on Sep 11th, 2015, 8:24pm

on Sep 11th, 2015, 5:34pm, michael wrote:
I will just make a Program generator to merge the files together quickly into a new program.

Can I just reiterate that 'include works correctly in LBB, as documented. If it serves your purpose (and it's ideal for the gxGraphics library) then use it.

Richard.