The future of GCOL

Discussions about the BBC BASIC language, with particular reference to BB4W and BBCSDL
RichardRussell
Posts: 533
Joined: Tue 15 Oct 2019, 09:10

The future of GCOL

Post by RichardRussell »

The GCOL statement has two forms, one that takes a single parameter and sets the graphics foreground or background colour (analogous with the single-parameter form of COLOUR for text) and a two-parameter form which sets the colour and a 'logical' plotting mode (OR, AND, XOR or invert). GCOL 0,n is equivalent to GCOL n.

Although the two-parameter form is relatively less common, it is a very important feature of BBC BASIC without which many graphics effects would be impossible. For example XOR plotting is invaluable for its property that plotting the same thing twice restores what was originally there, so is ideal for drawing a graphics 'cursor'.

It is therefore very fortunate that the graphics 'backends' used by both BBC BASIC for Windows (WinGDI) and BBC BASIC for SDL 2.0 (OpenGL) support these logical plotting modes, by means of the SetROP2 and glLogicOp functions respectively. Although SDL 2.0 does not expose this functionality, it does allow you to make direct OpenGL calls so you can access it that way.

However such 'logical plotting' support is considered a legacy feature and more 'modern' graphics backends typically don't provide it, for example GDI+ in Windows, OpenGLES (2.0 and later), Metal (as used by Apple) and Vulkan. Apple have already deprecated OpenGL in MacOS (although for the time being it still works) and a time will come when it is not available.

Indeed this has already happened in the case of the new in-browser edition of BBC BASIC for SDL 2.0 which uses WebGL as its graphics backend, and since WebGL is based on OpenGLES it does not support logical plotting. So what to do? Not supporting the GCOL modes in BBC BASIC would be a major limitation, but emulating them isn't practical in an accelerated graphics environment (even if possible it would be hopelessly slow).

So I've decided on a radical 'solution': in the in-browser edition I've mapped the GCOL modes to the nearest operations that are supported by the graphics backend. Specifically GCOL 1 is add rather than OR, GCOL 2 is multiply rather than AND, and GCOL 3 is the closest 'linear' operation to XOR available: a*(1-b) + (1-a)*b. Although these have significantly different effects they are equivalent to the logical operations in the special case that the RGB components of the source and destination colours are all 0.0 (&00) or 1.0 (&FF).

So looking to the future it is likely that GCOL will increasingly work this way. I am hopeful that it won't prove too difficult to adapt programs to work with the revised functionality. Indeed I have been pleasantly surprised by how many programs work acceptably well without any modification, as you can see for yourself in the case of polydots.bbc, snowscene.bbc, persian.bbc and optics.bbc.
If you have a comment about the style or tone of this message please report it to the moderators by clicking the exclamation mark icon, rather than complaining on the public forum.

Ivan
Posts: 76
Joined: Tue 07 May 2019, 16:47

Re: The future of GCOL

Post by Ivan »

I use GCOL 3,colour(x) a lot for my simple drawing programs.

It's the easyest way for me to restore what ever was on the screen before.

I also like the "legacy features" where I made my own simple 3D drawings by using cos, sin and tan.

The "legacy features" also did, that I was able to understand the basics of trigonometry and don't have use advanced graphics libraries.

A year ago I had never come across the unit circle.
BBC Model B - 1984-1989. 6502 assembler, Unicomal 1988-1994, Some C and C++, Pascal 1990-1994. Bought a copy of BBC-BASIC 2007, but started to program at a daily basis 2019. Project: Calculation by efficient use of fabric.

RichardRussell
Posts: 533
Joined: Tue 15 Oct 2019, 09:10

Re: The future of GCOL

Post by RichardRussell »

Ivan wrote:
Wed 09 Sep 2020, 10:04
I use GCOL 3,colour(x) a lot for my simple drawing programs.
If you get an opportunity, try your programs in the new in-browser edition of BBCSDL to see if the revised specification of GCOL 3,n that I have been forced to adopt (since WebGL doesn't support logical plotting modes) is compatible with your usage. You will need to use (up-to-date) Microsoft Edge or Google Chrome.
If you have a comment about the style or tone of this message please report it to the moderators by clicking the exclamation mark icon, rather than complaining on the public forum.

Ivan
Posts: 76
Joined: Tue 07 May 2019, 16:47

Re: The future of GCOL

Post by Ivan »

I don't know anything about Emscripten.To boil the situation down: Legacy graphics will be changed to advanced graphics and Emscripten is a way to overcome that or have I misunderstood?

I don't use Chrome or Egde but Firefox Release 80.0.1 September 1, 2020 - will Firefox do?
BBC Model B - 1984-1989. 6502 assembler, Unicomal 1988-1994, Some C and C++, Pascal 1990-1994. Bought a copy of BBC-BASIC 2007, but started to program at a daily basis 2019. Project: Calculation by efficient use of fabric.

RichardRussell
Posts: 533
Joined: Tue 15 Oct 2019, 09:10

Re: The future of GCOL

Post by RichardRussell »

Ivan wrote:
Wed 09 Sep 2020, 13:24
Legacy graphics will be changed to advanced graphics and Emscripten is a way to overcome that or have I misunderstood?
I don't think Emscripten comes into this at all, it's not something that a BBC BASIC programmer needs to know about.

I listed the main 'modern' graphics backends that don't support the 'logical' plotting modes (OR, AND, XOR, NOT): OpenGLES (2.0 or later, typically used on Android devices), Metal (Apple's proprietary system, used in iOS and MacOS), Vulkan (cross-platform) and WebGL (used in browsers).

