|
G3D::Win32Window Class Reference#include <Win32Window.h>
Inherits G3D::GWindow.
List of all members.
|
Public Member Functions |
| virtual std::string | caption () |
| void | close () |
| virtual void | decInputCaptureCount () |
| virtual void | decMouseHideCount () |
| virtual Rect2D | dimensions () const |
| virtual void | fireEvent (const GEvent &event) |
| virtual std::string | getAPIName () const |
| virtual std::string | getAPIVersion () const |
| virtual void | getDroppedFilenames (Array< std::string > &files) |
| virtual void | getJoystickState (unsigned int stickNum, Array< float > &axis, Array< bool > &button) |
| virtual void | getRelativeMouseState (double &x, double &y, uint8 &mouseButtons) const |
| virtual void | getRelativeMouseState (int &x, int &y, uint8 &mouseButtons) const |
| virtual void | getRelativeMouseState (Vector2 &position, uint8 &mouseButtons) const |
| void | getSettings (GWindow::Settings &settings) const |
| virtual bool | hasFocus () const |
| HDC | hdc () const |
| virtual int | height () const |
| HWND | hwnd () const |
| virtual void | incInputCaptureCount () |
| virtual void | incMouseHideCount () |
| virtual bool | inputCapture () const |
| int | inputCaptureCount () const |
| virtual std::string | joystickName (unsigned int sticknum) |
| void | makeCurrent () const |
| int | mouseHideCount () const |
| virtual bool | mouseVisible () const |
| virtual void | notifyResize (int w, int h) |
| virtual int | numJoysticks () const |
| virtual bool | pollEvent (GEvent &e) |
| virtual void | popLoopBody () |
| virtual void | pushLoopBody (GApp *app) |
| virtual void | pushLoopBody (void(*body)(void *), void *arg) |
| RenderDevice * | renderDevice () const |
| virtual bool | requiresMainLoop () const |
| virtual void | runMainLoop () |
| virtual void | setCaption (const std::string &caption) |
| virtual void | setDimensions (const Rect2D &dims) |
| virtual void | setGammaRamp (const Array< uint16 > &gammaRamp) |
| virtual void | setIcon (const std::string &imageFilename) |
| virtual void | setIcon (const GImage &image) |
| virtual void | setInputCapture (bool c) |
| void | setInputCaptureCount (int c) |
| void | setMouseHideCount (int c) |
| virtual void | setMouseVisible (bool b) |
| virtual void | setPosition (int x, int y) |
| virtual void | setRelativeMousePosition (const Vector2 &p) |
| virtual void | setRelativeMousePosition (double x, double y) |
| virtual void | swapGLBuffers () |
| virtual int | width () const |
| virtual | ~Win32Window () |
Static Public Member Functions |
| static Win32Window * | create (const GWindow::Settings &settings, HDC hdc) |
| static Win32Window * | create (const GWindow::Settings &settings, HWND hwnd) |
| static Win32Window * | create (const GWindow::Settings &settings=GWindow::Settings()) |
| static const GWindow * | current () |
Protected Member Functions |
| void | executeLoopBody () |
| bool | notDone () |
| virtual void | reallyMakeCurrent () const |
Protected Attributes |
| Queue< GEvent > | m_eventQueue |
| int | m_inputCaptureCount |
| int | m_mouseHideCount |
Friends |
| LRESULT WINAPI | _internal::window_proc (HWND window, UINT message, WPARAM wparam, LPARAM lparam) |
Constructor & Destructor Documentation
| virtual G3D::Win32Window::~Win32Window |
( |
|
) |
[virtual] |
Finds the closest match to the desired GWindowSettings.
The width and height fields always refer to full-screen resolution.
Only width, height, rgbBits, alphaBits, depthBits, stencilBits, fsaaSamples, stereo and refreshRate are valid.
Member Function Documentation
| virtual std::string G3D::Win32Window::caption |
( |
|
) |
[virtual] |
| void G3D::Win32Window::close |
( |
|
) |
|
The HDC should be a private CS_OWNDC device context because it is assumed to be perisistant.
Different subclasses will be returned depending on whether DirectInput8 is available.
You must delete the window returned when you are done with it.
| static const GWindow* G3D::GWindow::current |
( |
|
) |
[inline, static, inherited] |
| virtual void G3D::GWindow::decInputCaptureCount |
( |
|
) |
[inline, virtual, inherited] |
| virtual void G3D::GWindow::decMouseHideCount |
( |
|
) |
[inline, virtual, inherited] |
| virtual Rect2D G3D::Win32Window::dimensions |
( |
|
) |
const [virtual] |
Shape of the client area of the window in screen coordinates.
Implements G3D::GWindow.
| void G3D::GWindow::executeLoopBody |
( |
|
) |
[protected, inherited] |
Subclasses should call from their idle function.
| virtual void G3D::GWindow::fireEvent |
( |
const GEvent & |
event |
) |
[virtual, inherited] |
Inserts an event into the queue.
| virtual std::string G3D::Win32Window::getAPIName |
( |
|
) |
const [virtual] |
Description of the windowing API for logging purposes (e.g.
"SDL").
Implements G3D::GWindow.
| virtual std::string G3D::Win32Window::getAPIVersion |
( |
|
) |
const [virtual] |
Description of the windowing API for logging purposes (e.g.
"1.2.7" for SDL 1.2.7).
Implements G3D::GWindow.
| virtual void G3D::Win32Window::getDroppedFilenames |
( |
Array< std::string > & |
files |
) |
[virtual] |
| virtual void G3D::Win32Window::getJoystickState |
( |
unsigned int |
stickNum, |
|
|
Array< float > & |
axis, |
|
|
Array< bool > & |
button | |
|
) |
| | [virtual] |
Returns the state of the given joystick.
Not all sticks support all buttons and axes and frequently the state of one stick overlaps the state of another. An asserition fails if stickNum > numJoysticks(). Joystick axes are normalized to the range [-1, 1] (but might not be calibrated...). Joystick axes should be in the starting order: X, Y, Z, Slider1, Slider2, rX, rY, rZ
Implements G3D::GWindow.
| virtual void G3D::Win32Window::getRelativeMouseState |
( |
double & |
x, |
|
|
double & |
y, |
|
|
uint8 & |
mouseButtons | |
|
) |
| | const [virtual] |
| virtual void G3D::Win32Window::getRelativeMouseState |
( |
int & |
x, |
|
|
int & |
y, |
|
|
uint8 & |
mouseButtons | |
|
) |
| | const [virtual] |
| virtual void G3D::Win32Window::getRelativeMouseState |
( |
Vector2 & |
position, |
|
|
uint8 & |
mouseButtons | |
|
) |
| | const [virtual] |
Returns the current mouse position and the state of the mouse buttons.
It is essential to sample both simultaneously so that the mouse has not moved from the location where a click occurred.
- Parameters:
-
| position | In pixels, with y=up. Relative to the upper left corner of the window. |
| mouseButtons | If button i is currently pressed then bit i is set. |
Implements G3D::GWindow.
Return the actual properties of this window (as opposed to the desired settings from which it was initialized).
Implements G3D::GWindow.
| virtual bool G3D::Win32Window::hasFocus |
( |
|
) |
const [virtual] |
Returns true if this window currently has [keyboard] focus (i.e.
is in the foreground, not minimized, recieves keystrokes.)
Implements G3D::GWindow.
| HDC G3D::Win32Window::hdc |
( |
|
) |
const [inline] |
| virtual int G3D::Win32Window::height |
( |
|
) |
const [virtual] |
| HWND G3D::Win32Window::hwnd |
( |
|
) |
const [inline] |
| virtual void G3D::GWindow::incInputCaptureCount |
( |
|
) |
[inline, virtual, inherited] |
| virtual void G3D::GWindow::incMouseHideCount |
( |
|
) |
[inline, virtual, inherited] |
| virtual bool G3D::Win32Window::inputCapture |
( |
|
) |
const [virtual] |
| int G3D::GWindow::inputCaptureCount |
( |
|
) |
const [inline, inherited] |
If the count is 1 or greater, then the keyboard and mouse focus is captured, locking the mouse to the client area of this window.
The use of a count instead of an explicit capture/release API allows multiple parts of a program to capture input without accidentally releasing and enclosing capture.
| virtual std::string G3D::Win32Window::joystickName |
( |
unsigned int |
sticknum |
) |
[virtual] |
The name by which the OS refers to this joystick (e.g.
"Gravis Gamepad")
Implements G3D::GWindow.
| void G3D::GWindow::makeCurrent |
( |
|
) |
const [inline, inherited] |
Makes the OpenGL context of this window current.
If you have multiple windows, call this before rendering to one of them. beta
| int G3D::GWindow::mouseHideCount |
( |
|
) |
const [inline, inherited] |
If the count is 1 or greater, then the keyboard and mouse focus is captured, locking the mouse to the client area of this window.
The use of a count instead of an explicit capture/release API allows multiple parts of a program to capture input without accidentally releasing and enclosing capture.
| virtual bool G3D::Win32Window::mouseVisible |
( |
|
) |
const [virtual] |
| bool G3D::GWindow::notDone |
( |
|
) |
[inline, protected, inherited] |
| virtual void G3D::Win32Window::notifyResize |
( |
int |
w, |
|
|
int |
h | |
|
) |
| | [virtual] |
Notifies the window that it has been resized (called by RenderDevice::notifyResize).
Some window systems (e.g. SDL) need explicit notification in this form when a resize event comes in.
Must not destroy the underlying OpenGL context (i.e. textures, vertex buffers, and GPU programs must be preserved across calls).
Implements G3D::GWindow.
| virtual int G3D::Win32Window::numJoysticks |
( |
|
) |
const [virtual] |
Returns 0 if there are no joysticks available.
Implements G3D::GWindow.
| virtual bool G3D::GWindow::pollEvent |
( |
GEvent & |
e |
) |
[virtual, inherited] |
Checks to see if any events are waiting.
If there is an event, returns true and fills out the GEvent structure. Otherwise returns false. The caller is responsible for invoking GWindow::notifyResize with any resize events; the GWindow does not notify itself.
| virtual void G3D::GWindow::popLoopBody |
( |
|
) |
[virtual, inherited] |
Pops a loop body off the stack.
If the loop body was a GApplet, invokes GApplet::endRun on it. If the loop body was a GApp2, invokes GApp2::endRun on it.
| virtual void G3D::GWindow::pushLoopBody |
( |
GApp * |
app |
) |
[virtual, inherited] |
Invokes GApplet::beginRun after the applet is on the stack.
| virtual void G3D::GWindow::pushLoopBody |
( |
void(*)(void *) |
body, |
|
|
void * |
arg | |
|
) |
| | [inline, virtual, inherited] |
Pushes a function onto the stack of functions called by runMainLoop.
| virtual void G3D::Win32Window::reallyMakeCurrent |
( |
|
) |
const [protected, virtual] |
Override this with the glMakeCurrent call appropriate for your window.
Reimplemented from G3D::GWindow.
| RenderDevice* G3D::GWindow::renderDevice |
( |
|
) |
const [inline, inherited] |
If a RenderDevice has been created and initialized for this window, returns that renderDevice.
Otherwise returns NULL.
| virtual bool G3D::Win32Window::requiresMainLoop |
( |
|
) |
const [virtual] |
Windows for which this is true require a program to hand control of the main loop to GWindow::startMainLoop.
The program's functionality may then be implemented through the "loop body" function.
That is, if requiresMainLoop returns true, you must use the following structure:
void doEvents() {
GEvent e;
while (window->pollEvent(e)) {
... // Event handling
}
}
void doGraphics() {
renderDevice->beginFrame();
renderDevice->clear(true, true, true);
... // draw stuff
renderDevice->endFrame();
}
void loopBody(void*) {
all per-frame code; event-handling, physics, networking, AI, etc.
doEvents();
doLogic();
doNetwork();
doAI();
doGraphics();
To end the program, invoke window->popLoopBody
}
window->pushLoopBody(callback, NULL);
window->runMainLoop(); // doesn't return
When requiresMainLoop returns false, you may use either the above structure or the following one (which puts you in more control of when graphics vs. other code is executed):
while (true) {
doEvents();
doLogic();
doNetwork();
doAI();
doGraphics();
}
This design is necessary because some underlying Window APIs (e.g. ActiveX, GLUT) enforce an event-driven structure.
Reimplemented from G3D::GWindow.
| virtual void G3D::GWindow::runMainLoop |
( |
|
) |
[inline, virtual, inherited] |
Executes an event loop, invoking callback repeatedly.
Put everything that you want to execute once per frame into the callback function. It is guaranteed safe to call pollEvents and all other GWindow methods from the callback function.
The default implementation (for requiresMainLoop() == false GWindows) just calls the callback continuously. Subclasses should use the notDone() and executeLoopBody() functions.
| virtual void G3D::Win32Window::setCaption |
( |
const std::string & |
caption |
) |
[virtual] |
| virtual void G3D::Win32Window::setDimensions |
( |
const Rect2D & |
dims |
) |
[virtual] |
Fails silently if unable to change the dimensions.
The value returned by getSettings will not change immediately-- it waits for a notifyResize call.
Implements G3D::GWindow.
| virtual void G3D::Win32Window::setGammaRamp |
( |
const Array< uint16 > & |
gammaRamp |
) |
[virtual] |
| virtual void G3D::GWindow::setIcon |
( |
const std::string & |
imageFilename |
) |
[inline, virtual, inherited] |
| virtual void G3D::Win32Window::setIcon |
( |
const GImage & |
image |
) |
[virtual] |
Set the icon (if supported).
Fails silently if not supported or the window has no frame. May also fail if the GWindow implementation's underlying GUI library is too limited. - Parameters:
-
| image | May have any dimension supported by underlying OS. |
Reimplemented from G3D::GWindow.
| virtual void G3D::Win32Window::setInputCapture |
( |
bool |
c |
) |
[virtual] |
Capture the keyboard and mouse focus, locking the mouse to the client area of this window.
Sets the inputCaptureCount to 1 if c is true and 0 if c is false - Deprecated:
- use setInputCaptureCount
Implements G3D::GWindow.
| void G3D::GWindow::setInputCaptureCount |
( |
int |
c |
) |
[inline, inherited] |
| void G3D::GWindow::setMouseHideCount |
( |
int |
c |
) |
[inline, inherited] |
| virtual void G3D::Win32Window::setMouseVisible |
( |
bool |
b |
) |
[virtual] |
| virtual void G3D::Win32Window::setPosition |
( |
int |
x, |
|
|
int |
y | |
|
) |
| | [inline, virtual] |
Fails silently if unable to change the position.
Sets the window (not client) position.
Implements G3D::GWindow.
| virtual void G3D::Win32Window::setRelativeMousePosition |
( |
const Vector2 & |
p |
) |
[virtual] |
| virtual void G3D::Win32Window::setRelativeMousePosition |
( |
double |
x, |
|
|
double |
y | |
|
) |
| | [virtual] |
| virtual void G3D::Win32Window::swapGLBuffers |
( |
|
) |
[virtual] |
| virtual int G3D::Win32Window::width |
( |
|
) |
const [virtual] |
Measured in pixels, this is the client area of the window.
Returns the same width as getSettings and dimensions(). Convenience method for users.
Implements G3D::GWindow.
Friends And Related Function Documentation
| LRESULT WINAPI _internal::window_proc |
( |
HWND |
window, |
|
|
UINT |
message, |
|
|
WPARAM |
wparam, |
|
|
LPARAM |
lparam | |
|
) |
| | [friend] |
Member Data Documentation
The documentation for this class was generated from the following file:
Generated on Thu Aug 2 11:40:48 2007 for G3D by
1.5.2
Hosted by
| |