2 * Copyright 2012 Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
6 * John Scipione, jscipione@gmail.com
9 * src/kits/game/DirectWindow.cpp hrev45044
10 * src/kits/game/DirectWindow.h hrev45044
18 \brief Provides the BDirectWindow class.
23 \enum direct_buffer_state
25 Direct buffer state constants
32 \enum direct_driver_state
34 Direct driver state constants
41 \struct direct_buffer_info
45 Direct butter info struct
52 \var direct_buffer_info::buffer_state
54 State of the direct buffer access privileges.
55 It can have one of the following values:
56 - \c B_DIRECT_MODE_MASK
63 - \c B_CLIPPING_MODIFIED
70 \var direct_buffer_info::driver_state
72 State of the graphics card on which your direct window is displayed.
73 There are two possible values:
74 - \c B_MODE_CHANGED The resolution or color depth has changed.
75 - \c B_DRIVER_CHANGED The window was moved onto another monitor.
82 \var direct_buffer_info::bits
84 Pointer to the frame buffer in your team's memory space.
91 \var direct_buffer_info::pci_bits
93 Pointer to the frame buffer in the PCI memory space. This value is
94 typically needed to control DMA.
101 \var direct_buffer_info::bytes_per_row
103 Number of bytes used to represent a single row of pixels in the frame buffer.
110 \var direct_buffer_info::bits_per_pixel
112 Number of bits actually used to store a single pixel, including reserved,
113 unused, or alpha channel bits. This value is usually a multiple of eight.
120 \var direct_buffer_info::pixel_format
122 The format used to encode a pixel as defined by the \c color_space type.
129 \var direct_buffer_info::layout
131 Reserved for future use.
138 \var direct_buffer_info::orientation
140 Reserved for future use.
147 \var direct_buffer_info::_reserved[9]
149 Reserved for future use.
156 \var direct_buffer_info::_dd_type_
158 Reserved for future use.
165 \var direct_buffer_info::_dd_token_
167 Reserved for future use.
174 \var direct_buffer_info::clip_list_count
176 Number of rectangles in \c clip_list.
183 \var direct_buffer_info::window_bounds
185 Rectangle that defines the full content area of the window in screen
193 \var direct_buffer_info::clip_bounds
195 Bounding rectangle of the visible part of the content area of the window
196 in screen coordinates.
203 \var direct_buffer_info::clip_list
205 List of rectangles that together define the visible region of the content
206 area of the window in screen coordinates.
216 \brief Provides direct access to the video card graphics frame buffer.
223 \fn BDirectWindow::BDirectWindow(BRect frame, const char* title,
224 window_type type, uint32 flags, uint32 workspace)
225 \brief Creates and initializes a BDirectWindow object.
227 \param frame The initial frame rectangle of the window.
228 \param title The title of the Window.
229 \param type Window type (see BWindow).
230 \param flags Window flags (see BWindow).
231 \param workspace Workspace of the direct window (see BWindow).
238 \fn BDirectWindow::BDirectWindow(BRect frame, const char* title,
239 window_look look, window_feel feel, uint32 flags, uint32 workspace)
240 \brief Creates and initializes a BDirectWindow object.
242 \param frame The initial frame rectangle of the window.
243 \param title The title of the Window.
244 \param look Window look (see BWindow).
245 \param feel Window feel (see BWindow).
246 \param flags Window flags (see BWindow).
247 \param workspace Workspace of the direct window (see BWindow).
254 \fn BDirectWindow::~BDirectWindow()
255 \brief Destroys the BDirectWindow and frees all memory used by it.
257 Do not delete a BDirectWindow object directly, call Quit() instead.
259 Destroying a BDirectWindow involves a few steps to make sure that it
260 is disconnected and cleaned up.
262 Set the fConnectionDisabled flag to \c true to prevent DirectConnected()
263 from attempting to reconnect while it's being destroyed.
265 next call Hide() and finally Sync() to force the direct window to
266 disconnect from direct access.
268 Once these steps are complete you may do your usual destructor work.
275 \fn BArchivable* BDirectWindow::Instantiate(BMessage* data)
276 \brief Instantiate window from message \a data. Not implemented.
283 \fn status_t BDirectWindow::Archive(BMessage* data, bool deep) const
284 \brief Archive window into message \a data. Not implemented.
291 \fn void BDirectWindow::DirectConnected(direct_buffer_info* info)
292 \brief Hook method called when your application learns about the state
293 of the graphics display and changes occur.
295 This is the heart of BDirectWindow.
297 \param info The \c direct_buffer_info struct
304 \fn status_t BDirectWindow::GetClippingRegion(BRegion* region,
305 BPoint* origin) const
306 \brief Sets \a region to the current clipping region of the direct window.
308 If \a origin is not \c NULL, the \a region is offset by \a origin.
310 \warning GetClippingRegion() should only be called from within the
311 DirectConnected() method. If called outside GetClippingRegion()
312 will return \c B_ERROR.
314 \param region The clipping region to fill out.
315 \param origin An origin to offset the region by.
317 \returns A status code.
318 \retval B_OK Everything went as expected.
319 \retval B_BAD_VALUE \a region was NULL.
320 \retval B_ERROR Window not locked or not in DirectConnected() method.
321 \retval B_NO_MEMORY Not enough memory to fill \a region
328 \fn status_t BDirectWindow::SetFullScreen(bool enable)
329 \brief Enables or disables full-screen mode.
331 The SupportsWindowMode() method determines whether or not the video card
332 is capable of supporting windowed mode.
334 When the window is in full screen mode it will always have the focus and
335 no other window can be in front of it.
337 \param enable \c true to enable fullscreen mode, \c false for windowed mode.
339 \returns A status code.
340 \retval B_OK Everything went as expected.
341 \retval B_ERROR An error occurred while trying to switch between full screen
344 \see BDirectWindow::SupportsWindowMode()
351 \fn bool BDirectWindow::IsFullScreen() const
352 \brief Returns whether the window is in full-screen or windowed mode.
354 \returns \c true if in full-screen mode, \c false if in windowed mode.
361 \fn static bool BDirectWindow::SupportsWindowMode(screen_id id)
362 \brief Returns whether or not the specified screen supports windowed mode.
364 Because this is a static function you don't have to construct a
365 BDirectWindow object to call it.
367 \param id The id of the screen you want to check, \c B_MAIN_SCREEN_ID by
370 \returns \c true if the screen support windowed mode, \c false otherwise.