Hi group,
I'm trying to get printing my OpenGL scenes of aUCBLogo to work in Linux
(in M$Windows I already have that running). But I'm new to X, and what I
have so far crashes, but why?
Display *dis=(Display*)wxGetDisplay();
Drawable d=glXGetCurrentDrawable();
Pixmap pixmap=XCreatePixmap(dis, d, w, h, 64);
int attribList[] =
{ GLX_RGBA,
GLX_RED_SIZE, 8,
GLX_GREEN_SIZE, 8,
GLX_BLUE_SIZE, 8,
GLX_ALPHA_SIZE, 8,
GLX_DEPTH_SIZE, 16,
None
};
XVisualInfo *vis=glXChooseVisual(dis, 0, attribList);
GLXPixmap pm=glXCreateGLXPixmap(dis, vis, pixmap);
GLXContext context=glXCreateContext(dis, vis, 0, False);
glXMakeCurrent(dis, pm, context);
Then goes my rendering code, and at last I need something like Blit in
M$ Windows. Are there any samples on printing or offscreen rendering
under X? Can anybody help me, please?
Thanks for any suggestions,
Andreas
|
|
0
|
|
|
|
Reply
|
Andreas
|
2/28/2006 5:16:48 AM |
|
Andreas Micheler wrote:
> Hi group,
>
> I'm trying to get printing my OpenGL scenes of aUCBLogo to work
> in Linux (in M$Windows I already have that running). But I'm
> new to X, and what I have so far crashes, but why?
>
Instead of a Pixmap use a PBuffer.
Display *dis = (Display*)wxGetDisplay();
int scrnum = DefaultScreen( dpy );
GLXContext FBRC = glXGetCurrentContext();
GLXDrawable FBDC = glXGetCurrentDrawable();
if (dpy == NULL)
{
throw "unable to get device context";
}
if (!FBDC)
{
throw "unable to get render context";
}
int attrib[] =
{
GLX_DOUBLEBUFFER, False,
GLX_RED_SIZE, 8,
GLX_GREEN_SIZE, 8,
GLX_BLUE_SIZE, 8,
GLX_ALPHA_SIZE, 8,
GLX_STENCIL_SIZE, 8,
GLX_DEPTH_SIZE, 24,
GLX_RENDER_TYPE, GLX_RGBA_BIT,
GLX_DRAWABLE_TYPE, GLX_PBUFFER_BIT | GLX_WINDOW_BIT,
None
};
int PBattrib[] =
{
GLX_PBUFFER_WIDTH, width,
GLX_PBUFFER_HEIGHT, height,
GLX_LARGEST_PBUFFER, False,
None
};
// choose a pixel format that meets our minimum requirements
int count = 0;
GLXFBConfig *config =
glXChooseFBConfig(dpy, scrnum, attrib, &count);
if(config == NULL || count == 0)
{
throw "no fitting pbuffer pixel format found";
}
PBDC = glXCreatePbuffer(dpy, config[0], PBattrib);
PBRC = glXCreateNewContext(dpy, config[0], GLX_RGBA_TYPE, FBRC,
true);
XFree(config);
A few years ago the statement that X has nothing to do with
printing would have been true, but since about 3 years there is
a new technique called XPrint: A special XServer that sends it's
clients drawing commands to a printer instead of display device.
However I didn't use XPrint yet, so I can make no auggestions
about it. Anyway the more portable way to do it is like almost
all *nix Applications print: Generate a Postscript and send it
into lpr. And since you seem to use wxWidgets you don't have to
care about it, since wxWidgets provides you everything you need.
To print, render with OpenGL to the PBuffer, use glReadPixels to
get the image and print this with wxWidgets. Don't bother to
find an equvialent to inter DC bliting like it's possible in MS
Windows, since there is no one. BTW: You shouldn't use DC to DC
bliting in Windows, too. Using a PFD_DRAW_TO_BITMAP will kick
you into slow software rendering. Use PBuffers there instead,
too.
Wolfgang Draxinger
--
|
|
0
|
|
|
|
Reply
|
Wolfgang
|
2/28/2006 11:54:50 AM
|
|
Hallo Wolfgang,
Thanks for your detailed answer, very interesting all that. But I have
one more question: If I use PBuffers, then there must be enough memory
on my graphcs card to hold my image in printer resolution, mustn't it?
Or will the graphics card use virtual memory, to last resort on the hard
drive?
Wolfgang Draxinger wrote:
> Andreas Micheler wrote:
>
>
>>Hi group,
>>
>>I'm trying to get printing my OpenGL scenes of aUCBLogo to work
>>in Linux (in M$Windows I already have that running). But I'm
>>new to X, and what I have so far crashes, but why?
>>
>
>
>
> Instead of a Pixmap use a PBuffer.
>
> Display *dis = (Display*)wxGetDisplay();
> int scrnum = DefaultScreen( dpy );
> GLXContext FBRC = glXGetCurrentContext();
> GLXDrawable FBDC = glXGetCurrentDrawable();
>
> if (dpy == NULL)
> {
> throw "unable to get device context";
> }
> if (!FBDC)
> {
> throw "unable to get render context";
> }
> int attrib[] =
> {
> GLX_DOUBLEBUFFER, False,
> GLX_RED_SIZE, 8,
> GLX_GREEN_SIZE, 8,
> GLX_BLUE_SIZE, 8,
> GLX_ALPHA_SIZE, 8,
> GLX_STENCIL_SIZE, 8,
> GLX_DEPTH_SIZE, 24,
> GLX_RENDER_TYPE, GLX_RGBA_BIT,
> GLX_DRAWABLE_TYPE, GLX_PBUFFER_BIT | GLX_WINDOW_BIT,
> None
> };
>
> int PBattrib[] =
> {
> GLX_PBUFFER_WIDTH, width,
> GLX_PBUFFER_HEIGHT, height,
> GLX_LARGEST_PBUFFER, False,
> None
> };
>
> // choose a pixel format that meets our minimum requirements
> int count = 0;
> GLXFBConfig *config =
> glXChooseFBConfig(dpy, scrnum, attrib, &count);
>
> if(config == NULL || count == 0)
> {
> throw "no fitting pbuffer pixel format found";
> }
>
> PBDC = glXCreatePbuffer(dpy, config[0], PBattrib);
> PBRC = glXCreateNewContext(dpy, config[0], GLX_RGBA_TYPE, FBRC,
> true);
> XFree(config);
>
>
> A few years ago the statement that X has nothing to do with
> printing would have been true, but since about 3 years there is
> a new technique called XPrint: A special XServer that sends it's
> clients drawing commands to a printer instead of display device.
>
> However I didn't use XPrint yet, so I can make no auggestions
> about it. Anyway the more portable way to do it is like almost
> all *nix Applications print: Generate a Postscript and send it
> into lpr. And since you seem to use wxWidgets you don't have to
> care about it, since wxWidgets provides you everything you need.
>
> To print, render with OpenGL to the PBuffer, use glReadPixels to
> get the image and print this with wxWidgets. Don't bother to
> find an equvialent to inter DC bliting like it's possible in MS
> Windows, since there is no one. BTW: You shouldn't use DC to DC
> bliting in Windows, too. Using a PFD_DRAW_TO_BITMAP will kick
> you into slow software rendering. Use PBuffers there instead,
> too.
>
> Wolfgang Draxinger
|
|
0
|
|
|
|
Reply
|
Andreas
|
3/1/2006 3:23:51 PM
|
|
Andreas Micheler wrote:
> Hallo Wolfgang,
>
> Thanks for your detailed answer, very interesting all that. But
> I have one more question: If I use PBuffers, then there must be
> enough memory on my graphcs card to hold my image in printer
> resolution, mustn't it? Or will the graphics card use virtual
> memory, to last resort on the hard drive?
Google for "tiled rendering". delphi3d.net has example source
code for it.
Wolfgang Draxinger
--
|
|
0
|
|
|
|
Reply
|
Wolfgang
|
3/1/2006 11:14:13 PM
|
|
Thanks, Wolfgang!
Tiled rendering is the way to go, ok, I'll try this!
Cheers,
Andreas
Wolfgang Draxinger wrote:
> Andreas Micheler wrote:
>>Thanks for your detailed answer, very interesting all that. But
>>I have one more question: If I use PBuffers, then there must be
>>enough memory on my graphcs card to hold my image in printer
>>resolution, mustn't it? Or will the graphics card use virtual
>>memory, to last resort on the hard drive?
>
>
> Google for "tiled rendering". delphi3d.net has example source
> code for it.
>
> Wolfgang Draxinger
|
|
0
|
|
|
|
Reply
|
Andreas
|
3/2/2006 2:39:01 AM
|
|
|
4 Replies
402 Views
(page loaded in 0.043 seconds)
|