Send commands from DLL to new Screen created by main file

New to FreeBASIC? Post your questions here.
fert
Posts: 2
Joined: Oct 31, 2013 0:33

Send commands from DLL to new Screen created by main file

Postby fert » Oct 31, 2013 1:22

If i create a Screen from the main file, how can i make a DLL send commands to that new Screen and not to the original console screen?
For example, the Print command from the DLL goes to the console screen, not to the new Screen.
Thanks for any help!
fxm
Posts: 9072
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Send commands from DLL to new Screen created by main fil

Postby fxm » Oct 31, 2013 17:18

Hello fert, welcome to the forum.

In pure FreeBASIC:
- You must create the new graphic screen from the DLL ('Screen/ScreenRes' must be executed from a procedure of the DLL).
- Each DLL can process only its own graphic screen (created by it).

See examples at: Create DLL, from viewtopic.php?p=181774#p181774
fert
Posts: 2
Joined: Oct 31, 2013 0:33

Re: Send commands from DLL to new Screen created by main fil

Postby fert » Nov 02, 2013 4:49

That's the answer that i was looking for, many thanks
I see i can do like: Main => Multiples DLL's so i can control each screen of each DLL from the main code. I was wondering if i could do the 'reverse', like: Multiples DLL => Main file , so i could use the various DLL's to send commands to a single screen created by the Main file. That would be the solution but it seems that it is not possible. Anyway, i was looking at the FB Help and find out that simply modularizating the code into several files and then compiling like: " fbc main.bas functions.bas subs.bas " would be enough to better organize the code, that was what i was looking for. Thanks again
TJF
Posts: 3474
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: Send commands from DLL to new Screen created by main fil

Postby TJF » Nov 02, 2013 9:59

fert wrote:... and find out that simply modularizating the code into several files and then compiling like: " fbc main.bas functions.bas subs.bas " would be enough to better organize the code, that was what i was looking for.

Also check #INCLUDE [ONCE].

fert wrote:I was wondering if i could do the 'reverse', like: Multiples DLL => Main file , so i could use the various DLL's to send commands to a single screen created by the Main file.

At least you can create an image in the main file and draw on it from several modules. Then PUT it on the screen in the main modul. It's a bit tricky and each dll-modul needs its own fbgfx graphic library. (You should have good reasons to go that way, ie a plugin system.)
dodicat
Posts: 5888
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Send commands from DLL to new Screen created by main fil

Postby dodicat » Nov 03, 2013 2:09

A couple of points with fb .9
You must make a windowtitle for each .dll.
But it can be overwritten in the main module.
You cannot move an openGL screen (bug)

Here are some updated .dll's with images incorporated, one way by put, the other way by get>
screen1.bas

Code: Select all

'DLL file
' screen1.bas
' to compile with  -dll to get screen1.dll
'____________________________________________________________

 sub windowtitle1(s as string) export
    windowtitle s
end sub
 
Sub screen1 (Byval X As Integer, Byval Y As Integer,xres as integer,yres as integer,d as integer=32) EXPORT
    windowtitle "Screen 1"
  Screenres xres,yres,d
  SCREENCONTROL(100, X, Y)
End Sub

sub put1(im as any pointer,x as integer,y as integer) export
    put(x,y),im,pset
end sub

function get1(x as integer,y as integer) as any pointer export
    dim as integer w,h
    screeninfo w,h
    dim as any pointer i=imagecreate(w,h)
    get (1,1)-(x-1,y-1),i
    return i
    end function
'
sub colour1(c1 as uinteger) export
    color ,c1
end sub

sub paint1(x as integer,y as integer,c1 as uinteger,c2 as uinteger) export
    paint(x,y),c1,c2
    end sub

Sub Print1 (Byref text As String,indicator as string="") EXPORT
 if indicator="," then Print text,:exit sub
 if indicator=";" then print text;:exit sub
 print text
End Sub

sub line1(x1 as double,y1 as double,x2 as double,y2 as double,c as uinteger,f as string="",im as any pointer=0) EXPORT
    if f="" then line im,(x1,y1)-(x2,y2),c
    if f="b" then line im,(x1,y1)-(x2,y2),c,b
    if f="bf" then line im,(x1,y1)-(x2,y2),c,bf
end sub

