well now I am trying to switch to "regular" XShmPutImage, but it doesn't
work for me
a few comments to the code: my visual is 16bpp 565 RGB the following code
misses smth, please spend two minutes in Draw function, put your attention
that window is allocated in the other place, what I get on screen are two
black windows :( may be I miss something, Should I handle Exposure event in
some special way in my event loop?
class XVideoRenderer : public IVideoRenderer {
public:
XVideoRenderer();
virtual ~XVideoRenderer();
virtual int Initialize(void *pWindowHandle);
virtual int Draw(unsigned char *pFrameBuffer,
long nFrameBufferSize,
unsigned short nWidth,
unsigned short nHeight,
unsigned short nBpp,
void *pLiveVideoWindow = 0,
bool bUpdate = false,
unsigned long dwFlags = 0);
virtual int Finalize();
private:
int isInitialized; file://part of initialization performed on first draw
Window win; file://X window handle
XWindowAttributes *win_attr;
GC gc; file://Graphic context
Display *dpy; file://X server connection
XImage *x_image; file://shared memory based image
XShmSegmentInfo x_shminfo; file://shared memory info struct
int cur_width, cur_height; file://current height and width of win
void get_win_size(int *width, int *height); file://get the size of win
from Xserver
};
int XVideoRenderer::Initialize(void *pWindowHandle)
{
win = (Window)pWindowHandle;
dpy = XOpenDisplay(NULL);
win_attr = (XWindowAttributes *)malloc(sizeof(XWindowAttributes));
XGetWindowAttributes(dpy, win, win_attr);
gc = XCreateGC(dpy, win, 0, 0);
return 0;
}
int XVideoRenderer::Draw(unsigned char *pFrameBuffer,
long nFrameBufferSize,
unsigned short nWidth,
unsigned short nHeight,
unsigned short nBpp,
void *pLiveVideoWindow = 0,
bool bUpdate = false,
unsigned long dwFlags = 0)
{
if (!isInitialized)
{
printf("Initalizing\n");
x_image = XShmCreateImage(dpy, win_attr->visual, win_attr->depth,
ZPixmap, 0, &x_shminfo, nWidth,
nHeight);
x_shminfo.shmid = shmget(IPC_PRIVATE, x_image->bytes_per_line *
x_image->height, IPC_CREAT |
0777);
x_shminfo.shmaddr = x_image->data = (char *)shmat(x_shminfo.shmid,
0, 0);
x_shminfo.readOnly = False;
XShmAttach(dpy, &x_shminfo);
isInitialized = 1;
}
// check for window size
int new_width, new_height;
get_win_size(&new_width, &new_height);
if ((new_width != nWidth) || (new_height != nHeight))
{
XResizeWindow(dpy, win, nWidth, nHeight);
}
memcpy(x_image->data, pFrameBuffer, nWidth * nHeight * 2);
XShmPutImage(dpy, win, gc, x_image,
0, 0, x_image->width, x_image->height,
0, 0, False);
XFlush(dpy);
return 0;
}
thank you in advance,
Michael
_______________________________________________
Xpert mailing list
[EMAIL PROTECTED]
http://XFree86.Org/mailman/listinfo/xpert