SP-Forth and OpenGL question

28 messages Options
Embed this post
Permalink
1 2
Ruvim Pinka

Re: SP-Forth and OpenGL question

Reply Threaded More More options
Print post
Permalink
Dave, look at http://spf.sourceforge.net/docs/intro.en.html#dll
You don't need to use the LoadLibrary function directly.

--
Ruvim

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Spf-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spf-dev
D TALIAFERRO

Re: SP-Forth and OpenGL question

Reply Threaded More More options
Print post
Permalink
Some javascript/style in this post has been disabled (why?)
I tried the example with a little more luck but still having problems; I think it's the settings Visual Studio compiler.
 
I will revisit this problem.
 
I managed to find the old glut mods for my pForth-OpenGL and got everything to work in Visual Studio 2008 (recompiled the glut libs and dlls).
 
But I get an error when I start using glut commands from Forth :
 
glut error : out of memory
 
Has anyone here seen this? The tag "out of memory" occurs a lot in the glut source code so it is hard to trace.
 
It will be easier to port my l-system code to SP-Forth if I can get the original working.
 
Thanks,
 
Dave
 


> Date: Wed, 12 Nov 2008 00:44:51 +0300
> From: [hidden email]
> To: [hidden email]
> Subject: Re: [Spf-dev] SP-Forth and OpenGL question
>
> Dave, look at http://spf.sourceforge.net/docs/intro.en.html#dll
> You don't need to use the LoadLibrary function directly.
>
> --
> Ruvim
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Spf-dev mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/spf-dev


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Spf-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spf-dev
Ruvim Pinka

Re: SP-Forth and OpenGL question

Reply Threaded More More options
Print post
Permalink
Hello,

On Thu, Nov 13, 2008 at 4:03 AM, D TALIAFERRO <[hidden email]> wrote:

But I get an error when I start using glut commands from Forth :
 
glut error : out of memory
 
Has anyone here seen this?

--
Ruvim

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Spf-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spf-dev
D TALIAFERRO

Re: SP-Forth and OpenGL question

Reply Threaded More More options
Print post
Permalink
Some javascript/style in this post has been disabled (why?)
It was a glu malloc in my pforth code.

Somehow I need to increase the memory size (heap) in Visual Studio.

Otherwise it is almost working.


Date: Thu, 13 Nov 2008 21:50:20 +0300
From: [hidden email]
To: [hidden email]
Subject: Re: [Spf-dev] SP-Forth and OpenGL question

Hello,

On Thu, Nov 13, 2008 at 4:03 AM, D TALIAFERRO <[hidden email]> wrote:

But I get an error when I start using glut commands from Forth :
 
glut error : out of memory
 
Has anyone here seen this?

--
Ruvim

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Spf-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spf-dev
D TALIAFERRO

importing external dll functions

Reply Threaded More More options
Print post
Permalink
Some javascript/style in this post has been disabled (why?)
I am having trouble importing external C functions.

I created a dll in Visual Studio using this syntax :

extern "C" __declspec(dllexport) void __cdecl setsigma(void);

here is the output from pedump on the resulting "t3.dll" :

At the end of this post are the rsults for the examples in the SP-Forth doc.

When it loads without error, I cannot see the Forth name for the function.

Thanks,

Dave


Dump of file T3.DLL

exports table:

  Name:            t3.dll
  Characteristics: 00000000
  TimeDateStamp:   491DC11A -> Fri Nov 14 11:19:06 2008
  Version:         0.00
  Ordinal base:    00000001
  # of functions:  00000022
  # of Names:      00000022

  Entry Pt  Ordn  Name
  0001115E     1  Hdot
  00011014     2  HdotP1dot
  000111A9     3  Hminus
  000110E1     4  Hminus90
  00011019     5  Hplus
  0001119A     6  Hplus90
  0001118B     7  Lminus
  000110F5     8  Lminus90
  00011195     9  Lplus
  00011186    10  Lplus90
  00011028    11  P0dot
  00011172    12  PointXMatrix
  00011258    13  U180
  00011131    14  Uminus
  0001110E    15  Uminus90
  000110AF    16  Uplus
  00011163    17  Uplus90
  00011122    18  addHeading
  00011064    19  calcTurtleDistance
  00011109    20  crossprod
  000111A4    21  getHeading
  00011249    22  getHeadingPrime
  0001119F    23  getHprime
  00011005    24  getP0
  0001100A    25  getP1
  00011212    26  getsigma
  00011235    27  initHeading
  0001112C    28  normalize
  000110DC    29  p02p1
  000110BE    30  setHeading
  000111C7    31  setHprime
  00011221    32  setP0
  00011226    33  setP1
  00011253    34  setsigma



results for FP-Forth doc examples :

if you want to import automatically all DLL functions as forth words, use (for
stdcall)

example 1 :
REQUIRE UseDLL ~nn/lib/usedll.f
UseDLL "DLL name"

result :

SP-FORTH - ANS FORTH 94 for Win95/98/ME/NT/2000/XP

REQUIRE UseDLL ~nn/lib/usedll.f
 Ok
UseDLL t3.dll
 Ok

' setsigma
' setsigma
        ^ -321 - not found !


example 2 :

REQUIRE DLL ~ac/lib/ns/dll-xt.f
DLL NEW: "DLL name"

SP-FORTH - ANS FORTH 94 for Win95/98/ME/NT/2000/XP

REQUIRE DLL ~ac/lib/ns/dll-xt.f
 Ok
DLL NEW: t3.dll
DLL NEW: t3.dll
       ^ -2003 WORD OR FILE NOT FOUND


example 3 :

REQUIRE USES_C ~af/lib/c/capi-func.f
USES_C "DLL name"