sub circle1(x1 as double,_
    y1 as double,_
    rad as double,_
    c as uinteger,_
    arc1 as double=0,_
    arc2 as double=6.28318,_
    aspect as double=1,_
    fill as string="",_
    im as any pointer=0) EXPORT
    if fill="" then
    circle im,(x1,y1),rad,c,arc1,arc2,aspect
else
    circle im,(x1,y1),rad,c,,,aspect,f
    end if
end sub
sub pset1(x1 as double,y1 as double,c as uinteger,im as any pointer=0) EXPORT
    pset im,(x1,y1),c
end sub
sub clearscreen1 export
    cls
end sub
sub endkey1 export
    if inkey=chr(27) then end
end sub
sub screenlock1 export
    screenlock
end sub
sub screenunlock1 export
    screenunlock
end sub
sub getmouse1(byref mx as integer,byref my as integer,byref mw as integer=0,byref mb as integer=0) export
    getmouse(mx,my,mw,mb)
end sub
sub locate1(x as integer,y as integer) export
    locate x,y
    end sub


 


screen2.bas

Code: Select all

'DLL file
' screen2.bas
' to compile with  -dll to get screen2.dll
'____________________________________________________________
sub windowtitle2(s as string) export
    windowtitle s
end sub
 
 Sub screen2 (Byval X As Integer, Byval Y As Integer,xres as integer,yres as integer,d as integer=32) EXPORT
   windowtitle "Screen 2"   
  Screenres xres,yres,d
  SCREENCONTROL(100, X, Y)
End Sub

sub put2(im as any pointer,x as integer,y as integer) export
    put(x,y),im,pset
end sub

function get2(x as integer,y as integer) as any pointer export
    dim as integer w,h
    screeninfo w,h
    dim as any pointer i=imagecreate(w,h)
    get (1,1)-(x-1,y-1),i
    return i
end function

sub colour2(c1 as uinteger) export
    color ,c1
end sub
sub paint2(x as integer,y as integer,c1 as uinteger,c2 as uinteger) export
    paint(x,y),c1,c2
    end sub

Sub Print2 (Byref text As String,indicator as string="") EXPORT
 if indicator="," then Print text,:exit sub
 if indicator=";" then print text;:exit sub
 print text
End Sub

sub line2(x1 as double,y1 as double,x2 as double,y2 as double,c as uinteger,f as string="",im as any pointer=0) EXPORT
    if f="" then line im,(x1,y1)-(x2,y2),c
    if f="b" then line im,(x1,y1)-(x2,y2),c,b
    if f="bf" then line im,(x1,y1)-(x2,y2),c,bf
end sub
sub circle2(x1 as double,_
    y1 as double,_
    rad as double,_
    c as uinteger,_
    arc1 as double=0,_
    arc2 as double=6.28318,_
    aspect as double=1,_
    fill as string="",_
    im as any pointer=0) EXPORT
    if fill="" then
    circle im,(x1,y1),rad,c,arc1,arc2,aspect
else
    circle im,(x1,y1),rad,c,,,aspect,f
    end if
end sub
sub pset2(x1 as double,y1 as double,c as uinteger,im as any pointer=0) EXPORT
    pset im,(x1,y1),c
end sub
sub clearscreen2 export
    cls
end sub
sub endkey2 export
    if inkey=chr(27) then end
end sub
sub screenlock2 export
    screenlock
end sub
sub screenunlock2 export
    screenunlock
    end sub
sub getmouse2(byref mx as integer,byref my as integer,byref mw as integer=0,byref mb as integer=0) export
    getmouse(mx,my,mw,mb)
end sub
sub locate2(x as integer,y as integer) export
    locate x,y
end sub

       

screen3.bas

Code: Select all

'DLL file
' screen3.bas
' to compile with  -dll to get screen3.dll
'____________________________________________________________

sub windowtitle3(s as string) export
    windowtitle s
end sub

Sub screen3 (Byval X As Integer, Byval Y As Integer,xres as integer,yres as integer,d as integer=32) EXPORT
     windowtitle "Screen 3"
  Screenres xres,yres,d
  SCREENCONTROL(100, X, Y)
End Sub

sub put3(im as any pointer,x as integer,y as integer) export
    put(x,y),im,pset
end sub

function get3(x as integer,y as integer) as any pointer export
    dim as integer w,h
    screeninfo w,h
    dim as any pointer i=imagecreate(w,h)
    get (1,1)-(x-1,y-1),i
    return i
    end function
