I am using official fbc 1.05.0-win64 and latest built iup/cd library from iup official website
the following code is adapted from Phix language's demo on https://rosettacode.org/wiki/Draw_a_pixel because the official C demo http://webserver2.tecgraf.puc-rio.br/cd ... src_c.html looks some long for me to grasp the main idea
however, when I run the EXE file, it crash soon. And when I compile I get( maybe all of them can be handled via cast. is cast safe?)
the codesimple_cd.bas(12) warning 3(1): Passing different pointer types, at parameter 1
of CDCANVASACTIVATE()
simple_cd.bas(13) warning 3(1): Passing different pointer types, at parameter 1
of CDCANVASPIXEL()
simple_cd.bas(14) warning 3(1): Passing different pointer types, at parameter 1
of CDCANVASFLUSH()
simple_cd.bas(19) warning 4(1): Suspicious pointer assignment
simple_cd.bas(28) warning 3(1): Passing different pointer types, at parameter 3
of IUPSETCALLBACK()
simple_cd.bas(31) warning 3(1): Passing different pointer types, at parameter 3
of IUPSETCALLBACK()
Code: Select all
#include"string.bi"
#include once"crt/stdio.bi"
#include once"IUP/iup.bi"
#include once"IUP/iupcontrols.bi"
#include once"IUP/iupcbs.bi"
#include once"cd/cd.bi"
#include once"cd/cdiup.bi"
dim shared as Ihandle ptr cdcanvas
function redraw_cb cdecl (byval ih as Ihandle ptr , byval posx as integer, byval posy as integer) as integer
cdCanvasActivate(cdcanvas)
cdCanvasPixel(cdcanvas, 100, 100, CD_RED)
cdCanvasFlush(cdcanvas)
return IUP_DEFAULT
end function
function map_cb cdecl (byval ih as Ihandle ptr ) as integer
cdcanvas = cdCreateCanvas(CD_IUP, ih)
return IUP_DEFAULT
end function
sub main()
IupOpen(NULL, NULL)
IupControlsOpen()
var canvas = IupCanvas(0)
IupSetAttribute(canvas, "RASTERSIZE", "320x240")
IupSetCallback(canvas, "MAP_CB", @("map_cb"))
var dlg = IupDialog(canvas)
IupSetAttribute(dlg, "TITLE", "Draw a pixel")
IupSetCallback(canvas, "ACTION", @("redraw_cb"))
' ~ IupCloseOnEscape(dlg)
IupShow(dlg)
IupMainLoop()
IupClose()
end sub
main()