Panda3D
Loading...
Searching...
No Matches
parasiteBuffer.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 parasiteBuffer.h
10 * @author drose
11 * @date 2004-02-27
12 */
13
14#ifndef PARASITEBUFFER_H
15#define PARASITEBUFFER_H
16
17#include "pandabase.h"
18
19#include "graphicsOutput.h"
20#include "texture.h"
21#include "pointerTo.h"
22
23/**
24 * This is a special GraphicsOutput type that acts a lot like a
25 * GraphicsBuffer, effectively allowing rendering to an offscreen buffer,
26 * except it does not create any framebuffer space for itself. Instead, it
27 * renders into the framebuffer owned by some other GraphicsOutput.
28 *
29 * The x_size and y_size must therefore fit within the bounds of the source
30 * GraphicsOutput.
31 *
32 * Since the framebuffer will be subsequently cleared when the actual owner
33 * draws in it later, this only makes sense if we are going to copy the
34 * contents of the framebuffer to a texture immediately after we draw it.
35 * Thus, has_texture() is implicitly true for a ParasiteBuffer.
36 *
37 * This class is useful to render offscreen to a texture while preventing the
38 * waste of framebuffer memory for API's that are unable to render directly
39 * into a texture (and must render into a separate framebuffer first and then
40 * copy to texture). It is also the only way to render to a texture on API's
41 * that do not support offscreen rendering.
42 */
43class EXPCL_PANDA_DISPLAY ParasiteBuffer : public GraphicsOutput {
44public:
45 ParasiteBuffer(GraphicsOutput *host, const std::string &name,
46 int x_size, int y_size, int flags);
47
48PUBLISHED:
49 virtual ~ParasiteBuffer();
50
51 virtual bool is_active() const;
52 void set_size(int x, int y);
53
54public:
55 void set_size_and_recalc(int x, int y);
56 virtual bool flip_ready() const;
57 virtual void begin_flip();
58 virtual void ready_flip();
59 virtual void end_flip();
60
61 virtual bool begin_frame(FrameMode mode, Thread *current_thread);
62 virtual void end_frame(FrameMode mode, Thread *current_thread);
63 virtual GraphicsOutput *get_host();
64
65private:
66 int _creation_flags;
67
68public:
69 static TypeHandle get_class_type() {
70 return _type_handle;
71 }
72 static void init_type() {
73 GraphicsOutput::init_type();
74 register_type(_type_handle, "ParasiteBuffer",
75 GraphicsOutput::get_class_type());
76 }
77 virtual TypeHandle get_type() const {
78 return get_class_type();
79 }
80 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
81
82private:
83 static TypeHandle _type_handle;
84};
85
86#include "parasiteBuffer.I"
87
88#endif
This is a base class for the various different classes that represent the result of a frame of render...
virtual void ready_flip()
This function will be called within the draw thread after end_frame() has been called on all windows,...
virtual void begin_flip()
This function will be called within the draw thread after end_frame() has been called on all windows,...
is_active
Returns true if the window is ready to be rendered into, false otherwise.
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.
virtual void end_flip()
This function will be called within the draw thread after begin_flip() has been called on all windows...
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.
virtual GraphicsOutput * get_host()
This is normally called only from within make_texture_buffer().
void set_size_and_recalc(int x, int y)
Changes the x_size and y_size, then recalculates structures that depend on size.
virtual bool flip_ready() const
Returns true if a frame has been rendered and needs to be flipped, false otherwise.
This is a special GraphicsOutput type that acts a lot like a GraphicsBuffer, effectively allowing ren...
A thread; that is, a lightweight process.
Definition thread.h:46
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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.