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 */
43 class EXPCL_PANDA_DISPLAY ParasiteBuffer : public GraphicsOutput {
44 public:
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
54 public:
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
65 private:
66 int _creation_flags;
67
68 public:
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
82 private:
83 static TypeHandle _type_handle;
84};
85
86#include "parasiteBuffer.I"
87
88#endif
GraphicsOutput::ready_flip
virtual void ready_flip()
This function will be called within the draw thread after end_frame() has been called on all windows,...
Definition graphicsOutput.cxx:1295
GraphicsOutput::begin_flip
virtual void begin_flip()
This function will be called within the draw thread after end_frame() has been called on all windows,...
Definition graphicsOutput.cxx:1282
GraphicsOutput::is_active
is_active
Returns true if the window is ready to be rendered into, false otherwise.
Definition graphicsOutput.h:155
GraphicsOutput::end_frame
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.
Definition graphicsOutput.cxx:1180
GraphicsOutput::end_flip
virtual void end_flip()
This function will be called within the draw thread after begin_flip() has been called on all windows...
Definition graphicsOutput.cxx:1306
GraphicsOutput::begin_frame
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.
Definition graphicsOutput.cxx:1170
GraphicsOutput::get_host
virtual GraphicsOutput * get_host()
This is normally called only from within make_texture_buffer().
Definition graphicsOutput.cxx:1064
GraphicsOutput::set_size_and_recalc
void set_size_and_recalc(int x, int y)
Changes the x_size and y_size, then recalculates structures that depend on size.
Definition graphicsOutput.cxx:1121
GraphicsOutput::flip_ready
virtual bool flip_ready() const
Returns true if a frame has been rendered and needs to be flipped, false otherwise.
Definition graphicsOutput.cxx:1054
ParasiteBuffer::set_size
void set_size(int x, int y)
This is called by the GraphicsEngine to request that the buffer resize itself.
Definition parasiteBuffer.cxx:79
ParasiteBuffer::ParasiteBuffer
ParasiteBuffer(GraphicsOutput *host, const std::string &name, int x_size, int y_size, int flags)
Normally, the ParasiteBuffer constructor is not called directly; these are created instead via the Gr...
Definition parasiteBuffer.cxx:24
Thread
A thread; that is, a lightweight process.
Definition thread.h:46
TypeHandle
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
graphicsOutput.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pandabase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
parasiteBuffer.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pointerTo.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
register_type
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
Definition register_type.I:22
texture.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.