70 PBuffer::PBuffer(
int _bits)
75 sbAttrib_.push_back(GLX_DOUBLEBUFFER); sbAttrib_.push_back(
true);
76 sbAttrib_.push_back(GLX_RED_SIZE); sbAttrib_.push_back(_bits);
77 sbAttrib_.push_back(GLX_GREEN_SIZE); sbAttrib_.push_back(_bits);
78 sbAttrib_.push_back(GLX_BLUE_SIZE); sbAttrib_.push_back(_bits);
79 sbAttrib_.push_back(GLX_ALPHA_SIZE); sbAttrib_.push_back(_bits);
80 sbAttrib_.push_back(GLX_DEPTH_SIZE); sbAttrib_.push_back(24);
81 sbAttrib_.push_back(GLX_RENDER_TYPE); sbAttrib_.push_back(GLX_RGBA_BIT);
82 sbAttrib_.push_back(GLX_DRAWABLE_TYPE); sbAttrib_.push_back(GLX_PBUFFER_BIT);
83 sbAttrib_.push_back(
None);
87 pbAttrib_.push_back(GLX_PBUFFER_WIDTH); pbAttrib_.push_back(100);
88 pbAttrib_.push_back(GLX_PBUFFER_HEIGHT); pbAttrib_.push_back(100);
89 pbAttrib_.push_back(GLX_PRESERVED_CONTENTS); pbAttrib_.push_back(
true);
90 pbAttrib_.push_back(
None);
94 dpy_ = glXGetCurrentDisplay();
95 currctx_ = glXGetCurrentContext();
96 currdraw_ = glXGetCurrentDrawable();
98 fbc_ = glXChooseFBConfig(dpy_, DefaultScreen(dpy_), &sbAttrib_[0], &n);
101 std::cerr <<
"glXChooseFBConfig failed.\n";
105 pbuf_ = glXCreatePbuffer(dpy_, fbc_[0], &pbAttrib_[0]);
108 std::cerr <<
"glXCreatePbuffer failed.\n";
112 pbufctx_ = glXCreateNewContext(dpy_, fbc_[0], GLX_RGBA_TYPE, currctx_,
true);
115 std::cerr <<
"glXCreateNewContextWithConfigSGIX failed.\n";
124 PBuffer::PBuffer(
int _w,
int _h,
int _bits)
129 sbAttrib_.push_back(GLX_DOUBLEBUFFER); sbAttrib_.push_back(
true);
130 sbAttrib_.push_back(GLX_RED_SIZE); sbAttrib_.push_back(_bits);
131 sbAttrib_.push_back(GLX_GREEN_SIZE); sbAttrib_.push_back(_bits);
132 sbAttrib_.push_back(GLX_BLUE_SIZE); sbAttrib_.push_back(_bits);
133 sbAttrib_.push_back(GLX_ALPHA_SIZE); sbAttrib_.push_back(_bits);
134 sbAttrib_.push_back(GLX_DEPTH_SIZE); sbAttrib_.push_back(24);
135 sbAttrib_.push_back(GLX_RENDER_TYPE); sbAttrib_.push_back(GLX_RGBA_BIT);
136 sbAttrib_.push_back(GLX_DRAWABLE_TYPE); sbAttrib_.push_back(GLX_PBUFFER_BIT);
137 sbAttrib_.push_back(
None);
140 pbAttrib_.push_back(GLX_PBUFFER_WIDTH); pbAttrib_.push_back(_w);
141 pbAttrib_.push_back(GLX_PBUFFER_HEIGHT); pbAttrib_.push_back(_h);
142 pbAttrib_.push_back(GLX_PRESERVED_CONTENTS); pbAttrib_.push_back(
true);
143 pbAttrib_.push_back(
None);
147 dpy_ = glXGetCurrentDisplay();
148 currctx_ = glXGetCurrentContext();
149 currdraw_ = glXGetCurrentDrawable();
151 fbc_ = glXChooseFBConfig(dpy_, DefaultScreen(dpy_), &sbAttrib_[0], &n);
154 std::cerr <<
"glXChooseFBConfig failed.\n";
158 pbuf_ = glXCreatePbuffer(dpy_, fbc_[0], &pbAttrib_[0]);
161 std::cerr <<
"glXCreatePbuffer failed.\n";
165 pbufctx_ = glXCreateNewContext(dpy_, fbc_[0], GLX_RGBA_TYPE, currctx_,
true);
168 std::cerr <<
"glXCreateNewContextWithConfigSGIX failed.\n";
179 glXDestroyContext(dpy_, currctx_);
180 glXDestroyPbuffer(dpy_, pbuf_);
187 void PBuffer::resize(
int _w,
int _h)
191 glXDestroyPbuffer(dpy_, pbuf_);
192 pbuf_ = glXCreatePbuffer(dpy_, fbc_[0], &pbAttrib_[0]);
193 if (!pbuf_) std::cerr <<
"Resizing pbuffer failed.\n";
209 void PBuffer::activate()
211 if (!glXMakeCurrent(dpy_, pbuf_, pbufctx_))
212 std::cerr <<
"PBuffer:activate() failed.\n";
219 void PBuffer::deactivate()
221 if (!glXMakeCurrent(dpy_, currdraw_, currctx_))
222 std::cerr <<
"PBuffer:deactivate() failed.\n";
229 const int PBuffer::width()
const
238 const int PBuffer::height()
const
Clear all attribute bits.