Panda3D
Loading...
Searching...
No Matches
graphicsBuffer.cxx
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 graphicsBuffer.cxx
10 * @author drose
11 * @date 2004-02-06
12 */
13
14#include "graphicsBuffer.h"
15
16TypeHandle GraphicsBuffer::_type_handle;
17
18/**
19 * Normally, the GraphicsBuffer constructor is not called directly; these are
20 * created instead via the GraphicsEngine::make_buffer() function.
21 */
22GraphicsBuffer::
23GraphicsBuffer(GraphicsEngine *engine, GraphicsPipe *pipe,
24 const std::string &name,
25 const FrameBufferProperties &fb_prop,
26 const WindowProperties &win_prop, int flags,
28 GraphicsOutput *host) :
29 GraphicsOutput(engine, pipe, name, fb_prop, win_prop, flags, gsg, host, false)
30{
31#ifdef DO_MEMORY_USAGE
32 MemoryUsage::update_type(this, this);
33#endif
34
35 if (display_cat.is_debug()) {
36 display_cat.debug()
37 << "Creating new offscreen buffer " << get_name() << "\n";
38 }
39
40 _overlay_display_region->compute_pixels(_size.get_x(), _size.get_y());
41 _open_request = OR_none;
42}
43
44/**
45 *
46 */
47GraphicsBuffer::
48~GraphicsBuffer() {
49}
50
51/**
52 * This is called by the GraphicsEngine to request that the buffer resize
53 * itself. Although calls to get the size will return the new value, much of
54 * the actual resizing work doesn't take place until the next begin_frame.
55 * Not all buffers are resizeable.
56 */
58set_size(int x, int y) {
59 if ((_creation_flags & GraphicsPipe::BF_resizeable) == 0) {
60 nassert_raise("Cannot resize buffer unless it is created with BF_resizeable flag");
61 return;
62 }
64}
65
66/**
67 * This is called by the GraphicsEngine to request that the buffer (or
68 * whatever) open itself or, in general, make itself valid, at the next call
69 * to process_events().
70 */
73 _open_request = OR_open;
74}
75
76/**
77 * This is called by the GraphicsEngine to request that the buffer (or
78 * whatever) close itself or, in general, make itself invalid, at the next
79 * call to process_events(). By that time we promise the gsg pointer will be
80 * cleared.
81 */
84 _open_request = OR_none;
85}
86
87/**
88 * This is called by the GraphicsEngine to insist that the buffer be closed
89 * immediately. This is only called from the buffer thread.
90 */
93 _open_request = OR_none;
94 close_buffer();
95}
96
97/**
98 * Honor any requests recently made via request_open() or request_close().
99 *
100 * This function is called only within the window thread.
101 */
104 // Save the current request and reset it immediately, in case we end up
105 // calling recursively back into this function.
106 OpenRequest this_request = _open_request;
107 _open_request = OR_none;
108
109 switch (this_request) {
110 case OR_none:
111 return;
112
113 case OR_open:
114 if (open_buffer()) {
115 _is_valid = true;
116 set_inverted(_gsg->get_copy_texture_inverted());
117 }
118 break;
119
120 case OR_close:
121 close_buffer();
122 break;
123 }
124}
125
126/**
127 * Closes the buffer right now. Called from the window thread.
128 */
129void GraphicsBuffer::
130close_buffer() {
131 display_cat.info()
132 << "Closing " << get_type() << "\n";
133}
134
135/**
136 * Opens the buffer right now. Called from the window thread. Returns true
137 * if the buffer is successfully opened, or false if there was a problem.
138 */
139bool GraphicsBuffer::
140open_buffer() {
141 return false;
142}
A container for the various kinds of properties we might ask to have on a graphics frameBuffer before...
virtual void process_events()
Honor any requests recently made via request_open() or request_close().
virtual void set_size(int x, int y)
This is called by the GraphicsEngine to request that the buffer resize itself.
virtual void request_close()
This is called by the GraphicsEngine to request that the buffer (or whatever) close itself or,...
virtual void set_close_now()
This is called by the GraphicsEngine to insist that the buffer be closed immediately.
virtual void request_open()
This is called by the GraphicsEngine to request that the buffer (or whatever) open itself or,...
This class is the main interface to controlling the render process.
This is a base class for the various different classes that represent the result of a frame of render...
set_inverted
Changes the current setting of the inverted flag.
void set_size_and_recalc(int x, int y)
Changes the x_size and y_size, then recalculates structures that depend on size.
An object to create GraphicsOutputs that share a particular 3-D API.
Encapsulates all the communication with a particular instance of a given rendering backend.
static void update_type(ReferenceCount *ptr, TypeHandle type)
Associates the indicated type with the given pointer.
Definition memoryUsage.I:55
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
A container for the various kinds of properties we might ask to have on a graphics window before we o...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.