Scolring - Forum

Entraides et échanges autour de la technologie Scol - Informations and exchanges on the Scol technology

Vous pouvez changer la langue de l'interface une fois inscrit - You can change the language once registered

You are not logged in.

#1 3-Nov-2014 20:26:25

hebdemnobad
Member
From: northamerica
Registered: 20-Apr-2011
Posts: 1,541
Website

Does the VM have a callback for changing tablet orientation

colleagues:

does the vm have a callback for changing tablet orientation? atm, if I load the scene in portrait mode, and then tip the screen to landscape mode, the an edmainwindow will rotate 90 degrees, but, for example, if it is full screen, it won't be full screen any longer.  the converse happens if I load a screen in landscape mode and rotate it to portrait mode

Offline

#2 3-Nov-2014 20:32:21

arkeon
Admin. / Scol language & OpenSpace3D developer
From: Nantes
Registered: 30-Mar-2009
Posts: 5,161
Website

Re: Does the VM have a callback for changing tablet orientation

arg the windows desktop turn ?
no this is not managed hmm

Offline

#3 3-Nov-2014 20:36:34

hebdemnobad
Member
From: northamerica
Registered: 20-Apr-2011
Posts: 1,541
Website

Re: Does the VM have a callback for changing tablet orientation

arkeon wrote:

arg the windows desktop turn ?
no this is not managed hmm


yes that would be another way of saying it. I'll tag it as an issue/but on redmine.
on the upside the vm will then have a function that can be ported to all those other little gadgets that users rotate around.... smile

Offline

#4 3-Nov-2014 20:37:46

arkeon
Admin. / Scol language & OpenSpace3D developer
From: Nantes
Registered: 30-Mar-2009
Posts: 5,161
Website

Re: Does the VM have a callback for changing tablet orientation

the window turn but change it's size ?
if this is the case you can regularly check to desktop size and update the windows when values are modified.

Offline

#5 3-Nov-2014 20:39:21

hebdemnobad
Member
From: northamerica
Registered: 20-Apr-2011
Posts: 1,541
Website

Re: Does the VM have a callback for changing tablet orientation

arkeon wrote:

the window turn but change it's size ?
if this is the case you can regularly check to desktop size and update the windows when values are modified.

with a timer?

Offline

#6 3-Nov-2014 21:12:12

arkeon
Admin. / Scol language & OpenSpace3D developer
From: Nantes
Registered: 30-Mar-2009
Posts: 5,161
Website

Re: Does the VM have a callback for changing tablet orientation

or in a paint callback for example

Offline

#7 3-Nov-2014 21:17:49

hebdemnobad
Member
From: northamerica
Registered: 20-Apr-2011
Posts: 1,541
Website

Re: Does the VM have a callback for changing tablet orientation

thx arkeon, are the

_CBcontainerPostRender
and
_CBcontainerPreRender

called automatically  by the vm, as in an so3 scene?

Offline

#8 3-Nov-2014 21:21:43

arkeon
Admin. / Scol language & OpenSpace3D developer
From: Nantes
Registered: 30-Mar-2009
Posts: 5,161
Website

Re: Does the VM have a callback for changing tablet orientation

yes every time the scene is rendered

Offline

#9 3-Nov-2014 21:21:51

iri
Admin. / Scol language & Scol apps developer
From: France
Registered: 22-Feb-2009
Posts: 2,024
Website

Re: Does the VM have a callback for changing tablet orientation

or _CBcontainerPaint

Offline

#10 3-Nov-2014 22:04:12

hebdemnobad
Member
From: northamerica
Registered: 20-Apr-2011
Posts: 1,541
Website

Re: Does the VM have a callback for changing tablet orientation

arkeon wrote:

yes every time the scene is rendered

great. I think (?) I know what to do. thx. maybe this is a way i can get those misbehaving loading screen(s) to work.

Offline

#11 4-Nov-2014 16:27:20

hebdemnobad
Member
From: northamerica
Registered: 20-Apr-2011
Posts: 1,541
Website

Re: Does the VM have a callback for changing tablet orientation

thx for your help guys....I ended up using SO3CbBufferPostRender because there isn't always an objcontanier that exists in my modded player. (octoplayerstruct holds all the additional features of my modded player...or it's supposed to. I'm trying to move all global variables into this struct, I remember from one of Iri's posts that the less global variables, the better. That's still a work in progress.

so I added:

      SO3CbBufferPostRender viewstr.V3D_buffer mkfun3 @buffercallback octoplayerstruct nil;

to my mod of fun initOs3dPlayer

here is the callback. I've tested it on my tablet, except I haven't added a code to handle the opening screens. And whether they will behave well is another issue as well.
I leave that for another day...the opening screens do rotate when the tablet rotates. whether they will listen to new position coordinates is another matter)

octoplayerstruct.OCTOPLAYER_screen_oldsize holds the mainWindow screensize at startup, and is reset if the screen changes shape, which happens when it is rotated.

