G3D::SDLWindow Class ReferenceAn implementation of G3D::Window that uses the Open Source SDL library.
More...
#include <SDLWindow.h>
Inherits G3D::GWindow.
List of all members.
|
Public Member Functions |
| virtual std::string | caption () |
| 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 &p, uint8 &mouseButtons) const |
| ::SDL_Joystick * | getSDL_Joystick (unsigned int num) const |
| virtual void | getSettings (GWindow::Settings &settings) const |
| virtual bool | hasFocus () const |
| virtual int | height () const |
| virtual void | incInputCaptureCount () |
| virtual void | incMouseHideCount () |
| int | inputCaptureCount () const |
| virtual std::string | joystickName (unsigned int sticknum) |
| void | makeCurrent () const |
| int | mouseHideCount () 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 () |
| | SDLWindow (const GWindow::Settings &settings) |
| 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) |
| void | setInputCaptureCount (int c) |
| void | setMouseHideCount (int c) |
| 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 |
| Display * | x11Display () const |
| Window | x11Window () const |
| virtual | ~SDLWindow () |
Static Public Member Functions |
| static const GWindow * | current () |
Protected Member Functions |
| void | executeLoopBody () |
| bool | notDone () |
| virtual bool | pollOSEvent (GEvent &e) |
| virtual void | reallyMakeCurrent () const |
| virtual void | setInputCapture (bool c) |
| virtual void | setMouseVisible (bool b) |
Protected Attributes |
| Array< std::string > | m_droppedFiles |
| int | m_inputCaptureCount |
| int | m_mouseHideCount |
Detailed Description
An implementation of G3D::Window that uses the Open Source SDL library.
Works on Windows, Linux, and OS/X.
On Windows, centering is relative to the primary monitor and full-screen means on the primary monitor.
- Deprecated:
- on Windows, use Win32Window instead. SDL will not be supported (or required) on Windows in future versions of G3D. It will be available for Mac and Linux (and will still work on Windows, but it won't be part of the build).
Constructor & Destructor Documentation
| virtual G3D::SDLWindow::~SDLWindow |
( |
|
) |
[virtual] |
Member Function Documentation
| virtual std::string G3D::SDLWindow::caption |
( |
|
) |
[virtual] |
| 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::SDLWindow::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::SDLWindow::getAPIName |
( |
|
) |
const [virtual] |
Description of the windowing API for logging purposes (e.g.
"SDL").
Implements G3D::GWindow.
| virtual std::string G3D::SDLWindow::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::SDLWindow::getDroppedFilenames |
( |
Array< std::string > & |
files |
) |
[virtual] |
| virtual void G3D::SDLWindow::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::SDLWindow::getRelativeMouseState |
( |
double & |
x, |
|
|
double & |
y, |
|
|
uint8 & |
mouseButtons | |
|
) |
| | const [virtual] |
| virtual void G3D::SDLWindow::getRelativeMouseState |
( |
int & |
x, |
|
|
int & |
y, |
|
|
uint8 & |
mouseButtons | |
|
) |
| | const [virtual] |
| virtual void G3D::SDLWindow::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.
| ::SDL_Joystick* G3D::SDLWindow::getSDL_Joystick |
( |
unsigned int |
num |
) |
const |
Returns the underlying SDL joystick pointer.
| virtual void G3D::SDLWindow::getSettings |
( |
GWindow::Settings & |
settings |
) |
const [virtual] |
Return the actual properties of this window (as opposed to the desired settings from which it was initialized).
Implements G3D::GWindow.
| virtual bool G3D::SDLWindow::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.
| virtual int G3D::SDLWindow::height |
( |
|
) |
const [virtual] |
| virtual void G3D::GWindow::incInputCaptureCount |
( |
|
) |
[inline, virtual, inherited] |
| virtual void G3D::GWindow::incMouseHideCount |
( |
|
) |
[inline, virtual, inherited] |
| 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::SDLWindow::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.
| bool G3D::GWindow::notDone |
( |
|
) |
[inline, protected, inherited] |
| virtual void G3D::SDLWindow::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::SDLWindow::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 bool G3D::SDLWindow::pollOSEvent |
( |
GEvent & |
e |
) |
[protected, virtual] |
Extract one event from the underlying operating system.
Reimplemented from G3D::GWindow.
| 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::SDLWindow::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::GWindow::requiresMainLoop |
( |
|
) |
const [inline, virtual, inherited] |
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 in G3D::CarbonWindow, and G3D::Win32Window.
| 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::SDLWindow::setCaption |
( |
const std::string & |
caption |
) |
[virtual] |
| virtual void G3D::SDLWindow::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::SDLWindow::setGammaRamp |
( |
const Array< uint16 > & |
gammaRamp |
) |
[virtual] |
| virtual void G3D::GWindow::setIcon |
( |
const std::string & |
imageFilename |
) |
[inline, virtual, inherited] |
| virtual void G3D::SDLWindow::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::SDLWindow::setInputCapture |
( |
bool |
c |
) |
[protected, 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::SDLWindow::setMouseVisible |
( |
bool |
b |
) |
[protected, virtual] |
| virtual void G3D::SDLWindow::setPosition |
( |
int |
x, |
|
|
int |
y | |
|
) |
| | [virtual] |
Fails silently if unable to change the position.
Sets the window (not client) position.
Implements G3D::GWindow.
| virtual void G3D::SDLWindow::setRelativeMousePosition |
( |
const Vector2 & |
p |
) |
[virtual] |
| virtual void G3D::SDLWindow::setRelativeMousePosition |
( |
double |
x, |
|
|
double |
y | |
|
) |
| | [virtual] |
| virtual void G3D::SDLWindow::swapGLBuffers |
( |
|
) |
[virtual] |
| virtual int G3D::SDLWindow::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.
| Display* G3D::SDLWindow::x11Display |
( |
|
) |
const |
| Window G3D::SDLWindow::x11Window |
( |
|
) |
const |
Member Data Documentation
The documentation for this class was generated from the following file:
Generated on Thu Aug 2 11:40:47 2007 for G3D by
1.5.2
Hosted by
|