'
sub colour3(c1 as uinteger) export
    color ,c1
end sub

sub paint3(x as integer,y as integer,c1 as uinteger,c2 as uinteger) export
    paint(x,y),c1,c2
    end sub

Sub Print3 (Byref text As String,indicator as string="") EXPORT
 if indicator="," then Print text,:exit sub
 if indicator=";" then print text;:exit sub
 print text
End Sub

sub line3(x1 as double,y1 as double,x2 as double,y2 as double,c as uinteger,f as string="",im as any pointer=0) EXPORT
    if f="" then line im,(x1,y1)-(x2,y2),c
    if f="b" then line im,(x1,y1)-(x2,y2),c,b
    if f="bf" then line im,(x1,y1)-(x2,y2),c,bf
end sub

sub circle3(x1 as double,_
    y1 as double,_
    rad as double,_
    c as uinteger,_
    arc1 as double=0,_
    arc2 as double=6.28318,_
    aspect as double=1,_
    fill as string="",_
    im as any pointer=0) EXPORT
    if fill="" then
    circle im,(x1,y1),rad,c,arc1,arc2,aspect
else
    circle im,(x1,y1),rad,c,,,aspect,f
    end if
end sub
sub pset3(x1 as double,y1 as double,c as uinteger,im as any pointer=0) EXPORT
    pset im,(x1,y1),c
end sub
sub clearscreen3 export
    cls
end sub
sub endkey3 export
    if inkey=chr(27) then end
end sub
sub screenlock3 export
    screenlock
end sub
sub screenunlock3 export
    screenunlock
end sub
sub getmouse3(byref mx as integer,byref my as integer,byref mw as integer=0,byref mb as integer=0) export
    getmouse(mx,my,mw,mb)
end sub
sub locate3(x as integer,y as integer) export
    locate x,y
    end sub


 

glscreendll.bas

Code: Select all


'glscreendll.bas
'compile with -dll switch to get glscreendll.dll
#include "gl/glu.bi"

sub glwindowtitle(s as string) export
    windowtitle s
end sub

Sub glscreen (Byval X As Integer, Byval Y As Integer,xres as integer,yres as integer,d as integer=32) EXPORT
     windowtitle "OPENGL"
  Screenres xres,yres,d,,2
  SCREENCONTROL(100, X, Y)
End Sub

sub Glsetcolor(r as single,g as single,b as single,a as single) export
   glcolor4f(r,g,b,a)
end sub   

sub glLine(x1 as integer,y1 as integer,x2 as integer,y2 as integer, th as integer) export
    glLineWidth th
    glbegin gl_lines
    glvertex2f(x1,y1)
    glvertex2f(x2,y2)
    glend
end sub

sub glsetortho(x1 as integer,x2 as integer,y1 as integer,y2 as integer,z1 as integer,z2 as integer) export
    glortho(x1,x2,y1,y2,z1,z2)
    glDisable (GL_DEPTH_TEST)
    glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA)
    glEnable (GL_BLEND)
    glEnable (GL_LINE_SMOOTH)
end sub

sub glclearbuffer() export
glClear (GL_COLOR_BUFFER_BIT)
end sub

sub glflip export
    flip
end sub
sub glpolygonfill(x as integer,y as integer,rx as integer,ry as integer,numsides as integer) export
    Var pi2 = 8*Atn(1),st=pi2/(numsides)
    glend
    glBegin GL_TRIANGLE_FAN
    For a As Single=0 To pi2  Step st
        glVertex2f (x)+Cos(a)*(rx),(y)+Sin(a)*(ry)
    Next
    glEnd
end sub

sub glpolygon(x as integer,y as integer,rx as integer,ry as integer,numsides as integer,thickness as integer) export
    Var pi2 = 8*Atn(1),st=pi2/(numsides)
    glend
    glLineWidth(thickness)
    glBegin GL_LINES
    For a As Single=0 To pi2  Step st
        glVertex2f (x)+Cos(a)*(rx),(y)+Sin(a)*(ry)
        glVertex2f (x)+Cos(a+st)*(rx),(y)+Sin(a+st)*(ry)
    Next
    glEnd
end sub

