Author Topic: LongToDouble  (Read 4410 times)

0 Members and 1 Guest are viewing this topic.

Peter

  • Guest
LongToDouble
« on: April 16, 2011, 11:24:26 AM »
Deleted
« Last Edit: May 05, 2015, 12:42:46 PM by Peter »

Charles Pegge

  • Guest
Re: LongToDouble
« Reply #1 on: April 16, 2011, 12:35:51 PM »
Yes Peter, that will work
Code: [Select]
sys a=10,b=20
double d=a/b
print d   '0,5
There was a problem with number literals and type conversion but this has now been fixed.

You can also avoid byvals everywhere by placing the type first eg:

Code: [Select]
Sub ResizeGl(long width, long height) 'byvals
Sub ResizeGl(long*width, long*height) 'byrefs

Charles

Charles Pegge

  • Guest
Re: LongToDouble
« Reply #2 on: April 16, 2011, 01:43:14 PM »

Yes, the problem was specific to literal number expressions containing a division operator being passed to a function expecting a floating point value.

Er sorry I'll decypher that :)

example:
Code: [Select]
function f(single v)
  print v
end function

f 1/2 '<-- this displayed 0 instead of 0.5

Charles

Charles Pegge

  • Guest
Re: LongToDouble
« Reply #3 on: April 16, 2011, 08:58:58 PM »
Hi Peter,

you still need to remove those "&" address operators

Also CreateWindowEx final param should be byref 0

but there is still a problem somewhere...

Have you considered building on one of the Opengl examples like OpenglWin1.o2bas.

It uses standard WinMain and WndProc techniques. It resizes smoothly and works correctly with Wine. You also have the full set of Opengl headers. These things take a long time to get right so give yourself a head start :)

Charles
« Last Edit: April 16, 2011, 09:00:45 PM by Charles Pegge »

Charles Pegge

  • Guest
Re: LongToDouble
« Reply #4 on: April 17, 2011, 03:28:11 AM »

Hi Peter,

If a parameter in your prototype specifies BYREF implicitly or explicitly  then you must not use "&". It will not work. The compiler automatically resolves the reference when it sees the prototype. This is Basic, not C.

Only for functions without a prototype  is '&' needed to pass a parameter address explicitly.

Why not start with Charles GL and turn it into Peter GL. It is much easier to start with working code than building from scratch. You can make alterations to the code in small testable steps with much easier bug detection.

Charles


Charles Pegge

  • Guest
Re: LongToDouble
« Reply #5 on: April 17, 2011, 04:05:54 AM »

But this is how nature does it.

We were once encoded as bacteria and gradually morphed into Humans :)

And MS Windows is more complex than Human DNA. You can just about squeeze the human genome onto 1 CD but not Windows Vista! :)

Charles

Charles Pegge

  • Guest
Re: LongToDouble
« Reply #6 on: April 17, 2011, 06:35:24 AM »
Peter,

Whether an intelligent agent was involved or not, copy and paste is to be found everywhere in nature. We share 60% of our genes with fruit flies, and our sexual reproduction system, which we share with plants,fungi and all other higher organisms is entirely cut and paste :)

What I'm really suggesting is that this is the most efficient way to create new functionality while preserving some degree of compatibility.

Charles
« Last Edit: April 17, 2011, 06:42:37 AM by Charles Pegge »