Home

Add

Edit

With Linenumbers

Code in Textfield

Download

#INCLIB "X11"
#INCLIB "Xext"

Type XScreen
    ext_data            As Any Ptr
    display         As Any Ptr
    root                As Integer
    Width               As Integer
    height          As Integer
    mwidth          As Integer
    mheight         As Integer
    ndepths         As Integer
    depths          As Any Ptr
    root_depth      As Integer
    root_visual     As Any Ptr
    default_gc      As Integer
    cmap                As Integer
    white_pixel     As Uinteger
    black_pixel     As Uinteger
    max_maps            As Integer
    min_maps            As Integer
    backing_store       As Integer
    save_unders     As Integer
    root_input_mask As Integer
End Type

Type Display
    XExtData            As Any Ptr
    private1            As Any Ptr
    fd                  As Integer
    private2            As Integer
    proto_major_version As Integer
    proto_minor_version As Integer
    vendor              As Zstring Ptr
    private3            As Integer
    private4            As Integer
    private5            As Integer
    private6            As Integer
    resource_alloc      As Any Ptr
    byte_order          As Integer
    bitmap_unit         As Integer
    bitmap_pad          As Integer
    bitmap_bit_order    As Integer
    nformats            As Integer
    pixmap_format       As Any Ptr
    private8            As Integer
    release             As Integer
    private9            As Any Ptr
    private10           As Any Ptr
    qlen                As Integer
    last_request_read   As Uinteger
    request             As Uinteger
    private11           As Byte Ptr
    private12           As Byte Ptr
    private13           As Byte Ptr
    private14           As Byte Ptr
    max_request_size    As Uinteger
    db                  As Any Ptr
    private15           As Any Ptr
    display_name        As Zstring Ptr
    default_screen      As Integer
    nscreens            As Integer
    screens             As XSCREEN Ptr
    motion_buffer       As Uinteger
    private16           As Uinteger
    min_keycode         As Integer
    max_keycode         As Integer
    private17           As Byte Ptr
    private18           As Byte Ptr
    private19           As Byte Ptr
    xdefaults           As Zstring Ptr
End Type

Type ShmSeg As Uinteger
Type XShmSegmentInfo
    shmseg              As ShmSeg
    shmid               As Integer
    shmaddr             As Byte Ptr
    readOnly            As Integer
End Type

#DEFINE DefaultScreen(dpy)  (dpy->default_screen)
#DEFINE DefaultDepth(dpy,s) (dpy->screens[s].root_depth)
#DEFINE DefaultVisual(dpy,s)(dpy->screens[s].root_visual)

Declare Function XOpenDisplay Cdecl Alias "XOpenDisplay"(Byval As String = "") As Display Ptr
Declare Function XQueryExtension Cdecl Alias "XQueryExtension"(Byval lpDisplay As Display Ptr, Byval ExtName As String, Byref major_opcode_return As Integer, Byref first_event_return As Integer, Byref first_error_return As Integer) As Integer
Declare Function XShmQueryExtension Cdecl Alias "XShmQueryExtension"(Byval lpDisplay As Display Ptr) As Integer
Declare Function XShmQueryVersion Cdecl Alias "XShmQueryVersion"(Byval lpDisplay As Display Ptr, Byval major As Integer Ptr, Byval minor As Integer Ptr, Byval pixmaps As Integer Ptr) As Integer
Declare Function XShmCreateImage Cdecl Alias "XCreateImage"(Byval lpDisplay As Display Ptr, Byval visual As Any Ptr, Byval depth As Integer, Byval Format As Integer, Byval offset As Integer, Byval shminfo As XShmSegmentInfo Ptr, Byval w As Uinteger, Byval height As Uinteger) As Any Ptr

Enum IMAGEFORMATS
    XYBitmap        = 0
    XYPixmap        = 1
    ZPixmap         = 2
End Enum

Dim TDisplay As Display Ptr = XOpenDisplay()
Dim V_ShmInfo As XShmSegmentInfo

Dim TI1 As Integer
Dim TI2 As Integer
Dim TI3 As Integer
Print "QE_SHM:" & XQueryExtension(TDisplay, "MIT-SHM", TI1, TI2, TI3)
Print "TI1:" & TI1
Print "TI2:" & TI2
Print "TI3:" & TI3
Print "XQE:" & XShmQueryExtension(TDisplay)
Dim V_XImg As Any Ptr = XShmCreateImage(TDisplay, DefaultVisual(TDisplay, DefaultScreen(TDisplay)), DefaultDepth(TDisplay, DefaultScreen(TDisplay)), ZPixmap, 0, @V_ShmInfo, 300, 300)
'Dim V_XImgas XImage Ptr = XCreateImage(TDisplay, DefaultVisual(TDisplay, DefaultScreen(TDisplay)), DefaultDepth(TDisplay, DefaultScreen(TDisplay)), ZPixmap, 0, @V_ShmInfo, V_Width, V_Height, 32, 0)
If V_XImg <> 0 Then
    Print "OK"
Else: Print "FAIL!"
End If
End 0