The only edition of BBC BASIC for SDL 2.0 which currently uses any of these backends is the new in-browser edition, which uses WebGL, so it's handy for testing compatibility with the 'revised' specification of the GCOL modes (e.g. GCOL 1 meaning add and GCOL 2 meaning multiply).
I don't use Chrome or Egde but Firefox Release 80.0.1 September 1, 2020 - will Firefox do?
No. I am led to believe that it is possible to enable the necessary capability in Firefox by serving some specific headers, but I don't know how to achieve that. Anyway, Firefox is now an unpopular browser and I'd suggest switching to Chrome.
If you have a comment about the style or tone of this message please report it to the moderators by clicking the exclamation mark icon, rather than complaining on the public forum.

Ivan
Posts: 76
Joined: Tue 07 May 2019, 16:47

Re: The future of GCOL

Post by Ivan »

The "Don't be evel" hypocrisy company - no thanks!
https://en.wikipedia.org/wiki/Don%27t_be_evil

If it is Microsoft or Google - I'll pass.

No problem for me to run good old programs in virtual modes or dedicate an old pc without internet.
BBC Model B - 1984-1989. 6502 assembler, Unicomal 1988-1994, Some C and C++, Pascal 1990-1994. Bought a copy of BBC-BASIC 2007, but started to program at a daily basis 2019. Project: Calculation by efficient use of fabric.

RichardRussell
Posts: 533
Joined: Tue 15 Oct 2019, 09:10

Re: The future of GCOL

Post by RichardRussell »

Ivan wrote:
Thu 10 Sep 2020, 12:28
The "Don't be evel" hypocrisy company - no thanks!
I'm more interested in technical merit and popularity than 'politics'. Google Chrome has 66% of the browser market, Android has 74% of the mobile OS market and Google.com has 75% of the search engine market. Microsoft Edge (the second most popular browser) is built around the Chrome engine.

If you want to criticise a company for its ethics I think you should rather direct your attention to Apple!
If you have a comment about the style or tone of this message please report it to the moderators by clicking the exclamation mark icon, rather than complaining on the public forum.

Ivan
Posts: 76
Joined: Tue 07 May 2019, 16:47

Re: The future of GCOL

Post by Ivan »

I understand your point of view regarding the technic, but I would rather support small companies that don't are full of them selves.

I totally agree about Apple - they are proberly the worst of all.

Take a look of these small companies that Apple try to "kill". They repair Apple products that Appel say can't be repaired or repair Apple products for very small cost. Apple runs a website that only allows threads that Apple likes. If anyone write that data can be recovered that thread will be deleted and Apple say that they violate Apple rules. Especially when someone need help about to start there Iphone - Apple says: If you can't start your phone - data is lost, but that is not true in 95% of the cases.

https://www.rossmanngroup.com/
https://www.ipadrehab.com/
https://www.ifixit.com/
https://repair.org/
BBC Model B - 1984-1989. 6502 assembler, Unicomal 1988-1994, Some C and C++, Pascal 1990-1994. Bought a copy of BBC-BASIC 2007, but started to program at a daily basis 2019. Project: Calculation by efficient use of fabric.

RichardRussell
Posts: 533
Joined: Tue 15 Oct 2019, 09:10

Re: The future of GCOL

Post by RichardRussell »

Ivan wrote:
Thu 10 Sep 2020, 19:06
I understand your point of view regarding the technic, but I would rather support small companies that don't are full of them selves.
As you will have seen from the other thread, the in-browser edition of BBCSDL now runs in Firefox (version 80), it was not easy!
If you have a comment about the style or tone of this message please report it to the moderators by clicking the exclamation mark icon, rather than complaining on the public forum.

Ivan
Posts: 76
Joined: Tue 07 May 2019, 16:47

Re: The future of GCOL

Post by Ivan »

Thanks for your effort, but I'll think I'll stick with the present system.
BBC Model B - 1984-1989. 6502 assembler, Unicomal 1988-1994, Some C and C++, Pascal 1990-1994. Bought a copy of BBC-BASIC 2007, but started to program at a daily basis 2019. Project: Calculation by efficient use of fabric.