as I've seen, once os3d is up and running, everything is predictable.

 fun buffercallback(buffer, userparameter,octoplayerstruct)=
 	let _GETdesktopSize -> [dw dh] in
 	let octoplayerstruct.OCTOPLAYER_screen_oldsize -> [ow oh] in
 	(
 		
 		if (dw!=ow) || (dh!=oh) then
 		(
 			setEdWindowSizeEx mainWindow dw dh;
 			set octoplayerstruct.OCTOPLAYER_screen_oldsize = [dw dh];
 			
 			0;
 		) else
 		(
 			nil;
 			0;
 		);
 	
 

Is there a cheaper way to do this? My tablet doesn't appear to need a cheaper way, but I was wondering.

Last edited by hebdemnobad (4-Nov-2014 16:27:41)

Offline

#12 4-Nov-2014 16:30:02

arkeon
Admin. / Scol language & OpenSpace3D developer
From: Nantes
Registered: 30-Mar-2009
Posts: 5,161
Website

Re: Does the VM have a callback for changing tablet orientation

you should not redefine SO3CbBufferPostRender on V3Dbuffer. you should use the callback from V3DView struct, or you will break OS3D projects functionnalities.

Offline

#13 4-Nov-2014 16:31:40

arkeon
Admin. / Scol language & OpenSpace3D developer
From: Nantes
Registered: 30-Mar-2009
Posts: 5,161
Website

Re: Does the VM have a callback for changing tablet orientation

override V3DsetCbPostRender viewstr @cbPlugView3dPostRender; call, add your own callback and then don't forget to call cbPlugView3dPostRender for plugits.

Offline

#14 4-Nov-2014 16:42:15

hebdemnobad
Member
From: northamerica
Registered: 20-Apr-2011
Posts: 1,541
Website

Re: Does the VM have a callback for changing tablet orientation

thx arkeon....do i do this:

      V3DsetCbPostRender viewstr @cbPlugView3dPostRender;
      V3DsetCbPostRender viewstr @my_extra_callback;

or do I create a new function in the v3lib.pkg, like

     fun  V3DsetCbPostRender_octo_tablet_rotate = //code here...will I be able to pass a struct defined in my mod of os3dplayer.pkg to this function? will i be able to pass the mainWindow global variable defined in os3dplayer.pkg to this function? i pass both to the postrender callback I wrote

Last edited by hebdemnobad (4-Nov-2014 16:43:04)

Offline

#15 4-Nov-2014 17:25:57

arkeon
Admin. / Scol language & OpenSpace3D developer
From: Nantes
Registered: 30-Mar-2009
Posts: 5,161
Website

Re: Does the VM have a callback for changing tablet orientation

no

fun my_extra_callback(viewstr)=
  //your code
  cbPlugView3dPostRender viewstr;
0;;

V3DsetCbPostRender viewstr @my_extra_callback;

Offline

#16 4-Nov-2014 17:28:44

hebdemnobad
Member
From: northamerica
Registered: 20-Apr-2011
Posts: 1,541
Website

Re: Does the VM have a callback for changing tablet orientation

aha, ingenious, thx. hopefully this will help me further customize my project without throwing a monkey wrench into the os3d architecture.

Offline

#17 4-Nov-2014 17:32:39

arkeon
Admin. / Scol language & OpenSpace3D developer
From: Nantes
Registered: 30-Mar-2009
Posts: 5,161
Website

Re: Does the VM have a callback for changing tablet orientation

smile

Offline

#18 4-Nov-2014 18:21:49

hebdemnobad
Member
From: northamerica
Registered: 20-Apr-2011
Posts: 1,541
Website

Re: Does the VM have a callback for changing tablet orientation

what arguments are passed to @my_extra_callback with V3DsetCbScenePostRender? I couldn't find any documentation of the callback prototype on redmine.
thx

Offline

#19 4-Nov-2014 18:57:32

iri
Admin. / Scol language & Scol apps developer
From: France
Registered: 22-Feb-2009
Posts: 2,024
Website

Re: Does the VM have a callback for changing tablet orientation

The session structure and the callback.

By example :

V3DsetCbScenePostRender sessionstr @my_extra_callback;

in "tools / os3dlib / v3dlib.pkg", you can read :

fun V3DsetCbScenePostRender(sessionstr, cbfun)=
  set sessionstr.V3D_cbScenePostRender = cbfun;
  0;;

The prototype of this callback is :

fun [V3Dsession I] I

To know that, read the session structure definition, in the same file.
So,

V3Dseesion : the current session
I : the elapsed time

The function must return an integer ( I ).

If you need more arguments, use mkfun3 function.

Offline

#20 4-Nov-2014 19:16:12

hebdemnobad
Member
From: northamerica
Registered: 20-Apr-2011
Posts: 1,541
Website

Re: Does the VM have a callback for changing tablet orientation

thx Iri, i used mkfun3 as you said and I had found the answer myself in the v3lib.pkg file too....I hope I am groing out of these types of questions:

modified postrender declaration:

 V3DsetCbScenePostRender sessionstr  mkfun3 @buffercallback [octoplayerstruct viewstr];

modfied callback as per arkeon

 fun 	buffercallback (sessionstr, etime, extra_parameter)=
 	let extra_parameter -> [octoplayerstruct viewstr] in
 	let _GETdesktopSize -> [dw dh] in
 	let octoplayerstruct.OCTOPLAYER_screen_oldsize -> [ow oh] in
 	(
 		cbPlugView3dPostRender viewstr;
 		if (dw!=ow) || (dh!=oh) then
 		(
 			setEdWindowSizeEx mainWindow dw dh;
 			set octoplayerstruct.OCTOPLAYER_screen_oldsize = [dw dh];
 			//change here
 			0;
 		) else
 		(
 			nil;
 			0;
 		);
	
 		
 	);
 	nil;
 	0;;

time to see if it works on the tablet....

Offline

#21 4-Nov-2014 19:20:27

hebdemnobad
Member
From: northamerica
Registered: 20-Apr-2011
Posts: 1,541
Website

Re: Does the VM have a callback for changing tablet orientation

and it works smile

Offline

#22 4-Nov-2014 19:31:45

hebdemnobad
Member
From: northamerica
Registered: 20-Apr-2011
Posts: 1,541
Website

Re: Does the VM have a callback for changing tablet orientation

It's taken a while to understand the mkfun command. coming from a javascript background, callbacks usually don't have preset arguments sent to them, you set them yourself (or you set none at all).

I started writing a tutorial about this....from the perspective of a coder who doesn't know much about computer science.

Last edited by hebdemnobad (4-Nov-2014 19:32:46)

Offline

#23 4-Nov-2014 20:43:45

iri
Admin. / Scol language & Scol apps developer
From: France
Registered: 22-Feb-2009
Posts: 2,024
Website

Re: Does the VM have a callback for changing tablet orientation

For that, the Scol tutorial by Sylvain Huet provides also a very short explanation (make a search "mkfun").

Offline

#24 4-Nov-2014 20:46:45

hebdemnobad
Member
From: northamerica
Registered: 20-Apr-2011
Posts: 1,541
Website

Re: Does the VM have a callback for changing tablet orientation

iri wrote:

For that, the Scol tutorial by Sylvain Huet provides also a very short explanation (make a search "mkfun").

I have, many times. sad last night most recently.
The only way I have come to understand it is in the sense of adding arguments to functions that have a preset quantity of arguments. So I look at the function body without the mkfun word, add one to the default (prototype) arguments, which gives me the number (2, 3, whatever) that I have to make the function pass to carry an extra argument. (usually a tuple since you can put as many objects as you want in it.)

Last edited by hebdemnobad (4-Nov-2014 20:48:38)

Offline

#25 4-Nov-2014 21:15:42

iri
Admin. / Scol language & Scol apps developer
From: France
Registered: 22-Feb-2009
Posts: 2,024
Website

Re: Does the VM have a callback for changing tablet orientation

Yes, it is correct smile

A function takes one argument. You need two arguments. You use mkfun2.
A function takes two arguments. You need three arguments. You use mkfun3.
etc

Indeed, set a tuple is the easiest way.

You can add several mkfunX instead of a tuple.
From this example, you obtain the same result with :

typeof tmrMain = Timer;;
typeof iCount  = I;;

fun cbTick(tmr, pri_param, tupleParams) =
  let tupleParams -> ["secondary_param_3" "secondary_param_2" "secondary_param_1"] in
  _fooS strcatn (itoa iCount)::" "::pri_param::" "::sec_param_1::" "::sec_param_2::" "::sec_param_3::nil;
  set iCount = iCount + 1;
  if (iCount == 10) then
    _deltimer tmrMain
  else
    0;
  0;;

fun main() = 
   _showconsole;
   _fooS "***********************************";

   set iCount = 0;
   set tmrMain = _starttimer _channel 100;
   _rfltimer tmrMain mkfun3 @cbTick "primary_param" ["secondary_param_3" "secondary_param_2" "secondary_param_1"];

   _fooS "***********************************";
   0;;

I think also this way is easier and more comprehensive.

A remark : if you use a mkfunX, the called function has a new prototype.
In this example, cbTick is normally fun [ Timer S ] I
but with mkfun3, its protype is fun [ Timer S [S S S] ] I
You can not call cbTick with its "normal" type from another part of code in a given environment.

{
An environment is the whole of Scol apis and all functions defined (loaded) in a channel, typically, an application. The minimal environment is the Scol APIs only, they are loaded in the startup, you can see them in any log head file.
A channel is a network connection with a given environment.
}

Offline

Board footer

Powered by FluxBB