sub gldrawline(x as integer,y as integer,angle as double,length as double,byref x2 as double=0,byref y2 as double=0) export
    angle=angle*.0174532925199433  '=4*atn(1)/180
     x2=x+length*cos(angle)
     y2=y-length*sin(angle)
     glend
     glLineWidth(1)
     glbegin gl_lines
     glvertex2f(x,y)
     glvertex2f(x2,y2)
     glend
end sub
sub endkeygl export
    if inkey=chr(27) then end
end sub


declarations.bas

Code: Select all

'DECLARATIONS FOR THE  DLL'S
'declarations.bas
'==============================================================================
declare sub windowtitle1(s as string)
declare Sub screen1 (Byval X As Integer, Byval Y As Integer,xres as integer,yres as integer,d as integer=32)
declare sub put1(im as any pointer,x as integer,y as integer)
'======================
declare function get1(x as integer,y as integer) as any pointer
'======================
declare sub colour1(c1 as uinteger)
declare sub paint1(x as integer,y as integer,c1 as uinteger,c2 as uinteger)
Declare Sub Print1 (Byref text As String,indicator as string="")
declare sub line1(x1 as double,y1 as double,x2 as double,y2 as double,c as uinteger,f as string="",im as any pointer=0)
declare sub circle1(x1 as double,_
    y1 as double,_
    rad as double,_
    c as uinteger,_
    arc1 as double=0,_
    arc2 as double= 6.28318,_
    aspect as double=1,_
    fill as string="",_
    im as any pointer=0)
   
declare sub pset1(x1 as double,x2 as double,c as uinteger,im as any pointer=0)
declare sub clearscreen1
declare sub endkey1
declare sub screenlock1
declare sub screenunlock1
declare sub getmouse1(byref mx as integer,byref my as integer,byref mw as integer=0,byref mb as integer=0)
declare sub locate1(x as integer,y as integer)

'=====================================================================
declare sub windowtitle2(s as string)

declare Sub screen2 (Byval X As Integer, Byval Y As Integer,xres as integer,yres as integer,d as integer=32)
declare sub put2(im as any pointer,x as integer,y as integer)
'======================
declare function get2(x as integer,y as integer) as any pointer
'======================
declare sub colour2(c1 as uinteger)
declare sub paint2(x as integer,y as integer,c1 as uinteger,c2 as uinteger)
Declare Sub Print2 (Byref text As String,indicator as string="")
declare sub line2(x1 as double,y1 as double,x2 as double,y2 as double,c as uinteger,f as string="",im as any pointer=0)
declare sub circle2(x1 as double,_
    y1 as double,_
    rad as double,_
    c as uinteger,_
    arc1 as double=0,_
    arc2 as double= 6.28318,_
    aspect as double=1,_
    fill as string="",_
    im as any pointer=0)
   
declare sub pset2(x1 as double,x2 as double,c as uinteger,im as any pointer=0)
declare sub clearscreen2
declare sub endkey2
declare sub screenlock2
declare sub screenunlock2
declare sub getmouse2(byref mx as integer,byref my as integer,byref mw as integer=0,byref mb as integer=0)
declare sub locate2(x as integer,y as integer)
'_____________________________________________________________
declare sub windowtitle3(s as string)

declare Sub screen3 (Byval X As Integer, Byval Y As Integer,xres as integer,yres as integer,d as integer=32)
 declare sub put3(im as any pointer,x as integer,y as integer)
 '======================
declare function get3(x as integer,y as integer) as any pointer
'======================
declare sub colour3(c1 as uinteger)
declare sub paint3(x as integer,y as integer,c1 as uinteger,c2 as uinteger)
Declare Sub Print3 (Byref text As String,indicator as string="")
declare sub line3(x1 as double,y1 as double,x2 as double,y2 as double,c as uinteger,f as string="",im as any pointer=0)
declare sub circle3(x1 as double,_
    y1 as double,_
    rad as double,_
    c as uinteger,_
    arc1 as double=0,_
    arc2 as double= 6.28318,_
    aspect as double=1,_
    fill as string="",_
    im as any pointer=0)
   
declare sub pset3(x1 as double,x2 as double,c as uinteger,im as any pointer=0)
declare sub clearscreen3
declare sub endkey3
declare sub screenlock3
declare sub screenunlock3
declare sub getmouse3(byref mx as integer,byref my as integer,byref mw as integer=0,byref mb as integer=0)
declare sub locate3(x as integer,y as integer)

