programming tools for Windows applications development
  Home  |   SwiftForth Archive  |   SwiftX Archive  |

Re: BeginPaint, EndPaint

From: Mike Ghan <mikeghan_at_logix-controls.com>
Date: Wed, 28 Aug 2002 07:38:09 -0700

Elliot,

As I understand it, the SWOOP method ADDR does not convert
absolute/relative addressing, it is a method (operation) for an object
which simply returns the address of the object's data area *and*
restores the dictionary search order back to it's previous state.
When you reference an object, SF expects a method by way of
restricting the search order. Referencing a method, among other
things, restores the search order. The search order bit is why you
bombed on BeginPaint.

I don't see any problems with USING in your example below but NAMES
may be easier (no VALUEs or USING required):

: 4V-UNITIZE ( v1 v2 -- ) \ assumes original vector non-0
   [OBJECTS 4V NAMES V2 4V NAMES V1 OBJECTS]
   V1 DATA V2 DATA V2 LENGTH F@ ( v1data v2data v2length )
   4 0 DO
      2DUP F@ FOVER F/ F! 2*8+
   LOOP 2DROP FDROP
   1E V1 LENGTH F!
;

NAMES is like a local variable but for objects.

Note that with either technique, both 4V-UNITIZE parameters should be
object ADDResses:

4V BUILDS FOO
4V BUILDS BAR

FOO ADDR BAR ADDR 4V-UNITIZE

Hope this helps,
Mike

-----Original Message-----
From: sftalk-bounce_at_forth.com [mailto:sftalk-bounce_at_forth.com]On
Behalf
Of elliott
Sent: Wednesday, August 28, 2002 5:07 AM
To: sftalk_at_forth.com
Subject: [sftalk] Re: BeginPaint, EndPaint

Thanks, Mike. I'll try it and see what other errors are uncovered.
Care to
elaborate on SF absolute/relative addressing and usage? I wonder if
there's
any relation to USING, which I've had to use in SWOOP in a way not
mentioned in the manual. See the colon def. after the class def.

1024 VALUE XMAX
768 VALUE YMAX
0 VALUE SMAX

: SET-SMAX
    XMAX YMAX + 2/ TO SMAX
;

SET-SMAX

: BITS ( n1 -- n2 ) \ # of 1-bits in n1
    0 SWAP 32 0 DO
       2 /MOD SWAP IF
          SWAP 1+ SWAP
       THEN
    LOOP DROP ;

ICODE 8+
    8 # EBX ADD
RET END-CODE

ICODE 16+
    16 # EBX ADD
RET END-CODE

ICODE 2*8+
    8 # EBX ADD
    8 # 0 [EBP] ADD
RET END-CODE

ICODE 3*8+
    8 # EBX ADD
    8 # 0 [EBP] ADD
    8 # 4 [EBP] ADD
RET END-CODE

CLASS 4V

    32 BUFFER: DATA
     8 BUFFER: LENGTH

    : 0FILL
       0E DATA 4 0 DO
          FDUP DUP F! 8+
       LOOP FDROP DROP
       0E LENGTH F!
    ;

    : UPDATE-LENGTH
       0E DATA 4 0 DO
         DUP F@ FDUP F* F+ 8+
       LOOP DROP
       FSQRT LENGTH F!
    ;

    : RANDOMIZE
       SMAX DATA 4 0 DO
          2DUP SWAP RND S>F F! 8+
       LOOP 2DROP
       UPDATE-LENGTH
    ;

: SHOW
    DUP DATA 4 0 DO
       DUP F@ F. 8+
    LOOP DROP
    CR LENGTH F@ F. CR
;

END-CLASS

\ placeholders for vector arithmetic:
\ V1 result
\ V2 main parameter
\ V3 2nd parameter. e.g., divisor

0 VALUE V1
0 VALUE V2
0 VALUE V3

: 4V-UNITIZE \ ( v1 v2 -- ) \ assumes original vector non-0
    TO V2 TO V1
    V1 USING 4V DATA V2 USING 4V DATA V2 USING 4V LENGTH F@ ( v1data
v2data
v2length )
    4 0 DO
       2DUP F@ FOVER F/ F! 2*8+
    LOOP 2DROP FDROP
    1E V1 USING 4V LENGTH F!
;

At 12:03 AM 8/28/02, you wrote:

>Elliot,
>
>ps is an object and expects a method. BeginPaint requires the
>*address* of ps so you would use
> ps ADDR as follows:
>
>[SWITCH MESSAGE-HANDLER DEFWINPROC ( -- res )
> WM_PAINT RUN:
> DISPLAY HWND ps ADDR 2DUP BeginPaint EndPaint ;
>SWITCH]
>
>Mike
>
>
>-----Original Message-----
>From: sftalk-bounce_at_forth.com [mailto:sftalk-bounce_at_forth.com]On
>Behalf
>Of elliott
>Sent: Tuesday, August 27, 2002 8:49 PM
>To: sftalk_at_forth.com
>Subject: [sftalk] Re: BeginPaint, EndPaint
>
>
>
>Right Rick. So here's what happens when I try to load:
>
>LIBRARY GLU32.DLL ok
>LIBRARY OPENGL32.DLL ok
> ok
>FVARIABLE DF ok
> ok
>: 1dfparm ( f: x -- ) ( s: -- xl xh )
> DF DUP F! 2@ SWAP ; ok
> ok
>: dfparms ( f: n*x reversed -- ) ( s: n -- n*x )
> 0 DO 1dfparm LOOP ; ok
> ok
>1 IMPORT: glClear ok
>1 IMPORT: glBegin ok
>6 IMPORT: glColor3d ok
>2 IMPORT: glVertex2i ok
>0 IMPORT: glEnd ok
>0 IMPORT: glFlush ok
>4 IMPORT: glViewport ok
> ok
>: glColor3d ( f: 3*x reversed -- s: -- 3*x )
> 3 dfparms glColor3d ; ok
> ok
>: DISPLAY
> GL_COLOR_BUFFER_BIT glClear
> GL_TRIANGLES glBegin
> 0e 0e 1e glColor3d
> 0 1 glVertex2i
> 0e 1e 0e glColor3d
> -1 -1 glVertex2i
> 1e 0e 0e glColor3d
> 1 -1 glVertex2i
> glEnd
> glFlush
>; ok
> ok
>PAINTSTRUCT BUILDS ps ok
> ok
>0 VALUE hAPP ok
>CREATE CLASSNAME ,Z" openGL triangle" ok
> ok
>: -APP ( -- flag )
> 'MAIN @ [ 'MAIN @ ] LITERAL = ; ok
> ok
> ok
>[SWITCH MESSAGE-HANDLER DEFWINPROC ( -- res ) ok
> WM_PAINT RUN:
> DISPLAY HWND ps 2DUP BeginPaint EndPaint ; BeginPaint ?
>
>

----------------------------------------------------------------------
sftalk_at_forth.com The SwiftForth programming discussion email list
To unsubscribe, send subject "unsubscribe sftalk" to listar_at_forth.com
For help with listar commands, send subject "help" to listar_at_forth.com
Archives are located at http://www.forth.com/sftalk -- check them out!
Search the archives! Visit http://www.forth.com/search for details.
Received on Wed Aug 28 2002 - 07:38:12 PDT

This archive was generated by hypermail 2.2.0 : Wed Jan 07 2009 - 03:04:02 PST