15 #include "wglGraphicsPipe.h" 16 #include "config_wgldisplay.h" 17 #include "config_windisplay.h" 18 #include "wglGraphicsWindow.h" 19 #include "wglGraphicsBuffer.h" 21 typedef enum {Software, MCD, ICD} OGLDriverType;
24 bool wglGraphicsPipe::_current_valid;
25 HDC wglGraphicsPipe::_current_hdc;
26 HGLRC wglGraphicsPipe::_current_hglrc;
35 _current_valid =
false;
53 void wglGraphicsPipe::
54 wgl_make_current(HDC hdc, HGLRC hglrc,
PStatCollector *collector) {
55 if ((_current_valid) &&
56 (_current_hdc == hdc) &&
57 (_current_hglrc == hglrc)) {
60 _current_valid =
true;
62 _current_hglrc = hglrc;
66 res = wglMakeCurrent(hdc, hglrc);
68 res = wglMakeCurrent(hdc, hglrc);
106 make_output(
const string &name,
122 DCAST_INTO_R(wglgsg, gsg, NULL);
129 wglgsg -> get_supports_wgl_render_texture() &&
130 support_render_texture;
136 if (((flags&BF_require_parasite)!=0)||
137 ((flags&BF_refuse_window)!=0)||
138 ((flags&BF_resizeable)!=0)||
139 ((flags&BF_size_track_host)!=0)||
140 ((flags&BF_rtt_cumulative)!=0)||
141 ((flags&BF_can_bind_color)!=0)||
142 ((flags&BF_can_bind_every)!=0)||
143 ((flags&BF_can_bind_layered)!=0)) {
146 if ((flags & BF_fb_props_optional)==0) {
147 if ((fb_prop.get_aux_rgba() > 0)||
148 (fb_prop.get_aux_hrgba() > 0)||
149 (fb_prop.get_aux_float() > 0)) {
160 if (!gl_support_fbo || host == NULL ||
161 (flags & (BF_require_parasite | BF_require_window)) != 0) {
166 if ((flags & BF_fb_props_optional) == 0) {
167 if (fb_prop.get_indexed_color() ||
168 fb_prop.get_back_buffers() > 0 ||
169 fb_prop.get_accum_bits() > 0) {
173 if (wglgsg != NULL && wglgsg->is_valid() && !wglgsg->needs_reset()) {
174 if (!wglgsg->_supports_framebuffer_object ||
175 wglgsg->_glDrawBuffers == NULL) {
183 return new GLGraphicsBuffer(engine,
this, name, fb_prop, win_prop,
190 if (((flags&BF_require_parasite)!=0)||
191 ((flags&BF_require_window)!=0)||
192 ((flags&BF_can_bind_layered)!=0)) {
196 (wglgsg->is_valid()) &&
197 (!wglgsg->needs_reset()) &&
198 !wglgsg->_supports_pbuffer) {
203 if (((flags&BF_rtt_cumulative)!=0)||
204 ((flags&BF_can_bind_every)!=0)) {
213 if ((flags & BF_fb_props_optional) == 0) {
214 if ((fb_prop.get_aux_rgba() > 0)||
215 (fb_prop.get_aux_rgba() > 0)||
216 (fb_prop.get_aux_float() > 0)) {
223 (wglgsg->is_valid()) &&
224 (!wglgsg->needs_reset()) &&
259 string wglGraphicsPipe::
260 format_pfd_flags(DWORD pfd_flags) {
265 static FlagDef flag_def[] = {
266 { PFD_DRAW_TO_WINDOW,
"PFD_DRAW_TO_WINDOW" },
267 { PFD_DRAW_TO_BITMAP,
"PFD_DRAW_TO_BITMAP" },
268 { PFD_SUPPORT_GDI,
"PFD_SUPPORT_GDI" },
269 { PFD_SUPPORT_OPENGL,
"PFD_SUPPORT_OPENGL" },
270 { PFD_GENERIC_ACCELERATED,
"PFD_GENERIC_ACCELERATED" },
271 { PFD_GENERIC_FORMAT,
"PFD_GENERIC_FORMAT" },
272 { PFD_NEED_PALETTE,
"PFD_NEED_PALETTE" },
273 { PFD_NEED_SYSTEM_PALETTE,
"PFD_NEED_SYSTEM_PALETTE" },
274 { PFD_DOUBLEBUFFER,
"PFD_DOUBLEBUFFER" },
275 { PFD_STEREO,
"PFD_STEREO" },
276 { PFD_SWAP_LAYER_BUFFERS,
"PFD_SWAP_LAYER_BUFFERS" },
277 { PFD_SWAP_COPY,
"PFD_SWAP_COPY" },
278 { PFD_SWAP_EXCHANGE,
"PFD_SWAP_EXCHANGE" },
280 static const int num_flag_defs =
sizeof(flag_def) /
sizeof(FlagDef);
284 const char *sep =
"";
285 bool got_any =
false;
286 for (
int i = 0; i < num_flag_defs; i++) {
287 if (pfd_flags & flag_def[i].flag) {
288 out << sep << flag_def[i].name;
289 pfd_flags &= ~flag_def[i].flag;
295 if (pfd_flags != 0 || !got_any) {
296 out << sep << hex <<
"0x" << pfd_flags << dec;
virtual string get_interface_name() const
Returns the name of the rendering interface associated with this GraphicsPipe.
A lightweight class that can be used to automatically start and stop a PStatCollector around a sectio...
A tiny specialization on GLGraphicsStateGuardian to add some wgl-specific information.
A lightweight class that represents a single element that may be timed and/or counted via stats...
A container for the various kinds of properties we might ask to have on a graphics window before we o...
An object to create GraphicsOutputs that share a particular 3-D API.
A single graphics window for rendering OpenGL under Microsoft Windows.
This is a base class for the various different classes that represent the result of a frame of render...
This graphics pipe represents the interface for creating OpenGL graphics windows on the various Windo...
const FrameBufferProperties & get_fb_properties() const
Returns the properties of the pixel format that was chosen for this gsg.
An offscreen render buffer.
bool pfnum_supports_pbuffer() const
Returns true if the gsg's pixel format is capable of supporting a pbuffer.
Encapsulates all the communication with a particular instance of a given rendering backend...
bool subsumes(const FrameBufferProperties &other) const
Returns true if this set of properties makes strictly greater or equal demands of the framebuffer tha...
This class is the main interface to controlling the render process.
TypeHandle is the identifier used to differentiate C++ class types.
A container for the various kinds of properties we might ask to have on a graphics frameBuffer before...