Panda3D
wglGraphicsBuffer.h
1 // Filename: wglGraphicsBuffer.h
2 // Created by: drose (08Feb04)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef WGLGRAPHICSBUFFER_H
16 #define WGLGRAPHICSBUFFER_H
17 
18 #include "pandabase.h"
19 #include "graphicsBuffer.h"
20 #include "glgsg.h"
21 
22 // This must be included after we have included glgsg.h (which
23 // includes gl.h).
24 #include "wglext.h"
25 #ifndef WIN32_LEAN_AND_MEAN
26 #define WIN32_LEAN_AND_MEAN 1
27 #endif
28 #include <windows.h>
29 
30 ////////////////////////////////////////////////////////////////////
31 // Class : wglGraphicsBuffer
32 // Description : An offscreen render buffer. In OpenGL under Windows,
33 // this simply renders into a window that is never made
34 // visible. There's a Windows interface for rendering
35 // into a DIB, but this puts restrictions on the kind of
36 // pixelformat we can use, and thus makes it difficult
37 // to support one GSG rendering into an offscreen buffer
38 // and also into a window.
39 ////////////////////////////////////////////////////////////////////
40 class EXPCL_PANDAGL wglGraphicsBuffer : public GraphicsBuffer {
41 public:
43  const string &name,
44  const FrameBufferProperties &fb_prop,
45  const WindowProperties &win_prop,
46  int flags,
48  GraphicsOutput *host);
49  virtual ~wglGraphicsBuffer();
50 
51  virtual bool begin_frame(FrameMode mode, Thread *current_thread);
52  virtual void end_frame(FrameMode mode, Thread *current_thread);
53 
54  virtual void select_target_tex_page(int page);
55 
56  virtual void process_events();
57 
58  virtual bool get_supports_render_texture() const;
59 
60 protected:
61  virtual void close_buffer();
62  virtual bool open_buffer();
63 
64 private:
65  void bind_texture_to_pbuffer();
66  bool rebuild_bitplanes();
67  void release_pbuffer();
68 
69  static void process_1_event();
70 
71  HPBUFFERARB _pbuffer;
72  HDC _pbuffer_dc;
73  bool _pbuffer_mipmap;
74  Texture::TextureType _pbuffer_type;
75  int _pbuffer_sizex;
76  int _pbuffer_sizey;
77  PT(Texture) _pbuffer_bound;
78 
79 public:
80  static TypeHandle get_class_type() {
81  return _type_handle;
82  }
83  static void init_type() {
84  GraphicsBuffer::init_type();
85  register_type(_type_handle, "wglGraphicsBuffer",
86  GraphicsBuffer::get_class_type());
87  }
88  virtual TypeHandle get_type() const {
89  return get_class_type();
90  }
91  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
92 
93 private:
94  static TypeHandle _type_handle;
95 
96  friend class wglGraphicsStateGuardian;
97 };
98 
99 #include "wglGraphicsBuffer.I"
100 
101 #endif
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...
Definition: texture.h:75
virtual void end_frame(FrameMode mode, Thread *current_thread)
This function will be called within the draw thread after rendering is completed for a given frame...
A tiny specialization on GLGraphicsStateGuardian to add some wgl-specific information.
virtual void select_target_tex_page(int page)
Called internally when the window is in render-to-a-texture mode and we are in the process of renderi...
virtual void process_events()
Honor any requests recently made via request_open() or request_close().
A container for the various kinds of properties we might ask to have on a graphics window before we o...
An offscreen buffer for rendering into.
An object to create GraphicsOutputs that share a particular 3-D API.
Definition: graphicsPipe.h:58
virtual bool get_supports_render_texture() const
Returns true if this particular GraphicsOutput can render directly into a texture, or false if it must always copy-to-texture at the end of each frame to achieve this effect.
This is a base class for the various different classes that represent the result of a frame of render...
An offscreen render buffer.
A thread; that is, a lightweight process.
Definition: thread.h:51
Encapsulates all the communication with a particular instance of a given rendering backend...
This class is the main interface to controlling the render process.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
A container for the various kinds of properties we might ask to have on a graphics frameBuffer before...
virtual bool begin_frame(FrameMode mode, Thread *current_thread)
This function will be called within the draw thread before beginning rendering for a given frame...