Panda3D
Loading...
Searching...
No Matches
wglGraphicsStateGuardian.h
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file wglGraphicsStateGuardian.h
10 * @author drose
11 * @date 2003-01-27
12 */
13
14#ifndef WGLGRAPHICSSTATEGUARDIAN_H
15#define WGLGRAPHICSSTATEGUARDIAN_H
16
17#include "pandabase.h"
18
19#include "glgsg.h"
20
21// This must be included after we have included glgsg.h (which includes gl.h).
22#include "wglext.h"
23
24/**
25 * A tiny specialization on GLGraphicsStateGuardian to add some wgl-specific
26 * information.
27 */
28class wglGraphicsStateGuardian : public GLGraphicsStateGuardian {
29public:
31 wglGraphicsStateGuardian *share_with);
33
34 INLINE int get_pfnum() const;
35 INLINE bool pfnum_supports_pbuffer() const;
36 INLINE const FrameBufferProperties &get_fb_properties() const;
37 bool fail_pfnum();
38
39 INLINE bool made_context() const;
40 INLINE HGLRC get_context(HDC hdc);
41 void get_properties(FrameBufferProperties &properties, HDC hdc, int pfnum);
42 bool get_properties_advanced(FrameBufferProperties &properties, HDC hdc, int pfnum);
43 void choose_pixel_format(const FrameBufferProperties &properties, bool need_pbuffer);
44 virtual void reset();
45
46 INLINE HDC get_twindow_dc();
47 INLINE bool get_supports_wgl_render_texture() const;
48
49 static bool get_gamma_table(void);
50 static bool static_set_gamma(bool restore, PN_stdfloat gamma);
51 bool set_gamma(PN_stdfloat gamma);
52 void restore_gamma();
53 static void atexit_function(void);
54
55
56protected:
57 virtual void get_extra_extensions();
58 virtual void *do_get_extension_func(const char *name);
59
60private:
61 void make_context(HDC hdc);
62 HGLRC get_share_context() const;
63 void redirect_share_pool(wglGraphicsStateGuardian *share_with);
64
65
66 bool make_twindow();
67 void release_twindow();
68
69 static void register_twindow_class();
70
71 // We have to save a pointer to the GSG we intend to share texture context
72 // with, since we don't create our own context in the constructor.
73 PT(wglGraphicsStateGuardian) _share_with;
74
75 // These properties are for all wglGraphicsWindow that use this gsg.
76 FrameBufferProperties _pfnum_properties;
77 bool _pfnum_supports_pbuffer;
78 int _pfnum;
79
80 // This pfnum is the pfnum chosen via DescribePixelFormat. It is used in
81 // case the one returned by wglChoosePixelFormatARB() fails.
82 FrameBufferProperties _pre_pfnum_properties;
83 int _pre_pfnum;
84
85 bool _made_context;
86 HGLRC _context;
87
88 HWND _twindow;
89 HDC _twindow_dc;
90
91 static const char * const _twindow_class_name;
92 static bool _twindow_class_registered;
93
94public:
95 bool _supports_swap_control;
96 PFNWGLSWAPINTERVALEXTPROC _wglSwapIntervalEXT;
97
98 bool _supports_pbuffer;
99 PFNWGLCREATEPBUFFERARBPROC _wglCreatePbufferARB;
100 PFNWGLGETPBUFFERDCARBPROC _wglGetPbufferDCARB;
101 PFNWGLRELEASEPBUFFERDCARBPROC _wglReleasePbufferDCARB;
102 PFNWGLDESTROYPBUFFERARBPROC _wglDestroyPbufferARB;
103 PFNWGLQUERYPBUFFERARBPROC _wglQueryPbufferARB;
104
105 bool _supports_pixel_format;
106 PFNWGLGETPIXELFORMATATTRIBIVARBPROC _wglGetPixelFormatAttribivARB;
107 PFNWGLGETPIXELFORMATATTRIBFVARBPROC _wglGetPixelFormatAttribfvARB;
108 PFNWGLCHOOSEPIXELFORMATARBPROC _wglChoosePixelFormatARB;
109
110 bool _supports_wgl_multisample;
111
112 bool _supports_wgl_render_texture;
113 PFNWGLBINDTEXIMAGEARBPROC _wglBindTexImageARB;
114 PFNWGLRELEASETEXIMAGEARBPROC _wglReleaseTexImageARB;
115 PFNWGLSETPBUFFERATTRIBARBPROC _wglSetPbufferAttribARB;
116
117 PFNWGLCREATECONTEXTATTRIBSARBPROC _wglCreateContextAttribsARB;
118
119public:
120 static TypeHandle get_class_type() {
121 return _type_handle;
122 }
123 static void init_type() {
124 GLGraphicsStateGuardian::init_type();
125 register_type(_type_handle, "wglGraphicsStateGuardian",
126 GLGraphicsStateGuardian::get_class_type());
127 }
128 virtual TypeHandle get_type() const {
129 return get_class_type();
130 }
131 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
132
133private:
134 static TypeHandle _type_handle;
135
136 friend class wglGraphicsBuffer;
137};
138
140
141#endif
A container for the various kinds of properties we might ask to have on a graphics frameBuffer before...
This class is the main interface to controlling the render process.
An object to create GraphicsOutputs that share a particular 3-D API.
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
An offscreen render buffer.
A tiny specialization on GLGraphicsStateGuardian to add some wgl-specific information.
HDC get_twindow_dc()
Returns the DC associated with the temporary, invisible window that was created with the gsg to query...
bool set_gamma(PN_stdfloat gamma)
Non static version of setting gamma.
virtual void reset()
Resets all internal state as if the gsg were newly created.
bool get_supports_wgl_render_texture() const
Returns true if this particular GSG can render from a wglGraphicsBuffer directly into a texture,...
void get_properties(FrameBufferProperties &properties, HDC hdc, int pfnum)
Gets the FrameBufferProperties to match the indicated pixel format descriptor.
void choose_pixel_format(const FrameBufferProperties &properties, bool need_pbuffer)
Selects a pixel format for all the windows and buffers that use this gsg.
bool get_properties_advanced(FrameBufferProperties &properties, HDC hdc, int pfnum)
Gets the FrameBufferProperties to match the indicated pixel format descriptor, using the WGL extensio...
static bool static_set_gamma(bool restore, PN_stdfloat gamma)
Static function for setting gamma which is needed for atexit.
static bool get_gamma_table(void)
Static function for getting the original gamma.
int get_pfnum() const
Returns the pixel format number chosen for windows that use this context.
bool made_context() const
Returns true if the GSG has had a context made for it already, false otherwise.
static void atexit_function(void)
This function is passed to the atexit function.
bool pfnum_supports_pbuffer() const
Returns true if the gsg's pixel format is capable of supporting a pbuffer.
void restore_gamma()
Restore original gamma.
bool fail_pfnum()
This is called by wglGraphicsWindow when it finds it cannot use the pfnum determined by the GSG.
const FrameBufferProperties & get_fb_properties() const
Returns the properties of the pixel format that was chosen for this gsg.
HGLRC get_context(HDC hdc)
Returns the GL context associated with the GSG.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.