'opengl declarations
declare Sub glscreen (Byval X As Integer, Byval Y As Integer,xres as integer,yres as integer,d as integer=32)
declare sub glsetcolor(r as single,g as single,b as single,a as single)
declare sub glLine(x1 as integer,y1 as integer,x2 as integer,y2 as integer, th as integer)
declare sub glsetortho(x1 as integer,x2 as integer,y1 as integer,y2 as integer,z1 as integer,z2 as integer)
declare sub glclearbuffer()
declare sub glflip
declare sub glpolygonfill(x as integer,y as integer,rx as integer,ry as integer,numsides as integer)
declare sub glpolygon(x as integer,y as integer,rx as integer,ry as integer,numsides as integer,thickness as integer)
declare sub glwindowtitle(s as string) 
declare sub gldrawline(x as integer,y as integer,angle as double,length as double,byref x2 as double=0,byref y2 as double=0)
declare sub endkeygl
' =================  END DECLARATIONS =================================


 

and finally the test code,test.bas

Code: Select all


'test.bas

'=============== EXAMPLE ====================================
#include "declarations.bas"

'LOAD THE  DLL'S
#inclib "screen1"
#inclib "screen2"
#inclib "screen3"
#inclib "glscreendll"

'local subs in this code
declare Sub ball1()
declare Sub ball2(byref xpos as integer,byref ypos as integer)
Function framecounter() As Integer
    Var t1=Timer,t2=t1
    Static As Double t3,frames,answer
    frames=frames+1
    If (t2-t3)>=1 Then
        t3=t2
        answer=frames
        frames=0
    End If
    Return answer
End Function

'local variables in this code

Dim Shared As Double dx=2,dy=2
dim shared as double dx2=4,dy2=3
dim shared as integer xres3,yres3, xres2,yres2,xres1,yres1

screenres 800,600 'main screen

xres1=500
yres1=400

screen1(10,10,xres1,yres1,8) 'set up screen1 at 10,10,screenres 500,400,8
windowtitle1("win 1")

xres2=400
yres2=420
screen2(550,10,xres2,yres2,32)' set up screen2 at 550,10,screenres 400,420,32
windowtitle2("win 2")

xres3=300
yres3=200
screen3(30,300,xres3,yres3,32)
windowtitle3("win 3")
'colour two of the screens
colour1(4)
colour2(rgb(0,0,50))

'-------------OpenGL variables ----------
glscreen (500,300,400,400)

glsetortho(0,400,400,0,-1,1)
glwindowtitle("OpenGL")
dim as double x1,y1,inc
x1=400/2
y1=400/2
dim as any ptr image32=imagecreate(100,100,,32)
dim as any ptr image8=imagecreate(100,100,,8)
dim as any ptr mainimage=imagecreate(xres1,yres1,8)
'create images
for x as integer=0 to 100
    for y as integer=0 to 100
        pset image8,(x,y),x or y
    next y
next x

for x as integer=0 to 100
    for y as integer=0 to 100
        pset image32,(x,y),rgb(x,x or y,y)
    next y
next x

dim as integer imageX,imageY 'for bouncing box

'get image of screen 1 to set on main screen
   screenlock1
    line1(20,20,480,380,3,"b") 'the box, screen1
    paint1(1,1,1,3)            'paint round the box
    paint1(xres1/2,yres1/2,4,3)
    put1(image8,50,50)          '8 bit image
        locate1 5,2
    print1 "SCREEN1.dll"
    print1 str(xres1)+"  "+str(yres1)
   screenunlock1
mainimage=get1(xres1,yres1)
'------------------------------
 Do
    screenlock  'main screen(800 by 600)
    cls
    put (150,100),mainimage
    locate 5,10
    print "MAIN SCREEN with image of screen1"
    screenunlock
    sleep 1,1
    '_____________________________________
    Screenlock1 'screen 1
    Clearscreen1
    line1(20,20,480,380,3,"b") 'the box, screen1
    paint1(1,1,1,3)            'paint round the box
    put1(image8,50,50)          '8 bit image
    locate1 5,2
    print1 "SCREEN1.dll"
    print1 str(xres1)+"  "+str(yres1)
    ball1()
    screenunlock1
    'mainimage=get1(xres1,yres1)
    endkey1
    sleep 1,1
 '__________________________________________   
    screenlock2 'screen 2
    clearscreen2
    put2(image32,imageX,imageY)'32 bit image in motion
    locate2 2,2
    print2 "SCREEN2.dll"
     print2 str(xres2)+"  "+str(yres2)
    ball2(imageX,imageY)
    Screenunlock2
    endkey2
    Sleep 1,1