SP-FORTH - ANS FORTH 94 for Win95/98/ME/NT/2000/XP

REQUIRE USES_C ~af/lib/c/capi-func.f
CODE isn't unique
 Ok
USES_C t3.dll
 Ok
' setsigma
' setsigma
        ^ -321 - not found !

example 4 :

REQUIRE SO ~ac/lib/ns/so-xt.f
SO NEW: "DLL name"

SP-FORTH - ANS FORTH 94 for Win95/98/ME/NT/2000/XP

REQUIRE SO ~ac/lib/ns/so-xt.f
 Ok
SO NEW: t3.dll
SO NEW: t3.dll
      ^ -2003 WORD OR FILE NOT FOUND







-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Spf-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spf-dev
Andrey Cherezov

Re: importing external dll functions

Reply Threaded More More options
Print post
Permalink
Some javascript/style in this post has been disabled (why?)
14.11.2008 20:49 D TALIAFERRO wrote:
extern "C" __declspec(dllexport) void __cdecl setsigma(void);
here is the output from pedump on the resulting "t3.dll" :

  Name:            t3.dll
  00011253    34  setsigma

REQUIRE UseDLL ~nn/lib/usedll.f
 Ok
UseDLL t3.dll
 Ok

' setsigma
' setsigma
        ^ -321 - not found !

example 2 :

example 3 :

example 4 :
REQUIRE SO ~ac/lib/ns/so-xt.f
 Ok
SO NEW: t3.dll
SO NEW: t3.dll
      ^ -2003 WORD OR FILE NOT FOUND
;-)
ALSO SO NEW: t3.dll

Look at the huge number of examples of importing various dll/so in ~ac\lib\lin folder.

Or try the easiest way:
WINAPI: setsigma t3.dll

Or post t3.dll and its source code here.


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Spf-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spf-dev
ygrek-3

Re: importing external dll functions

Reply Threaded More More options
Print post
Permalink
In reply to this post by D TALIAFERRO
On Fri, 14 Nov 2008 18:49:02 +0000
D TALIAFERRO <[hidden email]> wrote:

> results for FP-Forth doc examples :
>
> if you want to import automatically all DLL functions as forth words, use (for
> stdcall)
>
> example 1 :
> REQUIRE UseDLL ~nn/lib/usedll.f
> UseDLL "DLL name"
>
> result :
>
> SP-FORTH - ANS FORTH 94 for Win95/98/ME/NT/2000/XP
>
> REQUIRE UseDLL ~nn/lib/usedll.f
>  Ok
> UseDLL t3.dll
>  Ok
>
> ' setsigma
> ' setsigma
>         ^ -321 - not found !
' (tick) will never work for the function imported this way, it is
resolved via NOTFOUND. Just call it by name when needed. And really
look at some examples in devel.

--
 ~ygrek


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Spf-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spf-dev

attachment0 (204 bytes) Download Attachment
D TALIAFERRO

Re: importing external dll functions

Reply Threaded More More options
Print post
Permalink
In reply to this post by Andrey Cherezov
Some javascript/style in this post has been disabled (why?)
Thanks, that worked :
 
WINAPI: P0dot t3.dll
 Ok
P0dot
 P0x  0.000  P0y  0.000  P0z  0.000 Ok ( 36 )
 
 
The "t3.dll" contains some C matrix code for the opengl turtle graphics.
 
I could get rid of the C code and use either opengl matrix calls or Forth matrix functions (preferred method).
 
There is some matrix code in ~diver\fsl-util.f, but the ~diver\matrix\*.f are in Russian.
 
also matrix code in ~ygrek\prog\iasa\nm1\matrix.f
 
Please suggest suitable matrix functions work with. I just need simple 3x3 matrix words.
 
Thanks, Dave
 
 
Here is the C code I used as basis for my turtle Forth words :
 
typedef struct Point3Struct { /* 3d point */
float x, y, z;
} Point3;
 
typedef Point3 Vector3;
typedef struct IntPoint3Struct { /* 3d integer point */
int x, y, z;
} IntPoint3;
 
typedef struct Matrix3Struct { /* 3-by-3 matrix */
float element[3][3];
} Matrix3;
typedef float matrix3[3][3];
double sigma; /* the turtle rotation angle variable */
 
 
extern "C" __declspec(dllexport) void __stdcall
crossprod(GLfloat v1[3], GLfloat v2[3], GLfloat prod[3])
{
GLfloat p[3];
/* in case prod == v1 or v2 */
p[0] = v1[1] * v2[2] - v2[1] * v1[2];
p[1] = v1[2] * v2[0] - v2[2] * v1[0];
p[2] = v1[0] * v2[1] - v2[0] * v1[1];
prod[0] = p[0];
prod[1] = p[1];
prod[2] = p[2];
}
 
 
/* return vector sum c = a+b */
Vector3 *V3Add(Vector3 *a, Vector3 *b, Vector3 *c)
{
c->x = a->x+b->x; c->y = a->y+b->y; c->z = a->z+b->z;
return(c);
};
 
 
/* multiply a point by a matrix and return the transformed point */
extern "C" __declspec(dllexport) void __cdecl PointXMatrix(Point3 *pin, Point3 *pout, Matrix3 *m)
{
pout->x = (pin->x * m->element[0][0]) + (pin->y * m->element[1][0]) +
(pin->z * m->element[2][0]);
pout->y = (pin->x * m->element[0][1]) + (pin->y * m->element[1][1]) +
(pin->z * m->element[2][1]);
pout->z = (pin->x * m->element[0][2]) + (pin->y * m->element[1][2]) +
(pin->z * m->element[2][2]);
}
 
 
 
 
 

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Spf-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spf-dev
1 2