15 #include "pandabase.h"
19 #include "tinyWinGraphicsWindow.h"
20 #include "config_tinydisplay.h"
21 #include "config_windisplay.h"
22 #include "tinyWinGraphicsPipe.h"
23 #include "tinyGraphicsStateGuardian.h"
24 #include "pStatTimer.h"
28 TypeHandle TinyWinGraphicsWindow::_type_handle;
35 TinyWinGraphicsWindow::
47 update_pixel_factor();
55 TinyWinGraphicsWindow::
56 ~TinyWinGraphicsWindow() {
68 bool TinyWinGraphicsWindow::
69 begin_frame(FrameMode mode,
Thread *current_thread) {
70 begin_frame_spam(mode);
75 if (!get_unexposed_draw() && !_got_expose_event) {
76 if (tinydisplay_cat.is_spam()) {
77 tinydisplay_cat.spam()
78 <<
"Not drawing " <<
this <<
": unexposed.\n";
84 DCAST_INTO_R(tinygsg, _gsg,
false);
86 tinygsg->_current_frame_buffer = _frame_buffer;
89 _gsg->set_current_properties(&get_fb_properties());
90 return _gsg->begin_frame(current_thread);
100 void TinyWinGraphicsWindow::
101 end_frame(FrameMode mode,
Thread *current_thread) {
102 end_frame_spam(mode);
105 if (mode == FM_render) {
110 _gsg->end_frame(current_thread);
112 if (mode == FM_render) {
114 clear_cube_map_selection();
128 void TinyWinGraphicsWindow::
135 HBITMAP bm = CreateCompatibleBitmap(_hdc, _frame_buffer->xsize, _frame_buffer->ysize);
136 HDC bmdc = CreateCompatibleDC(_hdc);
137 SelectObject(bmdc, bm);
139 int fb_xsize = get_fb_x_size();
140 int fb_ysize = get_fb_y_size();
141 int fb_ytop = _frame_buffer->ysize - fb_ysize;
143 SetDIBits(_hdc, bm, fb_ytop, fb_ysize, _frame_buffer->pbuf,
144 &_bitmap_info, DIB_RGB_COLORS);
146 if (fb_xsize == _frame_buffer->xsize) {
147 BitBlt(_hdc, 0, 0, fb_xsize, fb_ysize,
148 bmdc, 0, 0, SRCCOPY);
151 StretchBlt(_hdc, 0, 0, _frame_buffer->xsize, _frame_buffer->ysize,
152 bmdc, 0, 0,fb_xsize, fb_ysize,
176 bool TinyWinGraphicsWindow::
177 supports_pixel_zoom()
const {
187 void TinyWinGraphicsWindow::
191 DCAST_INTO_V(tinygsg, _gsg);
192 tinygsg->_current_frame_buffer = NULL;
196 ReleaseDC(_hWnd, _hdc);
198 WinGraphicsWindow::close_window();
208 bool TinyWinGraphicsWindow::
210 if (!WinGraphicsWindow::open_window()) {
221 DCAST_INTO_R(tinygsg, _gsg,
false);
226 create_frame_buffer();
227 if (_frame_buffer == NULL) {
228 tinydisplay_cat.error()
229 <<
"Could not create frame buffer.\n";
233 tinygsg->_current_frame_buffer = _frame_buffer;
251 void TinyWinGraphicsWindow::
253 WinGraphicsWindow::handle_reshape();
254 if (_frame_buffer != NULL) {
255 ZB_resize(_frame_buffer, NULL, _properties.get_x_size(), _properties.get_y_size());
267 bool TinyWinGraphicsWindow::
268 do_fullscreen_resize(
int x_size,
int y_size) {
269 bool result = WinGraphicsWindow::do_fullscreen_resize(x_size, y_size);
270 ZB_resize(_frame_buffer, NULL, _properties.get_x_size(), _properties.get_y_size());
281 void TinyWinGraphicsWindow::
282 create_frame_buffer() {
283 if (_frame_buffer != NULL) {
284 ZB_close(_frame_buffer);
285 _frame_buffer = NULL;
288 _frame_buffer = ZB_open(_properties.get_x_size(), _properties.get_y_size(), ZB_MODE_RGBA, 0, 0, 0, 0);
298 void TinyWinGraphicsWindow::
299 setup_bitmap_info() {
300 _bitmap_info.bmiHeader.biSize =
sizeof(BITMAPINFOHEADER);
301 _bitmap_info.bmiHeader.biWidth = _frame_buffer->xsize;
302 _bitmap_info.bmiHeader.biHeight = -_frame_buffer->ysize;
303 _bitmap_info.bmiHeader.biPlanes = 1;
304 _bitmap_info.bmiHeader.biBitCount = 32;
305 _bitmap_info.bmiHeader.biCompression = BI_RGB;
306 _bitmap_info.bmiHeader.biSizeImage = _frame_buffer->linesize * _frame_buffer->ysize;
307 _bitmap_info.bmiHeader.biXPelsPerMeter = 0;
308 _bitmap_info.bmiHeader.biYPelsPerMeter = 0;
309 _bitmap_info.bmiHeader.biClrUsed = 0;
310 _bitmap_info.bmiHeader.biClrImportant = 0;
virtual void end_flip()
This function will be called within the draw thread after begin_flip() has been called on all windows...
bool reset_if_new()
Calls reset() to initialize the GSG, but only if it hasn't been called yet.
bool is_valid() const
Returns true if the GSG has been correctly initialized within a graphics context, false if there has ...
A container for the various kinds of properties we might ask to have on a graphics window before we o...
An abstract base class for glGraphicsWindow and dxGraphicsWindow (and, in general, graphics windows that interface with the Microsoft Windows API).
An object to create GraphicsOutputs that share a particular 3-D API.
This is a base class for the various different classes that represent the result of a frame of render...
A thread; that is, a lightweight process.
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.
A container for the various kinds of properties we might ask to have on a graphics frameBuffer before...
An interface to the TinyPanda software rendering code within this module.