forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

%og fails at runtime when adding grave character

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+
View previous topic :: View next topic  
Author Message
Ryan



Joined: 25 Feb 2016
Posts: 110

PostPosted: Sun Jan 28, 2018 9:08 pm    Post subject: %og fails at runtime when adding grave character Reply with quote

The following code fails at runtime with 'Argument number 4 of WINIO@ (continuation 7) should be a 64 bit integer'. This is using gFortran to call ClearWin+. Is there another way to extract a handle to the rendering context so I can work around it? The code is from an existing application that works under 32 bit ClearWin when compiled with FTN95.

Code:

      i=winio$('%`^og[double,depth16]&',iwinx,iwiny, icont, opengl_proc)


Simplifying it to the following by removing the grave character (and parameter) works, but does not return the handle, as required.

Code:

      i=winio$('%^og[double,depth16]&',iwinx, iwiny, opengl_proc)


I have tried single dimensions scalar arrays for the integers (as suggested in the FTN95.chm help file) and both 32 and 64 bit integers for the icont parameter.

On usage of the grave character, from the help file (it looks as if it should be a 32 bit integer from the definitions):
Quote:
By using the grave modifier (%`og) you supply one extra integer argument (immediately before the callback function, if any) that receives a handle known as a 'rendering context'. This handle is passed to SET_OPENGL_CONTEXT@ in order to switch between the various active OpenGL controls:

SUBROUTINE SET_OPENGL_CONTEXT@(C)
INTEGER C

INTEGER FUNCTION GET_OPENGL_CONTEXT@()


As this is from working code, I don't believe I am doing anything daft but am happy to be corrected.

Thanks

Ryan
Back to top
View user's profile Send private message
DanRRight



Joined: 10 Mar 2008
Posts: 2813
Location: South Pole, Antarctica

PostPosted: Sun Jan 28, 2018 9:44 pm    Post subject: Reply with quote

Curious where do you use this handle? Is it possible to switch %og plotting surfaces same was like with %gr when several of them are open?

I use the handle for the window (not for the %og plotting content) where OpenGL %og is defined like here

Code:
        i=winio@('%hw',  ihw_ctrlGLwindow01)


declaring ihw_ctrlGLwindow01 as

Code:
integer (7) ihw_ctrlGLwindow01


to work both with /32 and /64
Back to top
View user's profile Send private message
Ryan



Joined: 25 Feb 2016
Posts: 110

PostPosted: Sun Jan 28, 2018 9:50 pm    Post subject: Reply with quote

That handle is used in the print function in a call to SET_OPENGL_CONTEXT .

Like your code, the main window hwnd is grabbed via %hw too.

I'll have to look at %gr, I'm learning as I go as this is not my original code. Although I did read in the sample code in ftn95.chm when searching for %og that it can be used to switch between multiple contexts.
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Mon Jan 29, 2018 9:04 am    Post subject: Reply with quote

I am not familiar with OpenGL but at first sight it looks like you need a 64 bit value.

opengl_proc is a HGLRC HANDLE that you supply, so the question is "how is it determined in the 32 bit version of the code"?

I note from the Internet that opengl_proc might possibly be provided by a call to wglCreateContext (for a given HDC).

When you have found where opengl_proc is assigned, you can change its type to INTEGER*8. Or maybe it is not assigned and was never used.
Back to top
View user's profile Send private message AIM Address
Ryan



Joined: 25 Feb 2016
Posts: 110

PostPosted: Mon Jan 29, 2018 11:37 am    Post subject: Reply with quote

As noted above, I have tried passing a 64 bit value. This is for the icont parameter, not opengl_proc parameter which seems to be working.

From ftn95.chm '%^og indicating that a call-back function, opengl_proc, has been provided to handle messages.'. This is just a ClearWin+ callback that returns a 32 bit integer. It's purpose is to handle window events (resize, mouse move etc.).

The callback does not seem to be the issue, it seems that the grave parameter errors for both 32 and 64 bit versions of icont.

I may be able to work around this by calling Clearwin_info('OPENGL_DEVICE_CONTEXT')
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Mon Jan 29, 2018 2:53 pm    Post subject: Reply with quote

Yes. I should have written "icont" in place of "opengl_proc". Otherwise I think that my post is still correct. "icont" is a Windows HANDLE and needs to be a 64 bit integer when in 64 bit mode.
Back to top
View user's profile Send private message AIM Address
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2388
Location: Yateley, Hants, UK

PostPosted: Tue Jan 30, 2018 6:18 pm    Post subject: Reply with quote

Seeing and reading this thread reminded me that I often see beautiful OpenGL graphics, but every time I have a go at reading the documentation I find it excessively complicated, and realise that I should have paid more attention to the Klingon lessons at school. I compare the complexities of OpenGL with the simplicity or the Windows graphics primitives in Clearwin+, reflect that mainly I want things drawn in 2D, and console myself with the thought that I really don't need OpenGL or 3D - and anyway, maybe it isn't even supported on some of my computers' graphics systems.

However, my Windows 10 has recently updated itself, and now I find that I have a 3D version of Paint, and can use 3D objects in Powerpoint - presumably to allow MS applications to deal with 3D printers, eventually. It must be the case therefore that Windows has 3D graphics. As Clearwin+ is 'simply a wrapper for Microsoft etc.' (quote from Paul), then presumably those things are, will be or should be wrappable in Clearwin+. ...

I only ask as an interested bystander! But wouldn't it be nice to get OpenGL style very simply?

To save Paul the effort, I predict the reply begins: "There are no plans at present ..."
Back to top
View user's profile Send private message
DanRRight



Joined: 10 Mar 2008
Posts: 2813
Location: South Pole, Antarctica

PostPosted: Sat Feb 10, 2018 5:32 am    Post subject: Re: Reply with quote

LitusSaxonicum wrote:
I only ask as an interested bystander! But wouldn't it be nice to get OpenGL style very simply?

To save Paul the effort, I predict the reply begins: "There are no plans at present ..."


Silverfrost had good start offering OpenGL 20 years ago. And since then did not add too much to it. Using just these few examples which were provided i made pretty useful graphical utility for myself to plot different 3D things which now looks like this. As usual, no talmuds of documentation or graphics professors' lessons were used. I can send you an example of it made a decade ago if you want, my style there was FTN77-ish but who cares, the example is small and it is easy to change

Back to top
View user's profile Send private message
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2388
Location: Yateley, Hants, UK

PostPosted: Sat Feb 10, 2018 11:13 am    Post subject: Reply with quote

Ryan,

If you understood OpenGL, you will certainly understand %gr, as the difference in complexity is like reading War and Peace (in the original Russian) compared to a nursery rhyme.

Eddie
Back to top
View user's profile Send private message
DanRRight



Joined: 10 Mar 2008
Posts: 2813
Location: South Pole, Antarctica

PostPosted: Sat Feb 10, 2018 8:54 pm    Post subject: Reply with quote

Eddie,
If i had time i'd write few examples showing that the difference between Clearwin+ graphics and OpenGL is like adding to the calls one more variable for 3d dimension instead of just 2 for Clearwin. The only what really is missing is header interface. But i do not have time and do not know OpenGL to the extend to offer users best practice of using it. I's still do that but missing how to place arbitrary size/color/font text at arbitrary xyz position substantially reduces my brute force approach to programming and many other things ("try everything yourself based on your existing background knowledge and common sense and only read the theory if you fail").

As you know, in %gr you need
1) to open %gr with appropriate graphics parameters (now many things are united, including the full RGB 8bit/color being a default) and just call either
2) draw_line_between@(x0,i0,x1,y1,color) or
3) call draw_characters@().
4) To know current plotted parameters there are Clearwin_info@ on keyboard and mouse and screen as well as many other utilities complementing ones from FTN77 like They are also used to manipulate the plot

Almost the same with OpenGL
1) you open analog of %gr called %og with almost the same syntax
2) Accept established common design consisting of couple few lines long functions you will always call in specific order to initialize plot and manipulate it
3) call analogs of draw_line_between@(x0,i0,x1,y1,color)
4) call analogs of draw_characters@().
5) use the same Clearwin_Info@ to know parameters and to manipulate the plot

That's all about Leo Tolsoy which is also a nursery rhime and the W&P historically actually a total BS (LT was genius, no doubt about that, the #1 in Russia, just take the fact that only recently, 200 years later, we started to find how much actual history was distorted by LT. I'm both laughing and seriously). This lesson took 5 minutes because actually all in programming is simple, it is just intentionally or by stupidity made complex. Of course computing programming, bug hunt etc are time consuming and nerve stretching but that's a different from being complex.

/** Some professors would spend the whole semester effing your brain cells and time with the heap of data in the order good only for their own brain because very often "Those Who Can't, Teach” (c). I have never seen a single good professor in my life by visiting and worked in the top science labs and universities of the world. May be Vitaly Ginzburg and couple more were OK but also mainly because they also had good written books. Others were just waste of time, i never got anything from them, all was taken from the books, or better say, from the exercises at the end of theory sections. The way all of them teach i think is totally wrong and the only way to fix that is to substitute all professors with the hypertexted computer programs expandable by the students themselves and education psychologists after they complete the total rebuild of professors' lessons. By the way, to me, the best of all teachers and professors were couple regular simple school teachers with unique methodologies. And the worst of them surprisingly were actually the brightest and the most inventive people on the planet. Worst books of all times were mentioned before Landau's ones, all of them have to be completely rewritten for being read only on the computers. They have typically one exercise per topic.

For compiler developers what follows from this is that making many good examples of usage is very important. Otherwise people will just follow the flow and take those compilers which succeeded to monopolize the market


Last edited by DanRRight on Sun Feb 11, 2018 12:06 pm; edited 1 time in total
Back to top
View user's profile Send private message
John-Silver



Joined: 30 Jul 2013
Posts: 1520
Location: Aerospace Valley

PostPosted: Sun Feb 11, 2018 10:03 am    Post subject: Reply with quote

Dan wrote:

Quote:
... and the only way to fix that is to substitute all professors with the hypertexted computer programs expandable by the students themselves and education psychologists after they complete the total rebuild of professors lessons


Ahh, you mean like Wikipedia ! Wink LOL

Agree fully with you about the need for examples.
That 'ol devil called %pl is a good example.

There's a wealth of examples scattered around in the ftn95 documentation but a picture paints a thousand words as the saying goes. And there aren't many !
Just getting to grips with the jargon used in programming in general can push even the most tenacious engineer/scientist's patience to the lėmit sometimes.
I sometimes think programming shouldn't be so difficult sometimes.
Maybe difficult is not the right word, it's probably 'challenging' a better description.
The problem, and this has been going on for some considerable time now, is that we are not typists/secretaries and certainly not pecialised in the writing of technical documents. That is a specialist field in it's own right, and one that has been getting smaller precisely because we are expected to do everything these days - programming (or using that devil called excel), calculations, data processing, ... and then writing kgs of documents (every time starting from scratch again ! Where is the time for that most wonderful trait of the human ..... thinking ?
Sadly heading towards extinction.
All very inefficient and counter-productive imo.

As for professors, all very theoretical all that stuff - useless in the general run of things. The 'education' system should be revised immdiately, putting practical expertise(EXPERIENCE) as a priority above all else, backed up with some theoretical background.

Our world is becoming one of blind numbers generation wothout either the capacity or will to process all the data as it should be processed.
We have so much computing power at our disposal and yet often companies are fobbed off and conned into buying 'generic' programs adapted for their own uses (SAP derivatives and the like for example).

Other attempts at creating 'miracle program suites' (the ones that do everything you want them to do and wash the dishes at the same time) in recent years do nothing useful and simply cost a lot of bucks and probably confuse more than solve headaches.
In the grand scheme of hyper-adancement of computing power from the hardware size, companies whose existence depend on software have for a long time been creating stuff that just isn't needed nor fitted to the use it's supposed to.
All because software 'creators' just don't do the most important thing first - ask the potential customers what they actually want before just doing somthing they think they want and then stuffing it down their throats.
It's a cut-throat world I guess.

But I digress, although it's all relevant to Dan's good point about the need for examples and that those who provide the most udėser-friendly product will inevitably come out on top of the pile, whether their product is the best or not.
That's where the smoke n mirrors, promises and lies merchants step in.
_________________
''Computers (HAL and MARVIN excepted) are incredibly rigid. They question nothing. Especially input data.Human beings are incredibly trusting of computers and don't check input data. Together cocking up even the simplest calculation ... Smile "
Back to top
View user's profile Send private message
DanRRight



Joined: 10 Mar 2008
Posts: 2813
Location: South Pole, Antarctica

PostPosted: Mon Feb 12, 2018 6:51 am    Post subject: Reply with quote

As to Clearwin+, OpenGL and using SDBG, Plato examples (John, thanks for supporting that many examples are needed placed conveniently), i'd add trying to imagine ideal way of doing that, the text for all of them has to be placed below the graphics showing this example. This definitely has to be made by special, possibly non-trivial way, because it is necessary to make somehow the sources to be compilable right here and the result shown also here in one click away. Use will start practicing immediately. Right now i can not even find the Examples folder hidden deep in a million of branches. Then i have to compile them, and this never worked smoothly. After compilation the Example folder will look like a city dump with the names of files telling you little. In 90th this procedure was may be OK on our cray PC boxes and dull graphics and nothing else interesting to do, right now on flashy boxes with Internet, shopping and 4K movies, eBay, Amazons, Twitrters and Youtubes no one will bother to go through all gray source text examples organized older way. And even when one do, he will forget what is what and findong anything will become an exercise...e

Also there have to be other variants made by any contributor. Like in Amazon "Look at this product from different sources"
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+ All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group