'---------------------------------------
  screenlock3 'screen 3
    clearscreen3
    put3(image32,0,0)'fixed 32 bit image
    locate3 2,15
    print3 "SCREEN3.dll"
    locate3 4,15
     print3 str(xres3)+"  "+str(yres3)
     locate3 6,15
     print3 "System FPS = ",";"
     print3 str(framecounter)
    Screenunlock3
    endkey3
    Sleep 1,1 
    '----------------------------- openglscreen
    inc=inc+.1
    glclearbuffer()
    glsetcolor(1,1,0,1)
    glline(20,20,50,50,4)
    glsetcolor(.5,.5,.5,.5)
    glpolygonfill(100,100,100,90,50)
    glsetcolor(0,0,1,1)
    glpolygon(200,200,50,50,6,3)
    glsetcolor(0,100,0,1)
    for angle as single=inc to 360-6+inc step 6
        gldrawline(x1,y1,angle,190)
        next angle
    glflip
    endkeygl
Loop until inkey=chr(27)
imagedestroy image8
imagedestroy image32
imagedestroy mainimage
end


Sub ball1()
    Static As Double x=100
    static as double y=100 
    x=x+dx
    y=y+dy
    Circle1(x,y,10,3,,,,"f")
    Circle1(x,y,10,0,,,,"")
    If y>yres1-30 Then dy= -dy
    If y<30 Then dy= -dy
    If x>xres1-30 Then dx= -dx
    If x < 30 Then dx= -dx
End Sub

Sub ball2(byref xpos as integer,byref ypos as integer)
    Static As Double x=100
    static as double y=100
    x=x+dx2
    y=y+dy2
    'Circle2(x,y,10,rgb(200,100,0),,,,"f")
    'Circle2(x,y,10,rgb(200,200,200),,,,"")
    xpos=x-50:ypos=y-50
    If y>yres2-50 Then dy2= -dy2
    If y<50 Then dy2= -dy2
    If x>xres2-50 Then dx2= -dx2
    If x < 50 Then dx2= -dx2
End Sub
 

Pop them all into a temporary folder and compile the screens as .dll
Then run the test file.
Just press esc to end the run.
TJF
Posts: 3474
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: Send commands from DLL to new Screen created by main fil

Postby TJF » Nov 03, 2013 9:01

@dodicat,

you needn't create a real (visible) SCREEN / window in the dll, its enought to initialize libfbgfx. Then create an IMAGE in the main modul and exchange the IMAGE PTR to the SUBs / FUNCTIONs in the dll.

dll.bas (compile with fbc -dylib dll.bas)

Code: Select all

' dll.bas

' just to use the GFX_NULL definition
#INCLUDE ONCE "fbgfx.bi"

' unvisible SCREEN to initialize libfbgfx
SCREENRES(8, 8, 32, 0, FB.GFX_NULL)

SUB draw_line CDECL ALIAS "draw_line" (BYVAL Buffer AS ANY PTR) EXPORT
  LINE Buffer, (20, 20)-(300, 180)
END SUB


main.bas

Code: Select all

'' main.bas

CONST scrw = 320, scrh = 200

#IFDEF __FB_UNIX__
VAR dylib = DYLIBLOAD("dll.so")
#ELSE
VAR dylib = DYLIBLOAD("dll.dll")
#ENDIF
IF 0 = dylib THEN ?"Failed to load library." : END 1

DIM draw_line AS SUB CDECL(BYVAL AS ANY PTR) = DYLIBSYMBOL(dylib, "draw_line")
IF 0 = draw_line THEN
  ? "Could not retrieve the draw_line() function's address"
ELSE
  SCREENRES(scrw, scrh, 32) '' here we make the visible SCREEN

  VAR img = IMAGECREATE(scrw, scrh, , 32)
  IF 0 = img THEN
    ? "Could not create image"
  ELSE
    draw_line(img) '' draw from dll on the IMAGE
    PUT(0, 0), img '' and PUT it on SCREEN

    SLEEP
    IMAGEDESTROY(img)
  END IF
END IF

Return to “Beginners”

Who is online

Users browsing this forum: No registered users and 7 guests