64 PBuffer::PBuffer(
int _bits)
69 sbAttrib_.push_back(GLX_DOUBLEBUFFER); sbAttrib_.push_back(
true);
70 sbAttrib_.push_back(GLX_RED_SIZE); sbAttrib_.push_back(_bits);
71 sbAttrib_.push_back(GLX_GREEN_SIZE); sbAttrib_.push_back(_bits);
72 sbAttrib_.push_back(GLX_BLUE_SIZE); sbAttrib_.push_back(_bits);
73 sbAttrib_.push_back(GLX_ALPHA_SIZE); sbAttrib_.push_back(_bits);
74 sbAttrib_.push_back(GLX_DEPTH_SIZE); sbAttrib_.push_back(24);
75 sbAttrib_.push_back(GLX_RENDER_TYPE); sbAttrib_.push_back(GLX_RGBA_BIT);
76 sbAttrib_.push_back(GLX_DRAWABLE_TYPE); sbAttrib_.push_back(GLX_PBUFFER_BIT);
77 sbAttrib_.push_back(
None);
81 pbAttrib_.push_back(GLX_PBUFFER_WIDTH); pbAttrib_.push_back(100);
82 pbAttrib_.push_back(GLX_PBUFFER_HEIGHT); pbAttrib_.push_back(100);
83 pbAttrib_.push_back(GLX_PRESERVED_CONTENTS); pbAttrib_.push_back(
true);
84 pbAttrib_.push_back(
None);
88 dpy_ = glXGetCurrentDisplay();
89 currctx_ = glXGetCurrentContext();
90 currdraw_ = glXGetCurrentDrawable();
92 fbc_ = glXChooseFBConfig(dpy_, DefaultScreen(dpy_), &sbAttrib_[0], &n);
95 std::cerr <<
"glXChooseFBConfig failed.\n";
99 pbuf_ = glXCreatePbuffer(dpy_, fbc_[0], &pbAttrib_[0]);
102 std::cerr <<
"glXCreatePbuffer failed.\n";
106 pbufctx_ = glXCreateNewContext(dpy_, fbc_[0], GLX_RGBA_TYPE, currctx_,
true);
109 std::cerr <<
"glXCreateNewContextWithConfigSGIX failed.\n";
118 PBuffer::PBuffer(
int _w,
int _h,
int _bits)
123 sbAttrib_.push_back(GLX_DOUBLEBUFFER); sbAttrib_.push_back(
true);
124 sbAttrib_.push_back(GLX_RED_SIZE); sbAttrib_.push_back(_bits);
125 sbAttrib_.push_back(GLX_GREEN_SIZE); sbAttrib_.push_back(_bits);
126 sbAttrib_.push_back(GLX_BLUE_SIZE); sbAttrib_.push_back(_bits);
127 sbAttrib_.push_back(GLX_ALPHA_SIZE); sbAttrib_.push_back(_bits);
128 sbAttrib_.push_back(GLX_DEPTH_SIZE); sbAttrib_.push_back(24);
129 sbAttrib_.push_back(GLX_RENDER_TYPE); sbAttrib_.push_back(GLX_RGBA_BIT);
130 sbAttrib_.push_back(GLX_DRAWABLE_TYPE); sbAttrib_.push_back(GLX_PBUFFER_BIT);
131 sbAttrib_.push_back(
None);
134 pbAttrib_.push_back(GLX_PBUFFER_WIDTH); pbAttrib_.push_back(_w);
135 pbAttrib_.push_back(GLX_PBUFFER_HEIGHT); pbAttrib_.push_back(_h);
136 pbAttrib_.push_back(GLX_PRESERVED_CONTENTS); pbAttrib_.push_back(
true);
137 pbAttrib_.push_back(
None);
141 dpy_ = glXGetCurrentDisplay();
142 currctx_ = glXGetCurrentContext();
143 currdraw_ = glXGetCurrentDrawable();
145 fbc_ = glXChooseFBConfig(dpy_, DefaultScreen(dpy_), &sbAttrib_[0], &n);
148 std::cerr <<
"glXChooseFBConfig failed.\n";
152 pbuf_ = glXCreatePbuffer(dpy_, fbc_[0], &pbAttrib_[0]);
155 std::cerr <<
"glXCreatePbuffer failed.\n";
159 pbufctx_ = glXCreateNewContext(dpy_, fbc_[0], GLX_RGBA_TYPE, currctx_,
true);
162 std::cerr <<
"glXCreateNewContextWithConfigSGIX failed.\n";
173 glXDestroyContext(dpy_, currctx_);
174 glXDestroyPbuffer(dpy_, pbuf_);
181 void PBuffer::resize(
int _w,
int _h)
185 glXDestroyPbuffer(dpy_, pbuf_);
186 pbuf_ = glXCreatePbuffer(dpy_, fbc_[0], &pbAttrib_[0]);
187 if (!pbuf_) std::cerr <<
"Resizing pbuffer failed.\n";
203 void PBuffer::activate()
205 if (!glXMakeCurrent(dpy_, pbuf_, pbufctx_))
206 std::cerr <<
"PBuffer:activate() failed.\n";
213 void PBuffer::deactivate()
215 if (!glXMakeCurrent(dpy_, currdraw_, currctx_))
216 std::cerr <<
"PBuffer:deactivate() failed.\n";
223 const int PBuffer::width()
const 232 const int PBuffer::height()
const Clear all attribute bits.