PBuffers in SDL -< how to make glCopyTexSubImage2D work?

Hm… i got “invalid operation” as result of glGetError after the followinf
code:

GLXFBConfig* fbc;
Display *dpy;
Window win;
GLXContext PBufferCtx;
GLXContext WinCtx;
GLXPbuffer PBuffer;
int nElements;
const int sbAttrib[] ={ GLX_DRAWABLE_TYPE, GLX_PBUFFER_BIT,
GLX_RENDER_TYPE, GLX_RGBA_BIT, None };
const int pbAttrib[] = {GLX_PBUFFER_WIDTH, 1024,GLX_PBUFFER_HEIGHT,
1024,GLX_PRESERVED_CONTENTS, True,None };

dpy = glXGetCurrentDisplay();
fbc = glXChooseFBConfig(dpy, DefaultScreen(dpy), sbAttrib,
&nElements);
cerr << “NELEMENTS” << nElements << endl;
PBuffer = glXCreatePbuffer (dpy, fbc[2], pbAttrib);
PBufferCtx = glXCreateNewContext( dpy, fbc[2], GLX_RGBA_TYPE, 0,
GL_TRUE);

GLXDrawable drawable = glXGetCurrentDrawable();
dpy = glXGetCurrentDisplay();
WinCtx = glXGetCurrentContext();

    if (glXMakeContextCurrent(dpy, PBuffer,PBuffer, PBufferCtx)==false) 
    //if (glXMakeCurrent(dpy, PBuffer, PBufferCtx)==false) 
            cerr << "WWWWW" << endl; 

    err = glGetError(); 
    if (err) 
            cerr  << "xa0=ERROR:" <<  gluErrorString(err) << ":" << errno 

<<endl;

… a lot of drawing, changing viewport, matrices…

// HERE:
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0 /GL_DEPTH_COMPONENT/,0, 0, 0,
1024,1024); // This gave me error “invalid operation”
//----- Commenting out this line will cause that no errors will appear,
// but of course i need this line to work - this is part of
// shadow mapping algorithm. I wanted to use pbuffers to speed it out.


if (glXMakeCurrent(dpy,drawable, WinCtx) == false) //
cerr << “OOOOOPS” << endl;

… a lot of drawing, changing matrices…

SDL_GL_SwapBuffers();
:wq

What’s happening? Is my pbuffer not valid after the second pass, but why, I
have set GLX_PRESERVED_CONTENTS to True? Anyway, MakeContext returns true, so
why the error?

Where should i start to search for errors? Any suggestions?

I have glx 1.3, glu 1.3, opengl 1.4, NVidia RIVA TNT2/TNT2 Pro, driver:
NVIDIA Linux x86 nvidia.o Kernel Module 1.0-5328

Ok, i made it work - i made PBufferCtx with glXCreateNewContext( … etc)
sharing with WinCtx. It now works, but it works even SLOWER than before!
Aren’t pbuffers supposed to speed things up? What i am doing wrong?!?!

Arkadiusz Danilecki <szopen europe.com> writes:

Ok, i made it work - i made PBufferCtx with glXCreateNewContext( … etc)
sharing with WinCtx. It now works, but it works even SLOWER than before!
Aren’t pbuffers supposed to speed things up? What i am doing wrong?!?!

Hehehe… I checked supported extensions in NVIDIA site… I had no idea that
my graphic card is THAT old. So, because ARB_shadow is in OpenGL 1.4 it does
support it, but in software mode :slight_smile: And that’s explains everything :slight_smile: