uses X11, X11_Displays, X11_Windows, xlib, X11_SHM_Extension, SYSV_Shared_Memory, SYSV, X11_Shared_Memory, X11_Pixmaps, type_fixes; procedure DrawLine(aBuffer : PByte; aX1, aY1, aX2, aY2 : TInteger); var fRowStride : TInteger; fT : TInteger; fLen : TInteger; fX : TInteger; fY : TInteger; begin fRowStride := 80 * 4; aBuffer := aBuffer + aY1 * fRowStride + aX1 * 4; Dec(aX2, aX1); Dec(aY2, aY1); if (aX2 = aX1) and (aY2 = aY1) then Exit; fLen := Trunc(SQRT(aX2 * aX2 + aY2 * aY2)); for fT := 0 to fLen - 1 do begin fX := aX2 * fT div fLen; fY := aY2 * fT div fLen; (aBuffer + fY * fRowStride + fX * 4 + 1)^ := $FF; end; end; var fEvent : TXEvent; fSharedMemory : ISharedMemory; fPixmap : IPixmap; fDisplay : PDisplay; fSegment : X11.ISHMSegment; fWindow : IWindow; begin fDisplay := X11_Displays.TDisplay.Default.Handle; with X11_Displays.TDisplay.Default do begin fWindow := X11_Windows.TWindow.Create(fDisplay, Screens[DefaultScreen].RootWindow, 0, 0, 100, 100, 2); fWindow.Title := 'test'; end; with X11_SHM_Extension.TSHMExtension.Open(fDisplay) do begin assert(BSharedMemoryPixmaps); end; fSharedMemory := SYSV_Shared_Memory.TSharedMemory.Create(100000{FIXME size}); fSegment := X11_Shared_Memory.TSHMSegment.Attach(fDisplay, fSharedMemory, False{read-only}); fPixmap := X11_Pixmaps.TPixmap.CreateSHM(fDisplay, fSegment, 80{width}, 80{height}, 24{depth}, fWindow{or nil}); FillChar(fSharedMemory.Address^, 100000, $30); DrawLine(fSharedMemory.Address, 10, 10, 100, 100); fWindow.BackgroundPixmap := fPixmap; fWindow.Map(); XNextEvent(X11_Displays.TDisplay.Default.Handle, @fEvent); { XClearWindow(xw->display,xw->window); XSync(xw->display,FALSE); /* act as XFlush and wait for all requests to be received and processed by the X server */ } end.